/* Claude side panel — styled to match claude.ai: warm "paper" light theme (default) and a dark
   theme, coral accent, serif wordmark, prose-rendered assistant messages. Theme is chosen by JS,
   which sets data-theme="light"|"dark" on <html>; absent that, we follow the OS preference. */

/* ---- Light theme (default, warm paper) ---------------------------------- */
:root {
  --bg: #faf9f5;          /* app background, warm paper */
  --bg-raised: #ffffff;   /* cards, menus, composer */
  --bg-input: #ffffff;    /* text inputs */
  --bg-sunken: #f0eee6;   /* user bubble, subtle fills */
  --border: #e6e2d6;      /* hairlines */
  --border-strong: #d8d3c4;
  --text: #2b2a27;        /* primary ink */
  --text-dim: #73706a;    /* secondary */
  --text-faint: #a39f96;  /* tertiary, placeholders */
  --accent: #c96442;      /* coral / clay */
  --accent-hover: #b4583a;
  --accent-text: #ffffff;
  --accent-soft: #f4e9e3; /* accent-tinted fill */
  --danger: #c0392b;
  --code-bg: #f3f1ea;     /* inline code + code block chrome */
  --code-text: #2b2a27;
  /* syntax highlighting (highlight.js tokens) */
  --syn-comment: #8a8578; --syn-keyword: #9c3d2a; --syn-string: #3a7a4e;
  --syn-number: #8a5a1a; --syn-function: #2f6f9f; --syn-attr: #7a4ea8;
  --syn-type: #1f7a8c; --syn-literal: #9c3d2a;
  --shadow: 0 1px 2px rgba(40, 36, 28, 0.06), 0 8px 24px rgba(40, 36, 28, 0.08);
  --radius: 14px;
  --radius-sm: 9px;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Georgia, "Times New Roman", serif;
  --sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", "SFMono-Regular", Menlo, Consolas, "Liberation Mono", monospace;
  color-scheme: light;
}

