/* ---------- tokens ---------- */
:root {
  color-scheme: light;
  --bg: #ffffff;
  --sidebar: #f9f9f9;
  --surface: #ffffff;
  --surface-2: #f4f4f4;
  --surface-3: #ececec;
  --hover: rgb(0 0 0 / .05);
  --border: #e5e5e5;
  --border-strong: #d0d0d0;
  --text: #0d0d0d;
  --text-2: #5d5d5d;
  --text-3: #8f8f8f;
  --accent: #0f6b62;
  --accent-soft: #e3f1ee;
  --accent-text: #ffffff;
  --ink: #0d0d0d;
  --ink-text: #ffffff;
  --danger: #c4291c;
  --danger-soft: #fdecea;
  --warn: #8a5a00;
  --warn-soft: #fff6dc;
  --ok: #18794e;
  --code-bg: #f7f7f7;
  --code-head: #ececec;
  --shadow: 0 8px 28px rgb(0 0 0 / .12), 0 1px 3px rgb(0 0 0 / .08);
  --focus: #0f6b62;
  --sidebar-w: 260px;
  --col: 48rem;
  --radius: 12px;
  --font: ui-sans-serif, -apple-system, system-ui, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC", "Source Han Sans SC", sans-serif;
  --mono: ui-monospace, "SFMono-Regular", "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --bg: #212121; --sidebar: #171717; --surface: #2a2a2a; --surface-2: #303030; --surface-3: #3a3a3a;
    --hover: rgb(255 255 255 / .07); --border: #3a3a3a; --border-strong: #4a4a4a;
    --text: #ececec; --text-2: #b4b4b4; --text-3: #8a8a8a;
    --accent: #5cc4b5; --accent-soft: #1e3532; --accent-text: #0b1a18; --ink: #ececec; --ink-text: #171717;
    --danger: #f28b82; --danger-soft: #3b2120; --warn: #f0c96a; --warn-soft: #362f1a; --ok: #6fcf97;
    --code-bg: #171717; --code-head: #2a2a2a; --shadow: 0 8px 28px rgb(0 0 0 / .5), 0 0 0 1px rgb(255 255 255 / .06);
    --focus: #5cc4b5;
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #212121; --sidebar: #171717; --surface: #2a2a2a; --surface-2: #303030; --surface-3: #3a3a3a;
  --hover: rgb(255 255 255 / .07); --border: #3a3a3a; --border-strong: #4a4a4a;
  --text: #ececec; --text-2: #b4b4b4; --text-3: #8a8a8a;
  --accent: #5cc4b5; --accent-soft: #1e3532; --accent-text: #0b1a18; --ink: #ececec; --ink-text: #171717;
  --danger: #f28b82; --danger-soft: #3b2120; --warn: #f0c96a; --warn-soft: #362f1a; --ok: #6fcf97;
  --code-bg: #171717; --code-head: #2a2a2a; --shadow: 0 8px 28px rgb(0 0 0 / .5), 0 0 0 1px rgb(255 255 255 / .06);
  --focus: #5cc4b5;
}

/* ---------- base ---------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 16px/1.65 var(--font); -webkit-text-size-adjust: 100%; overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { -webkit-tap-highlight-color: transparent; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }
.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.ico { fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; flex-shrink: 0; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: 40px; padding: 0 16px; border-radius: 999px; border: 1px solid transparent;
  cursor: pointer; font-weight: 500; font-size: 15px; white-space: nowrap; background: var(--surface-2);
}
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--ink); color: var(--ink-text); }
.btn-primary:hover:not(:disabled) { opacity: .85; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-ghost { background: transparent; border-color: var(--border-strong); }
.btn-ghost:hover:not(:disabled) { background: var(--hover); }
.btn-sm { min-height: 32px; padding: 0 12px; font-size: 14px; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 10px;
  border: 0; background: transparent; cursor: pointer; color: var(--text-2); padding: 0;
}
.icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--text); }
.icon-btn:disabled { opacity: .4; cursor: default; }
.icon-btn.round { border-radius: 999px; }
.link-btn { border: 0; background: none; color: var(--text-2); font-size: 13px; cursor: pointer; padding: 4px 6px; border-radius: 6px; }
.link-btn:hover { color: var(--text); background: var(--hover); }

/* ---------- boot / login ---------- */
.boot { display: grid; place-items: center; height: 100%; color: var(--text-2); padding: 16px; text-align: center; }
.login { display: grid; place-items: center; height: 100%; padding: 16px; overflow-y: auto; }
.login-card { width: 100%; max-width: 360px; text-align: left; }
.login-logo { display: block; margin: 0 0 16px; border-radius: 10px; }
.login-title { margin: 0 0 4px; font-size: 24px; font-weight: 600; }
.login-hint { margin: 0 0 24px; color: var(--text-2); font-size: 15px; }
.field-label { display: block; font-size: 14px; font-weight: 500; margin-bottom: 6px; }
.login-card input {
  width: 100%; min-height: 48px; padding: 10px 14px; border-radius: 12px;
  border: 1px solid var(--border-strong); background: var(--bg); margin-bottom: 14px;
}
.login-card .btn { min-height: 48px; }
.form-error { color: var(--danger); font-size: 14px; margin: 0 0 12px; }

/* ---------- layout ---------- */
.app { display: flex; height: 100vh; }
@supports (height: 100dvh) { .app { height: 100dvh; } }

