/* Conductor — mobile-first design system.
   Phones get a bottom tab bar, cards and bottom sheets; ≥ 900px adds a sidebar and roomier layouts. */

:root {
  --bg: #f6f4f0;
  --bg-glow: radial-gradient(1200px 600px at 100% -10%, rgba(217, 119, 87, .10), transparent 60%);
  --surface: #ffffff;
  --surface-2: #f3f0eb;
  --surface-3: #ebe7e0;
  --line: rgba(31, 28, 24, .09);
  --line-strong: rgba(31, 28, 24, .16);
  --text: #1c1a17;
  --text-2: #6b655c;
  --text-3: #9a948a;
  --accent: #d26a46;
  --accent-2: #e98b63;
  --accent-ink: #fff;
  --accent-soft: rgba(210, 106, 70, .12);
  --blue: #2f6fd6;
  --green: #22915a;
  --amber: #c27a12;
  --red: #d0453b;
  --violet: #7a5af0;
  --teal: #13908f;
  --code: #f2efe9;
  --chrome: rgba(250, 248, 245, .82);
  --shadow-sm: 0 1px 2px rgba(30, 25, 20, .06);
  --shadow: 0 1px 2px rgba(30, 25, 20, .05), 0 8px 24px -8px rgba(30, 25, 20, .12);
  --shadow-lg: 0 24px 64px -16px rgba(30, 25, 20, .35);
  --r-sm: 10px;
  --r: 16px;
  --r-lg: 22px;
  --tabbar-h: 64px;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", Inter, Roboto, "Helvetica Neue", sans-serif;
  --display: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Segoe UI", Inter, Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;
  --ease: cubic-bezier(.2, .8, .2, 1);
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d0c0b;
    --bg-glow: radial-gradient(1000px 520px at 100% -10%, rgba(233, 139, 99, .13), transparent 60%), radial-gradient(800px 500px at -10% 110%, rgba(122, 90, 240, .08), transparent 60%);
    --surface: #171614;
    --surface-2: #1f1d1b;
    --surface-3: #292724;
    --line: rgba(255, 245, 230, .07);
    --line-strong: rgba(255, 245, 230, .14);
    --text: #f2eee8;
    --text-2: #a8a197;
    --text-3: #736d64;
    --accent: #e98b63;
    --accent-2: #f2a27f;
    --accent-ink: #1a0f0a;
    --accent-soft: rgba(233, 139, 99, .15);
    --blue: #6fa0ff;
    --green: #4fcf8a;
    --amber: #f0b44c;
    --red: #ff7a6e;
    --violet: #a48bff;
    --teal: #4cd1cf;
    --code: #1d1b19;
    --chrome: rgba(16, 15, 14, .78);
    --shadow-sm: 0 1px 0 rgba(255, 255, 255, .03) inset;
    --shadow: 0 1px 0 rgba(255, 255, 255, .04) inset, 0 12px 32px -12px rgba(0, 0, 0, .6);
    --shadow-lg: 0 30px 80px -20px rgba(0, 0, 0, .8);
    color-scheme: dark;
  }
}

/* ---------- base ---------- */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg-glow), var(--bg);
  background-attachment: fixed;
  color: var(--text);
  font: 15px/1.5 var(--sans);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  overscroll-behavior-y: none;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre, .mono { font-family: var(--mono); font-size: 12.5px; }
