/* Teamcomm — Ink & sky brand (brand guide v1.1). Inter, 4 px grid, 8–12 px radii. */
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('/fonts/inter-latin-wght-normal.woff2') format('woff2'); unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD; }
@font-face { font-family: 'Inter'; font-style: normal; font-weight: 100 900; font-display: swap; src: url('/fonts/inter-latin-ext-wght-normal.woff2') format('woff2'); unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF; }

:root {
  /* Teamcomm foundation (fixed) */
  --ink: #172B4D;           /* navigation, logo, headings */
  --ink-hover: #22385E;
  --ink-active: #2C4570;
  --sky: #A9DDF5;           /* small highlights only; never white text on sky */
  --canvas: #F5F8FC;        /* reading surfaces */
  --surface: #FFFFFF;
  --slate: #526580;         /* secondary text */
  --on-dark: #FFFFFF;
  --on-dark-muted: #B9C6DA;
  /* Business accent (set from workspace branding; Teamcomm cobalt by default) */
  --action: #245DDB;
  --action-hover: #1D4FBD;
  --action-soft: #E5EDFB;
  --action-on-dark: #8FB0F0;
  --on-action: #FFFFFF;
  /* Status colours stay independent of any client accent */
  --success: #1E7B4F;
  --warning: #8A5300;
  --danger: #B42318;
  /* Derived */
  --bg: var(--surface);
  --fg: var(--ink);
  --muted: var(--slate);
  --line: #DCE3ED;
  --hover: #EEF3FA;
  --mention-bg: #E3F3FC;
  --mention-me-bg: var(--sky);
  --pin: #F3F7FD;
  --link: var(--action);
  --focus: var(--action);
  --r-sm: 8px;
  --r-md: 12px;
  --shadow: 0 8px 28px rgba(23, 43, 77, .16);
  --sidebar-w: 272px;
  --pane-w: 400px;
  --tabbar-h: 0px;
  font-family: Inter, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color-scheme: light;
  -webkit-text-size-adjust: 100%;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12203A;
    --surface: #12203A;
    --canvas: #0E1A2F;
    --fg: #E8EEF8;
    --muted: #A9B7CC;
    --line: #26395C;
    --hover: #1A2C4C;
    --mention-bg: #1C3B5C;
    --mention-me-bg: #2B567E;
    --pin: #172947;
    --link: var(--action-on-dark);
    --focus: var(--sky);
    --action-soft: #1C3157;
    color-scheme: dark;
  }
}
* { box-sizing: border-box; }
html, body, #app { margin: 0; height: 100%; background: var(--bg); color: var(--fg); }
body { font-feature-settings: "cv11", "ss01"; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; cursor: pointer; }
input, textarea, select { font: inherit; color: var(--fg); background: var(--bg); }
a { color: var(--link); }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 4px; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
h1, h2, h3 { font-weight: 600; color: var(--fg); }

/* ---------- buttons & fields ---------- */
.btn { border: 1px solid var(--line); background: var(--surface); color: var(--fg); border-radius: var(--r-sm); padding: 8px 16px; font-weight: 500; font-size: 14px; line-height: 20px; }
.btn:hover { background: var(--hover); }
.btn.primary { background: var(--action); border-color: var(--action); color: var(--on-action); }
.btn.primary:hover { background: var(--action-hover); border-color: var(--action-hover); }
.btn.danger { color: var(--danger); border-color: currentColor; background: var(--surface); }
.btn.small { padding: 4px 12px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: default; }
.field { display: grid; gap: 4px; }
.field label { font-weight: 500; font-size: 14px; line-height: 20px; }
.field input, .field select, .field textarea { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 12px; width: 100%; background: var(--surface); }
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--action); outline: 2px solid var(--action-soft); }
.field .hint, .hint { font-size: 13px; color: var(--muted); line-height: 18px; }
.error { color: var(--danger); font-size: 14px; min-height: 1em; }
.error:not(:empty)::before { content: "⚠ "; }