/* ---- Dark theme --------------------------------------------------------- */
:root[data-theme="dark"] {
  --bg: #262624;
  --bg-raised: #30302e;
  --bg-input: #1f1e1d;
  --bg-sunken: #343431;
  --border: #3a3a37;
  --border-strong: #4a4a46;
  --text: #f5f4ee;
  --text-dim: #a6a39b;
  --text-faint: #76736c;
  --accent: #d97757;
  --accent-hover: #e4886a;
  --accent-text: #ffffff;
  --accent-soft: #3a2b24;
  --danger: #e5705f;
  --code-bg: #1f1e1d;
  --code-text: #f5f4ee;
  --syn-comment: #7d7a72; --syn-keyword: #e08a6a; --syn-string: #9ecb8a;
  --syn-number: #e0b36a; --syn-function: #86b8e0; --syn-attr: #c6a8e8;
  --syn-type: #7fd0d8; --syn-literal: #e08a6a;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

/* Follow OS preference only when JS has not pinned a theme. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --bg: #262624; --bg-raised: #30302e; --bg-input: #1f1e1d; --bg-sunken: #343431;
    --border: #3a3a37; --border-strong: #4a4a46;
    --text: #f5f4ee; --text-dim: #a6a39b; --text-faint: #76736c;
    --accent: #d97757; --accent-hover: #e4886a; --accent-soft: #3a2b24; --danger: #e5705f;
    --code-bg: #1f1e1d; --code-text: #f5f4ee;
    --syn-comment: #7d7a72; --syn-keyword: #e08a6a; --syn-string: #9ecb8a;
    --syn-number: #e0b36a; --syn-function: #86b8e0; --syn-attr: #c6a8e8;
    --syn-type: #7fd0d8; --syn-literal: #e08a6a;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

button { font-family: inherit; cursor: pointer; }
a { color: var(--accent); }

/* ---- Buttons ------------------------------------------------------------ */
.primary {
  background: var(--accent); color: var(--accent-text);
  border: none; border-radius: var(--radius-sm);
  padding: 10px 14px; font-size: 14px; font-weight: 600;
  transition: background 0.12s ease;
}
.primary:hover { background: var(--accent-hover); }
.primary:disabled { opacity: 0.5; cursor: default; }

.secondary {
  background: transparent; color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 7px 12px; font-size: 13px; font-weight: 500;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.secondary:hover { background: var(--bg-sunken); }

.ghost {
  background: transparent; color: var(--text-dim);
  border: none; border-radius: var(--radius-sm);
  padding: 7px 12px; font-size: 13px;
}
.ghost:hover { color: var(--text); background: var(--bg-sunken); }

.link-btn {
  background: none; border: none; color: var(--accent);
  padding: 6px; font-size: 13px; text-decoration: underline; text-underline-offset: 2px;
}
.link-btn:hover { color: var(--accent-hover); }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; padding: 0;
  background: transparent; color: var(--text-dim);
  border: none; border-radius: 8px; font-size: 18px; line-height: 1;
  transition: background 0.12s ease, color 0.12s ease;
}
.icon-btn:hover { background: var(--bg-sunken); color: var(--text); }
.icon-btn:focus-visible, button:focus-visible, a:focus-visible,
input:focus-visible, textarea:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

/* ---- Update bar --------------------------------------------------------- */
.update-bar {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; background: var(--accent-soft);
  border-bottom: 1px solid var(--border); font-size: 13px;
}
.update-text { flex: 1; color: var(--text); }
.update-btn {
  background: var(--accent); color: var(--accent-text); border: none;
  border-radius: 7px; padding: 5px 12px; font-size: 13px; font-weight: 600;
}
.update-btn:hover { background: var(--accent-hover); }
.update-dismiss { background: none; border: none; color: var(--text-dim); font-size: 18px; line-height: 1; padding: 2px 6px; }

/* ---- Login / enroll ----------------------------------------------------- */
.login {
  height: 100%; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: var(--bg);
}
.login-card {
  width: 100%; max-width: 360px;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 28px 24px; box-shadow: var(--shadow);
}
.login-title {
  font-family: var(--serif); font-weight: 500; font-size: 30px;
  margin: 0 0 4px; color: var(--text); letter-spacing: -0.01em;
}
.login-sub { margin: 0 0 20px; color: var(--text-dim); font-size: 14px; }
.login-form { display: flex; flex-direction: column; gap: 6px; }
.login-form label { font-size: 12px; font-weight: 600; color: var(--text-dim); margin-top: 8px; }
.login-form input {
  background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 10px 12px; font-size: 14px; font-family: inherit;
}
.login-form input::placeholder { color: var(--text-faint); }
.login-form .primary { margin-top: 14px; }
.login-error { color: var(--danger); font-size: 13px; margin: 10px 0 0; }
.login-hint { margin: 16px 0 0; color: var(--text-faint); font-size: 12px; line-height: 1.5; }

/* Enroll QR + secret */
.enroll-qr {
  display: flex; align-items: center; justify-content: center;
  background: #ffffff; border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px; margin: 4px 0 14px;
}
.enroll-qr svg { width: 180px; height: 180px; display: block; }
.enroll-secret-row { margin: 0 0 8px; }
.enroll-secret-label { font-size: 12px; color: var(--text-dim); }
.enroll-secret-line { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.enroll-secret {
  flex: 1; font-family: var(--mono); font-size: 13px; letter-spacing: 1px;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: 7px; padding: 8px 10px; word-break: break-all; color: var(--text);
}

/* ---- Chat shell --------------------------------------------------------- */
.chat { height: 100%; display: flex; flex-direction: column; position: relative; background: var(--bg); }

.topbar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 10px; border-bottom: 1px solid var(--border); background: var(--bg);
}
.brand { display: flex; align-items: center; gap: 7px; padding: 0 2px; }
.brand-mark { width: 20px; height: 20px; border-radius: 5px; display: block; }
.brand-name { font-family: var(--serif); font-size: 18px; font-weight: 500; letter-spacing: -0.01em; color: var(--text); }
.spacer { flex: 1; }

/* Model switcher (custom dropdown replacing the native <select>) */
.model-switch { position: relative; }
.model-btn {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; color: var(--text-dim);
  border: 1px solid transparent; border-radius: 8px;
  padding: 5px 8px; font-size: 13px; font-weight: 500; max-width: 180px;
  transition: background 0.12s ease, color 0.12s ease;
}
.model-btn:hover { background: var(--bg-sunken); color: var(--text); }
.model-btn-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.model-btn .chev { width: 14px; height: 14px; flex: none; opacity: 0.7; }
.model-menu {
  position: absolute; top: calc(100% + 4px); left: 0; z-index: 30;
  min-width: 240px; max-width: 300px; max-height: 60vh; overflow-y: auto;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 5px;
}
.model-option {
  display: flex; align-items: flex-start; gap: 8px; width: 100%;
  background: transparent; border: none; border-radius: 8px;
  padding: 8px 9px; text-align: left; color: var(--text);
}
.model-option:hover { background: var(--bg-sunken); }
.model-option .mo-check { width: 16px; height: 16px; flex: none; margin-top: 1px; color: var(--accent); visibility: hidden; }
.model-option[aria-selected="true"] .mo-check { visibility: visible; }
.model-option .mo-body { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.model-option .mo-name { font-size: 13px; font-weight: 600; }
.model-option .mo-id { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }

/* Account menu */
.account { position: relative; }
.account-menu {
  position: absolute; top: calc(100% + 4px); right: 0; z-index: 30;
  min-width: 220px; background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-sm); box-shadow: var(--shadow); padding: 8px;
}
.account-id { padding: 6px 8px 10px; border-bottom: 1px solid var(--border); margin-bottom: 6px; }
.acct-email { font-size: 13px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; }
.acct-plan { font-size: 12px; color: var(--text-dim); margin-top: 2px; }
.acct-plan.sync-error { color: var(--danger); }
.menu-item {
  display: flex; align-items: center; width: 100%; gap: 8px;
  background: transparent; border: none; border-radius: 7px;
  padding: 8px; font-size: 13px; color: var(--text); text-align: left;
}
.menu-item:hover { background: var(--bg-sunken); }
.menu-label { font-size: 11px; font-weight: 600; color: var(--text-faint); text-transform: uppercase; letter-spacing: 0.04em; padding: 4px 8px 2px; }
.theme-seg { display: flex; gap: 4px; padding: 2px 8px 6px; }
.theme-seg button {
  flex: 1; background: var(--bg-sunken); color: var(--text-dim);
  border: 1px solid var(--border); border-radius: 7px; padding: 6px 4px; font-size: 12px; font-weight: 500;
}
.theme-seg button[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

/* ---- Messages ----------------------------------------------------------- */
.messages { flex: 1; overflow-y: auto; padding: 16px 0; scroll-behavior: smooth; }
.empty-hint {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 10px; color: var(--text-dim); text-align: center; padding: 0 32px;
}
.empty-hint .eh-mark { width: 44px; height: 44px; opacity: 0.9; }
.empty-hint .eh-title { font-family: var(--serif); font-size: 22px; color: var(--text); font-weight: 500; }
.empty-hint .eh-sub { font-size: 13px; }

.msg { padding: 4px 16px; }
.msg .role {
  font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-faint); margin: 0 0 4px;
}
.msg.user { display: flex; justify-content: flex-end; }
.msg.user .bubble {
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: 16px 16px 4px 16px; padding: 10px 14px; max-width: 85%;
  white-space: pre-wrap; word-wrap: break-word; color: var(--text);
}
.msg.assistant { padding: 8px 16px 12px; }
.msg.assistant .bubble { max-width: 100%; color: var(--text); white-space: pre-wrap; word-wrap: break-word; }
.msg.assistant .bubble.error { color: var(--danger); white-space: normal; }
.cursor { display: inline-block; width: 7px; height: 1.1em; vertical-align: text-bottom; background: var(--accent); margin-left: 2px; border-radius: 1px; animation: blink 1s step-end infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Message action row (copy / regenerate) */
.msg-actions { display: flex; gap: 2px; margin-top: 6px; opacity: 0; transition: opacity 0.12s ease; }
.msg.assistant:hover .msg-actions, .msg-actions:focus-within { opacity: 1; }
.msg-action {
  display: inline-flex; align-items: center; gap: 5px;
  background: transparent; border: none; border-radius: 7px;
  padding: 4px 8px; font-size: 12px; color: var(--text-dim);
}
.msg-action:hover { background: var(--bg-sunken); color: var(--text); }
.msg-action svg { width: 14px; height: 14px; }

/* ---- Prose (assistant markdown, rendered by render.js) ------------------ */
/* white-space: normal, or the bubble's pre-wrap turns the newlines marked puts between block tags into blank lines. */
.prose { font-size: 14px; line-height: 1.65; color: var(--text); word-wrap: break-word; white-space: normal; }
.prose > :first-child { margin-top: 0; }
.prose > :last-child { margin-bottom: 0; }
.prose p { margin: 0 0 12px; }
.prose h1, .prose h2, .prose h3, .prose h4 { font-family: var(--serif); font-weight: 600; line-height: 1.3; margin: 20px 0 10px; color: var(--text); }
.prose h1 { font-size: 22px; }
.prose h2 { font-size: 19px; }
.prose h3 { font-size: 16px; }
.prose h4 { font-size: 14px; }
.prose ul, .prose ol { margin: 0 0 12px; padding-left: 22px; }
.prose li { margin: 3px 0; }
.prose li > ul, .prose li > ol { margin: 3px 0; }
.prose a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.prose blockquote { margin: 0 0 12px; padding: 2px 0 2px 14px; border-left: 3px solid var(--border-strong); color: var(--text-dim); }
.prose hr { border: none; border-top: 1px solid var(--border); margin: 18px 0; }
.prose code {
  font-family: var(--mono); font-size: 0.86em;
  background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 5px; padding: 1px 5px;
}
.prose pre {
  margin: 0 0 12px; background: var(--code-bg); border: 1px solid var(--border);
  border-radius: 10px; overflow: hidden;
}
.prose pre code { display: block; background: none; border: none; border-radius: 0; padding: 12px 14px; overflow-x: auto; font-size: 12.5px; line-height: 1.5; }
.prose table { border-collapse: collapse; margin: 0 0 12px; font-size: 13px; width: 100%; display: block; overflow-x: auto; }
.prose th, .prose td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.prose th { background: var(--bg-sunken); font-weight: 600; }

/* Code block chrome: language label + copy button */
.code-wrap { margin: 0 0 12px; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--code-bg); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 5px 10px 5px 12px; border-bottom: 1px solid var(--border); font-size: 11px; color: var(--text-dim); }
.code-lang { font-family: var(--mono); text-transform: lowercase; }
.code-copy { background: none; border: none; color: var(--text-dim); font-size: 11px; display: inline-flex; align-items: center; gap: 4px; padding: 2px 6px; border-radius: 6px; }
.code-copy:hover { background: var(--bg-sunken); color: var(--text); }
.code-wrap pre { margin: 0; border: none; border-radius: 0; background: none; }

/* highlight.js token theme (mapped to the active palette so it follows light/dark) */
.hljs { color: var(--code-text); background: none; }
.hljs-comment, .hljs-quote { color: var(--syn-comment); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-doctag, .hljs-section, .hljs-meta .hljs-keyword { color: var(--syn-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-meta-string { color: var(--syn-string); }
.hljs-number, .hljs-literal { color: var(--syn-number); }
.hljs-title, .hljs-title.function_, .hljs-function .hljs-title, .hljs-selector-id, .hljs-selector-class { color: var(--syn-function); }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable, .hljs-property { color: var(--syn-attr); }
.hljs-type, .hljs-built_in, .hljs-builtin-name, .hljs-class .hljs-title, .hljs-params { color: var(--syn-type); }
.hljs-symbol, .hljs-bullet, .hljs-link, .hljs-name, .hljs-tag { color: var(--syn-literal); }
.hljs-meta, .hljs-comment { opacity: 0.95; }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }
.hljs-deletion { color: var(--danger); }

/* ---- Composer ----------------------------------------------------------- */
.composer { padding: 10px 12px 14px; border-top: 1px solid var(--border); background: var(--bg); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.chip {
  display: flex; align-items: center; gap: 6px; max-width: 100%;
  background: var(--bg-sunken); border: 1px solid var(--border);
  border-radius: 9px; padding: 5px 7px 5px 9px; font-size: 12px; color: var(--text);
}
.chip .chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 150px; }
.chip .chip-meta { color: var(--text-faint); }
.chip .chip-x { background: none; border: none; color: var(--text-dim); font-size: 15px; line-height: 1; padding: 0 2px; }
.chip .chip-x:hover { color: var(--text); }
.chip.warn { border-color: var(--danger); color: var(--danger); }
.msg-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; justify-content: flex-end; }

.composer-box {
  display: flex; align-items: flex-end; gap: 6px;
  background: var(--bg-input); border: 1px solid var(--border-strong);
  border-radius: var(--radius); padding: 6px 6px 6px 8px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.composer-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.composer-box .icon-btn { flex: none; }
.input {
  flex: 1; resize: none; max-height: 200px;
  background: transparent; color: var(--text); border: none;
  padding: 7px 2px; font-size: 14px; font-family: inherit; line-height: 1.5;
}
.input:focus { outline: none; }
.input::placeholder { color: var(--text-faint); }
.send {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; background: var(--accent); color: var(--accent-text);
  border: none; border-radius: 10px; transition: background 0.12s ease;
}
.send:hover { background: var(--accent-hover); }
.send:disabled { opacity: 0.4; cursor: default; }
.send.stop { background: var(--bg-sunken); color: var(--text); }

.composer-tools { display: flex; align-items: center; gap: 10px; margin-top: 8px; padding: 0 2px; }
.sandbox-toggle { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-dim); cursor: pointer; }
.sandbox-toggle input { accent-color: var(--accent); }

.composer-error { color: var(--danger); font-size: 12px; margin-top: 8px; }

/* Supported-types disclosure */
.supported { margin-top: 8px; font-size: 12px; }
.supported-summary { color: var(--text-dim); cursor: pointer; list-style: none; user-select: none; }
.supported-summary::-webkit-details-marker { display: none; }
.supported-summary::before { content: "▸ "; color: var(--text-faint); }
.supported[open] .supported-summary::before { content: "▾ "; }
.supported-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.supported-group-label { font-weight: 600; color: var(--text); }
.supported-group-exts { color: var(--text-dim); font-family: var(--mono); font-size: 11px; word-break: break-word; }

/* ---- Sandbox dialog ----------------------------------------------------- */
.sandbox-dialog {
  position: absolute; left: 12px; right: 12px; bottom: 90px; z-index: 20;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px;
}
.sandbox-head { font-weight: 600; margin-bottom: 8px; }
.sandbox-code {
  width: 100%; resize: vertical; background: var(--bg-input); color: var(--text);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  padding: 10px; font-family: var(--mono); font-size: 12px;
}
.sandbox-result {
  margin-top: 8px; background: var(--code-bg); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 8px 10px; font-family: var(--mono);
  font-size: 12px; white-space: pre-wrap; max-height: 140px; overflow-y: auto;
}
.sandbox-result.err { color: var(--danger); }
.sandbox-actions { display: flex; gap: 8px; margin-top: 10px; }

/* ---- History drawer ----------------------------------------------------- */
.history-drawer {
  position: absolute; inset: 0; z-index: 25; display: flex; flex-direction: column;
  background: var(--bg);
}
.history-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.history-title { font-family: var(--serif); font-size: 17px; font-weight: 500; }
.history-note {
  margin: 10px 12px 0; padding: 8px 10px; border-radius: var(--radius-sm);
  background: var(--accent-soft); color: var(--text); font-size: 12px;
}
.history-note.err { background: var(--code-bg); color: var(--danger); }
.history-list { flex: 1; overflow-y: auto; padding: 8px; }
.history-row {
  display: flex; align-items: center; gap: 4px; border-radius: var(--radius-sm);
}
.history-row:hover { background: var(--bg-sunken); }
.history-row.active { background: var(--accent-soft); }
.history-open {
  flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px;
  background: transparent; border: none; border-radius: var(--radius-sm);
  padding: 10px; text-align: left; color: var(--text);
}
.history-row-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-row-meta { font-size: 11px; color: var(--text-faint); }
.history-del { background: none; border: none; color: var(--text-faint); font-size: 16px; line-height: 1; padding: 6px 8px; margin-right: 4px; border-radius: 6px; }
.history-del:hover { color: var(--danger); background: var(--bg); }
.history-empty { color: var(--text-dim); text-align: center; padding: 40px 20px; font-size: 13px; }

/* ---- Drag-and-drop overlay ---------------------------------------------- */
.drop-overlay {
  position: absolute; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--bg) 80%, transparent); backdrop-filter: blur(2px);
}
.drop-inner {
  border: 2px dashed var(--accent); border-radius: var(--radius);
  padding: 28px 40px; color: var(--accent); font-weight: 600; background: var(--accent-soft);
}