h1, h2, h3 { margin: 0; font-family: var(--display); }
h2 { font-size: 17px; font-weight: 650; letter-spacing: -.01em; }
h3 { font-size: 12px; font-weight: 650; color: var(--text-2); text-transform: uppercase; letter-spacing: .06em; }
::selection { background: var(--accent-soft); }
.i { display: inline-flex; width: 1.15em; height: 1.15em; flex: 0 0 auto; }
.i svg { width: 100%; height: 100%; }
.muted { color: var(--text-2); }
.faint { color: var(--text-3); }
.small { font-size: 13px; }
.tiny { font-size: 11.5px; }
.grow { flex: 1; min-width: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.nowrap { flex-wrap: nowrap; }
.stack { display: grid; gap: 12px; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; }
@media (max-width: 599px) { .hide-sm { display: none !important; } }
@media (min-width: 600px) { .only-sm { display: none !important; } }

/* ---------- buttons ---------- */
button, .btn {
  font: inherit; font-size: 14px; font-weight: 600; letter-spacing: -.005em;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  min-height: 40px; padding: 0 16px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); color: var(--text);
  cursor: pointer; white-space: nowrap; text-decoration: none;
  transition: transform .12s var(--ease), background .15s, border-color .15s, box-shadow .15s, opacity .15s;
}
button:hover, .btn:hover { background: var(--surface-2); text-decoration: none; }
button:active, .btn:active { transform: scale(.97); }
button:disabled { opacity: .45; cursor: default; transform: none; }
button:focus-visible, .btn:focus-visible, a:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
button.primary, .btn.primary {
  background: linear-gradient(180deg, var(--accent-2), var(--accent)); border-color: transparent; color: var(--accent-ink);
  box-shadow: 0 6px 16px -6px color-mix(in srgb, var(--accent) 70%, transparent);
}
button.primary:hover, .btn.primary:hover { filter: brightness(1.04); background: linear-gradient(180deg, var(--accent-2), var(--accent)); }
button.danger, .btn.danger { color: var(--red); }
button.danger.solid { background: var(--red); color: #fff; border-color: transparent; }
button.ghost, .btn.ghost { background: transparent; border-color: transparent; }
button.ghost:hover { background: var(--surface-2); }
button.small, .btn.sm { min-height: 32px; padding: 0 12px; font-size: 13px; }
button.lg, .btn.lg { min-height: 50px; padding: 0 22px; font-size: 16px; }
button.block, .btn.block { width: 100%; }
.icon-btn {
  width: 40px; min-height: 40px; height: 40px; padding: 0; border-radius: 50%;
  border-color: transparent; background: transparent; color: var(--text);
}
.icon-btn .i { width: 21px; height: 21px; }
.icon-btn:hover { background: var(--surface-2); }
.icon-btn.filled { background: var(--surface-2); }
.icon-btn.accent { background: var(--accent-soft); color: var(--accent); }
@media (max-width: 599px) { .btn .lbl { display: none; } .btn.has-icon { padding: 0 12px; } }

/* ---------- inputs ---------- */
input, select, textarea {
  font: inherit; font-size: 16px; /* ≥16px stops iOS from zooming on focus */
  color: var(--text); background: var(--surface); width: 100%;
  border: 1px solid var(--line-strong); border-radius: 12px; padding: 11px 13px;
  transition: border-color .15s, box-shadow .15s;
}
select { appearance: none; padding-right: 36px; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23999' stroke-width='2.2' stroke-linecap='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; }
textarea { resize: vertical; min-height: 96px; line-height: 1.5; }
input::placeholder, textarea::placeholder { color: var(--text-3); }
input:focus, select:focus, textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
@media (min-width: 900px) { input, select, textarea { font-size: 14.5px; padding: 9px 12px; } }
label.field { display: grid; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-2); align-content: start; }
label.field .hint, .hint { font-weight: 450; font-size: 12.5px; color: var(--text-3); }
.form { display: grid; gap: 16px; max-width: 760px; }
.form-grid { display: grid; gap: 16px; }
@media (min-width: 700px) { .form-grid { grid-template-columns: 1fr 1fr; align-items: start; } }
.presets { display: flex; gap: 6px; flex-wrap: wrap; }
.presets button { min-height: 30px; font-size: 12.5px; padding: 0 11px; background: var(--surface-2); border-color: transparent; }

input.switch {
  appearance: none; width: 46px; height: 28px; min-height: 0; padding: 0; flex: 0 0 auto; border-radius: 999px; border: none; cursor: pointer;
  background: var(--surface-3); position: relative; transition: background .2s var(--ease);
}
input.switch::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 22px; height: 22px; border-radius: 50%;
  background: #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .25); transition: transform .22s var(--ease);
}
input.switch:checked { background: var(--green); }
input.switch:checked::after { transform: translateX(18px); }
input.switch:focus-visible { box-shadow: 0 0 0 4px var(--accent-soft); }
label.check, .toggle-row { display: flex; align-items: center; gap: 12px; font-weight: 500; font-size: 14.5px; cursor: pointer; }
label.check input[type=checkbox]:not(.switch) { width: 20px; height: 20px; accent-color: var(--accent); }

.chip {
  display: inline-flex; align-items: center; gap: 5px; min-height: 30px; padding: 0 11px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface); font-size: 12.5px; font-weight: 550; cursor: pointer; user-select: none;
  transition: background .15s, border-color .15s, color .15s;
}
.chip input { position: absolute; opacity: 0; pointer-events: none; }
.chip:has(input:checked) { background: var(--accent-soft); border-color: color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); }
.chip:has(input:checked)::before { content: "✓"; font-weight: 800; font-size: 11px; }
.presets:has(.chip) { gap: 6px; }

/* Horizontally scrollable segmented filter */
.segmented { display: flex; gap: 6px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 2px 16px 4px; }
.segmented::-webkit-scrollbar { display: none; }
.segmented button { min-height: 36px; padding: 0 14px; border-color: transparent; background: var(--surface); box-shadow: var(--shadow-sm); font-size: 13.5px; }
.segmented button.on { background: var(--text); color: var(--bg); }
.segmented .count { opacity: .6; font-weight: 500; }

