/* Work Viewer: Material 3-style tokens, light and dark */
:root {
  --bg: #f7f5fb; --surface: #ffffff; --surface-2: #f1eef7; --surface-3: #e9e5f1; --on: #1c1b20; --on-2: #4a4655; --line: #d9d4e3;
  --primary: #5b4bc4; --on-primary: #fff; --primary-c: #e6e0ff; --on-primary-c: #1d1259;
  --tertiary-c: #ffe0d6; --on-tertiary-c: #3d1408; --warn-c: #fff1c9; --on-warn-c: #3d2d00;
  --r-s: 8px; --r-m: 12px; --r-l: 16px; --r-xl: 24px; --r-full: 999px;
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", sans-serif;
  --mono: "Cascadia Code", Consolas, "SFMono-Regular", Menlo, monospace;
  --serif: Georgia, "Source Serif 4", "Times New Roman", serif;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #16141c; --surface: #1e1c25; --surface-2: #26232f; --surface-3: #302c3a; --on: #e7e3ee; --on-2: #b3adbf; --line: #3b3746;
    --primary: #c6bcff; --on-primary: #2b1d86; --primary-c: #41339e; --on-primary-c: #e6e0ff;
    --tertiary-c: #5c2a1b; --on-tertiary-c: #ffdbcf; --warn-c: #4d3c00; --on-warn-c: #ffe08a;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #16141c; --surface: #1e1c25; --surface-2: #26232f; --surface-3: #302c3a; --on: #e7e3ee; --on-2: #b3adbf; --line: #3b3746;
  --primary: #c6bcff; --on-primary: #2b1d86; --primary-c: #41339e; --on-primary-c: #e6e0ff;
  --tertiary-c: #5c2a1b; --on-tertiary-c: #ffdbcf; --warn-c: #4d3c00; --on-warn-c: #ffe08a;
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--on); font: 15px/1.5 var(--font); -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--primary); }
code { font-family: var(--mono); font-size: 0.92em; }
button { font: inherit; color: inherit; }
.skip { position: absolute; left: -999px; top: 8px; z-index: 99; padding: 8px 12px; background: var(--primary); color: var(--on-primary); border-radius: var(--r-s); }
.skip:focus { left: 8px; }
:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 40px; padding: 0 18px; border: 0; border-radius: var(--r-full); font-weight: 650; cursor: pointer; text-decoration: none; transition: border-radius 200ms, background 150ms; }
.btn:active { border-radius: var(--r-s); }
.btn--filled { background: var(--primary); color: var(--on-primary); }
.btn--tonal { background: var(--primary-c); color: var(--on-primary-c); }
.btn--text { background: none; color: var(--primary); padding: 0 12px; }
.btn--wide { width: 100%; height: 48px; }
.btn svg { width: 18px; height: 18px; }
.iconbtn { display: grid; place-items: center; width: 40px; height: 40px; border: 0; border-radius: var(--r-full); background: none; cursor: pointer; color: var(--on-2); }
.iconbtn:hover { background: var(--surface-3); }
.iconbtn svg { width: 22px; height: 22px; }
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 17px; }

/* Unlock */
.unlock { min-height: 100%; display: grid; place-items: center; padding: 24px 16px; }
.unlock__card { width: min(440px, 100%); display: grid; gap: 14px; padding: 28px; border-radius: var(--r-xl); background: var(--surface); box-shadow: 0 2px 12px rgba(0,0,0,.08); }
.unlock__title { margin: 6px 0 0; font-size: 26px; line-height: 32px; }
.unlock__lead { margin: 0; color: var(--on-2); }
.unlock__err { margin: 0; padding: 10px 12px; border-radius: var(--r-s); background: var(--tertiary-c); color: var(--on-tertiary-c); }
.field { display: grid; gap: 6px; font-weight: 650; font-size: 14px; }
.field input { height: 48px; padding: 0 14px; border: 1px solid var(--line); border-radius: var(--r-m); background: var(--surface-2); color: var(--on); font: 16px var(--mono); }
.check { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--on-2); }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }

/* Layout */
.app { display: grid; grid-template-columns: 340px minmax(0, 1fr); height: 100%; }
.side { display: flex; flex-direction: column; min-height: 0; border-right: 1px solid var(--line); background: var(--surface); }
.side__head { display: flex; align-items: center; justify-content: space-between; padding: 14px 10px 8px 16px; }
.side__tools { display: flex; }
.search { display: flex; align-items: center; gap: 8px; margin: 4px 12px 6px; padding: 0 14px; height: 44px; border-radius: var(--r-full); background: var(--surface-2); color: var(--on-2); }
.search svg { width: 20px; height: 20px; flex-shrink: 0; }
.search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--on); font: inherit; outline: none; }
.side__meta { padding: 2px 18px 8px; font-size: 12.5px; color: var(--on-2); }
.slist { list-style: none; margin: 0; padding: 0 8px 16px; overflow-y: auto; flex: 1; }
.srow { display: block; width: 100%; padding: 10px 12px; border: 0; border-radius: var(--r-m); background: none; text-align: left; cursor: pointer; text-decoration: none; color: inherit; }
.srow:hover { background: var(--surface-2); }
.srow[aria-current="true"] { background: var(--primary-c); color: var(--on-primary-c); }
.srow__title { display: block; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow__meta { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 2px; font-size: 12.5px; color: var(--on-2); }
.srow[aria-current="true"] .srow__meta { color: inherit; opacity: 0.8; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 0 8px; height: 20px; border-radius: var(--r-full); background: var(--warn-c); color: var(--on-warn-c); font-size: 11.5px; font-weight: 700; }
.main { min-width: 0; min-height: 0; overflow-y: auto; outline: none; }
.empty { padding: 48px 24px; color: var(--on-2); text-align: center; }
.empty h2 { color: var(--on); margin: 0 0 6px; }

/* Session page */
.sess { max-width: 980px; margin: 0 auto; padding: 22px 28px 64px; }
.sess__top { display: flex; align-items: flex-start; gap: 8px; }
.back { display: none; }
.sess__heads { flex: 1; min-width: 0; }
.sess__title { margin: 0; font-size: 26px; line-height: 32px; font-weight: 800; overflow-wrap: anywhere; }
.sess__meta { margin: 4px 0 0; font-size: 13px; color: var(--on-2); overflow-wrap: anywhere; }
.sess__summary { margin: 16px 0 0; font-family: var(--serif); font-size: 16.5px; line-height: 25px; }
.needs { margin: 18px 0 0; padding: 14px 16px; border-radius: var(--r-l); background: var(--warn-c); color: var(--on-warn-c); }
.needs h2 { margin: 0 0 8px; font-size: 14px; letter-spacing: 0.04em; text-transform: uppercase; }
.needs ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.needs a { color: inherit; font-weight: 700; }
.tabs { display: flex; gap: 4px; margin: 22px 0 14px; border-bottom: 1px solid var(--line); }
.tab { padding: 10px 16px; border: 0; border-bottom: 3px solid transparent; background: none; font-weight: 650; color: var(--on-2); cursor: pointer; text-decoration: none; }
.tab[aria-selected="true"] { color: var(--primary); border-bottom-color: var(--primary); }
.files { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 10px; }
.fcard { display: flex; gap: 12px; height: 100%; padding: 14px; border-radius: var(--r-l); background: var(--surface); text-decoration: none; color: inherit; border: 1px solid var(--line); }
.fcard:hover { border-color: var(--primary); }
.ficon { flex-shrink: 0; display: grid; place-items: center; width: 42px; height: 42px; border-radius: var(--r-m); background: var(--primary-c); color: var(--on-primary-c); font: 800 11px var(--font); text-transform: uppercase; }
.fcard__body { min-width: 0; }
.fcard__name { display: block; font-weight: 700; overflow-wrap: anywhere; }
.fcard__note { display: block; margin-top: 2px; font-size: 13px; color: var(--on-2); }
.fcard__meta { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 6px; font-size: 12px; color: var(--on-2); }

/* File viewer */
.fview__bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 12px; }
.fview__name { flex: 1; min-width: 0; margin: 0; font-size: 20px; line-height: 26px; overflow-wrap: anywhere; }
.fview__note { margin: 0 0 12px; color: var(--on-2); }
.fview__input { margin: 0 0 14px; padding: 10px 14px; border-radius: var(--r-m); background: var(--warn-c); color: var(--on-warn-c); }
.fview__body { border-radius: var(--r-l); background: var(--surface); border: 1px solid var(--line); overflow: hidden; }
.fview__msg { padding: 32px; text-align: center; color: var(--on-2); }
.doc { padding: 24px 32px; overflow-x: auto; overflow-wrap: anywhere; }
.doc h1, .doc h2, .doc h3 { line-height: 1.25; }
.doc table { border-collapse: collapse; margin: 12px 0; font-size: 14px; }
.doc th, .doc td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; vertical-align: top; }
.doc th { background: var(--surface-2); }
.doc pre { padding: 12px 14px; border-radius: var(--r-m); background: var(--surface-2); overflow-x: auto; }
.doc img { max-width: 100%; height: auto; }
.doc blockquote { margin: 12px 0; padding: 4px 14px; border-left: 3px solid var(--primary); color: var(--on-2); }
.code { margin: 0; padding: 16px 18px; overflow: auto; max-height: 75vh; font: 13px/1.55 var(--mono); white-space: pre; tab-size: 4; }
.imgview { display: grid; place-items: center; padding: 16px; background: var(--surface-2); }
.imgview img { max-width: 100%; max-height: 78vh; height: auto; }
.frame { display: block; width: 100%; height: 78vh; border: 0; background: #fff; }
.tablewrap { overflow: auto; max-height: 75vh; }
.grid { border-collapse: collapse; font-size: 13px; }
.grid th, .grid td { border: 1px solid var(--line); padding: 5px 9px; white-space: nowrap; max-width: 420px; overflow: hidden; text-overflow: ellipsis; }
.grid thead th { position: sticky; top: 0; background: var(--surface-2); }
.sheettabs { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px; border-bottom: 1px solid var(--line); }
.chip { padding: 4px 12px; border: 1px solid var(--line); border-radius: var(--r-full); background: none; font-size: 13px; cursor: pointer; }
.chip[aria-pressed="true"] { background: var(--primary-c); color: var(--on-primary-c); border-color: transparent; }
.pdfpages { display: grid; gap: 12px; justify-items: center; padding: 16px; background: var(--surface-2); }
.pdfpages canvas { max-width: 100%; height: auto; background: #fff; box-shadow: 0 1px 4px rgba(0,0,0,.15); }
.note-trunc { padding: 8px 16px; font-size: 12.5px; color: var(--on-2); border-bottom: 1px solid var(--line); }
.nb-cell { padding: 10px 24px; border-bottom: 1px solid var(--line); }
.nb-out { margin-top: 8px; }
.nb-out img { max-width: 100%; }

/* Transcript */
.tx { display: grid; gap: 14px; }
.tx__user { justify-self: end; max-width: min(640px, 88%); padding: 10px 16px; border-radius: var(--r-l) var(--r-l) var(--r-s) var(--r-l); background: var(--primary-c); color: var(--on-primary-c); white-space: pre-wrap; overflow-wrap: anywhere; }
.tx__time { display: block; margin-bottom: 2px; font-size: 11.5px; opacity: 0.75; }
.tx__ai { max-width: 760px; overflow-wrap: anywhere; }
.tx__ai > :first-child { margin-top: 0; }
.tx__ai > :last-child { margin-bottom: 0; }
.tx__ai pre { padding: 10px 12px; border-radius: var(--r-m); background: var(--surface-2); overflow-x: auto; }
.tx__ai table { border-collapse: collapse; font-size: 14px; }
.tx__ai th, .tx__ai td { border: 1px solid var(--line); padding: 4px 8px; }
.tx__tools { max-width: 760px; border-radius: var(--r-m); background: var(--surface-2); font-size: 13px; }
.tx__tools summary { padding: 6px 12px; cursor: pointer; color: var(--on-2); }
.tx__tools ol { margin: 0; padding: 0 12px 8px 34px; color: var(--on-2); }
.tx__tools li { padding: 1px 0; overflow-wrap: anywhere; }
.tx__tools b { font-family: var(--mono); font-weight: 600; color: var(--on); }
.tx__more { justify-self: center; }
.tx__count { margin: 0 0 12px; font-size: 13px; color: var(--on-2); }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 50; max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: var(--r-m); background: var(--on); color: var(--bg); box-shadow: 0 4px 16px rgba(0,0,0,.2); }

@media (max-width: 899px) {
  .app { grid-template-columns: minmax(0, 1fr); }
  .app.is-detail .side { display: none; }
  .app:not(.is-detail) .main { display: none; }
  .side { border-right: 0; }
  .back { display: grid; margin-left: -8px; }
  .sess { padding: 14px 16px calc(48px + env(safe-area-inset-bottom)); }
  .sess__title { font-size: 21px; line-height: 27px; }
  .doc { padding: 16px; }
  .files { grid-template-columns: minmax(0, 1fr); }
  .frame { height: 70vh; }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
