/* Layout: fixed sidebar of panels + main work area (view tabs, table/kanban) + record drawer on the right. */
:root {
  --bg: #f5f6f4;
  --surface: #ffffff;
  --surface-2: #eef0ec;
  --line: #dde1da;
  --ink: #1b211d;
  --ink-2: #59625b;
  --ink-3: #8a938b;
  --accent: #1f6b52;
  --accent-ink: #ffffff;
  --accent-soft: #e2efe8;
  --focus: #2f8f6d;
  --c-red-bg: #fbe4e1; --c-red: #a3281b;
  --c-orange-bg: #fcebd7; --c-orange: #93510b;
  --c-green-bg: #ddf0e3; --c-green: #1e6b3a;
  --c-blue-bg: #e1eaf8; --c-blue: #24508f;
  --c-purple-bg: #ebe3f7; --c-purple: #5b3a8f;
  --c-gray-bg: #eceeea; --c-gray: #545c55;
  --shadow: 0 10px 30px rgba(20, 30, 24, .14);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --r: 6px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121614; --surface: #1a1f1c; --surface-2: #222824; --line: #2e3530;
    --ink: #e6ebe7; --ink-2: #a9b2ab; --ink-3: #737c75;
    --accent: #4fb48c; --accent-ink: #0d1411; --accent-soft: #1d3329; --focus: #6fd0a7;
    --c-red-bg: #3a1f1c; --c-red: #f19b8f;
    --c-orange-bg: #382a19; --c-orange: #efb874;
    --c-green-bg: #1b3324; --c-green: #8fd6a6;
    --c-blue-bg: #1c2a40; --c-blue: #9cbcf0;
    --c-purple-bg: #2c2240; --c-purple: #c4abef;
    --c-gray-bg: #262c28; --c-gray: #b3bbb4;
    --shadow: 0 10px 30px rgba(0, 0, 0, .5);
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #121614; --surface: #1a1f1c; --surface-2: #222824; --line: #2e3530;
  --ink: #e6ebe7; --ink-2: #a9b2ab; --ink-3: #737c75;
  --accent: #4fb48c; --accent-ink: #0d1411; --accent-soft: #1d3329; --focus: #6fd0a7;
  --c-red-bg: #3a1f1c; --c-red: #f19b8f;
  --c-orange-bg: #382a19; --c-orange: #efb874;
  --c-green-bg: #1b3324; --c-green: #8fd6a6;
  --c-blue-bg: #1c2a40; --c-blue: #9cbcf0;
  --c-purple-bg: #2c2240; --c-purple: #c4abef;
  --c-gray-bg: #262c28; --c-gray: #b3bbb4;
  --shadow: 0 10px 30px rgba(0, 0, 0, .5);
  color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.num { font-variant-numeric: tabular-nums; }
.muted { color: var(--ink-3); }

/* ---------- shell ---------- */
.shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); height: 100%; }
.side {
  background: var(--surface); border-right: 1px solid var(--line);
  display: flex; flex-direction: column; padding: 14px 10px; gap: 4px; min-height: 0;
}
.brand { display: flex; align-items: center; gap: 8px; padding: 4px 8px 14px; font-weight: 650; letter-spacing: -.01em; }
.brand-mark {
  width: 24px; height: 24px; border-radius: 5px; background: var(--accent); color: var(--accent-ink);
  display: grid; place-items: center; font-size: 12px; font-weight: 700;
}
.side-label { font-size: 11px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 10px 8px 4px; }
.nav-item {
  display: flex; align-items: center; gap: 10px; padding: 7px 8px; border-radius: var(--r);
  color: var(--ink); text-decoration: none !important; border: 0; background: none; width: 100%; text-align: left; cursor: pointer;
}
.nav-item:hover { background: var(--surface-2); }
.nav-item.active { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.nav-short {
  min-width: 30px; height: 20px; padding: 0 5px; border-radius: 4px; font-size: 10.5px; font-weight: 700; letter-spacing: .03em;
  display: grid; place-items: center; background: var(--surface-2); color: var(--ink-2);
}
.nav-item.active .nav-short { background: var(--accent); color: var(--accent-ink); }
.nav-count { margin-left: auto; color: var(--ink-3); font-size: 12px; }
.side-foot { margin-top: auto; border-top: 1px solid var(--line); padding-top: 10px; display: flex; flex-direction: column; gap: 4px; }
.me { display: flex; align-items: center; gap: 8px; padding: 6px 8px; min-width: 0; }
.me span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.avatar { width: 24px; height: 24px; border-radius: 50%; background: var(--surface-2); flex: none; object-fit: cover; }

.main { min-width: 0; display: flex; flex-direction: column; min-height: 0; }
.topbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 16px 24px 0; background: var(--bg);
}
.topbar h1 { font-size: 19px; margin: 0; letter-spacing: -.015em; font-weight: 650; text-wrap: balance; }
.topbar .desc { color: var(--ink-3); font-size: 13px; flex-basis: 100%; margin-top: -8px; }
.spacer { flex: 1; }
.btn.menu-btn { display: none; }