/* ---------- shell: bottom tabs on phones, sidebar on desktop ---------- */
.shell { min-height: 100dvh; }
.main { min-width: 0; padding-bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 24px); animation: enter .28s var(--ease); }
@keyframes enter { from { opacity: 0; transform: translateY(6px); } }
.sidebar { display: none; }
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 40;
  height: calc(var(--tabbar-h) + env(safe-area-inset-bottom)); padding: 0 8px env(safe-area-inset-bottom);
  display: grid; grid-template-columns: repeat(5, 1fr); align-items: center;
  background: var(--chrome); backdrop-filter: saturate(1.6) blur(20px); -webkit-backdrop-filter: saturate(1.6) blur(20px);
  border-top: 1px solid var(--line);
}
.tab {
  position: relative; display: grid; justify-items: center; gap: 3px; padding: 8px 0 6px;
  color: var(--text-3); font-size: 10.5px; font-weight: 600; letter-spacing: .01em; text-decoration: none !important;
}
.tab .i { width: 24px; height: 24px; transition: transform .2s var(--ease); }
.tab.active { color: var(--accent); }
.tab.active .i { transform: translateY(-1px); }
.tab .badge { position: absolute; top: 3px; left: calc(50% + 6px); }
.fab {
  justify-self: center; width: 54px; height: 54px; border-radius: 18px; display: grid; place-items: center; margin-top: -18px;
  background: linear-gradient(145deg, var(--accent-2), var(--accent)); color: var(--accent-ink);
  box-shadow: 0 10px 24px -8px color-mix(in srgb, var(--accent) 80%, transparent), 0 0 0 5px var(--bg);
  text-decoration: none !important; transition: transform .15s var(--ease);
}
.fab:active { transform: scale(.94); }
.fab .i { width: 26px; height: 26px; }
.fab.disabled { visibility: hidden; }
.shell.immersive .tabbar { display: none; }
.shell.immersive .main { padding-bottom: 0; }

@media (min-width: 900px) {
  .shell { display: grid; grid-template-columns: 252px 1fr; }
  .tabbar { display: none; }
  .main { padding-bottom: 40px; }
  .shell.immersive .main { padding-bottom: 0; }
  .sidebar {
    display: flex; flex-direction: column; gap: 4px; position: sticky; top: 0; height: 100dvh; padding: 18px 14px;
    border-right: 1px solid var(--line); background: color-mix(in srgb, var(--surface) 55%, transparent); backdrop-filter: blur(12px);
  }
  .sidebar .brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px 18px; font: 700 17px/1 var(--display); letter-spacing: -.01em; }
  .sidebar .new { margin: 0 2px 14px; }
  .side-link {
    display: flex; align-items: center; gap: 11px; padding: 9px 11px; border-radius: 11px; color: var(--text-2);
    font-weight: 600; font-size: 14px; text-decoration: none !important; transition: background .15s, color .15s;
  }
  .side-link .i { width: 19px; height: 19px; }
  .side-link:hover { background: var(--surface-2); color: var(--text); }
  .side-link.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
  .side-link.active .i { color: var(--accent); }
  .side-link .badge { margin-left: auto; }
  .sidebar .spacer { flex: 1; }
  .me-card { display: flex; align-items: center; gap: 10px; padding: 10px; border-radius: 14px; background: var(--surface-2); text-decoration: none !important; color: inherit; }
  .me-card .name { font-weight: 650; font-size: 13.5px; }
}
.brand-logo { width: 28px; height: 28px; border-radius: 8px; box-shadow: 0 4px 12px -4px color-mix(in srgb, var(--accent) 70%, transparent); }

.badge {
  min-width: 18px; height: 18px; padding: 0 5px; border-radius: 999px; display: inline-grid; place-items: center;
  background: var(--red); color: #fff; font-size: 10.5px; font-weight: 800; line-height: 1; box-shadow: 0 0 0 2px var(--chrome);
}
.badge.live { background: var(--blue); }

/* ---------- pages ---------- */
.page { padding: calc(14px + env(safe-area-inset-top)) 16px 24px; max-width: 1120px; margin: 0 auto; }
@media (min-width: 900px) { .page { padding: 34px 40px 48px; } }
.page-head { display: flex; align-items: center; gap: 10px; margin: 6px 0 18px; }
.page-head .title { font: 800 30px/1.1 var(--display); letter-spacing: -.025em; }
.page-head .eyebrow { font-size: 13px; color: var(--text-2); font-weight: 600; display: inline-flex; align-items: center; gap: 4px; margin-bottom: 4px; text-decoration: none; }
@media (min-width: 900px) { .page-head .title { font-size: 32px; } }
.section-title { display: flex; align-items: center; gap: 8px; margin: 26px 4px 10px; font-size: 13px; font-weight: 700; color: var(--text-2); text-transform: uppercase; letter-spacing: .07em; }
.section-title .count { color: var(--text-3); font-weight: 600; }

.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); padding: 16px; }
.cards { display: grid; gap: 12px; }
@media (min-width: 700px) { .cards { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 14px; } }

/* Stat tiles scroll sideways on phones */
.stats { display: flex; gap: 10px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px 18px; padding: 2px 16px 6px; scroll-snap-type: x mandatory; }
.stats::-webkit-scrollbar { display: none; }
.stat {
  flex: 0 0 auto; min-width: 136px; scroll-snap-align: start; padding: 14px 16px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); display: grid; gap: 6px;
}
.stat .k { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; color: var(--text-2); }
.stat .k .i { color: var(--c, var(--accent)); }
.stat .v { font: 750 24px/1 var(--display); letter-spacing: -.02em; font-variant-numeric: tabular-nums; }
.stat .v.text { font-size: 16px; line-height: 1.2; }
@media (min-width: 900px) { .stats { display: grid; grid-template-columns: repeat(5, 1fr); overflow: visible; margin: 0 0 22px; padding: 0; } }