/* ---------- sign-in / setup ---------- */
.login { min-height: 100%; display: grid; place-items: center; background: var(--canvas); padding: 24px 16px; }
.login form { background: var(--surface); padding: 32px; border-radius: var(--r-md); width: 100%; max-width: 400px; box-shadow: var(--shadow); display: grid; gap: 16px; border: 1px solid var(--line); }
.login .lockup { height: 40px; width: auto; margin: 0 auto 8px; display: block; }
.login h1 { margin: 0; font-size: 24px; line-height: 32px; }
.login p { margin: 0; color: var(--muted); font-size: 14px; }
.login .client { display: flex; align-items: center; gap: 12px; padding: 12px; border-radius: var(--r-sm); background: var(--canvas); border: 1px solid var(--line); }
.login .client img { height: 32px; width: auto; max-width: 120px; object-fit: contain; }
.login .foot { text-align: center; font-size: 12px; color: var(--muted); }
@media (prefers-color-scheme: dark) { .login .lockup.light { display: none; } }
@media (prefers-color-scheme: light) { .login .lockup.dark { display: none; } }

/* ---------- app shell ---------- */
.shell { display: grid; grid-template-columns: var(--sidebar-w) minmax(0, 1fr) auto; height: 100vh; height: 100dvh; }
.sidebar { background: var(--ink); color: var(--on-dark); display: flex; flex-direction: column; min-height: 0; }
.side-scroll { flex: 1; overflow-y: auto; padding-bottom: 16px; }
.side-top { padding: 16px 16px 8px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.side-top .lockup { height: 26px; width: auto; display: block; }
.ws-switch { margin: 4px 8px 8px; width: calc(100% - 16px); display: flex; align-items: center; gap: 12px; padding: 8px; border-radius: var(--r-sm); border: 0; background: rgba(255, 255, 255, .06); color: var(--on-dark); text-align: left; }
.ws-switch:hover { background: var(--ink-hover); }
.ws-mark { width: 32px; height: 32px; border-radius: var(--r-sm); background: var(--sky); color: var(--ink); display: grid; place-items: center; font-weight: 700; font-size: 15px; flex: none; overflow: hidden; }
.ws-mark img { width: 100%; height: 100%; object-fit: contain; background: #fff; padding: 2px; }
.ws-switch .nm { flex: 1; min-width: 0; font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-search { margin: 0 8px 8px; position: relative; }
.side-search input { width: 100%; border: 1px solid rgba(255, 255, 255, .14); border-radius: var(--r-sm); padding: 8px 12px 8px 32px; background: rgba(255, 255, 255, .08); color: var(--on-dark); font-size: 14px; }
.side-search input::placeholder { color: var(--on-dark-muted); }
.side-search::before { content: "⌕"; position: absolute; left: 11px; top: 6px; color: var(--on-dark-muted); font-size: 16px; }
.side-section { padding: 8px 0 4px; }
.side-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 16px; color: var(--on-dark-muted); font-size: 13px; font-weight: 500; }
.side-head button { background: none; border: 0; color: var(--on-dark-muted); font-size: 18px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.side-head button:hover { color: var(--on-dark); background: var(--ink-hover); }
.side-item { display: flex; align-items: center; gap: 8px; padding: 6px 12px; margin: 1px 8px; border-radius: var(--r-sm); color: var(--on-dark-muted); text-decoration: none; cursor: pointer; border: 0; background: none; width: calc(100% - 16px); text-align: left; font-size: 15px; line-height: 20px; }
.side-item:hover { background: var(--ink-hover); color: var(--on-dark); }
.side-item.active { background: var(--ink-active); color: var(--on-dark); }
.side-item.nav.active { background: var(--action); color: var(--on-action); }
.side-item.unread { font-weight: 700; color: var(--on-dark); }
.side-item .ic { width: 20px; text-align: center; flex: none; }
.side-item .label { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.badge { background: var(--sky); color: var(--ink); border-radius: 10px; font-size: 12px; font-weight: 700; padding: 0 8px; min-width: 20px; text-align: center; line-height: 20px; }
.side-me { border-top: 1px solid rgba(255, 255, 255, .1); padding: 8px; }
.side-me .side-item { margin: 0; width: 100%; }

.main { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.pane { width: var(--pane-w); display: flex; flex-direction: column; min-height: 0; background: var(--bg); border-left: 1px solid var(--line); }
.pane.closed { display: none; }
.head { display: flex; align-items: center; gap: 8px; padding: 0 16px; min-height: 56px; border-bottom: 1px solid var(--line); flex: none; background: var(--bg); }
.head h2 { margin: 0; font-size: 18px; line-height: 24px; display: flex; align-items: center; gap: 4px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.head .topic { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; cursor: pointer; }
.head .topic:hover { color: var(--fg); }
.head .spacer { flex: 1; }
.icon-btn.back-btn { display: none; }
.icon-btn { background: none; border: 1px solid transparent; border-radius: var(--r-sm); padding: 6px 8px; display: inline-flex; align-items: center; gap: 4px; color: var(--muted); font-size: 14px; min-height: 32px; }
.icon-btn:hover { background: var(--hover); color: var(--fg); }
.huddle-btn { border: 1px solid var(--line); border-radius: var(--r-sm); padding: 6px 12px; background: var(--surface); color: var(--fg); font-weight: 500; font-size: 14px; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; }
.huddle-btn:hover { background: var(--hover); }
.huddle-btn.live { background: var(--success); color: #fff; border-color: var(--success); }

/* ---------- messages ---------- */
.messages { flex: 1; overflow-y: auto; padding: 8px 0 16px; min-height: 0; overscroll-behavior: contain; }
.load-more { display: block; margin: 8px auto; }
.day { display: flex; align-items: center; gap: 8px; margin: 16px 16px 8px; color: var(--muted); font-size: 13px; font-weight: 500; }
.day::before, .day::after { content: ""; flex: 1; border-top: 1px solid var(--line); }
.new-line { display: flex; align-items: center; gap: 8px; margin: 8px 16px; color: var(--action); font-size: 12px; font-weight: 700; }
.new-line::before { content: ""; flex: 1; border-top: 1px solid var(--action); }
.msg { display: grid; grid-template-columns: 40px minmax(0, 1fr); gap: 0 12px; padding: 8px 16px; position: relative; }
.msg:hover { background: var(--hover); }
.msg.compact { padding-top: 2px; padding-bottom: 2px; }
.msg.compact .avatar { visibility: hidden; height: 0; }
.msg.compact .meta { display: none; }
.msg.pinned { background: var(--pin); }
.msg.highlight { animation: flash 2s ease-out; }
@keyframes flash { from { background: var(--mention-bg); } to { background: transparent; } }
.msg.system { color: var(--muted); font-size: 14px; padding-top: 4px; padding-bottom: 4px; }
.avatar { width: 40px; height: 40px; border-radius: var(--r-sm); display: grid; place-items: center; color: #fff; font-weight: 600; font-size: 15px; flex: none; position: relative; }
.avatar.sm { width: 20px; height: 20px; font-size: 10px; border-radius: 6px; }
.avatar.md { width: 28px; height: 28px; font-size: 12px; border-radius: 6px; }
.pres { position: absolute; right: -3px; bottom: -3px; width: 11px; height: 11px; border-radius: 50%; border: 2px solid var(--ink); background: transparent; }
.pres.active { background: #2FB37A; }
.pres.away { background: var(--ink); box-shadow: inset 0 0 0 1.5px var(--on-dark-muted); }
.main .pres, .pane .pres, .modal .pres { border-color: var(--bg); }
.meta { display: flex; align-items: baseline; gap: 8px; flex-wrap: wrap; }
.meta .name { font-weight: 600; font-size: 15px; }
.meta .time, .meta .edited { color: var(--muted); font-size: 12px; }
.meta .tag { font-size: 11px; background: var(--canvas); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; color: var(--muted); font-weight: 500; }
.body { line-height: 24px; overflow-wrap: anywhere; }
.body pre { background: var(--canvas); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 12px; overflow-x: auto; margin: 4px 0; white-space: pre-wrap; font-size: 14px; line-height: 20px; }
.body code { background: var(--canvas); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; font-size: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.body pre code { border: 0; padding: 0; background: none; }
.mention { background: var(--mention-bg); color: var(--fg); border-radius: 4px; padding: 0 2px; font-weight: 600; }
.mention.me { background: var(--mention-me-bg); color: var(--ink); }
@media (prefers-color-scheme: dark) { .mention.me { color: #fff; } }
.deleted { color: var(--muted); font-style: italic; }
.attach { margin-top: 8px; }
.attach img { max-width: min(360px, 100%); max-height: 280px; border-radius: var(--r-sm); border: 1px solid var(--line); display: block; cursor: zoom-in; }
.file-card { display: inline-flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px 12px; text-decoration: none; color: var(--fg); background: var(--surface); max-width: 100%; }
.file-card .fn { font-weight: 500; overflow-wrap: anywhere; }
.file-card .fs { color: var(--muted); font-size: 13px; }
.clip { border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px; display: inline-block; max-width: 420px; width: 100%; background: var(--canvas); }
.clip video { width: 100%; border-radius: var(--r-sm); background: #000; display: block; max-height: 280px; }
.clip audio { width: 100%; }
.clip .clip-bar { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); margin-top: 8px; flex-wrap: wrap; }
.clip select { padding: 2px 4px; border-radius: 6px; border: 1px solid var(--line); }
.reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.react { border: 1px solid var(--line); background: var(--surface); border-radius: 12px; padding: 0 8px; font-size: 13px; line-height: 24px; display: inline-flex; gap: 4px; align-items: center; min-height: 26px; }
.react.mine { border-color: var(--action); background: var(--action-soft); }
.react.add { color: var(--muted); }
.thread-link { display: flex; align-items: center; gap: 6px; margin-top: 4px; font-size: 13px; color: var(--link); font-weight: 600; background: none; border: 1px solid transparent; border-radius: var(--r-sm); padding: 2px 4px; margin-left: -4px; }
.thread-link:hover { border-color: var(--line); background: var(--surface); }
.thread-link .last { color: var(--muted); font-weight: 400; }
.huddle-card { display: flex; align-items: center; gap: 12px; border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; margin-top: 2px; background: var(--canvas); max-width: 460px; flex-wrap: wrap; }
.huddle-card .t { font-weight: 600; }
.huddle-card .s { color: var(--muted); font-size: 13px; }
.stack { display: flex; }
.stack .avatar { margin-left: -4px; border: 2px solid var(--bg); }
.stack .avatar:first-child { margin-left: 0; }
.actions { position: absolute; right: 16px; top: -16px; display: none; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); box-shadow: 0 2px 8px rgba(23, 43, 77, .1); padding: 2px; z-index: 2; }
.msg:hover .actions, .actions.open { display: flex; }
.actions button { background: none; border: 0; border-radius: 6px; padding: 4px 8px; font-size: 15px; min-width: 32px; min-height: 32px; }
.actions button:hover { background: var(--hover); }

/* ---------- composer ---------- */
.composer-wrap { padding: 0 16px 16px; flex: none; }
.composer { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); position: relative; }
.composer:focus-within { border-color: var(--action); box-shadow: 0 0 0 3px var(--action-soft); }
.composer textarea { width: 100%; border: 0; resize: none; padding: 12px 12px 4px; outline: none; max-height: 240px; min-height: 44px; background: transparent; line-height: 24px; font-size: 16px; }
.composer .bar { display: flex; align-items: center; gap: 2px; padding: 4px 8px 8px; }
.composer .bar .spacer { flex: 1; }
.composer .send { background: var(--action); color: var(--on-action); border: 0; border-radius: var(--r-sm); padding: 6px 16px; font-weight: 600; font-size: 14px; min-height: 32px; }
.composer .send:hover { background: var(--action-hover); }
.composer .send:disabled { opacity: .4; cursor: default; }
.composer .also { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; padding: 0 12px 4px; }
.composer .kbd-hint { font-size: 12px; color: var(--muted); margin-right: 8px; }
.pending-file { margin: 8px 12px 0; display: inline-flex; gap: 8px; align-items: center; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 4px 8px; font-size: 13px; }
.readonly-note { border: 1px solid var(--line); background: var(--canvas); border-radius: var(--r-md); padding: 16px; color: var(--muted); text-align: center; font-size: 14px; }
.typing { height: 20px; font-size: 12px; color: var(--muted); padding: 2px 4px; }
.archived-banner { background: var(--canvas); border: 1px solid var(--line); border-radius: var(--r-md); padding: 16px; text-align: center; display: grid; gap: 8px; justify-items: center; font-size: 14px; }

.popup { position: absolute; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow); z-index: 50; }
.mention-pop { bottom: 100%; left: 8px; margin-bottom: 8px; min-width: 280px; max-width: calc(100vw - 32px); max-height: 260px; overflow-y: auto; padding: 4px; }
.mention-pop .opt { display: flex; gap: 8px; align-items: center; padding: 8px; border-radius: var(--r-sm); cursor: pointer; }
.mention-pop .opt.sel, .mention-pop .opt:hover { background: var(--action); color: var(--on-action); }
.mention-pop .opt .sub { opacity: .8; font-size: 13px; }
.emoji-pop { width: min(320px, calc(100vw - 16px)); padding: 8px; position: fixed; }
.emoji-pop input { width: 100%; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px; margin-bottom: 8px; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; max-height: 232px; overflow-y: auto; }
.emoji-grid button { background: none; border: 0; font-size: 22px; padding: 4px; border-radius: 6px; min-height: 36px; }
.emoji-grid button:hover { background: var(--hover); }

/* ---------- lists & pages ---------- */
.list-view { flex: 1; overflow-y: auto; padding: 8px 0; }
.list-row { display: flex; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); cursor: pointer; align-items: flex-start; }
.list-row:hover { background: var(--hover); }
.list-row.unread { background: var(--action-soft); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .sub { color: var(--muted); font-size: 13px; }
.list-row .prev { overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.empty { color: var(--muted); padding: 40px 24px; text-align: center; }
.thread-card { border: 1px solid var(--line); border-radius: var(--r-md); margin: 12px 16px; overflow: hidden; background: var(--bg); }
.thread-card .tc-head { padding: 8px 12px; background: var(--canvas); font-size: 13px; color: var(--muted); display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; align-items: center; }
.section-title { padding: 8px 16px; color: var(--muted); font-size: 13px; font-weight: 500; }
.page { flex: 1; overflow-y: auto; padding: 24px; }
.page h3 { margin: 24px 0 8px; font-size: 20px; line-height: 28px; }
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); padding: 0 16px; flex: none; overflow-x: auto; }
.tabs button { background: none; border: 0; border-bottom: 2px solid transparent; padding: 12px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.tabs button.on { color: var(--fg); border-bottom-color: var(--action); }
.form-grid { display: grid; gap: 16px; max-width: 560px; }
.table-wrap { overflow-x: auto; }
table.tbl { border-collapse: collapse; width: 100%; font-size: 14px; }
.tbl th, .tbl td { text-align: left; padding: 8px; border-bottom: 1px solid var(--line); vertical-align: middle; }
.tbl th { color: var(--muted); font-weight: 500; font-size: 13px; }
.code-box { font-family: ui-monospace, Menlo, monospace; font-size: 12px; background: var(--canvas); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 8px; overflow-x: auto; white-space: pre; }

/* ---------- branding settings ---------- */
.brand-grid { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 24px; max-width: 920px; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch { width: 32px; height: 32px; border-radius: var(--r-sm); border: 2px solid var(--line); padding: 0; }
.swatch.on { outline: 2px solid var(--fg); outline-offset: 2px; }
.color-row { display: flex; gap: 8px; align-items: center; }
.color-row input[type=color] { width: 48px; height: 40px; border: 1px solid var(--line); border-radius: var(--r-sm); padding: 2px; background: var(--surface); }
.color-row input[type=text] { width: 120px; font-family: ui-monospace, Menlo, monospace; text-transform: uppercase; }
.contrast { font-size: 13px; line-height: 20px; display: grid; gap: 4px; }
.contrast .ok { color: var(--success); }
.contrast .warn { color: var(--warning); }
.preview { border: 1px solid var(--line); border-radius: var(--r-md); overflow: hidden; display: grid; grid-template-columns: 180px 1fr; min-height: 220px; background: var(--surface); }
.preview .pv-side { background: var(--ink); color: #fff; padding: 12px 8px; display: grid; align-content: start; gap: 4px; font-size: 13px; }
.preview .pv-side img.lk { height: 18px; margin: 0 4px 8px; }
.preview .pv-ws { display: flex; gap: 8px; align-items: center; padding: 6px; border-radius: var(--r-sm); background: rgba(255,255,255,.06); font-weight: 600; }
.preview .pv-ws .ws-mark { width: 24px; height: 24px; font-size: 12px; }
.preview .pv-item { padding: 4px 8px; border-radius: 6px; color: var(--on-dark-muted); }
.preview .pv-item.on { color: #fff; }
.preview .pv-main { padding: 16px; display: grid; gap: 12px; align-content: start; color: var(--ink); background: #fff; }
.preview .pv-main a { font-weight: 600; }
.logo-drop { border: 1px dashed var(--line); border-radius: var(--r-md); padding: 16px; display: flex; gap: 16px; align-items: center; flex-wrap: wrap; }
.logo-drop .ws-mark { width: 56px; height: 56px; font-size: 22px; }

/* ---------- modals & toasts ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(15, 26, 47, .5); display: grid; place-items: center; z-index: 100; padding: 16px; }
.modal { background: var(--bg); border-radius: var(--r-md); width: 100%; max-width: 520px; max-height: 90vh; max-height: 90dvh; overflow-y: auto; box-shadow: var(--shadow); }
.modal.wide { max-width: 760px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 24px 8px; gap: 8px; }
.modal-head h3 { margin: 0; font-size: 20px; line-height: 28px; }
.modal-body { padding: 8px 24px 16px; display: grid; gap: 16px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 24px 24px; flex-wrap: wrap; }
.user-pick { max-height: 260px; overflow-y: auto; border: 1px solid var(--line); border-radius: var(--r-sm); }
.user-pick label { display: flex; gap: 8px; align-items: center; padding: 8px 12px; cursor: pointer; }
.user-pick label:hover { background: var(--hover); }
.switch-row { display: flex; gap: 8px; align-items: center; font-size: 14px; }
.guidelines { line-height: 24px; }
#toasts { position: fixed; right: 16px; top: 16px; display: grid; gap: 8px; z-index: 200; max-width: calc(100vw - 32px); }
.toast { background: var(--ink); color: #fff; padding: 12px 16px; border-radius: var(--r-sm); box-shadow: var(--shadow); max-width: 380px; font-size: 14px; display: flex; gap: 12px; align-items: center; }
.toast button { background: var(--sky); color: var(--ink); border: 0; border-radius: 6px; padding: 4px 12px; font-weight: 600; white-space: nowrap; }
.install-card { display: flex; gap: 12px; align-items: center; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--canvas); }
.install-card img { width: 40px; height: 40px; }

/* ---------- huddle dock ---------- */
.huddle-dock { position: fixed; left: 12px; bottom: 12px; width: 248px; background: var(--ink); color: #fff; border-radius: var(--r-md); box-shadow: var(--shadow); z-index: 60; overflow: hidden; }
.huddle-dock.big { left: 50%; top: 50%; bottom: auto; transform: translate(-50%, -50%); width: min(960px, calc(100vw - 32px)); }
.hd-top { display: flex; align-items: center; gap: 8px; padding: 12px; font-weight: 600; font-size: 14px; }
.hd-top .grow { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hd-top button { background: none; border: 0; color: #fff; padding: 4px 8px; border-radius: 6px; }
.hd-top button:hover { background: var(--ink-hover); }
.hd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 8px; padding: 0 12px 8px; }
.huddle-dock.big .hd-grid { grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); max-height: 70vh; overflow-y: auto; }
.tile { position: relative; background: var(--ink-active); border-radius: var(--r-sm); aspect-ratio: 16 / 10; display: grid; place-items: center; overflow: hidden; }
.tile video { width: 100%; height: 100%; object-fit: cover; }
.tile.screen video { object-fit: contain; background: #000; }
.tile .nm { position: absolute; left: 6px; bottom: 4px; font-size: 11px; background: rgba(0, 0, 0, .55); padding: 1px 6px; border-radius: 4px; }
.tile.speaking { outline: 2px solid var(--sky); }
.hd-controls { display: flex; justify-content: space-between; gap: 4px; padding: 8px 12px 12px; border-top: 1px solid rgba(255, 255, 255, .1); }
.hd-controls button { flex: 1; background: rgba(255, 255, 255, .1); border: 0; color: #fff; border-radius: var(--r-sm); padding: 8px 0; font-size: 16px; min-height: 40px; }
.hd-controls button.off, .hd-controls button.leave { background: var(--danger); }
.hd-controls button.on { background: var(--success); }
.media-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* ---------- clip recorder ---------- */
.rec-preview { background: #000; border-radius: var(--r-sm); width: 100%; aspect-ratio: 16/9; display: grid; place-items: center; color: #aaa; overflow: hidden; }
.rec-preview video { width: 100%; height: 100%; object-fit: contain; }
.rec-kinds { display: flex; gap: 8px; flex-wrap: wrap; }
.rec-kinds button { flex: 1; }
.rec-kinds button.on { background: var(--action); color: var(--on-action); border-color: var(--action); }
.rec-timer { font-variant-numeric: tabular-nums; font-weight: 600; }
.rec-dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .2; } }

/* ---------- phones: one screen at a time + bottom tabs ---------- */
.tabbar { display: none; }
@media (max-width: 760px) {
  :root { --tabbar-h: calc(56px + env(safe-area-inset-bottom)); }
  .shell { grid-template-columns: 1fr; height: 100dvh; padding-bottom: var(--tabbar-h); }
  .shell > .sidebar, .shell > .main, .shell > .pane { grid-column: 1; grid-row: 1; width: auto; border: 0; }
  .shell.m-home > .main, .shell.m-home > .pane, .shell.m-main > .sidebar, .shell.m-main > .pane, .shell.m-pane > .sidebar, .shell.m-pane > .main { display: none; }
  .shell.m-pane > .pane { display: flex; }
  .sidebar { padding-top: env(safe-area-inset-top); }
  .head { padding-top: env(safe-area-inset-top); min-height: calc(56px + env(safe-area-inset-top)); padding-left: 8px; }
  .icon-btn.back-btn { display: inline-flex; font-size: 24px; padding: 4px 10px; }
  .head .topic { display: none; }
  .head .hide-m { display: none; }
  .side-item { font-size: 17px; padding: 10px 12px; }
  .msg { padding-left: 12px; padding-right: 12px; }
  .actions { right: 8px; top: auto; bottom: -12px; }
  .msg:hover .actions { display: none; }
  .msg .actions.open { display: flex; flex-wrap: wrap; max-width: calc(100vw - 24px); }
  .composer-wrap { padding: 0 8px 8px; }
  .composer .kbd-hint { display: none; }
  .composer .clip-label { display: none; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; height: var(--tabbar-h); padding-bottom: env(safe-area-inset-bottom); background: var(--bg); border-top: 1px solid var(--line); z-index: 70; }
  .tabbar button { flex: 1; background: none; border: 0; display: grid; place-items: center; gap: 0; font-size: 11px; font-weight: 500; color: var(--muted); padding: 6px 0; position: relative; }
  .tabbar button .ti { font-size: 20px; line-height: 24px; }
  .tabbar button.on { color: var(--action); }
  @media (prefers-color-scheme: dark) { .tabbar button.on { color: var(--action-on-dark); } }
  .tabbar .badge { position: absolute; top: 4px; left: calc(50% + 6px); font-size: 10px; line-height: 16px; padding: 0 5px; min-width: 16px; }
  .huddle-dock { left: 8px; right: 8px; width: auto; bottom: calc(var(--tabbar-h) + 8px); }
  .huddle-dock.big { top: auto; transform: none; left: 8px; bottom: calc(var(--tabbar-h) + 8px); width: auto; }
  .page { padding: 16px; }
  .brand-grid { grid-template-columns: 1fr; }
  .preview { grid-template-columns: 120px 1fr; }
  #toasts { top: auto; bottom: calc(var(--tabbar-h) + 8px); right: 8px; left: 8px; }
  .modal-back { align-items: end; padding: 0; }
  .modal { max-width: none !important; border-radius: var(--r-md) var(--r-md) 0 0; padding-bottom: env(safe-area-inset-bottom); }
  .attach img { max-width: 100%; }
}
@media (hover: none) {
  .msg:hover { background: transparent; }
  .msg:hover .actions { display: none; }
  .msg .actions.open { display: flex; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
/* topic fills the header on desktop; on phones the spacer does */
.head .topic ~ .spacer { display: none; }
@media (max-width: 760px) { .head .topic ~ .spacer { display: block; } }