.sidebar {
  width: var(--sidebar-w); flex-shrink: 0; display: flex; flex-direction: column; min-height: 0;
  background: var(--sidebar); border-right: 1px solid var(--border); transition: margin-left .2s ease;
}
.sb-collapsed .sidebar { margin-left: calc(-1 * var(--sidebar-w)); visibility: hidden; }
.sb-head {
  display: flex; align-items: center; justify-content: space-between; padding: 8px;
  padding-top: max(8px, env(safe-area-inset-top));
}
.sb-actions { padding: 0 8px 8px; }
.sb-row {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 10px;
  border: 0; border-radius: 10px; background: transparent; cursor: pointer; text-align: left; font-size: 14px;
}
.sb-row:hover { background: var(--hover); }
.sb-search { position: relative; margin-top: 4px; }
.sb-search-icon { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: var(--text-3); display: grid; }
.sb-search-icon .ico { width: 18px; height: 18px; }
.sb-search input {
  width: 100%; min-height: 38px; padding: 0 10px 0 36px; border-radius: 10px; font-size: 14px;
  border: 1px solid transparent; background: var(--hover);
}
.sb-search input:focus { border-color: var(--border-strong); background: var(--bg); outline: none; }
.sb-search input:focus-visible { outline: 2px solid var(--focus); outline-offset: 0; }
.conv-nav { flex: 1; overflow-y: auto; padding: 0 8px 8px; overscroll-behavior: contain; }
.conv-empty { color: var(--text-3); font-size: 14px; padding: 8px 10px; margin: 0; }
.conv-group-title { margin: 14px 10px 4px; font-size: 12px; font-weight: 600; color: var(--text-3); }
.conv-list { list-style: none; margin: 0; padding: 0; }
.conv-li { position: relative; border-radius: 10px; }
.conv-li:hover, .conv-li:focus-within { background: var(--hover); }
.conv-li.current { background: var(--surface-3); }
.conv-item {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: 38px; padding: 0 40px 0 10px;
  border: 0; background: transparent; border-radius: 10px; text-align: left; cursor: pointer; font-size: 14px;
}
.conv-text { flex: 1; min-width: 0; display: flex; flex-direction: column; padding: 6px 0; }
.conv-title { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.conv-snippet { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; color: var(--text-2); }
.conv-running { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; animation: pulse 1.2s ease-in-out infinite; }
.conv-more {
  position: absolute; right: 2px; top: 50%; transform: translateY(-50%); width: 34px; height: 34px;
  opacity: 0;
}
.conv-li:hover .conv-more, .conv-li.current .conv-more, .conv-more:focus-visible, .conv-more[aria-expanded="true"] { opacity: 1; }
@media (hover: none) { .conv-more { opacity: 1; } }
.sb-foot { padding: 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); border-top: 1px solid var(--border); }

