:root {
  --bg: #f6f5f2;
  --surface: #ffffff;
  --surface-2: #faf9f7;
  --ink: #1b1d22;
  --ink-2: #555a66;
  --ink-3: #8a8f9b;
  --line: #e7e4de;
  --line-2: #efece7;
  --accent: #4f46e5;
  --accent-2: #0ea5a4;
  --accent-soft: #eceafd;
  --mark: #fff1a8;
  --mark-ink: #3b3000;
  --me: #4f46e5;
  --me-ink: #ffffff;
  --danger: #d14343;
  --flag: #e8a400;
  --shadow: 0 1px 2px rgba(20, 20, 30, .05), 0 6px 24px rgba(20, 20, 30, .06);
  --radius: 14px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light dark;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #121317;
    --surface: #1a1c21;
    --surface-2: #16181c;
    --ink: #eceef2;
    --ink-2: #a9aebb;
    --ink-3: #737987;
    --line: #2a2d34;
    --line-2: #23262c;
    --accent: #8b85ff;
    --accent-soft: #26244a;
    --mark: #5b4d00;
    --mark-ink: #fff3b0;
    --me: #5a52e8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
  }
}
:root[data-theme="dark"] {
    --bg: #121317;
    --surface: #1a1c21;
    --surface-2: #16181c;
    --ink: #eceef2;
    --ink-2: #a9aebb;
    --ink-3: #737987;
    --line: #2a2d34;
    --line-2: #23262c;
    --accent: #8b85ff;
    --accent-soft: #26244a;
    --mark: #5b4d00;
    --mark-ink: #fff3b0;
    --me: #5a52e8;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 8px 28px rgba(0, 0, 0, .25);
  }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--ink); font: 14px/1.45 var(--font); -webkit-font-smoothing: antialiased; }
button, input, select { font: inherit; color: inherit; }
kbd { font: 11px var(--mono); padding: 1px 5px; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 5px; background: var(--surface); color: var(--ink-2); }
svg { fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.app { display: grid; grid-template-rows: auto auto 1fr auto; height: 100vh; }

/* ---------- top bar ---------- */
.topbar { display: grid; grid-template-columns: 220px 1fr auto; align-items: center; gap: 18px; padding: 14px 20px 10px; }
.brand { display: flex; align-items: center; gap: 10px; font-size: 16px; letter-spacing: -.01em; }
.brand-mark { width: 28px; height: 28px; }
.brand-name b { font-weight: 650; }

.search { position: relative; display: flex; align-items: center; max-width: 760px; width: 100%; justify-self: center; }
.search input {
  width: 100%; height: 44px; padding: 0 84px 0 44px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--surface); box-shadow: var(--shadow); outline: none; font-size: 15px; transition: border-color .15s, box-shadow .15s;
}
.search input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 16%, transparent), var(--shadow); }
.search input::-webkit-search-cancel-button { display: none; }
.search-icon { position: absolute; left: 14px; width: 18px; height: 18px; color: var(--ink-3); pointer-events: none; }
.search-kbd { position: absolute; right: 48px; }
.search .icon-btn { position: absolute; right: 6px; }

.controls { display: flex; align-items: center; gap: 8px; }
.icon-btn { width: 34px; height: 34px; display: grid; place-items: center; border: 0; border-radius: 9px; background: transparent; color: var(--ink-2); cursor: pointer; font-weight: 600; }
.icon-btn:hover { background: var(--line-2); color: var(--ink); }
.icon-btn svg { width: 18px; height: 18px; }

.segmented { display: inline-flex; padding: 3px; background: var(--line-2); border-radius: 10px; }
.segmented button { border: 0; background: transparent; padding: 6px 12px; border-radius: 8px; color: var(--ink-2); cursor: pointer; font-size: 13px; }
.segmented button[aria-selected="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 3px rgba(0,0,0,.08); font-weight: 600; }
.select { height: 32px; border: 1px solid var(--line); border-radius: 9px; background: var(--surface); padding: 0 8px; font-size: 13px; }

/* ---------- chips ---------- */
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 20px 12px 258px; }
.chip { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--ink-2); cursor: pointer; font-size: 12.5px; }
.chip:hover { border-color: var(--ink-3); color: var(--ink); }
.chip[aria-pressed="true"] { background: var(--accent-soft); border-color: transparent; color: var(--accent); font-weight: 600; }
.chip svg { width: 14px; height: 14px; }

/* ---------- panes ---------- */
.panes { display: grid; grid-template-columns: 238px minmax(340px, 440px) 1fr; min-height: 0; gap: 0; padding: 0 12px 0 0; }

.rail { overflow: auto; padding: 4px 10px 20px 14px; }
.rail-item { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); cursor: pointer; text-align: left; font-size: 13px; }
.rail-item:hover { background: var(--line-2); color: var(--ink); }
.rail-item[aria-current="true"] { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); font-weight: 600; }
.rail-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item .n { font-size: 11.5px; color: var(--ink-3); font-variant-numeric: tabular-nums; }
.rail-item .n.unread { color: var(--accent); font-weight: 700; }
.rail-item svg { width: 15px; height: 15px; flex: none; }
.rail-group { margin: 16px 0 4px; padding: 0 10px; font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.rail-item.sub { padding-left: 26px; }

.results { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--line); border-right: 0; border-radius: var(--radius) 0 0 var(--radius); overflow: hidden; }
.results-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px 10px; border-bottom: 1px solid var(--line-2); font-size: 12.5px; color: var(--ink-3); }
.query-errors { color: var(--danger); }
.list { list-style: none; margin: 0; padding: 0; overflow: auto; flex: 1; outline: none; }
.item { position: relative; display: grid; grid-template-columns: 34px 1fr; gap: 10px; padding: 12px 16px 12px 14px; border-bottom: 1px solid var(--line-2); cursor: pointer; }
.item:hover { background: var(--surface-2); }
.item[aria-selected="true"] { background: var(--accent-soft); }
.item[aria-selected="true"]::before { content: ""; position: absolute; left: 0; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); }
.item.unread .who, .item.unread .subj { font-weight: 700; color: var(--ink); }
.item.unread .avatar::after { content: ""; position: absolute; right: -2px; top: -2px; width: 9px; height: 9px; border-radius: 50%; background: var(--accent); border: 2px solid var(--surface); }
.item-main { min-width: 0; }
.row1 { display: flex; align-items: baseline; gap: 8px; }
.who { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink-2); font-size: 13px; }
.when { font-size: 11.5px; color: var(--ink-3); white-space: nowrap; font-variant-numeric: tabular-nums; }
.subj { margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--ink); font-size: 13.5px; }
.snip { margin-top: 2px; color: var(--ink-3); font-size: 12.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 6px; }
.pill { display: inline-flex; align-items: center; gap: 4px; height: 20px; padding: 0 7px; border-radius: 6px; background: var(--line-2); color: var(--ink-2); font-size: 11px; }
.pill svg { width: 12px; height: 12px; }
.pill.count { background: var(--accent-soft); color: var(--accent); font-weight: 700; }
.pill.flag { color: var(--flag); background: color-mix(in srgb, var(--flag) 14%, transparent); }
mark { background: var(--mark); color: var(--mark-ink); border-radius: 3px; padding: 0 1px; }

