/* Context37 AI Chat. Neutral, warm palette; light/dark via variables.
   No data-theme attribute = follow the system; data-theme="light" | "dark" = user override. */

:root {
  --bg: #f6f8fb;
  --surface: #ffffff;
  --sidebar: #edf1f6;
  --hover: #e4eaf1;
  --active: #d8e1eb;
  --text: #0f172a;
  --muted: #64748b;
  --border: #dbe3ec;
  --accent: #0e7490;
  --accent-text: #ffffff;
  --brand-from: #10b981;
  --brand-mid: #0e7490;
  --brand-to: #1e3a8a;
  --brand-gradient: linear-gradient(135deg, var(--brand-from), var(--brand-mid) 55%, var(--brand-to));
  --user-bubble: #e6eef6;
  --code-bg: #f1f5f9;
  --inline-code: #e2e8f0;
  --danger: #b42318;
  --shadow: 0 1px 2px rgba(15, 23, 42, .05), 0 4px 16px rgba(15, 23, 42, .06);

  --hl-keyword: #a23c1e; --hl-string: #2f6f3e; --hl-number: #a15c00; --hl-comment: #8a877e;
  --hl-title: #3b5ba9; --hl-type: #7a3e9d; --hl-attr: #8a5a00; --hl-meta: #5b6470;

  --font: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "SF Mono", Consolas, monospace;
  color-scheme: light;
}

/* Dark: the same values twice, once for "follow the system", once for the explicit override. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f141a; --surface: #161d26; --sidebar: #0b1015; --hover: #1b2430; --active: #233041;
    --text: #e6edf5; --muted: #94a3b8; --border: #253242; --accent: #2dd4bf; --accent-text: #04201c;
    --brand-from: #34d399; --brand-mid: #0e9fb8; --brand-to: #2547b8;
    --user-bubble: #1c2836; --code-bg: #0b1015; --inline-code: #1f2a37; --danger: #fda4af;
    --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
    --hl-keyword: #e08a6a; --hl-string: #9ccc8a; --hl-number: #e3b26b; --hl-comment: #8c8a83;
    --hl-title: #8fb0f0; --hl-type: #c9a0e6; --hl-attr: #e0bf7a; --hl-meta: #a7b0bc;
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f141a; --surface: #161d26; --sidebar: #0b1015; --hover: #1b2430; --active: #233041;
    --text: #e6edf5; --muted: #94a3b8; --border: #253242; --accent: #2dd4bf; --accent-text: #04201c;
    --brand-from: #34d399; --brand-mid: #0e9fb8; --brand-to: #2547b8;
    --user-bubble: #1c2836; --code-bg: #0b1015; --inline-code: #1f2a37; --danger: #fda4af;
  --shadow: 0 1px 2px rgba(0, 0, 0, .3), 0 4px 16px rgba(0, 0, 0, .25);
  --hl-keyword: #e08a6a; --hl-string: #9ccc8a; --hl-number: #e3b26b; --hl-comment: #8c8a83;
  --hl-title: #8fb0f0; --hl-type: #c9a0e6; --hl-attr: #e0bf7a; --hl-meta: #a7b0bc;
  color-scheme: dark;
}

/* ---------- base ---------- */

*, *::before, *::after { box-sizing: border-box; }
[cx-cloak] { display: none !important; }