/* ---- Artifact inline card (in the assistant message) -------------------- */
.artifact-card {
  display: flex; align-items: center; gap: 10px; width: 100%;
  margin: 4px 0 12px; padding: 10px 12px; text-align: left;
  background: var(--bg-raised); border: 1px solid var(--border);
  border-radius: var(--radius-sm); color: var(--text);
  transition: border-color 0.12s ease, background 0.12s ease;
}
.artifact-card:hover { border-color: var(--border-strong); background: var(--bg-sunken); }
.artifact-card .ac-icon {
  flex: none; display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 8px;
  background: var(--accent-soft); color: var(--accent);
}
.artifact-card .ac-icon svg { width: 17px; height: 17px; }
.artifact-card .ac-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.artifact-card .ac-title { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artifact-card .ac-sub { font-size: 11px; color: var(--text-faint); }
.artifact-card .ac-open { flex: none; color: var(--text-faint); display: inline-flex; }
.artifact-card .ac-open svg { width: 16px; height: 16px; }
.artifact-card.streaming { opacity: 0.75; }

/* ---- Artifact panel (slide-over) ---------------------------------------- */
.artifact-panel {
  position: absolute; inset: 0; z-index: 35; display: flex; flex-direction: column;
  background: var(--bg);
}
.artifact-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.artifact-head-text { flex: 1; min-width: 0; }
.artifact-title { font-family: var(--serif); font-size: 16px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artifact-sub { font-size: 11px; color: var(--text-faint); font-family: var(--mono); }
.artifact-toolbar { display: flex; align-items: center; gap: 6px; padding: 8px 12px; border-bottom: 1px solid var(--border); }
.artifact-tabs { display: inline-flex; gap: 2px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: 8px; padding: 2px; }
.artifact-tab {
  background: transparent; border: none; border-radius: 6px;
  padding: 4px 12px; font-size: 12px; font-weight: 500; color: var(--text-dim);
}
.artifact-tab[aria-selected="true"] { background: var(--bg-raised); color: var(--text); box-shadow: var(--shadow); }
.artifact-versions { display: inline-flex; align-items: center; gap: 2px; }
.artifact-versions .icon-btn { width: 26px; height: 26px; font-size: 16px; }
.artifact-ver-label { font-size: 12px; color: var(--text-dim); min-width: 24px; text-align: center; font-family: var(--mono); }
.artifact-body { flex: 1; min-height: 0; overflow: hidden; display: flex; }
.artifact-preview-wrap { flex: 1; min-height: 0; background: #fff; }
.artifact-frame { width: 100%; height: 100%; border: none; display: block; background: #fff; }
.artifact-code-wrap { flex: 1; min-height: 0; overflow: auto; padding: 12px; }
.artifact-code-wrap .code-wrap { margin: 0; }

/* Account-menu switch row (computer-use toggle). */
.menu-switch { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 6px 8px 8px; cursor: pointer; }
.menu-switch-text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.menu-switch-title { font-size: 13px; color: var(--text); }
.menu-switch-sub { font-size: 11px; color: var(--text-dim); }
.menu-switch input { accent-color: var(--accent); flex: none; width: 15px; height: 15px; }

/* Computer-use step cards inside an assistant message. */
.cua-step { margin-top: 8px; padding: 8px 10px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-sunken); }
.cua-action { font-size: 12px; font-weight: 500; color: var(--text-dim); }
.cua-result { margin-top: 6px; font-size: 12px; }
.cua-result.ok { color: var(--text-faint); }
.cua-result.err { color: var(--danger, #c0392b); white-space: pre-wrap; word-break: break-word; }
.cua-confirm { margin-top: 8px; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }
.cua-confirm p { flex-basis: 100%; margin: 0; font-size: 13px; color: var(--text); word-break: break-word; }
.cua-confirm button { padding: 5px 12px; font-size: 13px; }
.cua-shot { display: block; margin-top: 6px; max-width: 100%; height: auto; border: 1px solid var(--border); border-radius: 8px; }
.cua-details { margin-top: 6px; font-size: 12px; color: var(--text-dim); }
.cua-details summary { cursor: pointer; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cua-details summary:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
.cua-details pre { margin: 6px 0 0; max-height: 240px; overflow: auto; padding: 6px 8px; border-radius: 6px; background: var(--bg); font-size: 11px; white-space: pre-wrap; word-break: break-word; }

/* ---- Projects (drawer section + editor + list header) ------------------- */
.projects-section { border-bottom: 1px solid var(--border); padding: 8px; }
.projects-head { display: flex; align-items: center; gap: 8px; padding: 2px 4px 8px; }
.projects-title { flex: 1; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-dim); }
.projects-empty { color: var(--text-dim); font-size: 12px; padding: 4px 6px 8px; }
.project-row { display: flex; align-items: center; gap: 4px; border-radius: var(--radius-sm); }
.project-row:hover { background: var(--bg-sunken); }
.project-row.active { background: var(--accent-soft); }
.project-open {
  flex: 1; min-width: 0; display: flex; align-items: baseline; gap: 8px;
  background: transparent; border: none; border-radius: var(--radius-sm);
  padding: 8px 10px; text-align: left; color: var(--text);
}
.project-name { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-meta { font-size: 11px; color: var(--text-faint); flex: none; }
.project-edit { background: none; border: none; color: var(--text-faint); font-size: 12px; padding: 6px 8px; border-radius: 6px; }
.project-edit:hover { color: var(--text); background: var(--bg); }
.project-del { background: none; border: none; color: var(--text-faint); font-size: 16px; line-height: 1; padding: 6px 8px; margin-right: 4px; border-radius: 6px; }
.project-del:hover { color: var(--danger); background: var(--bg); }
.project-editor { display: flex; flex-direction: column; gap: 6px; padding: 8px; margin: 0 0 8px; background: var(--bg-sunken); border: 1px solid var(--border); border-radius: var(--radius-sm); }
.project-editor label { font-size: 11px; font-weight: 600; color: var(--text-dim); }
.project-editor input, .project-editor textarea {
  background: var(--bg-input); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm); padding: 8px 10px; font: inherit; font-size: 13px; resize: vertical;
}
.project-editor-hint { font-size: 11px; color: var(--text-faint); }
.project-editor-actions { display: flex; gap: 8px; margin-top: 2px; }

.history-list-head { display: flex; align-items: center; gap: 8px; padding: 4px 6px 8px; }
.history-list-title { flex: 1; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--text-dim); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.history-move { background: none; border: none; color: var(--text-faint); font-size: 11px; padding: 6px 8px; border-radius: 6px; }
.history-move:hover { color: var(--text); background: var(--bg); }
.history-move-select {
  background: var(--bg-input); color: var(--text); border: 1px solid var(--border-strong);
  border-radius: 6px; padding: 4px 6px; font: inherit; font-size: 12px; margin-right: 4px; max-width: 140px;
}

/* ---- Project bar (above the composer) ----------------------------------- */
.project-bar {
  display: flex; align-items: center; gap: 8px; margin: 0 0 6px;
  padding: 5px 6px 5px 10px; background: var(--accent-soft);
  border: 1px solid var(--border); border-radius: 999px;
}
.project-bar-dot { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--accent); }
.project-bar-name { flex: 1; min-width: 0; font-size: 12px; font-weight: 600; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-bar-clear { flex: none; background: none; border: none; color: var(--text-faint); font-size: 15px; line-height: 1; padding: 2px 6px; border-radius: 6px; }
.project-bar-clear:hover { color: var(--danger); background: var(--bg); }

/* Must stay last: beats any display rule above. */
[hidden] { display: none !important; }