.avatar { position: relative; width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; color: #fff; font-size: 12.5px; font-weight: 700; letter-spacing: .02em; flex: none; }
.avatar.stack { border-radius: 11px; }

.empty { padding: 48px 28px; text-align: center; color: var(--ink-3); }
.empty b { display: block; color: var(--ink); margin-bottom: 6px; font-size: 15px; }
.more { display: block; width: calc(100% - 32px); margin: 12px 16px 18px; padding: 9px; border: 1px dashed var(--line); border-radius: 10px; background: transparent; color: var(--ink-2); cursor: pointer; }

/* ---------- reader ---------- */
.reader { min-height: 0; overflow: auto; background: var(--surface-2); border: 1px solid var(--line); border-radius: 0 var(--radius) var(--radius) 0; }
.reader-empty { height: 100%; display: grid; place-content: center; justify-items: center; gap: 14px; color: var(--ink-3); text-align: center; padding: 40px; }
.reader-empty-mark { width: 56px; height: 56px; opacity: .9; }
.shortcuts { display: flex; flex-wrap: wrap; gap: 14px; justify-content: center; font-size: 12px; }
.reader-body { padding: 26px 34px 60px; max-width: 920px; margin: 0 auto; }
.conv-head { display: flex; align-items: flex-start; gap: 16px; margin-bottom: 22px; }
.conv-head h1 { flex: 1; margin: 0; font-size: 22px; line-height: 1.25; letter-spacing: -.015em; font-weight: 650; }
.conv-sub { margin-top: 6px; color: var(--ink-3); font-size: 12.5px; }
.toggle { display: inline-flex; align-items: center; gap: 8px; white-space: nowrap; font-size: 12.5px; color: var(--ink-2); cursor: pointer; user-select: none; }
.toggle input { appearance: none; width: 32px; height: 18px; border-radius: 999px; background: var(--line); position: relative; cursor: pointer; transition: background .15s; margin: 0; }
.toggle input::after { content: ""; position: absolute; left: 2px; top: 2px; width: 14px; height: 14px; border-radius: 50%; background: #fff; transition: transform .15s; box-shadow: 0 1px 2px rgba(0,0,0,.2); }
.toggle input:checked { background: var(--accent); }
.toggle input:checked::after { transform: translateX(14px); }

.timeline { display: flex; flex-direction: column; gap: 14px; }
.msg { display: grid; grid-template-columns: 34px minmax(0, 1fr); gap: 12px; align-items: start; }
.msg.mine { grid-template-columns: minmax(0, 1fr) 34px; }
.msg.mine .avatar { order: 2; }
.bubble { background: var(--surface); border: 1px solid var(--line); border-radius: 4px 16px 16px 16px; padding: 12px 16px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.03); min-width: 0; }
.msg.mine .bubble { border-radius: 16px 4px 16px 16px; background: color-mix(in srgb, var(--me) 7%, var(--surface)); border-color: color-mix(in srgb, var(--me) 22%, var(--line)); }
.msg.focus .bubble { box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 45%, transparent); }
.bubble-head { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.bubble-head .name { font-weight: 650; }
.bubble-head .addr { color: var(--ink-3); font-size: 12px; }
.bubble-head .time { margin-left: auto; color: var(--ink-3); font-size: 12px; }
.bubble-to { color: var(--ink-3); font-size: 12px; margin-top: 1px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bubble-text { margin-top: 10px; white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.55; }
.bubble-text a { color: var(--accent); }
.msg.collapsed .bubble { cursor: pointer; }
.msg.collapsed .bubble-text { display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden; color: var(--ink-3); margin-top: 4px; white-space: normal; }
.msg.collapsed .bubble-to, .msg.collapsed .bubble-actions, .msg.collapsed .quoted-toggle, .msg.collapsed .attachments { display: none; }
.quoted-toggle { margin-top: 8px; border: 0; background: var(--line-2); color: var(--ink-2); border-radius: 6px; padding: 1px 8px; cursor: pointer; font-size: 12px; letter-spacing: .1em; }
.quoted { margin-top: 8px; padding-left: 12px; border-left: 3px solid var(--line); color: var(--ink-3); white-space: pre-wrap; font-size: 13px; overflow-wrap: anywhere; }
.attachments { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.attachments .pill { height: 26px; padding: 0 10px; background: var(--surface-2); border: 1px solid var(--line); }
.bubble-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 12px; padding-top: 10px; border-top: 1px solid var(--line-2); }
.act { display: inline-flex; align-items: center; gap: 6px; height: 28px; padding: 0 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 12.5px; }
.act:hover { background: var(--line-2); color: var(--ink); }
.act svg { width: 15px; height: 15px; }
.act.on { color: var(--flag); }
.gap-note { text-align: center; color: var(--ink-3); font-size: 12px; }
.gap-note button { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 4px 12px; color: var(--ink-2); cursor: pointer; font-size: 12px; }

/* ---------- status ---------- */
.status { display: flex; align-items: center; gap: 10px; height: 34px; padding: 0 20px; color: var(--ink-3); font-size: 12px; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-2); }
.status-dot.busy { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.status-dot.err { background: var(--danger); }
@keyframes pulse { 50% { opacity: .35; } }
.progress { width: 180px; height: 4px; background: var(--line); border-radius: 999px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width .3s; }

/* ---------- dialogs ---------- */
.dlg { border: 1px solid var(--line); border-radius: 16px; padding: 22px 24px; background: var(--surface); color: var(--ink); box-shadow: 0 20px 60px rgba(0,0,0,.25); max-width: 640px; width: calc(100% - 40px); }
.dlg::backdrop { background: rgba(15, 15, 25, .35); backdrop-filter: blur(2px); }
.dlg h2 { margin: 0 0 14px; font-size: 17px; }
.help-table { width: 100%; border-collapse: collapse; margin-bottom: 16px; font-size: 13px; }
.help-table td { padding: 7px 8px; border-bottom: 1px solid var(--line-2); vertical-align: top; }
.help-table td:first-child { white-space: nowrap; }
.help-table code { font-family: var(--mono); font-size: 12px; background: var(--line-2); padding: 2px 6px; border-radius: 5px; cursor: pointer; }
.btn { height: 34px; padding: 0 16px; border: 0; border-radius: 9px; background: var(--accent); color: #fff; cursor: pointer; font-weight: 600; }
.btn.ghost { background: transparent; color: var(--danger); border: 1px solid var(--line); }
.dlg-actions { display: flex; justify-content: space-between; align-items: center; margin-top: 18px; }
.switch { display: flex; align-items: center; gap: 10px; padding: 8px 0; cursor: pointer; }
.switch input { width: 16px; height: 16px; accent-color: var(--accent); }
.row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 0; }
.hint { margin: -4px 0 6px 26px; color: var(--ink-3); font-size: 12px; }

@media (max-width: 1180px) and (min-width: 761px) {
  .panes { grid-template-columns: 200px minmax(280px, 360px) 1fr; }
  .topbar { grid-template-columns: 186px 1fr auto; }
  .chips { padding-left: 220px; }
  .sort-hide, #sort { display: none; }
}


/* ================= standalone app additions ================= */
.mobile-only { display: none; }
.link-btn { border: 0; background: none; color: var(--accent); cursor: pointer; font-size: 12.5px; padding: 0 4px; }
.icon-btn.danger:hover { color: var(--danger); }

/* auth */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 24px;
  background: radial-gradient(1200px 600px at 10% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
              radial-gradient(900px 500px at 110% 110%, color-mix(in srgb, var(--accent-2) 14%, transparent), transparent 60%), var(--bg); }
.auth-card { width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 34px 32px 26px; box-shadow: 0 20px 60px rgba(20,20,40,.08); }
.auth-logo { width: 46px; height: 46px; }
.auth-card h1 { margin: 14px 0 6px; font-size: 26px; font-weight: 500; letter-spacing: -.02em; }
.auth-card h1 b { font-weight: 700; }
.auth-tag { margin: 0 0 22px; color: var(--ink-2); }
.auth-switch { margin: 18px 0 0; text-align: center; color: var(--ink-3); font-size: 13px; }
.auth-switch a { color: var(--accent); font-weight: 600; text-decoration: none; }
.field { display: flex; flex-direction: column; gap: 5px; margin-bottom: 12px; font-size: 12.5px; color: var(--ink-2); font-weight: 500; }
.field input, .field select { height: 40px; border: 1px solid var(--line); border-radius: 10px; padding: 0 12px; background: var(--surface); font-size: 14px; outline: none; color: var(--ink); }
.field input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 15%, transparent); }
.form-error { min-height: 18px; margin: 4px 0 10px; color: var(--danger); font-size: 13px; }
.btn.wide { width: 100%; height: 42px; font-size: 15px; }
.btn:disabled { opacity: .6; cursor: progress; }
.btn.ghost-plain { background: transparent; color: var(--ink-2); border: 1px solid var(--line); }
.note { margin: -4px 0 12px; padding: 9px 12px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); font-size: 12.5px; }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
details { margin: 4px 0 8px; }
details summary { cursor: pointer; color: var(--ink-2); font-size: 13px; margin-bottom: 10px; }
.server-grid { display: grid; grid-template-columns: 1fr 80px auto; gap: 0 10px; align-items: center; }
.switch.small { padding: 10px 0 0; font-size: 12.5px; }
.dlg h3 { margin: 18px 0 8px; font-size: 12px; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); }

