/* ========================================================================
   偉騰客服諮詢系統 — 設計系統
   調性：公司共用的「紙色＋墨色」token（paper #F7F3E8 / ink #12110E），本系統以「赤銅」為主色、
   訊息式版面（左側導覽欄＋對話時間線＋底部輸入列），手機優先；與報價系統（深青綠側欄）、
   專案追蹤（頂部導覽、墨色主按鈕）明確區隔。
   ======================================================================== */
:root {
  --font: -apple-system, BlinkMacSystemFont, 'PingFang TC', 'Noto Sans TC', 'Microsoft JhengHei', 'Segoe UI', system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, 'JetBrains Mono', Consolas, monospace;

  --paper: #f7f3e8; --paper-raised: #fcfaf3; --paper-recessed: #efe9d9;
  --ink: #12110e; --ink-2: #54514a; --ink-3: #716c5e; --ink-4: #9a9384;
  --copper: #8e5a31; --copper-deep: #6f4423; --copper-soft: #f4e7d8; --copper-tint: rgba(142, 90, 49, 0.14);
  --teal: #157070; --teal-soft: #dcf0ee;
  --lime: #4f9a12; --lime-soft: #e9f6d6;

  --bg: var(--paper);
  --surface: var(--paper-raised);
  --surface-2: #f3eee1;
  --surface-3: #ebe4d2;
  --input-bg: #ffffff;
  --border: #e5dfd0;
  --border-2: #d2cab7;
  --text: var(--ink);
  --text-2: var(--ink-2);
  --text-3: #857f71;

  --primary: var(--copper);
  --primary-hover: var(--copper-deep);
  --on-primary: #fff;
  --primary-soft: var(--copper-soft);
  --ring: rgba(142, 90, 49, 0.35);
  --link: var(--teal);

  --red: #9c3e3e; --red-soft: #f6e2df;
  --orange: #b9641e; --orange-soft: #f8e7d6;
  --amber: #a27710; --amber-soft: #f6ecd1;
  --green: #3f8f2e; --green-soft: #e6f3d8;
  --blue: #3a5f9e; --blue-soft: #e2e9f4;
  --purple: #7a4f9e; --purple-soft: #eee6f3;
  --gray: #716c5e; --gray-soft: #ece7db;

  --bubble-them: #ffffff;
  --bubble-us: #ead9c6;

  --radius-sm: 8px; --radius: 12px; --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(18, 17, 14, 0.06);
  --shadow: 0 8px 24px -16px rgba(18, 17, 14, 0.45);
  --shadow-lg: 0 24px 60px -28px rgba(18, 17, 14, 0.55);
  --rail-w: 76px; --tabbar-h: 60px; --topbar-h: 56px;
  color-scheme: light;
}
[data-theme='dark'] {
  --bg: #13120f; --surface: #1c1a16; --surface-2: #23211b; --surface-3: #2c2922;
  --input-bg: #17150f; --border: #33302a; --border-2: #4a453b;
  --text: #f1ecdf; --text-2: #bcb5a5; --text-3: #867f70;
  --primary: #d4a06e; --primary-hover: #e4b482; --on-primary: #1a140d; --primary-soft: rgba(212, 160, 110, 0.16); --ring: rgba(212, 160, 110, 0.4);
  --copper-soft: rgba(212, 160, 110, 0.14); --copper-tint: rgba(212, 160, 110, 0.18);
  --teal: #7fdad9; --teal-soft: #173634; --lime: #b4ec6a; --lime-soft: #26331a; --link: #7fdad9;
  --red: #e08a82; --red-soft: #3a2422; --orange: #e9a068; --orange-soft: #3a2a1a; --amber: #e0b85a; --amber-soft: #383018;
  --green: #8fd36a; --green-soft: #22331a; --blue: #93b0e2; --blue-soft: #1f2a3c; --purple: #bda2e4; --purple-soft: #2d243c; --gray: #a39d8d; --gray-soft: #2a2822;
  --bubble-them: #23211b; --bubble-us: #3a2c1f;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4); --shadow: 0 10px 30px -18px rgba(0, 0, 0, 0.7); --shadow-lg: 0 30px 70px -30px rgba(0, 0, 0, 0.9);
  color-scheme: dark;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; height: 100%; }
