/* ==========================================================
   Support desk: design tokens ("look E", soft cards)
   Accent: Lime. Change the tokens here and the whole app follows.
   Light set first; the dark set is repeated for the system
   setting and for the manual switch (data-theme="dark").
   ========================================================== */
:root {
  --font: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  --display: "Outfit", "Inter", -apple-system, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, monospace;

  --accent: #e4f39a;        /* lime */
  --accent-ink: #1b1d12;
  --accent-soft: #eef7c8;

  --outer: #c9d2cb;         /* sage page background */
  --frame: #eef0ed;         /* the rounded app frame, soft fills */
  --card: #ffffff;
  --ink: #16181a;
  --muted: #6a6f6b;
  --line: #e2e5e1;
  --line2: #c9cec9;
  --sel: #f3f5f2;           /* hover / open row */
  --sel-accent: #f6f9e4;    /* selected (checked) row */
  --rail: #16181a;
  --rail-ink: #ffffff;
  --rail-muted: #8b908c;
  --rail-active: #2d3133;
  --btn: #16181a;           /* black pill buttons */
  --btn-ink: #ffffff;
  --bar-btn: #2d3133;       /* buttons on the black bulk bar */
  --dark: #16181a;          /* dark stat / activity cards */
  --dark-ink: #ffffff;
  --note-bg: #f6f9df;       /* internal notes */

  --urgent: #b42318; --urgent-soft: #fde8e6;
  --warn: #b7791f;   --warn-soft: #fbf0d9;
  --ok: #3f7d4e;     --ok-soft: #e1efe3;

  --shadow: 0 10px 30px rgba(22, 24, 26, .14), 0 2px 6px rgba(22, 24, 26, .06);
  --r-card: 22px;
  --r-row: 14px;
  --pad: 28px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --accent-soft: #2f3424;
    --outer: #0b0d0c; --frame: #141716; --card: #1c201e; --ink: #eef0ed; --muted: #9aa19c;
    --line: #2c312e; --line2: #3a403c; --sel: #242926; --sel-accent: #262b20;
    --rail: #060707; --rail-muted: #7c827e; --rail-active: #232726;
    --btn: #eef0ed; --btn-ink: #16181a; --bar-btn: #c9cec9; --dark: #2a2f2c; --note-bg: #2a2d22;
    --urgent: #f08a7e; --urgent-soft: #3a201d; --warn: #e0b04f; --warn-soft: #3a3019; --ok: #7cc48d; --ok-soft: #1d3324;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --accent-soft: #2f3424;
  --outer: #0b0d0c; --frame: #141716; --card: #1c201e; --ink: #eef0ed; --muted: #9aa19c;
  --line: #2c312e; --line2: #3a403c; --sel: #242926; --sel-accent: #262b20;
  --rail: #060707; --rail-muted: #7c827e; --rail-active: #232726;
  --btn: #eef0ed; --btn-ink: #16181a; --bar-btn: #c9cec9; --dark: #2a2f2c; --note-bg: #2a2d22;
  --urgent: #f08a7e; --urgent-soft: #3a201d; --warn: #e0b04f; --warn-soft: #3a3019; --ok: #7cc48d; --ok-soft: #1d3324;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5), 0 2px 6px rgba(0, 0, 0, .3);
  color-scheme: dark;
}

/* ========================= Base ========================= */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; padding: var(--pad); display: flex;
  height: 100vh; height: 100dvh;
  background: var(--outer); color: var(--ink);
  font: 13px/1.5 var(--font); -webkit-font-smoothing: antialiased;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