.toolbar {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 12px 24px; border-bottom: 1px solid var(--line);
}
.tabs { display: flex; gap: 2px; flex-wrap: wrap; }
.tab {
  border: 0; background: none; padding: 6px 10px; border-radius: var(--r); cursor: pointer; color: var(--ink-2);
  display: inline-flex; gap: 6px; align-items: center;
}
.tab:hover { background: var(--surface-2); color: var(--ink); }
.tab.active { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: inset 0 0 0 1px var(--line); }
.tab .count { font-size: 11.5px; color: var(--ink-3); font-weight: 500; }
.search {
  margin-left: auto; width: 240px; max-width: 100%; padding: 6px 10px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface);
}

.btn {
  display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: var(--r);
  border: 1px solid var(--line); background: var(--surface); cursor: pointer; white-space: nowrap;
  color: var(--ink); text-decoration: none !important;
}
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.primary:hover { filter: brightness(1.07); }
.btn.danger { color: var(--c-red); }
.btn.danger.armed { background: var(--c-red); color: var(--surface); border-color: var(--c-red); }
.btn.ghost { border-color: transparent; background: none; }
.btn.small { padding: 3px 8px; font-size: 12.5px; }
.btn:disabled { opacity: .5; cursor: default; }

.content { flex: 1; min-height: 0; overflow: auto; padding: 16px 24px 40px; }

/* ---------- table ---------- */
.table-wrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table.grid { border-collapse: collapse; width: 100%; min-width: 640px; }
.grid th {
  text-align: left; font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3);
  padding: 9px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; cursor: pointer; user-select: none;
  position: sticky; top: 0; background: var(--surface);
}
.grid th:hover { color: var(--ink); }
.grid th .arrow { color: var(--accent); margin-left: 3px; }
.grid td .num { white-space: nowrap; }
.grid td { padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: middle; max-width: 320px; }
.grid tr:last-child td { border-bottom: 0; }
.grid tbody tr.row { cursor: pointer; }
.grid tbody tr.row:hover td { background: var(--surface-2); }
.grid tbody tr.row.open td { background: var(--accent-soft); }
.grid td.title { font-weight: 600; min-width: 180px; }
.grid td .sub { display: block; font-weight: 400; color: var(--ink-3); font-size: 12px; }
.grid td.clip { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.grid tr.group td {
  background: var(--surface-2); font-weight: 650; font-size: 12.5px; padding: 7px 12px; cursor: default;
}
.empty {
  padding: 48px 20px; text-align: center; color: var(--ink-2); display: flex; flex-direction: column; align-items: center; gap: 10px;
}
.empty strong { color: var(--ink); font-size: 15px; }

/* ---------- chips ---------- */
.chip {
  display: inline-flex; align-items: center; gap: 4px; padding: 1px 8px; border-radius: 999px;
  font-size: 12px; font-weight: 550; white-space: nowrap; background: var(--c-gray-bg); color: var(--c-gray);
}
.chip.red { background: var(--c-red-bg); color: var(--c-red); }
.chip.orange { background: var(--c-orange-bg); color: var(--c-orange); }
.chip.green { background: var(--c-green-bg); color: var(--c-green); }
.chip.blue { background: var(--c-blue-bg); color: var(--c-blue); }
.chip.purple { background: var(--c-purple-bg); color: var(--c-purple); }
.chips { display: inline-flex; gap: 4px; flex-wrap: wrap; }
.tag { font-size: 12px; padding: 1px 6px; border-radius: 4px; border: 1px solid var(--line); color: var(--ink-2); white-space: nowrap; }
.star { color: var(--c-orange); font-size: 15px; }
.overdue { color: var(--c-red); font-weight: 600; }
.soon { color: var(--c-orange); font-weight: 600; }
.rating { letter-spacing: 1px; color: var(--accent); }

/* ---------- kanban ---------- */
.board { display: flex; gap: 12px; align-items: flex-start; overflow-x: auto; padding-bottom: 12px; min-height: 100%; }
.col { flex: 0 0 272px; background: var(--surface-2); border-radius: 8px; padding: 8px; display: flex; flex-direction: column; gap: 8px; max-height: 100%; }
.col.drop { outline: 2px dashed var(--accent); outline-offset: -2px; }
.col-head { display: flex; align-items: center; gap: 6px; padding: 2px 4px; }
.col-head .n { color: var(--ink-3); font-size: 12px; margin-left: auto; }
.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 9px 10px;
  display: flex; flex-direction: column; gap: 6px; cursor: pointer;
}
.card:hover { border-color: var(--ink-3); }
.card.dragging { opacity: .4; }
.card .t { font-weight: 600; display: flex; gap: 6px; align-items: baseline; }
.card .meta { display: flex; flex-wrap: wrap; gap: 4px 8px; align-items: center; font-size: 12.5px; color: var(--ink-2); }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(10, 15, 12, .28); z-index: 20; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(640px, 100%); z-index: 21;
  background: var(--surface); box-shadow: var(--shadow); display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px);
}
.drawer-head { display: flex; align-items: flex-start; gap: 10px; padding: 16px 20px 12px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font-size: 18px; letter-spacing: -.01em; text-wrap: balance; }
.drawer-head .sub { color: var(--ink-3); font-size: 12.5px; margin-top: 2px; }
.drawer-body { flex: 1; overflow-y: auto; padding: 4px 20px 32px; }
.drawer-tabs { display: flex; gap: 2px; padding: 8px 20px 0; border-bottom: 1px solid var(--line); }
.drawer-tabs .tab { border-radius: var(--r) var(--r) 0 0; }
.drawer-tabs .tab.active { box-shadow: inset 0 -2px 0 var(--accent); background: none; }

