/* Claude in the browser. The look is Vaultstream's: system type, quiet surfaces, one accent, squircle corners and
   motion that shows where a thing came from. Nothing is loaded from anywhere else. The dark palette is dark.css,
   which applies as the device is, always, or never, as the user picked (theme.js sets its media before paint).

   Spacing is a 4px grid (--s-*). Corners are squircles: corner-shape where the browser has it, a 9-slice
   superellipse mask in Safari, plain rounding in Firefox. A mask cuts off whatever lies outside it — a border,
   a box-shadow, a focus ring — so surfaces carry no borders: fills and shadows separate them. */

:root {
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-7: 32px;
  --s-8: 40px;
  --s-9: 56px;

  --r-card: 26px;
  --r-tile: 22px;
  --r-inner: 16px;
  --r-control: 14px;
  --r-control-s: 11px;
  --r-pill: 999px;

  --bg: #f3f3f6;
  --side: #ebebf0;
  --card: #ffffff;
  --card-2: #f5f5f8;
  --field: #f1f1f5;
  --field-hover: #eaeaf0;
  --well: #dfdfe7;
  --knob: #ffffff;
  --text: #1c1c21;
  --muted: #62626d;
  --faint: #8c8c97;
  --line: rgba(24, 24, 48, 0.08);
  --accent: #5b5bd6;
  --accent-strong: #4a4ac6;
  --accent-soft: #eeeefc;
  --accent-softer: #f5f5fe;
  --accent-ring: rgba(91, 91, 214, 0.3);
  --on-accent: #ffffff;
  --green: #17803f;
  --green-soft: #e3f4e9;
  --amber: #955406;
  --amber-soft: #fcf1da;
  --red: #cf2f2b;
  --red-soft: #fdeaea;
  --on-red: #ffffff;
  --bubble: #e7e7fb;
  --code-bg: #ffffff;
  --shadow-card: 0 1px 2px rgba(16, 24, 40, 0.04), 0 6px 22px rgba(16, 24, 40, 0.055);
  --shadow-float: 0 10px 30px rgba(16, 24, 40, 0.16);
  --shadow-dock: 0 2px 6px rgba(16, 24, 40, 0.05), 0 12px 32px rgba(16, 24, 40, 0.12);
  --shadow-knob: 0 1px 3px rgba(16, 24, 40, 0.14);
  --drop-card: drop-shadow(0 1px 1px rgba(16, 24, 40, 0.04)) drop-shadow(0 5px 12px rgba(16, 24, 40, 0.06));
  --drop-float: drop-shadow(0 8px 20px rgba(16, 24, 40, 0.16));
  --drop-knob: drop-shadow(0 1px 1.5px rgba(16, 24, 40, 0.16));
  --backdrop: rgba(20, 20, 36, 0.28);

  /* syntax */
  --hl-keyword: #5b5bd6;
  --hl-string: #17803f;
  --hl-number: #955406;
  --hl-comment: #8c8c97;
  --hl-title: #2563c9;
  --hl-literal: #cf2f2b;
  --hl-attr: #8a4fd8;
  --hl-meta: #62626d;

  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", system-ui, Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --squircle-img: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2096%2096'%3E%3Cpath%20d='M96%2048%20L95.93%2054.99%20L95.71%2059.38%20L95.35%2063.12%20L94.84%2066.47%20L94.19%2069.52%20L93.39%2072.35%20L92.45%2074.97%20L91.36%2077.41%20L90.13%2079.68%20L88.76%2081.8%20L87.24%2083.76%20L85.57%2085.57%20L83.76%2087.24%20L81.8%2088.76%20L79.68%2090.13%20L77.41%2091.36%20L74.97%2092.45%20L72.35%2093.39%20L69.52%2094.19%20L66.47%2094.84%20L63.12%2095.35%20L59.38%2095.71%20L54.99%2095.93%20L48%2096%20L41.01%2095.93%20L36.62%2095.71%20L32.88%2095.35%20L29.53%2094.84%20L26.48%2094.19%20L23.65%2093.39%20L21.03%2092.45%20L18.59%2091.36%20L16.32%2090.13%20L14.2%2088.76%20L12.24%2087.24%20L10.43%2085.57%20L8.76%2083.76%20L7.24%2081.8%20L5.87%2079.68%20L4.64%2077.41%20L3.55%2074.97%20L2.61%2072.35%20L1.81%2069.52%20L1.16%2066.47%20L0.65%2063.12%20L0.29%2059.38%20L0.07%2054.99%20L0%2048%20L0.07%2041.01%20L0.29%2036.62%20L0.65%2032.88%20L1.16%2029.53%20L1.81%2026.48%20L2.61%2023.65%20L3.55%2021.03%20L4.64%2018.59%20L5.87%2016.32%20L7.24%2014.2%20L8.76%2012.24%20L10.43%2010.43%20L12.24%208.76%20L14.2%207.24%20L16.32%205.87%20L18.59%204.64%20L21.03%203.55%20L23.65%202.61%20L26.48%201.81%20L29.53%201.16%20L32.88%200.65%20L36.62%200.29%20L41.01%200.07%20L48%200%20L54.99%200.07%20L59.38%200.29%20L63.12%200.65%20L66.47%201.16%20L69.52%201.81%20L72.35%202.61%20L74.97%203.55%20L77.41%204.64%20L79.68%205.87%20L81.8%207.24%20L83.76%208.76%20L85.57%2010.43%20L87.24%2012.24%20L88.76%2014.2%20L90.13%2016.32%20L91.36%2018.59%20L92.45%2021.03%20L93.39%2023.65%20L94.19%2026.48%20L94.84%2029.53%20L95.35%2032.88%20L95.71%2036.62%20L95.93%2041.01%20Z'/%3E%3C/svg%3E");
  --squircle-pill-img: url("data:image/svg+xml,%3Csvg%20xmlns='http://www.w3.org/2000/svg'%20viewBox='0%200%2096%2096'%3E%3Cpath%20d='M96%2048%20L95.95%2060.28%20L95.79%2065.34%20L95.54%2069.2%20L95.18%2072.42%20L94.71%2075.21%20L94.14%2077.69%20L93.46%2079.92%20L92.67%2081.94%20L91.77%2083.78%20L90.75%2085.45%20L89.62%2086.98%20L88.36%2088.36%20L86.98%2089.62%20L85.45%2090.75%20L83.78%2091.77%20L81.94%2092.67%20L79.92%2093.46%20L77.69%2094.14%20L75.21%2094.71%20L72.42%2095.18%20L69.2%2095.54%20L65.34%2095.79%20L60.28%2095.95%20L48%2096%20L35.72%2095.95%20L30.66%2095.79%20L26.8%2095.54%20L23.58%2095.18%20L20.79%2094.71%20L18.31%2094.14%20L16.08%2093.46%20L14.06%2092.67%20L12.22%2091.77%20L10.55%2090.75%20L9.02%2089.62%20L7.64%2088.36%20L6.38%2086.98%20L5.25%2085.45%20L4.23%2083.78%20L3.33%2081.94%20L2.54%2079.92%20L1.86%2077.69%20L1.29%2075.21%20L0.82%2072.42%20L0.46%2069.2%20L0.21%2065.34%20L0.05%2060.28%20L0%2048%20L0.05%2035.72%20L0.21%2030.66%20L0.46%2026.8%20L0.82%2023.58%20L1.29%2020.79%20L1.86%2018.31%20L2.54%2016.08%20L3.33%2014.06%20L4.23%2012.22%20L5.25%2010.55%20L6.38%209.02%20L7.64%207.64%20L9.02%206.38%20L10.55%205.25%20L12.22%204.23%20L14.06%203.33%20L16.08%202.54%20L18.31%201.86%20L20.79%201.29%20L23.58%200.82%20L26.8%200.46%20L30.66%200.21%20L35.72%200.05%20L48%200%20L60.28%200.05%20L65.34%200.21%20L69.2%200.46%20L72.42%200.82%20L75.21%201.29%20L77.69%201.86%20L79.92%202.54%20L81.94%203.33%20L83.78%204.23%20L85.45%205.25%20L86.98%206.38%20L88.36%207.64%20L89.62%209.02%20L90.75%2010.55%20L91.77%2012.22%20L92.67%2014.06%20L93.46%2016.08%20L94.14%2018.31%20L94.71%2020.79%20L95.18%2023.58%20L95.54%2026.8%20L95.79%2030.66%20L95.95%2035.72%20Z'/%3E%3C/svg%3E");
  --ease: cubic-bezier(0.2, 0, 0, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --spring: cubic-bezier(0.3, 1.35, 0.5, 1);
  --t-1: 0.12s;
  --t-2: 0.2s;
  --t-3: 0.36s;
  --t-4: 0.6s;
  --moves: background-color var(--t-2) var(--ease), color var(--t-2) var(--ease), box-shadow var(--t-2) var(--ease),
    filter var(--t-2) var(--ease), opacity var(--t-2) var(--ease), transform var(--t-3) var(--spring);

  --side-w: 304px;
  --head-h: 60px;
  --dock-h: 96px;
  --feed-w: 800px;
  color-scheme: light;
}

