/* claude-chat: claude.ai-like look (PRD-nostr §10, N11). Light ("ivory") and dark (warm
   charcoal) themes, a muted clay accent. System by default; <html data-theme="light|dark">
   (theme.js, theme-boot.js) forces one. Every colour is a custom property below. System font
   stacks only, no third-party fonts or logos. */

:root {
  color-scheme: light dark;
  --bg: #faf9f5;
  --bg-elev: #ffffff;
  --bg-side: #f5f4ed;
  --bg-hover: rgba(31, 30, 29, 0.06);
  --bg-active: rgba(31, 30, 29, 0.1);
  --bg-user: #f0eee6;
  --bg-code: #f5f4ef;
  --fg: #141413;
  --fg-soft: #3d3d3a;
  --fg-muted: #6f6e68;
  --border: rgba(31, 30, 29, 0.15);
  --border-strong: rgba(31, 30, 29, 0.3);
  --accent: #c6613f;
  --accent-fg: #ffffff;
  --danger: #b3261e;
  --warn: #8a5a00;
  --info: #2f5f8a;
  --focus: #2c84db;
  --radius: 12px;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
  --shadow-card: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.04), 0 0 0 0.5px rgba(31, 30, 29, 0.08);
  --side-w: 288px;
  --column: 48rem;
  --touch: 44px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --serif: ui-serif, "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, serif;
  --mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

/* Dark: the same block twice, for "system" on a dark device and for the forced choice. */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #262624;
    --bg-elev: #30302e;
    --bg-side: #1f1e1d;
    --bg-hover: rgba(250, 249, 245, 0.06);
    --bg-active: rgba(250, 249, 245, 0.1);
    --bg-user: #141413;
    --bg-code: #1f1e1d;
    --fg: #faf9f5;
    --fg-soft: #c3c2b7;
    --fg-muted: #9c9a92;
    --border: rgba(222, 220, 209, 0.15);
    --border-strong: rgba(222, 220, 209, 0.3);
    --accent: #d97757;
    --accent-fg: #1f1e1d;
    --danger: #f2756a;
    --warn: #e5b45a;
    --info: #8cb8e6;
    --focus: #79a6f2;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
    --shadow-card: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.2), 0 0 0 0.5px rgba(222, 220, 209, 0.1);
  }
}
:root[data-theme="dark"] {
  color-scheme: dark;
  --bg: #262624;
  --bg-elev: #30302e;
  --bg-side: #1f1e1d;
  --bg-hover: rgba(250, 249, 245, 0.06);
  --bg-active: rgba(250, 249, 245, 0.1);
  --bg-user: #141413;
  --bg-code: #1f1e1d;
  --fg: #faf9f5;
  --fg-soft: #c3c2b7;
  --fg-muted: #9c9a92;
  --border: rgba(222, 220, 209, 0.15);
  --border-strong: rgba(222, 220, 209, 0.3);
  --accent: #d97757;
  --accent-fg: #1f1e1d;
  --danger: #f2756a;
  --warn: #e5b45a;
  --info: #8cb8e6;
  --focus: #79a6f2;
  --shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
  --shadow-card: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.2), 0 0 0 0.5px rgba(222, 220, 209, 0.1);
}
:root[data-theme="light"] { color-scheme: light; }

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.55 var(--font);
  -webkit-text-size-adjust: 100%;
  overflow: hidden;
}
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.muted { color: var(--fg-muted); }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }


/* ---- buttons ---- */
.btn {
  min-height: var(--touch);
  padding: 0 16px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  cursor: pointer;
}
.btn:hover { background: var(--bg-hover); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-fg); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.danger-btn { background: var(--danger); border-color: var(--danger); color: #fff; }
.icon-btn {
  min-width: var(--touch);
  min-height: var(--touch);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 10px;
  background: transparent;
  cursor: pointer;
  font-size: 18px;
}
.icon-btn:hover { background: var(--bg-hover); }


/* ---- icons: CSS masks of small inline SVGs (data: images, img-src allows them); they take
   the text colour ---- */
.ico {
  display: inline-block;
  flex: none;
  width: 20px;
  height: 20px;
  background-color: currentColor;
  -webkit-mask: var(--ico) center / contain no-repeat;
  mask: var(--ico) center / contain no-repeat;
}
.ico-plus, .ico-plus-small { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M12 5v14M5 12h14'/%3E%3C/svg%3E"); }
.ico-close { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E"); }
.ico-sidebar { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'%3E%3Crect x='3' y='4' width='18' height='16' rx='3'/%3E%3Cpath d='M9.5 4v16'/%3E%3C/svg%3E"); }
.ico-search { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E"); }
.ico-more { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='black'%3E%3Ccircle cx='5' cy='12' r='1.8'/%3E%3Ccircle cx='12' cy='12' r='1.8'/%3E%3Ccircle cx='19' cy='12' r='1.8'/%3E%3C/svg%3E"); }
.ico-chats { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'%3E%3Cpath d='M4 5h16v11H9l-5 4z'/%3E%3C/svg%3E"); }
.ico-folder { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'%3E%3Cpath d='M3 7a2 2 0 0 1 2-2h4l2 2h8a2 2 0 0 1 2 2v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3C/svg%3E"); }
.ico-settings { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Cpath d='M4 7h10M18 7h2M4 17h4M12 17h8'/%3E%3Ccircle cx='16' cy='7' r='2'/%3E%3Ccircle cx='10' cy='17' r='2'/%3E%3C/svg%3E"); }
.ico-theme-system { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8'%3E%3Ccircle cx='12' cy='12' r='8'/%3E%3Cpath d='M12 4a8 8 0 0 1 0 16z' fill='black'/%3E%3C/svg%3E"); }
.ico-theme-light { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Ccircle cx='12' cy='12' r='4'/%3E%3Cpath d='M12 2v2M12 20v2M2 12h2M20 12h2M4.9 4.9l1.4 1.4M17.7 17.7l1.4 1.4M4.9 19.1l1.4-1.4M17.7 6.3l1.4-1.4'/%3E%3C/svg%3E"); }
.ico-theme-dark { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'%3E%3Cpath d='M20 14.5A8 8 0 1 1 9.5 4a6.5 6.5 0 0 0 10.5 10.5z'/%3E%3C/svg%3E"); }
.ico-attach { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M20 11.5l-8.2 8.2a5 5 0 0 1-7.1-7.1l8.5-8.5a3.3 3.3 0 0 1 4.7 4.7l-8.5 8.5a1.7 1.7 0 0 1-2.4-2.4L15 7'/%3E%3C/svg%3E"); }
.ico-camera { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'%3E%3Cpath d='M4 8h3l2-3h6l2 3h3v11H4z'/%3E%3Ccircle cx='12' cy='13' r='3.5'/%3E%3C/svg%3E"); }
.ico-mic { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Crect x='9' y='3' width='6' height='11' rx='3'/%3E%3Cpath d='M5 11a7 7 0 0 0 14 0M12 18v3'/%3E%3C/svg%3E"); }
.ico-stop { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Crect x='7' y='7' width='10' height='10' rx='1.5' fill='black'/%3E%3C/svg%3E"); }
.ico-send { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 19V5M6 11l6-6 6 6'/%3E%3C/svg%3E"); }
.ico-new { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4H6a2 2 0 0 0-2 2v12a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2v-6'/%3E%3Cpath d='M17.5 3.5a2.1 2.1 0 0 1 3 3L12 15l-4 1 1-4z'/%3E%3C/svg%3E"); }
.ico-copy { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'%3E%3Crect x='8' y='8' width='12' height='12' rx='2'/%3E%3Cpath d='M16 8V6a2 2 0 0 0-2-2H6a2 2 0 0 0-2 2v8a2 2 0 0 0 2 2h2'/%3E%3C/svg%3E"); }
.ico-download { --ico: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M12 4v11M7 10l5 5 5-5M5 20h14'/%3E%3C/svg%3E"); }
.ico-plus-small { width: 16px; height: 16px; }

/* ---- layout: sidebar | main (centred column) | artifact panel ---- */
.app {
  display: flex;
  height: 100dvh;
  padding-top: env(safe-area-inset-top);
  padding-left: env(safe-area-inset-left);
  padding-right: env(safe-area-inset-right);
}
.sidebar {
  position: fixed;
  z-index: 30;
  inset: 0 auto 0 0;
  width: min(86vw, var(--side-w));
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: calc(8px + env(safe-area-inset-top)) 8px calc(8px + env(safe-area-inset-bottom)) calc(8px + env(safe-area-inset-left));
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  transform: translateX(-102%);
  transition: transform 0.2s ease;
  font-size: 14px;
}
.drawer-open .sidebar { transform: none; box-shadow: var(--shadow); }
.scrim { position: fixed; inset: 0; z-index: 20; background: rgba(0, 0, 0, 0.35); }
.side-head { display: flex; align-items: center; gap: 4px; min-height: 44px; padding-left: 8px; }
.brand { flex: 1; font-family: var(--serif); font-size: 19px; font-weight: 600; letter-spacing: -0.01em; color: var(--fg); }
.new-chat {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  padding: 0 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--fg);
  font-weight: 600;
  cursor: pointer;
  text-align: left;
}
.new-chat:hover { background: var(--bg-hover); }
.new-chat-plus {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-fg);
}
.new-chat-plus .ico { width: 16px; height: 16px; }
.search-wrap { position: relative; display: flex; align-items: center; }
.search-wrap .ico { position: absolute; left: 10px; width: 16px; height: 16px; color: var(--fg-muted); pointer-events: none; }
.search {
  width: 100%;
  min-height: 36px;
  padding: 0 10px 0 32px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  font-size: 14px;
}
.search:focus { border-color: var(--border-strong); outline: none; }
.search:focus-visible { outline: 2px solid var(--focus); outline-offset: 1px; }
.side-nav { flex: 1; min-height: 0; overflow-y: auto; margin: 4px -4px 0; padding: 0 4px; }
.side-section { margin-bottom: 8px; }
.side-heading { margin: 0; padding: 12px 8px 4px; font-size: 12px; font-weight: 500; color: var(--fg-muted); }
.chat-list, .project-side-list { list-style: none; margin: 0; padding: 0; }
.list-empty { padding: 8px; }
.chat-item { position: relative; display: flex; align-items: center; border-radius: 8px; }
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active { background: var(--bg-active); }
.chat-link {
  flex: 1;
  min-width: 0;
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 8px;
  color: var(--fg-soft);
  text-decoration: none;
}
.chat-item.active .chat-link { color: var(--fg); }
.chat-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-more { min-width: 30px; min-height: 30px; margin-right: 2px; opacity: 0; color: var(--fg-muted); }
.chat-more .ico { width: 16px; height: 16px; }
.chat-item:hover .chat-more, .chat-item.active .chat-more, .chat-more:focus-visible, .chat-more[aria-expanded="true"] { opacity: 1; }
.chat-proj-tag { flex: none; max-width: 40%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 11px; padding: 1px 6px; border-radius: 6px; background: var(--bg-hover); color: var(--fg-muted); font-weight: 400; }
.project-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  min-height: 34px;
  padding: 0 8px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--fg-soft);
  text-align: left;
  text-decoration: none;
  cursor: pointer;
}
.project-item .ico { width: 16px; height: 16px; color: var(--fg-muted); }
.project-item:hover { background: var(--bg-hover); }
.project-item[aria-pressed="true"] { background: var(--bg-active); color: var(--fg); font-weight: 500; }
.project-item[data-project=""][aria-pressed="true"] { background: transparent; }
.project-item[data-project=""][aria-pressed="true"]:hover { background: var(--bg-hover); }
.project-item-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.project-all { color: var(--fg-muted); }
.side-foot { display: flex; align-items: center; gap: 4px; padding: 8px 0 0 4px; border-top: 1px solid var(--border); }
.avatar {
  display: inline-flex;
  flex: none;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--fg-soft);
  color: var(--bg);
  font-size: 13px;
  font-weight: 600;
}
.side-foot .me { flex: 1; min-width: 0; padding-left: 4px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.settings-link { color: inherit; text-decoration: none; }

.main { flex: 1; min-width: 0; display: flex; flex-direction: column; background: var(--bg); }
.topbar {
  display: flex;
  align-items: center;
  gap: 4px;
  min-height: 52px;
  padding: 4px 8px;
}
.topbar .chat-title { flex: 0 1 auto; padding: 0 6px; }
.chat-title { margin: 0; min-width: 0; font-size: 15px; font-weight: 500; color: var(--fg-soft); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-project {
  flex: none;
  max-width: 40%;
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 12px;
  color: var(--fg-muted);
  text-decoration: none;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-cost { flex: none; margin-left: auto; padding: 0 4px; font-size: 13px; color: var(--fg-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.topbar-new { margin-left: auto; }
.chat-cost:not([hidden]) + .topbar-new { margin-left: 0; }
.open-side { display: none; }

/* phone: drawer; desktop: a fixed column that can collapse */
@media (max-width: 799px) {
  .only-wide { display: none !important; }
  .open-side { display: inline-flex; }
  .topbar { border-bottom: 1px solid var(--border); }
  .topbar .chat-title { flex: 1; text-align: center; }
  .composer-reason { display: none; } /* the placeholder and the status line say it */
}
@media (min-width: 800px) {
  .sidebar { position: static; transform: none; width: var(--side-w); flex: 0 0 var(--side-w); }
  .scrim, .only-narrow { display: none !important; }
  .side-collapsed .sidebar { display: none; }
  .side-collapsed .open-side { display: inline-flex; }
}

/* ---- banners ---- */
.banners { display: flex; flex-direction: column; gap: 6px; padding: 0 12px; }
.banners:not(:empty) { padding-top: 8px; }
.banner {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: var(--column);
  width: 100%;
  margin: 0 auto;
  padding: 4px 4px 4px 14px;
  border-radius: 10px;
  border: 1px solid var(--danger);
  color: var(--danger);
  background: var(--bg-elev);
}
.banner.info { border-color: var(--info); color: var(--info); }
.banner-text { flex: 1; }
.banner a { color: inherit; }


/* ---- status line (status.js) ---- */
.status-line {
  display: flex;
  align-items: center;
  gap: 8px;
  width: calc(100% - 24px);
  max-width: var(--column);
  margin: 8px auto 0;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  color: var(--fg-soft);
  font-size: 14px;
}
.status-line::before { content: ""; flex: none; width: 8px; height: 8px; border-radius: 50%; background: var(--fg-muted); }
.status-line.info::before { background: var(--info); animation: pulse 1.4s ease-in-out infinite; }
.status-line.warn { border-color: color-mix(in srgb, var(--warn) 45%, transparent); }
.status-line.warn::before { background: var(--warn); }
.status-line.error { border-color: var(--danger); color: var(--danger); }
.status-line.error::before { background: var(--danger); }
.status-line.status-degraded::before { animation: none; background: var(--warn); }
@keyframes pulse { 50% { opacity: 0.3; } }

/* ---- transcript: a centred column ---- */
.transcript { flex: 1; overflow-y: auto; overscroll-behavior: contain; }
.column { max-width: var(--column); margin: 0 auto; padding: 16px 16px 32px; min-height: 100%; display: flex; flex-direction: column; }
.messages { display: flex; flex-direction: column; gap: 24px; }
.empty-state { flex: 1; display: flex; align-items: center; justify-content: center; min-height: 40vh; }
.hello { margin: 0; font-family: var(--serif); font-size: clamp(26px, 5vw, 36px); font-weight: 400; color: var(--fg-soft); text-align: center; }
.hello-mark { display: none; }
.msg { min-width: 0; }
.msg.user { align-self: flex-end; max-width: 85%; }
.msg.user .bubble { background: var(--bg-user); border-radius: 18px; padding: 10px 16px; }
.user-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.atts { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 6px; margin-bottom: 6px; }
.atts .svg-figure { margin: 0; }
.att-thumb img { display: block; max-width: 180px; max-height: 180px; border-radius: 10px; }
.att-svg { margin: 0; }
.msg.assistant { min-width: 0; line-height: 1.65; color: var(--fg); }
.msg-status { font-size: 13px; color: var(--fg-muted); margin-top: 4px; }
.msg-status.error { color: var(--danger); }

/* ---- reply usage footer (model, tokens, cost); tap to expand ---- */
.usage-foot { margin-top: 2px; font-size: 12px; color: var(--fg-muted); }
.usage-foot summary { cursor: pointer; list-style: none; display: inline-flex; align-items: center; min-height: 32px; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.usage-foot summary::-webkit-details-marker { display: none; }
.usage-foot summary:hover { color: var(--fg); }
.usage-breakdown { display: grid; grid-template-columns: max-content 1fr; gap: 2px 12px; margin: 0 0 6px; padding: 8px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elev); }
.usage-breakdown dt { margin: 0; }
.usage-breakdown dd { margin: 0; color: var(--fg); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.hide-usage .usage-foot, .hide-usage .chat-cost { display: none !important; }
.toggle-row { display: flex; align-items: center; gap: 10px; min-height: var(--touch); cursor: pointer; }
.toggle-row input { width: 20px; height: 20px; margin: 0; flex: none; }
.msg.streaming .md > :last-child::after {
  content: "";
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 2px;
  vertical-align: text-bottom;
  background: var(--accent);
  animation: blink 1s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0; } }

.thinking { margin-bottom: 8px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg-elev); }
.thinking summary { cursor: pointer; padding: 8px 12px; color: var(--fg-muted); font-size: 14px; min-height: var(--touch); display: flex; align-items: center; gap: 6px; list-style: none; }
.thinking summary::-webkit-details-marker { display: none; }
.thinking summary::before { content: "\25B8"; transition: transform 0.15s; }
.thinking[open] summary::before { transform: rotate(90deg); }
.thinking-body { padding: 0 12px 10px; white-space: pre-wrap; font-size: 14px; color: var(--fg-muted); max-height: 40vh; overflow-y: auto; }

/* ---- per-message actions (⋮ button, long-press menu, select mode) ---- */
.msg-tools { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.msg.user .msg-tools { justify-content: flex-end; }
.msg-more { min-width: 32px; min-height: 32px; color: var(--fg-muted); opacity: 0.6; }
.msg-more:hover, .msg-more:focus-visible, .msg-more[aria-expanded="true"] { opacity: 1; }
.msg-select-hint { font-size: 13px; color: var(--fg-muted); }
.msg.selecting { outline: 2px dashed var(--focus); outline-offset: 6px; border-radius: 4px; }
/* Labels and buttons never end up in a selection or a copied text. */
.msg-tools, .code-head, .svg-figure figcaption, .thinking summary { -webkit-user-select: none; user-select: none; }

/* ---- rendered markdown ---- */
.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md a[href] { color: var(--accent); }
.md table { border-collapse: collapse; display: block; overflow-x: auto; max-width: 100%; margin: 12px 0; }
.md th, .md td { border: 1px solid var(--border); padding: 6px 10px; text-align: left; }
.md th { background: var(--bg-hover); }
.md blockquote { margin: 8px 0; padding-left: 12px; border-left: 3px solid var(--border); color: var(--fg-muted); }
.md :not(pre) > code { font-family: var(--mono); font-size: 0.9em; padding: 1px 5px; border-radius: 5px; background: var(--bg-code); }
.md img.md-img { max-width: 100%; border-radius: 8px; }
.blocked-img { font-size: 14px; color: var(--fg-muted); border: 1px dashed var(--border); border-radius: 6px; padding: 0 6px; text-decoration: none; }
.task-box { font-family: var(--mono); }
.code-block { margin: 12px 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--bg-code); }
.code-head { display: flex; align-items: center; justify-content: space-between; padding: 2px 4px 2px 12px; font-size: 12px; color: var(--fg-muted); border-bottom: 1px solid var(--border); }
.code-actions { display: flex; gap: 6px; }
.copy-btn, .svg-source-toggle, .preview-btn, .artifact-btn {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  font-size: 12px;
  cursor: pointer;
}
.md pre, .svg-source { margin: 0; overflow-x: auto; }
.md pre code.hljs, .svg-source code.hljs { display: block; padding: 12px; font: 13.5px/1.5 var(--mono); background: transparent; }
.svg-figure { margin: 12px 0; }
.svg-img { display: block; max-width: 100%; max-height: 70vh; background: #fff; border: 1px solid var(--border); border-radius: 8px; }
.svg-figure figcaption { margin-top: 6px; }
.svg-source { margin-top: 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-code); }

/* ---- live preview (preview.js): a dialog on wide screens, full screen on phones ---- */
.preview-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(0, 0, 0, 0.5);
}
.preview-panel {
  display: flex;
  flex-direction: column;
  width: min(1000px, 100%);
  max-height: 100%;
  background: var(--bg-elev);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.preview-bar { display: flex; align-items: center; gap: 8px; padding: 6px 8px 6px 14px; border-bottom: 1px solid var(--border); }
.preview-title { font-weight: 600; }
.preview-note { flex: 1; font-size: 12px; color: var(--fg-muted); }
.preview-source-toggle, .preview-close {
  min-height: var(--touch);
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-elev);
  cursor: pointer;
}
.preview-close { font-weight: 600; }
.preview-body { flex: 1; min-height: 0; overflow: auto; display: flex; flex-direction: column; }
.preview-frame {
  display: block;
  flex: none;
  width: 100%;
  height: var(--preview-h, 60vh);
  max-height: calc(100vh - 120px);
  border: 0;
  background: #fff;
}
.preview-source { margin: 0; overflow: auto; background: var(--bg-code); }
.preview-source code { display: block; padding: 12px; font: 13px/1.5 var(--mono); white-space: pre; }
.preview-error { padding: 24px; color: var(--fg-muted); }
@media (max-width: 799px) {
  .preview-overlay { padding: 0; }
  .preview-panel {
    width: 100%;
    height: 100%;
    max-height: none;
    border-radius: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  .preview-note { display: none; }
  .preview-title { flex: 1; }
  .preview-frame { flex: 1; height: auto; max-height: none; }
  .preview-source { flex: 1; }
}


/* ---- composer: a rounded card pinned to the bottom ---- */
.composer {
  width: 100%;
  max-width: calc(var(--column) + 32px);
  margin: 0 auto;
  padding: 4px 16px calc(12px + env(safe-area-inset-bottom));
}
.composer-box {
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-elev);
  box-shadow: var(--shadow-card);
  transition: border-color 0.15s;
}
.composer-box:focus-within { border-color: var(--border-strong); }
.chips { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 12px 0; }
.input {
  display: block;
  width: 100%;
  resize: none;
  border: 0;
  background: transparent;
  padding: 14px 16px 4px;
  min-height: 52px;
  max-height: 40vh;
  overflow-y: hidden;
  outline: none;
  font-size: 16px; /* >= 16px: no zoom on focus in mobile browsers */
}
.input::placeholder { color: var(--fg-muted); }
.input.scrolling { overflow-y: auto; }
.composer-bar {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px 8px;
}
.plus-wrap { position: relative; flex: none; }
.plus-btn { min-width: 34px; min-height: 34px; border: 1px solid var(--border); border-radius: 10px; color: var(--fg-soft); }
.menu.plus-menu { position: absolute; left: 0; bottom: calc(100% + 8px); top: auto; min-width: 220px; }
.menu.plus-menu button { display: flex; align-items: center; gap: 10px; }
.plus-menu .ico { width: 18px; height: 18px; color: var(--fg-muted); }
.composer-reason { flex: 0 1 auto; min-width: 0; padding: 0 6px; font-size: 13px; color: var(--fg-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.picker {
  flex: 0 1 auto;
  min-width: 0;
  min-height: 34px;
  max-width: 200px;
  padding: 0 24px 0 8px;
  border: 0;
  border-radius: 8px;
  /* A chevron drawn in the text colour (no image, follows the theme). */
  background:
    linear-gradient(45deg, transparent 50%, currentColor 50%) calc(100% - 13px) 55% / 5px 5px no-repeat,
    linear-gradient(135deg, currentColor 50%, transparent 50%) calc(100% - 8px) 55% / 5px 5px no-repeat,
    transparent;
  -webkit-appearance: none;
  appearance: none;
  color: var(--fg-soft);
  font-size: 13px;
  text-overflow: ellipsis;
  white-space: nowrap;
  overflow: hidden;
  cursor: pointer;
}
.picker:hover { background-color: var(--bg-hover); }
.picker option { background: var(--bg-elev); color: var(--fg); }
.spacer { flex: 1 1 0; min-width: 0; }
.round-btn {
  flex: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}
.round-btn .ico { width: 18px; height: 18px; }
.send { background: var(--accent); color: var(--accent-fg); }
.send:hover:not(:disabled) { filter: brightness(1.06); }
.send:disabled { opacity: 0.4; cursor: default; }
.stop { background: var(--fg); color: var(--bg); }
.composer.blocked .composer-box { border-style: dashed; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 240px;
  min-height: 36px;
  padding: 2px 4px 2px 8px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
  font-size: 13px;
  color: inherit;
  text-decoration: none;
}
.chip.error { border-color: var(--danger); }
.chip-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chip-size, .chip-err { color: var(--fg-muted); white-space: nowrap; }
.chip-err { color: var(--danger); }
.chip-thumb { width: 28px; height: 28px; object-fit: cover; border-radius: 6px; }
.chip-progress { width: 56px; height: 6px; }
.chip-remove { min-width: 32px; min-height: 32px; border: 0; border-radius: 8px; background: transparent; cursor: pointer; }
.chip-remove:hover { background: var(--bg-hover); }
.att-chip { padding-right: 10px; }

/* ---- overlays ---- */
.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.35);
  pointer-events: none;
}
.drop-box { padding: 40px 56px; border: 3px dashed var(--accent); border-radius: 18px; background: var(--bg-elev); font-size: 20px; }
.menu {
  position: fixed;
  z-index: 40;
  min-width: 190px;
  padding: 4px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  box-shadow: var(--shadow);
}
.menu button {
  display: block;
  width: 100%;
  min-height: var(--touch);
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  text-align: left;
  cursor: pointer;
}
.menu button:hover, .menu button:focus-visible { background: var(--bg-hover); }
.menu .danger { color: var(--danger); }
.menu [role="menuitemcheckbox"]::before { content: ""; display: inline-block; width: 1.4em; }
.menu [role="menuitemcheckbox"][aria-checked="true"]::before { content: "\2713"; }
.dialog {
  width: min(92vw, 420px);
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-elev);
  color: var(--fg);
  box-shadow: var(--shadow);
}
.dialog::backdrop { background: rgba(0, 0, 0, 0.4); }
.dialog h2 { margin: 0 0 12px; font-size: 18px; }
.text-input { width: 100%; min-height: var(--touch); padding: 0 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg); }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }
.signed-out { max-width: 520px; margin: 15vh auto; padding: 0 20px; }
.noscript { padding: 20px; }

/* ---- PWA: update banner, offline page ---- */
.update-banner { padding: 4px 4px 4px 14px; }
.update-btn { min-height: 36px; padding: 0 12px; }
.offline-page { overflow: auto; }
.offline { max-width: 480px; margin: 15vh auto 0; padding: 0 20px calc(20px + env(safe-area-inset-bottom)); text-align: center; }
.offline-icon { border-radius: 16px; }
.offline-retry { display: inline-flex; align-items: center; text-decoration: none; }

/* ---- settings ---- */
.settings {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 12px calc(24px + env(safe-area-inset-bottom));
}
.settings-inner { max-width: 760px; margin: 0 auto; }
.settings-tabs {
  position: sticky;
  top: 0;
  z-index: 2;
  display: flex;
  gap: 4px;
  padding: 10px 0 8px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.settings-tab {
  display: inline-flex;
  align-items: center;
  min-height: var(--touch);
  padding: 0 14px;
  border-radius: 10px;
  color: inherit;
  text-decoration: none;
}
.settings-tab.active { background: var(--bg-hover); font-weight: 600; }
.settings-section { margin: 20px 0; }
.settings-section h2 { margin: 0 0 8px; font-size: 18px; }
.settings-section > .btn { margin-top: 8px; }
.small { font-size: 13px; }
.settings-loading { padding: 20px 0; }
.cap-warning { margin-top: 16px; padding: 10px 14px; border-radius: 10px; border: 1px solid var(--info); color: var(--info); background: var(--bg-elev); }
.cap-warning.over { border-color: var(--danger); color: var(--danger); }
.usage-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 12px; }
.usage-card { padding: 14px 16px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); }
.usage-card.warn { border-color: var(--info); }
.usage-card.over { border-color: var(--danger); }
.usage-card h3 { margin: 0 0 4px; font-size: 14px; font-weight: 600; color: var(--fg-muted); }
.usage-card p { margin: 4px 0; }
.usage-cost strong { font-size: 24px; }
.usage-bar { display: block; width: 100%; height: 8px; appearance: none; border: 0; border-radius: 4px; background: var(--bg-hover); overflow: hidden; }
.usage-bar::-webkit-progress-bar { background: var(--bg-hover); border-radius: 4px; }
.usage-bar::-webkit-progress-value { background: var(--accent); border-radius: 4px; }
.usage-bar::-moz-progress-bar { background: var(--accent); border-radius: 4px; }
.usage-card.over .usage-bar::-webkit-progress-value { background: var(--danger); }
.usage-card.over .usage-bar::-moz-progress-bar { background: var(--danger); }
.usage-meta { font-size: 13px; }
.table-wrap { overflow-x: auto; }
.settings-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.settings-table th, .settings-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; white-space: nowrap; }
.settings-table th { font-weight: 600; color: var(--fg-muted); }
.settings-table .num { text-align: right; font-variant-numeric: tabular-nums; }
.device-list, .project-list, .file-list { list-style: none; margin: 0; padding: 0; }
.device, .file-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.device-info, .file-info { flex: 1; min-width: 0; display: flex; flex-wrap: wrap; align-items: center; gap: 2px 8px; }
.device-name, .file-name { font-weight: 600; overflow-wrap: anywhere; }
.device-meta { flex-basis: 100%; font-size: 13px; }
.file-info .small { flex-basis: 100%; }
.device.revoked { opacity: 0.6; }
.badge { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--accent); color: var(--accent-fg); }
.btn.danger-outline { color: var(--danger); border-color: var(--danger); background: transparent; flex: none; }
.link-box { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); }
.link-box p { margin: 0 0 8px; }
.link-row { display: flex; flex-wrap: wrap; gap: 8px; }
.link-url { flex: 1 1 260px; font-family: var(--mono); font-size: 13px; }
.link-actions { display: flex; gap: 8px; }
.link-expiry { margin: 8px 0 0 !important; font-size: 13px; color: var(--fg-muted); }
.push-badge { background: var(--bg-elev); color: var(--fg-muted); border: 1px solid var(--border); }
.push-box .push-state { margin: 0 0 8px; }
.push-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.inline-form { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 12px; }
.inline-form .text-input { flex: 1 1 200px; width: auto; }
.project-link {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 2px 10px;
  min-height: 52px;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: inherit;
  text-decoration: none;
}
.project-name { font-weight: 600; }
.project-meta { font-size: 13px; }
.project-head { margin-top: 12px; }
.back-link { display: inline-flex; align-items: center; min-height: var(--touch); color: var(--accent); text-decoration: none; }
.project-title-row { display: flex; align-items: center; gap: 10px; }
.project-title { flex: 1; min-width: 0; margin: 0; font-size: 22px; overflow-wrap: anywhere; }
.project-actions { margin-top: 8px; }
.text-area {
  display: block;
  width: 100%;
  min-height: 160px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-elev);
  font-size: 16px;
  resize: vertical;
}
.row-end { display: flex; align-items: center; justify-content: flex-end; gap: 12px; margin-top: 8px; }
.accepted-types { margin: 0 0 4px; }
.chars-used { margin: 0 0 8px; }
.instructions-group { margin: 14px 0 0; }
.field-label { display: block; margin: 0 0 6px; font-weight: 600; }
.instructions-field { min-height: 120px; }
.char-count { font-variant-numeric: tabular-nums; }
.char-count.near { color: var(--info); }
.char-count.over { color: var(--danger); }
.danger-btn { color: #fff; }

/* ---- voice: composer mic (recording / transcribing) and read aloud ---- */
.mic { flex: none; }
.mic.recording { background: var(--danger); color: #fff; animation: mic-pulse 1.2s ease-in-out infinite; }
.mic.busy { opacity: 0.6; cursor: progress; }
@keyframes mic-pulse { 50% { box-shadow: 0 0 0 6px color-mix(in srgb, var(--danger) 25%, transparent); } }
.mic-status { flex: none; font-size: 13px; color: var(--fg-muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.composer.recording .mic-status { color: var(--danger); }
.msg-speak-stop { min-height: 32px; padding: 0 10px; font-size: 13px; }
.msg.speaking .md { outline: 2px solid color-mix(in srgb, var(--accent) 35%, transparent); outline-offset: 6px; border-radius: 4px; }
.voice-view select.text-input { margin-bottom: 6px; }
.tts-note { margin: 0 0 12px; }

/* ---- touch: every control at least 44px, nothing hover-only ---- */
@media (pointer: coarse), (max-width: 799px) {
  .picker, .copy-btn, .svg-source-toggle, .preview-btn, .artifact-btn, .update-btn, .chat-project { min-height: var(--touch); }
  .plus-btn, .round-btn { min-width: var(--touch); min-height: var(--touch); width: var(--touch); height: var(--touch); }
  .chat-link, .project-item { min-height: var(--touch); }
  .new-chat { min-height: var(--touch); }
  .search { min-height: var(--touch); }
  .chip { min-height: var(--touch); }
  .chip-remove { min-width: var(--touch); min-height: var(--touch); }
  .chat-more { opacity: 1; }
  .msg-more { min-width: var(--touch); min-height: var(--touch); opacity: 0.85; }
  .msg-speak-stop { min-height: var(--touch); }
  .msg-tools { margin-bottom: -8px; }
}

/* ---- touch: a long-press opens the message menu, not the text selection ---- */
@media (pointer: coarse) {
  .msg { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
  .msg.selecting { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
}

@media (prefers-reduced-motion: reduce) {
  .sidebar { transition: none; }
  .status-line::before { animation: none; }
  .msg.streaming .md > :last-child::after { animation: none; }
  .mic.recording { animation: none; }
}

/* ---- Nostr onboarding and device keys (N9) ---- */
.onboard { position: fixed; inset: 0; z-index: 50; overflow-y: auto; overscroll-behavior: contain; background: var(--bg); padding: env(safe-area-inset-top) 16px calc(24px + env(safe-area-inset-bottom)); }
.onboard-card { max-width: 480px; margin: 8vh auto 0; }
.onboard-card h1 { font-size: 24px; margin: 0 0 12px; }
.onboard-card h1:focus { outline: none; }
.onboard-note { padding: 10px 12px; border-radius: 10px; background: var(--bg-elev); border: 1px solid var(--accent); }
.onboard-lead { font-weight: 600; margin: 12px 0 4px; }
.onboard-choices { display: flex; flex-direction: column; gap: 10px; margin-top: 20px; }
.onboard-choices .btn { width: 100%; justify-content: center; }
.onboard-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 12px; }
.onboard-status { margin: 16px 0 0; }
.onboard-foot { margin-top: 28px; text-align: center; }
.link-btn { border: 0; background: transparent; color: var(--fg-muted); text-decoration: underline; }
.segmented { display: flex; gap: 0; margin: 12px 0; border: 1px solid var(--border); border-radius: 10px; overflow: hidden; }
.segmented .seg { flex: 1; min-height: var(--touch); border: 0; background: transparent; cursor: pointer; }
.segmented .seg[aria-pressed="true"] { background: var(--accent); color: var(--accent-fg); }
.code-box { display: flex; flex-direction: column; align-items: center; gap: 10px; margin: 12px 0; }
.qr-wrap { padding: 12px; border-radius: 12px; background: #fff; line-height: 0; }
.qr { display: block; width: min(240px, 70vw); height: auto; image-rendering: pixelated; }
.code-text { display: block; max-width: 100%; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px; background: var(--bg-code); font-family: var(--mono); font-size: 13px; overflow-wrap: anywhere; user-select: all; }
.code-text.inline { display: inline; padding: 1px 6px; }
.code-box.secret .code-text { border-color: var(--danger); }
.code-actions, .key-buttons { display: flex; flex-wrap: wrap; gap: 8px; }
.key-warnings { margin: 8px 0; padding-left: 20px; font-size: 14px; }
.key-warnings.danger li { color: var(--danger); }
.key-input { min-height: 72px; padding: 8px 12px; font-family: var(--mono); font-size: 13px; resize: vertical; }
.key-slot:not(:empty) { margin-top: 12px; padding: 12px 14px; border: 1px solid var(--border); border-radius: var(--radius); background: var(--bg-elev); }
.form-error { margin: 6px 0 0; color: var(--danger); font-size: 14px; }
.pair-row { display: flex; gap: 8px; margin-bottom: 8px; }
.pair-row .text-input { flex: 1; font-family: var(--mono); font-size: 13px; }
.scan-video { display: block; width: 100%; max-width: 360px; margin: 8px 0; border-radius: var(--radius); background: #000; }
.devices-view .text-input + .form-error, .devices-view .pair-row + .text-input { margin-top: 8px; }
.signout-row { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; margin-top: 20px; }
.check-label { font-size: 14px; color: var(--fg-muted); }
.pending-badge { background: var(--info); }
.onboard-msg { padding: 8px 12px; border-radius: 10px; background: var(--bg-elev); border: 1px solid var(--border); }
.onboard-msg.error { border-color: var(--danger); color: var(--danger); }


/* ---- artifacts panel (artifacts.js): right-hand panel on desktops, full-screen modal on phones ---- */
.artifact {
  position: relative;
  flex: 0 0 var(--artifact-w, 560px);
  width: var(--artifact-w, 560px);
  min-width: 0;
  display: flex;
  border-left: 1px solid var(--border);
  background: var(--bg-elev);
}
.artifact-inner { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.artifact-resize {
  position: absolute;
  z-index: 2;
  top: 0;
  bottom: 0;
  left: -5px;
  width: 10px;
  cursor: col-resize;
  touch-action: none;
}
.artifact-resize::after { content: ""; position: absolute; top: 50%; left: 3px; width: 4px; height: 40px; margin-top: -20px; border-radius: 2px; background: var(--border-strong); opacity: 0; transition: opacity 0.15s; }
.artifact-resize:hover::after, .artifact-resize:focus-visible::after, .artifact-resizing .artifact-resize::after { opacity: 1; }
.artifact-resizing, .artifact-resizing * { cursor: col-resize !important; user-select: none !important; }
.artifact-resizing iframe { pointer-events: none; }
.artifact-head { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; min-height: 52px; padding: 6px 8px 6px 16px; border-bottom: 1px solid var(--border); }
.artifact-title { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.artifact-tabs { display: inline-flex; padding: 2px; border-radius: 10px; background: var(--bg-hover); }
.artifact-tab { min-height: 30px; padding: 0 12px; border: 0; border-radius: 8px; background: transparent; color: var(--fg-muted); font-size: 13px; cursor: pointer; }
.artifact-tab[aria-selected="true"] { background: var(--bg-elev); color: var(--fg); box-shadow: 0 1px 2px rgba(0, 0, 0, 0.12); }
.artifact-actions { display: inline-flex; gap: 2px; }
.artifact-actions .icon-btn { min-width: 34px; min-height: 34px; color: var(--fg-soft); }
.artifact-actions .ico { width: 18px; height: 18px; }
.artifact-pane { flex: 1; min-height: 0; overflow: auto; }
.artifact-code { background: var(--bg-code); }
.artifact-code pre { margin: 0; }
.artifact-code code { display: block; padding: 16px; font: 13px/1.55 var(--mono); white-space: pre; background: transparent; }
.artifact-preview { display: flex; flex-direction: column; background: var(--bg); }
.artifact-svg { display: block; max-width: calc(100% - 32px); max-height: calc(100% - 32px); margin: auto; padding: 12px; border-radius: 8px; background: #fff; }
.artifact-note { margin: 0; padding: 6px 16px; font-size: 12px; color: var(--fg-muted); }
.artifact-frame { flex: 1; height: auto; max-height: none; }
@media (max-width: 799px) {
  .artifact {
    position: fixed;
    z-index: 60;
    inset: 0;
    width: auto;
    border: 0;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  }
  .artifact-resize { display: none; }
  .artifact-head { padding-left: 12px; }
  .artifact-tabs { order: 3; flex: 1 0 100%; }
  .artifact-tab { flex: 1; min-height: var(--touch); }
  .artifact-actions .icon-btn { min-width: var(--touch); min-height: var(--touch); }
}
@media (min-width: 800px) and (max-width: 1099px) {
  /* Not enough room for three columns: the panel takes the sidebar's place. */
  .artifact-open .sidebar { display: none; }
}

/* ---- settings: theme ---- */
.theme-picker { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 16px; margin: 0 0 12px; padding: 0; border: 0; }
.theme-picker legend { padding: 0; margin-bottom: 6px; }
.theme-picker .muted { flex-basis: 100%; margin: 4px 0 0; }
.theme-option { display: inline-flex; align-items: center; gap: 8px; min-height: var(--touch); cursor: pointer; }
.theme-option input { width: 18px; height: 18px; margin: 0; }
