/* Claude Deck — dark-only, mobile-first. Neutrals + chart chrome follow the
   validated reference palette (dark column). */

:root {
  color-scheme: dark;
  --page: #0d0d0d;
  --surface: #1a1a19;
  --raised: #232322;
  --sunken: #141413;
  --ink: #ffffff;
  --ink-2: #c3c2b7;
  --muted: #898781;
  --hairline: rgba(255, 255, 255, 0.10);
  --grid: #2c2c2a;
  --accent: #3987e5;        /* series-1 dark */
  --accent-dim: #1c5cab;
  --good: #0ca30c;
  --warning: #fab219;
  --serious: #ec835a;
  --critical: #d03b3b;
  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;
  --series-4: #c98500;
  --radius: 14px;
  --nav-h: calc(56px + env(safe-area-inset-bottom));
  font-size: 16px;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--page);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
}
button {
  font: inherit; color: inherit; background: none; border: none;
  padding: 0; cursor: pointer; touch-action: manipulation;
}
input, textarea, select {
  font: inherit; color: var(--ink); background: var(--raised);
  border: 1px solid var(--hairline); border-radius: 10px; padding: 10px 12px;
  width: 100%; outline: none;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent-dim); }
a { color: var(--accent); text-decoration: none; }
code, pre, .mono { font-family: ui-monospace, "Cascadia Mono", Menlo, monospace; }