/* ------------------------------------------------------------ squircles */

* {
  box-sizing: border-box;
  corner-shape: superellipse(1.5);
}
.badge,
.dot,
.chip {
  corner-shape: superellipse(2);
}

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

html {
  -webkit-text-size-adjust: 100%;
  background: var(--bg);
  height: 100%;
}
body {
  margin: 0;
  height: 100%;
  font: 16px/1.5 var(--font);
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
::selection { background: var(--accent-ring); }
a { color: var(--accent); text-decoration: underline 1.5px transparent; text-underline-offset: 3px; transition: var(--moves); }
a:hover { text-decoration-color: currentColor; }
h1, h2, h3, h4, p, ul, ol, dl, figure, pre, blockquote { margin: 0; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg { flex-shrink: 0; }
/* every icon has a size even where no rule gives it one (an icon without one fills its box) */
:where(svg) { width: 20px; height: 20px; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: 14px; line-height: 1.45; }
.mono { font-family: var(--mono); }
.grow { flex: 1; min-width: 0; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* --------------------------------------------------------------- buttons */

button, .button {
  appearance: none;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  min-height: 44px;
  padding: 0 var(--s-5);
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  border-radius: var(--r-control);
  background: var(--accent);
  color: var(--on-accent);
  text-decoration: none;
  white-space: nowrap;
  transition: var(--moves);
  -webkit-tap-highlight-color: transparent;
}
button:hover, .button:hover { background: var(--accent-strong); color: var(--on-accent); }
button:active, .button:active { transform: scale(0.97); transition-duration: var(--t-1); }
button:disabled { opacity: 0.5; cursor: default; transform: none; }
button.secondary, .button.secondary { background: var(--accent-soft); color: var(--accent); }
button.secondary:hover, .button.secondary:hover { background: color-mix(in srgb, var(--accent-soft) 78%, var(--accent) 22%); color: var(--accent); }
button.quiet, .button.quiet { background: var(--field); color: var(--text); }
button.quiet:hover, .button.quiet:hover { background: var(--field-hover); color: var(--text); }
button.ghost { background: transparent; color: var(--accent); min-height: 36px; padding: 0 var(--s-3); }
button.ghost:hover { background: var(--accent-soft); color: var(--accent); }
button.danger { background: var(--red); color: var(--on-red); }
button.danger:hover { background: color-mix(in srgb, var(--red) 88%, #000); color: var(--on-red); }
button.ghost.danger, button.quiet.danger { background: transparent; color: var(--red); }
button.ghost.danger:hover, button.quiet.danger:hover { background: var(--red-soft); }
button.good { background: var(--green); color: #fff; }
button.good:hover { background: color-mix(in srgb, var(--green) 88%, #000); color: #fff; }
button.small, .button.small { min-height: 36px; padding: 0 14px; font-size: 14px; border-radius: var(--r-control-s); }
button.wide, .button.wide { width: 100%; }
button svg, .button svg { width: 18px; height: 18px; }
.icon-btn {
  min-height: 0;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 13px;
  background: transparent;
  color: var(--muted);
}
.icon-btn:hover { background: var(--field); color: var(--text); }
.icon-btn svg { width: 21px; height: 21px; }
.buttons { display: flex; flex-wrap: wrap; gap: var(--s-2); align-items: center; }

[aria-busy="true"] { position: relative; pointer-events: none; -webkit-text-fill-color: transparent; }
[aria-busy="true"] > svg { opacity: 0; }
[aria-busy="true"]::after,
.spinner {
  content: "";
  flex-shrink: 0;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: conic-gradient(from 90deg, transparent 10%, currentColor);
  -webkit-mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
  mask: radial-gradient(farthest-side, transparent calc(100% - 2.5px), #000 calc(100% - 2px));
  animation: spin 0.8s linear infinite;
}
[aria-busy="true"]::after { position: absolute; inset: 0; margin: auto; -webkit-text-fill-color: initial; color: inherit; }
@keyframes spin { to { transform: rotate(1turn); } }

/* ----------------------------------------------------------------- forms */

label { display: flex; flex-direction: column; gap: var(--s-2); font-weight: 550; font-size: 14px; color: var(--text); }
.hint { font-size: 13px; line-height: 1.45; color: var(--muted); font-weight: 400; }
input:not([type="radio"], [type="checkbox"], [type="file"]), select, textarea {
  font: inherit;
  font-size: 16px;
  font-weight: 400;
  width: 100%;
  min-height: 44px;
  padding: 10px 14px;
  border: 0;
  border-radius: var(--r-control);
  background: var(--field);
  color: var(--text);
  box-shadow: inset 0 0 0 0 transparent, 0 0 0 0 transparent;
  transition: var(--moves);
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:not([type="radio"], [type="checkbox"], [type="file"]):hover, select:hover, textarea:hover { background: var(--field-hover); }
input:not([type="radio"], [type="checkbox"], [type="file"]):focus, select:focus, textarea:focus {
  outline: none;
  background: var(--card);
  box-shadow: inset 0 0 0 1.5px var(--accent), 0 0 0 4px var(--accent-ring);
}
select {
  appearance: none;
  padding-right: 40px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%238c8c97' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 15px center;
}
input[type="checkbox"] {
  appearance: none;
  flex-shrink: 0;
  width: 20px;
  height: 20px;
  margin: 1px 0 0;
  border-radius: 7px;
  background: var(--well) center / 0 0 no-repeat;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6.5 12.5l3.5 3.5 7.5-8' fill='none' stroke='white' stroke-width='2.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  cursor: pointer;
  transition: var(--moves), background-size var(--t-3) var(--spring);
}
input[type="checkbox"]:checked { background-color: var(--accent); background-size: 16px 16px; }
.field { display: flex; flex-direction: column; gap: var(--s-2); min-width: 0; }
.row { display: flex; gap: var(--s-2); align-items: center; }
.error {
  color: var(--red);
  background: var(--red-soft);
  padding: var(--s-3) var(--s-4);
  border-radius: var(--r-control);
  font-size: 15px;
}

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

.app {
  display: grid;
  grid-template-columns: var(--side-w) minmax(0, 1fr);
  height: 100vh;
  height: 100dvh;
}

/* the list of sessions */
.side {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--side);
  box-shadow: 1px 0 0 var(--line);
  z-index: 2;
}
.side-head {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: calc(var(--s-3) + env(safe-area-inset-top)) var(--s-3) var(--s-2) calc(var(--s-4) + env(safe-area-inset-left));
}
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; flex: 1; font-weight: 650; font-size: 17px; letter-spacing: -0.012em; color: var(--text); text-decoration: none; }
.brand img { width: 28px; height: 28px; transition: transform var(--t-4) var(--spring); }
.brand:hover img { transform: rotate(-10deg); }
.brand span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.new-btn { width: 38px; height: 38px; min-height: 0; padding: 0; border-radius: 12px; background: var(--card); color: var(--accent); box-shadow: var(--shadow-card); }
.new-btn:hover { background: var(--accent); color: var(--on-accent); }
.new-btn svg { width: 20px; height: 20px; }
.side-search { padding: var(--s-1) var(--s-3) var(--s-2) calc(var(--s-3) + env(safe-area-inset-left)); }
.side-search input { min-height: 38px; padding: 8px 12px 8px 36px; font-size: 15px; border-radius: 12px; background: var(--card) no-repeat 11px center / 17px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238c8c97' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='m16 16 4 4'/%3E%3C/svg%3E"); }
.side-search input:hover { background-color: var(--card); }
.side-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s-1) var(--s-2) var(--s-4) calc(var(--s-2) + env(safe-area-inset-left));
  scrollbar-width: thin;
}
.side-group { padding: var(--s-3) var(--s-3) var(--s-1); color: var(--faint); font-size: 12px; font-weight: 650; letter-spacing: 0.02em; text-transform: uppercase; }
.srow {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  column-gap: 9px;
  row-gap: 1px;
  padding: 9px 12px;
  margin: 1px 0;
  border-radius: 15px;
  color: var(--text);
  text-decoration: none;
  transition: background-color var(--t-2) var(--ease), box-shadow var(--t-2) var(--ease);
}
.srow:hover { background: color-mix(in srgb, var(--card) 55%, transparent); text-decoration: none; }
.srow[aria-current="page"] { background: var(--card); box-shadow: var(--shadow-card); }
.srow .sdot { grid-row: 1; width: 8px; height: 8px; border-radius: 50%; background: transparent; }
.srow .stitle { grid-row: 1; font-size: 15px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; letter-spacing: -0.005em; }
.srow .stime { grid-row: 1; font-size: 12px; color: var(--faint); font-variant-numeric: tabular-nums; white-space: nowrap; }
.srow .ssub { grid-column: 2 / 4; font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.srow .ssub.work { color: var(--accent); }
.srow .ssub.wait { color: var(--amber); font-weight: 550; }
.srow[data-status="working"] .sdot { background: var(--accent); animation: breathe 1.4s var(--ease) infinite; }
.srow[data-status="waiting"] .sdot { background: var(--amber); animation: breathe 1.4s var(--ease) infinite; }
.srow[data-unread="true"] .sdot { background: var(--accent); }
.srow[data-unread="true"] .stitle { font-weight: 700; }
.srow[data-outcome="error"] .sdot, .srow[data-outcome="crashed"] .sdot { background: var(--red); }
.srow .spin { width: 8px; height: 8px; }
.side-empty { padding: var(--s-6) var(--s-4); color: var(--muted); font-size: 14px; text-align: center; }
.side-foot {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-2) var(--s-3) calc(var(--s-3) + env(safe-area-inset-bottom)) calc(var(--s-3) + env(safe-area-inset-left));
  box-shadow: 0 -1px 0 var(--line);
}
.side-foot .procs { flex: 1; font-size: 12.5px; color: var(--faint); min-width: 0; }
.limit-banner { margin: 0 var(--s-3) var(--s-2); padding: 10px 12px; border-radius: 14px; background: var(--amber-soft); color: var(--amber); font-size: 13px; font-weight: 550; }
.limit-banner.bad { background: var(--red-soft); color: var(--red); }

/* the chat */
.chat { position: relative; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--bg); }
.chat-head {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: var(--s-2);
  min-height: calc(var(--head-h) + env(safe-area-inset-top));
  padding: calc(var(--s-2) + env(safe-area-inset-top)) max(var(--s-4), env(safe-area-inset-right)) var(--s-2) var(--s-4);
  box-shadow: 0 1px 0 transparent;
  transition: box-shadow var(--t-2) var(--ease);
}
.chat-head.edge { box-shadow: 0 1px 0 var(--line); }
.chat-head::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: color-mix(in srgb, var(--bg) 76%, transparent);
  -webkit-backdrop-filter: saturate(180%) blur(22px);
  backdrop-filter: saturate(180%) blur(22px);
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .chat-head::before { background: var(--bg); } }
.back-btn { display: none; margin-left: -6px; }
.head-main { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.head-title {
  appearance: none;
  display: block;
  width: fit-content;
  max-width: 100%;
  min-height: 0;
  padding: 1px 6px;
  margin-left: -6px;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  font-size: 16.5px;
  font-weight: 650;
  letter-spacing: -0.012em;
  text-align: left;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.head-title:hover { background: var(--field); color: var(--text); }
.head-sub { display: flex; align-items: center; gap: 6px; min-width: 0; font-size: 12.5px; color: var(--muted); }
.head-sub .cwd { font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; direction: rtl; text-align: left; unicode-bidi: plaintext; }
.head-sub .state { flex-shrink: 0; font-weight: 550; }
.head-sub .state.work { color: var(--accent); }
.head-sub .state.wait { color: var(--amber); }
.head-chips { display: flex; align-items: center; gap: 6px; }
.chip-btn {
  min-height: 34px;
  padding: 0 11px;
  gap: 6px;
  border-radius: 11px;
  background: var(--field);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
}
.chip-btn:hover { background: var(--field-hover); color: var(--text); }
.chip-btn svg { width: 16px; height: 16px; color: var(--muted); }
.chip-btn.hot { background: var(--red-soft); color: var(--red); }
.chip-btn.hot svg { color: var(--red); }
.chip-btn.plan { background: var(--accent-soft); color: var(--accent); }
.chip-btn.plan svg { color: var(--accent); }

.scroller {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  scroll-padding-top: calc(var(--head-h) + 12px);
}
.feed {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: 100%;
  max-width: calc(var(--feed-w) + 2 * var(--s-5));
  margin: 0 auto;
  padding: calc(var(--head-h) + env(safe-area-inset-top) + var(--s-4)) var(--s-5) calc(var(--dock-h) + var(--s-6));
}
.feed-top { display: flex; justify-content: center; min-height: 1px; }
.feed-top .spinner { color: var(--faint); margin: var(--s-2); }
.feed-start { text-align: center; color: var(--faint); font-size: 13px; padding: var(--s-2) 0; }

/* empty session */
.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--s-3);
  margin: auto;
  padding: var(--s-8) var(--s-4);
  max-width: 520px;
}
.empty .big-icon { display: grid; place-items: center; width: 72px; height: 72px; border-radius: 22px; background: var(--card); box-shadow: var(--shadow-card); margin-bottom: var(--s-2); }
.empty .big-icon img { width: 44px; height: 44px; }
.empty h2 { font-size: 24px; letter-spacing: -0.02em; }
.empty .cwd-chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 11px; background: var(--card); color: var(--muted); font-family: var(--mono); font-size: 13px; max-width: 100%; }
.empty .cwd-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty .tips { display: grid; gap: var(--s-2); width: 100%; margin-top: var(--s-3); }
.empty .tip { display: flex; align-items: center; gap: var(--s-3); padding: 12px 14px; border-radius: 16px; background: var(--card); color: var(--text); font-size: 14.5px; font-weight: 500; text-align: left; justify-content: flex-start; min-height: 0; white-space: normal; box-shadow: var(--shadow-card); }
.empty .tip:hover { background: var(--card); color: var(--accent); }
.empty .tip svg { width: 18px; height: 18px; color: var(--accent); }

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

.msg { min-width: 0; }
.msg-user {
  align-self: flex-end;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--s-2);
  max-width: min(86%, 660px);
  margin-top: var(--s-2);
}
.bubble {
  padding: 10px 16px;
  border-radius: 22px;
  background: var(--bubble);
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 16px;
  line-height: 1.5;
}
.bubble a { color: inherit; text-decoration: underline 1px; }
.bubble.cmd { font-family: var(--mono); font-size: 14.5px; background: var(--card); color: var(--accent); box-shadow: var(--shadow-card); }
.msg-user.queued .bubble { opacity: 0.6; }
.msg-user .queue-note { display: flex; align-items: center; gap: 5px; font-size: 12px; color: var(--faint); }
.msg-user .queue-note svg { width: 13px; height: 13px; }
.thumbs { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.thumb { display: block; width: 132px; height: 132px; padding: 0; border-radius: 18px; overflow: hidden; background: var(--field); min-height: 0; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb:hover { background: var(--field); transform: scale(1.02); }
.fchips { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 6px; }
.fchip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  font-size: 13.5px;
  font-weight: 550;
  text-decoration: none;
  box-shadow: var(--shadow-card);
}
.fchip:hover { color: var(--accent); text-decoration: none; }
.fchip svg { width: 17px; height: 17px; color: var(--accent); }
.fchip .fmeta { color: var(--faint); font-weight: 400; font-size: 12.5px; white-space: nowrap; }
.fchip .fname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }

.msg-text { padding: 0 2px; }
.msg-text.streaming > .prose > :last-child::after {
  content: "";
  display: inline-block;
  width: 0.5em;
  height: 1.05em;
  margin-left: 2px;
  vertical-align: -0.15em;
  border-radius: 3px;
  background: var(--accent);
  animation: caret 1s steps(2) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

/* Markdown */
.prose { font-size: 16px; line-height: 1.62; overflow-wrap: break-word; min-width: 0; }
.prose > * + * { margin-top: 0.8em; }
.prose h1, .prose h2, .prose h3, .prose h4, .prose h5, .prose h6 { line-height: 1.3; letter-spacing: -0.014em; margin-top: 1.25em; }
.prose > :first-child { margin-top: 0; }
.prose h1 { font-size: 23px; font-weight: 700; }
.prose h2 { font-size: 20px; font-weight: 680; }
.prose h3 { font-size: 17.5px; font-weight: 650; }
.prose h4, .prose h5, .prose h6 { font-size: 16px; font-weight: 650; }
.prose h1 + *, .prose h2 + *, .prose h3 + *, .prose h4 + * { margin-top: 0.45em; }
.prose strong { font-weight: 650; }
.prose ul, .prose ol { padding-left: 1.45em; }
.prose li + li { margin-top: 0.3em; }
.prose li > ul, .prose li > ol { margin-top: 0.3em; }
.prose li::marker { color: var(--faint); }
.prose ol > li::marker { font-variant-numeric: tabular-nums; }
.prose li:has(> input[type="checkbox"]) { list-style: none; margin-left: -1.45em; display: flex; gap: 8px; align-items: flex-start; }
.prose li > input[type="checkbox"] { margin-top: 4px; pointer-events: none; }
.prose hr { border: 0; height: 1px; background: var(--line); margin: 1.4em 0; }
.prose blockquote { padding: 2px 0 2px 16px; color: var(--muted); box-shadow: inset 3px 0 0 var(--well); }
.prose a { word-break: break-word; }
.prose code {
  font-family: var(--mono);
  font-size: 0.86em;
  background: var(--accent-soft);
  color: var(--text);
  padding: 2px 6px;
  border-radius: 7px;
  overflow-wrap: anywhere;
}
.prose img { max-width: 100%; border-radius: 14px; }
.table-wrap { overflow-x: auto; max-width: 100%; border-radius: 16px; background: var(--card); box-shadow: var(--shadow-card); }
.prose table { border-collapse: collapse; font-size: 14.5px; line-height: 1.45; min-width: 100%; }
.prose th { text-align: left; font-weight: 650; color: var(--muted); font-size: 13px; background: var(--card-2); }
.prose th, .prose td { padding: 9px 14px; box-shadow: 0 1px 0 var(--line); vertical-align: top; }
.prose tr:last-child td { box-shadow: none; }
.prose td code { white-space: nowrap; }

/* code blocks */
.code { position: relative; border-radius: 16px; background: var(--code-bg); box-shadow: var(--shadow-card); overflow: hidden; min-width: 0; }
.code-head { display: flex; align-items: center; justify-content: space-between; gap: var(--s-2); padding: 6px 6px 0 14px; min-height: 34px; color: var(--faint); font-size: 12px; font-weight: 600; font-family: var(--mono); }
.code-head button { min-height: 28px; padding: 0 9px; gap: 5px; border-radius: 9px; background: transparent; color: var(--faint); font-size: 12px; font-family: var(--font); font-weight: 550; }
.code-head button:hover { background: var(--field); color: var(--text); }
.code-head button svg { width: 14px; height: 14px; }
.code-head button.done { color: var(--green); }
.code pre { margin: 0; padding: 6px 14px 14px; overflow-x: auto; font-family: var(--mono); font-size: 13.5px; line-height: 1.55; tab-size: 4; scrollbar-width: thin; }
.code pre code { background: none; padding: 0; border-radius: 0; font-size: inherit; color: var(--text); overflow-wrap: normal; white-space: pre; }

/* highlight.js, in the palette */
.hljs-keyword, .hljs-selector-tag, .hljs-type, .hljs-doctag { color: var(--hl-keyword); }
.hljs-string, .hljs-regexp, .hljs-addition, .hljs-selector-attr, .hljs-selector-pseudo, .hljs-template-tag { color: var(--hl-string); }
.hljs-number, .hljs-symbol, .hljs-bullet, .hljs-variable.constant_ { color: var(--hl-number); }
.hljs-comment, .hljs-quote { color: var(--hl-comment); font-style: italic; }
.hljs-title, .hljs-title.function_, .hljs-section, .hljs-name { color: var(--hl-title); }
.hljs-literal, .hljs-deletion, .hljs-built_in { color: var(--hl-literal); }
.hljs-attr, .hljs-attribute, .hljs-property, .hljs-selector-class, .hljs-selector-id, .hljs-variable, .hljs-template-variable, .hljs-params { color: var(--hl-attr); }
.hljs-meta, .hljs-meta .hljs-keyword, .hljs-tag { color: var(--hl-meta); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 700; }

/* ------------------------------------------------------------ tool calls */

.tools {
  display: flex;
  flex-direction: column;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  overflow: hidden;
  min-width: 0;
}
.trow {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: 46px;
  padding: 8px 14px 8px 10px;
  border-radius: 0;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  text-align: left;
  justify-content: flex-start;
  white-space: nowrap;
}
.trow:hover { background: var(--card-2); color: var(--text); }
.trow:active { transform: none; background: var(--field); }
.trow + .tdetail, .tool + .tool { box-shadow: 0 -1px 0 var(--line); }
.tbody > .tool:first-child { box-shadow: 0 -1px 0 var(--line); }
.ti { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 9px; background: var(--field); color: var(--muted); flex-shrink: 0; }
.ti svg { width: 16px; height: 16px; }
.ti.stack { position: relative; background: var(--accent-soft); color: var(--accent); }
.tname { font-weight: 600; flex-shrink: 0; }
.tdesc { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 13.5px; }
.tdesc.mono { font-family: var(--mono); font-size: 12.5px; }
.tstat { display: grid; place-items: center; width: 20px; height: 20px; flex-shrink: 0; }
.tstat svg { width: 17px; height: 17px; }
.tstat .spinner { width: 15px; height: 15px; color: var(--accent); }
.tstat.ok { color: var(--green); }
.tstat.error { color: var(--red); }
.tstat.stopped { color: var(--faint); }
.tchev { width: 16px; height: 16px; color: var(--faint); transition: transform var(--t-3) var(--spring); flex-shrink: 0; }
[aria-expanded="true"] > .tchev { transform: rotate(90deg); }
.tsub { font-size: 12px; color: var(--accent); background: var(--accent-soft); padding: 2px 7px; border-radius: 7px; flex-shrink: 0; font-weight: 600; }
.tdetail { display: flex; flex-direction: column; gap: var(--s-2); padding: 4px 14px 14px 48px; min-width: 0; }
.tdetail .tlabel { font-size: 11.5px; font-weight: 650; color: var(--faint); letter-spacing: 0.03em; text-transform: uppercase; margin-top: 4px; }
.tdetail pre {
  margin: 0;
  padding: 10px 12px;
  border-radius: 12px;
  background: var(--card-2);
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.5;
  overflow-x: auto;
  max-height: 420px;
  overflow-y: auto;
  white-space: pre;
  scrollbar-width: thin;
}
.tdetail pre.wrap { white-space: pre-wrap; overflow-wrap: anywhere; }
.tdetail .path { font-family: var(--mono); font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.tdetail .prose { font-size: 14.5px; }
.diff { padding: 8px 0 !important; }
.diff span { display: block; padding: 0 12px; min-height: 1.5em; }
.diff .add { background: var(--green-soft); color: var(--green); }
.diff .del { background: var(--red-soft); color: var(--red); }
.diff .gap { color: var(--faint); }
.tgroup-head .tdesc { color: var(--text); font-weight: 500; font-family: var(--font); font-size: 14px; }
.tgroup-head .tcount { color: var(--faint); font-size: 13px; flex-shrink: 0; font-variant-numeric: tabular-nums; }
.tbody { display: flex; flex-direction: column; }
.tbody .trow { padding-left: 14px; }
.tbody .tdetail { padding-left: 52px; }
.todos { list-style: none; padding: 0; display: flex; flex-direction: column; gap: 4px; font-size: 14px; }
.todos li { display: flex; gap: 8px; align-items: flex-start; }
.todos .box { width: 17px; height: 17px; border-radius: 6px; background: var(--well); flex-shrink: 0; margin-top: 2px; display: grid; place-items: center; color: #fff; }
.todos .box svg { width: 12px; height: 12px; }
.todos .done .box { background: var(--green); }
.todos .done span { color: var(--faint); text-decoration: line-through; }
.todos .now .box { background: var(--accent); }
.todos .now span { font-weight: 600; }

/* files Claude shows */
.media { display: flex; flex-direction: column; gap: 6px; max-width: 100%; }
.media img, .media video { display: block; max-width: 100%; max-height: 560px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow-card); cursor: zoom-in; }
.media video { cursor: auto; width: 100%; }
.media .cap { font-size: 13.5px; color: var(--muted); padding: 0 4px; }
.fcard {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: 12px 14px;
  border-radius: 18px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  color: var(--text);
  text-decoration: none;
  max-width: 460px;
}
.fcard:hover { text-decoration: none; }
.fcard .ficon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 13px; background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.fcard .ficon svg { width: 21px; height: 21px; }
.fcard .fmain { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.fcard .fname { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.fcard .fmeta { font-size: 13px; color: var(--muted); }
.fcard .fdl { color: var(--faint); }
.fcard:hover .fdl { color: var(--accent); }

/* notices and turn results */
.notice-line { display: flex; align-items: center; justify-content: center; gap: 8px; color: var(--faint); font-size: 13px; text-align: center; padding: 2px 0; }
.notice-line::before, .notice-line::after { content: ""; flex: 1; height: 1px; background: var(--line); max-width: 120px; }
.notice-line.warn { color: var(--amber); }
.notice-line.ok { color: var(--green); }
.notice-card { padding: 12px 16px; border-radius: 18px; background: var(--card); box-shadow: var(--shadow-card); font-size: 14.5px; min-width: 0; }
.notice-card.error { background: var(--red-soft); color: var(--red); box-shadow: none; }
.notice-card.error .prose code, .notice-card.error .code { background: color-mix(in srgb, var(--red-soft) 60%, var(--card)); }
.notice-card.warn { background: var(--amber-soft); color: var(--amber); box-shadow: none; }
.notice-card .prose { font-size: 14.5px; }
details.fold > summary { display: flex; align-items: center; gap: 8px; cursor: pointer; list-style: none; color: var(--muted); font-size: 14px; font-weight: 550; }
details.fold > summary::-webkit-details-marker { display: none; }
details.fold > summary svg { width: 16px; height: 16px; transition: transform var(--t-3) var(--spring); }
details.fold[open] > summary svg { transform: rotate(90deg); }
details.fold[open] > summary { margin-bottom: var(--s-3); }
.result { display: flex; align-items: center; gap: 6px; color: var(--faint); font-size: 12.5px; padding: 0 4px; font-variant-numeric: tabular-nums; }
.result svg { width: 14px; height: 14px; }
.result.ok svg { color: var(--green); }
.result.error svg { color: var(--red); }

/* ------------------------------------------------------------ prompts */

.prompt {
  display: flex;
  flex-direction: column;
  gap: var(--s-3);
  padding: var(--s-4) var(--s-5) var(--s-5);
  border-radius: var(--r-tile);
  background: var(--card);
  box-shadow: var(--shadow-card), inset 0 0 0 1.5px var(--amber);
  min-width: 0;
  animation: rise var(--t-4) var(--ease-out) backwards;
}
.prompt.question, .prompt.plan { box-shadow: var(--shadow-card), inset 0 0 0 1.5px var(--accent); }
.prompt-head { display: flex; align-items: center; gap: 10px; }
.prompt-head .pi { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 11px; background: var(--amber-soft); color: var(--amber); flex-shrink: 0; }
.prompt.question .pi, .prompt.plan .pi { background: var(--accent-soft); color: var(--accent); }
.prompt-head .pi svg { width: 19px; height: 19px; }
.prompt-head h3 { font-size: 16px; font-weight: 650; line-height: 1.3; min-width: 0; overflow-wrap: anywhere; }
.prompt .pdesc { color: var(--muted); font-size: 14.5px; }
.prompt .preason { padding: 10px 12px; border-radius: 12px; background: var(--amber-soft); color: var(--amber); font-size: 14px; }
.prompt pre { margin: 0; padding: 10px 12px; border-radius: 12px; background: var(--card-2); font-family: var(--mono); font-size: 13px; line-height: 1.5; overflow: auto; max-height: 360px; white-space: pre-wrap; overflow-wrap: anywhere; }
.prompt .actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.prompt .reply { display: flex; gap: var(--s-2); }
.prompt .reply input { min-height: 40px; font-size: 15px; }
.prompt .reply button { min-height: 40px; }
.prompt .q { display: flex; flex-direction: column; gap: var(--s-2); }
.prompt .q + .q { padding-top: var(--s-3); box-shadow: 0 -1px 0 var(--line); }
.prompt .qhead { font-size: 12px; font-weight: 650; color: var(--accent); letter-spacing: 0.03em; text-transform: uppercase; }
.prompt .qtext { font-size: 15.5px; font-weight: 600; }
.opts { display: grid; gap: 6px; }
.opt {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  min-height: 0;
  padding: 11px 14px;
  border-radius: var(--r-inner);
  background: var(--card-2);
  color: var(--text);
  font-weight: 600;
  font-size: 15px;
  text-align: left;
  white-space: normal;
  box-shadow: inset 0 0 0 0 var(--accent);
}
.opt:hover { background: var(--field-hover); color: var(--text); }
.opt .odesc { font-weight: 400; font-size: 13.5px; color: var(--muted); }
.opt[aria-pressed="true"] { background: var(--accent-soft); box-shadow: inset 0 0 0 1.5px var(--accent); color: var(--text); }
.prompt.settled { box-shadow: var(--shadow-card); padding: 12px 16px; gap: var(--s-2); animation: none; }
.prompt.settled .prompt-head h3 { font-size: 15px; }
.prompt.settled .pi { width: 28px; height: 28px; border-radius: 9px; background: var(--field); color: var(--muted); }
.prompt.settled .pi svg { width: 16px; height: 16px; }
.outcome { font-size: 14px; font-weight: 550; color: var(--muted); }
.outcome.good { color: var(--green); }
.outcome.bad { color: var(--red); }
.plan-body { max-height: 60vh; overflow: auto; padding: 4px 2px; }

/* ------------------------------------------------------------ the dock */

.dock {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 5;
  padding: var(--s-6) max(var(--s-4), env(safe-area-inset-right)) calc(var(--s-3) + env(safe-area-inset-bottom)) max(var(--s-4), env(safe-area-inset-left));
  background: linear-gradient(to top, var(--bg) 55%, color-mix(in srgb, var(--bg) 0%, transparent));
  pointer-events: none;
}
.dock > * { pointer-events: auto; width: 100%; max-width: var(--feed-w); margin-left: auto; margin-right: auto; }
.status-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  max-width: min(100%, var(--feed-w));
  margin-bottom: var(--s-2);
  padding: 7px 12px 7px 10px;
  border-radius: 13px;
  background: var(--card);
  box-shadow: var(--shadow-card);
  font-size: 13.5px;
  color: var(--muted);
  min-width: 0;
}
.status-bar .pulse { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); flex-shrink: 0; animation: breathe 1.4s var(--ease) infinite; }
.status-bar.wait .pulse { background: var(--amber); }
.status-bar .sb-act { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; color: var(--text); font-weight: 500; }
.status-bar .sb-meta { flex-shrink: 0; font-variant-numeric: tabular-nums; }
.status-bar .sb-todo { flex-shrink: 0; padding: 2px 7px; border-radius: 7px; background: var(--accent-soft); color: var(--accent); font-weight: 600; font-size: 12.5px; cursor: pointer; }
.to-bottom {
  position: absolute;
  right: max(var(--s-5), env(safe-area-inset-right));
  bottom: calc(var(--dock-h) + var(--s-2));
  z-index: 5;
  width: 40px;
  height: 40px;
  min-height: 0;
  padding: 0;
  border-radius: 14px;
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-float);
  animation: pop var(--t-3) var(--spring);
}
.to-bottom:hover { background: var(--card); color: var(--accent); }
.to-bottom svg { width: 20px; height: 20px; }
.composer {
  position: relative;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-card);
  background: var(--card);
  box-shadow: var(--shadow-dock);
  transition: box-shadow var(--t-2) var(--ease);
}
.composer.drag { box-shadow: var(--shadow-dock), inset 0 0 0 2px var(--accent); }
.composer .tray { display: flex; flex-wrap: wrap; gap: 6px; padding: 10px 10px 0; }
.composer .att { position: relative; display: flex; align-items: center; gap: 8px; max-width: 220px; height: 52px; padding: 0 30px 0 6px; border-radius: 14px; background: var(--field); font-size: 13px; }
.composer .att img { width: 40px; height: 40px; border-radius: 10px; object-fit: cover; }
.composer .att .aicon { display: grid; place-items: center; width: 40px; height: 40px; border-radius: 10px; background: var(--card); color: var(--accent); }
.composer .att .aicon svg { width: 18px; height: 18px; }
.composer .att .aname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 550; min-width: 0; }
.composer .att .ameta { font-size: 11.5px; color: var(--faint); }
.composer .att .ax { position: absolute; top: 4px; right: 4px; width: 22px; height: 22px; min-height: 0; padding: 0; border-radius: 7px; background: transparent; color: var(--faint); }
.composer .att .ax:hover { background: var(--card); color: var(--red); }
.composer .att .ax svg { width: 14px; height: 14px; }
.composer .att.up::after { content: ""; position: absolute; left: 6px; right: 30px; bottom: 5px; height: 3px; border-radius: 2px; background: var(--accent); transform-origin: left; transform: scaleX(var(--p, 0)); transition: transform var(--t-2) linear; }
.composer .att.fail { background: var(--red-soft); color: var(--red); }
.cbar { display: flex; align-items: flex-end; gap: 4px; padding: 6px; }
.cbar textarea {
  flex: 1;
  min-height: 44px;
  max-height: 42vh;
  padding: 11px 6px;
  border-radius: 0;
  background: transparent !important;
  box-shadow: none !important;
  resize: none;
  line-height: 1.45;
  font-size: 16px;
  scrollbar-width: thin;
}
.cbar .icon-btn { width: 44px; height: 44px; border-radius: 16px; }
.send-btn { width: 44px; height: 44px; min-height: 0; padding: 0; border-radius: 16px; flex-shrink: 0; }
.send-btn svg { width: 21px; height: 21px; }
.send-btn.stop { background: var(--text); color: var(--bg); }
.send-btn.stop:hover { background: color-mix(in srgb, var(--text) 82%, var(--bg)); color: var(--bg); }
.send-btn:disabled { opacity: 1; background: var(--field); color: var(--faint); }
.composer .chint { padding: 0 16px 10px; font-size: 12.5px; color: var(--amber); }
.slash {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(100% + 8px);
  max-height: min(340px, 50vh);
  overflow-y: auto;
  padding: 6px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow-float);
  z-index: 3;
  animation: drop-up var(--t-3) var(--ease-out);
}
.slash button { display: flex; flex-direction: column; align-items: flex-start; gap: 1px; width: 100%; min-height: 0; padding: 8px 12px; border-radius: 12px; background: transparent; color: var(--text); font-weight: 600; font-size: 14.5px; text-align: left; white-space: normal; }
.slash button span { font-weight: 400; font-size: 13px; color: var(--muted); }
.slash button .sn { font-family: var(--mono); font-weight: 600; font-size: 14px; color: var(--text); }
.slash button.on, .slash button:hover { background: var(--field); color: var(--text); }

/* ------------------------------------------------------------ menus, sheets, toasts */

.menu {
  position: fixed;
  z-index: 70;
  min-width: 230px;
  max-width: min(380px, calc(100vw - 24px));
  max-height: min(70vh, 560px);
  overflow-y: auto;
  padding: 6px;
  border-radius: 20px;
  background: var(--card);
  box-shadow: var(--shadow-float);
  animation: pop var(--t-3) var(--spring);
  transform-origin: top right;
}
.menu .mi { display: flex; align-items: center; gap: 11px; width: 100%; min-height: 42px; padding: 8px 12px; border-radius: 13px; background: transparent; color: var(--text); font-weight: 500; font-size: 15px; text-align: left; justify-content: flex-start; white-space: normal; }
.menu .mi:hover { background: var(--field); color: var(--text); }
.menu .mi svg { width: 18px; height: 18px; color: var(--muted); }
.menu .mi .mt { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.menu .mi .md { font-size: 12.5px; color: var(--muted); font-weight: 400; line-height: 1.35; }
.menu .mi.on { color: var(--accent); font-weight: 600; }
.menu .mi.on svg { color: var(--accent); }
.menu .mi .check { width: 18px; height: 18px; color: var(--accent); margin-left: auto; }
.menu .mi.danger, .menu .mi.danger svg { color: var(--red); }
.menu .mi.danger:hover { background: var(--red-soft); }
.menu .msep { height: 1px; margin: 5px 10px; background: var(--line); }
.menu .mlabel { padding: 8px 12px 4px; font-size: 12px; font-weight: 650; color: var(--faint); text-transform: uppercase; letter-spacing: 0.03em; }
.scrim { position: fixed; inset: 0; z-index: 69; }

dialog.sheet {
  border: 0;
  padding: 0;
  width: min(560px, calc(100vw - 32px));
  max-height: min(88vh, 860px);
  border-radius: var(--r-card);
  background: var(--card);
  color: var(--text);
  box-shadow: var(--shadow-float);
  overflow: hidden;
}
dialog.sheet[open] { display: flex; flex-direction: column; animation: pop var(--t-3) var(--spring); }
dialog.sheet::backdrop { background: var(--backdrop); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); animation: fade-in var(--t-3) var(--ease); }
.sheet-head { display: flex; align-items: center; gap: var(--s-2); padding: var(--s-4) var(--s-3) var(--s-2) var(--s-6); }
.sheet-head h2 { flex: 1; font-size: 19px; font-weight: 680; letter-spacing: -0.014em; }
.sheet-body { display: flex; flex-direction: column; gap: var(--s-4); padding: var(--s-2) var(--s-6) var(--s-6); overflow-y: auto; min-height: 0; }
.sheet-foot { display: flex; justify-content: flex-end; gap: var(--s-2); padding: var(--s-3) var(--s-6) calc(var(--s-5) + env(safe-area-inset-bottom)); box-shadow: 0 -1px 0 var(--line); }
.section { display: flex; flex-direction: column; gap: var(--s-3); }
.section + .section { padding-top: var(--s-4); box-shadow: 0 -1px 0 var(--line); }
.section h3 { font-size: 15px; font-weight: 650; }
.list { display: flex; flex-direction: column; }
.list .li { display: flex; align-items: center; gap: var(--s-3); min-height: 52px; padding: 8px 0; box-shadow: 0 -1px 0 var(--line); }
.list .li:first-child { box-shadow: none; }
.list .li > svg { width: 20px; height: 20px; color: var(--muted); }
.list .li .lmain { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.list .li .ltitle { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.list .li .lsub { font-size: 13px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick { display: flex; align-items: center; gap: var(--s-3); width: 100%; min-height: 50px; padding: 8px 12px; border-radius: 14px; background: transparent; color: var(--text); font-weight: 500; text-align: left; justify-content: flex-start; white-space: normal; }
.pick:hover { background: var(--field); color: var(--text); }
.pick svg { width: 19px; height: 19px; color: var(--accent); }
.pick .lmain { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.pick .ltitle { font-weight: 600; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pick .lsub { font-size: 12.5px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 400; }
.pick:disabled { opacity: 0.55; }
.crumbs { display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-family: var(--mono); font-size: 13px; }
.crumbs button { min-height: 28px; padding: 0 6px; border-radius: 8px; background: transparent; color: var(--accent); font-family: var(--mono); font-weight: 500; font-size: 13px; }
.crumbs button:hover { background: var(--accent-soft); color: var(--accent); }
.crumbs span { color: var(--faint); }
.dirs { display: flex; flex-direction: column; max-height: 300px; overflow-y: auto; margin: 0 -12px; padding: 0 4px; }
.dirs .pick { min-height: 40px; padding: 6px 12px; }
.dirs .pick svg { width: 17px; height: 17px; }
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; width: fit-content; padding: 4px; background: var(--field); border-radius: 15px; }
.segmented button { min-height: 36px; background: transparent; color: var(--text); font-weight: 550; padding: 0 var(--s-4); border-radius: 11px; gap: 6px; }
.segmented button svg { width: 17px; height: 17px; }
.segmented button:hover { background: var(--field-hover); color: var(--text); }
.segmented button[aria-pressed="true"] { background: var(--knob); color: var(--accent); box-shadow: var(--shadow-knob); }
.tabs2 { display: flex; gap: 2px; padding: 4px; background: var(--field); border-radius: 15px; }
.tabs2 button { flex: 1; min-height: 36px; background: transparent; color: var(--muted); font-weight: 550; font-size: 14px; border-radius: 11px; }
.tabs2 button[aria-pressed="true"] { background: var(--knob); color: var(--text); box-shadow: var(--shadow-knob); }
.badge { display: inline-flex; align-items: center; gap: 5px; min-height: 22px; padding: 0 9px; border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 650; white-space: nowrap; flex-shrink: 0; }
.badge svg { width: 13px; height: 13px; }
.badge.green { background: var(--green-soft); color: var(--green); }
.badge.amber { background: var(--amber-soft); color: var(--amber); }
.badge.red { background: var(--red-soft); color: var(--red); }
.badge.plain { background: var(--field); color: var(--muted); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 8px 16px; font-size: 14.5px; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

.toasts { position: fixed; left: 50%; bottom: calc(var(--toast-y, 24px) + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 90; display: flex; flex-direction: column; align-items: center; gap: 8px; width: max-content; max-width: calc(100vw - 24px); pointer-events: none; }
.toast {
  display: flex;
  align-items: center;
  gap: 10px;
  max-width: 100%;
  padding: 11px 16px;
  border-radius: 16px;
  background: color-mix(in srgb, var(--text) 94%, transparent);
  color: var(--bg);
  font-size: 14.5px;
  font-weight: 500;
  box-shadow: var(--shadow-float);
  pointer-events: auto;
  animation: drop-up var(--t-4) var(--spring);
}
.toast.error { background: var(--red); color: var(--on-red); }
.toast.link { cursor: pointer; }
.toast svg { width: 18px; height: 18px; }
.toast .tt { display: flex; flex-direction: column; min-width: 0; }
.toast .tt b { font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.toast .tt span { opacity: 0.8; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
.toast.out { animation: fade-out var(--t-3) var(--ease) forwards; }

.lightbox { position: fixed; inset: 0; z-index: 95; display: grid; place-items: center; padding: calc(16px + env(safe-area-inset-top)) 16px calc(16px + env(safe-area-inset-bottom)); background: rgba(8, 8, 14, 0.86); -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px); animation: fade-in var(--t-3) var(--ease); cursor: zoom-out; }
.lightbox img { max-width: 100%; max-height: 100%; border-radius: 14px; box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5); animation: pop var(--t-4) var(--spring); }
.lightbox .lb-close { position: absolute; top: calc(12px + env(safe-area-inset-top)); right: 12px; width: 44px; height: 44px; min-height: 0; padding: 0; border-radius: 14px; background: rgba(255, 255, 255, 0.12); color: #fff; }
.lightbox .lb-open { position: absolute; bottom: calc(14px + env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); background: rgba(255, 255, 255, 0.14); color: #fff; }

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

.login { display: grid; place-items: center; min-height: 100vh; min-height: 100dvh; padding: 24px; overflow-y: auto; }
.login-card { display: flex; flex-direction: column; align-items: center; gap: var(--s-4); width: min(420px, 100%); padding: var(--s-8) var(--s-7) var(--s-7); border-radius: var(--r-card); background: var(--card); box-shadow: var(--shadow-card); text-align: center; animation: rise var(--t-4) var(--ease-out) backwards; }
.login-card img { width: 64px; height: 64px; animation: pop var(--t-4) var(--spring) 0.1s backwards; }
.login-card h1 { font-size: 26px; letter-spacing: -0.024em; }
.login-card .buttons { flex-direction: column; width: 100%; margin-top: var(--s-2); }
.login-card .buttons button { width: 100%; min-height: 50px; font-size: 16px; }
.login-card .note { font-size: 13.5px; color: var(--muted); }
.boot { display: grid; place-items: center; height: 100vh; height: 100dvh; color: var(--faint); }

/* ------------------------------------------------------------ motion */

@keyframes rise { from { opacity: 0; transform: translateY(10px); } }
@keyframes pop { from { opacity: 0; transform: scale(0.94); } }
@keyframes drop-up { from { opacity: 0; transform: translateY(8px) scale(0.98); } }
@keyframes fade-in { from { opacity: 0; } }
@keyframes fade-out { to { opacity: 0; transform: translateY(6px); } }
@keyframes breathe { 50% { transform: scale(0.72); opacity: 0.6; } }
@keyframes slide-in { from { transform: translateX(28px); opacity: 0.4; } }
@keyframes sheet-up { from { transform: translateY(100%); } }

@media (prefers-reduced-motion: no-preference) {
  .feed > .fresh { animation: rise var(--t-4) var(--ease-out) backwards; }
  .srow { animation: none; }
  .tdetail { animation: rise var(--t-3) var(--ease-out); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ------------------------------------------------------------ phones */

@media (max-width: 860px) {
  :root { --head-h: 56px; }
  .app { grid-template-columns: minmax(0, 1fr); }
  .side, .chat { grid-area: 1 / 1; }
  .side { box-shadow: none; background: var(--bg); }
  body[data-view="chat"] .side { visibility: hidden; }
  body[data-view="list"] .chat { visibility: hidden; }
  body[data-view="chat"] .chat { animation: slide-in var(--t-3) var(--ease-out); }
  .back-btn { display: inline-flex; }
  .head-chips .chip-btn .cl { display: none; }
  .head-chips .chip-btn { padding: 0 9px; }
  .head-chips .chip-btn.opt-hide { display: none; }
  .feed { padding-left: var(--s-4); padding-right: var(--s-4); gap: 12px; }
  .srow { padding: 11px 12px; }
  .side-head { padding-left: calc(var(--s-5) + env(safe-area-inset-left)); }
  .brand { font-size: 20px; font-weight: 700; }
  .brand img { width: 30px; height: 30px; }
  .msg-user { max-width: 92%; }
  .thumb { width: 108px; height: 108px; }
  dialog.sheet { width: 100vw; max-width: 100vw; max-height: 92dvh; margin: auto 0 0; border-radius: var(--r-card) var(--r-card) 0 0; }
  dialog.sheet[open] { animation: sheet-up var(--t-4) var(--ease-out); }
  .sheet-head { padding-left: var(--s-5); }
  .sheet-body { padding-left: var(--s-5); padding-right: var(--s-5); }
  .sheet-foot { padding-left: var(--s-5); padding-right: var(--s-5); }
  .sheet-foot button { flex: 1; }
  .tdetail { padding-left: 14px; }
  .tbody .tdetail { padding-left: 14px; }
  .prompt { padding: var(--s-4); }
  .prompt .actions button { flex: 1 1 auto; }
  .login-card { padding: var(--s-7) var(--s-5) var(--s-6); }
}
@media (max-width: 480px) {
  .head-chips .chip-btn.opt-hide2 { display: none; }
  .bubble { font-size: 15.5px; }
  .prose { font-size: 15.5px; }
}
@media (hover: none) {
  .srow:hover { background: transparent; }
  .srow[aria-current="page"] { background: transparent; box-shadow: none; }
  .trow:hover { background: transparent; }
}

/* -------------------------------------------- squircles, Safari's way
   Where corner-shape is missing but a mask can be drawn — Safari. Firefox can do neither and keeps the plain
   rounding, which is right: a mask there would leave the corners square. */
@supports not (corner-shape: squircle) {
  @supports (-webkit-mask-box-image: none) {
    .tools, .code, .table-wrap, .prompt, .notice-card, .fcard, .media img, .media video, .composer .att, .thumb, .bubble,
    .fchip, .status-bar, .new-btn, .srow, .limit-banner, .empty .big-icon, .empty .tip, .empty .cwd-chip, .opt,
    .segmented, .tabs2, .chip-btn, .icon-btn, .send-btn, .to-bottom, .ti, .login-card,
    button, .button, input, select, textarea {
      border-radius: 0;
      -webkit-mask-box-image: var(--squircle-img) 48% / var(--sqr, 18px) stretch;
    }
    .cbar textarea { -webkit-mask-box-image: none; }
    .tools { --sqr: 24px; box-shadow: none; filter: var(--drop-card); }
    .code, .table-wrap, .fcard, .notice-card { --sqr: 22px; box-shadow: none; filter: var(--drop-card); }
    .prompt { --sqr: 29px; box-shadow: none; filter: var(--drop-card); background: color-mix(in srgb, var(--card) 88%, var(--amber-soft)); }
    .prompt.question, .prompt.plan { background: color-mix(in srgb, var(--card) 80%, var(--accent-soft)); }
    .prompt.settled { background: var(--card); }
    .media img, .media video { --sqr: 24px; box-shadow: none; filter: var(--drop-card); }
    .bubble { --sqr: 29px; }
    .login-card { --sqr: 34px; box-shadow: none; filter: var(--drop-card); }
    .thumb { --sqr: 24px; }
    .composer .att { --sqr: 18px; }
    .fchip, .status-bar, .srow { --sqr: 19px; box-shadow: none; }
    .srow[aria-current="page"] { filter: var(--drop-card); }
    .fchip, .status-bar { filter: var(--drop-card); }
    .new-btn { --sqr: 16px; box-shadow: none; filter: var(--drop-card); }
    .limit-banner, .opt { --sqr: 19px; }
    .opt[aria-pressed="true"] { box-shadow: none; background: color-mix(in srgb, var(--accent-soft) 70%, var(--accent) 14%); }
    .empty .big-icon { --sqr: 29px; box-shadow: none; filter: var(--drop-card); }
    .empty .tip { --sqr: 21px; box-shadow: none; filter: var(--drop-card); }
    .empty .cwd-chip { --sqr: 15px; }
    .segmented, .tabs2 { --sqr: 19px; }
    .segmented button, .tabs2 button { --sqr: 15px; }
    .chip-btn { --sqr: 15px; }
    .icon-btn, .ti { --sqr: 13px; }
    .send-btn, .cbar .icon-btn { --sqr: 21px; }
    .to-bottom { --sqr: 18px; box-shadow: none; filter: var(--drop-float); }
    button.small, .button.small { --sqr: 14px; }
    .segmented button[aria-pressed="true"], .tabs2 button[aria-pressed="true"] { box-shadow: none; filter: var(--drop-knob); }
    input:not([type="radio"], [type="checkbox"], [type="file"]):focus, select:focus, textarea:focus { box-shadow: none; filter: drop-shadow(0 0 1px var(--accent)) drop-shadow(0 0 2px var(--accent-ring)); }
    :is(button, .button):focus-visible { outline: none; filter: drop-shadow(0 0 1px var(--accent)) drop-shadow(0 0 3px var(--accent-ring)); }
  }
}

.sheet-stack { display: flex; flex-direction: column; gap: var(--s-4); }

/* a new theme spreads from its button over the whole page */
::view-transition-old(root) { animation: none; z-index: 0; }
::view-transition-new(root) { animation: none; mix-blend-mode: normal; z-index: 1; }
.empty .cwd-chip svg { width: 15px; height: 15px; }

/* subscription usage: the meter under the list, and its sheet */
.usage {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: auto;
  min-height: 0;
  margin: 0 var(--s-3) var(--s-2);
  padding: 10px 12px;
  border-radius: 15px;
  background: color-mix(in srgb, var(--card) 60%, transparent);
  color: var(--text);
  font-weight: 500;
  white-space: normal;
}
.usage:hover { background: var(--card); color: var(--text); }
.usage:active { transform: scale(0.98); }
.uwin { display: grid; grid-template-columns: 54px 1fr auto; grid-template-rows: auto auto; align-items: center; column-gap: 8px; row-gap: 1px; font-size: 12.5px; }
.uwin .ulabel { color: var(--muted); font-weight: 550; }
.uwin .upct { font-variant-numeric: tabular-nums; font-weight: 650; }
.uwin .ureset { grid-column: 2 / 4; color: var(--faint); font-size: 11.5px; text-align: left; }
.ubar { position: relative; display: block; height: 6px; border-radius: 3px; background: var(--well); overflow: hidden; }
.ubar.big { height: 8px; border-radius: 4px; }
.ubar .ufill { position: absolute; inset: 0 auto 0 0; border-radius: inherit; background: var(--green); transition: width var(--t-4) var(--ease-out); }
.warn .ufill { background: var(--amber); }
.bad .ufill { background: var(--red); }
.warn .upct { color: var(--amber); }
.bad .upct { color: var(--red); }
.uline { display: flex; flex-direction: column; gap: 6px; }
.uline + .uline { padding-top: var(--s-3); }
.uline .upct { font-weight: 700; font-variant-numeric: tabular-nums; }
pre.report { margin: 0; padding: 12px; border-radius: 12px; background: var(--card-2); font-family: var(--mono); font-size: 12.5px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; max-height: 50vh; overflow: auto; }

/* usage rings in the corner: S — the 5-hour session, W — the week */
.gauges {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 0;
  padding: 3px;
  margin-left: -3px;
  border-radius: 12px;
  background: transparent;
  color: var(--text);
}
.gauges:hover { background: var(--field); color: var(--text); }
.ring { width: 32px; height: 32px; }
.ring .rtrack { fill: none; stroke: var(--well); stroke-width: 3.4; }
.ring .rfill { fill: none; stroke: var(--green); stroke-width: 3.4; stroke-linecap: round; transition: stroke-dashoffset var(--t-4) var(--ease-out), stroke var(--t-3) var(--ease); }
.ring.warn .rfill { stroke: var(--amber); }
.ring.bad .rfill { stroke: var(--red); }
.ring text { fill: var(--muted); font: 700 11px var(--font); }
.ring.warn text { fill: var(--amber); }
.ring.bad text { fill: var(--red); }