body { margin: 0; min-height: 100%; font-family: var(--font); font-size: 15px; line-height: 1.55; color: var(--text); background: var(--bg); -webkit-font-smoothing: antialiased; }
a { color: var(--link); text-decoration: none; } a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0; font-weight: 700; letter-spacing: -0.01em; line-height: 1.3; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 15px; } h4 { font-size: 14px; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
ul, ol { margin: 0; padding: 0; list-style: none; }
hr { border: 0; border-top: 1px solid var(--border); margin: 14px 0; }
code, .mono { font-family: var(--mono); font-size: 12.5px; }
.muted { color: var(--text-2); } .faint { color: var(--text-3); }
.small { font-size: 12.5px; } .xs { font-size: 11.5px; } .bold { font-weight: 600; }
.nowrap { white-space: nowrap; } .right { text-align: right; } .center { text-align: center; }
.row { display: flex; align-items: center; gap: 8px; } .row.wrap { flex-wrap: wrap; } .grow { flex: 1 1 auto; min-width: 0; }
.col { display: flex; flex-direction: column; gap: 8px; }
.gap-s { gap: 4px; } .gap-l { gap: 16px; }
.mt { margin-top: 12px; } .mt-l { margin-top: 20px; } .mb { margin-bottom: 12px; }
.hidden { display: none !important; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.clamp2 { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.pre { white-space: pre-wrap; word-break: break-word; }
.icon { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; flex: 0 0 auto; vertical-align: -3px; }
.icon.sm { width: 15px; height: 15px; } .icon.lg { width: 22px; height: 22px; }
:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }
::selection { background: var(--copper-tint); }

/* ---------- shell ---------- */
#app { min-height: 100vh; min-height: 100dvh; }
.shell { display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr); min-height: 100dvh; }
.rail { position: sticky; top: 0; height: 100dvh; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; align-items: center; padding: 14px 0 12px; gap: 6px; }
.rail .brand { width: 44px; height: 44px; margin-bottom: 10px; display: grid; place-items: center; }
.rail .brand img, .rail .brand svg { width: 40px; height: 40px; }
.rail a.nav { width: 60px; height: 56px; border-radius: var(--radius); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; color: var(--text-2); font-size: 11px; font-weight: 500; text-decoration: none; position: relative; }
.rail a.nav .icon { width: 21px; height: 21px; }
.rail a.nav:hover { background: var(--surface-2); color: var(--text); }
.rail a.nav.active { background: var(--primary-soft); color: var(--primary); }
.rail .spacer { flex: 1; }
.rail .badge-dot { position: absolute; top: 8px; right: 12px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
.main { min-width: 0; display: flex; flex-direction: column; }
.topbar { position: sticky; top: 0; z-index: 20; height: var(--topbar-h); background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: saturate(1.4) blur(10px); -webkit-backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--border); display: flex; align-items: center; gap: 10px; padding: 0 16px; }
.topbar h1 { font-size: 17px; font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .back { width: 36px; height: 36px; margin-left: -8px; }
.topbar .sub { font-size: 12px; color: var(--text-3); font-weight: 400; margin-left: 6px; }
.page { padding: 18px 16px 110px; max-width: 1180px; width: 100%; margin: 0 auto; }
.page.narrow { max-width: 820px; }
.page.wide { max-width: 1400px; }
.tabbar { display: none; }
@media (max-width: 899px) {
  .shell { grid-template-columns: 1fr; }
  .rail { display: none; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding-bottom: env(safe-area-inset-bottom); background: color-mix(in srgb, var(--surface) 92%, transparent); backdrop-filter: saturate(1.4) blur(12px); -webkit-backdrop-filter: saturate(1.4) blur(12px); border-top: 1px solid var(--border); z-index: 30; }
  .tabbar a { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--text-3); font-size: 10.5px; text-decoration: none; position: relative; }
  .tabbar a .icon { width: 22px; height: 22px; }
  .tabbar a.active { color: var(--primary); }
  .tabbar .badge-dot { position: absolute; top: 6px; right: calc(50% - 20px); min-width: 15px; height: 15px; padding: 0 4px; border-radius: 8px; background: var(--red); color: #fff; font-size: 10px; font-weight: 700; display: grid; place-items: center; }
  .page { padding: 14px 14px 120px; }
}

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 38px; padding: 0 14px; border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--surface); color: var(--text); font-weight: 600; font-size: 14px; white-space: nowrap; transition: background .15s, border-color .15s, transform .05s; text-decoration: none; }
.btn:hover { background: var(--surface-2); text-decoration: none; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn.primary { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }
.btn.primary:hover { background: var(--primary-hover); border-color: var(--primary-hover); }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: var(--surface-2); }
.btn.soft { background: var(--primary-soft); border-color: transparent; color: var(--primary); }
.btn.danger { color: var(--red); border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.btn.danger:hover { background: var(--red-soft); }
.btn.sm { height: 31px; padding: 0 10px; font-size: 13px; }
.btn.xs { height: 26px; padding: 0 8px; font-size: 12px; border-radius: 6px; }
.btn.lg { height: 46px; padding: 0 20px; font-size: 15px; border-radius: var(--radius); }
.btn.block { width: 100%; }
.btn.icon-btn { width: 38px; padding: 0; }
.btn.icon-btn.sm { width: 31px; }
.btn.icon-btn.xs { width: 26px; }
.btn.round { border-radius: 999px; }
.btn.busy { pointer-events: none; opacity: .7; }
.fab { position: fixed; right: 18px; bottom: calc(var(--tabbar-h) + 18px + env(safe-area-inset-bottom)); z-index: 25; height: 50px; padding: 0 18px 0 14px; border-radius: 999px; box-shadow: var(--shadow); }
@media (min-width: 900px) { .fab { bottom: 28px; right: 28px; } }

/* ---------- inputs ---------- */
.input, .textarea, .select { width: 100%; height: 40px; padding: 0 12px; border: 1px solid var(--border-2); border-radius: var(--radius-sm); background: var(--input-bg); color: var(--text); transition: border-color .15s, box-shadow .15s; }
.textarea { height: auto; min-height: 92px; padding: 10px 12px; resize: vertical; line-height: 1.55; }
.input:focus, .textarea:focus, .select:focus { outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--ring); }
.select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23716c5e' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 10px center; padding-right: 32px; }
.input.sm, .select.sm { height: 33px; font-size: 13.5px; }
.field { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.field > label { font-size: 12.5px; font-weight: 600; color: var(--text-2); }
.field .hint { font-size: 12px; color: var(--text-3); }
.field .req::after { content: ' *'; color: var(--red); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px 14px; }
.form-grid .span2 { grid-column: 1 / -1; }
.form-error { color: var(--red); font-size: 13px; background: var(--red-soft); padding: 8px 10px; border-radius: var(--radius-sm); }
.check { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.check input { width: 17px; height: 17px; accent-color: var(--primary); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .track { width: 40px; height: 24px; border-radius: 12px; background: var(--border-2); position: relative; transition: background .15s; flex: 0 0 auto; }
.switch .track::after { content: ''; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: left .15s; box-shadow: 0 1px 2px rgba(0,0,0,.3); }
.switch input:checked + .track { background: var(--primary); } .switch input:checked + .track::after { left: 19px; }
.search { position: relative; }
.search .icon { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); color: var(--text-3); }
.search .input { padding-left: 36px; }
.segment { display: inline-flex; background: var(--surface-2); border-radius: var(--radius-sm); padding: 3px; gap: 2px; }
.segment button { height: 30px; padding: 0 12px; border: 0; border-radius: 6px; background: transparent; color: var(--text-2); font-weight: 600; font-size: 13px; }
.segment button.on { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }
.chips-select { display: flex; flex-wrap: wrap; gap: 6px; }
.chips-select .chip { cursor: pointer; user-select: none; }
.chips-select .chip.on { background: var(--primary); color: var(--on-primary); border-color: var(--primary); }

/* ---------- chips / badges ---------- */
.chip { display: inline-flex; align-items: center; gap: 4px; height: 24px; padding: 0 9px; border-radius: 999px; font-size: 12px; font-weight: 600; background: var(--gray-soft); color: var(--gray); border: 1px solid transparent; white-space: nowrap; }
.chip.sm { height: 20px; font-size: 11px; padding: 0 7px; }
.chip.red { background: var(--red-soft); color: var(--red); } .chip.orange { background: var(--orange-soft); color: var(--orange); } .chip.amber { background: var(--amber-soft); color: var(--amber); }
.chip.green { background: var(--green-soft); color: var(--green); } .chip.blue { background: var(--blue-soft); color: var(--blue); } .chip.purple { background: var(--purple-soft); color: var(--purple); }
.chip.teal { background: var(--teal-soft); color: var(--teal); } .chip.copper { background: var(--copper-soft); color: var(--copper); } .chip.lime { background: var(--lime-soft); color: var(--lime); }
.chip.outline { background: transparent; border-color: var(--border-2); color: var(--text-2); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--gray); display: inline-block; }
.dot.pulse { background: var(--copper); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: inline-grid; place-items: center; color: #fff; font-size: 11.5px; font-weight: 700; flex: 0 0 auto; }
.avatar.sm { width: 24px; height: 24px; font-size: 10px; } .avatar.lg { width: 44px; height: 44px; font-size: 15px; }

/* ---------- cards / lists ---------- */
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 16px; }
.card.pad-s { padding: 12px; }
.card-title { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.card-title h2, .card-title h3 { display: flex; align-items: center; gap: 8px; }
.grid2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 14px; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 14px; }
.list > * + * { border-top: 1px solid var(--border); }
.list-item { display: flex; align-items: center; gap: 12px; padding: 11px 0; min-width: 0; }
.list-item.link { cursor: pointer; margin: 0 -8px; padding-left: 8px; padding-right: 8px; border-radius: var(--radius-sm); }
.list-item.link:hover { background: var(--surface-2); }
.empty { text-align: center; color: var(--text-3); padding: 34px 12px; font-size: 14px; }
.empty .icon { width: 36px; height: 36px; margin-bottom: 8px; color: var(--border-2); }
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; text-decoration: none; color: inherit; display: block; }
.kpi:hover { text-decoration: none; border-color: var(--border-2); }
.kpi .v { font-size: 24px; font-weight: 800; letter-spacing: -0.02em; font-variant-numeric: tabular-nums; }
.kpi .k { font-size: 12px; color: var(--text-2); margin-top: 2px; }
.kpi.accent .v { color: var(--primary); }
.kpi.red .v { color: var(--red); }