h1, h2, h3 { margin: 0; line-height: 1.15; font-weight: 400; }
kbd {
  font: 11px var(--mono); padding: 1px 6px; border-radius: 6px;
  background: var(--frame); color: var(--muted);
}
.i { width: 16px; height: 16px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
[hidden] { display: none !important; }
.grow { flex: 1; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.phone-only { display: none !important; }

/* ========================= Frame + layout ========================= */
.app {
  flex: 1; min-width: 0; min-height: 0; display: flex;
  background: var(--frame); border-radius: 28px; overflow: hidden;
}
.content { flex: 1; min-width: 0; min-height: 0; display: flex; flex-direction: column; padding: 24px 26px 26px 14px; }
.list-panel, .main { flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 16px; }
.app[data-pane="list"] .main { display: none; }
.app[data-pane="today"] .list-panel, .app[data-pane="ticket"] .list-panel { display: none; }

/* ========================= Rail ========================= */
.rail {
  flex: 0 0 64px; margin: 12px; padding: 14px 0; border-radius: 22px; background: var(--rail);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.rail-logo {
  width: 36px; height: 36px; border-radius: 50%; margin-bottom: 14px; padding: 0;
  border: 1.5px solid var(--rail-ink); background: none; color: var(--rail-ink);
  font: 600 14px var(--display); display: grid; place-items: center;
}
.rail-logo.active { background: var(--rail-ink); color: var(--rail); }
.rail-btn {
  width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0;
  background: none; color: var(--rail-muted); display: grid; place-items: center;
}
.rail-btn .i { width: 17px; height: 17px; }
.rail-btn:hover { color: var(--rail-ink); }
.rail-btn.active { background: var(--rail-active); color: var(--rail-ink); }
.rail-gap { flex: 1; }
.me .avatar {
  width: 34px; height: 34px; background: var(--accent); color: var(--accent-ink); font-size: 12px;
}
.me { position: relative; }
.stage-badge {
  display: inline-block; font-size: 9.5px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  padding: 1px 6px; border-radius: 99px; background: var(--accent); color: var(--accent-ink);
}
.me .stage-badge { position: absolute; left: 50%; bottom: -14px; transform: translateX(-50%); }

/* ========================= Pills, buttons ========================= */
.pill, .btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  height: 40px; padding: 0 16px; border: 0; border-radius: 99px;
  background: var(--card); color: var(--ink); font-weight: 400; white-space: nowrap; text-decoration: none;
}
.pill:hover, .btn:hover { filter: brightness(.97); }
.pill:disabled, .btn:disabled { opacity: .55; cursor: default; }
.pill-dark, .btn-primary { background: var(--btn); color: var(--btn-ink); font-weight: 500; }
.pill-dark:hover, .btn-primary:hover { filter: none; opacity: .9; }
.pill-accent { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.pill-soft { background: var(--frame); }
.pill-bar { background: var(--bar-btn); color: var(--btn-ink); }
.pill-sm, .btn-sm { height: 32px; padding: 0 14px; }
.pill-round { width: 34px; height: 34px; padding: 0; }
.pill .i, .btn .i { width: 15px; height: 15px; }
select.pill { appearance: none; -webkit-appearance: none; padding-right: 16px; }
.btn-ghost { background: none; }
.icon-btn {
  display: inline-grid; place-items: center; width: 30px; height: 30px; padding: 0;
  border: 0; border-radius: 50%; background: none; color: var(--muted);
}
.icon-btn:hover { background: var(--frame); color: var(--ink); }
.circle-btn {
  flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; padding: 0;
  background: var(--card); color: var(--ink); display: grid; place-items: center;
}
.circle-btn .i { width: 18px; height: 18px; }

/* ========================= Page head ========================= */
.page-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; justify-content: space-between; }
.page-title { min-width: 0; }
.crumb { color: var(--muted); }
.page-head h1 { font: 400 36px/1.1 var(--display); letter-spacing: -.01em; }
.page-head h1 .count { color: var(--muted); }
.page-sub { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.search {
  display: flex; align-items: center; gap: 8px; height: 40px; padding: 0 14px 0 16px;
  border-radius: 99px; background: var(--card); color: var(--muted);
}
.search:focus-within { box-shadow: 0 0 0 2px var(--ink); }
.search input { width: 170px; min-width: 0; border: 0; outline: 0; background: none; color: var(--ink); }
.search input::-webkit-search-cancel-button { display: none; }

/* ========================= Pill tabs ========================= */
.tabs { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.tab {
  height: 34px; padding: 0 16px; border: 0; border-radius: 99px;
  background: var(--card); color: var(--ink); white-space: nowrap;
}
.tab:hover { filter: brightness(.97); }
.tab.on { background: var(--btn); color: var(--btn-ink); font-weight: 500; }
.tab-sep { width: 1px; align-self: stretch; margin: 4px 6px; background: var(--line2); }
.seg { display: inline-flex; gap: 4px; padding: 4px; border-radius: 99px; background: var(--card); }
.seg button { height: 32px; padding: 0 14px; border: 0; border-radius: 99px; background: none; color: var(--ink); white-space: nowrap; }
.seg button.on { background: var(--btn); color: var(--btn-ink); font-weight: 500; }
.subbar { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

/* ========================= Bulk bar ========================= */
.bulkbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  padding: 8px 8px 8px 12px; border-radius: 99px; background: var(--btn); color: var(--btn-ink);
}
.bulkbar strong { font-weight: 600; }
.bulkbar .pill { height: 34px; padding: 0 14px; }
.bulkbar .pill-round { padding: 0; }
.bulkbar .check span { border-color: var(--btn-ink); background: transparent; }

/* ========================= Table / rows ========================= */
.table { flex: 1; min-height: 0; overflow-y: auto; padding: 8px; border-radius: var(--r-card); background: var(--card); }
.cols { display: grid; gap: 12px; align-items: center;
  grid-template-columns: 36px minmax(140px, 1fr) minmax(0, 2.4fr) 120px 130px 84px 80px; }
.cols.snz { grid-template-columns: 36px minmax(140px, 1fr) minmax(0, 2.2fr) 150px 140px; }
.thead { padding: 8px 14px; color: var(--muted); font-size: 12px; }
.thead span:last-child { text-align: right; }
.rows { display: flex; flex-direction: column; }
.row { padding: 12px 14px; border-radius: var(--r-row); cursor: pointer; position: relative; }
.row + .row { box-shadow: 0 -1px 0 var(--line); }
.row:hover, .row.active { background: var(--sel); box-shadow: none; }
.row:hover + .row, .row.active + .row, .row.selected + .row { box-shadow: none; }
.row.selected { background: var(--sel-accent); box-shadow: none; }
.row.kbd { box-shadow: inset 0 0 0 1.5px var(--ink); }
.row-who { display: flex; align-items: center; gap: 10px; min-width: 0; }
.row-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-weight: 500; }
.row.unread .row-name { font-weight: 600; }
.row.unread .row-name::after { content: ""; display: inline-block; width: 7px; height: 7px; margin-left: 6px; border-radius: 50%; background: var(--ink); vertical-align: middle; }
.row-text { min-width: 0; }
.row-subject, .row-preview { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-subject { display: flex; gap: 6px; align-items: center; }
.row-subject > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.row-preview { color: var(--muted); }
.row-time { text-align: right; color: var(--muted); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row-assignee { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-act { justify-self: end; }
.avatar {
  flex: none; width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: var(--frame); color: var(--ink); font-size: 11px; font-weight: 600; letter-spacing: .01em;
}
.table .row .check { margin: 0; }

/* Checkbox */
.check { position: relative; display: grid; width: 18px; height: 18px; place-items: center; cursor: pointer; }
.check input { position: absolute; opacity: 0; inset: -4px; margin: 0; cursor: pointer; }
.check span { width: 18px; height: 18px; border-radius: 6px; border: 1.5px solid var(--line2); background: var(--card); }
.check input:checked + span { background: var(--accent); border-color: var(--accent); }
.check input:checked + span::after { content: ""; display: block; width: 5px; height: 9px; margin: 2px 0 0 5px; border: solid var(--accent-ink); border-width: 0 2px 2px 0; transform: rotate(45deg); }
.check input:indeterminate + span { background: var(--accent); border-color: var(--accent); }

/* Chips */
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border-radius: 99px;
  background: var(--frame); color: var(--ink); font-size: 12px; white-space: nowrap; line-height: 1.5;
}
.chip .i { width: 12px; height: 12px; }
.chip-accent { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip-new-reply { flex: none; padding: 1px 8px; font-size: 11px; background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.chip-urgent { flex: none; background: var(--urgent-soft); color: var(--urgent); font-weight: 600; }
.chip-dark { background: var(--btn); color: var(--btn-ink); }
.chip-line { background: none; box-shadow: inset 0 0 0 1px var(--line2); color: var(--muted); }
.chip-done { background: var(--ok-soft); color: var(--ok); }
.chip-due { background: var(--warn-soft); color: var(--warn); font-weight: 600; }

/* Groups (snoozed) */
.group { padding: 14px 0 0; }
.group + .group { margin-top: 12px; padding-top: 18px; box-shadow: 0 -8px 0 var(--frame); }
.group-head { display: flex; align-items: baseline; gap: 8px; padding: 0 12px 6px; }
.group-head strong { font: 500 18px var(--display); }
.table.grouped { background: none; padding: 0; overflow-y: auto; }
.table.grouped .group { background: var(--card); border-radius: var(--r-card); padding: 14px 8px 8px; box-shadow: none; margin: 0 0 12px; }

.list-empty, .list-loading { padding: 56px 24px; text-align: center; color: var(--muted); }
.list-empty strong { display: block; color: var(--ink); font: 400 22px var(--display); margin-bottom: 4px; }
.load-more { display: flex; margin: 12px auto 8px; }
.skeleton { height: 58px; margin: 4px 0; border-radius: var(--r-row); background: linear-gradient(90deg, var(--card) 0%, var(--sel) 50%, var(--card) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Extra cards above a list (Gamefound) */
.stat-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stat {
  padding: 18px; border-radius: var(--r-card); background: var(--card); color: var(--ink);
  display: flex; flex-direction: column; gap: 4px; text-align: left; border: 0; min-width: 0;
}
button.stat:hover { filter: brightness(.98); }
.stat-top { display: flex; justify-content: space-between; gap: 8px; color: var(--muted); }
.stat-num { font: 400 44px/1.1 var(--display); margin: 6px 0 8px; font-variant-numeric: tabular-nums; }
.stat-num small { font-size: 16px; color: var(--muted); }
.stat-accent { background: var(--accent); color: var(--accent-ink); }
.stat-accent .stat-top, .stat-accent .stat-num small { color: inherit; opacity: .75; }
.stat-dark { background: var(--dark); color: var(--dark-ink); }
.stat-dark .stat-top { color: inherit; opacity: .7; }
.stat .pill { align-self: flex-start; height: 34px; padding: 0 14px; margin-top: auto; }
.stat-dark .pill { background: var(--dark-ink); color: var(--dark); font-weight: 500; }
.stat-text { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.bars { display: flex; gap: 4px; margin-top: auto; }
.bars span { flex: 1; height: 26px; border-radius: 99px; background: var(--ink); }
.bars span.empty { background: none; box-shadow: inset 0 0 0 1.5px var(--muted); opacity: .7; }

/* ========================= Today ========================= */
.today { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 16px; margin-right: -8px; padding-right: 8px; }
.today > * { flex-shrink: 0; }
.today-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; justify-content: space-between; }
.today-head h1 { font: 400 40px/1.1 var(--display); letter-spacing: -.01em; }
.phone-top { display: none; }
.today-split { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-start; }
.card { border-radius: var(--r-card); background: var(--card); }
.inbox-card { flex: 1 1 380px; min-width: 0; padding: 10px; display: flex; flex-direction: column; gap: 4px; }
.side-card { flex: 1 1 300px; max-width: 420px; min-width: 0; display: flex; flex-direction: column; gap: 12px; }
.card-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 6px 8px; }
.card-head strong { font: 500 18px var(--display); }
.soft-row { display: flex; gap: 12px; padding: 12px; border-radius: 16px; cursor: pointer; text-align: left; border: 0; background: none; width: 100%; }
.soft-row:hover { background: var(--sel); }
.soft-row .avatar { width: 38px; height: 38px; font-size: 12px; }
.soft-row .grow { min-width: 0; }
.soft-row .line { display: flex; justify-content: space-between; gap: 8px; }
.soft-row .line > span:first-child { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.soft-row strong { font-weight: 600; }
.soft-row .muted { white-space: nowrap; }
.soft-row .sub { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.health { padding: 18px; display: flex; flex-direction: column; gap: 14px; }
.health-item { display: flex; gap: 12px; align-items: center; }
.health-item small { display: block; color: var(--muted); font-size: 12px; }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--ok); box-shadow: 0 0 0 4px var(--ok-soft); flex: none; }
.pulse.warn { background: var(--warn); box-shadow: 0 0 0 4px var(--warn-soft); }
.banner {
  display: flex; gap: 10px; align-items: flex-start; padding: 14px 18px; border-radius: 18px;
  background: var(--accent-soft); color: var(--ink);
}
.banner .i { margin-top: 2px; }
.banner.warn { background: var(--urgent-soft); }
.banner.warn .i { color: var(--urgent); }
.banner ul { margin: 6px 0 0; padding-left: 18px; }
.banner small { color: var(--muted); }

/* ========================= Conversation ========================= */
.convo-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; }
.convo-title { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1 1 360px; }
.convo-title > div { min-width: 0; }
.convo-title h1 { font: 400 32px/1.15 var(--display); overflow-wrap: anywhere; }
.convo-title .chip { flex: none; }
.convo-meta { color: var(--muted); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.convo-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.convo-body { flex: 1; min-height: 0; display: flex; gap: 12px; }
.convo-card { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 8px; border-radius: var(--r-card); background: var(--card); }
.thread { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 14px; }

.msg { padding: 16px 18px; border-radius: 18px; background: var(--frame); min-width: 0; }
.msg.out { background: none; box-shadow: inset 0 0 0 1px var(--line); }
.msg-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 4px 10px; margin-bottom: 6px; color: var(--muted); }
.msg-head b { color: var(--ink); font-weight: 600; }
.msg-body { font-size: 14px; line-height: 1.65; white-space: pre-wrap; overflow-wrap: anywhere; }
.msg-body.html { white-space: normal; border-radius: 12px; overflow: hidden; background: #fff; }
.msg-body iframe { display: block; width: 100%; border: 0; min-height: 120px; background: #fff; }
.msg-tools { display: flex; gap: 6px; margin-top: 8px; }
.msg-tools .btn { height: 28px; padding: 0 12px; font-size: 12px; background: var(--card); }
.msg.out .msg-tools .btn { background: var(--frame); }
.failed { color: var(--urgent); font-weight: 600; }
.notice { display: flex; gap: 8px; align-items: flex-start; margin-top: 10px; padding: 8px 12px; border-radius: 12px; background: var(--warn-soft); font-size: 13px; }
.notice .i { color: var(--warn); margin-top: 2px; }

.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumb, .file-chip {
  display: flex; align-items: center; gap: 8px; padding: 6px 10px 6px 6px; border-radius: 12px; border: 0;
  background: var(--card); color: var(--ink); text-align: left; text-decoration: none; max-width: 260px; font-size: 13px;
}
.msg.out .thumb, .msg.out .file-chip { background: var(--frame); }
.thumb img { width: 34px; height: 34px; border-radius: 8px; object-fit: cover; background: var(--line); flex: none; }
.thumb div, .file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.file-chip .i { width: 34px; height: 34px; padding: 8px; border-radius: 8px; background: var(--line); }
.thumb small, .file-chip small { color: var(--muted); margin-left: 4px; }

/* Group 2: photos and files */
.photo { padding: 0; border: 0; background: none; color: var(--ink); text-align: left; width: 150px; cursor: zoom-in; }
.photo img { display: block; width: 150px; height: 104px; border-radius: 12px; object-fit: cover; background: var(--line); }
.photo-cap { display: flex; gap: 4px; margin-top: 4px; font-size: 12px; min-width: 0; }
.photo-cap span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.photo-cap small { color: var(--muted); flex: none; }
.file-card { display: flex; align-items: center; gap: 10px; align-self: flex-start; padding: 10px 14px; border-radius: 12px; background: var(--card); color: var(--ink); text-decoration: none; max-width: 280px; }
.msg.out .file-card { background: var(--frame); }
.file-badge { flex: none; width: 34px; height: 40px; border-radius: 6px; background: var(--line); display: flex; align-items: center; justify-content: center; font-size: 10px; font-weight: 700; }
.file-text { display: flex; flex-direction: column; min-width: 0; }
.file-text > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-text small { color: var(--muted); font-size: 12px; }
.notice a { color: inherit; font-weight: 500; }
/* Group 2: Gamefound replies sit under the comment they answer */
.msg.reply { margin-left: 28px; border-radius: 16px; padding: 14px 16px; }

.note-item { display: flex; gap: 10px; align-items: flex-start; padding: 12px 16px; border-radius: 16px; background: var(--note-bg); }
.note-item > .i { margin-top: 2px; }
.note-item p { margin: 2px 0 0; white-space: pre-wrap; overflow-wrap: anywhere; }
.note-item strong { font-weight: 600; }
.event { align-self: center; font-size: 12px; color: var(--muted); text-align: center; }
.day-sep { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.day-sep::before, .day-sep::after { content: ""; flex: 1; height: 1px; background: var(--line); }

/* Composer */
.composer { margin: 4px 8px 8px; padding: 8px; border-radius: 20px; background: var(--frame); }
.composer.note-mode { background: var(--note-bg); }
.composer-tabs { display: flex; gap: 4px; padding: 4px; }
.composer-tabs button {
  height: 32px; padding: 0 14px; border: 0; border-radius: 99px; background: none; color: var(--muted);
  display: inline-flex; gap: 6px; align-items: center;
}
.composer-tabs button.on { background: var(--card); color: var(--ink); font-weight: 500; }
.composer textarea {
  display: block; width: 100%; min-height: 96px; max-height: 300px; resize: vertical; border: 0; outline: 0;
  background: none; padding: 10px 12px; font-size: 14px; line-height: 1.6; color: var(--ink);
}
.composer-foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; padding: 4px 4px 2px; color: var(--muted); }
.composer-foot > span { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1 1 200px; }
.composer-foot .btns { display: flex; gap: 6px; align-items: center; }
.composer-foot .pill { height: 40px; }
.gf-reply { margin: 4px 8px 0; display: flex; gap: 10px; flex-wrap: wrap; align-items: center; justify-content: space-between; padding: 14px 16px; border-radius: 18px; background: var(--accent); color: var(--accent-ink, #1b1d12); }
.gf-reply .pill { height: 38px; }
.gf-note { background: var(--note-bg); }
.gf-note-head { display: flex; align-items: center; gap: 6px; padding: 6px 8px; font-weight: 500; }
.gf-note-head .muted { font-weight: 400; }
.gf-reply span { flex: 1; min-width: 200px; }

/* ========================= Details ========================= */
.details { flex: 0 0 320px; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.d-card { padding: 18px; border-radius: var(--r-card); background: var(--card); display: flex; flex-direction: column; gap: 12px; }
.d-card h3 { font-size: 12px; color: var(--muted); font-weight: 400; }
.customer { display: flex; gap: 12px; align-items: center; }
.customer .avatar { width: 44px; height: 44px; font-size: 13px; }
.customer-name { font: 400 18px var(--display); }
.customer-email { color: var(--muted); display: flex; align-items: center; gap: 2px; overflow-wrap: anywhere; }
.tiles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tile { padding: 10px 12px; border-radius: 14px; background: var(--frame); }
.tile div:first-child { color: var(--muted); }
.tile b { font: 400 22px var(--display); }
.prop { display: flex; justify-content: space-between; align-items: center; gap: 10px; min-height: 30px; }
.prop > span:first-child, .prop > label { color: var(--muted); flex: none; }
.prop > span:last-child { text-align: right; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.prop select, .prop input {
  height: 30px; max-width: 170px; padding: 0 12px; border: 0; border-radius: 99px;
  background: var(--frame); color: var(--ink); text-align: right;
}
.prop select { appearance: none; -webkit-appearance: none; text-align-last: right; cursor: pointer; }
.link-list { display: flex; flex-direction: column; gap: 4px; }
.link-list a, .link-list button {
  display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink);
  background: none; border: 0; padding: 6px 8px; margin: 0 -8px; border-radius: 10px; text-align: left; min-width: 0;
}
.link-list a:hover, .link-list button:hover { background: var(--frame); }
.link-list .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.d-dark { background: var(--dark); color: var(--dark-ink); }
.d-dark h3 { color: inherit; opacity: .7; }
.activity { display: flex; flex-direction: column; gap: 8px; font-size: 12px; }
.activity small { opacity: .65; }
.inline-form { display: flex; gap: 6px; }
.inline-form input { flex: 1; min-width: 0; height: 32px; padding: 0 12px; border: 0; border-radius: 99px; background: var(--frame); outline: 0; }
.details-close { display: none; }
/* Group 2: side panel controls */
.d-head { display: flex; justify-content: space-between; align-items: center; }
.d-card h3 { margin: 0 0 6px; }
.text-btn { padding: 0; border: 0; background: none; color: inherit; font: inherit; text-decoration: underline; text-underline-offset: 2px; cursor: pointer; text-align: left; overflow-wrap: anywhere; }
.customer-email .text-btn { color: var(--muted); text-decoration: none; }
.customer-email .text-btn:hover { text-decoration: underline; }
.d-dark .text-btn { opacity: .7; }
.earlier { display: flex; flex-direction: column; gap: 4px; }
.earlier button[data-act="open"] { display: flex; justify-content: space-between; gap: 8px; padding: 8px 10px; border: 0; border-radius: 12px; background: var(--frame); color: var(--ink); text-align: left; min-width: 0; }
.earlier .grow { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.earlier .muted { flex: none; }
.earlier .text-btn { color: var(--muted); padding: 4px 10px; text-decoration: none; }
.seg-full { display: flex; width: 100%; box-sizing: border-box; background: var(--frame); }
.seg-full button { flex: 1; height: 30px; }
.snoozed-line { margin-top: 6px; color: var(--muted); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip-btn { position: relative; display: inline-flex; align-items: center; height: 32px; padding: 0 12px; border: 0; border-radius: 99px; background: var(--frame); color: var(--ink); font: inherit; cursor: pointer; }
.chip-btn.on { background: var(--accent); color: var(--accent-ink, #1b1d12); font-weight: 600; }
.date-chip input { position: absolute; inset: 0; opacity: 0; cursor: pointer; width: 100%; }
.switch { position: relative; width: 44px; height: 26px; padding: 0; border: 0; border-radius: 99px; background: var(--frame); cursor: pointer; flex: none; }
.switch span { position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: var(--card); box-shadow: 0 1px 2px rgba(0,0,0,.2); transition: left .15s; }
.switch.on { background: var(--urgent, #c0392b); }
.switch.on span { left: 21px; }
.soft-btn { display: flex; align-items: center; justify-content: center; gap: 6px; height: 36px; padding: 0 14px; border: 0; border-radius: 99px; background: var(--frame); color: var(--ink); font: inherit; text-decoration: none; cursor: pointer; }

/* ========================= Overlays ========================= */
.overlay { position: fixed; inset: 0; z-index: 50; background: rgba(11, 13, 12, .45); display: grid; place-items: center; padding: 20px; }
.modal { width: min(560px, 100%); max-height: 90vh; overflow: auto; background: var(--card); border-radius: 24px; box-shadow: var(--shadow); }
.modal-head { display: flex; align-items: center; padding: 18px 20px 8px; }
.modal-head h3 { flex: 1; font: 400 24px var(--display); }
.modal-body { padding: 8px 20px 12px; display: flex; flex-direction: column; gap: 10px; }
.modal-body label { display: flex; flex-direction: column; gap: 4px; color: var(--muted); }
.modal-body input, .modal-body select, .modal-body textarea { width: 100%; padding: 10px 14px; border: 0; border-radius: 14px; background: var(--frame); color: var(--ink); outline: 0; }
.modal-body input:focus, .modal-body select:focus, .modal-body textarea:focus { box-shadow: 0 0 0 2px var(--ink); }
.modal-body textarea { min-height: 160px; resize: vertical; }
.modal-body small { color: var(--muted); }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 8px 20px 20px; }
.modal-foot .btn { background: var(--frame); }
.modal-foot .btn-primary { background: var(--btn); }
.shortcut-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 24px; }
.shortcut-grid div { display: flex; justify-content: space-between; gap: 10px; padding: 3px 0; }
.lightbox { position: fixed; inset: 0; z-index: 60; background: rgba(0, 0, 0, .85); display: grid; place-items: center; padding: 24px; cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 12px; background: #fff; }
.menu { position: fixed; z-index: 55; min-width: 220px; background: var(--card); border-radius: 18px; box-shadow: var(--shadow); padding: 6px; }
.menu button { display: flex; width: 100%; gap: 10px; align-items: center; padding: 8px 10px; border: 0; border-radius: 12px; background: none; text-align: left; color: var(--ink); }
.menu button:hover, .menu button:focus-visible { background: var(--frame); outline: 0; }
.menu button small { margin-left: auto; color: var(--muted); }
.menu .avatar { width: 24px; height: 24px; font-size: 10px; }
.menu form { gap: 4px; padding: 4px; }
.menu input { flex: 1; min-width: 0; height: 34px; padding: 0 12px; border: 0; border-radius: 99px; background: var(--frame); color: var(--ink); }
.menu form .btn { width: auto; height: 34px; background: var(--btn); color: var(--btn-ink); }

.toast-wrap { position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%); z-index: 70; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast { display: flex; align-items: center; gap: 14px; padding: 10px 18px; border-radius: 99px; background: var(--btn); color: var(--btn-ink); box-shadow: var(--shadow); animation: rise .18s ease-out; }
.toast button { border: 0; background: none; color: var(--accent); font-weight: 600; padding: 0; }
:root[data-theme="dark"] .toast button { color: var(--ink); text-decoration: underline; }
.toast.error { background: var(--urgent); color: #fff; }
@keyframes rise { from { transform: translateY(8px); opacity: 0; } }
.scrim { position: fixed; inset: 0; z-index: 39; background: rgba(0, 0, 0, .3); }

/* ========================= Responsive ========================= */
@media (max-width: 1360px) {
  .cols { grid-template-columns: 36px minmax(130px, 1fr) minmax(0, 2.2fr) 110px 120px 72px; }
  .cols > .c-assignee { display: none; }
}
@media (max-width: 1180px) {
  :root { --pad: 16px; }
  .details { position: fixed; top: 0; right: 0; bottom: 0; width: 340px; z-index: 40; padding: 12px; background: var(--frame); box-shadow: var(--shadow); transform: translateX(105%); transition: transform .2s; }
  .app.show-details .details { transform: none; }
  .details-close { display: inline-grid; }
  .stat-row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .cols { grid-template-columns: 36px minmax(120px, 1fr) minmax(0, 2fr) 120px 64px; }
  .cols > .c-channel { display: none; }
}
@media (min-width: 1181px) { #details-toggle { display: none; } }

@media (max-width: 900px) {
  :root { --pad: 0px; }
  body { font-size: 14px; }
  .app { border-radius: 0; }
  .phone-only { display: revert !important; }
  .rail-btn.phone-only { display: grid !important; }
  .desk-only { display: none !important; }
  .content { padding: 16px 14px 0; }
  .list-panel, .main { gap: 14px; }

  /* The rail becomes a floating bar at the bottom (hidden inside a conversation). */
  .rail {
    position: fixed; z-index: 30; left: 12px; right: 12px; bottom: calc(10px + env(safe-area-inset-bottom));
    margin: 0; padding: 8px 10px; flex-direction: row; justify-content: space-around; gap: 4px; height: 56px; box-shadow: var(--shadow);
  }
  .rail-logo, .rail-gap, .me { display: none; }
  .app[data-pane="ticket"] .rail { display: none; }
  .list-panel, .today { padding-bottom: 80px; }
  .table { overflow: visible; flex: none; border-radius: 22px 22px 0 0; min-height: 50vh; }
  .list-panel { overflow-y: auto; margin: 0 -14px; padding: 0 14px 80px; }
  .list-panel > * { flex-shrink: 0; }

  .page-head { align-items: flex-start; }
  .page-head h1 { font-size: 30px; }
  .page-actions { width: 100%; }
  .page-actions .search { flex: 1 1 100%; }
  .page-actions .search input { width: 100%; }
  .page-actions .pill { flex: 1; }
  .pill { height: 44px; }
  .tabs { flex-wrap: nowrap; overflow-x: auto; margin: 0 -14px; padding: 0 14px; scrollbar-width: none; }
  .tabs::-webkit-scrollbar { display: none; }
  .tab { flex: none; height: 36px; padding: 0 14px; font-size: 13px; }
  .bulkbar { border-radius: 22px; }
  .subbar .seg { max-width: 100%; overflow-x: auto; scrollbar-width: none; }
  .subbar .seg::-webkit-scrollbar { display: none; }

  /* Rows: soft cards like the phone mockup */
  .thead { display: none; }
  .cols { grid-template-columns: 38px minmax(0, 1fr) auto; grid-template-areas: "who name time" "who text text" "who meta meta"; gap: 2px 12px; align-items: start; }
  .row { padding: 12px; }
  .row .c-check { display: none; }
  .rows.selecting .row .c-check { display: grid; grid-area: who; margin-top: 10px; }
  .rows.selecting .row .avatar { display: none; }
  .row-who { display: contents; }
  .row-who .avatar { grid-area: who; width: 38px; height: 38px; font-size: 12px; }
  .row-name { grid-area: name; }
  .row-text { grid-area: text; }
  .row-time { grid-area: time; font-size: 12px; }
  .cols > .c-channel, .cols > .c-assignee { display: none; }
  .cols > .c-status { grid-area: meta; display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
  .cols > .c-status:empty { display: none; }
  .cols > .c-status .chip-plain { display: none; }
  .cols > .row-act { grid-area: time; height: 30px; padding: 0 12px; }
  .cols.snz { grid-template-columns: 38px minmax(0, 1fr) auto; }
  .cols.snz > .c-status { grid-area: time; margin: 0; }
  .cols.snz > .row-act { grid-area: meta; justify-self: start; margin-top: 6px; }
  .stat-row, .stat-row.three { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .stat { padding: 14px; border-radius: 20px; }
  .stat-num { font-size: 34px; margin: 2px 0; }
  .hide-phone { display: none !important; }

  /* Today */
  .phone-top { display: flex; justify-content: space-between; align-items: center; }
  .phone-logo { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--rail); color: #fff; display: grid; place-items: center; font: 600 15px var(--display); }
  .today-head .page-actions { display: none; }
  .today-head h1 { font-size: 30px; }
  .today-head h1 .hello { display: none; }
  .today { margin: 0 -14px; padding: 0 14px 90px; }
  .inbox-card { flex-basis: 100%; padding: 8px; }
  .side-card { max-width: none; flex-basis: 100%; }

  /* Conversation: single panel */
  .app[data-pane="ticket"] .content { padding: 12px 0 0; }
  .convo-head { padding: 0 12px; gap: 10px; }
  .convo-title { flex-basis: 100%; gap: 8px; }
  .convo-title > div { flex: 1; }
  .convo-title h1 { font-size: 19px; }
  .convo-title .crumb, .convo-title > .chip { display: none; }
  .convo-meta { font-size: 12px; }
  .convo-actions { flex-wrap: nowrap; overflow-x: auto; width: calc(100% + 24px); margin: 0 -12px; padding: 0 12px; scrollbar-width: none; }
  .convo-actions .pill { height: 36px; padding: 0 14px; font-size: 13px; flex: none; }
  .circle-btn { width: 44px; height: 44px; }
  .convo-body { padding: 0 8px; }
  .convo-card { border-radius: 22px 22px 0 0; padding: 4px; }
  .thread { padding: 8px; gap: 10px; }
  .msg { padding: 12px 14px; border-radius: 16px; }
  .msg-body { font-size: 14px; line-height: 1.55; }
  .composer { margin: 4px 0 0; border-radius: 20px 20px 0 0; padding: 6px 6px calc(8px + env(safe-area-inset-bottom)); }
  .composer textarea { min-height: 56px; }
  .composer-foot kbd { display: none; }
  .details { width: 100%; max-width: 380px; }
}
@media (max-width: 1180px) and (min-width: 901px) {
  .rail-btn.phone-only { display: none !important; }
}

/* ========================= Group 3: pop-ups ========================= */
.modal-wide { width: min(660px, 100%); }
.modal-body .sect, .drawer .sect { color: var(--muted); font-size: 12px; margin-top: 4px; }
.modal-body .small { font-size: 12px; padding: 0 4px; }
.modal-body .chips .chip-btn { color: var(--ink); }
.modal-body .field { display: flex; align-items: center; gap: 10px; padding: 0 6px 0 14px; min-height: 46px; border-radius: 14px; background: var(--frame); }
.modal-body .field .lab { flex: 0 0 58px; color: var(--muted); }
.modal-body .field input { flex: 1; min-width: 0; padding: 10px 4px; background: none; box-shadow: none !important; border-radius: 0; }
.modal-body .field .text-btn { flex: none; padding: 0 8px; }
.modal-body textarea { min-height: 200px; font-size: 14px; line-height: 1.6; }
.to-tag { display: inline-flex; align-items: center; gap: 6px; height: 30px; padding: 0 2px 0 4px; border-radius: 99px; background: var(--card); color: var(--ink); max-width: 100%; }
.to-tag .avatar { width: 22px; height: 22px; font-size: 9px; }
#to-tag { flex: 1; min-width: 0; }
.attach-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.file-list { display: flex; flex-wrap: wrap; gap: 6px; }
.file-pill { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 4px 0 12px; border-radius: 99px; background: var(--frame); color: var(--ink); }
.file-pill small { color: var(--muted); }
.modal-foot { align-items: center; }
.modal-foot .grow { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Snooze menu with calendar */
.snooze-menu { width: 290px; display: flex; flex-direction: column; gap: 2px; }
.menu-sep { height: 1px; background: var(--line); margin: 6px 4px; }
.cal-wrap { padding: 2px 6px; }
.cal-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.cal-head b { font-weight: 500; }
.cal-head .icon-btn { width: 28px; height: 28px; font-size: 16px; }
.cal { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; font-size: 12px; }
.cal-d { color: var(--muted); font-size: 11px; height: 24px; display: flex; align-items: center; justify-content: center; }
.menu .cal button.cal-day { width: 32px; height: 30px; margin: 0 auto; padding: 0; justify-content: center; border-radius: 50%; font-size: 12px; }
.menu .cal button.cal-day.past { color: var(--line); cursor: default; }
.menu .cal button.cal-day.today { box-shadow: inset 0 0 0 1px var(--ink); }
.menu .cal button.cal-day.pick { background: var(--btn); color: var(--btn-ink); font-weight: 600; }
.snooze-why { display: flex; flex-direction: column; gap: 4px; padding: 6px 8px 2px; color: var(--muted); font-size: 12px; }
.snooze-why input { height: 34px; padding: 0 12px; border: 0; border-radius: 12px; background: var(--frame); color: var(--ink); outline: 0; font-size: 13px; }
.snooze-foot { padding: 8px; }
.menu .snooze-foot .pill { width: 100%; justify-content: center; }
.menu .snooze-foot .pill:disabled { opacity: .45; }

/* Undo bar */
.toast { padding: 0 6px 0 18px; height: 48px; gap: 14px; background: var(--dark, #16181a); color: #fff; }
.toast .toast-act { color: var(--accent); }
.toast .toast-x { width: 34px; height: 34px; border-radius: 50%; background: rgba(255,255,255,.12); color: #fff; display: grid; place-items: center; }
.toast .toast-x .i { width: 14px; height: 14px; }
:root[data-theme="dark"] .toast button.toast-act { color: var(--accent); text-decoration: none; }

/* Photo viewer */
.viewer { position: fixed; inset: 0; z-index: 60; background: rgba(6, 7, 7, .92); color: #fff; display: flex; flex-direction: column; }
.viewer-top { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; padding: 20px 28px; }
.viewer-top b { font-weight: 500; }
.viewer-top span { opacity: .65; }
.viewer-btns { display: flex; gap: 8px; }
.pill-glass { background: rgba(255,255,255,.12) !important; color: #fff !important; text-decoration: none; }
.pill-white { background: #fff !important; color: #16181a !important; width: 40px; padding: 0 !important; justify-content: center; }
.viewer-stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 0 90px; cursor: zoom-out; }
.viewer-stage img { max-width: 100%; max-height: 100%; border-radius: 14px; background: #fff; cursor: default; }
.viewer-arrow { position: absolute; top: 50%; transform: translateY(-50%); width: 52px; height: 52px; border: 0; border-radius: 50%; background: rgba(255,255,255,.14); color: #fff; font-size: 24px; }
.viewer-arrow.prev { left: 24px; } .viewer-arrow.next { right: 24px; }
.viewer-strip { display: flex; justify-content: center; align-items: center; gap: 10px; padding: 18px; }
.viewer-strip button { padding: 0; border: 0; background: none; opacity: .55; border-radius: 8px; }
.viewer-strip button.on { opacity: 1; box-shadow: 0 0 0 2px #fff; }
.viewer-strip img { display: block; width: 64px; height: 44px; object-fit: cover; border-radius: 8px; }
.viewer-strip span { opacity: .6; margin-left: 6px; }

/* Shortcuts */
.shortcut-cols { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 24px; }
.shortcut-cols h4 { margin: 0 0 6px; font-size: 12px; font-weight: 400; color: var(--muted); }
.sc-row { display: flex; justify-content: space-between; align-items: center; gap: 8px; padding: 7px 0; border-top: 1px solid var(--line); }
.modal-body p.muted { margin: 8px 0 4px; }

/* Phone menu */
.drawer { position: fixed; z-index: 45; left: 0; top: 0; bottom: 0; width: min(300px, 85vw); box-sizing: border-box; padding: 20px 14px 16px; background: var(--frame); border-radius: 0 26px 26px 0; display: flex; flex-direction: column; gap: 2px; overflow-y: auto; animation: slidein .18s ease-out; }
@keyframes slidein { from { transform: translateX(-100%); } }
.drawer-head { display: flex; align-items: center; gap: 10px; padding: 0 6px 14px; }
.drawer-head b { flex: 1; font: 500 18px var(--display); }
.drawer-head .rail-logo { display: grid !important; place-items: center; width: 36px; height: 36px; border-radius: 50%; border: 1.5px solid var(--ink); color: var(--ink); background: none; font: 600 15px var(--display); }
.drawer > button { display: flex; align-items: center; gap: 12px; height: 44px; padding: 0 14px; border: 0; border-radius: 14px; background: none; color: var(--ink); text-align: left; font-size: 14px; }
.drawer > button.on { background: var(--card); font-weight: 500; }
.drawer > button .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); }
.drawer > button.on .dot { background: var(--accent); box-shadow: 0 0 0 1px var(--ink); }
.drawer > button small { margin-left: auto; color: var(--muted); }
.drawer .sect { padding: 10px 14px 2px; }
.drawer-foot { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 12px 6px 0; border-top: 1px solid var(--line); }
.drawer-foot .grow { flex: 1; }
@media (max-width: 900px) {
  .shortcut-cols { grid-template-columns: 1fr; }
  .viewer-stage { padding: 0 12px; }
  .viewer-arrow { top: auto; bottom: 90px; transform: none; }
  .viewer-top { padding: 14px 16px; }
  .viewer-btns .pill-glass:nth-child(2) { display: none; }
  .modal-foot .grow { display: none; }
}
.modal-body label.chip-btn { flex-direction: row; gap: 6px; }
.modal-body .chip-btn.on { color: var(--accent-ink, #1b1d12); }
.chip-btn .i { width: 15px; height: 15px; }
.menu .cal-head span { display: flex; gap: 2px; }
.menu .cal-head .icon-btn { display: grid; place-items: center; width: 28px; padding: 0; }

/* ===================== Tags and saved replies (E1, E2) ===================== */
.small { font-size: 12px; }
.tag { display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 10px; border-radius: 99px; font-size: 12px; font-weight: 500; white-space: nowrap; color: var(--ink); background: color-mix(in srgb, var(--tag) 22%, transparent); }
.tag i { width: 7px; height: 7px; border-radius: 50%; background: var(--tag); flex: none; }
.tag-x { border: 0; background: none; padding: 0 0 0 2px; color: var(--muted); font-size: 15px; line-height: 1; cursor: pointer; }
.tag-x:hover { color: var(--ink); }
.row-tags { display: flex; gap: 4px; margin-top: 4px; overflow: hidden; }
.pill-on { box-shadow: inset 0 0 0 2px var(--ink); }
.menu .box { width: 16px; height: 16px; border-radius: 5px; box-shadow: inset 0 0 0 1.5px var(--line); flex: none; }
.menu .box.on { background: var(--btn); box-shadow: none; }
.menu-search { width: 100%; box-sizing: border-box; height: 36px; padding: 0 12px; margin-bottom: 4px; border: 0; border-radius: 12px; background: var(--frame); color: var(--ink); outline: 0; font: inherit; }
.tag-menu { width: 280px; }
.tag-list { max-height: 320px; overflow-y: auto; }
.menu .muted { color: var(--muted); }

/* Reply box: saved replies */
.composer-tabs { align-items: center; }
.composer-tabs .grow { flex: 1; }
.saved-btn { display: inline-flex; align-items: center; gap: 6px; height: 32px; padding: 0 12px; border: 0; border-radius: 99px; background: var(--card); color: var(--ink); font: inherit; cursor: pointer; }
.saved-btn kbd { height: 20px; }
.picker-menu { padding: 0; overflow: hidden; }
.picker { display: flex; width: min(640px, calc(100vw - 32px)); max-height: 420px; }
.picker-list { flex: 1; min-width: 0; padding: 10px; border-right: 1px solid var(--line); overflow-y: auto; }
.picker-list .sect { color: var(--muted); font-size: 12px; padding: 4px 6px; }
.menu .pick { display: flex; gap: 8px; align-items: center; padding: 9px 10px; border-radius: 12px; }
.menu .pick.on { background: var(--frame); }
.pick .grow { min-width: 0; flex: 1; display: flex; flex-direction: column; }
.pick b { font-weight: 500; }
.pick small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin: 0 !important; }
.picker-preview { flex: 0 0 250px; padding: 16px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; overflow-y: auto; }
.picker-preview b { font-weight: 500; }
.preview-text { color: var(--muted); font-size: 12px; line-height: 1.6; white-space: pre-wrap; }
.picker-foot { margin-top: auto; display: flex; gap: 8px; align-items: center; }
.menu .picker-foot .pill { width: auto; }
.gap-note { display: flex; gap: 6px; align-items: flex-start; padding: 8px 10px; border-radius: 10px; background: var(--warn-soft); font-size: 12px; }
.gap-note .i { color: var(--warn); flex: none; width: 14px; height: 14px; margin-top: 1px; }

/* Library page */
.app[data-pane="library"] .list-panel { display: none; }
.library { display: flex; flex-direction: column; gap: 16px; min-height: 0; height: 100%; }
.lib-bar { display: flex; flex-wrap: wrap; gap: 10px; justify-content: space-between; align-items: center; }
.lib-cols { display: flex; gap: 12px; flex: 1; min-height: 0; }
.lib-list { flex: 0 0 380px; padding: 10px; border-radius: var(--r-card); background: var(--card); display: flex; flex-direction: column; gap: 2px; overflow-y: auto; }
.lib-search { height: 38px; padding: 0 14px; margin-bottom: 6px; border: 0; border-radius: 14px; background: var(--frame); color: var(--ink); outline: 0; }
.lib-item { display: flex; gap: 10px; align-items: center; padding: 10px 12px; border: 0; border-radius: 14px; background: none; color: var(--ink); text-align: left; }
.lib-item.on { background: var(--frame); }
.lib-item .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.lib-item b { font-weight: 500; }
.lib-item small { color: var(--muted); font-size: 12px; }
.lib-edit { flex: 1; min-width: 0; padding: 22px; border-radius: var(--r-card); background: var(--card); display: flex; flex-direction: column; gap: 12px; }
.lib-edit .field { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 46px; border-radius: 14px; background: var(--frame); }
.lib-edit .field .lab { flex: 0 0 50px; color: var(--muted); }
.lib-edit .field input, .lib-edit .field select { flex: 1; min-width: 0; border: 0; background: none; color: var(--ink); outline: 0; font: inherit; padding: 10px 0; }
.lib-edit .field select { flex: 0 1 240px; }
.lib-edit textarea { flex: 1; min-height: 240px; padding: 14px; border: 0; border-radius: 14px; background: var(--frame); color: var(--ink); font: inherit; font-size: 14px; line-height: 1.7; resize: vertical; outline: 0; }
.var-row { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.var-row b { font-weight: 600; }
.lib-foot { display: flex; flex-wrap: wrap; gap: 8px; justify-content: space-between; align-items: center; }
.lib-foot .btns { display: flex; gap: 6px; }
.lib-table { padding: 8px; border-radius: var(--r-card); background: var(--card); }
.lib-tr { display: grid; grid-template-columns: minmax(180px, 240px) 1fr 110px 220px; gap: 12px; align-items: center; padding: 12px 16px; border-top: 1px solid var(--line); }
.lib-th { color: var(--muted); border-top: 0; padding-top: 8px; padding-bottom: 8px; }
.lib-tr .num { text-align: right; }
.lib-tr .acts { text-align: right; color: var(--muted); white-space: nowrap; }
.lib-tr .acts .text-btn { color: var(--ink); }
.swatch input { position: absolute; opacity: 0; }
.swatch span { display: block; width: 26px; height: 26px; border-radius: 50%; background: var(--tag); cursor: pointer; }
.swatch input:checked + span { box-shadow: 0 0 0 2px var(--card), 0 0 0 4px var(--ink); }
.swatch { position: relative; flex-direction: row !important; }
.btn-danger { background: var(--urgent) !important; color: #fff !important; }
@media (max-width: 900px) {
  .lib-cols { flex-direction: column; }
  .lib-list { flex: none; max-height: 260px; }
  .lib-tr { grid-template-columns: 1fr auto; }
  .lib-tr > span:nth-child(2), .lib-th { display: none; }
  .lib-tr .acts { grid-column: 1 / -1; text-align: left; }
  .picker-preview { display: none; }
}

/* ============ Group E pages ============ */
.library { overflow-y: auto; padding-bottom: 20px; }
.library .page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-end; gap: 12px; }
.library .seg { background: var(--card); }
.name-link { font: inherit; color: inherit; text-decoration: none; }
.name-link:hover { text-decoration: underline; }
/* Customer page */
.cust-side { flex: 0 0 340px; display: flex; flex-direction: column; gap: 12px; }
.cust-side .pill { justify-content: center; }
.cust-note h3 { display: flex; align-items: center; gap: 6px; }
.cust-note h3 .i { width: 14px; height: 14px; }
.cust-note textarea { min-height: 90px; padding: 10px 12px; border: 0; border-radius: 14px; background: var(--note-bg); color: var(--ink); font: inherit; resize: vertical; outline: 0; }
.cust-list { flex: 1; min-width: 0; align-self: flex-start; }
.cust-row { display: flex; gap: 10px; align-items: center; width: 100%; padding: 12px 16px; border: 0; border-top: 1px solid var(--line); background: none; color: var(--ink); text-align: left; }
.lib-th.cust-row { border-top: 0; color: var(--muted); }
button.cust-row:hover { background: var(--frame); border-radius: 14px; }
.cust-row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.cust-row b { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-row small { color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.cust-row .when { flex: 0 0 70px; text-align: right; }
.cust-tags { display: flex; gap: 4px; }
/* Auto-filed */
.af-group { border-top: 1px solid var(--line); }
.af-group:first-child { border-top: 0; }
.af-group summary { display: flex; align-items: center; gap: 12px; padding: 14px 16px; cursor: pointer; list-style: none; }
.af-group summary::-webkit-details-marker { display: none; }
.af-name { flex: 0 0 220px; font-weight: 500; }
.af-group summary .grow { flex: 1; }
.af-count { font: 400 20px var(--display); min-width: 50px; text-align: right; }
.af-group[open] summary .muted:last-child { visibility: hidden; }
.af-items { margin: 0 16px 12px; padding: 6px; border-radius: 14px; background: var(--frame); }
.af-item { display: flex; gap: 10px; align-items: center; padding: 6px 10px; }
.af-item .grow { flex: 1; min-width: 0; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.af-item .pill { background: var(--card); }
/* Reports */
.stat-row.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.rep-cols { align-items: stretch; }
.rep-chart { flex: 1.4; min-width: 0; padding: 18px 20px; display: flex; flex-direction: column; }
.rep-tags { flex: 1; min-width: 0; padding: 18px 20px; display: flex; flex-direction: column; gap: 6px; }
.rep-head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.rep-head b { font-weight: 500; }
.legend { display: flex; gap: 12px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 9px; height: 9px; border-radius: 3px; margin-right: 5px; }
.rbars { flex: 1; min-height: 180px; display: flex; gap: 8px; align-items: stretch; }
.rbar { flex: 1; min-width: 0; display: flex; flex-direction: column; justify-content: flex-end; align-items: center; gap: 4px; }
.rbar .stack { width: 62%; min-height: 2px; display: flex; flex-direction: column; border-radius: 8px; overflow: hidden; }
.rbar .stack span { min-height: 0; }
.rbar small { color: var(--muted); font-size: 11px; white-space: nowrap; }
.rbar-n { font-size: 11px; color: var(--muted); }
.tag-bar { display: flex; align-items: center; gap: 10px; }
.tag-bar > span:first-child { flex: 0 0 170px; }
.tag-bar .track { flex: 1; height: 10px; border-radius: 5px; background: var(--frame); overflow: hidden; }
.tag-bar .track span { display: block; height: 100%; border-radius: 5px; }
.tag-bar b { flex: 0 0 30px; text-align: right; font-weight: 500; }
.lib-tr.rep-people { grid-template-columns: 1fr 90px 90px; }
.rep-people .avatar { width: 26px; height: 26px; font-size: 10px; margin-right: 6px; vertical-align: middle; }
/* Settings */
.set-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; align-items: start; }
.set-title { font-weight: 500; font-size: 15px; }
.set-grid .field { display: flex; align-items: center; gap: 10px; padding: 0 14px; min-height: 42px; border-radius: 14px; background: var(--frame); }
.set-grid .field .lab { flex: 0 0 60px; color: var(--muted); }
.set-grid .field input { flex: 1; min-width: 0; border: 0; background: none; color: var(--ink); outline: 0; font: inherit; }
.set-box > span:first-child { color: var(--ink) !important; }
.team-row { display: flex; gap: 8px; align-items: center; padding: 6px 0; border-top: 1px solid var(--line); }
.team-row .avatar { width: 30px; height: 30px; font-size: 11px; flex: none; }
.team-row input { min-width: 0; height: 34px; padding: 0 10px; border: 0; border-radius: 10px; background: var(--frame); color: var(--ink); font: inherit; outline: 0; }
.team-row .t-name { flex: 0 0 90px; } .team-row .t-email { flex: 1; } .team-row .t-role { flex: 0 0 110px; }
@media (max-width: 1100px) { .set-grid { grid-template-columns: 1fr; } .stat-row.four { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 900px) {
  .cust-side { flex: none; }
  .rep-cols { flex-direction: column; }
  .af-name { flex: 1; } .af-group summary .grow { display: none; }
  .cust-row .chip, .cust-tags { display: none; }
  .team-row { flex-wrap: wrap; } .team-row .t-email { flex: 1 1 100%; order: 5; }
}
.rbar .stack { width: min(62%, 56px); border-radius: 8px; }
.rbar .stack span { display: block; border-radius: 0 !important; width: 100%; }
.rep-people > span:first-child { display: flex; align-items: center; gap: 8px; }
.rep-people .avatar { margin-right: 0; }
.cust-row .when { flex: 0 0 auto; min-width: 64px; white-space: nowrap; }

/* Audit 2026-11-20: phone layouts */
.set-grid > * { min-width: 0; }
.set-box { flex-wrap: wrap; }
.set-box > span:last-child { white-space: normal; text-align: left; }
.wf-notice { margin: 4px 8px 0; }
@media (max-width: 900px) {
  .cust-list { align-self: stretch; }
  .lib-cols > * { min-width: 0; }
}

/* Audit round 3: phone reply box tabs stay on one line */
@media (max-width: 900px) {
  .composer-tabs { flex-wrap: nowrap; }
  .composer-tabs button { white-space: nowrap; }
  .saved-btn kbd { display: none; }
  .saved-btn { padding: 0 10px; }
}

/* Audit round 4 */
.picker-foot { position: sticky; bottom: -16px; background: var(--card); padding: 8px 0; width: 100%; }
.file-card.missing { opacity: .75; }
#rows.archive .c-check { visibility: hidden; pointer-events: none; }
.team-hint { font-size: 12px; color: var(--muted); }

/* Replies: files and pasted screenshots (2026-11-20) */
.reply-files { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; padding: 0 6px; }
.reply-files:empty { display: none; }
.reply-shot { position: relative; display: inline-block; }
.reply-shot img { display: block; height: 64px; max-width: 120px; object-fit: cover; border-radius: 8px; border: 1px solid var(--line); }
.reply-shot .icon-btn { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; border-radius: 50%; background: var(--card); box-shadow: var(--shadow); }
.attach-btn { cursor: pointer; }

/* Final pass 2026-11-20 */
.row.unread .row-name::after { content: none; }
.row.unread .row-who { position: relative; }
.row.unread .row-who::after { content: ""; flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--ink); }
.bulkbar:not([hidden]) { position: sticky; top: 0; z-index: 3; }
.menu .cal button.cal-day.past { color: var(--muted); opacity: .45; }