/* ---------- session cards ---------- */
.list { display: grid; gap: 10px; }
.s-card {
  display: grid; grid-template-columns: auto 1fr; gap: 4px 12px; padding: 14px; border-radius: var(--r);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow); color: inherit; text-decoration: none !important;
  position: relative; overflow: hidden; transition: transform .15s var(--ease), box-shadow .15s;
}
.s-card:active { transform: scale(.985); }
@media (hover: hover) { .s-card:hover { transform: translateY(-1px); box-shadow: var(--shadow), 0 0 0 1px var(--line-strong); } }
.s-card::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--status, transparent); }
.s-card .avatar { grid-row: span 2; }
.s-card .top { display: flex; align-items: center; gap: 8px; min-width: 0; }
.s-card .title { font-weight: 650; font-size: 15px; letter-spacing: -.01em; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.s-card .time { font-size: 12px; color: var(--text-3); flex: 0 0 auto; }
.s-card .sub { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-2); min-width: 0; }
.s-card .meta { grid-column: 2; display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-top: 6px; }
.s-card.attention { border-color: color-mix(in srgb, var(--amber) 45%, transparent); background: linear-gradient(0deg, color-mix(in srgb, var(--amber) 6%, var(--surface)), var(--surface)); }
@media (min-width: 900px) { .list.grid2 { grid-template-columns: 1fr 1fr; } }

.tag {
  display: inline-flex; align-items: center; gap: 5px; height: 24px; padding: 0 9px; border-radius: 999px;
  background: var(--surface-2); color: var(--text-2); font-size: 12px; font-weight: 550; max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-decoration: none !important;
}
.tag .i { width: 13px; height: 13px; }
.tag.mono { font-family: var(--mono); font-size: 11.5px; }
a.tag:hover { color: var(--text); }
.tag.accent { background: var(--accent-soft); color: var(--accent); }

.pill { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px 0 8px; border-radius: 999px; font-size: 12px; font-weight: 650; white-space: nowrap; color: var(--c); background: color-mix(in srgb, var(--c) 13%, transparent); }
.pill-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.pill.running, .pill.starting { --c: var(--blue); }
.pill.running .pill-dot, .pill.starting .pill-dot { animation: pulse 1.2s ease-in-out infinite; }
.pill.waiting { --c: var(--amber); }
.pill.waiting .pill-dot { animation: pulse 1s ease-in-out infinite; }
.pill.idle { --c: var(--violet); }
.pill.completed { --c: var(--green); }
.pill.failed { --c: var(--red); }
.pill.queued, .pill.stopped { --c: var(--text-2); }
@keyframes pulse { 50% { opacity: .35; transform: scale(.8); } }
.st-running, .st-starting { --status: var(--blue); }
.st-waiting { --status: var(--amber); }
.st-idle { --status: var(--violet); }
.st-completed { --status: var(--green); }
.st-failed { --status: var(--red); }

.avatar {
  --h: 20; width: 42px; height: 42px; border-radius: 13px; display: inline-grid; place-items: center; flex: 0 0 auto;
  font: 750 14px/1 var(--display); letter-spacing: .02em; color: #fff;
  background: linear-gradient(145deg, hsl(var(--h) 72% 62%), hsl(calc(var(--h) + 40) 70% 46%));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25);
}
.avatar.sm { width: 28px; height: 28px; border-radius: 9px; font-size: 11px; }
.avatar.xs { width: 22px; height: 22px; border-radius: 50%; font-size: 9.5px; }
.avatar.round { border-radius: 50%; }