/* ---------- layout ---------- */
.shell { min-height: 100dvh; display: flex; flex-direction: column; }
.page {
  flex: 1; padding: 12px 14px calc(var(--nav-h) + 16px);
  max-width: 760px; width: 100%; margin: 0 auto;
}
.topbar {
  position: sticky; top: 0; z-index: 20;
  display: flex; align-items: center; gap: 10px;
  padding: calc(8px + env(safe-area-inset-top)) 14px 8px;
  background: color-mix(in srgb, var(--page) 88%, transparent);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--hairline);
  min-height: 52px;
}
.topbar h1 { font-size: 17px; font-weight: 650; margin: 0; flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.topbar .sub { font-size: 12px; color: var(--muted); font-weight: 400; display: block;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.iconbtn {
  width: 38px; height: 38px; border-radius: 10px; flex: none;
  display: grid; place-items: center; font-size: 19px; color: var(--ink-2);
}
.iconbtn:active { background: var(--raised); }

.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; justify-content: space-around; align-items: stretch;
  height: var(--nav-h); padding-bottom: env(safe-area-inset-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--hairline);
}
.bottomnav button {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  justify-content: center; gap: 2px; font-size: 10.5px; color: var(--muted);
}
.bottomnav button.active { color: var(--accent); }
.bottomnav .icon { font-size: 21px; line-height: 1; }

.fab {
  position: fixed; right: 18px; bottom: calc(var(--nav-h) + 18px); z-index: 25;
  width: 56px; height: 56px; border-radius: 18px;
  background: var(--accent); color: #fff; font-size: 28px; font-weight: 300;
  display: grid; place-items: center;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}
.fab:active { transform: scale(0.94); }

/* ---------- cards / lists ---------- */
.card {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 13px 14px; margin-bottom: 10px;
}
.card:active { background: var(--raised); }
.row { display: flex; align-items: center; gap: 8px; }
.grow { flex: 1; min-width: 0; }
.ellip { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dim { color: var(--ink-2); } .faint { color: var(--muted); }
.small { font-size: 12.5px; } .tiny { font-size: 11px; }

.chip {
  display: inline-flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; padding: 3px 9px; border-radius: 99px;
  background: var(--raised); color: var(--ink-2); border: 1px solid var(--hairline);
  white-space: nowrap;
}
.chip .dot { width: 7px; height: 7px; border-radius: 99px; background: var(--muted); flex: none; }
.chip.running .dot { background: var(--accent); animation: pulse 1.2s ease-in-out infinite; }
.chip.awaiting_permission { border-color: var(--warning); color: var(--warning); }
.chip.awaiting_permission .dot { background: var(--warning); animation: pulse 0.8s ease-in-out infinite; }
.chip.idle .dot, .chip.done .dot { background: var(--good); }
.chip.error .dot { background: var(--critical); }
.chip.starting .dot { background: var(--accent); animation: pulse 0.6s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.25; } }

.empty { text-align: center; color: var(--muted); padding: 60px 20px; font-size: 14px; }
.empty .big { font-size: 40px; margin-bottom: 12px; }

/* ---------- chat ---------- */
.chat { padding: 10px 12px 0; max-width: 760px; margin: 0 auto; width: 100%; }
.msg { margin: 10px 0; max-width: 100%; overflow-wrap: break-word; }
.msg-user {
  background: var(--accent-dim); color: #fff; border-radius: 16px 16px 4px 16px;
  padding: 10px 14px; margin-left: 48px; width: fit-content; max-width: calc(100% - 48px);
  margin-left: auto; white-space: pre-wrap; font-size: 15px;
}
.msg-assistant { font-size: 15px; line-height: 1.55; }
.msg-assistant .md > :first-child { margin-top: 0; }
.msg-assistant .md > :last-child { margin-bottom: 0; }
.md pre {
  background: var(--sunken); border: 1px solid var(--hairline); border-radius: 10px;
  padding: 10px 12px; overflow-x: auto; font-size: 12.5px; line-height: 1.5;
}
.md code { font-size: 0.9em; background: var(--raised); padding: 1px 5px; border-radius: 5px; }
.md pre code { background: none; padding: 0; }
.md table { border-collapse: collapse; display: block; overflow-x: auto; font-size: 13px; }
.md th, .md td { border: 1px solid var(--grid); padding: 5px 9px; text-align: left; }
.md blockquote { border-left: 3px solid var(--grid); margin: 8px 0; padding: 2px 12px; color: var(--ink-2); }
.md img { max-width: 100%; border-radius: 8px; }
.md h1, .md h2, .md h3 { font-size: 1.12em; margin: 14px 0 6px; }
.md ul, .md ol { padding-left: 22px; }
.md p { margin: 8px 0; }

.thinking {
  color: var(--muted); font-size: 13px; font-style: italic;
  border-left: 2px solid var(--grid); padding-left: 10px; margin: 8px 0;
}
.thinking.collapsed { max-height: 40px; overflow: hidden; position: relative; }
.thinking.collapsed::after {
  content: ""; position: absolute; inset: auto 0 0 0; height: 24px;
  background: linear-gradient(transparent, var(--page));
}

.toolcard {
  background: var(--surface); border: 1px solid var(--hairline); border-radius: 12px;
  margin: 8px 0; overflow: hidden; font-size: 13px;
}
.toolcard.nested { margin: 6px 0 6px 14px; opacity: 0.92; }
.toolcard-head { display: flex; align-items: center; gap: 8px; padding: 9px 12px; width: 100%; text-align: left; }
.toolcard-head .t-icon { flex: none; font-size: 15px; }
.toolcard-head .t-name { font-weight: 650; flex: none; }
.toolcard-head .t-detail { color: var(--muted); flex: 1; min-width: 0;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  font-family: ui-monospace, Menlo, monospace; font-size: 12px; }
.toolcard-head .t-status { flex: none; font-size: 12px; }
.toolcard-body { border-top: 1px solid var(--hairline); padding: 10px 12px; }
.toolcard-body pre {
  margin: 0; background: var(--sunken); border-radius: 8px; padding: 9px 10px;
  overflow-x: auto; font-size: 12px; line-height: 1.45; max-height: 320px; overflow-y: auto;
  white-space: pre-wrap; word-break: break-word;
}
.toolcard-body .lbl { color: var(--muted); font-size: 11px; margin: 8px 0 4px; text-transform: uppercase; letter-spacing: 0.04em; }
.toolcard-body .lbl:first-child { margin-top: 0; }
.tool-err { color: var(--serious); }

.syschip {
  text-align: center; margin: 12px 0;
}
.syschip span {
  font-size: 11px; color: var(--muted); background: var(--surface);
  border: 1px solid var(--hairline); border-radius: 99px; padding: 3px 12px;
}

.result-line {
  display: flex; gap: 8px; align-items: center; margin: 12px 0;
  font-size: 11.5px; color: var(--muted);
}
.result-line::before, .result-line::after { content: ""; flex: 1; height: 1px; background: var(--grid); }
.result-line.err { color: var(--critical); }

.stream-cursor::after { content: "▍"; animation: pulse 1s infinite; color: var(--accent); }

/* ---------- composer ---------- */
.composer {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom));
  background: color-mix(in srgb, var(--page) 94%, transparent);
  backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px);
  border-top: 1px solid var(--hairline);
}
.composer-inner { max-width: 760px; margin: 0 auto; display: flex; gap: 8px; align-items: flex-end; }
.composer textarea {
  flex: 1; resize: none; max-height: 132px; min-height: 44px; line-height: 1.4;
  border-radius: 14px; padding: 11px 14px; font-size: 15px;
}
.sendbtn {
  width: 44px; height: 44px; border-radius: 14px; flex: none;
  background: var(--accent); color: #fff; font-size: 19px;
  display: grid; place-items: center;
}
.sendbtn:disabled { background: var(--raised); color: var(--muted); }
.sendbtn.stop { background: var(--critical); }
.composer-meta { max-width: 760px; margin: 0 auto 6px; display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; }
.composer-meta::-webkit-scrollbar { display: none; }