html, body { height: 100%; margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.6 var(--font); -webkit-font-smoothing: antialiased; }
a { color: var(--accent); }
button { font: inherit; color: inherit; cursor: pointer; }
button:disabled { cursor: default; opacity: .45; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.muted { color: var(--muted); }
.icon-button { background: none; border: 0; border-radius: 8px; padding: 4px 8px; color: var(--muted); font-size: 16px; line-height: 1; }
.icon-button:hover { background: var(--hover); color: var(--text); }

/* ---------- layout ---------- */

.app { display: grid; grid-template-columns: 272px 1fr; height: 100dvh; }

.sidebar { display: flex; flex-direction: column; min-height: 0; background: var(--sidebar); border-right: 1px solid var(--border); padding: 12px 10px; gap: 6px; }
.sidebar-head { padding: 4px 8px 10px; }
.brand { font-weight: 650; font-size: 17px; color: var(--text); text-decoration: none; letter-spacing: -.01em; }
.brand { display: inline-flex; align-items: center; gap: 9px; }
.brand-name span { color: var(--accent); }
.brand-mark { display: inline-grid; place-items: center; width: 1.6em; height: 1.6em; border-radius: 28%;
  background: var(--brand-gradient); color: #fff; box-shadow: 0 1px 3px rgba(14, 116, 144, .35); flex-shrink: 0; }
.brand-mark ui-icon { width: 1em; height: 1em; vertical-align: 0; }
conversation-list { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 4px; }
.sidebar-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; border-top: 1px solid var(--border); padding: 10px 6px 2px; position: relative; }
.user-menu { position: absolute; left: 6px; right: 6px; bottom: calc(100% + 4px); z-index: 30; display: flex; flex-direction: column; padding: 4px;
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px; box-shadow: var(--shadow); }
.user-menu a, .user-menu button { display: flex; align-items: center; gap: 10px; padding: 8px 10px; border: 0; border-radius: 6px; background: none;
  color: var(--text); font: inherit; font-size: 14px; text-align: left; text-decoration: none; cursor: pointer; }
.user-menu a:hover, .user-menu button:hover, .user-menu a:focus-visible, .user-menu button:focus-visible { background: var(--hover); }
.user-menu ui-icon { color: var(--muted); }
.menu-sep { height: 1px; margin: 4px 6px; background: var(--border); }
.user { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.main { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; }
cx-router-view, home-view, chat-view, not-found-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.menu-button, .scrim { display: none; }

.page-message { margin: 48px auto; max-width: 640px; padding: 0 20px; text-align: center; }
.page-error { color: var(--danger); text-align: center; margin: 16px 0; }

/* ---------- sidebar list ---------- */

.new-chat { display: flex; align-items: center; gap: 8px; width: 100%; background: none; border: 0; border-radius: 10px; padding: 8px 10px; font-weight: 550; text-align: left; }
.new-chat .new-chat-icon { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; background: var(--brand-gradient); color: var(--accent-text); font-size: 13px; }
.new-chat:hover { background: var(--hover); }
.section-label { margin: 12px 10px 2px; font-size: 12px; color: var(--muted); }
.conversations { overflow-y: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; gap: 1px; }
.conversation { display: flex; align-items: center; gap: 4px; padding-right: 6px; border-radius: 8px; font-size: 14px; }
.conversation:hover { background: var(--hover); }
.conversation.active { background: var(--active); }
.conversation .title { flex: 1; min-width: 0; padding: 6px 0 6px 10px; color: inherit; text-decoration: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border-radius: 8px; }
.conversation .actions { display: none; gap: 2px; }
.conversation:hover .actions, .conversation.active .actions, .conversation:focus-within .actions { display: flex; }
.conversation .actions button { background: none; border: 0; border-radius: 6px; padding: 2px 6px; color: var(--muted); font-size: 12px; }
.conversation .actions button:hover { background: var(--active); color: var(--text); }
.empty { color: var(--muted); font-size: 13px; padding: 4px 10px; }
.search-box { padding: 6px 4px 0; }
.search-box input { width: 100%; padding: 6px 10px; font: inherit; font-size: 13px; color: var(--text); background: var(--surface);
  border: 1px solid var(--border); border-radius: 8px; }
.search-box input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }
.conversation .snippet { display: block; font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- home ---------- */

.home { flex: 1; display: flex; flex-direction: column; justify-content: center; width: 100%; max-width: 720px; margin: 0 auto; padding: 24px 20px 18vh; }
.greeting { font-weight: 400; font-size: 34px; letter-spacing: -.02em; text-align: center; margin: 0 0 28px; }
.greeting .brand-mark, .auth-title .brand-mark { font-size: .9em; margin-right: 6px; vertical-align: -0.28em; }

/* ---------- chat ---------- */

.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.chat-head { padding: 12px 20px 8px 56px; display: flex; align-items: center; gap: 8px; position: relative; }

/* Conversation details: opened from the context meter, floats above the composer */
.details-panel { position: absolute; bottom: calc(100% + 4px); right: 20px; z-index: 20; width: min(440px, calc(100vw - 32px)); max-height: 70vh;
  overflow-y: auto; padding: 14px 16px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px;
  box-shadow: var(--shadow); font-size: 13px; }
.details-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.details-panel h4 { margin: 14px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.details-grid { display: grid; grid-template-columns: 130px 1fr; gap: 4px 16px; margin: 0; }
.details-grid dt { color: var(--muted); }
.details-grid dd { margin: 0; font-variant-numeric: tabular-nums; }
.details-table { width: 100%; border-collapse: collapse; font-variant-numeric: tabular-nums; }
.details-table th, .details-table td { padding: 4px 6px; text-align: right; border-bottom: 1px solid var(--border); }
.details-table th:first-child, .details-table td:first-child { text-align: left; }
.details-table th { font-weight: 550; color: var(--muted); }
.details-note { margin: 10px 0 0; font-size: 12px; }
.chat-title { flex: 1; margin: 0 auto; max-width: 760px; font-size: 15px; font-weight: 550; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.scroller { flex: 1; min-height: 0; overflow-y: auto; }
.thread { max-width: 760px; margin: 0 auto; padding: 8px 20px 24px; display: flex; flex-direction: column; gap: 22px; }
.composer-dock { width: 100%; max-width: 760px; margin: 0 auto; padding: 0 20px 10px; position: relative; }
.disclaimer { margin: 6px 0 0; font-size: 12px; color: var(--muted); display: flex; justify-content: center; align-items: center; gap: 16px; flex-wrap: wrap; }
.context-meter { display: inline-flex; align-items: center; gap: 6px; font-variant-numeric: tabular-nums; cursor: pointer;
  padding: 2px 8px; margin: -2px 0; border: 0; border-radius: 999px; background: none; color: inherit; font: inherit; }
.context-meter:hover, .context-meter.active { background: var(--hover); color: var(--text); }
.meter { width: 56px; height: 5px; border-radius: 3px; background: var(--border); overflow: hidden; }
.meter-fill { display: block; height: 100%; background: var(--muted); }
.context-meter.warn .meter-fill { background: #c98a1b; }
.context-meter.full { color: var(--danger); }
.context-meter.full .meter-fill { background: var(--danger); }
.spend-meter { margin-left: 2px; }

/* ---------- messages ---------- */

.message-user { display: flex; justify-content: flex-end; }
.bubble { background: var(--user-bubble); border-radius: 18px; padding: 10px 16px; max-width: 85%; white-space: pre-wrap; overflow-wrap: anywhere; }

.message-assistant { min-width: 0; }
.thinking { margin-bottom: 10px; color: var(--muted); font-size: 14px; }
.thinking summary { cursor: pointer; width: fit-content; user-select: none; }
.thinking-text { margin-top: 8px; padding-left: 12px; border-left: 2px solid var(--border); white-space: pre-wrap; }

.typing { display: flex; gap: 4px; padding: 8px 0; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.message-error { margin-top: 8px; padding: 8px 12px; border: 1px solid var(--danger); border-radius: 10px; color: var(--danger); font-size: 14px; }
.meta { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; margin-top: 6px; font-size: 12px; color: var(--muted); }
.meta-button { background: none; border: 0; padding: 2px 6px; margin-left: -6px; border-radius: 6px; color: var(--muted); font-size: 12px; }
.meta-button:hover { background: var(--hover); color: var(--text); }
.meta .note { font-style: italic; }
.meta .cost { font-variant-numeric: tabular-nums; cursor: help; }

/* Message actions: edit, versions (branches), continue, refusal */
.message-user { flex-wrap: wrap; }
.meta-user { flex-basis: 100%; justify-content: flex-end; margin-top: 4px; opacity: 0; transition: opacity .15s; }
.message-user:hover .meta-user, .meta-user:focus-within, .meta-user:has(.branch-nav) { opacity: 1; }
.branch-nav { display: inline-flex; align-items: center; gap: 2px; font-variant-numeric: tabular-nums; }
.branch-nav .meta-button { margin-left: 0; padding: 2px 6px; }
.meta-button:disabled { opacity: .4; cursor: default; background: none; }
.meta-button.continue { color: var(--accent); font-weight: 600; }
.edit-box { width: min(100%, 640px); display: flex; flex-direction: column; gap: 8px; }
.edit-box textarea { width: 100%; min-height: 60px; max-height: 40vh; resize: none; padding: 10px 14px; font: inherit;
  color: var(--text); background: var(--surface); border: 1px solid var(--border); border-radius: 14px; }
.edit-actions { display: flex; justify-content: flex-end; gap: 8px; }
.edit-actions .auth-button { width: auto; padding: 6px 16px; }
.refusal { margin-top: 8px; padding: 10px 14px; border-left: 3px solid var(--accent); background: var(--code-bg);
  border-radius: 6px; font-size: 14px; }

/* ---------- markdown ---------- */

.markdown { overflow-wrap: anywhere; }
.markdown > :first-child { margin-top: 0; }
.markdown > :last-child { margin-bottom: 0; }
.markdown p, .markdown ul, .markdown ol, .markdown pre, .markdown table, .markdown blockquote { margin: 0 0 14px; }
.markdown h1, .markdown h2, .markdown h3, .markdown h4 { margin: 22px 0 10px; line-height: 1.3; font-weight: 650; }
.markdown h1 { font-size: 1.4em; } .markdown h2 { font-size: 1.25em; } .markdown h3 { font-size: 1.1em; }
.markdown ul, .markdown ol { padding-left: 24px; }
.markdown li + li { margin-top: 4px; }
.markdown blockquote { padding-left: 14px; border-left: 3px solid var(--border); color: var(--muted); }
.markdown hr { border: 0; border-top: 1px solid var(--border); margin: 20px 0; }
.markdown table { border-collapse: collapse; display: block; overflow-x: auto; }
.markdown th, .markdown td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.markdown th { background: var(--code-bg); font-weight: 600; }
.markdown code { font-family: var(--mono); font-size: .88em; background: var(--inline-code); padding: 1px 5px; border-radius: 5px; }
.markdown pre { position: relative; background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; padding: 14px 16px; overflow-x: auto; }
.markdown pre code { background: none; padding: 0; font-size: 13px; line-height: 1.55; }
.markdown code, .code-lang { font-variant-ligatures: none; } /* -> and => stay as typed */

/* Code blocks: header with language and actions; Mermaid diagram/code toggle; markdown preview. */
.code-block { margin: 0 0 14px; background: var(--code-bg); border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.markdown .code-block pre { margin: 0; border: 0; border-radius: 0; background: none; }
.code-block.wrap > pre { white-space: pre-wrap; overflow-wrap: anywhere; }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 3px 4px 3px 14px;
  border-bottom: 1px solid var(--border); font-size: 12px; color: var(--muted); }
.code-lang { font-family: var(--mono); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.code-actions { display: flex; gap: 2px; flex-shrink: 0; }
.code-actions button { font: inherit; font-size: 12px; padding: 3px 8px; border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; }
.code-actions button:hover, .code-actions button:focus-visible { background: var(--hover); color: var(--text); }
.code-actions button[hidden] { display: none; }
.mermaid-view { padding: 16px; overflow-x: auto; background: var(--surface); text-align: center; }
.mermaid-view svg { max-width: 100%; height: auto; }
.mermaid-block.showing-diagram > pre, .mermaid-block:not(.showing-diagram):not(.mermaid-failed) > .mermaid-view { display: none; }
.mermaid-block.mermaid-failed > pre { display: block; }
.mermaid-block.mermaid-failed > .mermaid-view { text-align: left; font-size: 13px; color: var(--danger); background: none; padding: 0 16px 12px; white-space: pre-wrap; }
.md-preview { padding: 14px 16px; background: var(--surface); }
.code-block.previewing > pre, .code-block:not(.previewing) > .md-preview { display: none; }

/* highlight.js tokens, coloured from the theme */
.hljs-keyword, .hljs-selector-tag, .hljs-built_in, .hljs-literal { color: var(--hl-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-template-variable { color: var(--hl-string); }
.hljs-number, .hljs-symbol, .hljs-bullet { color: var(--hl-number); }
.hljs-comment, .hljs-quote { color: var(--hl-comment); font-style: italic; }
.hljs-title, .hljs-section, .hljs-function .hljs-title { color: var(--hl-title); }
.hljs-type, .hljs-class .hljs-title, .hljs-variable.language_ { color: var(--hl-type); }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-params { color: var(--hl-attr); }
.hljs-meta, .hljs-tag, .hljs-name, .hljs-deletion { color: var(--hl-meta); }
.hljs-emphasis { font-style: italic; } .hljs-strong { font-weight: 700; }

/* ---------- composer ---------- */

.composer { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 12px 12px 8px 16px; box-shadow: var(--shadow); transition: border-color .15s; }
.composer:focus-within { border-color: color-mix(in srgb, var(--accent) 45%, var(--border)); }
.composer textarea { display: block; width: 100%; border: 0; outline: none; resize: none; background: transparent; color: var(--text); font: inherit; line-height: 1.5; max-height: 40vh; padding: 2px 0 6px; }
.composer textarea::placeholder { color: var(--muted); }
.composer-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.composer-tools { display: flex; align-items: center; gap: 4px; min-width: 0; }
.attach-button { font-size: 16px; }
.composer.dragging { border-color: var(--accent); border-style: dashed; }

/* Attachments: chips in the composer, thumbnails/chips on sent messages */
.attachments { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 8px; }
.attachment { display: flex; align-items: center; gap: 8px; max-width: 260px; padding: 6px 6px 6px 10px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--bg); font-size: 13px; }
.attachment.pending { opacity: .7; }
.attachment.failed { border-color: var(--danger); }
.attachment.failed .attachment-info { color: var(--danger); white-space: normal; }
.attachment-text { display: flex; flex-direction: column; min-width: 0; }
.attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; }
.attachment-info { font-size: 11px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attachment-remove { border: 0; background: none; color: var(--muted); border-radius: 6px; padding: 2px 6px; cursor: pointer; }
.attachment-remove:hover { background: var(--hover); color: var(--text); }
.message-files { flex-basis: 100%; display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; margin-bottom: 6px; }
.message-file { color: inherit; text-decoration: none; }
.message-file img { display: block; max-width: 220px; max-height: 160px; border-radius: 12px; border: 1px solid var(--border); object-fit: cover; }
.message-file-chip { display: inline-flex; align-items: center; gap: 6px; padding: 8px 12px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--surface); font-size: 13px; }
.message-file:hover .message-file-chip { background: var(--hover); }
model-picker { display: flex; gap: 4px; flex-wrap: wrap; }
.picker { appearance: none; background: none; border: 1px solid transparent; border-radius: 8px; padding: 4px 8px; color: var(--muted); font: inherit; font-size: 13px; cursor: pointer; }
.picker:hover { background: var(--hover); color: var(--text); }
.picker option { background: var(--surface); color: var(--text); }
.send-button { flex: none; width: 34px; height: 34px; border-radius: 10px; border: 0; background: var(--brand-gradient); color: var(--accent-text); font-size: 17px; font-weight: 700; display: grid; place-items: center; }
.send-button.stop { background: var(--text); color: var(--bg); font-size: 12px; }

/* ---------- narrow screens ---------- */

@media (max-width: 820px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { position: fixed; inset: 0 auto 0 0; width: 280px; z-index: 20; transform: translateX(-100%); transition: transform .2s ease; }
  .sidebar-open .sidebar { transform: none; box-shadow: var(--shadow); }
  .sidebar-open .scrim { display: block; position: fixed; inset: 0; z-index: 15; background: rgba(0, 0, 0, .25); }
  .menu-button { display: block; position: absolute; top: 10px; left: 10px; z-index: 5; }
  .greeting { font-size: 26px; }
}

/* ---------- sign-in ---------- */

.splash { display: grid; place-items: center; height: 100dvh; }
.auth-shell { min-height: 100dvh; display: grid; place-items: center; padding: 24px 16px; }
auth-shell, signin-view, link-view { display: block; width: 100%; }
.auth-card { width: 100%; max-width: 400px; margin: 0 auto; background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 32px 28px; box-shadow: var(--shadow); }
.auth-title { margin: 0; font-size: 26px; font-weight: 500; letter-spacing: -.01em; text-align: center; }
.auth-sub { margin: 6px 0 24px; text-align: center; color: var(--muted); }
.auth-button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); font-weight: 550; }
.auth-button:hover:not(:disabled) { background: var(--hover); }
.auth-button.primary { background: var(--brand-gradient); border-color: transparent; color: #fff; }
.auth-button.primary:hover:not(:disabled) { background: var(--brand-gradient); filter: brightness(1.08); }
.ms-logo { display: grid; grid-template-columns: 9px 9px; gap: 2px; }
.ms-logo i { width: 9px; height: 9px; display: block; }
.ms-logo i:nth-child(1) { background: #f25022; } .ms-logo i:nth-child(2) { background: #7fba00; }
.ms-logo i:nth-child(3) { background: #00a4ef; } .ms-logo i:nth-child(4) { background: #ffb900; }
.auth-divider { display: flex; align-items: center; gap: 10px; margin: 20px 0; color: var(--muted); font-size: 13px; }
.auth-divider::before, .auth-divider::after { content: ""; flex: 1; border-top: 1px solid var(--border); }
.auth-form { display: flex; flex-direction: column; gap: 8px; }
.auth-form label { font-size: 13px; color: var(--muted); }
.auth-form input, .invite-form input, .invite-form select, .users select { font: inherit; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 10px; padding: 9px 12px; }
.auth-form input:focus, .invite-form input:focus { outline: 2px solid color-mix(in srgb, var(--accent) 50%, transparent); outline-offset: 0; }
.auth-form .auth-button { margin-top: 6px; }
.code-input { font-size: 24px !important; letter-spacing: 8px; text-align: center; font-variant-numeric: tabular-nums; }
.auth-message { font-size: 14px; color: var(--muted); margin: 0 0 12px; }
.auth-hint { font-size: 13px; color: var(--muted); margin: 14px 0 0; }
.link-button { background: none; border: 0; padding: 0; color: var(--accent); font-size: inherit; text-decoration: underline; }
.remember { display: flex; align-items: center; gap: 8px; margin-top: 18px; font-size: 13px; color: var(--muted); }

/* ---------- admin ---------- */

admin-users { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.admin { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.admin-body { flex: 1; overflow: auto; width: 100%; max-width: 980px; margin: 0 auto; padding: 8px 20px 24px; }
.invite-form { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 16px; margin-bottom: 18px; border: 1px solid var(--border); border-radius: 14px; background: var(--surface); }
.invite-form h3 { width: 100%; margin: 0 0 4px; font-size: 15px; }
.invite-form input { flex: 1 1 200px; }
.invite-form .auth-button { width: auto; }
.admin-hint { width: 100%; margin: 4px 0 0; font-size: 12px; color: var(--muted); }
.admin-notice { color: var(--accent); }
.users { width: 100%; border-collapse: collapse; font-size: 14px; }
.users th { text-align: left; font-weight: 600; color: var(--muted); font-size: 12px; padding: 6px 10px; border-bottom: 1px solid var(--border); }
.users td { padding: 8px 10px; border-bottom: 1px solid var(--border); }
.users tr.disabled td { opacity: .55; }
.users select { padding: 4px 8px; border-radius: 8px; }
.you { color: var(--muted); }

/* Tool calls inside a reply: one compact row each, details on demand */
.reply-part + .reply-part { margin-top: 10px; }
.tool-call { border: 1px solid var(--border); border-radius: 10px; background: var(--code-bg); font-size: 13px; max-width: 100%; }
.tool-call summary { display: flex; align-items: baseline; gap: 8px; padding: 6px 12px; cursor: pointer; color: var(--muted); list-style: none; }
.tool-call summary::-webkit-details-marker { display: none; }
.tool-call summary:hover { color: var(--text); }
.tool-call .tool-label { font-family: var(--mono); font-size: 12.5px; color: var(--text); overflow-wrap: anywhere; }
.tool-call .tool-icon { width: 1.2em; text-align: center; flex-shrink: 0; }
.tool-call.running .tool-label { color: var(--muted); }
.tool-call.failed { border-color: color-mix(in srgb, var(--danger) 45%, var(--border)); }
.tool-call .tool-error { color: var(--danger); font-size: 12.5px; overflow-wrap: anywhere; }
.tool-detail { padding: 0 12px 10px; border-top: 1px solid var(--border); }
.tool-detail-label { margin: 8px 0 4px; font-size: 11px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.tool-detail pre { margin: 0; max-height: 320px; overflow: auto; font-family: var(--mono); font-size: 12px; white-space: pre-wrap; overflow-wrap: anywhere; }
/* Admin: limit requests, settings and activity (phase 16.1) */
.limit-requests { margin: 0 0 16px; padding: 12px 14px; border: 1px solid color-mix(in srgb, var(--accent) 45%, var(--border)); border-radius: 12px; }
.limit-requests h3 { margin: 0 0 8px; font-size: 14px; }
.limit-request { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 16px; padding: 8px 0; font-size: 14px; }
.limit-request + .limit-request { border-top: 1px solid var(--border); }
.limit-reason { margin-top: 2px; color: var(--muted); font-style: italic; }
.limit-actions { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.limit-actions .auth-button { width: auto; padding: 5px 12px; font-size: 13px; }
.limit-settings { font-size: 14px; margin: 0 0 12px; }
.limit-settings .meta-button { margin-left: 4px; }
.limit-cell { white-space: nowrap; }
.limit-cell .meta-button { margin-left: 2px; }
.over-limit { color: var(--danger); font-weight: 600; }
.admin-log { margin-top: 16px; font-size: 13.5px; }
.admin-log summary { cursor: pointer; color: var(--muted); }
.admin-log ul { margin: 8px 0 0; padding-left: 18px; line-height: 1.6; }

/* Spending limit notice in the composer (phase 16.1) */
.limit-notice { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 10px; margin: -2px 0 8px; padding: 6px 10px;
  border-radius: 8px; background: var(--code-bg); color: var(--muted); font-size: 12.5px; line-height: 1.4; }
.limit-notice.blocked { color: var(--text); background: color-mix(in srgb, var(--danger) 10%, var(--surface)); }
.limit-notice .meta-button { margin-left: 0; padding: 2px 8px; color: var(--accent); font-weight: 600; }
.limit-notice .limit-error { color: var(--danger); }

/* A rendered file, under its tool step (phase 17) */
.reply-file { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 10px 14px; max-width: 460px;
  border: 1px solid var(--border); border-radius: 12px; background: var(--surface); }
.reply-file > ui-icon { font-size: 22px; color: var(--accent); }
.reply-file-text { display: flex; flex-direction: column; flex: 1; min-width: 0; font-size: 13.5px; }
.reply-file-text strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.reply-file-text .muted { font-size: 12px; }
.reply-file .meta-button { margin-left: 0; }
/* PDF preview in the Files panel */
.ws-pdf { width: 100%; height: min(70vh, 620px); border: 1px solid var(--border); border-radius: 8px; background: var(--code-bg); }

/* A generated or edited image, under its tool step (phase 15) */
.reply-image { display: inline-block; margin-top: 8px; max-width: 100%; }
.reply-image img { display: block; max-width: min(100%, 512px); max-height: 512px; height: auto; border-radius: 12px; border: 1px solid var(--border); }

/* ---------- workspace panel ---------- */
.chat-layout { display: flex; flex: 1; min-height: 0; min-width: 0; }
.chat-layout > .chat { flex: 1; min-width: 0; }
workspace-panel { display: flex; flex-direction: column; width: min(46%, 760px); min-width: 320px; border-left: 1px solid var(--border); background: var(--surface); }
.ws-panel { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ws-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); min-height: 48px; }
.ws-title { font-size: 14px; }
.ws-path { flex: 1; min-width: 0; font-family: var(--mono); font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-dirty { color: var(--accent); }
.ws-head-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.ws-error { margin: 8px 12px; }
.ws-list { overflow-y: auto; flex: 1; padding: 6px; }
.ws-empty { padding: 16px 10px; font-size: 13px; }
.ws-file { display: flex; align-items: center; gap: 4px; border-radius: 8px; }
.ws-file:hover { background: var(--hover); }
.ws-file-open { flex: 1; min-width: 0; display: flex; flex-direction: column; align-items: flex-start; gap: 2px; padding: 7px 10px;
  background: none; border: 0; text-align: left; color: inherit; cursor: pointer; border-radius: 8px; }
.ws-file-name { font-family: var(--mono); font-size: 13px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-file-meta { font-size: 11.5px; color: var(--muted); }
.ws-file-actions { display: none; gap: 2px; padding-right: 6px; }
.ws-file:hover .ws-file-actions, .ws-file:focus-within .ws-file-actions { display: flex; }
.ws-file-actions .icon-button, .ws-toolbar-actions .icon-button { text-decoration: none; font-size: 14px; }
.ws-file-view { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.ws-toolbar { display: flex; align-items: center; gap: 10px; padding: 6px 12px; border-bottom: 1px solid var(--border); flex-wrap: wrap; }
.ws-tabs { display: inline-flex; background: var(--code-bg); border-radius: 8px; padding: 2px; }
.ws-tabs button { border: 0; background: none; padding: 3px 10px; border-radius: 6px; font-size: 12.5px; color: var(--muted); cursor: pointer; }
.ws-tabs button.active { background: var(--surface); color: var(--text); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.ws-version { font-size: 12px; }
.ws-toolbar-actions { margin-left: auto; display: flex; align-items: center; gap: 4px; }
.ws-save { width: auto; padding: 4px 14px; font-size: 13px; }
.ws-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.ws-preview { flex: 1; overflow: auto; padding: 16px 18px; }
.ws-preview.markdown > .code-block:only-child { margin: 0; }
.ws-raw { flex: 1; margin: 0; overflow: auto; padding: 14px 16px; font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; overflow-wrap: anywhere; background: var(--bg); }
.ws-editor { flex: 1; width: 100%; resize: none; border: 0; outline: none; padding: 14px 16px; font-family: var(--mono); font-size: 13px;
  line-height: 1.5; color: var(--text); background: var(--bg); tab-size: 2; }
.ws-html-frame { width: 100%; height: 100%; min-height: 60vh; border: 1px solid var(--border); border-radius: 8px; background: #fff; }
.ws-svg { max-width: 100%; height: auto; }
.files-button { flex-shrink: 0; display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--border); background: var(--surface);
  border-radius: 8px; padding: 3px 10px; font-size: 13px; color: var(--text); cursor: pointer; }
.files-button:hover, .files-button.active { background: var(--hover); }
.files-count { background: var(--accent); color: var(--accent-text); border-radius: 10px; padding: 0 6px; font-size: 11px; font-weight: 600; }
@media (max-width: 900px) {
  workspace-panel { position: fixed; inset: 0; z-index: 30; width: auto; min-width: 0; border-left: 0; }
}

/* Projects: tag in the chat header, selector and sections in the panel, notes on messages */
.project-tag { flex-shrink: 0; border: 0; background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent);
  border-radius: 8px; padding: 3px 10px; font-size: 12.5px; font-weight: 600; cursor: pointer; max-width: 220px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-project { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 13px; }
.ws-project-label { color: var(--muted); }
.ws-project-select { flex: 1; min-width: 0; padding: 4px 8px; font: inherit; font-size: 13px; color: var(--text);
  background: var(--surface); border: 1px solid var(--border); border-radius: 8px; }
.ws-section + .ws-section { margin-top: 10px; padding-top: 8px; border-top: 1px dashed var(--border); }
.ws-section-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 10px; font-size: 12px;
  font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.ws-section-head .meta-button { text-transform: none; letter-spacing: 0; font-weight: 500; }
.ws-scope-badge { display: inline-block; margin-right: 6px; padding: 0 6px; border-radius: 6px; font-family: var(--font); font-size: 11px;
  background: color-mix(in srgb, var(--accent) 14%, transparent); color: var(--accent); }
.message-note { flex-basis: 100%; display: flex; justify-content: flex-end; margin-bottom: 4px; font-size: 12px; color: var(--muted); text-align: right; }
.conv-project { color: var(--muted); font-size: 12px; }

.ws-file-summary { font-size: 12px; color: var(--text); opacity: .8; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Conversation memory: a summary chunk after the message it ends at */
.memory-chunk { margin-top: 14px; border-top: 1px dashed var(--border); padding-top: 8px; font-size: 13px; color: var(--muted); }
.memory-chunk summary { cursor: pointer; }
.memory-summary { margin-top: 8px; padding: 10px 14px; background: var(--code-bg); border-radius: 10px; color: var(--text); font-size: 13.5px; }

/* ---------- icons (self-hosted Lucide sprite, <ui-icon>) ---------- */
ui-icon { display: inline-flex; width: 1.15em; height: 1.15em; flex-shrink: 0; vertical-align: -0.2em; }
ui-icon svg.icon { width: 100%; height: 100%; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
ui-icon.filled svg.icon { fill: currentColor; }
ui-icon.spin svg.icon { animation: ui-spin 1s linear infinite; }
@keyframes ui-spin { to { transform: rotate(360deg); } }
.icon-button ui-icon { width: 18px; height: 18px; }
.send-button ui-icon { width: 18px; height: 18px; color: #fff; }
.send-button.stop ui-icon { width: 13px; height: 13px; }
.conversation .actions ui-icon, .ws-file-actions ui-icon, .attachment-remove ui-icon { width: 15px; height: 15px; }
.meta-button ui-icon, .branch-nav ui-icon { width: 15px; height: 15px; vertical-align: -0.25em; }
.tool-icon ui-icon { width: 15px; height: 15px; }
.tool-call.failed .tool-icon { color: var(--danger); }
.files-button ui-icon, .project-tag ui-icon { width: 15px; height: 15px; }
.message-note ui-icon, .memory-chunk summary ui-icon { width: 14px; height: 14px; }
.new-chat .new-chat-icon ui-icon { width: 15px; height: 15px; color: #fff; }
.send-button.stop ui-icon { color: var(--bg); }

/* ---------- usage & cost (admin) ---------- */
/* Chart series: validated pair (dataviz validator, light on #ffffff, dark on #161d26). */
:root { --series-1: #2a78d6; --series-2: #eb6834; --chart-grid: #e6ebf1; --chart-axis: #c5cfdb; }
@media (prefers-color-scheme: dark) { :root:not([data-theme="light"]) { --series-1: #3987e5; --series-2: #d95926; --chart-grid: #222c39; --chart-axis: #34414f; } }
:root[data-theme="dark"] { --series-1: #3987e5; --series-2: #d95926; --chart-grid: #222c39; --chart-axis: #34414f; }

.usage-body { max-width: 1100px; }
.usage-filters { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-bottom: 16px; }
.range-button { border: 1px solid var(--border); background: var(--surface); color: var(--text); border-radius: 8px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.range-button:hover { background: var(--hover); }
.range-button.active { border-color: var(--accent); box-shadow: inset 0 0 0 1px var(--accent); font-weight: 600; }
.usage-range { font-size: 12.5px; margin-left: 6px; }
.kpis { display: grid; grid-template-columns: 1.4fr repeat(4, 1fr); gap: 12px; margin-bottom: 16px; }
.kpis.kpis-4 { grid-template-columns: 1.4fr repeat(3, 1fr); }
.kpi { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; }
.kpi-label { font-size: 12.5px; color: var(--muted); }
.kpi-value { font-size: 24px; font-weight: 650; margin: 4px 0 2px; letter-spacing: -.01em; }
.kpi.hero .kpi-value { font-size: 48px; line-height: 1.05; }
.kpi-of { font-size: 18px; font-weight: 500; color: var(--muted); }
.kpi .kpi-meter { display: inline-block; vertical-align: middle; margin-right: 4px; }
.kpi-meter.warn .meter-fill { background: #c98a1b; }
.kpi-meter.full .meter-fill { background: var(--danger); }
.kpi .meta-button { margin: 4px 0 0 -6px; color: var(--accent); font-weight: 600; }
.csv-link { margin-left: auto; display: inline-flex; align-items: center; gap: 4px; text-decoration: none; }
.usage-table tr.inactive td { color: var(--muted); }

/* Admin settings (phase 16.4) */
.settings-table td { vertical-align: top; }
.settings-table select { padding: 3px 6px; border-radius: 6px; font: inherit; font-size: 13px; }
.small { font-size: 12px; }
.badge { display: inline-block; padding: 1px 8px; border-radius: 999px; background: var(--code-bg); border: 1px solid var(--border); font-size: 12px; }
.grants { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; align-items: center; }
.grant { display: inline-flex; align-items: center; gap: 2px; padding: 1px 4px 1px 8px; border-radius: 999px; background: var(--code-bg); font-size: 12px; }
.grant-remove { border: 0; background: none; padding: 0 2px; color: var(--muted); cursor: pointer; display: inline-flex; }
.tool-description { max-width: 520px; color: var(--muted); font-size: 12.5px; }
.settings-intro { margin: 0 0 12px; }
.usage-card.instruction { margin-bottom: 12px; }
.usage-card.instruction.inactive { opacity: .65; }
.usage-card.instruction .usage-card-head { flex-wrap: wrap; gap: 8px 12px; }
.usage-card.instruction select { padding: 3px 6px; border-radius: 6px; font: inherit; font-size: 13px; }
.inline-check { display: inline-flex; gap: 4px; align-items: center; font-size: 13px; }
.instruction-text { width: 100%; box-sizing: border-box; min-height: 80px; padding: 10px 12px; border: 1px solid var(--border); border-radius: 8px;
  background: var(--bg); color: var(--text); font: inherit; font-size: 13.5px; line-height: 1.5; resize: vertical; }
.instruction-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; margin-top: 8px; }
.instruction-actions .auth-button { width: auto; padding: 5px 14px; }
.instruction-preview { margin: 0; max-height: 420px; overflow: auto; white-space: pre-wrap; font-family: var(--mono); font-size: 12px; line-height: 1.5; }
.danger-text { color: var(--danger); }
.retention-field { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin: 10px 0; font-size: 14px; }
.retention-field input { width: 90px; padding: 5px 8px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; }
.retention-note { margin-top: 12px; }
.kpi-note { font-size: 12px; color: var(--muted); }
.usage-card { background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; margin-bottom: 16px; min-width: 0; }
.usage-card-head { display: flex; align-items: center; gap: 14px; margin-bottom: 10px; }
.usage-card-head h3 { margin: 0; font-size: 14px; font-weight: 600; flex: 1; }
.legend { display: flex; gap: 14px; font-size: 12.5px; color: var(--muted); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 10px; height: 10px; border-radius: 2px; }
.legend-swatch.series-1, .tt-key.series-1 { background: var(--series-1); }
.legend-swatch.series-2, .tt-key.series-2 { background: var(--series-2); }
.chart-host { position: relative; width: 100%; }
.daily-chart { display: block; }
.daily-chart .chart-grid { stroke: var(--chart-grid); stroke-width: 1; }
.daily-chart .chart-baseline { stroke: var(--chart-axis); stroke-width: 1; }
.daily-chart .chart-tick { fill: var(--muted); font-size: 11px; font-variant-numeric: tabular-nums; }
.daily-chart path.series-1 { fill: var(--series-1); }
.daily-chart path.series-2 { fill: var(--series-2); }
.daily-chart .chart-hit { fill: transparent; outline: none; cursor: default; }
.daily-chart .chart-col.active path { filter: brightness(1.15); }
.daily-chart .chart-hit:focus-visible { stroke: var(--accent); stroke-width: 1; fill: color-mix(in srgb, var(--accent) 6%, transparent); }
.chart-tooltip { position: absolute; pointer-events: none; min-width: 140px; padding: 8px 10px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; box-shadow: var(--shadow); font-size: 12px; z-index: 5; }
.tt-head { color: var(--muted); }
.tt-total { font-size: 16px; font-weight: 650; margin: 2px 0 4px; }
.tt-row { display: flex; align-items: center; gap: 6px; }
.tt-row strong { font-variant-numeric: tabular-nums; }
.tt-row span:last-child { color: var(--muted); }
.tt-key { display: inline-block; width: 10px; height: 2px; border-radius: 1px; }
.tt-note { color: var(--muted); margin-top: 4px; }
.usage-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 16px; }
.usage-grid .usage-card { margin-bottom: 0; }
.usage-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.usage-table th { text-align: left; font-weight: 550; color: var(--muted); font-size: 12px; padding: 4px 6px; border-bottom: 1px solid var(--border); }
.usage-table td { padding: 6px; border-bottom: 1px solid var(--chart-grid); }
.usage-table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.usage-table.ranked .bar-cell { width: 34%; }
.rank-bar { display: block; height: 8px; border-radius: 0 4px 4px 0; background: var(--accent); }
.usage-empty { font-size: 13px; }
@media (max-width: 900px) { .kpis, .kpis.kpis-4 { grid-template-columns: repeat(2, 1fr); } .kpi.hero { grid-column: 1 / -1; } }

/* ---------- dialogs (services/dialog.js) ---------- */

.app-dialog { width: min(420px, calc(100vw - 32px)); padding: 0; border: 1px solid var(--border); border-radius: 14px;
  background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.app-dialog::backdrop { background: rgb(15 23 42 / .45); }
.app-dialog form { display: flex; flex-direction: column; gap: 12px; padding: 18px 20px 16px; }
.app-dialog-title { margin: 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.app-dialog-message { margin: 0; font-size: 14px; color: var(--muted); line-height: 1.45; }
.app-dialog-field { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.app-dialog-field input, .app-dialog-field textarea { resize: vertical; padding: 9px 11px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg);
  color: var(--text); font: inherit; font-size: 14px; }
.app-dialog-field input:focus, .app-dialog-field textarea:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
.app-dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
.app-dialog-actions .auth-button { width: auto; padding: 7px 16px; color: var(--text); }
.app-dialog-actions .auth-button.primary { color: #fff; }
.auth-button:disabled { opacity: .5; cursor: default; }
.auth-button.danger { background: var(--danger); border-color: transparent; color: var(--surface); }
.auth-button.danger:hover:not(:disabled) { background: var(--danger); filter: brightness(1.08); }
.ws-section-actions { display: inline-flex; gap: 2px; }

/* Workspace zip download: the choices (all files, or one folder) under the section's Zip button */
.ws-zip { position: relative; display: inline-flex; }
.ws-zip-menu { position: absolute; top: calc(100% + 4px); right: 0; z-index: 25; min-width: 220px; max-height: 50vh; overflow-y: auto;
  display: flex; flex-direction: column; padding: 4px; background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow); text-transform: none; letter-spacing: 0; font-weight: 400; }
.ws-zip-menu a { display: flex; justify-content: space-between; gap: 16px; padding: 7px 10px; border-radius: 6px; color: var(--text);
  text-decoration: none; font-size: 13px; }
.ws-zip-menu a:hover, .ws-zip-menu a:focus-visible { background: var(--hover); }

/* Workspace panel: a non-text file (image, PDF, Office…) */
.ws-binary { padding: 16px; display: flex; flex-direction: column; gap: 8px; align-items: flex-start; font-size: 13px; }
.ws-binary p { margin: 0; }
.ws-binary-image { max-width: 100%; max-height: 50vh; border-radius: 8px; border: 1px solid var(--border); }
.ws-uploading { margin: 8px 16px; font-size: 13px; }

/* Upload progress (phase 14.2): a thin bar under an attachment while it uploads */
.attachment { position: relative; }
.attachment-progress { position: absolute; left: 8px; right: 8px; bottom: 3px; height: 3px; border-radius: 2px; background: var(--border); overflow: hidden; }
.attachment-progress span { display: block; height: 100%; background: var(--accent); transition: width .2s; }
.ws-uploading { display: flex; align-items: center; gap: 8px; }

/* Phase 14.7: narrow screens */
/* File names: a long folder shrinks (ellipsis) before the file name does. */
.ws-file-name { display: flex; min-width: 0; }
.ws-file-folder { flex: 0 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.ws-file-base { flex: 0 0 auto; max-width: 100%; overflow: hidden; text-overflow: ellipsis; }
.ws-section-head .meta-button { white-space: nowrap; }
.project-tag-name { margin-left: 4px; }
@media (max-width: 600px) {
  .project-tag-name { display: none; }            /* the icon stays; the name is in its tooltip and the Files panel */
  .project-tag { padding: 4px 7px; }
  .ws-section-head { flex-wrap: wrap; gap: 2px 8px; }
}
.ws-path { display: flex; align-items: center; gap: 0; }
.ws-path .ws-scope-badge { flex-shrink: 0; margin-right: 6px; }