/* ---------- empty / misc ---------- */
.empty { display: grid; justify-items: center; text-align: center; gap: 8px; padding: 40px 20px; border-radius: var(--r-lg); background: var(--surface); border: 1px dashed var(--line-strong); }
.empty-icon { width: 60px; height: 60px; border-radius: 20px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); margin-bottom: 6px; }
.empty-icon .i { width: 28px; height: 28px; }
.empty-title { font: 700 17px/1.3 var(--display); }
.empty-text { color: var(--text-2); font-size: 14px; max-width: 420px; }
.empty-actions { display: flex; gap: 8px; margin-top: 8px; flex-wrap: wrap; justify-content: center; }
.skeleton { height: 76px; border-radius: var(--r); background: linear-gradient(90deg, var(--surface) 0, var(--surface-2) 50%, var(--surface) 100%); background-size: 200% 100%; animation: shimmer 1.2s infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Agent and repo cards */
.a-card { display: grid; gap: 12px; }
.a-card .head { display: flex; align-items: center; gap: 12px; }
.a-card .name { font: 700 16px/1.25 var(--display); letter-spacing: -.01em; color: inherit; }
.a-card .prompt { color: var(--text-2); font-size: 13.5px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.a-card .facts { display: flex; gap: 6px; flex-wrap: wrap; }
.a-card .foot { display: flex; align-items: center; gap: 8px; padding-top: 12px; border-top: 1px solid var(--line); }

/* Inset grouped lists (settings, forms) */
.group { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r); box-shadow: var(--shadow); overflow: hidden; }
.group + .group { margin-top: 12px; }
.group-row { display: flex; align-items: center; gap: 12px; padding: 13px 16px; min-height: 52px; }
.group-row + .group-row { border-top: 1px solid var(--line); }
.group-row .ico { width: 32px; height: 32px; border-radius: 9px; display: grid; place-items: center; color: #fff; background: var(--c, var(--accent)); flex: 0 0 auto; }
.group-row .ico .i { width: 18px; height: 18px; }
.group-row .label { font-weight: 600; font-size: 14.5px; }
.group-row .desc { font-size: 12.5px; color: var(--text-2); }
.group-row.stacked { display: grid; gap: 10px; align-items: stretch; }
.group-body { padding: 16px; display: grid; gap: 14px; }
.group-body + .group-body { border-top: 1px solid var(--line); }
.settings { display: grid; gap: 8px; max-width: 820px; }
.settings .section-title:first-of-type { margin-top: 4px; }

.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--text-3); flex: 0 0 auto; }
.dot.on { background: var(--green); box-shadow: 0 0 0 3px color-mix(in srgb, var(--green) 22%, transparent); }
.qr { width: min(260px, 68vw); background: #fff; border-radius: 18px; padding: 10px; box-shadow: var(--shadow); }
.qr svg { width: 100%; height: auto; display: block; }
.dm { max-width: 88%; padding: 9px 13px; border-radius: 16px; background: var(--surface-2); font-size: 14px; }
.dm.out { justify-self: start; border-bottom-left-radius: 6px; }
.dm.in { justify-self: end; background: var(--accent-soft); border-bottom-right-radius: 6px; }
.copy { display: flex; gap: 8px; align-items: center; min-width: 0; }
.copy code { flex: 1; min-width: 0; background: var(--code); border: 1px solid var(--line); padding: 9px 11px; border-radius: 10px; overflow-x: auto; white-space: nowrap; scrollbar-width: thin; }
table.list { width: 100%; border-collapse: collapse; }
table.list td, table.list th { padding: 10px 6px; border-bottom: 1px solid var(--line); text-align: left; font-size: 13.5px; }
table.list tr:last-child td { border-bottom: none; }
select.compact { width: auto; min-height: 0; padding: 5px 30px 5px 10px; font-size: 13px; border-radius: 999px; background-position: right 8px center; }

/* ---------- login ---------- */
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login .card { width: min(380px, 100%); padding: 28px 24px; display: grid; gap: 14px; border-radius: var(--r-lg); box-shadow: var(--shadow-lg); }
.login .brand { display: grid; justify-items: center; gap: 10px; margin-bottom: 8px; text-align: center; }
.login .brand img { width: 64px; height: 64px; border-radius: 18px; box-shadow: 0 16px 36px -12px color-mix(in srgb, var(--accent) 80%, transparent); }
.login .brand .name { font: 800 24px/1 var(--display); letter-spacing: -.02em; }

/* ---------- session view ---------- */
.session { display: flex; flex-direction: column; height: 100dvh; position: relative; }
.appbar {
  position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 4px;
  padding: calc(8px + env(safe-area-inset-top)) 8px 8px; min-height: 60px;
  background: var(--chrome); backdrop-filter: saturate(1.6) blur(20px); -webkit-backdrop-filter: saturate(1.6) blur(20px);
  border-bottom: 1px solid var(--line);
}
.appbar .heading { flex: 1; min-width: 0; padding: 2px 6px; cursor: pointer; border-radius: 10px; }
.appbar .heading:hover { background: var(--surface-2); }
.appbar .heading .t { font: 700 16px/1.25 var(--display); letter-spacing: -.01em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.appbar .heading .s { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--text-2); overflow: hidden; white-space: nowrap; margin-top: 2px; }
.appbar .heading .s .pill { height: 18px; font-size: 11px; padding: 0 7px 0 6px; }
.presence { display: flex; align-items: center; padding-right: 4px; }
.presence .avatar { margin-left: -7px; box-shadow: 0 0 0 2px var(--surface); }
.presence .avatar:first-child { margin-left: 0; }
.progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; background: linear-gradient(90deg, transparent, var(--blue), transparent); background-size: 40% 100%; background-repeat: no-repeat; animation: slide 1.4s linear infinite; }
.progress.waiting { background-image: linear-gradient(90deg, transparent, var(--amber), transparent); }
@keyframes slide { from { background-position: -40% 0; } to { background-position: 140% 0; } }

.transcript { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px 14px 28px; }
.transcript-inner { max-width: 820px; margin: 0 auto; display: grid; gap: 12px; }
@media (min-width: 900px) { .transcript { padding: 24px 32px 36px; } }