/* ---------- permission sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.55); z-index: 40;
  animation: fadein 0.15s ease-out;
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 41;
  background: var(--raised); border-radius: 20px 20px 0 0;
  border-top: 1px solid var(--hairline);
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom));
  max-height: 82dvh; overflow-y: auto;
  animation: slideup 0.18s ease-out;
  max-width: 760px; margin: 0 auto;
}
@keyframes slideup { from { transform: translateY(40px); opacity: 0.5; } }
@keyframes fadein { from { opacity: 0; } }
.sheet h3 { margin: 0 0 4px; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.sheet .perm-input {
  background: var(--sunken); border: 1px solid var(--hairline); border-radius: 10px;
  padding: 10px 12px; margin: 10px 0; font-size: 12.5px; overflow-x: auto;
  max-height: 300px; overflow-y: auto; white-space: pre-wrap; word-break: break-word;
}
.sheet-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 12px; }
.btn {
  border-radius: 12px; padding: 13px; font-size: 15px; font-weight: 600;
  text-align: center; background: var(--surface); border: 1px solid var(--hairline);
  color: var(--ink); width: 100%;
}
.btn:active { opacity: 0.8; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.danger { color: var(--critical); border-color: color-mix(in srgb, var(--critical) 40%, transparent); }
.btn.subtle { color: var(--ink-2); font-weight: 500; }
.btn:disabled { opacity: 0.45; }
.btn.sm { padding: 9px 12px; font-size: 13.5px; width: auto; }

.opt {
  display: block; width: 100%; text-align: left; background: var(--surface);
  border: 1px solid var(--hairline); border-radius: 12px; padding: 11px 13px; margin: 6px 0;
}
.opt.sel { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, var(--surface)); }
.opt .o-label { font-weight: 600; font-size: 14px; }
.opt .o-desc { color: var(--muted); font-size: 12.5px; margin-top: 2px; }

/* ---------- forms ---------- */
.field { margin-bottom: 14px; }
.field label { display: block; font-size: 12.5px; color: var(--ink-2); margin-bottom: 6px; font-weight: 600; }
.seg { display: flex; background: var(--raised); border-radius: 11px; padding: 3px; gap: 3px; border: 1px solid var(--hairline); }
.seg button { flex: 1; padding: 8px 4px; border-radius: 8px; font-size: 12.5px; color: var(--muted); font-weight: 600; }
.seg button.active { background: var(--surface); color: var(--ink); box-shadow: 0 1px 4px rgba(0,0,0,0.4); }
.dirpick { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }

/* ---------- login ---------- */
.login {
  min-height: 100dvh; display: flex; flex-direction: column;
  align-items: center; justify-content: center; padding: 24px; gap: 8px;
}
.login .logo { font-size: 52px; }
.login h1 { font-size: 22px; margin: 4px 0 18px; }
.login form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 10px; }
.login .err { color: var(--critical); font-size: 13px; text-align: center; min-height: 18px; }