/* ---------- cases list ---------- */
.case-row { display: grid; grid-template-columns: 42px minmax(0, 1fr) auto; gap: 12px; align-items: center; padding: 12px 10px; border-radius: var(--radius); cursor: pointer; text-decoration: none; color: inherit; }
.case-row:hover { background: var(--surface-2); text-decoration: none; }
.case-row .name { font-weight: 700; display: flex; align-items: center; gap: 8px; min-width: 0; }
.case-row .name span.t { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-row .meta { font-size: 12.5px; color: var(--text-2); margin-top: 2px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-row .snippet { font-size: 13px; color: var(--text-3); margin-top: 3px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.case-row .side { text-align: right; font-size: 11.5px; color: var(--text-3); display: flex; flex-direction: column; align-items: flex-end; gap: 5px; }
.case-row.red { background: color-mix(in srgb, var(--red-soft) 55%, transparent); }
.stage-filters { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.stage-filters::-webkit-scrollbar { display: none; }
.stage-filters .chip { cursor: pointer; height: 28px; font-size: 12.5px; flex: 0 0 auto; }
.stage-filters .chip.on { background: var(--ink); color: var(--paper); }
[data-theme='dark'] .stage-filters .chip.on { background: var(--paper); color: var(--ink); }

/* ---------- case workspace ---------- */
.case-head { display: flex; flex-direction: column; gap: 8px; }
.case-head .title { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.case-head h1 { font-size: 20px; }
.case-head .facts { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 13px; color: var(--text-2); }
.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; margin: 10px 0 14px; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a { padding: 9px 12px; font-size: 14px; font-weight: 600; color: var(--text-2); border-bottom: 2px solid transparent; white-space: nowrap; text-decoration: none; display: inline-flex; gap: 6px; align-items: center; }
.tabs a.active { color: var(--primary); border-bottom-color: var(--primary); }
.tabs a .count { font-size: 11px; background: var(--surface-3); color: var(--text-2); border-radius: 999px; padding: 0 6px; }
.redlight { display: flex; gap: 10px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); background: var(--red-soft); color: var(--red); border: 1px solid color-mix(in srgb, var(--red) 30%, transparent); font-weight: 600; }
.redlight .icon { margin-top: 2px; }
.workspace { display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
@media (min-width: 1200px) { .workspace.with-side { grid-template-columns: minmax(0, 1fr) 320px; align-items: start; } .side-panel { position: sticky; top: calc(var(--topbar-h) + 12px); } }
.timeline { display: flex; flex-direction: column; gap: 18px; }
.round { display: flex; flex-direction: column; gap: 8px; }
.round-head { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text-3); }
.round-head .line { flex: 1; border-top: 1px dashed var(--border-2); }
.bubble { position: relative; max-width: 92%; padding: 10px 14px; border-radius: 16px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; font-size: 14.5px; }
.bubble.them { align-self: flex-start; background: var(--bubble-them); border: 1px solid var(--border); border-top-left-radius: 6px; }
.bubble.us { align-self: flex-end; background: var(--bubble-us); border-top-right-radius: 6px; }
.bubble.note { align-self: center; background: var(--surface-2); color: var(--text-2); font-size: 13px; border-radius: 10px; max-width: 100%; }
.bubble .label { display: block; font-size: 11px; font-weight: 700; color: var(--text-3); margin-bottom: 4px; letter-spacing: .02em; }
.bubble .actions { display: flex; gap: 6px; margin-top: 8px; justify-content: flex-end; }
.bubble.us .actions { justify-content: flex-start; }
.attach-row { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; max-width: 92%; }
.attach { display: inline-flex; align-items: center; gap: 6px; padding: 4px 8px 4px 4px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); font-size: 12px; color: var(--text-2); text-decoration: none; max-width: 240px; }
.attach img { width: 30px; height: 30px; object-fit: cover; border-radius: 5px; }
.attach .ph { width: 30px; height: 30px; border-radius: 5px; background: var(--surface-3); display: grid; place-items: center; color: var(--text-3); }
.attach span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.memo { align-self: stretch; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; }
.memo summary { padding: 9px 14px; font-size: 13px; font-weight: 600; color: var(--text-2); cursor: pointer; list-style: none; display: flex; align-items: center; gap: 8px; }
.memo summary::-webkit-details-marker { display: none; }
.memo summary .icon { transition: transform .15s; }
.memo[open] summary .icon.chev { transform: rotate(180deg); }
.memo .body { padding: 2px 14px 12px; font-size: 13.5px; }
.memo .body ul { padding-left: 18px; list-style: disc; } .memo .body li { margin: 3px 0; }
.docpath { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 6px 10px; padding: 8px 0; border-top: 1px dashed var(--border); align-items: center; font-size: 13px; }
.docpath .d { font-weight: 600; } .docpath .w { color: var(--text-3); font-size: 12px; } .docpath .p { color: var(--text-2); grid-column: 1 / -1; }
.progress { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 12px 14px; align-self: stretch; }
.progress .head { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13.5px; }
.progress .log { margin-top: 8px; font-size: 12.5px; color: var(--text-2); max-height: 180px; overflow: auto; font-family: var(--mono); line-height: 1.5; }
.progress .log div { padding: 1px 0; }
.progress .log .t { color: var(--text-3); margin-right: 8px; }
.failed { border-color: color-mix(in srgb, var(--red) 40%, transparent); }
.failed .head { color: var(--red); }

/* composer */
.composer { position: sticky; bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); z-index: 15; margin-top: 16px; background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius-lg); box-shadow: var(--shadow); padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; }
@media (min-width: 900px) { .composer { bottom: 14px; } }
.composer textarea { width: 100%; border: 0; background: transparent; resize: none; min-height: 44px; max-height: 40vh; padding: 6px 4px; line-height: 1.5; font-size: 15px; }
.composer textarea:focus { outline: none; }
.composer .tools { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.composer .tools .grow { flex: 1; }
.composer .pending { display: flex; gap: 8px; flex-wrap: wrap; }
.composer .pending .thumb { position: relative; width: 60px; height: 60px; border-radius: 8px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); display: grid; place-items: center; font-size: 10px; color: var(--text-3); text-align: center; padding: 2px; }
.composer .pending .thumb img { width: 100%; height: 100%; object-fit: cover; }
.composer .pending .thumb .rm { position: absolute; top: 2px; right: 2px; width: 18px; height: 18px; border-radius: 50%; background: rgba(0,0,0,.6); color: #fff; border: 0; display: grid; place-items: center; padding: 0; }
.composer .pending .thumb .rm .icon { width: 11px; height: 11px; stroke-width: 3; }
.composer .overrides { display: flex; flex-wrap: wrap; gap: 6px; }
.composer .instruction { border-top: 1px dashed var(--border); padding-top: 8px; }
.composer .instruction input { border: 0; background: transparent; width: 100%; font-size: 13.5px; padding: 4px; }
.composer .instruction input:focus { outline: none; }
.composer.disabled { opacity: .7; pointer-events: none; }

/* side panel */
.side-panel .card + .card { margin-top: 12px; }
.facts-list { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 13px; }
.facts-list dt { color: var(--text-3); white-space: nowrap; } .facts-list dd { margin: 0; min-width: 0; word-break: break-word; }
.mini-stat { display: flex; gap: 10px; flex-wrap: wrap; font-size: 12.5px; color: var(--text-2); }

/* worklog */
.md { font-size: 14.5px; line-height: 1.7; word-break: break-word; }
.md h1 { font-size: 20px; margin: 0 0 8px; } .md h2 { font-size: 16.5px; margin: 24px 0 8px; padding-top: 12px; border-top: 1px solid var(--border); scroll-margin-top: 120px; }
.md h3 { font-size: 15px; margin: 16px 0 6px; } .md h4 { margin: 12px 0 4px; }
.md p { margin: 6px 0; } .md ul, .md ol { padding-left: 20px; margin: 6px 0; } .md ul { list-style: disc; } .md ol { list-style: decimal; } .md li { margin: 3px 0; }
.md table { border-collapse: collapse; width: 100%; font-size: 13px; margin: 8px 0; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 5px 8px; vertical-align: top; text-align: left; min-width: 60px; }
.md th { background: var(--surface-2); font-weight: 600; white-space: nowrap; }
.md code { background: var(--surface-2); padding: 1px 5px; border-radius: 4px; } .md pre { background: var(--surface-2); padding: 10px; border-radius: 8px; overflow: auto; }
.md blockquote { margin: 8px 0; padding: 4px 12px; border-left: 3px solid var(--primary); color: var(--text-2); }
.md a { word-break: break-all; }
.md hr { margin: 16px 0; }
.md img { max-width: 100%; }
.section-nav { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; padding-bottom: 4px; position: sticky; top: var(--topbar-h); background: var(--bg); z-index: 5; padding-top: 6px; }
.section-nav::-webkit-scrollbar { display: none; }
.section-nav a { flex: 0 0 auto; padding: 5px 10px; border-radius: 999px; background: var(--surface-2); font-size: 12.5px; font-weight: 600; color: var(--text-2); text-decoration: none; }
.editor { width: 100%; min-height: 60vh; font-family: var(--mono); font-size: 12.5px; line-height: 1.55; padding: 12px; border: 1px solid var(--border-2); border-radius: var(--radius); background: var(--input-bg); resize: vertical; }

/* files */
.file-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.file-card { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); overflow: hidden; cursor: pointer; display: flex; flex-direction: column; }
.file-card:hover { border-color: var(--border-2); }
.file-card .pv { height: 110px; background: var(--surface-2); display: grid; place-items: center; color: var(--text-3); overflow: hidden; }
.file-card .pv img { width: 100%; height: 100%; object-fit: cover; }
.file-card .pv .icon { width: 30px; height: 30px; }
.file-card .nm { padding: 8px 10px 4px; font-size: 12.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-card .st { padding: 0 10px 8px; font-size: 11.5px; color: var(--text-3); display: flex; gap: 6px; align-items: center; }
.file-preview img { max-width: 100%; max-height: 60vh; border-radius: 8px; border: 1px solid var(--border); }
.transcript { max-height: 50vh; overflow: auto; background: var(--surface-2); padding: 10px 12px; border-radius: var(--radius-sm); font-size: 13px; white-space: pre-wrap; word-break: break-word; }

/* docs */
.doc-actions { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 10px; }
.doc-action { border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 12px 14px; cursor: pointer; text-align: left; display: flex; gap: 10px; align-items: flex-start; }
.doc-action:hover { border-color: var(--primary); background: var(--primary-soft); }
.doc-action .icon { color: var(--primary); margin-top: 2px; }
.doc-action b { display: block; font-size: 14px; } .doc-action span { font-size: 12px; color: var(--text-2); }
.doc-item { display: grid; grid-template-columns: 36px minmax(0, 1fr) auto; gap: 10px; align-items: center; padding: 10px 0; }
.doc-item .k { width: 36px; height: 36px; border-radius: 8px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; }
.doc-item .t { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.doc-item .m { font-size: 12px; color: var(--text-3); }
.doc-item .a { display: flex; gap: 4px; }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.table th { text-align: left; font-size: 12px; color: var(--text-2); font-weight: 600; padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--surface-2); white-space: nowrap; }
.table td { padding: 9px 10px; border-bottom: 1px solid var(--border); vertical-align: top; }
.table tr:last-child td { border-bottom: 0; }
.table.hover tbody tr:hover { background: var(--surface-2); }
.table td.n, .table th.n { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tablewrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* knowledge */
.kb-hit { padding: 12px 0; border-top: 1px solid var(--border); }
.kb-hit:first-child { border-top: 0; }
.kb-hit .t { font-weight: 600; display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.kb-hit .b { font-size: 13.5px; color: var(--text-2); margin-top: 4px; white-space: pre-wrap; word-break: break-word; max-height: 160px; overflow: hidden; position: relative; }
.kb-hit .b.open { max-height: none; }
.kb-hit .b:not(.open)::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 40px; background: linear-gradient(transparent, var(--surface)); }
mark { background: var(--amber-soft); color: inherit; padding: 0 1px; border-radius: 2px; }

/* tools */
.result-box { background: var(--surface-2); border-radius: var(--radius-sm); padding: 12px; font-size: 13.5px; white-space: pre-wrap; word-break: break-word; max-height: 60vh; overflow: auto; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; font-size: 13.5px; }
.kv dt { color: var(--text-3); } .kv dd { margin: 0; word-break: break-word; }
.ok-big { font-size: 20px; font-weight: 800; }

/* modal / toast */
.modal-back { position: fixed; inset: 0; background: rgba(18, 17, 14, 0.45); backdrop-filter: blur(3px); z-index: 50; display: flex; align-items: flex-end; justify-content: center; padding: 0; animation: fade .15s; }
@media (min-width: 640px) { .modal-back { align-items: center; padding: 20px; } }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { background: var(--surface); width: 100%; max-width: 560px; max-height: 92dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; display: flex; flex-direction: column; box-shadow: var(--shadow-lg); animation: up .18s ease-out; }
@media (min-width: 640px) { .modal { border-radius: var(--radius-lg); } .modal.lg { max-width: 860px; } .modal.xl { max-width: 1100px; } }
@keyframes up { from { transform: translateY(16px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-head { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--border); }
.modal-head h2 { flex: 1; font-size: 16px; }
.modal-body { padding: 16px 18px; overflow: auto; }
.modal-foot { display: flex; gap: 8px; justify-content: flex-end; padding: 12px 18px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); flex-wrap: wrap; }
.modal-foot .left { margin-right: auto; }
#toasts { position: fixed; top: 12px; left: 50%; transform: translateX(-50%); z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center; width: min(92vw, 420px); pointer-events: none; }
.toast { background: var(--ink); color: var(--paper); padding: 10px 16px; border-radius: 999px; font-size: 13.5px; font-weight: 600; box-shadow: var(--shadow); animation: up .18s; display: flex; gap: 8px; align-items: center; max-width: 100%; }
[data-theme='dark'] .toast { background: var(--paper); color: var(--ink); }
.toast.success { background: var(--green); color: #fff; } .toast.error { background: var(--red); color: #fff; }

/* auth */
.auth { min-height: 100dvh; display: grid; grid-template-columns: 1fr; }
@media (min-width: 900px) { .auth { grid-template-columns: 1.1fr 1fr; } }
.auth .hero { background: var(--ink); color: var(--paper); padding: 48px 40px; display: flex; flex-direction: column; justify-content: space-between; gap: 30px; }
.auth .hero .mark { width: 56px; height: 56px; }
.auth .hero h1 { font-size: 30px; line-height: 1.25; letter-spacing: -0.02em; font-weight: 800; margin-top: 18px; }
.auth .hero p { color: #bdb7a8; max-width: 44ch; margin-top: 10px; font-size: 15px; }
.auth .hero ul { margin-top: 26px; display: grid; gap: 14px; }
.auth .hero li { display: flex; gap: 12px; align-items: flex-start; color: #e6e1d4; font-size: 14px; }
.auth .hero li .icon { color: #d4a06e; margin-top: 2px; }
.auth .hero .foot { color: #857f70; font-size: 12px; }
.auth .pane { display: flex; align-items: center; justify-content: center; padding: 32px 20px; }
.auth form { width: 100%; max-width: 380px; display: flex; flex-direction: column; gap: 14px; }
.auth h2 { font-size: 22px; }
@media (max-width: 899px) { .auth .hero { padding: 36px 24px 28px; } .auth .hero ul, .auth .hero .foot { display: none; } .auth .hero h1 { font-size: 24px; } }

/* skeleton */
.skel { background: linear-gradient(90deg, var(--surface-2), var(--surface-3), var(--surface-2)); background-size: 200% 100%; animation: sk 1.2s infinite; border-radius: 8px; height: 14px; margin: 10px 0; }
.skel.t { width: 40%; height: 22px; } .skel.b { height: 120px; }
@keyframes sk { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }

/* markdown note in bubble */
.bubble .md { font-size: 14px; }
.bubble .md p { margin: 4px 0; }

/* print */
@media print { .rail, .tabbar, .topbar, .composer, .fab { display: none !important; } .page { padding: 0; } }