.msg { display: grid; gap: 4px; animation: enter .25s var(--ease); min-width: 0; }
.msg .who { display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 650; color: var(--text-2); }
.msg .who .via { font-weight: 500; color: var(--text-3); }
.msg.assistant .who .mark { width: 20px; height: 20px; border-radius: 7px; display: grid; place-items: center; background: linear-gradient(145deg, var(--accent-2), var(--accent)); color: var(--accent-ink); }
.msg.assistant .who .mark .i { width: 12px; height: 12px; }
.msg.assistant .body { padding: 2px 2px 2px 26px; font-size: 15px; }
.msg.human { justify-items: end; }
.msg.human .bubble {
  max-width: min(88%, 640px); padding: 10px 14px; border-radius: 20px 20px 6px 20px; font-size: 15px;
  background: linear-gradient(160deg, var(--accent-2), var(--accent)); color: var(--accent-ink);
  box-shadow: 0 6px 18px -10px color-mix(in srgb, var(--accent) 80%, transparent);
}
.msg.human .bubble a { color: inherit; text-decoration: underline; }
.msg.human .bubble code { background: rgba(0, 0, 0, .12); }
.msg.human.task { justify-items: stretch; }
.msg.human.task .bubble { max-width: none; border-radius: 18px; background: var(--surface); color: var(--text); border: 1px solid var(--line); box-shadow: var(--shadow); }
.msg.human.task .bubble code { background: var(--code); }
.msg.human.other { justify-items: start; }
.msg.human.other .bubble { background: var(--surface); color: var(--text); border: 1px solid color-mix(in srgb, var(--blue) 35%, var(--line)); border-radius: 20px 20px 20px 6px; box-shadow: var(--shadow); }
.msg.human.review .bubble { border-color: color-mix(in srgb, var(--teal) 45%, var(--line)); background: color-mix(in srgb, var(--teal) 7%, var(--surface)); }
.msg.human.other .bubble code, .msg.human.review .bubble code { background: var(--code); }

.md { overflow-wrap: anywhere; }
.md > :first-child { margin-top: 0; }
.md > :last-child { margin-bottom: 0; }
.md p { margin: .45em 0; }
.md pre { background: var(--code); border: 1px solid var(--line); padding: 11px 13px; border-radius: 12px; overflow-x: auto; font-size: 12.5px; }
.md code { background: var(--code); padding: 1.5px 5px; border-radius: 6px; font-size: .88em; }
.md pre code { background: none; padding: 0; font-size: inherit; }
.md h2, .md h3, .md h4, .md h5 { margin: .9em 0 .35em; font-size: 15.5px; text-transform: none; letter-spacing: -.01em; color: inherit; }
.md ul, .md ol { padding-left: 1.3em; margin: .4em 0; }
.md li { margin: .15em 0; }
.md blockquote { margin: .5em 0; padding: 2px 0 2px 12px; border-left: 3px solid var(--line-strong); color: var(--text-2); }
.md table { border-collapse: collapse; margin: .5em 0; display: block; overflow-x: auto; }
.md td, .md th { border: 1px solid var(--line-strong); padding: 5px 9px; font-size: 13.5px; }

.thinking { font-size: 12.5px; color: var(--text-3); padding-left: 26px; margin: -4px 0; }
.thinking summary .i { width: 13px; height: 13px; }
.thinking summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; font-weight: 600; }
.thinking summary::-webkit-details-marker { display: none; }
.thinking .md { margin-top: 6px; padding: 10px 12px; border-left: 2px solid var(--line-strong); font-style: italic; }
.thinking.live { font-style: italic; white-space: pre-wrap; }