/* ---------- usage (viz-root per dataviz chrome) ---------- */
.viz-root { color-scheme: dark; }
.tiles { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 14px; }
.tile {
  background: var(--surface); border: 1px solid var(--hairline);
  border-radius: var(--radius); padding: 12px 14px;
}
.tile .t-label { font-size: 11.5px; color: var(--muted); font-weight: 600; letter-spacing: 0.02em; }
.tile .t-value { font-size: 26px; font-weight: 650; margin-top: 3px; line-height: 1.1; }
.tile .t-sub { font-size: 11.5px; color: var(--ink-2); margin-top: 4px; }
.chartcard { background: var(--surface); border: 1px solid var(--hairline); border-radius: var(--radius); padding: 14px; margin-bottom: 14px; }
.chartcard h3 { margin: 0 0 2px; font-size: 14px; }
.chartcard .csub { font-size: 12px; color: var(--muted); margin-bottom: 10px; }
.chartwrap { overflow-x: auto; }
.legend { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 10px; }
.legend .l-item { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--ink-2); }
.legend .l-swatch { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.viztip {
  position: fixed; z-index: 50; pointer-events: none;
  background: var(--raised); border: 1px solid var(--hairline); border-radius: 10px;
  padding: 8px 11px; font-size: 12px; box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  max-width: 240px;
}
.viztip .tt-title { font-weight: 650; margin-bottom: 4px; }
.viztip .tt-row { display: flex; align-items: center; gap: 6px; color: var(--ink-2); margin-top: 2px; }
.utable { width: 100%; border-collapse: collapse; font-size: 12.5px; }
.utable th { text-align: left; color: var(--muted); font-weight: 600; font-size: 11px; padding: 6px 8px; border-bottom: 1px solid var(--grid); }
.utable td { padding: 7px 8px; border-bottom: 1px solid var(--grid); font-variant-numeric: tabular-nums; }
.utable tr:last-child td { border-bottom: none; }

/* ---------- files ---------- */
.crumbs { display: flex; gap: 2px; overflow-x: auto; font-size: 13px; padding: 4px 0 10px; scrollbar-width: none; white-space: nowrap; }
.crumbs button { color: var(--accent); padding: 2px 4px; }
.crumbs .sep { color: var(--muted); }
.fentry { display: flex; align-items: center; gap: 11px; padding: 11px 6px; border-bottom: 1px solid var(--grid); width: 100%; text-align: left; }
.fentry .f-icon { font-size: 19px; flex: none; width: 24px; text-align: center; }
.fentry .f-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14.5px; }
.fentry .f-meta { color: var(--muted); font-size: 11px; flex: none; text-align: right; }
.fileview pre {
  background: var(--sunken); border: 1px solid var(--hairline); border-radius: 10px;
  padding: 12px; overflow-x: auto; font-size: 12px; line-height: 1.5; margin: 0;
}
.fileview iframe {
  width: 100%; height: calc(100dvh - 210px); border: 1px solid var(--hairline);
  border-radius: 10px; background: #fff;
}
.fileview img { max-width: 100%; border-radius: 10px; }
.filebar { display: flex; gap: 8px; margin-bottom: 10px; flex-wrap: wrap; }

/* hljs adjustments on dark sunken background */
.hljs { background: transparent; color: var(--ink-2); }
.hljs-keyword, .hljs-selector-tag, .hljs-literal { color: #9085e9; }
.hljs-string, .hljs-attr { color: #199e70; }
.hljs-number, .hljs-built_in { color: #c98500; }
.hljs-comment { color: var(--muted); font-style: italic; }
.hljs-title, .hljs-function { color: #3987e5; }

.toast {
  position: fixed; left: 50%; transform: translateX(-50%);
  bottom: calc(var(--nav-h) + 14px); z-index: 60;
  background: var(--raised); border: 1px solid var(--hairline); border-radius: 12px;
  padding: 10px 16px; font-size: 13.5px; box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  animation: slideup 0.2s ease-out; max-width: 90vw;
}
.spin {
  width: 18px; height: 18px; border: 2px solid var(--grid); border-top-color: var(--accent);
  border-radius: 99px; animation: rot 0.8s linear infinite; margin: 0 auto;
}
@keyframes rot { to { transform: rotate(360deg); } }
.menu {
  position: absolute; right: 10px; top: 52px; z-index: 45;
  background: var(--raised); border: 1px solid var(--hairline); border-radius: 12px;
  min-width: 190px; overflow: hidden; box-shadow: 0 8px 30px rgba(0,0,0,0.6);
}
.menu button { display: block; width: 100%; text-align: left; padding: 12px 15px; font-size: 14px; }
.menu button:active { background: var(--surface); }
.menu .m-sep { height: 1px; background: var(--hairline); }