.section-title { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin: 20px 0 6px; font-weight: 600; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 14px; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field.wide { grid-column: 1 / -1; }
.field label { font-size: 12px; color: var(--ink-2); }
.field label .req { color: var(--c-red); }
.input {
  width: 100%; padding: 6px 8px; border-radius: 5px; border: 1px solid var(--line); background: var(--surface);
  min-height: 32px;
}
.input:hover { border-color: var(--ink-3); }
textarea.input { resize: vertical; min-height: 80px; line-height: 1.45; }
.input.saved { border-color: var(--accent); transition: border-color .6s; }
.input.err { border-color: var(--c-red); }
.field .err-msg { color: var(--c-red); font-size: 12px; }
.checks { display: flex; flex-wrap: wrap; gap: 6px; }
.checks label {
  display: inline-flex; gap: 5px; align-items: center; font-size: 12.5px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 999px; padding: 2px 9px; cursor: pointer;
}
.checks input { margin: 0; }
.toggle { display: inline-flex; gap: 8px; align-items: center; min-height: 32px; cursor: pointer; }
.link-out { font-size: 12px; }

.note-form { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.note-form .row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.notes { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.note { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.note-head { display: flex; gap: 8px; align-items: center; font-size: 12.5px; color: var(--ink-3); flex-wrap: wrap; }
.note-head .who { color: var(--ink-2); font-weight: 600; }
.note-head .actions { margin-left: auto; display: flex; gap: 2px; }
.note-body { white-space: pre-wrap; margin-top: 6px; overflow-wrap: anywhere; }

.history { list-style: none; padding: 0; margin: 14px 0 0; display: flex; flex-direction: column; gap: 10px; }
.history li { font-size: 13px; border-left: 2px solid var(--line); padding-left: 10px; }
.history .when { color: var(--ink-3); font-size: 12px; }
.history .chg { color: var(--ink-2); overflow-wrap: anywhere; }
.drawer-foot { display: flex; gap: 8px; padding: 12px 20px; border-top: 1px solid var(--line); flex-wrap: wrap; padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px)); }

/* ---------- settings ---------- */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: 8px; padding: 18px 20px; max-width: 860px; margin-bottom: 16px; }
.panel h2 { font-size: 15px; margin: 0 0 4px; }
.panel p { color: var(--ink-2); margin: 0 0 12px; max-width: 68ch; }
.panel table { width: 100%; border-collapse: collapse; }
.panel td, .panel th { text-align: left; padding: 7px 8px; border-bottom: 1px solid var(--line); font-size: 13px; }
.panel th { color: var(--ink-3); font-weight: 600; font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; }
.secret {
  font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 8px 10px; border-radius: 5px;
  overflow-wrap: anywhere; display: block; margin: 8px 0; user-select: all;
}
pre.code { font-family: var(--mono); font-size: 12.5px; background: var(--surface-2); padding: 10px 12px; border-radius: 6px; overflow-x: auto; margin: 0; }

.toast {
  position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--bg); padding: 8px 14px; border-radius: 6px; font-size: 13px; box-shadow: var(--shadow);
}
.toast.error { background: var(--c-red); color: #fff; }

/* ---------- login ---------- */
.login { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.login-box { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 32px 28px; width: min(380px, 100%); display: flex; flex-direction: column; gap: 14px; }
.login-box h1 { margin: 0; font-size: 20px; letter-spacing: -.015em; }
.login-box p { margin: 0; color: var(--ink-2); }
.slack-btn { justify-content: center; padding: 10px 14px; font-weight: 600; }
.login-error { color: var(--c-red); font-size: 13px; }

/* ---------- small screens ---------- */
@media (max-width: 820px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .side { position: fixed; inset: 0 auto 0 0; width: 260px; z-index: 30; transform: translateX(-100%); transition: transform .18s; box-shadow: var(--shadow); padding-top: calc(14px + env(safe-area-inset-top, 0px)); }
  .side.open { transform: none; }
  .btn.menu-btn { display: inline-flex; }
  .topbar, .toolbar { padding-left: 16px; padding-right: 16px; }
  .content { padding: 12px 16px 32px; }
  .search { margin-left: 0; width: 100%; order: 5; }
  .fields { grid-template-columns: minmax(0, 1fr); }
  .drawer-head, .drawer-body, .drawer-foot { padding-left: 16px; padding-right: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}

/* ---------- list editor (contacts, team members) ---------- */
.list-edit { display: flex; flex-direction: column; gap: 6px; align-items: flex-start; }
.list-row { display: grid; grid-template-columns: repeat(var(--cols, 3), minmax(0, 1fr)) auto; gap: 6px; width: 100%; }
@media (max-width: 820px) { .list-row { grid-template-columns: repeat(2, minmax(0, 1fr)); padding-bottom: 8px; border-bottom: 1px solid var(--line); } }
.field .muted { font-size: 12px; }

/* ---------- conversation ---------- */
.thread { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.msg { border: 1px solid var(--line); border-radius: 6px; padding: 10px 12px; }
.msg.out { background: var(--accent-soft); border-color: transparent; }
.msg-subject { font-weight: 600; margin-top: 6px; }
.msg-to { font-size: 12px; overflow-wrap: anywhere; }
.msg-body { white-space: pre-wrap; margin-top: 6px; overflow-wrap: anywhere; font-size: 13.5px; }
.note-form .row .input { width: auto; flex: 1 1 160px; }

/* ---------- timeline ---------- */
.tl-summary { font-size: 12.5px; margin-top: 12px; }
.tl-day { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; margin-top: 8px; }
.msg.note-item { border-style: dashed; }
.files { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.file {
  display: inline-flex; align-items: center; gap: 8px; max-width: 100%; padding: 5px 9px; border-radius: 6px;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 12.5px; text-decoration: none !important;
}
.file:hover { border-color: var(--ink-3); }
.file-ext { font-size: 10px; font-weight: 700; letter-spacing: .03em; background: var(--surface-2); color: var(--ink-2); padding: 1px 5px; border-radius: 3px; }
.file-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

/* ---------- calendar ---------- */
.cal-nav { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; flex-wrap: wrap; }
.cal-range { margin-left: 8px; font-weight: 600; }
.cal-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 6px; }
.cal-dow { font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); font-weight: 600; padding: 0 4px; }
.cal-day { background: var(--surface); border: 1px solid var(--line); border-radius: 6px; min-height: 96px; padding: 6px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.cal-day.past { opacity: .6; }
.cal-day.today { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); }
.cal-date { font-size: 12px; color: var(--ink-2); font-weight: 600; }
.cal-event {
  display: flex; flex-direction: column; align-items: flex-start; gap: 1px; text-align: left; width: 100%; min-width: 0;
  border: 0; border-left: 3px solid var(--c-gray); background: var(--c-gray-bg); color: var(--ink); border-radius: 4px; padding: 4px 6px; cursor: pointer; font-size: 12.5px;
}
.cal-event:hover { filter: brightness(1.05); }
.cal-event.purple { border-left-color: var(--c-purple); background: var(--c-purple-bg); }
.cal-event.orange { border-left-color: var(--c-orange); background: var(--c-orange-bg); }
.cal-event.green { border-left-color: var(--c-green); background: var(--c-green-bg); }
.cal-event.blue { border-left-color: var(--c-blue); background: var(--c-blue-bg); }
.cal-event.red { border-left-color: var(--c-red); background: var(--c-red-bg); }
.cal-time { font-weight: 700; font-size: 12px; }
.cal-title { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.cal-meta { color: var(--ink-2); font-size: 11.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 100%; }
.cal-unscheduled { margin-top: 14px; }
.cal-chips { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 6px; }
@media (max-width: 820px) {
  .cal-grid { grid-template-columns: minmax(0, 1fr); }
  .cal-dow { display: none; }
  .cal-day { min-height: 0; }
}

/* ===== v2 layout: inbox list, record page, viewer ===== */
.topbar { padding-bottom: 4px; }
.topbar .search { margin-left: 0; width: 260px; }
.toolbar { padding-top: 8px; padding-bottom: 10px; }
.tab.alert .count { color: var(--c-red); font-weight: 700; }
.dot { display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--c-red); margin-right: 7px; vertical-align: 1px; }
.last-cell { max-width: 460px; }
.last { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.last-top { display: flex; gap: 8px; align-items: center; font-size: 12.5px; }
.last-who { font-weight: 600; }
.last-who.them { color: var(--ink); }
.last-text { color: var(--ink-2); font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 440px; }
.src { font-size: 10.5px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; padding: 1px 6px; border-radius: 3px; background: var(--c-gray-bg); color: var(--c-gray); white-space: nowrap; }
.src.email { background: var(--c-blue-bg); color: var(--c-blue); }
.src.wechat, .src.whatsapp { background: var(--c-green-bg); color: var(--c-green); }
.src.slack { background: var(--c-purple-bg); color: var(--c-purple); }
.src.note { background: var(--c-orange-bg); color: var(--c-orange); }

/* overflow menu */
.menu { position: relative; }
.menu > summary { list-style: none; }
.menu > summary::-webkit-details-marker { display: none; }
.menu-items {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 40; min-width: 200px; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px; box-shadow: var(--shadow); padding: 4px;
}
.menu-items > * { text-align: left; border: 0; background: none; padding: 7px 10px; border-radius: 4px; color: var(--ink); cursor: pointer; text-decoration: none !important; font-size: 13.5px; }
.menu-items > *:hover { background: var(--surface-2); }
.menu-items .danger { color: var(--c-red); }

/* record page */
.drawer.wide { width: min(1120px, 100%); }
.rec-title-wrap { min-width: 0; }
.rec-fields { display: flex; flex-wrap: wrap; gap: 10px 14px; padding: 10px 20px 12px; border-bottom: 1px solid var(--line); }
.mini { display: flex; flex-direction: column; gap: 3px; font-size: 11.5px; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; font-weight: 600; min-width: 140px; }
.mini .input { text-transform: none; letter-spacing: 0; font-weight: 400; font-size: 13.5px; color: var(--ink); min-height: 30px; padding: 4px 8px; }
.mini .toggle { text-transform: none; color: var(--ink); font-weight: 400; letter-spacing: 0; }
.rec-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 340px; }
.rec-main { overflow-y: auto; padding: 14px 20px 40px; min-width: 0; }
.rec-side { overflow-y: auto; border-left: 1px solid var(--line); padding: 6px 16px 40px; background: var(--bg); display: flex; flex-direction: column; }
.rec-side section { padding: 12px 0; border-bottom: 1px solid var(--line); display: flex; flex-direction: column; gap: 8px; }
.rec-side h3 { margin: 0; font-size: 11.5px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }
.rec-side .field label { font-size: 11.5px; }
.rec-side textarea.input { min-height: 64px; }
.fields.one { grid-template-columns: minmax(0, 1fr); }
.all-fields { padding: 12px 0; }
.all-fields summary { cursor: pointer; color: var(--ink-2); font-size: 13px; }
.people { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.person { display: flex; flex-direction: column; gap: 1px; width: 100%; padding: 6px 8px; border-radius: 5px; background: var(--surface); border: 1px solid var(--line); }
.person-top { display: flex; align-items: center; gap: 8px; }
.person-line { font-size: 12.5px; overflow-wrap: anywhere; }
.selectable { user-select: all; }
.cv-btn { margin-left: auto; border: 1px solid var(--accent); color: var(--accent); background: none; border-radius: 4px; font-size: 11px; font-weight: 700; padding: 1px 7px; cursor: pointer; }
.cv-btn:hover { background: var(--accent-soft); }
.people .list-row { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr) auto; }
.file-list { display: flex; flex-direction: column; gap: 4px; }
.file-row {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left; padding: 6px 8px; border-radius: 5px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-size: 12.5px; min-width: 0;
}
.file-row:hover { border-color: var(--accent); }
.file-row .file-name { flex: 1; }

/* viewer */
.preview { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; padding: 24px 16px; }
.preview .scrim { z-index: 0; }
.preview-box { position: relative; z-index: 1; width: min(1100px, 100%); height: min(92vh, 1400px); background: var(--surface); border-radius: 8px; box-shadow: var(--shadow); display: flex; flex-direction: column; overflow: hidden; }
.preview-box.narrow { width: min(640px, 100%); height: auto; max-height: 85vh; }
.preview-head { display: flex; align-items: center; gap: 8px; padding: 10px 14px; border-bottom: 1px solid var(--line); min-width: 0; }
.preview-head strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-frame { flex: 1; width: 100%; border: 0; background: #525659; }
.preview-img { flex: 1; min-height: 0; object-fit: contain; background: var(--surface-2); }
.preview-scroll { overflow-y: auto; padding: 0 16px 16px; }

/* timeline v2 */
.tl { display: flex; flex-direction: column; gap: 10px; }
.composer, .composer-chat { display: flex; flex-direction: column; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); }
.composer .row, .composer-chat .row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.composer textarea { min-height: 44px; border: 0; padding: 4px; }
.composer textarea:focus { outline: none; }
.composer:focus-within { border-color: var(--accent); }
.small-select { width: auto !important; flex: 0 0 auto !important; min-height: 28px; padding: 2px 6px; font-size: 12.5px; }
.tl-filters { display: flex; gap: 6px; flex-wrap: wrap; }
.pill { border: 1px solid var(--line); background: var(--surface); color: var(--ink-2); border-radius: 999px; padding: 3px 10px; font-size: 12.5px; cursor: pointer; display: inline-flex; gap: 6px; }
.pill .num { color: var(--ink-3); }
.pill.on { background: var(--ink); color: var(--bg); border-color: var(--ink); }
.pill.on .num { color: var(--bg); opacity: .7; }
.tl-list { display: flex; flex-direction: column; gap: 8px; }
.tl-item { border: 1px solid var(--line); border-radius: 8px; padding: 10px 12px; background: var(--surface); display: flex; flex-direction: column; gap: 6px; }
.tl-item.note { background: var(--c-orange-bg); border-color: transparent; }
.tl-item.mail.us { border-left: 3px solid var(--accent); }
.tl-head { display: flex; gap: 8px; align-items: center; font-size: 12.5px; flex-wrap: wrap; }
.tl-who { font-weight: 600; color: var(--ink); }
.mail-subject { font-weight: 600; }
.mail-body, .note-text { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 13.5px; }
.clamp { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.link-btn { align-self: flex-start; border: 0; background: none; color: var(--accent); padding: 0; cursor: pointer; font-size: 12.5px; }
.tl-files { display: flex; flex-direction: column; gap: 4px; max-width: 460px; }
.chat-lines { display: flex; flex-direction: column; gap: 4px; }
.line { display: grid; grid-template-columns: 84px minmax(0, 1fr) auto; gap: 8px; align-items: baseline; font-size: 13.5px; }
.line .tl-files { grid-column: 2 / -1; }
.line-who { font-weight: 600; color: var(--ink-2); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.line.us .line-who { color: var(--accent); }
.line-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.line-time { color: var(--ink-3); font-size: 11.5px; }

@media (max-width: 900px) {
  .rec-body { grid-template-columns: minmax(0, 1fr); overflow-y: auto; }
  .rec-main, .rec-side { overflow: visible; }
  .rec-side { border-left: 0; border-top: 1px solid var(--line); }
  .topbar .search { width: 100%; order: 5; }
  .line { grid-template-columns: 64px minmax(0, 1fr); }
  .line-time { display: none; }
}

.list-cell { max-width: 640px; }
.list-lines { display: flex; flex-direction: column; gap: 3px; }
.list-line { display: flex; flex-wrap: wrap; gap: 4px 6px; font-size: 13px; }
.list-line .sep { color: var(--ink-3); }
.toolbar-end { margin-left: auto; }