/* rail compose */
.compose-btn { display: flex; align-items: center; gap: 10px; width: 100%; height: 46px; margin: 0 0 14px; padding: 0 18px; border: 0; border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 60%, var(--accent-2))); color: #fff; font-weight: 650; font-size: 14px; cursor: pointer;
  box-shadow: 0 6px 18px color-mix(in srgb, var(--accent) 30%, transparent); }
.compose-btn svg { width: 18px; height: 18px; }
.compose-btn:hover { filter: brightness(1.05); }
.rail-item.add { color: var(--accent); margin-top: 10px; }
.acc-dot { width: 7px; height: 7px; border-radius: 50%; display: inline-block; margin-left: 6px; vertical-align: middle; background: var(--accent-2); }
.acc-dot.syncing { background: var(--accent); animation: pulse 1.2s infinite; }
.acc-dot.error { background: var(--danger); }
.onboard { margin: 40px auto; max-width: 420px; text-align: center; padding: 0 24px; }
.onboard img { width: 60px; }
.onboard h2 { margin: 14px 0 6px; font-size: 20px; }
.onboard p { color: var(--ink-3); margin: 0 0 18px; }

/* reader extras */
.view-switch { display: inline-flex; gap: 2px; padding: 2px; background: var(--line-2); border-radius: 8px; margin-left: auto; }
.view-switch button { border: 0; background: transparent; border-radius: 6px; padding: 2px 9px; font-size: 11.5px; color: var(--ink-2); cursor: pointer; }
.view-switch button[aria-pressed="true"] { background: var(--surface); color: var(--ink); box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.html-frame { width: 100%; border: 0; margin-top: 10px; background: #fff; border-radius: 10px; min-height: 120px; }
.img-note { display: flex; align-items: center; gap: 8px; margin-top: 10px; font-size: 12px; color: var(--ink-3); }
a.pill { text-decoration: none; cursor: pointer; }
a.pill:hover { border-color: var(--accent); color: var(--accent); }
.conv-actions { display: flex; gap: 4px; margin-bottom: 14px; flex-wrap: wrap; }
.back-btn { display: none; }

/* composer */
.composer { position: fixed; right: 24px; bottom: 0; width: min(620px, calc(100vw - 48px)); height: min(620px, calc(100vh - 80px)); display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-bottom: 0; border-radius: 16px 16px 0 0; box-shadow: 0 -10px 50px rgba(20,20,40,.18); z-index: 50; }
.composer-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 10px 10px 18px; border-bottom: 1px solid var(--line-2); font-weight: 650; }
.composer-fields { padding: 0 18px; }
.cf { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid var(--line-2); min-height: 40px; font-size: 13px; color: var(--ink-3); }
.cf span { width: 54px; flex: none; }
.cf input, .cf select { flex: 1; border: 0; outline: none; background: transparent; height: 38px; font-size: 14px; color: var(--ink); min-width: 0; }
.composer-body { flex: 1; border: 0; outline: none; resize: none; padding: 14px 18px; font: 14px/1.6 var(--font); background: transparent; color: var(--ink); }
.composer-atts { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 18px; }
.composer-atts .pill button { border: 0; background: none; cursor: pointer; color: var(--ink-3); padding: 0 0 0 4px; }
.composer-foot { display: flex; align-items: center; gap: 8px; padding: 10px 14px 14px 18px; }
.composer-foot .hint { flex: 1; margin: 0; }
.composer-foot .btn { padding: 0 22px; }

/* toast */
.toast { position: fixed; left: 50%; bottom: 46px; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; padding: 11px 16px; border-radius: 12px;
  background: #1b1d22; color: #fff; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 60; font-size: 13.5px; }
.toast .link-btn { color: #a5a0ff; font-weight: 700; font-size: 13.5px; }

.account-list { display: flex; flex-direction: column; gap: 8px; }
.account-card { display: grid; grid-template-columns: 1fr auto; gap: 8px 12px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; }
.account-card b { font-weight: 650; }
.account-card .sub { color: var(--ink-3); font-size: 12px; }
.account-card textarea { grid-column: 1 / -1; min-height: 56px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: 13px var(--font); background: var(--surface-2); color: var(--ink); resize: vertical; }

/* ================= mobile ================= */
@media (max-width: 760px) {
  .mobile-only { display: grid; }
  .topbar { grid-template-columns: auto 1fr; gap: 10px; padding: 10px 12px 8px; }
  .controls { grid-column: 1 / -1; justify-content: space-between; }
  .brand-name { display: none; }
  .search input { height: 40px; padding-right: 44px; }
  .search-kbd { display: none; }
  .chips { padding: 0 12px 8px; flex-wrap: nowrap; overflow-x: auto; }
  .chip { flex: none; }
  .panes { grid-template-columns: 1fr; padding: 0; }
  .rail { display: block; position: fixed; inset: 0 25% 0 0; z-index: 40; background: var(--bg); padding-top: 16px; transform: translateX(-105%); transition: transform .2s; box-shadow: 10px 0 40px rgba(0,0,0,.2); }
  body.rail-open .rail { transform: none; }
  .results { border-radius: 0; border-left: 0; }
  .reader { position: fixed; inset: 0; z-index: 30; border-radius: 0; transform: translateX(105%); transition: transform .2s; }
  body.reading .reader { transform: none; }
  .reader-body { padding: 14px 14px 80px; }
  .back-btn { display: inline-flex; }
  .conv-actions { position: sticky; top: 0; z-index: 2; margin: -14px -14px 12px; padding: 10px 10px 8px; background: color-mix(in srgb, var(--surface-2) 92%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line-2); }
  .conv-head { flex-direction: column; gap: 8px; }
  .conv-head h1 { font-size: 19px; }
  .msg, .msg.mine { grid-template-columns: minmax(0, 1fr); }
  .msg .avatar { display: none; }
  .composer { inset: 0; width: auto; height: auto; border-radius: 0; }
  .status { display: none; }
  .two { grid-template-columns: 1fr; }
  .compose-fab { display: grid; }
}
.compose-fab { display: none; position: fixed; right: 18px; bottom: 22px; width: 56px; height: 56px; border-radius: 18px; border: 0; place-items: center; z-index: 20;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; box-shadow: 0 10px 24px color-mix(in srgb, var(--accent) 40%, transparent); }
.compose-fab svg { width: 22px; height: 22px; }

.oauth-buttons { display: flex; flex-direction: column; gap: 8px; margin: 14px 0 6px; }
.oauth-btn { display: flex; align-items: center; justify-content: center; gap: 10px; height: 42px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-weight: 600; text-decoration: none; }
.oauth-btn:hover { border-color: var(--ink-3); }
.oauth-btn svg { width: 18px; height: 18px; stroke: none; }
.divider { display: flex; align-items: center; gap: 10px; color: var(--ink-3); font-size: 12px; margin: 10px 0 14px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.plan-card { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 16px; border-radius: 12px;
  background: linear-gradient(135deg, var(--accent-soft), color-mix(in srgb, var(--accent-2) 12%, var(--surface))); }
.plan-card b { font-size: 15px; }
.plan-card .sub { color: var(--ink-2); font-size: 12.5px; margin-top: 2px; }
.plan-actions { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

/* ---------- phase 3 ---------- */
.dlg.wide { max-width: 760px; }
.dlg-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
.dlg-head h2 { margin: 0; }
.dlg h4 { margin: 14px 0 6px; font-size: 13px; }
.btn.small { height: 30px; padding: 0 12px; font-size: 12.5px; display: inline-flex; align-items: center; text-decoration: none; }
.editor-bar { display: flex; flex-wrap: wrap; gap: 2px; padding: 6px 14px 0; }
.editor-bar button { min-width: 30px; height: 28px; border: 0; border-radius: 7px; background: transparent; color: var(--ink-2); cursor: pointer; font-size: 13px; }
.editor-bar button:hover { background: var(--line-2); color: var(--ink); }
.editor-bar .sep { width: 1px; background: var(--line); margin: 5px 4px; }
.composer-body { overflow: auto; }
.composer-body:empty::before { content: attr(data-placeholder); color: var(--ink-3); }
.composer-body blockquote, .bubble-text blockquote { margin: 6px 0; padding-left: 12px; border-left: 3px solid var(--line); color: var(--ink-2); }
.composer-body .k-sig { color: var(--ink-2); }
.composer-body .k-quote-head { color: var(--ink-3); font-size: 13px; }
.send-group { display: inline-flex; }
.send-group .btn:first-child { border-radius: 9px 0 0 9px; }
.send-group .caret { border-radius: 0 9px 9px 0; padding: 0 10px; border-left: 1px solid rgba(255,255,255,.25); }
.menu { position: fixed; z-index: 80; min-width: 240px; padding: 6px; background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: 0 16px 40px rgba(0,0,0,.18); }
.menu > button { display: flex; justify-content: space-between; gap: 16px; width: 100%; padding: 9px 10px; border: 0; border-radius: 8px; background: transparent; color: var(--ink); cursor: pointer; text-align: left; font-size: 13px; }
.menu > button:hover { background: var(--line-2); }
.menu small { color: var(--ink-3); }
.menu-custom { display: grid; grid-template-columns: 1fr auto; gap: 6px; padding: 8px 10px; border-top: 1px solid var(--line-2); margin-top: 4px; font-size: 12.5px; color: var(--ink-2); }
.menu-custom span { grid-column: 1 / -1; }
.menu-custom input { height: 30px; border: 1px solid var(--line); border-radius: 7px; padding: 0 6px; background: var(--surface); color: var(--ink); }
.search .save-search { right: 40px; color: var(--ink-3); font-size: 16px; }
.search .save-search:not([hidden]) ~ .search-kbd { right: 80px; }
.rail-sep { height: 1px; background: var(--line); margin: 10px 10px; }
.rail-item .x { opacity: 0; border: 0; background: none; color: var(--ink-3); cursor: pointer; }
.rail-item:hover .x { opacity: 1; }
.tool-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tool { display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); cursor: pointer; text-align: left; color: var(--ink); }
.tool:hover { border-color: var(--accent); }
.tool span { color: var(--ink-3); font-size: 12px; }
.import-hint { width: 100%; margin: 4px 0 8px; padding: 10px 12px; border: 1px dashed var(--line); border-radius: 10px; background: transparent; color: var(--accent); cursor: pointer; font-size: 13px; text-align: left; }
.imp-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 12px 0; }
.imp-card { display: flex; flex-direction: column; gap: 4px; align-items: flex-start; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink); cursor: pointer; text-align: left; min-height: 96px; }
.imp-card:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.imp-card span { color: var(--ink-3); font-size: 12px; }
.imp-card.auto { width: 100%; min-height: 0; flex-direction: row; align-items: center; gap: 10px; background: var(--accent-soft); border-color: transparent; }
.imp-card.auto svg { width: 20px; height: 20px; color: var(--accent); }
.imp-archive { display: inline-flex; align-items: center; gap: 6px; }
.imp-archive svg { width: 15px; height: 15px; }
.imp-help { padding-left: 20px; color: var(--ink-2); line-height: 1.7; }
.imp-help code { display: inline-block; max-width: 100%; overflow-wrap: anywhere; font: 12px var(--mono); background: var(--line-2); padding: 3px 7px; border-radius: 6px; cursor: copy; }
.dropzone { display: flex; align-items: center; justify-content: center; gap: 10px; min-height: 90px; margin: 10px 0; border: 2px dashed var(--line); border-radius: 14px; color: var(--ink-2); cursor: pointer; text-align: center; padding: 10px; }
.dropzone:hover { border-color: var(--accent); color: var(--accent); }
.dropzone input { display: none; }
.dropzone svg { width: 20px; height: 20px; }
.imp-acc { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 6px; }
.imp-acc.done { opacity: .6; }
.imp-acc-main { display: flex; align-items: center; gap: 10px; min-width: 0; }
.imp-acc-main span, .imp-row span { display: flex; flex-direction: column; min-width: 0; }
.imp-acc small, .imp-row small, .rule small, .ab-row small { color: var(--ink-3); font-size: 12px; overflow: hidden; text-overflow: ellipsis; }
.imp-acc input[type=password] { width: 200px; height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--surface); color: var(--ink); }
.imp-row { display: flex; align-items: flex-start; gap: 10px; padding: 7px 4px; }
.imp-warn { margin-top: 10px; color: var(--ink-2); font-size: 12.5px; }
.imp-wait { display: flex; align-items: center; gap: 12px; padding: 30px 0; color: var(--ink-2); }
.spin { width: 20px; height: 20px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.imp-res { padding: 6px 0; }
.imp-res.ok { color: #138a5b; } .imp-res.ko { color: var(--danger); }
.rule-list { display: flex; flex-direction: column; gap: 6px; margin: 10px 0; max-height: 60vh; overflow: auto; }
.rule { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.rule-main { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: pointer; }
.rule-rows { display: flex; flex-direction: column; gap: 6px; }
.rule-row { display: grid; grid-template-columns: 150px 170px 1fr 30px; gap: 6px; align-items: center; }
.rule-row:has(> select:first-child + input) { grid-template-columns: 170px 1fr 30px; }
.rule-row input, .ab-search, .ab-edit input, .rule-edit .field input { height: 34px; border: 1px solid var(--line); border-radius: 8px; padding: 0 10px; background: var(--surface); color: var(--ink); min-width: 0; }
.ab-bar { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 10px; }
.ab-search { flex: 1; min-width: 180px; }
.ab-list { max-height: 60vh; overflow: auto; }
.ab-row { display: flex; align-items: center; gap: 10px; padding: 8px 6px; border-bottom: 1px solid var(--line-2); }
.ab-row > svg { width: 18px; height: 18px; color: var(--ink-3); }
.ab-main { flex: 1; min-width: 0; display: flex; flex-direction: column; cursor: pointer; }
@media (max-width: 760px) { .imp-grid, .tool-grid { grid-template-columns: 1fr; } .rule-row { grid-template-columns: 1fr 1fr; } .imp-acc { flex-direction: column; align-items: stretch; } .imp-acc input[type=password] { width: 100%; } }

/* ---------- phase 4 ---------- */
.tpl-btn { margin-left: auto; font-weight: 600; color: var(--accent) !important; }
.followup { height: 30px; font-size: 12px; max-width: 170px; }
.label-pill { color: #fff !important; font-weight: 600; }
.label-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; margin: 0 3px; }
.menu label { display: flex; align-items: center; gap: 8px; padding: 7px 10px; border-radius: 8px; cursor: pointer; font-size: 13px; }
.menu label:hover { background: var(--line-2); }
.menu .menu-sep { height: 1px; background: var(--line-2); margin: 4px 0; }
.invite { margin-top: 12px; border: 1px solid var(--line); border-radius: 14px; overflow: hidden; background: var(--surface); }
.invite-top { display: flex; gap: 14px; padding: 14px 16px; align-items: center; }
.invite-date { flex: none; width: 58px; text-align: center; border-radius: 12px; overflow: hidden; border: 1px solid var(--line); }
.invite-date .m { background: var(--danger); color: #fff; font-size: 11px; font-weight: 700; text-transform: uppercase; padding: 2px 0; }
.invite-date .d { font-size: 22px; font-weight: 700; padding: 4px 0; }
.invite-info b { display: block; font-size: 15px; }
.invite-info span { color: var(--ink-2); font-size: 12.5px; display: block; }
.invite-actions { display: flex; gap: 6px; padding: 10px 16px; border-top: 1px solid var(--line-2); background: var(--surface-2); flex-wrap: wrap; align-items: center; }
.invite-actions .done { color: #138a5b; font-weight: 600; font-size: 13px; }
.sig-editor { grid-column: 1 / -1; min-height: 64px; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font-size: 13px; background: var(--surface-2); outline: none; }
.sig-editor img { max-height: 80px; }
.sig-bar { grid-column: 1 / -1; display: flex; gap: 2px; }
.sig-bar button { border: 0; background: transparent; border-radius: 6px; padding: 2px 8px; cursor: pointer; color: var(--ink-2); }
.sig-bar button:hover { background: var(--line-2); }
.tpl-edit .composer-body { min-height: 160px; border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; }
.offline-bar { position: fixed; top: 0; left: 50%; transform: translateX(-50%); z-index: 90; background: #1b1d22; color: #fff; font-size: 12.5px; padding: 6px 14px; border-radius: 0 0 10px 10px; }
.color-row { display: flex; gap: 6px; }
.color-row button { width: 22px; height: 22px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.color-row button[aria-pressed="true"] { border-color: var(--ink); }

/* ---------- v0.5: theme override, personalisation ---------- */
:root[data-theme="light"] { color-scheme: light; }
:root[data-theme="dark"] { color-scheme: dark; }
body.compact .item { padding-top: 7px; padding-bottom: 7px; }
body.compact .item .snippet { display: none; }
body.compact .rail-item { padding-top: 4px; padding-bottom: 4px; }
@media (min-width: 900px) {
  body.pane-bottom .panes { grid-template-columns: 238px 1fr; grid-template-rows: minmax(200px, 42%) 1fr; }
  body.pane-bottom .rail { grid-row: 1 / span 2; }
  body.pane-bottom .reader { border-radius: 0 0 var(--radius) var(--radius); border-top: 0; }
}
.color-row { display: flex; gap: 6px; }
.color-row button { width: 24px; height: 24px; border-radius: 50%; border: 2px solid transparent; cursor: pointer; }
.color-row button[aria-pressed="true"] { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface) inset; }
/* notes */
.note-box { margin: 0 0 16px; padding: 10px 12px; border-radius: 12px; background: #fff8d6; border: 1px solid #f1e1a0; color: #3b3000; }
.note-head { display: flex; align-items: center; gap: 6px; font-size: 12px; margin-bottom: 4px; }
.note-head svg { width: 14px; height: 14px; }
.note-state { margin-left: auto; opacity: .7; }
.note-area { width: 100%; border: 0; background: transparent; resize: vertical; outline: none; font: inherit; color: inherit; min-height: 44px; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) .note-box { background: #3a3315; border-color: #5b4d00; color: #fff3b0; } }
:root[data-theme="dark"] .note-box { background: #3a3315; border-color: #5b4d00; color: #fff3b0; }
.item .note-mark { color: var(--flag); }
/* security / integrations */
.sec-block { padding: 10px 0 14px; border-bottom: 1px solid var(--line-2); }
.sec-block h3 { margin: 4px 0 8px; }
.sec-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.sec-row input { flex: 1; min-width: 140px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.tfa-setup { display: flex; gap: 16px; align-items: center; margin: 8px 0; }
.tfa-setup img { border-radius: 10px; background: #fff; padding: 6px; }
code.copy { display: inline-block; user-select: all; padding: 4px 8px; border-radius: 8px; background: var(--line-2); font: 12.5px var(--mono); word-break: break-all; }
code.copy.big { display: block; margin: 6px 0; padding: 10px; }
pre.recovery { font: 13px var(--mono); background: var(--line-2); padding: 10px; border-radius: 10px; columns: 2; }
.ok-line { color: #16a34a; font-weight: 600; margin: 4px 0; }
.ev { font-size: 12px; color: var(--ink-2); padding: 3px 0; }
.ev.ko { color: var(--danger); }
.danger-text { color: var(--danger); cursor: pointer; margin-top: 8px; }
.auth-legal { margin-top: 18px; font-size: 12px; color: var(--ink-3); text-align: center; }
.auth-legal a { color: inherit; }
.legal { max-width: 760px; margin: 0 auto; padding: 40px 24px 80px; line-height: 1.6; }
.legal h1 { font-size: 26px; } .legal h2 { font-size: 18px; margin-top: 28px; }
.legal table { border-collapse: collapse; width: 100%; font-size: 13px; } .legal td, .legal th { border: 1px solid var(--line); padding: 6px 8px; text-align: left; vertical-align: top; }
@media print { .rail, .results, .topbar, .chips, .conv-actions, .bubble-actions, .compose-fab, .note-box { display: none !important; } .panes { display: block; } .reader { position: static; border: 0; overflow: visible; } }
.sec-row .switch { flex: none; margin: 0; }
.dlg .sec-block .hint, .dlg > .hint { margin-left: 0; }

/* ---------- v0.6: work views ---------- */
.rail-sep { height: 1px; background: var(--line); margin: 8px 10px; }
.rail-item.due .n { color: var(--danger); font-weight: 700; }
.work { min-height: 0; overflow: auto; background: var(--surface); border: 1px solid var(--line); border-right: 0; border-radius: var(--radius) 0 0 var(--radius); padding: 0 0 40px; }
body.work-mode .results { display: none; }
body.work-mode.work-wide .panes { grid-template-columns: 238px 1fr; }
body.work-mode.work-wide .work { border-right: 1px solid var(--line); border-radius: var(--radius); }
body.work-mode.work-wide .reader { position: fixed; top: 70px; right: 12px; bottom: 30px; width: min(760px, 62vw); z-index: 25; box-shadow: 0 20px 60px rgba(0,0,0,.25); border-radius: var(--radius); transform: translateX(110%); transition: transform .2s; }
body.work-mode.work-wide.reading-over .reader { transform: none; }
body.work-mode.work-wide .reader .back-btn { display: inline-flex; }
.work-head { position: sticky; top: 0; z-index: 2; display: flex; align-items: center; gap: 12px; padding: 14px 18px 10px; background: var(--surface); border-bottom: 1px solid var(--line-2); }
.work-head h2 { margin: 0; font-size: 18px; flex: 1; }
.work-actions { display: flex; align-items: center; gap: 8px; }
.w-loading { padding: 30px; color: var(--ink-3); }
.w-hello { margin: 14px 18px 4px; color: var(--ink-2); }
.w-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; margin: 12px 18px; }
.w-tile { padding: 12px 14px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface-2); display: grid; gap: 2px; }
.w-tile b { font-size: 22px; font-variant-numeric: tabular-nums; }
.w-tile span { font-size: 12px; color: var(--ink-3); }
.w-tile.warn b { color: var(--accent); } .w-tile.bad b { color: var(--danger); }
.w-sec { margin: 10px 0 0; }
.w-sec h3, .w-card h3, .person h3 { display: flex; align-items: center; gap: 8px; margin: 14px 18px 6px; font-size: 12px; letter-spacing: .05em; text-transform: uppercase; color: var(--ink-3); }
.w-n { font-size: 11px; padding: 1px 7px; border-radius: 99px; background: var(--line-2); color: var(--ink-2); font-weight: 600; text-transform: none; letter-spacing: 0; }
.w-row { display: flex; align-items: center; gap: 12px; width: 100%; padding: 10px 18px; border: 0; border-bottom: 1px solid var(--line-2); background: transparent; text-align: left; cursor: pointer; color: inherit; }
.w-row:hover { background: var(--surface-2); }
.w-row.unread b { color: var(--ink); } .w-row.unread .w-sub { font-weight: 600; }
.w-main { flex: 1; min-width: 0; display: grid; gap: 2px; }
.w-line { display: flex; gap: 8px; align-items: baseline; } .w-line b { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-sub { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-snip { color: var(--ink-3); font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-age { color: var(--ink-3); font-size: 12px; white-space: nowrap; }
.w-meta { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; justify-content: flex-end; }
.w-chip { font-size: 11.5px; padding: 2px 8px; border-radius: 99px; background: var(--line-2); color: var(--ink-2); white-space: nowrap; }
.w-chip.due.today { background: #fff1d6; color: #8a5a00; } .w-chip.due.late { background: #fde2e2; color: var(--danger); font-weight: 600; }
.w-chip.st-todo { background: var(--accent-soft); color: var(--accent); } .w-chip.st-waiting_us { background: #fff1d6; color: #8a5a00; }
.w-chip.st-waiting_them { background: #e3f4f4; color: #0b7f7e; } .w-chip.st-done { background: #e5f6ea; color: #16803c; }
:root[data-theme="dark"] .w-chip.due.today, :root[data-theme="dark"] .w-chip.st-waiting_us { background: #3a2f12; color: #ffd27a; }
:root[data-theme="dark"] .w-chip.due.late { background: #3d1a1a; color: #ff8a8a; }
:root[data-theme="dark"] .w-chip.st-waiting_them { background: #123433; color: #6fe0dd; } :root[data-theme="dark"] .w-chip.st-done { background: #13311d; color: #7be39b; }
.w-btn { font-size: 12px; padding: 4px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--ink-2); cursor: pointer; text-decoration: none; white-space: nowrap; }
.w-btn:hover { border-color: var(--accent); color: var(--accent); } .w-btn.on { background: #e5f6ea; color: #16803c; border-color: transparent; }
.w-empty { color: var(--ink-3); margin: 6px 18px; font-size: 13px; } .w-empty.big { margin: 40px 18px; text-align: center; font-size: 14px; }
.w-foot { color: var(--ink-3); font-size: 12px; margin: 18px; }
.w-bar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; padding: 12px 18px 4px; }
.w-search { flex: 1; min-width: 180px; padding: 7px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.seg { display: inline-flex; gap: 2px; padding: 2px; border-radius: 10px; background: var(--line-2); }
.seg.wrap { flex-wrap: wrap; }
.seg button { border: 0; background: transparent; padding: 5px 10px; border-radius: 8px; font-size: 12.5px; cursor: pointer; color: var(--ink-2); display: inline-flex; gap: 4px; align-items: center; }
.seg button[aria-pressed="true"] { background: var(--surface); color: var(--ink); font-weight: 600; box-shadow: var(--shadow); }
.seg.small button { padding: 4px 9px; font-size: 12px; }
.seg button.st-todo[aria-pressed="true"] { color: var(--accent); } .seg button.st-waiting_us[aria-pressed="true"] { color: #b07400; }
.seg button.st-waiting_them[aria-pressed="true"] { color: #0b7f7e; } .seg button.st-done[aria-pressed="true"] { color: #16803c; }
/* kanban */
.kb { display: grid; grid-template-columns: repeat(4, minmax(220px, 1fr)); gap: 12px; padding: 14px 18px; align-items: start; }
.kb-col { background: var(--surface-2); border: 1px solid var(--line-2); border-radius: 12px; padding: 8px; min-height: 200px; display: grid; gap: 8px; align-content: start; }
.kb-col.over { border-color: var(--accent); background: var(--accent-soft); }
.kb-head { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px 4px; }
.kb-card { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 10px 11px; cursor: grab; display: grid; gap: 4px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.kb-card:hover { border-color: var(--accent); } .kb-card.late { border-left: 3px solid var(--danger); }
.kb-card b { font-size: 13px; line-height: 1.3; }
.kb-snip { font-size: 12px; color: var(--ink-3); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.kb-foot { display: flex; gap: 6px; align-items: center; margin-top: 2px; }
.kb-who .avatar { width: 22px; height: 22px; font-size: 9px; }
/* documents */
.w-table { width: calc(100% - 36px); margin: 10px 18px; border-collapse: collapse; font-size: 13px; }
.w-table th { text-align: left; font-size: 11.5px; color: var(--ink-3); font-weight: 600; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.w-table td { padding: 8px; border-bottom: 1px solid var(--line-2); vertical-align: middle; }
.w-table tbody tr { cursor: pointer; } .w-table tbody tr:hover { background: var(--surface-2); }
.w-table tr.paid td { opacity: .6; } .w-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; } .w-table .bad { color: var(--danger); font-weight: 700; }
.w-acts { display: flex; gap: 6px; justify-content: flex-end; }
.doc-ic { display: inline-block; font-size: 10.5px; font-weight: 700; padding: 1px 6px; border-radius: 5px; background: var(--line-2); color: var(--ink-2); text-transform: uppercase; letter-spacing: .03em; }
.doc-invoice { background: #fde8d7; color: #9a4a00; } .doc-quote { background: var(--accent-soft); color: var(--accent); } .doc-contract { background: #efe3fb; color: #6b2bb5; }
.doc-order { background: #e3f4f4; color: #0b7f7e; } .doc-ddt { background: #e6eefc; color: #2457b5; } .doc-receipt { background: #e5f6ea; color: #16803c; }
/* insights */
.w-card { margin: 12px 18px; padding: 4px 4px 12px; border: 1px solid var(--line); border-radius: 12px; }
.w-card .w-row { padding: 8px 14px; }
.w-2col { display: grid; grid-template-columns: 1fr 1fr; }
.bars { display: flex; align-items: flex-end; gap: 2px; height: 140px; padding: 6px 14px 0; }
.bar-day { flex: 1; display: flex; align-items: flex-end; gap: 1px; height: 100%; }
.bar-day i { flex: 1; border-radius: 3px 3px 0 0; min-height: 1px; }
.b-in { background: var(--accent); } .b-out { background: var(--accent-2); }
.legend { margin-left: auto; display: inline-flex; gap: 6px; align-items: center; text-transform: none; letter-spacing: 0; font-weight: 400; }
.legend i { width: 10px; height: 10px; border-radius: 3px; display: inline-block; }
.heat { display: grid; grid-template-columns: 34px repeat(24, 1fr); gap: 2px; padding: 8px 14px; font-size: 10px; color: var(--ink-3); }
.heat .hc { aspect-ratio: 1; border-radius: 3px; background: var(--accent); }
.heat .hd { text-transform: capitalize; }
/* person card */
.person-head { display: flex; gap: 14px; align-items: center; margin-bottom: 6px; }
.person-head .avatar { width: 52px; height: 52px; font-size: 18px; }
.person-head > div:nth-child(2) { flex: 1; display: grid; gap: 2px; }
.person-acts { display: flex; gap: 6px; }
.person .w-tiles, .person h3, .person .w-row { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
.person-files { display: flex; flex-wrap: wrap; gap: 6px; }
.bubble-head .name.link { cursor: pointer; } .bubble-head .name.link:hover { text-decoration: underline; }
/* reader work bar */
.case-bar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: -4px 0 14px; }
.case-field { display: inline-flex; align-items: center; gap: 4px; color: var(--ink-3); }
.case-field svg { width: 15px; height: 15px; }
.case-due { padding: 3px 6px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); font-size: 12.5px; }
.case-due.late { border-color: var(--danger); color: var(--danger); }
.select.small { padding: 3px 26px 3px 8px; font-size: 12.5px; }
.ai-btn { color: var(--accent); font-weight: 600; }
.presence { margin: 0 0 12px; padding: 8px 12px; border-radius: 10px; background: #fff1d6; color: #8a5a00; font-size: 13px; font-weight: 600; }
.ai-box { margin: 0 0 16px; padding: 12px 14px; border-radius: 12px; border: 1px solid var(--accent-soft); background: linear-gradient(180deg, var(--accent-soft), transparent); display: grid; gap: 8px; }
.ai-head { display: flex; align-items: center; } .ai-head b { flex: 1; color: var(--accent); }
.ai-sum { white-space: pre-line; line-height: 1.55; }
.ai-acts { display: grid; gap: 6px; } .ai-acts small { color: var(--ink-3); text-transform: uppercase; font-size: 11px; letter-spacing: .05em; }
.ai-act { display: flex; gap: 8px; align-items: center; } .ai-act span:first-child { flex: 1; }
.comments { margin-top: 22px; padding: 12px; border-radius: 12px; background: var(--surface); border: 1px dashed var(--line); display: grid; gap: 8px; }
.c-head { display: flex; align-items: center; gap: 6px; } .c-head svg { width: 15px; height: 15px; } .c-head small { color: var(--ink-3); }
.comment { font-size: 13px; padding: 6px 10px; border-radius: 10px; background: #fff8d6; color: #3b3000; justify-self: start; max-width: 90%; }
.comment.mine { justify-self: end; background: var(--accent-soft); color: var(--ink); }
.comment small { opacity: .6; }
.c-input { display: flex; gap: 8px; } .c-input textarea { flex: 1; resize: none; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface-2); font: inherit; }
.pec-tag { margin-top: 8px; font-size: 12px; padding: 4px 9px; border-radius: 8px; background: var(--line-2); color: var(--ink-2); justify-self: start; display: inline-flex; flex-wrap: wrap; gap: 2px; align-items: center; }
.pec-tag.pec-delivered { background: #e5f6ea; color: #16803c; } .pec-tag.pec-failed { background: #fde2e2; color: var(--danger); font-weight: 600; } .pec-tag.pec-accepted, .pec-tag.pec-partial { background: #fff1d6; color: #8a5a00; }
.pec-st { width: 34px; flex: none; text-align: center; font-weight: 700; font-size: 12px; padding: 4px 0; border-radius: 8px; background: var(--line-2); }
.pec-st.pec-delivered { background: #e5f6ea; color: #16803c; } .pec-st.pec-failed { background: #fde2e2; color: var(--danger); } .pec-st.pec-accepted, .pec-st.pec-partial { background: #fff1d6; color: #8a5a00; }
@media (max-width: 900px) {
  body.work-mode .work { position: fixed; inset: 56px 0 0 0; z-index: 20; border-radius: 0; border: 0; }
  body.work-mode.work-wide .reader { top: 0; right: 0; bottom: 0; width: 100%; border-radius: 0; }
  body.work-mode .reader { z-index: 30; }
  .kb { grid-template-columns: repeat(4, 80vw); overflow-x: auto; }
  .w-2col { grid-template-columns: 1fr; }
  .w-table { font-size: 12px; } .w-table th:nth-child(3), .w-table td:nth-child(3), .w-table th:nth-child(4), .w-table td:nth-child(4) { display: none; }
}
.w-meta.left { justify-content: flex-start; margin-top: 4px; }
.person-head .link-btn { justify-self: start; padding: 0; }
/* Klaro Mail Local: single user on this PC — no sign-out, plans or teams */
body.local-edition #logoutBtn, body.local-edition #planBox, body.local-edition #openTeamBtn, body.local-edition #openSecBtn { display: none !important; }
/* download page */
.dl { max-width: 1000px; margin: 0 auto; padding: 48px 20px 60px; text-align: center; }
.dl h1 { font-size: 32px; margin: 10px 0 4px; }
.dl-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 14px; margin: 30px 0; text-align: left; }
.dl-card { border: 1px solid var(--line); border-radius: 16px; padding: 18px; background: var(--surface); display: grid; gap: 8px; align-content: start; }
.dl-card.mine { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.dl-card h2 { margin: 0; font-size: 18px; } .dl-card p { margin: 0 0 6px; color: var(--ink-3); font-size: 13px; }
.dl-local { border: 1px dashed var(--line); border-radius: 16px; padding: 18px; color: var(--ink-2); }
.dl .btn.disabled { opacity: .5; pointer-events: none; }

/* ================= v0.7: Outlook-style shell ================= */
.panes { grid-template-areas: "app rail ribbon ribbon" "app rail list reader"; grid-template-columns: 64px 236px minmax(340px, 440px) 1fr; grid-template-rows: auto 1fr; padding: 0 12px 0 0; }
.appbar { grid-area: app; } .rail { grid-area: rail; } .ribbon { grid-area: ribbon; } .results { grid-area: list; } .reader { grid-area: reader; } .work { grid-area: work; }
body.work-mode .panes { grid-template-areas: "app work reader" "app work reader"; grid-template-columns: 64px minmax(380px, 560px) 1fr; }
body.work-mode .rail, body.work-mode .ribbon { display: none; }
body.work-mode.work-wide .panes { grid-template-areas: "app work" "app work"; grid-template-columns: 64px 1fr; }
body.work-mode .work { border-radius: var(--radius) 0 0 var(--radius); border-right: 0; }
body.work-mode.work-wide .work { border-radius: var(--radius); border-right: 1px solid var(--line); }
@media (min-width: 900px) {
  body.pane-bottom .panes { grid-template-areas: "app rail ribbon" "app rail list" "app rail reader"; grid-template-columns: 64px 236px 1fr; grid-template-rows: auto minmax(200px, 40%) 1fr; }
  body.pane-bottom .rail { grid-row: auto; }
}
@media (max-width: 1180px) and (min-width: 761px) {
  .panes { grid-template-columns: 58px 196px minmax(280px, 360px) 1fr; }
  .rb > span { display: none; } .rb.big > span { display: block; }
}
/* app bar */
.appbar { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 4px 0 14px; min-height: 0; overflow: auto; }
.ab-btn { position: relative; width: 56px; border: 0; background: none; border-radius: 12px; padding: 7px 0 5px; display: grid; justify-items: center; gap: 3px; color: var(--ink-3); cursor: pointer; font-size: 10.5px; }
.ab-btn svg { width: 21px; height: 21px; }
.ab-btn:hover { background: var(--line-2); color: var(--ink); }
.ab-btn[aria-current="true"] { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.ab-btn[aria-current="true"]::before { content: ""; position: absolute; left: -4px; top: 10px; bottom: 10px; width: 3px; border-radius: 3px; background: var(--accent); }
.ab-badge { position: absolute; top: 3px; right: 6px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: var(--accent); color: #fff; font-size: 9.5px; line-height: 16px; }
.ab-badge.alert { background: var(--danger); }
.ab-sep { width: 28px; height: 1px; background: var(--line); margin: 6px 0; }
.ab-fill { flex: 1; }
/* ribbon */
.ribbon { display: flex; align-items: stretch; gap: 0; padding: 6px 8px; margin-bottom: 8px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; scrollbar-width: thin; }
.rb-group { display: grid; grid-template-rows: 1fr auto; padding: 0 8px; border-right: 1px solid var(--line-2); flex: none; }
.rb-group:last-child { border-right: 0; }
.rb-group > small { text-align: center; font-size: 10.5px; color: var(--ink-3); padding-top: 2px; }
.rb-row { display: flex; gap: 2px; align-items: stretch; }
.rb-col { display: grid; gap: 1px; align-content: center; }
.rb { display: flex; align-items: center; gap: 6px; border: 0; background: none; border-radius: 7px; padding: 4px 8px; font-size: 12.5px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.rb svg { width: 16px; height: 16px; flex: none; }
.rb:hover:not(:disabled) { background: var(--line-2); color: var(--ink); }
.rb:disabled { opacity: .38; cursor: default; }
.rb.big { flex-direction: column; justify-content: center; gap: 3px; padding: 6px 10px; min-width: 64px; }
.rb.big svg { width: 24px; height: 24px; }
.rb.primary { color: var(--accent); font-weight: 600; }
.rb.primary:hover { background: var(--accent-soft); color: var(--accent); }
/* rail: favorites + account tree */
.acc-head { display: flex; align-items: center; gap: 2px; margin-top: 12px; }
.acc-toggle { width: 20px; border: 0; background: none; color: var(--ink-3); cursor: pointer; font-size: 11px; padding: 4px 0; }
.acc-name { flex: 1; min-width: 0; display: flex; align-items: center; gap: 6px; border: 0; background: none; padding: 5px 6px; border-radius: 8px; cursor: pointer; font-weight: 700; font-size: 12.5px; color: var(--ink); text-align: left; }
.acc-name .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.acc-name:hover, .acc-name[aria-current="true"] { background: var(--line-2); }
.acc-more { border: 0; background: none; color: var(--ink-3); cursor: pointer; border-radius: 6px; padding: 2px 6px; opacity: 0; }
.acc-head:hover .acc-more { opacity: 1; }
.acc-shared { color: var(--accent); font-size: 11px; }
.rail-item.sub { padding-left: 26px; }
/* list: richer rows, hover quick actions */
.item { position: relative; }
.item.flagged { box-shadow: inset 3px 0 0 var(--flag, #f59e0b); }
.item .quick { position: absolute; right: 10px; top: 8px; display: none; gap: 2px; background: var(--surface); border: 1px solid var(--line); border-radius: 9px; padding: 2px; box-shadow: var(--shadow); z-index: 2; }
.item:hover .quick { display: flex; }
.item .quick button { border: 0; background: none; padding: 4px 5px; border-radius: 6px; color: var(--ink-3); cursor: pointer; display: grid; }
.item .quick button:hover { background: var(--line-2); color: var(--ink); }
.item .quick button.on { color: #f59e0b; }
.item .quick svg { width: 15px; height: 15px; }
.item:hover .when { visibility: hidden; }
.pill.w-chip { font-size: 10.5px; }
/* calendar */
.cal { padding: 10px 16px 20px; }
.work-actions-inner { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cal-month { display: grid; grid-template-columns: repeat(7, 1fr); grid-template-rows: auto repeat(6, minmax(96px, 1fr)); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cal-dow { min-height: 0; padding: 6px 8px; font-size: 11.5px; color: var(--ink-3); text-transform: capitalize; background: var(--surface-2); border-bottom: 1px solid var(--line); }
.cal-month > .cal-dow { grid-row: 1; height: auto; }
.cal-day { border-right: 1px solid var(--line-2); border-bottom: 1px solid var(--line-2); padding: 4px; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.cal-day:nth-child(7n) { border-right: 0; }
.cal-day.out { background: var(--surface-2); } .cal-day.out .cal-num { color: var(--ink-3); }
.cal-num { align-self: flex-end; border: 0; background: none; font-size: 12px; font-weight: 600; width: 24px; height: 24px; border-radius: 50%; cursor: pointer; color: var(--ink-2); }
.cal-day.today .cal-num { background: var(--accent); color: #fff; }
.cal-ev { display: block; width: 100%; text-align: left; border: 0; border-left: 3px solid var(--c); background: color-mix(in srgb, var(--c) 14%, transparent); color: var(--ink); border-radius: 5px; padding: 2px 6px; font-size: 11.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; cursor: pointer; }
.cal-ev:hover { background: color-mix(in srgb, var(--c) 24%, transparent); }
.cal-ev.tentative, .cal-ev.k-invite { border-left-style: dashed; }
.cal-ev b { font-weight: 600; }
.cal-more { border: 0; background: none; color: var(--ink-3); font-size: 11px; text-align: left; cursor: pointer; }
.cal-week { display: grid; grid-template-columns: 52px repeat(var(--n), 1fr); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
.cw-corner { border-bottom: 1px solid var(--line); background: var(--surface-2); }
.cw-head { padding: 6px; font-size: 12px; font-weight: 600; text-transform: capitalize; border-bottom: 1px solid var(--line); border-left: 1px solid var(--line-2); background: var(--surface-2); display: grid; gap: 3px; }
.cw-head.today { color: var(--accent); }
.cw-hours { grid-column: 1; font-size: 10.5px; color: var(--ink-3); text-align: right; padding-right: 6px; }
.cw-hours > div { border-top: 1px solid transparent; transform: translateY(-6px); }
.cw-col { position: relative; border-left: 1px solid var(--line-2); background: repeating-linear-gradient(to bottom, transparent 0, transparent 43px, var(--line-2) 43px, var(--line-2) 44px); }
.cal-ev.abs { position: absolute; left: 3px; right: 3px; white-space: normal; overflow: hidden; }
.cw-now { position: absolute; left: 0; right: 0; height: 2px; background: var(--danger); }
.cal-legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 10px; font-size: 12px; color: var(--ink-3); }
.cal-legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
/* contacts */
.ct { display: grid; grid-template-columns: minmax(260px, 340px) 1fr; min-height: calc(100% - 60px); }
.ct-list { border-right: 1px solid var(--line-2); padding: 10px 0; overflow: auto; max-height: calc(100vh - 210px); }
.ct-list .w-search { margin: 0 12px 8px; width: calc(100% - 24px); }
.ct-letter { position: sticky; top: 0; padding: 4px 16px; font-size: 11px; font-weight: 700; color: var(--accent); background: var(--surface); }
.ct-row { display: flex; gap: 10px; align-items: center; width: 100%; padding: 8px 16px; border: 0; background: none; text-align: left; cursor: pointer; color: inherit; }
.ct-row:hover { background: var(--surface-2); } .ct-row.on { background: var(--accent-soft); }
.ct-detail { padding: 18px 24px; overflow: auto; max-height: calc(100vh - 200px); }
.ct-detail .w-tiles, .ct-detail h3, .ct-detail .w-row { margin-left: 0; margin-right: 0; padding-left: 0; padding-right: 0; }
@media (max-width: 760px) {
  .panes { grid-template-areas: "list"; grid-template-columns: 1fr; grid-template-rows: 1fr; padding: 0 0 60px; }
  body.work-mode .panes, body.work-mode.work-wide .panes { grid-template-areas: "list"; grid-template-columns: 1fr; }
  .ribbon { display: none; }
  .appbar { position: fixed; left: 0; right: 0; bottom: 0; z-index: 35; flex-direction: row; justify-content: space-around; padding: 4px 4px calc(4px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); overflow-x: auto; }
  .appbar .ab-sep, .appbar .ab-fill { display: none; }
  .ab-btn { width: auto; min-width: 54px; padding: 5px 6px; }
  .ab-btn[aria-current="true"]::before { display: none; }
  body.work-mode .work { bottom: 60px; }
  .ct { grid-template-columns: 1fr; } .ct-detail { display: none; }
  .cal-month { grid-template-rows: auto repeat(6, minmax(64px, 1fr)); } .cal-ev { font-size: 10px; }
}

body.work-mode .chips { visibility: hidden; height: 0; min-height: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; }
.rb-group { padding: 0 6px; }
.rb { padding: 3px 6px; font-size: 12px; }
.rb.big { min-width: 56px; padding: 5px 8px; }
.ab-btn > span { max-width: 58px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