.chat { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.topbar {
  display: flex; align-items: center; gap: 4px; min-height: 52px; padding: 6px 8px;
  padding-top: max(6px, env(safe-area-inset-top)); background: var(--bg); position: relative; z-index: 2;
}
.menu-btn, .top-new { display: none; }
.sb-collapsed .menu-btn, .sb-collapsed .top-new { display: inline-grid; }
.topbar-spacer { flex: 1; }
.model-btn {
  display: inline-flex; align-items: center; gap: 6px; min-height: 40px; max-width: 100%; padding: 0 10px 0 12px;
  border: 0; border-radius: 10px; background: transparent; cursor: pointer; font-size: 17px; font-weight: 600;
  min-width: 0;
}
.model-btn:hover, .model-btn[aria-expanded="true"] { background: var(--hover); }
.model-btn-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-btn-effort { color: var(--text-2); font-weight: 500; font-size: 15px; white-space: nowrap; }
.model-btn-caret { display: grid; color: var(--text-3); }
.model-btn-caret .ico { width: 16px; height: 16px; }
.top-chip {
  display: inline-flex; align-items: center; gap: 6px; min-height: 36px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--bg); cursor: pointer; font-size: 14px; position: relative;
}
.top-chip:hover { background: var(--hover); }
.top-chip[aria-expanded="true"] { background: var(--surface-3); }
.top-chip .ico { width: 18px; height: 18px; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.dot.warn { background: var(--warn); animation: pulse 1.2s ease-in-out infinite; }

.banner { margin: 0 auto; max-width: var(--col); width: calc(100% - 32px); padding: 8px 14px; font-size: 14px; background: var(--warn-soft); color: var(--warn); border-radius: 10px; }
.banner[data-tone="error"] { background: var(--danger-soft); color: var(--danger); }

.scroller { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scroll-padding-bottom: 24px; }
.messages { max-width: var(--col); margin: 0 auto; padding: 16px 24px 32px; }

/* ---------- empty state ---------- */
.empty { padding: 22vh 8px 0; text-align: center; }
.empty-title { margin: 0 0 8px; font-size: 28px; font-weight: 600; letter-spacing: .01em; }
.empty-hint { margin: 0 auto; max-width: 30em; color: var(--text-2); font-size: 15px; }

/* ---------- messages ---------- */
.msg { margin: 0 0 28px; }
.msg-user { display: flex; flex-direction: column; align-items: flex-end; }
.bubble {
  max-width: min(80%, 36rem); background: var(--surface-2); border-radius: 20px; padding: 10px 16px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.user-attach { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: flex-start; gap: 8px; margin-bottom: 8px; max-width: 80%; }
.user-attach img { width: 160px; height: 160px; object-fit: cover; border-radius: 14px; border: 1px solid var(--border); display: block; }
.file-chip {
  display: inline-flex; align-items: center; gap: 8px; max-width: 260px; padding: 8px 12px; border-radius: 14px;
  border: 1px solid var(--border); background: var(--bg); font-size: 13px; color: var(--text); text-decoration: none;
}
.file-chip .ico { color: var(--text-2); }
.file-chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-chip-size { color: var(--text-3); flex-shrink: 0; }

.msg-assistant .msg-body { overflow-wrap: anywhere; }
.followup { display: flex; flex-direction: column; align-items: flex-end; margin: 14px 0; }
.followup.queued .bubble, .followup.undelivered .bubble { background: transparent; border: 1px dashed var(--border-strong); color: var(--text-2); }
.followup-note { margin-top: 4px; font-size: 12px; color: var(--text-3); display: flex; align-items: center; gap: 4px; }
.msg-actions { display: flex; align-items: center; gap: 2px; margin-top: 6px; min-height: 32px; flex-wrap: wrap; }
.msg-user .msg-actions { opacity: 0; transition: opacity .15s; }
.msg-user:hover .msg-actions, .msg-user:focus-within .msg-actions { opacity: 1; }
@media (hover: none) { .msg-user .msg-actions { opacity: 1; } }
.act { width: 32px; height: 32px; border-radius: 8px; }
.act .ico { width: 18px; height: 18px; }
.branch-nav { display: inline-flex; align-items: center; font-size: 13px; color: var(--text-2); font-variant-numeric: tabular-nums; }
.branch-nav .act { width: 28px; }
.model-badge { font-size: 12px; color: var(--text-3); margin-left: 6px; white-space: nowrap; }
.model-badge.mismatch { color: var(--warn); font-weight: 600; }

.edit-box { width: min(100%, 36rem); background: var(--surface-2); border-radius: 20px; padding: 12px; }
.edit-box textarea {
  width: 100%; min-height: 60px; max-height: 50vh; resize: none; border: 0; background: transparent; padding: 4px;
  line-height: 1.6; outline: none;
}
.edit-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 6px; }
.edit-note { font-size: 12px; color: var(--text-3); margin: 0 auto 0 4px; align-self: center; }

/* markdown */
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p, .md ul, .md ol, .md blockquote, .md .code-block, .md .table-wrap { margin: 0 0 14px; }
.md ul, .md ol { padding-left: 1.5em; }
.md li + li { margin-top: 4px; }
.md h3, .md h4, .md h5, .md h6 { margin: 22px 0 10px; line-height: 1.35; font-weight: 600; }
.md h3 { font-size: 20px; }
.md h4 { font-size: 17px; }
.md h5, .md h6 { font-size: 16px; }
.md a { color: var(--accent); text-underline-offset: 2px; }
.md hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.md blockquote { padding-left: 14px; border-left: 3px solid var(--border-strong); color: var(--text-2); }
.md code { font-family: var(--mono); font-size: .875em; background: var(--surface-2); border-radius: 5px; padding: .12em .4em; }
.code-block { border-radius: var(--radius); overflow: hidden; background: var(--code-bg); border: 1px solid var(--border); }
.code-bar {
  display: flex; align-items: center; justify-content: space-between; padding: 0 6px 0 14px; min-height: 36px;
  font-size: 12px; color: var(--text-2); background: var(--code-head);
}
.code-copy { display: inline-flex; align-items: center; gap: 4px; border: 0; background: transparent; cursor: pointer; font-size: 12px; color: var(--text-2); padding: 6px 8px; border-radius: 6px; }
.code-copy:hover { background: var(--hover); color: var(--text); }
.code-block pre { margin: 0; padding: 12px 14px; overflow-x: auto; }
.code-block code { background: none; padding: 0; font-size: 13.5px; line-height: 1.55; white-space: pre; }
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: 10px; }
.md table { border-collapse: collapse; font-size: 14px; min-width: 100%; }
.md th, .md td { border-bottom: 1px solid var(--border); padding: 8px 12px; text-align: left; vertical-align: top; }
.md tr:last-child td { border-bottom: 0; }
.md th { background: var(--surface-2); font-weight: 600; }