.tool { margin-left: 26px; border-radius: 14px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-sm); overflow: hidden; min-width: 0; }
.tool > summary { display: flex; align-items: center; gap: 10px; padding: 8px 12px 8px 8px; cursor: pointer; list-style: none; min-height: 44px; }
.tool > summary::-webkit-details-marker { display: none; }
.tool .ti { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; background: var(--surface-2); color: var(--text-2); flex: 0 0 auto; }
.tool .ti .i { width: 15px; height: 15px; }
.tool .name { font-weight: 650; font-size: 13px; flex: 0 0 auto; }
.tool .arg { color: var(--text-2); font-family: var(--mono); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; min-width: 0; }
.tool .state { width: 20px; height: 20px; border-radius: 50%; display: grid; place-items: center; flex: 0 0 auto; }
.tool .state .i { width: 13px; height: 13px; }
.tool .state.ok { background: color-mix(in srgb, var(--green) 16%, transparent); color: var(--green); }
.tool .state.err { background: color-mix(in srgb, var(--red) 16%, transparent); color: var(--red); }
.tool .state.pending { border: 2px solid color-mix(in srgb, var(--blue) 25%, transparent); border-top-color: var(--blue); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tool[open] > summary { border-bottom: 1px solid var(--line); }
.tool .body { padding: 10px 12px; display: grid; gap: 8px; }
.tool pre { margin: 0; white-space: pre-wrap; word-break: break-word; max-height: 360px; overflow: auto; background: var(--code); padding: 9px 11px; border-radius: 10px; font-size: 12px; }
.tool.err { border-color: color-mix(in srgb, var(--red) 35%, var(--line)); }
.subagent { display: grid; gap: 10px; padding-left: 10px; border-left: 2px solid var(--line-strong); }
.subagent .tool, .subagent .thinking, .subagent .msg.assistant .body { margin-left: 0; padding-left: 0; }
.todo-item { display: flex; gap: 8px; align-items: baseline; font-size: 13.5px; }
.todo-item.done { color: var(--text-3); text-decoration: line-through; }

.line { display: flex; align-items: center; gap: 10px; font-size: 12px; color: var(--text-3); padding: 2px 0; min-width: 0; }
.line::before, .line::after { content: ""; flex: 1; height: 1px; background: var(--line); min-width: 12px; }
.line > span { flex: 0 1 auto; text-align: center; overflow-wrap: anywhere; max-width: 80%; }
.line a { word-break: break-all; }
.line.error { color: var(--red); }
.line.error::before, .line.error::after { background: color-mix(in srgb, var(--red) 30%, transparent); }

.permission {
  border-radius: 20px; padding: 16px; display: grid; gap: 12px; position: relative;
  background: linear-gradient(var(--surface), var(--surface)) padding-box, linear-gradient(135deg, var(--amber), var(--accent)) border-box;
  border: 1.5px solid transparent; box-shadow: 0 16px 40px -18px color-mix(in srgb, var(--amber) 70%, transparent);
  animation: enter .3s var(--ease);
}
.permission .p-head { display: flex; align-items: center; gap: 10px; }
.permission .p-icon { width: 36px; height: 36px; border-radius: 12px; display: grid; place-items: center; background: color-mix(in srgb, var(--amber) 18%, transparent); color: var(--amber); flex: 0 0 auto; }
.permission .p-icon .i { width: 19px; height: 19px; }
.permission .p-title { font-weight: 700; font-size: 15px; }
.permission pre { margin: 0; white-space: pre-wrap; word-break: break-word; max-height: 240px; overflow: auto; background: var(--code); padding: 10px 12px; border-radius: 12px; font-size: 12.5px; }
.permission .diff { max-height: 240px; }
.permission .p-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.permission .p-actions .wide { grid-column: span 2; }
@media (min-width: 600px) { .permission .p-actions { display: flex; } .permission .p-actions .wide { grid-column: auto; } }
.permission.done { background: var(--surface); border: 1px solid var(--line); box-shadow: none; padding: 8px 12px 8px 8px; animation: none; }
.permission.done .p-icon { width: 28px; height: 28px; border-radius: 9px; }
.permission.done .p-icon .i { width: 15px; height: 15px; }
.permission.done .p-icon.ok { background: color-mix(in srgb, var(--green) 15%, transparent); color: var(--green); }
.permission.done .p-icon.no { background: color-mix(in srgb, var(--red) 15%, transparent); color: var(--red); }
.permission.done .p-title { font-size: 13.5px; font-weight: 600; }

.cursor::after { content: ""; display: inline-block; width: 7px; height: 1.05em; margin-left: 2px; vertical-align: -2px; border-radius: 2px; background: var(--accent); animation: pulse 1s infinite; }

.composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); background: var(--chrome); backdrop-filter: saturate(1.6) blur(20px); -webkit-backdrop-filter: saturate(1.6) blur(20px); border-top: 1px solid var(--line); }
.composer-inner { max-width: 820px; margin: 0 auto; display: grid; gap: 6px; }
.composer form { display: flex; align-items: flex-end; gap: 8px; padding: 5px 5px 5px 16px; border-radius: 26px; background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow); transition: border-color .15s, box-shadow .15s; }
.composer form:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.composer textarea { border: none; background: transparent; box-shadow: none !important; padding: 9px 0; min-height: 40px; height: 40px; max-height: 40vh; resize: none; border-radius: 0; }
.composer .send { width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: 50%; flex: 0 0 auto; }
.composer .send .i { width: 20px; height: 20px; }
.composer .hint { text-align: center; padding: 0 8px; }
.composer.readonly { text-align: center; color: var(--text-2); font-size: 13px; }
.jump { position: absolute; right: 16px; bottom: 110px; z-index: 5; width: 42px; height: 42px; padding: 0; box-shadow: var(--shadow-lg); }

