/* Relay — macOS-flavoured look. Light and dark follow the system. */
:root {
  color-scheme: light dark;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI Variable Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI Variable Display", "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --accent: #0a84ff;
  --accent-strong: #0071e3;
  --accent-soft: rgba(10, 132, 255, .12);
  --on-accent: #fff;

  --bg: #ffffff;
  --bg-2: #f5f5f7;
  --bg-3: #ebebef;
  --sidebar: rgba(240, 240, 244, .74);
  --toolbar: rgba(255, 255, 255, .82);
  --text: #1d1d1f;
  --text-2: #6e6e73;
  --text-3: #a1a1a6;
  --sep: rgba(0, 0, 0, .085);
  --sep-strong: rgba(0, 0, 0, .14);
  --hover: rgba(0, 0, 0, .045);
  --press: rgba(0, 0, 0, .08);
  --sel-muted: rgba(0, 0, 0, .065);
  --card: #ffffff;
  --field: #ffffff;
  --field-border: rgba(0, 0, 0, .13);
  --bubble-me: #f2f2f7;
  --code-bg: rgba(0, 0, 0, .05);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, .06), 0 0 0 .5px rgba(0, 0, 0, .07);
  --shadow-md: 0 6px 20px rgba(0, 0, 0, .10), 0 0 0 .5px rgba(0, 0, 0, .08);
  --shadow-lg: 0 30px 80px rgba(0, 0, 0, .25), 0 0 0 .5px rgba(0, 0, 0, .14);
  --scrim: rgba(0, 0, 0, .22);
  --wallpaper:
    radial-gradient(1200px 800px at 8% 10%, #c9d6ff 0%, transparent 60%),
    radial-gradient(1000px 900px at 92% 18%, #ffd3e2 0%, transparent 55%),
    radial-gradient(1200px 900px at 60% 100%, #c8f1e0 0%, transparent 60%),
    linear-gradient(160deg, #eef1fb, #f7eef4 50%, #eef7f3);

  --red: #ff3b30; --orange: #ff9500; --yellow: #ffcc00; --green: #34c759; --mint: #00c7be; --teal: #30b0c7;
  --cyan: #32ade6; --blue: #007aff; --indigo: #5856d6; --purple: #af52de; --pink: #ff2d55; --gray: #8e8e93;

  --r-sm: 6px;
  --r: 10px;
  --r-lg: 14px;
  --sidebar-w: 236px;
  --list-w: 380px;
  --toolbar-h: 52px;
  --safe-b: env(safe-area-inset-bottom, 0px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --accent: #0a84ff;
    --accent-strong: #409cff;
    --accent-soft: rgba(10, 132, 255, .22);
    --bg: #1c1c1e;
    --bg-2: #232325;
    --bg-3: #2c2c2e;
    --sidebar: rgba(38, 38, 42, .72);
    --toolbar: rgba(28, 28, 30, .82);
    --text: #f5f5f7;
    --text-2: #a1a1a6;
    --text-3: #6e6e73;
    --sep: rgba(255, 255, 255, .085);
    --sep-strong: rgba(255, 255, 255, .15);
    --hover: rgba(255, 255, 255, .06);
    --press: rgba(255, 255, 255, .1);
    --sel-muted: rgba(255, 255, 255, .08);
    --card: #232325;
    --field: rgba(255, 255, 255, .06);
    --field-border: rgba(255, 255, 255, .12);
    --bubble-me: #2c2c2e;
    --code-bg: rgba(255, 255, 255, .08);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .3), 0 0 0 .5px rgba(255, 255, 255, .06);
    --shadow-md: 0 8px 24px rgba(0, 0, 0, .45), 0 0 0 .5px rgba(255, 255, 255, .08);
    --shadow-lg: 0 30px 90px rgba(0, 0, 0, .6), 0 0 0 .5px rgba(255, 255, 255, .12);
    --scrim: rgba(0, 0, 0, .45);
    --wallpaper:
      radial-gradient(1200px 800px at 10% 8%, #1e2a5a 0%, transparent 60%),
      radial-gradient(1000px 900px at 92% 20%, #4a1d3d 0%, transparent 55%),
      radial-gradient(1200px 900px at 55% 100%, #0f3b33 0%, transparent 60%),
      linear-gradient(160deg, #0d0f1a, #141019 50%, #0b1512);
    --red: #ff453a; --orange: #ff9f0a; --yellow: #ffd60a; --green: #30d158; --mint: #63e6e2; --teal: #40c8e0;
    --cyan: #64d2ff; --blue: #0a84ff; --indigo: #5e5ce6; --purple: #bf5af2; --pink: #ff375f; --gray: #98989d;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font: 13.5px/1.45 var(--font);
  color: var(--text);
  background: var(--wallpaper);
  background-color: var(--bg-2);
  background-attachment: fixed;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  letter-spacing: -.003em;
}
button, input, textarea, select { font: inherit; color: inherit; letter-spacing: inherit; }
button { cursor: default; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
::selection { background: var(--accent-soft); }
svg.i { width: 18px; height: 18px; flex: none; stroke: currentColor; fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
svg.i.sm { width: 15px; height: 15px; }
svg.i.xs { width: 12px; height: 12px; stroke-width: 2; }
svg.i.lg { width: 22px; height: 22px; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

/* ---------- shell ---------- */
.shell {
  position: fixed; inset: 0;
  display: grid;
  grid-template-columns: var(--sidebar-w) var(--list-w) 1fr;
}
.shell.no-sidebar { grid-template-columns: 0 var(--list-w) 1fr; }
.shell.no-sidebar .sidebar { visibility: hidden; }

.sidebar {
  background: var(--sidebar);
  -webkit-backdrop-filter: blur(40px) saturate(180%);
  backdrop-filter: blur(40px) saturate(180%);
  border-right: .5px solid var(--sep-strong);
  display: flex; flex-direction: column; min-width: 0; overflow: hidden;
}
.sidebar-head { height: var(--toolbar-h); display: flex; align-items: center; gap: 9px; padding: 0 14px 0 16px; flex: none; }
.brand { display: flex; align-items: center; gap: 9px; font: 650 15px/1 var(--font-display); letter-spacing: -.015em; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 7px; display: grid; place-items: center; color: #fff;
  background: linear-gradient(140deg, #6e6cf0, #0a84ff 70%, #36c5f0);
  box-shadow: inset 0 0 0 .5px rgba(255,255,255,.35), 0 1px 2px rgba(0,0,0,.18);
}
.brand-mark svg { width: 15px; height: 15px; stroke: #fff; stroke-width: 2.2; }
.sidebar-scroll { flex: 1; overflow-y: auto; padding: 4px 10px 12px; }
.compose-btn {
  width: 100%; display: flex; align-items: center; justify-content: center; gap: 7px;
  height: 34px; border-radius: 9px; border: 0; margin: 2px 0 10px;
  background: var(--accent); color: var(--on-accent); font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .15), inset 0 .5px 0 rgba(255,255,255,.25);
  transition: transform .08s ease, filter .15s;
}
.compose-btn:hover { filter: brightness(1.06); }
.compose-btn:active { transform: scale(.985); filter: brightness(.95); }
.side-section { margin-top: 12px; }
.side-label {
  font-size: 11px; font-weight: 600; color: var(--text-3); padding: 0 8px 4px; letter-spacing: .01em;
  display: flex; align-items: center; justify-content: space-between;
}
.side-item {
  display: flex; align-items: center; gap: 9px; width: 100%; height: 30px; padding: 0 8px;
  border: 0; background: none; border-radius: 7px; text-align: left; color: var(--text);
  transition: background .12s;
}
.side-item:hover { background: var(--hover); }
.side-item.active { background: var(--sel-muted); font-weight: 550; }
.side-item .i { color: var(--accent); }
.side-item .label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .count { font-size: 12px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.side-item .badge {
  min-width: 19px; height: 18px; padding: 0 6px; border-radius: 9px; font-size: 11.5px; font-weight: 600;
  background: var(--accent); color: #fff; display: grid; place-items: center; font-variant-numeric: tabular-nums;
}
.side-item .badge.orange { background: var(--orange); }
.space-dot { width: 18px; height: 18px; border-radius: 5px; display: grid; place-items: center; color: #fff; font-size: 10.5px; font-weight: 700; flex: none; box-shadow: inset 0 0 0 .5px rgba(255,255,255,.25); }
.sidebar-foot {
  flex: none; border-top: .5px solid var(--sep); padding: 8px 10px calc(8px + var(--safe-b));
  display: flex; flex-direction: column; gap: 6px;
}
.desk-pill { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-2); padding: 2px 8px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray); flex: none; }
.dot.online { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 25%, transparent); }
.dot.busy { background: var(--orange); }
.me-btn { display: flex; align-items: center; gap: 9px; border: 0; background: none; padding: 5px 8px; border-radius: 8px; width: 100%; text-align: left; }
.me-btn:hover { background: var(--hover); }
.me-btn .who { flex: 1; min-width: 0; line-height: 1.2; }
.me-btn .who b { display: block; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.me-btn .who span { font-size: 11.5px; color: var(--text-2); }

/* ---------- panes ---------- */
.pane { background: var(--bg); display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.list-pane { border-right: .5px solid var(--sep-strong); background: var(--bg); }
.toolbar {
  height: var(--toolbar-h); flex: none; display: flex; align-items: center; gap: 8px; padding: 0 12px 0 16px;
  border-bottom: .5px solid var(--sep); background: var(--toolbar);
  -webkit-backdrop-filter: blur(20px) saturate(180%); backdrop-filter: blur(20px) saturate(180%);
  position: relative; z-index: 2;
}
.toolbar .title { min-width: 0; flex: 1; line-height: 1.15; }
.toolbar .title b { display: block; font: 650 15px/1.2 var(--font-display); letter-spacing: -.015em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.toolbar .title span { font-size: 11.5px; color: var(--text-2); }
.tb-btn {
  height: 30px; min-width: 30px; padding: 0 7px; border-radius: 7px; border: 0; background: none; color: var(--text-2);
  display: inline-flex; align-items: center; justify-content: center; gap: 5px; transition: background .12s, color .12s;
}
.tb-btn:hover { background: var(--hover); color: var(--text); }
.tb-btn:active { background: var(--press); }
.tb-btn.on { color: var(--accent); }
.tb-btn:disabled { opacity: .4; }
.search {
  display: flex; align-items: center; gap: 6px; height: 28px; padding: 0 8px; margin: 8px 12px 6px;
  border-radius: 8px; background: var(--bg-3); color: var(--text-2); flex: none;
}
.search input { border: 0; outline: 0; background: none; flex: 1; min-width: 0; height: 100%; font-size: 13px; color: var(--text); }
.search:focus-within { box-shadow: 0 0 0 3.5px var(--accent-soft), 0 0 0 1px var(--accent); }
.search kbd { font: 11px var(--font); color: var(--text-3); border: .5px solid var(--sep-strong); border-radius: 4px; padding: 0 4px; }
.filters { display: flex; gap: 6px; padding: 0 12px 8px; overflow-x: auto; flex: none; scrollbar-width: none; }
.chip-btn {
  height: 24px; padding: 0 10px; border-radius: 12px; border: .5px solid var(--sep-strong); background: none;
  font-size: 12px; color: var(--text-2); white-space: nowrap; transition: all .12s;
}
.chip-btn:hover { background: var(--hover); color: var(--text); }
.chip-btn.on { background: var(--accent); border-color: var(--accent); color: #fff; }

.list { flex: 1; overflow-y: auto; padding: 2px 8px 24px; overscroll-behavior: contain; }
.row {
  display: grid; grid-template-columns: 10px 32px 1fr; gap: 0 10px; padding: 10px 10px 10px 4px;
  border-radius: 10px; position: relative; cursor: default; transition: background .1s;
}
.row + .row::before { content: ""; position: absolute; left: 56px; right: 10px; top: 0; border-top: .5px solid var(--sep); }
.row:hover { background: var(--hover); }
.row.active, .row.active:hover { background: var(--accent); color: #fff; }
.row.active::before, .row.active + .row::before { display: none; }
.row .unread { width: 9px; height: 9px; border-radius: 50%; background: var(--accent); margin-top: 6px; }
.row.active .unread { background: #fff; }
.row .head { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.row .who { font-weight: 600; flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
.row .time { font-size: 12px; color: var(--text-2); white-space: nowrap; font-variant-numeric: tabular-nums; }
.row .ttl { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 1px; }
.row.fresh .ttl { font-weight: 600; }
.row .ex { font-size: 12.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; margin-top: 1px; line-height: 1.38; }
.row .meta { display: flex; align-items: center; gap: 6px; margin-top: 6px; flex-wrap: wrap; }
.row.active .time, .row.active .ex, .row.active .meta-txt { color: rgba(255,255,255,.85); }
.row.active .pill { background: rgba(255,255,255,.22) !important; color: #fff !important; }
.row.active .pill .pd { background: #fff !important; }
.meta-txt { font-size: 11.5px; color: var(--text-2); display: inline-flex; align-items: center; gap: 3px; }
.row .note { font-size: 11.5px; color: var(--accent); display: flex; align-items: center; gap: 4px; margin-top: 4px; }
.row.active .note { color: #fff; }

.pill {
  display: inline-flex; align-items: center; gap: 5px; height: 20px; padding: 0 8px; border-radius: 10px;
  font-size: 11.5px; font-weight: 550; white-space: nowrap; line-height: 1;
}
.pill .pd { width: 6px; height: 6px; border-radius: 50%; }
.pill.lg { height: 26px; padding: 0 11px; border-radius: 13px; font-size: 12.5px; }
.pill.lg .pd { width: 7px; height: 7px; }
button.pill { border: 0; transition: filter .12s; }
button.pill:hover { filter: brightness(.96); }

.empty { flex: 1; display: grid; place-items: center; text-align: center; color: var(--text-2); padding: 40px 24px; }
.empty .glyph {
  width: 64px; height: 64px; border-radius: 18px; display: grid; place-items: center; margin: 0 auto 14px;
  background: var(--bg-3); color: var(--text-3);
}
.empty .glyph svg { width: 30px; height: 30px; stroke-width: 1.5; }
.empty h3 { margin: 0 0 4px; font: 600 16px var(--font-display); color: var(--text); letter-spacing: -.01em; }
.empty p { margin: 0; max-width: 300px; font-size: 13px; }

/* ---------- detail ---------- */
.detail-scroll { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.detail-inner { max-width: 820px; margin: 0 auto; padding: 22px 28px 28px; }
.item-head h1 { font: 700 23px/1.22 var(--font-display); letter-spacing: -.022em; margin: 2px 0 10px; word-wrap: break-word; }
.item-head h1 .num { color: var(--text-3); font-weight: 500; margin-right: 6px; }
.item-head .facts { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.fact { display: inline-flex; align-items: center; gap: 5px; font-size: 12.5px; color: var(--text-2); }
.fact-btn { border: 0; background: var(--bg-3); border-radius: 13px; height: 26px; padding: 0 10px; display: inline-flex; align-items: center; gap: 6px; font-size: 12.5px; color: var(--text); }
.fact-btn:hover { background: var(--press); }
.fact-btn .i { color: var(--text-2); }
.agent-note {
  margin-top: 14px; display: flex; align-items: center; gap: 10px; padding: 9px 12px; border-radius: 10px;
  background: linear-gradient(90deg, var(--accent-soft), transparent 80%); font-size: 13px;
}
.agent-note .spark { animation: pulse 1.6s ease-in-out infinite; color: var(--accent); }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: .45; transform: scale(.88); } }

.stepper { display: flex; align-items: center; gap: 0; margin: 18px 0 4px; }
.step { display: flex; align-items: center; gap: 7px; font-size: 12px; color: var(--text-3); white-space: nowrap; }
.step .ball { width: 18px; height: 18px; border-radius: 50%; border: 1.5px solid var(--sep-strong); display: grid; place-items: center; background: var(--bg); }
.step.done { color: var(--text-2); }
.step.done .ball { background: var(--green); border-color: var(--green); color: #fff; }
.step.now { color: var(--text); font-weight: 600; }
.step.now .ball { border-color: var(--accent); background: var(--accent); color: #fff; box-shadow: 0 0 0 4px var(--accent-soft); }
.step-line { flex: 1; height: 1.5px; background: var(--sep-strong); margin: 0 8px; min-width: 14px; }
.step-line.done { background: var(--green); }

.msg { display: grid; grid-template-columns: 36px 1fr; gap: 12px; margin-top: 22px; }
.msg .bubble { min-width: 0; }
.msg .by { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.msg .by b { font-weight: 600; font-size: 13.5px; }
.msg .by .t { color: var(--text-3); font-size: 12px; }
.msg .by .tag { font-size: 10.5px; font-weight: 650; padding: 1px 6px; border-radius: 5px; letter-spacing: .02em; text-transform: uppercase; }
.msg .content { margin-top: 4px; padding: 11px 14px; border-radius: 4px 14px 14px 14px; background: var(--bubble-me); word-wrap: break-word; overflow-wrap: anywhere; }
.msg.original .content { background: none; padding: 2px 0 0; border-radius: 0; font-size: 14px; }
.msg.agent .content { background: color-mix(in srgb, var(--agent-color, var(--accent)) 9%, var(--bg)); box-shadow: inset 0 0 0 .5px color-mix(in srgb, var(--agent-color, var(--accent)) 25%, transparent); }
.msg .tools { opacity: 0; transition: opacity .12s; margin-left: auto; display: flex; gap: 2px; }
.msg:hover .tools { opacity: 1; }
.msg .tools button { border: 0; background: none; color: var(--text-3); height: 22px; padding: 0 5px; border-radius: 5px; font-size: 12px; }
.msg .tools button:hover { background: var(--hover); color: var(--text); }
.msg .deleted { color: var(--text-3); font-style: italic; }
.event-line { display: flex; align-items: center; justify-content: center; gap: 8px; margin: 18px 0 0; font-size: 12px; color: var(--text-2); text-align: center; flex-wrap: wrap; }
.event-line::before, .event-line::after { content: ""; flex: 1; border-top: .5px solid var(--sep); min-width: 20px; }
.event-line .t { color: var(--text-3); }

.md { font-size: 13.5px; line-height: 1.55; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: 0 0 .6em; }
.md h1, .md h2, .md h3, .md h4 { font-family: var(--font-display); letter-spacing: -.01em; margin: 1em 0 .4em; line-height: 1.3; }
.md h1 { font-size: 18px; } .md h2 { font-size: 16px; } .md h3, .md h4 { font-size: 14px; }
.md ul, .md ol { margin: 0 0 .6em; padding-left: 1.4em; }
.md li { margin: .15em 0; }
.md code { font: 12.5px/1.4 var(--mono); background: var(--code-bg); padding: 1px 5px; border-radius: 5px; }
.md pre { font: 12.5px/1.5 var(--mono); background: var(--code-bg); padding: 10px 12px; border-radius: 9px; overflow-x: auto; margin: 0 0 .7em; }
.md pre code { background: none; padding: 0; }
.md blockquote { margin: 0 0 .6em; padding: 2px 12px; border-left: 3px solid var(--sep-strong); color: var(--text-2); }
.md hr { border: 0; border-top: .5px solid var(--sep-strong); margin: 1em 0; }
.md table { border-collapse: collapse; margin: 0 0 .7em; font-size: 12.5px; display: block; overflow-x: auto; }
.md th, .md td { border: .5px solid var(--sep-strong); padding: 5px 9px; text-align: left; }
.md th { background: var(--code-bg); font-weight: 600; }
.md .mention { color: var(--accent); font-weight: 550; }
.md a { word-break: break-word; }

.atts { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.thumb {
  position: relative; width: 148px; height: 104px; border-radius: 10px; overflow: hidden; border: 0; padding: 0;
  background: var(--bg-3); box-shadow: var(--shadow-sm); cursor: zoom-in; transition: transform .15s ease, box-shadow .15s;
}
.thumb:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.single { width: auto; height: auto; max-width: min(100%, 520px); max-height: 360px; }
.thumb.single img { width: auto; max-width: 100%; max-height: 360px; object-fit: contain; }
.file-card {
  display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 9px; border-radius: 10px; background: var(--card);
  box-shadow: var(--shadow-sm); min-width: 200px; max-width: 320px; color: var(--text); text-decoration: none !important;
}
.file-card:hover { box-shadow: var(--shadow-md); }
.file-icon { width: 34px; height: 40px; border-radius: 6px; display: grid; place-items: center; font-size: 9.5px; font-weight: 700; color: #fff; flex: none; text-transform: uppercase; letter-spacing: .02em; }
.file-card .fn { font-size: 13px; font-weight: 550; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-card .fs { font-size: 11.5px; color: var(--text-2); }

.callout { display: flex; align-items: center; gap: 12px; padding: 12px 14px; border-radius: 12px; margin-top: 22px; font-size: 13px; flex-wrap: wrap; }
.callout .txt { flex: 1; min-width: 200px; }
.callout b { display: block; font-size: 13.5px; }
.callout.green { background: color-mix(in srgb, var(--green) 12%, var(--bg)); }
.callout.orange { background: color-mix(in srgb, var(--orange) 13%, var(--bg)); }
.callout.gray { background: var(--bg-2); }

/* ---------- composer ---------- */
.composer-wrap { flex: none; padding: 10px 20px calc(14px + var(--safe-b)); background: linear-gradient(to top, var(--bg) 70%, transparent); }
.composer {
  max-width: 780px; margin: 0 auto; border-radius: 16px; background: var(--field);
  box-shadow: var(--shadow-md); border: .5px solid var(--field-border); transition: box-shadow .15s;
}
.composer:focus-within { box-shadow: var(--shadow-md), 0 0 0 3.5px var(--accent-soft); }
.composer textarea {
  display: block; width: 100%; border: 0; outline: 0; background: none; resize: none; padding: 11px 14px 4px;
  min-height: 42px; max-height: 260px; line-height: 1.45; font-size: 14px;
}
.composer .bar { display: flex; align-items: center; gap: 4px; padding: 4px 6px 6px 8px; }
.composer .hint { font-size: 11.5px; color: var(--text-3); margin-left: 4px; flex: 1; }
.send-btn {
  width: 30px; height: 30px; border-radius: 50%; border: 0; display: grid; place-items: center;
  background: var(--accent); color: #fff; transition: transform .1s, opacity .15s;
}
.send-btn svg { stroke: #fff; stroke-width: 2.4; }
.send-btn:disabled { opacity: .35; }
.send-btn:not(:disabled):active { transform: scale(.92); }
.drafts { display: flex; gap: 8px; flex-wrap: wrap; padding: 10px 12px 2px; }
.draft {
  position: relative; height: 58px; min-width: 58px; max-width: 200px; border-radius: 9px; background: var(--bg-3);
  overflow: hidden; display: flex; align-items: center; gap: 8px; padding: 0 10px 0 0; font-size: 12px;
}
.draft.img { padding: 0; width: 76px; }
.draft img { width: 100%; height: 100%; object-fit: cover; }
.draft .fi { width: 40px; height: 100%; display: grid; place-items: center; background: var(--press); color: var(--text-2); }
.draft .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 130px; }
.draft .x {
  position: absolute; top: 3px; right: 3px; width: 18px; height: 18px; border-radius: 50%; border: 0;
  background: rgba(0,0,0,.55); color: #fff; display: grid; place-items: center; padding: 0;
}
.draft .x svg { width: 10px; height: 10px; stroke: #fff; stroke-width: 2.6; }
.draft .bar-p { position: absolute; left: 0; bottom: 0; height: 3px; background: var(--accent); transition: width .2s; }
.draft.err { outline: 1.5px solid var(--red); }

.drop-overlay {
  position: absolute; inset: 10px; z-index: 30; border-radius: 16px; border: 2px dashed var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, transparent); display: grid; place-items: center;
  color: var(--accent); font-weight: 600; font-size: 15px; pointer-events: none;
  -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
}

/* ---------- avatars ---------- */
.av {
  border-radius: 50%; display: grid; place-items: center; color: #fff; font-weight: 600; flex: none;
  box-shadow: inset 0 0 0 .5px rgba(255,255,255,.25); user-select: none; position: relative;
}
.av.agent { border-radius: 30%; }
.av.agent svg { stroke: #fff; fill: #fff; stroke-width: 0; }
.av .ai { position: absolute; right: -3px; bottom: -3px; font-size: 7.5px; font-weight: 800; background: var(--bg); color: var(--text-2); border-radius: 4px; padding: 0 2px; line-height: 10px; box-shadow: var(--shadow-sm); }

/* ---------- sheets, menus, popovers ---------- */
.scrim { position: fixed; inset: 0; z-index: 50; background: var(--scrim); display: flex; justify-content: center; align-items: flex-start; animation: fade .18s ease; }
@keyframes fade { from { opacity: 0; } }
.sheet {
  margin-top: 6vh; width: min(640px, calc(100vw - 24px)); max-height: 86vh; display: flex; flex-direction: column;
  background: var(--bg); border-radius: 14px; box-shadow: var(--shadow-lg); overflow: hidden;
  animation: drop .26s cubic-bezier(.2, .9, .3, 1.1);
}
@keyframes drop { from { transform: translateY(-14px) scale(.985); opacity: 0; } }
.sheet.wide { width: min(760px, calc(100vw - 24px)); }
.sheet-head { display: flex; align-items: center; gap: 10px; padding: 16px 18px 6px; }
.sheet-head h2 { margin: 0; flex: 1; font: 650 17px var(--font-display); letter-spacing: -.015em; }
.sheet-body { padding: 8px 18px 16px; overflow-y: auto; }
.sheet-foot { display: flex; align-items: center; gap: 8px; padding: 12px 18px 16px; border-top: .5px solid var(--sep); }
.sheet-foot .grow { flex: 1; font-size: 12px; color: var(--text-3); }

.field { display: block; margin-top: 14px; }
.field > .lbl { display: block; font-size: 12px; font-weight: 600; color: var(--text-2); margin-bottom: 6px; }
.field > .lbl .opt { font-weight: 400; color: var(--text-3); }
.input, .textarea, .select {
  width: 100%; border: .5px solid var(--field-border); background: var(--field); border-radius: 8px; outline: 0;
  padding: 8px 10px; font-size: 14px; transition: box-shadow .15s, border-color .15s; box-shadow: 0 .5px 1px rgba(0,0,0,.04);
}
.input:focus, .textarea:focus, .select:focus { border-color: var(--accent); box-shadow: 0 0 0 3.5px var(--accent-soft); }
.textarea { resize: vertical; min-height: 120px; line-height: 1.5; }
.row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.seg { display: inline-flex; padding: 2px; border-radius: 9px; background: var(--bg-3); gap: 2px; flex-wrap: wrap; }
.seg button {
  border: 0; background: none; height: 28px; padding: 0 12px; border-radius: 7px; font-size: 13px; color: var(--text);
  display: inline-flex; align-items: center; gap: 6px; transition: background .12s;
}
.seg button:hover { background: var(--hover); }
.seg button.on { background: var(--bg); box-shadow: 0 1px 3px rgba(0,0,0,.12), 0 0 0 .5px rgba(0,0,0,.06); font-weight: 550; }
.seg.full { display: flex; }
.seg.full button { flex: 1; justify-content: center; }

.space-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.space-opt {
  border: .5px solid var(--field-border); background: var(--field); border-radius: 10px; padding: 9px 10px; text-align: left;
  display: flex; align-items: center; gap: 9px; transition: all .12s; min-width: 0;
}
.space-opt:hover { background: var(--hover); }
.space-opt.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.space-opt .nm { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.space-opt .ds { font-size: 11px; color: var(--text-2); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.dropzone {
  margin-top: 8px; border: 1.5px dashed var(--sep-strong); border-radius: 12px; padding: 14px; text-align: center;
  color: var(--text-2); font-size: 13px; transition: all .15s; background: var(--bg-2);
}
.dropzone.over { border-color: var(--accent); background: var(--accent-soft); color: var(--accent); }
.dropzone button.link { border: 0; background: none; color: var(--accent); padding: 0; font-weight: 550; cursor: pointer; }
.dropzone .drafts { padding: 10px 0 0; justify-content: center; }

.btn {
  height: 30px; padding: 0 14px; border-radius: 8px; border: .5px solid var(--field-border); background: var(--field);
  font-weight: 550; font-size: 13px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  box-shadow: 0 .5px 1px rgba(0,0,0,.06); transition: filter .12s, transform .08s;
}
.btn:hover { filter: brightness(.97); }
.btn:active { transform: scale(.98); }
.btn.primary { background: var(--accent); color: #fff; border-color: transparent; box-shadow: 0 1px 2px rgba(0,0,0,.15), inset 0 .5px 0 rgba(255,255,255,.2); }
.btn.primary:hover { filter: brightness(1.07); }
.btn.green { background: var(--green); color: #fff; border-color: transparent; }
.btn.danger { color: var(--red); }
.btn:disabled { opacity: .5; pointer-events: none; }
.btn.lg { height: 38px; padding: 0 18px; font-size: 14px; border-radius: 10px; }

.menu {
  position: fixed; z-index: 80; min-width: 200px; padding: 5px; border-radius: 10px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  box-shadow: var(--shadow-lg); animation: pop .14s ease-out; max-height: 70vh; overflow-y: auto;
}
@keyframes pop { from { opacity: 0; transform: scale(.97); } }
.menu button {
  width: 100%; display: flex; align-items: center; gap: 9px; border: 0; background: none; padding: 5px 9px;
  border-radius: 6px; text-align: left; font-size: 13px; height: 28px;
}
.menu button:hover { background: var(--accent); color: #fff; }
.menu button:hover .i, .menu button:hover .k { color: #fff; }
.menu button .i { color: var(--text-2); }
.menu button .check { width: 14px; color: var(--accent); }
.menu button:hover .check { color: #fff; }
.menu .k { margin-left: auto; color: var(--text-3); font-size: 12px; }
.menu hr { border: 0; border-top: .5px solid var(--sep-strong); margin: 5px 6px; }
.menu .mlabel { font-size: 11px; font-weight: 600; color: var(--text-3); padding: 4px 9px 2px; }

.toast-stack { position: fixed; z-index: 90; top: 14px; right: 14px; display: flex; flex-direction: column; gap: 8px; pointer-events: none; }
.toast {
  pointer-events: auto; width: 340px; max-width: calc(100vw - 28px); display: flex; gap: 10px; padding: 11px 13px; border-radius: 14px;
  background: color-mix(in srgb, var(--bg) 82%, transparent); -webkit-backdrop-filter: blur(30px) saturate(180%); backdrop-filter: blur(30px) saturate(180%);
  box-shadow: var(--shadow-lg); animation: slidein .3s cubic-bezier(.2,.9,.3,1.1); cursor: default;
}
@keyframes slidein { from { transform: translateX(30px); opacity: 0; } }
.toast b { display: block; font-size: 13px; }
.toast span { font-size: 12.5px; color: var(--text-2); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.toast.error b { color: var(--red); }

.lightbox { position: fixed; inset: 0; z-index: 100; background: rgba(0,0,0,.82); display: flex; flex-direction: column; animation: fade .18s; -webkit-backdrop-filter: blur(20px); backdrop-filter: blur(20px); }
.lightbox .lb-bar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; color: #fff; }
.lightbox .lb-bar .nm { flex: 1; font-weight: 600; font-size: 13px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lightbox .lb-bar .tb-btn { color: rgba(255,255,255,.8); }
.lightbox .lb-bar .tb-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.lightbox .stage { flex: 1; display: grid; place-items: center; padding: 0 16px 16px; min-height: 0; position: relative; }
.lightbox .stage img, .lightbox .stage video { max-width: 100%; max-height: 100%; border-radius: 6px; box-shadow: 0 20px 60px rgba(0,0,0,.5); animation: zoomin .22s ease; }
.lightbox .stage iframe { width: min(1000px, 100%); height: 100%; border: 0; border-radius: 8px; background: #fff; }
@keyframes zoomin { from { transform: scale(.96); opacity: 0; } }
.lightbox .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.14); color: #fff; display: grid; place-items: center; }
.lightbox .nav:hover { background: rgba(255,255,255,.24); }
.lightbox .nav.l { left: 18px; } .lightbox .nav.r { right: 18px; }

/* ---------- auth ---------- */
.auth { position: fixed; inset: 0; display: grid; place-items: center; padding: 20px; overflow-y: auto; }
.auth-card {
  width: min(380px, 100%); padding: 34px 30px 26px; border-radius: 22px; text-align: center;
  background: color-mix(in srgb, var(--bg) 62%, transparent); -webkit-backdrop-filter: blur(40px) saturate(180%); backdrop-filter: blur(40px) saturate(180%);
  box-shadow: var(--shadow-lg); animation: drop .4s cubic-bezier(.2,.9,.3,1.1);
}
.app-icon {
  width: 76px; height: 76px; border-radius: 19px; margin: 0 auto 16px; display: grid; place-items: center;
  background: linear-gradient(140deg, #7472f2, #0a84ff 62%, #3fd0f5);
  box-shadow: 0 10px 30px rgba(10,132,255,.35), inset 0 0 0 .5px rgba(255,255,255,.4), inset 0 1px 0 rgba(255,255,255,.35);
}
.app-icon svg { width: 42px; height: 42px; stroke: #fff; stroke-width: 2; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.auth h1 { margin: 0; font: 700 26px var(--font-display); letter-spacing: -.025em; }
.auth .sub { color: var(--text-2); margin: 6px 0 22px; font-size: 13.5px; }
.auth .stack { display: flex; flex-direction: column; gap: 10px; text-align: left; }
.auth .input { height: 40px; border-radius: 10px; font-size: 15px; padding: 0 14px; background: color-mix(in srgb, var(--field) 85%, transparent); }
.go-field { position: relative; }
.go-field .input { padding-right: 46px; }
.go-field button { position: absolute; right: 6px; top: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; background: var(--accent); display: grid; place-items: center; }
.go-field button svg { stroke: #fff; stroke-width: 2.4; width: 15px; height: 15px; }
.go-field button:disabled { opacity: .35; }
.auth .err { color: var(--red); font-size: 12.5px; text-align: center; min-height: 18px; }
.auth .linkish { border: 0; background: none; color: var(--accent); font-size: 13px; padding: 4px; cursor: pointer; }
.auth .muted { color: var(--text-2); font-size: 12.5px; text-align: center; }
.auth .who-chip { display: inline-flex; align-items: center; gap: 8px; margin: 0 auto 4px; padding: 4px 12px 4px 4px; border-radius: 20px; background: var(--hover); font-size: 13px; border: 0; }

/* ---------- settings ---------- */
.tabs { display: flex; gap: 2px; padding: 0 18px; border-bottom: .5px solid var(--sep); }
.tabs button { border: 0; background: none; padding: 9px 12px; font-size: 13px; color: var(--text-2); border-bottom: 2px solid transparent; margin-bottom: -.5px; }
.tabs button.on { color: var(--text); border-bottom-color: var(--accent); font-weight: 600; }
.group { background: var(--bg-2); border-radius: 12px; margin-top: 14px; overflow: hidden; }
.group .gr { display: flex; align-items: center; gap: 12px; padding: 11px 14px; min-height: 46px; }
.group .gr + .gr { border-top: .5px solid var(--sep); }
.group .gr .grow { flex: 1; min-width: 0; }
.group .gr .grow b { display: block; font-weight: 550; font-size: 13px; }
.group .gr .grow span { font-size: 12px; color: var(--text-2); }
.switch { width: 38px; height: 22px; border-radius: 11px; border: 0; background: var(--sep-strong); position: relative; transition: background .2s; flex: none; padding: 0; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.25); transition: transform .2s cubic-bezier(.3,.9,.4,1.2); }
.switch.on { background: var(--green); }
.switch.on::after { transform: translateX(16px); }
.code-box { font: 600 18px var(--mono); letter-spacing: .02em; padding: 8px 12px; background: var(--bg); border-radius: 8px; user-select: all; }
.state-tag { font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 6px; background: var(--bg-3); color: var(--text-2); }
.state-tag.pending { background: color-mix(in srgb, var(--orange) 18%, transparent); color: var(--orange); }
.state-tag.admin { background: var(--accent-soft); color: var(--accent); }

.skeleton { background: linear-gradient(90deg, var(--bg-3), var(--bg-2), var(--bg-3)); background-size: 200% 100%; animation: shimmer 1.2s infinite; border-radius: 6px; }
@keyframes shimmer { to { background-position: -200% 0; } }

.mobile-only { display: none !important; }
.fab { display: none; }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  :root { --list-w: 340px; --sidebar-w: 214px; }
}
@media (max-width: 960px) {
  .shell { grid-template-columns: var(--list-w) 1fr; }
  .shell .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0; width: 270px; z-index: 40; transform: translateX(-105%);
    transition: transform .28s cubic-bezier(.2,.9,.3,1);
    background: color-mix(in srgb, var(--bg-2) 88%, transparent);
  }
  .shell.drawer .sidebar { transform: none; visibility: visible; box-shadow: var(--shadow-lg); }
  .shell.no-sidebar { grid-template-columns: var(--list-w) 1fr; }
  .drawer-scrim { position: fixed; inset: 0; z-index: 39; background: var(--scrim); animation: fade .2s; }
  .hide-tablet { display: none !important; }
}
@media (max-width: 700px) {
  body { font-size: 15px; }
  .shell { grid-template-columns: 1fr; }
  .shell.no-sidebar { grid-template-columns: 1fr; }
  .list-pane { border-right: 0; }
  .detail-pane { position: fixed; inset: 0; z-index: 20; transform: translateX(100%); transition: transform .3s cubic-bezier(.2,.9,.3,1); }
  .shell.show-detail .detail-pane { transform: none; box-shadow: var(--shadow-lg); }
  .shell.show-detail .list-pane { transform: translateX(-25%); transition: transform .3s cubic-bezier(.2,.9,.3,1); }
  .list-pane { transition: transform .3s cubic-bezier(.2,.9,.3,1); }
  .mobile-only { display: inline-flex !important; }
  .desktop-only { display: none !important; }
  .detail-inner { padding: 16px 16px 24px; }
  .item-head h1 { font-size: 21px; }
  .composer-wrap { padding: 8px 10px calc(10px + var(--safe-b)); }
  .composer textarea, .input, .textarea, .select, .search input { font-size: 16px; }
  .row .who, .row .ttl { font-size: 15px; }
  .row .ex { font-size: 14px; }
  .fab {
    display: grid; place-items: center; position: absolute; right: 18px; bottom: calc(22px + var(--safe-b)); z-index: 5;
    width: 54px; height: 54px; border-radius: 50%; border: 0; background: var(--accent); color: #fff;
    box-shadow: 0 8px 24px rgba(10,132,255,.4);
  }
  .fab svg { stroke: #fff; stroke-width: 2.4; width: 24px; height: 24px; }
  .scrim { align-items: flex-end; }
  .sheet { margin: 0; width: 100%; max-height: 94vh; border-radius: 16px 16px 0 0; animation: rise .3s cubic-bezier(.2,.9,.3,1); }
  @keyframes rise { from { transform: translateY(40px); opacity: 0; } }
  .sheet-foot { padding-bottom: calc(14px + var(--safe-b)); }
  .space-grid { grid-template-columns: 1fr 1fr; }
  .row2 { grid-template-columns: 1fr; }
  .stepper .step > span:not(.ball) { display: none; }
  .stepper .step.now > span { display: inline; }
  .stepper .step.now > .ball { display: grid; }
  .thumb { width: calc(50% - 4px); }
  .msg { grid-template-columns: 30px 1fr; gap: 10px; }
  .msg .tools { opacity: 1; }
  .toast-stack { left: 14px; right: 14px; top: calc(10px + env(safe-area-inset-top, 0px)); }
  .toast { width: 100%; }
}
/* The drawer button only exists where the sidebar is a drawer. */
.tablet-up { display: none !important; }
@media (max-width: 960px) { .tablet-up { display: inline-flex !important; } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