/* tool activity */
.activity { margin: 4px 0 14px; }
.activity > summary {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; font-size: 14px;
  color: var(--text-2); padding: 4px 8px 4px 4px; border-radius: 8px; max-width: 100%;
}
.activity > summary::-webkit-details-marker { display: none; }
.activity > summary:hover { background: var(--hover); color: var(--text); }
.activity > summary .ico { width: 16px; height: 16px; }
.activity-text { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.activity[open] > summary .chev { transform: rotate(180deg); }
.activity.running .activity-text { background: linear-gradient(90deg, var(--text-2) 0%, var(--text-3) 50%, var(--text-2) 100%); background-size: 200% 100%; -webkit-background-clip: text; background-clip: text; color: transparent; animation: shimmer 1.8s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.tool-list { list-style: none; margin: 6px 0 0 10px; padding: 0 0 0 14px; border-left: 2px solid var(--border); }
.tool-li { margin: 0 0 8px; font-size: 13px; }
.tool-row { display: flex; align-items: baseline; gap: 8px; }
.tool-label { flex-shrink: 0; font-weight: 600; }
.tool-summary { flex: 1; min-width: 0; color: var(--text-2); font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-state { flex-shrink: 0; color: var(--text-3); font-size: 12px; }
.tool-error .tool-state { color: var(--danger); }
.tool-running .tool-state { color: var(--accent); }
.tool-detail {
  margin: 6px 0 0; padding: 8px 10px; max-height: 200px; overflow: auto; border-radius: 8px;
  background: var(--code-bg); border: 1px solid var(--border); font: 12px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
}
.tool-more { border: 0; background: none; color: var(--text-3); font-size: 12px; cursor: pointer; padding: 0 4px; }
.tool-more:hover { color: var(--text); }

/* approval */
.approval { margin: 12px 0; padding: 14px; border-radius: 16px; border: 1px solid var(--border-strong); background: var(--surface); }
.approval-pending { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.approval-head { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-weight: 600; font-size: 15px; }
.approval-head .ico { color: var(--accent); }
.approval-summary { margin: 0 0 8px; color: var(--text-2); font-size: 14px; }
.approval-detail {
  margin: 0 0 12px; padding: 10px 12px; max-height: 260px; overflow: auto; border-radius: 10px;
  background: var(--code-bg); border: 1px solid var(--border); font: 12.5px/1.5 var(--mono); white-space: pre-wrap; overflow-wrap: anywhere;
}
.approval-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.approval-state { margin: 0; font-size: 13px; color: var(--text-2); }

.notice { margin: 10px 0; padding: 10px 12px; border-radius: 10px; background: var(--warn-soft); color: var(--warn); font-size: 14px; }

.compact-note { margin: 10px 0; display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--text-2); }
.compact-note.running span { animation: blink 1.2s infinite ease-in-out; }
.compact-note.failed { color: var(--danger); }
.status-actions { display: flex; align-items: flex-start; gap: 12px; margin-top: 12px; }
.status-actions .sheet-muted { flex: 1; margin: 0; }
.status-actions .btn { flex: none; }
@media (prefers-reduced-motion: reduce) { .compact-note.running span { animation: none; } }

.approval-reason { margin: 4px 0 8px; font-size: 13px; color: var(--text-2); }

.msg-status { margin: 8px 0 0; font-size: 14px; color: var(--text-2); display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.status-error { color: var(--danger); }
.status-interrupted, .status-stopped { color: var(--text-2); }
.thinking { display: inline-flex; gap: 4px; align-items: center; height: 24px; }
.thinking i { width: 7px; height: 7px; border-radius: 50%; background: var(--text-2); animation: blink 1.2s infinite ease-in-out; }
.thinking i:nth-child(2) { animation-delay: .15s; }
.thinking i:nth-child(3) { animation-delay: .3s; }
@keyframes blink { 0%, 80%, 100% { opacity: .2; } 40% { opacity: 1; } }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------- composer ---------- */
.composer-wrap { position: relative; padding: 0 16px; padding-bottom: max(8px, env(safe-area-inset-bottom)); background: var(--bg); }
.composer {
  max-width: var(--col); margin: 0 auto; background: var(--surface); border: 1px solid var(--border-strong);
  border-radius: 26px; padding: 8px 8px 8px 12px; box-shadow: 0 2px 10px rgb(0 0 0 / .04);
  display: flex; flex-direction: column; cursor: text;
}
.composer:focus-within { border-color: var(--text-3); }
.composer.dragover { border-color: var(--accent); background: var(--accent-soft); }
.composer textarea {
  width: 100%; min-height: 28px; max-height: 40vh; resize: none; padding: 6px 4px; border: 0; background: transparent;
  line-height: 1.55; outline: none; font-size: 16px;
}
.composer-bar { display: flex; align-items: center; gap: 4px; margin-left: -4px; }
.composer-spacer { flex: 1; }
.composer-model { font-size: 12px; color: var(--text-3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.send-btn {
  display: inline-grid; place-items: center; width: 36px; height: 36px; border-radius: 999px; border: 0;
  background: var(--ink); color: var(--ink-text); cursor: pointer; flex-shrink: 0;
}
.send-btn:disabled { background: var(--surface-3); color: var(--text-3); cursor: default; }
.send-btn .ico { stroke-width: 2.3; }
.send-btn.stop .ico { fill: currentColor; }
.composer-hint { max-width: var(--col); margin: 6px auto 0; text-align: center; font-size: 12px; color: var(--text-3); }
.composer-error { max-width: var(--col); margin: 6px auto 0; color: var(--danger); font-size: 14px; text-align: center; }
.jump {
  position: absolute; left: 50%; top: -48px; transform: translateX(-50%); width: 36px; height: 36px; border-radius: 999px;
  border: 1px solid var(--border-strong); background: var(--bg); box-shadow: var(--shadow); cursor: pointer;
  display: grid; place-items: center; color: var(--text); z-index: 3;
}
.attach-list { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0 8px; }
.att {
  position: relative; flex-shrink: 0; display: flex; align-items: center; gap: 8px; height: 56px; padding: 0 30px 0 8px;
  border-radius: 14px; border: 1px solid var(--border); background: var(--bg); max-width: 220px; font-size: 13px;
}
.att.image { width: 56px; padding: 0; overflow: hidden; }
.att.image img { width: 100%; height: 100%; object-fit: cover; }
.att-icon { display: grid; place-items: center; width: 36px; height: 36px; border-radius: 8px; background: var(--accent); color: #fff; flex-shrink: 0; }
.att-meta { min-width: 0; line-height: 1.3; }
.att-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.att-sub { color: var(--text-3); font-size: 12px; }
.att.error { border-color: var(--danger); }
.att.error .att-sub { color: var(--danger); }
.att-x {
  position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; border-radius: 999px; border: 0;
  background: var(--ink); color: var(--ink-text); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.att-x .ico { width: 14px; height: 14px; stroke-width: 2.5; }
.att-progress { position: absolute; inset: 0; display: grid; place-items: center; background: rgb(0 0 0 / .35); color: #fff; font-size: 12px; }

/* ---------- popovers & dialogs ---------- */
.popover {
  position: fixed; z-index: 40; background: var(--surface); color: var(--text); border-radius: 16px;
  box-shadow: var(--shadow); border: 1px solid var(--border); padding: 8px;
}
.pop-scrim { position: fixed; inset: 0; z-index: 39; }
.model-pop { width: 340px; max-height: min(80vh, 640px); overflow-y: auto; }
.pop-head { display: flex; align-items: center; justify-content: space-between; padding: 6px 8px 4px 10px; }
.pop-title { margin: 0; font-size: 13px; font-weight: 600; color: var(--text-2); }
.pop-sub { font-size: 13px; font-weight: 600; color: var(--text-2); }
.model-opt {
  display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px 10px; border: 0; border-radius: 10px;
  background: transparent; cursor: pointer; text-align: left;
}
.model-opt:hover { background: var(--hover); }
.model-opt[aria-checked="true"] { background: var(--surface-2); }
.model-opt-text { flex: 1; min-width: 0; }
.model-opt-name { display: block; font-size: 15px; font-weight: 500; }
.model-opt-desc { display: block; font-size: 12.5px; color: var(--text-2); line-height: 1.4; }
.model-opt-check { width: 20px; color: var(--text); visibility: hidden; }
.model-opt[aria-checked="true"] .model-opt-check { visibility: visible; }
.model-more {
  display: flex; align-items: center; justify-content: space-between; width: 100%; padding: 8px 10px; margin-top: 2px;
  border: 0; border-top: 1px solid var(--border); background: none; color: var(--text-2); font-size: 13px; cursor: pointer;
}
.model-more:hover { color: var(--text); }
.model-more[aria-expanded="true"] .ico { transform: rotate(180deg); }
.model-more .ico { width: 16px; height: 16px; }
.effort-box { border-top: 1px solid var(--border); margin-top: 4px; padding: 10px 10px 6px; }
.effort-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 8px; }
.effort-hint { font-size: 12px; color: var(--text-3); text-align: right; }
.seg { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; gap: 2px; background: var(--surface-2); border-radius: 10px; padding: 3px; }
.seg button {
  min-height: 34px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; font-size: 13px; color: var(--text-2); padding: 0 4px;
}
.seg button[aria-checked="true"] { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: 0 1px 2px rgb(0 0 0 / .12); }
.seg button:disabled { opacity: .4; cursor: default; }
.model-timing { margin: 8px 10px 4px; font-size: 13px; color: var(--accent); }
.menu-pop { min-width: 180px; }
.menu-item {
  display: flex; align-items: center; gap: 10px; width: 100%; min-height: 40px; padding: 0 12px; border: 0;
  border-radius: 10px; background: none; cursor: pointer; font-size: 14px; text-align: left;
}
.menu-item:hover, .menu-item:focus-visible { background: var(--hover); }
.menu-item.danger { color: var(--danger); }
.menu-item .ico { width: 18px; height: 18px; }

.dialog {
  border: 0; border-radius: 18px; padding: 20px; width: min(420px, calc(100vw - 32px)); background: var(--surface);
  color: var(--text); box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgb(0 0 0 / .4); }
.dialog-title { margin: 0 0 12px; font-size: 18px; font-weight: 600; }
.dialog-text { margin: 0 0 16px; color: var(--text-2); font-size: 15px; }
.dialog input { width: 100%; min-height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg); margin-bottom: 16px; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; }

.toast {
  position: fixed; left: 50%; bottom: calc(110px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 50;
  background: var(--ink); color: var(--ink-text); padding: 8px 16px; border-radius: 999px; font-size: 14px; box-shadow: var(--shadow);
  max-width: calc(100vw - 32px);
}

/* ---------- narrow screens ---------- */
@media (max-width: 767px) {
  .sidebar {
    position: fixed; inset: 0 auto 0 0; width: min(85vw, 300px); z-index: 30; margin-left: 0;
    transform: translateX(-100%); transition: transform .2s ease; visibility: hidden; box-shadow: var(--shadow);
  }
  .sb-collapsed .sidebar { margin-left: 0; }
  .drawer-open .sidebar { transform: none; visibility: visible; }
  .scrim { position: fixed; inset: 0; z-index: 25; background: rgb(0 0 0 / .4); }
  .menu-btn, .top-new { display: inline-grid; }
  #sb-collapse { display: none; }
  .sb-head { justify-content: flex-end; }
  .topbar { padding-left: 4px; padding-right: 4px; }
  .model-btn { font-size: 16px; padding: 0 6px 0 8px; }
  .model-btn-effort { font-size: 14px; }
  .messages { padding: 12px 16px 24px; }
  .bubble { max-width: 88%; }
  .composer-wrap { padding: 0 8px; padding-bottom: max(8px, env(safe-area-inset-bottom)); }
  .composer-hint { display: none; }
  .model-pop {
    left: 0 !important; right: 0; top: auto !important; bottom: 0; width: 100%; max-height: 85vh;
    border-radius: 20px 20px 0 0; padding-bottom: max(12px, env(safe-area-inset-bottom));
  }
  .pop-scrim { background: rgb(0 0 0 / .4); }
  .empty { padding-top: 16vh; }
  .empty-title { font-size: 24px; }
  .top-chip-text { display: none; }
  .top-chip { padding: 0 10px; }
}
@media (max-width: 360px) {
  .model-btn-effort { display: none; }
  .messages { padding-left: 12px; padding-right: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ---------- browser panel ---------- */
.bpanel {
  width: var(--bpanel-w, min(50vw, 960px)); min-width: 320px; flex-shrink: 0; display: flex; flex-direction: column; min-height: 0;
  border-left: 1px solid var(--border); background: var(--sidebar);
}
.bp-head {
  display: flex; align-items: center; gap: 6px; min-height: 52px; padding: 6px 8px 6px 14px;
  padding-top: max(6px, env(safe-area-inset-top));
}
.bp-back { display: none; align-items: center; gap: 6px; min-height: 40px; padding: 0 12px 0 8px; border: 0; border-radius: 10px; background: var(--surface-2); cursor: pointer; font-size: 15px; font-weight: 500; }
.bp-heading { margin: 0; font-size: 15px; font-weight: 600; }
.bp-pill { font-size: 12px; padding: 3px 10px; border-radius: 999px; background: var(--surface-3); color: var(--text-2); white-space: nowrap; }
.bp-pill[data-tone="agent"] { background: var(--accent-soft); color: var(--accent); }
.bp-pill[data-tone="waiting"] { background: var(--warn-soft); color: var(--warn); font-weight: 600; }
.bp-pill[data-tone="human"] { background: var(--ink); color: var(--ink-text); font-weight: 600; }
.bp-pill[data-tone="error"] { background: var(--danger-soft); color: var(--danger); }
.bp-help { display: flex; gap: 10px; margin: 0 12px 8px; padding: 10px 12px; border-radius: 12px; background: var(--warn-soft); color: var(--warn); }
.bp-help-icon { display: grid; padding-top: 2px; }
.bp-help-text { min-width: 0; }
.bp-help-reason { margin: 0; font-weight: 600; font-size: 15px; color: var(--text); }
.bp-help-details { margin: 2px 0 0; font-size: 13px; color: var(--text-2); }
.bp-help-details:empty { display: none; }
.bp-screen { position: relative; flex: 1; min-height: 0; margin: 0 12px; border-radius: 12px; overflow: hidden; background: #1b1b1b; border: 1px solid var(--border); }
.bp-screen.human { outline: 3px solid var(--ink); outline-offset: -3px; }
.bp-canvas { position: absolute; inset: 0; }
.bp-canvas > div { background: #1b1b1b !important; }
.bp-canvas canvas { margin: 0 auto !important; }
.bp-overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 12px; padding: 24px; text-align: center; background: rgb(20 20 20 / .82); color: #f2f2f2; }
.bp-overlay-text { margin: 0; max-width: 28em; font-size: 15px; }
.bp-overlay .btn-primary { background: #fff; color: #111; }
.bp-typebar { display: flex; gap: 6px; margin: 8px 12px 0; }
.bp-typebar input { flex: 1; min-width: 0; min-height: 36px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg); }
.bp-foot { display: flex; align-items: center; gap: 10px; padding: 10px 12px; padding-bottom: max(10px, env(safe-area-inset-bottom)); }
.bp-foot-text { flex: 1; margin: 0; font-size: 13px; color: var(--text-2); line-height: 1.45; }
.bp-foot .btn { flex-shrink: 0; }
.top-chip.waiting { border-color: var(--warn); color: var(--warn); }

/* hand-off card in the transcript */
.handoff { margin: 12px 0; padding: 14px; border-radius: 16px; border: 1px solid var(--border-strong); background: var(--surface); }
.handoff.pending { border-color: var(--warn); box-shadow: 0 0 0 3px var(--warn-soft); }
.handoff-head { display: flex; align-items: center; gap: 8px; margin: 0 0 4px; font-weight: 600; }
.handoff-head .ico { color: var(--warn); }
.handoff-reason { margin: 0 0 4px; }
.handoff-sub { margin: 0 0 10px; font-size: 13px; color: var(--text-2); }
.handoff-state { margin: 0; font-size: 13px; color: var(--text-2); }

@media (max-width: 1100px) and (min-width: 768px) {
  .bp-open .sidebar { display: none; }
  .bpanel { width: var(--bpanel-w, 55vw); min-width: 0; }
  .bp-open #sb-resize { display: none; }
}
@media (max-width: 767px) {
  .bpanel { position: fixed; inset: 0; z-index: 35; width: 100%; min-width: 0; border-left: 0; background: var(--bg); }
  .bp-back { display: inline-flex; }
  .bp-close, .bp-heading { display: none; }
  .bp-head { padding-left: 8px; }
  .bp-screen { margin: 0; border-radius: 0; border-left: 0; border-right: 0; }
}

/* ---------- settings / tasks sheets ---------- */
.dialog.sheet { width: min(640px, calc(100vw - 32px)); max-height: min(86vh, 860px); padding: 0; display: none; flex-direction: column; overflow: hidden; }
.dialog.sheet[open] { display: flex; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 12px 10px 20px; border-bottom: 1px solid var(--border); }
.sheet-head .dialog-title { margin: 0; }
.sheet-body { overflow-y: auto; padding: 8px 20px 20px; overscroll-behavior: contain; }
.sheet-section { padding: 14px 0; border-bottom: 1px solid var(--border); }
.sheet-section:last-child { border-bottom: 0; }
.sheet-section-head { display: flex; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.sheet-section-head .sheet-h { flex: 1; }
.sheet-h { margin: 0; font-size: 15px; font-weight: 600; }
.sheet-meta { font-size: 12px; color: var(--text-3); }
.sheet-muted { margin: 6px 0 0; font-size: 13px; color: var(--text-2); }
.sheet-error { margin: 6px 0; font-size: 14px; color: var(--danger); }
.usage-row { margin: 0 0 14px; }
.usage-top { display: flex; justify-content: space-between; gap: 8px; font-size: 14px; margin-bottom: 6px; }
.usage-name { font-weight: 500; }
.usage-pct { color: var(--text-2); font-variant-numeric: tabular-nums; }
.usage-bar { height: 8px; border-radius: 99px; background: var(--surface-3); overflow: hidden; }
.usage-fill { display: block; height: 100%; border-radius: 99px; background: var(--accent); transition: width .3s ease; }
.usage-fill.warn { background: var(--warn); }
.usage-fill.crit { background: var(--danger); }
.usage-reset { margin: 6px 0 0; font-size: 12px; color: var(--text-2); }
.kv { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 6px 16px; margin: 0; font-size: 14px; }
.kv dt { color: var(--text-2); }
.kv dd { margin: 0; overflow-wrap: anywhere; }
@media (prefers-reduced-motion: reduce) { .usage-fill { transition: none; } }

.tasks-bar { display: flex; align-items: flex-start; gap: 12px; padding: 10px 0 14px; }
.tasks-bar .sheet-muted { flex: 1; margin: 0; }
.tasks-empty { padding: 28px 8px; text-align: center; }
.task-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.task-card { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; background: var(--surface); }
.task-card.off { opacity: .7; }
.task-head { display: flex; align-items: center; gap: 8px; }
.task-name { flex: 1; min-width: 0; font-weight: 600; overflow-wrap: anywhere; }
.task-badge { font-size: 11px; padding: 1px 6px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); white-space: nowrap; }
.task-sched { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 6px 0 0; font-size: 13px; color: var(--text-2); }
.task-next { margin-left: auto; font-variant-numeric: tabular-nums; }
.task-prompt { margin: 8px 0 0; font-size: 14px; white-space: pre-wrap; overflow-wrap: anywhere; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.task-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 8px; font-size: 12px; color: var(--text-3); }
.task-fail { color: var(--danger); }
.task-actions { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.task-actions .btn .ico { width: 15px; height: 15px; }
.danger-text { color: var(--danger); }
.switch { flex-shrink: 0; width: 40px; height: 24px; border-radius: 99px; border: 0; background: var(--surface-3); position: relative; cursor: pointer; padding: 0; }
.switch::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: 0 1px 2px rgb(0 0 0 / .25); transition: transform .15s ease; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(16px); }

.task-form { display: grid; gap: 14px; padding-top: 12px; }
.task-form .field { display: grid; gap: 6px; }
.task-form .field-label { font-size: 13px; font-weight: 600; color: var(--text-2); padding: 0; }
.task-form input:not([type="checkbox"]):not([type="radio"]), .task-form select, .task-textarea {
  width: 100%; min-height: 40px; margin: 0; padding: 8px 12px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg); color: var(--text);
}
.task-textarea { resize: vertical; line-height: 1.5; }
.task-form input.mono { font-family: var(--mono); }
.task-form fieldset { border: 0; margin: 0; padding: 0; display: grid; gap: 8px; min-width: 0; }
.sched-detail { display: grid; gap: 10px; }
.sched-preview { margin: 0; font-size: 13px; color: var(--text-2); }
.sched-preview.bad { color: var(--danger); }
.days { display: flex; flex-wrap: wrap; gap: 6px; }
.day { width: 40px; height: 36px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg); cursor: pointer; }
.day[aria-pressed="true"] { background: var(--ink); color: var(--ink-text); border-color: var(--ink); }
.inline-row { display: flex; align-items: center; gap: 8px; }
.inline-row input { max-width: 96px; }
.inline-row select { max-width: 120px; }
.radio { display: flex; align-items: center; gap: 8px; font-size: 14px; cursor: pointer; }
.radio input { width: 18px; height: 18px; margin: 0; accent-color: var(--accent); }

/* ---------- "/" command palette ---------- */
.slash-pop {
  position: absolute; left: 16px; right: 16px; bottom: calc(100% - 4px); z-index: 30; max-width: var(--col); margin: 0 auto;
  max-height: min(46vh, 360px); overflow-y: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow); padding: 6px;
}
.slash-opt { padding: 8px 10px; border-radius: 10px; cursor: pointer; }
.slash-opt.active, .slash-opt:hover { background: var(--hover); }
.slash-top { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.slash-name { font-family: var(--mono); font-size: 14px; font-weight: 600; }
.slash-hint { font-family: var(--mono); font-size: 12px; color: var(--text-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.slash-badge { margin-left: auto; font-size: 11px; padding: 1px 6px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.slash-desc { font-size: 13px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slash-empty { margin: 0; padding: 10px; font-size: 13px; color: var(--text-2); }

@media (max-width: 767px) {
  .dialog.sheet { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; margin: 0; }
  .sheet-head { padding-top: max(14px, env(safe-area-inset-top)); }
  .sheet-body { padding: 8px 16px max(20px, env(safe-area-inset-bottom)); }
  .tasks-bar { flex-direction: column; }
  .slash-pop { left: 8px; right: 8px; }
}

/* ---------- read-only share page ---------- */
body.share-page { overflow: auto; height: auto; min-height: 100%; }
.share-head {
  position: sticky; top: 0; z-index: 5; display: flex; align-items: center; gap: 10px;
  padding: 10px 16px; padding-top: max(10px, env(safe-area-inset-top)); background: var(--bg); border-bottom: 1px solid var(--border);
}
.share-brand { font-weight: 600; }
.share-tag { font-size: 12px; padding: 2px 8px; border-radius: 99px; background: var(--surface-2); color: var(--text-2); }
.share-main { max-width: var(--col); margin: 0 auto; padding: 28px 16px max(40px, env(safe-area-inset-bottom)); }
.share-title { margin: 0 0 6px; font-size: 26px; line-height: 1.3; overflow-wrap: anywhere; }
.share-meta { margin: 0 0 28px; color: var(--text-2); font-size: 14px; }
.share-messages { padding: 0; max-width: none; }
.share-note { margin: 0 0 6px; font-size: 13px; color: var(--text-3); }
.share-foot { margin: 32px 0 0; padding-top: 16px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-3); }

/* ---------- share dialog ---------- */
.share-dialog { width: min(480px, calc(100vw - 32px)); }
.share-link { display: flex; gap: 8px; margin: 4px 0 8px; }
.share-link input { flex: 1; min-width: 0; margin: 0 !important; font-family: var(--mono); font-size: 13px; }
.share-actions { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.share-actions .spacer { flex: 1; }
.share-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; }
.share-item { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.share-item a { flex: 1; min-width: 0; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.share-item span { color: var(--text-3); font-size: 12px; white-space: nowrap; }
.task-model { margin: 4px 0 0; font-size: 13px; color: var(--text-2); }

/* ---------- resizable sidebar / browser panel (wide screens) ---------- */
.resizer {
  flex: 0 0 8px; margin: 0 -4px; position: relative; z-index: 6; cursor: col-resize; touch-action: none; outline: none;
}
.resizer::after {
  content: ""; position: absolute; top: 0; bottom: 0; left: 3px; width: 2px; border-radius: 2px;
  background: transparent; transition: background-color .15s ease;
}
.resizer:hover::after, .resizer.dragging::after, .resizer:focus-visible::after { background: var(--accent); }
.sb-collapsed #sb-resize, #bp-resize:has(+ .bpanel[hidden]) { display: none; }
body.resizing { cursor: col-resize; user-select: none; -webkit-user-select: none; }
body.resizing .sidebar { transition: none; }
@media (max-width: 767px) { .resizer { display: none; } }
@media (prefers-reduced-motion: reduce) { .resizer::after { transition: none; } }
.dialog:focus-visible { outline: none; }

/* ---------- permission mode ---------- */
.perm-chip {
  flex-shrink: 0; margin-left: 6px; padding: 2px 9px; border-radius: 99px; border: 1px solid var(--border);
  background: transparent; color: var(--text-2); font-size: 12px; line-height: 18px; cursor: pointer; white-space: nowrap;
}
.perm-chip:hover { background: var(--hover); color: var(--text); }
.perm-chip.danger { border-color: var(--danger); color: var(--danger); }
.perm-list { display: grid; gap: 6px; }
.perm-opt {
  display: flex; align-items: flex-start; gap: 10px; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 12px; cursor: pointer;
}
.perm-opt:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.perm-opt.risky:has(input:checked) { border-color: var(--danger); background: var(--danger-soft); }
.perm-opt input { width: 18px; height: 18px; margin: 2px 0 0 !important; accent-color: var(--accent); flex-shrink: 0; }
.perm-opt.risky input { accent-color: var(--danger); }
.perm-text { display: grid; gap: 2px; }
.perm-label { font-size: 14px; font-weight: 600; }
.perm-desc { font-size: 13px; color: var(--text-2); }
.perm-warn { margin: 8px 0 0; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-size: 13px; }
@media (max-width: 360px) { .composer-model { display: none; } }

/* ---------- lazy lists ---------- */
.load-earlier, .list-more {
  display: block; margin: 0 auto 20px; padding: 6px 14px; border-radius: 99px; border: 1px solid var(--border);
  background: var(--bg); color: var(--text-2); font-size: 13px; cursor: pointer;
}
.load-earlier:hover, .list-more:hover { background: var(--hover); color: var(--text); }
.list-more { margin: 8px auto 12px; }
.run-label { font-size: 14px; }
#max-runs { width: auto; min-width: 72px; min-height: 36px; padding: 0 8px; border-radius: 10px; border: 1px solid var(--border-strong); background: var(--bg); color: var(--text); }

/* Files Claude showed (assistant-media show_file) and the image viewer */
.shown-file { margin: 12px 0; }
.shown-file.image a { display: inline-block; border-radius: 12px; overflow: hidden; border: 1px solid var(--border); background: var(--surface-2); line-height: 0; cursor: zoom-in; }
.shown-file.image img { display: block; max-width: 100%; max-height: 420px; width: auto; height: auto; object-fit: contain; }
.shown-file figcaption { margin-top: 6px; font-size: 13px; color: var(--text-2); }
.viewer { width: 100vw; height: 100dvh; max-width: none; max-height: none; margin: 0; padding: 0; border: 0; background: rgba(0, 0, 0, .92); color: #fff; }
.viewer[open] { display: flex; flex-direction: column; }
.viewer::backdrop { background: rgba(0, 0, 0, .6); }
.viewer-bar { display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 16px; padding-top: max(8px, env(safe-area-inset-top)); }
.viewer-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.viewer .link-btn, .viewer .icon-btn { color: #fff; }
.viewer img { flex: 1; min-height: 0; width: 100%; object-fit: contain; padding: 0 8px max(8px, env(safe-area-inset-bottom)); }

/* Switch account */
.account-links { display: flex; flex-direction: column; gap: 6px; }
.account-link { display: flex; justify-content: space-between; gap: 12px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px; color: var(--text); font-size: 14px; text-decoration: none; }
a.account-link:hover { background: var(--hover); }
.account-link.current { background: var(--hover); }
.account-link-note { color: var(--text-2); font-size: 13px; overflow-wrap: anywhere; }