/* ---------- sheets (bottom on phones, dialog on desktop) ---------- */
.sheet-backdrop { position: fixed; inset: 0; z-index: 80; background: rgba(10, 8, 6, .42); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); display: flex; align-items: flex-end; justify-content: center; animation: fade .2s ease; }
.sheet {
  width: 100%; max-height: 92dvh; display: flex; flex-direction: column; background: var(--surface);
  border-radius: 24px 24px 0 0; box-shadow: var(--shadow-lg); animation: up .32s var(--ease); padding-bottom: env(safe-area-inset-bottom);
}
.sheet-grabber { width: 38px; height: 5px; border-radius: 3px; background: var(--line-strong); margin: 8px auto 0; flex: 0 0 auto; }
.sheet-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px 6px 20px; }
.sheet-head h2 { flex: 1; font-size: 18px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sheet-body { overflow-y: auto; padding: 8px 20px 20px; overscroll-behavior: contain; }
.sheet-foot { display: flex; gap: 8px; padding: 12px 20px 16px; border-top: 1px solid var(--line); }
.sheet-foot > * { flex: 1; }
.sheet-backdrop.closing { animation: fade .2s ease reverse forwards; }
.sheet-backdrop.closing .sheet { animation: up .2s ease-in reverse forwards; }
@keyframes fade { from { opacity: 0; } }
@keyframes up { from { transform: translateY(100%); } }
@media (min-width: 700px) {
  .sheet-backdrop { align-items: center; padding: 24px; }
  .sheet { max-width: 680px; border-radius: 24px; max-height: 86vh; animation: pop .25s var(--ease); }
  .sheet-grabber { display: none; }
  .sheet-head { padding-top: 16px; }
  .sheet-foot { justify-content: flex-end; }
  .sheet-foot > * { flex: 0 0 auto; }
  .sheet-backdrop.closing .sheet { animation: pop .2s ease-in reverse forwards; }
}
@keyframes pop { from { transform: scale(.96); opacity: 0; } }
.action-list { display: grid; gap: 2px; margin: 0 -8px; }
.action-item { justify-content: flex-start; gap: 14px; min-height: 54px; border: none; border-radius: 14px; background: transparent; padding: 6px 12px; font-weight: 600; text-align: left; white-space: normal; }
.action-item .i { width: 21px; height: 21px; color: var(--text-2); }
.action-item.danger, .action-item.danger .i { color: var(--red); }
.action-item .action-label { display: block; }
.action-item .action-hint { display: block; font-size: 12.5px; font-weight: 450; color: var(--text-3); }

.diff { font-family: var(--mono); font-size: 12px; white-space: pre; overflow: auto; background: var(--code); border: 1px solid var(--line); border-radius: 12px; padding: 8px 0; }
.diff div { padding: 0 12px; min-width: max-content; }
.diff .add { background: color-mix(in srgb, var(--green) 15%, transparent); color: color-mix(in srgb, var(--green) 70%, var(--text)); }
.diff .del { background: color-mix(in srgb, var(--red) 14%, transparent); color: color-mix(in srgb, var(--red) 70%, var(--text)); }
.diff .hunk { color: var(--blue); }
.diff .file { font-weight: 700; color: var(--text); background: var(--surface-2); padding-top: 5px; padding-bottom: 5px; margin-top: 4px; }

.kv { display: grid; grid-template-columns: auto 1fr; gap: 12px 16px; font-size: 14px; align-items: center; margin: 0; }
.kv dt { color: var(--text-2); font-size: 13px; }
.kv dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }

/* ---------- toast / banner ---------- */
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--tabbar-h) + env(safe-area-inset-bottom) + 14px); z-index: 90;
  max-width: calc(100vw - 32px); padding: 11px 16px; border-radius: 14px; background: var(--text); color: var(--bg);
  font-size: 14px; font-weight: 550; box-shadow: var(--shadow-lg); animation: toast .3s var(--ease);
}
.toast.error { background: var(--red); color: #fff; }
@keyframes toast { from { opacity: 0; transform: translate(-50%, 10px); } }
@media (min-width: 900px) { .toast { bottom: 24px; left: auto; right: 24px; transform: none; animation: toast-d .3s var(--ease); } }
@keyframes toast-d { from { opacity: 0; transform: translateY(10px); } }
.banner {
  position: fixed; left: 50%; transform: translateX(-50%); top: calc(10px + env(safe-area-inset-top)); z-index: 85;
  display: flex; align-items: center; gap: 10px; padding: 7px 8px 7px 14px; border-radius: 999px; max-width: calc(100vw - 24px);
  background: var(--text); color: var(--bg); font-size: 13px; font-weight: 600; box-shadow: var(--shadow-lg);
}
.banner .i { width: 17px; height: 17px; }
.banner.warn { background: var(--amber); color: #1c1407; padding-right: 14px; }
.banner button { min-height: 30px; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* ---------- settings lists & forms ---------- */
.items { display: grid; }
.item { display: grid; grid-template-columns: auto 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 0; min-width: 0; }
.item + .item { border-top: 1px solid var(--line); }
.item-main { min-width: 0; }
.item-title { font-weight: 650; font-size: 14.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-sub { font-size: 12.5px; color: var(--text-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.item-trail { display: flex; align-items: center; gap: 4px; }
.item-extra { grid-column: 1 / -1; padding-top: 8px; }
.lead-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: color-mix(in srgb, var(--c) 16%, transparent); color: var(--c); }
.lead-icon .i { width: 18px; height: 18px; }
.lead-avatar { position: relative; display: inline-flex; }
.lead-avatar .dot { position: absolute; right: -2px; bottom: -2px; box-shadow: 0 0 0 2px var(--surface); }
.inline-form { display: grid; gap: 10px; }
@media (min-width: 700px) { .inline-form { display: flex; align-items: flex-end; gap: 10px; } .inline-form > input, .inline-form > select, .inline-form > .field { flex: 1; } .inline-form > select { flex: 0 0 140px; } }
.section-sub { font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; color: var(--text-3); margin-top: 6px; }
details.add > summary { display: inline-flex; align-items: center; gap: 6px; cursor: pointer; list-style: none; font-weight: 600; font-size: 14px; color: var(--accent); }
details.add > summary::-webkit-details-marker { display: none; }
details.add[open] > summary { margin-bottom: 12px; }
