/* Hermes - dark-first workspace UI.
   Palette and type system drawn from the Forever component library aesthetic:
   near-black canvas, mint accent, Geist / Geist Mono / Schibsted Grotesk. */

:root {
  color-scheme: dark;
  --bg: #141416;
  --bg-raised: #1a1a1d;
  --surface: #202024;
  --surface-2: #28282d;
  --surface-3: #33333a;
  --glass: rgba(32, 32, 36, 0.78);
  --line: rgba(255, 255, 255, 0.1);
  --line-strong: rgba(255, 255, 255, 0.19);
  --text: #f4f4f1;
  --text-soft: #dcdcd7;
  --muted: #a3a39f;
  --dim: #76766f;
  --accent: #4cc98c;
  --accent-hi: #6fe0a8;
  --accent-ink: #03150c;
  --accent-soft: rgba(63, 182, 128, 0.12);
  --accent-line: rgba(63, 182, 128, 0.35);
  --accent-glow: rgba(63, 182, 128, 0.32);
  --danger: #e5645c;
  --danger-soft: rgba(229, 100, 92, 0.12);
  --warn: #e0a45a;
  --code-bg: #0b0b0b;
  --shadow-lg: 0 40px 90px -30px rgba(0, 0, 0, 0.75), 0 1px 0 rgba(255, 255, 255, 0.04) inset;
  --shadow-md: 0 18px 40px -22px rgba(0, 0, 0, 0.7);
  --r-xl: 26px;
  --r-lg: 18px;
  --r-md: 13px;
  --r-sm: 9px;
  --sans: "Geist", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --display: "Schibsted Grotesk", "Geist", system-ui, sans-serif;
  --mono: "Geist Mono", ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
  --text-scale: 1;
}

@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f4f4f1;
    --bg-raised: #fbfbf9;
    --surface: #ffffff;
    --surface-2: #f3f3f0;
    --surface-3: #e9e9e5;
    --glass: rgba(255, 255, 255, 0.78);
    --line: rgba(0, 0, 0, 0.08);
    --line-strong: rgba(0, 0, 0, 0.16);
    --text: #121212;
    --text-soft: #2b2b2b;
    --muted: #6b6b67;
    --dim: #9d9d98;
    --accent: #1f9d64;
    --accent-hi: #2bb577;
    --accent-ink: #ffffff;
    --accent-soft: rgba(31, 157, 100, 0.1);
    --accent-line: rgba(31, 157, 100, 0.35);
    --accent-glow: rgba(31, 157, 100, 0.22);
    --danger: #d6453d;
    --danger-soft: rgba(214, 69, 61, 0.09);
    --code-bg: #f1f1ee;
    --shadow-lg: 0 40px 80px -36px rgba(0, 0, 0, 0.22);
    --shadow-md: 0 14px 30px -20px rgba(0, 0, 0, 0.25);
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f4f1;
  --bg-raised: #fbfbf9;
  --surface: #ffffff;
  --surface-2: #f3f3f0;
  --surface-3: #e9e9e5;
  --glass: rgba(255, 255, 255, 0.78);
  --line: rgba(0, 0, 0, 0.08);
  --line-strong: rgba(0, 0, 0, 0.16);
  --text: #121212;
  --text-soft: #2b2b2b;
  --muted: #6b6b67;
  --dim: #9d9d98;
  --accent: #1f9d64;
  --accent-hi: #2bb577;
  --accent-ink: #ffffff;
  --accent-soft: rgba(31, 157, 100, 0.1);
  --accent-line: rgba(31, 157, 100, 0.35);
  --accent-glow: rgba(31, 157, 100, 0.22);
  --danger: #d6453d;
  --danger-soft: rgba(214, 69, 61, 0.09);
  --code-bg: #f1f1ee;
  --shadow-lg: 0 40px 80px -36px rgba(0, 0, 0, 0.22);
  --shadow-md: 0 14px 30px -20px rgba(0, 0, 0, 0.25);
}

*, *::before, *::after { box-sizing: border-box; }
html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: calc(15px * var(--text-scale));
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
  letter-spacing: -0.005em;
}

[hidden] { display: none !important; }
h1, h2, h3 { margin: 0; font-family: var(--display); font-weight: 650; letter-spacing: -0.025em; }
h1 { font-size: 34px; line-height: 1.1; }
h2 { font-size: 26px; line-height: 1.15; }
h3 { font-size: 19px; line-height: 1.25; }
p { margin: 0; }
kbd {
  font-family: var(--mono); font-size: 11px; padding: 2px 6px; border-radius: 6px;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--muted);
}

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.ico { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; flex: none; }
.meta { color: var(--muted); font-size: 13.5px; }
.lead { color: var(--muted); font-size: 15px; max-width: 64ch; }
.error { color: var(--danger); font-size: 14px; min-height: 1.4em; }
.spacer { flex: 1; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.gradient-text {
  background: linear-gradient(100deg, var(--text) 10%, var(--accent-hi) 110%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
}

.eyebrow, .eyebrow-sm, .crumb, .list-label, .tool-pill, .badge, .chip, .health, .composer-hint, .crumbs, .card-sub, .chat-item .s, .tile-meta, .palette-foot, .suggest-k {
  font-family: var(--mono);
}
.eyebrow, .eyebrow-sm {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 11px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim);
}

.pulse {
  width: 7px; height: 7px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-glow); animation: pulse 2.2s infinite;
}
@keyframes pulse { 0% { box-shadow: 0 0 0 0 var(--accent-glow); } 70% { box-shadow: 0 0 0 9px transparent; } 100% { box-shadow: 0 0 0 0 transparent; } }

/* ---------- Buttons, fields, chips ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 38px; padding: 0 16px; border-radius: 999px; border: 1px solid var(--line-strong);
  background: var(--surface-2); color: var(--text); font: inherit; font-size: 14px; font-weight: 500;
  cursor: pointer; text-decoration: none; white-space: nowrap;
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease), transform 0.12s var(--ease), box-shadow 0.2s var(--ease), color 0.2s;
}
.btn .ico { width: 17px; height: 17px; }
.btn:hover { background: var(--surface-3); border-color: var(--line-strong); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: default; transform: none; }
.btn.primary {
  background: var(--accent); border-color: transparent; color: var(--accent-ink); font-weight: 600;
  box-shadow: 0 8px 24px -10px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.18);
}
.btn.primary:hover { background: var(--accent-hi); box-shadow: 0 10px 30px -10px var(--accent-glow), inset 0 1px 0 rgba(255,255,255,0.22); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--surface-2); border-color: var(--line); }
.btn.big { height: 46px; padding: 0 22px; font-size: 15px; }
.btn.wide { width: 100%; }
.btn.icon-only { width: 38px; padding: 0; }
.btn.danger-text { color: var(--danger); }
.btn.danger-text:hover { background: var(--danger-soft); }
.btn:focus-visible, .nav-btn:focus-visible, .round:focus-visible, .chat-item:focus-visible, .card:focus-visible, .tile:focus-visible, .suggest:focus-visible {
  outline: 2px solid var(--accent); outline-offset: 2px;
}

.round {
  width: 42px; height: 42px; border-radius: 50%; border: 0; display: grid; place-items: center; flex: none;
  background: var(--surface-3); color: var(--text); cursor: pointer; transition: transform 0.12s var(--ease), background 0.2s;
}
.round:active { transform: scale(0.92); }
.round.primary { background: var(--accent); color: var(--accent-ink); box-shadow: 0 8px 22px -8px var(--accent-glow); }
.round.primary:hover { background: var(--accent-hi); }
.round.danger { background: var(--danger); color: #fff; }
.round:disabled { opacity: 0.4; cursor: default; }

.field {
  width: 100%; height: 40px; padding: 0 14px; border-radius: var(--r-md);
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text);
  font: inherit; font-size: 14.5px; outline: none; transition: border-color 0.2s, box-shadow 0.2s;
}
.field::placeholder { color: var(--dim); }
.field:focus { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft); }
.field.big { height: 52px; font-size: 16px; }
.field.select { width: auto; min-width: 200px; font-weight: 500; cursor: pointer; }

.chip {
  display: inline-flex; align-items: center; gap: 8px; height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface-2); color: var(--muted); font-size: 11.5px; letter-spacing: 0.04em;
}
.chip .ico { width: 14px; height: 14px; color: var(--accent); }
.chip::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }
.chip .ico + *, .chip::before { }

.kbd-btn { height: 34px; padding: 0 10px 0 12px; color: var(--muted); }
.kbd-btn kbd { margin-left: 2px; }

/* ---------- Login ---------- */

.screen {
  position: fixed; inset: 0; display: grid; place-items: center; padding: 20px;
  background:
    radial-gradient(700px 420px at 20% 0%, var(--accent-soft), transparent 70%),
    radial-gradient(600px 400px at 100% 100%, rgba(120, 150, 255, 0.07), transparent 70%),
    var(--bg);
}
.screen::before {
  content: ""; position: absolute; inset: 0; pointer-events: none; opacity: 0.5;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 48px 48px; mask-image: radial-gradient(ellipse at center, black 10%, transparent 70%);
}
.login-card {
  position: relative; width: min(420px, 100%); padding: 40px 36px;
  background: var(--glass); backdrop-filter: blur(24px) saturate(160%); -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--line-strong); border-radius: var(--r-xl); box-shadow: var(--shadow-lg);
  animation: rise 0.6s var(--ease) both;
}
.login-card .eyebrow { margin-bottom: 22px; }
.login-title { margin-bottom: 10px; }
.login-card .lead { margin-bottom: 26px; font-size: 15px; }

/* ---------- Shell ---------- */

.shell {
  position: fixed; inset: 0; display: grid; grid-template-columns: 104px minmax(0, 1fr);
}
.shell::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; opacity: 0.35;
  background-image: linear-gradient(var(--line) 1px, transparent 1px), linear-gradient(90deg, var(--line) 1px, transparent 1px);
  background-size: 56px 56px; mask-image: radial-gradient(ellipse at 40% 0%, black 15%, transparent 70%);
}

/* Floating dock */
.rail {
  position: relative; z-index: 2; margin: 14px 0 14px 14px; padding: 14px 8px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  background: var(--glass); backdrop-filter: blur(20px) saturate(160%); -webkit-backdrop-filter: blur(20px) saturate(160%);
  border: 1px solid var(--line); border-radius: 26px; box-shadow: var(--shadow-md);
}
.brand {
  width: 44px; height: 44px; margin-bottom: 8px; border-radius: 14px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent-soft), transparent); border: 1px solid var(--accent-line);
}
.brand-ico { width: 22px; height: 22px; color: var(--accent); }

.nav-btn {
  position: relative; width: 74px; height: 62px; border: 0; border-radius: 18px; background: transparent;
  color: var(--muted); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 5px;
  font: inherit; font-family: var(--mono); font-size: 9.5px; letter-spacing: 0.1em; text-transform: uppercase; cursor: pointer;
  transition: color 0.2s, background 0.2s var(--ease);
}
.nav-btn .ico { width: 21px; height: 21px; }
.nav-btn:hover { color: var(--text); background: var(--surface-2); }
.nav-btn[aria-current="page"] { color: var(--accent); background: var(--accent-soft); }
.nav-btn[aria-current="page"]::after {
  content: ""; position: absolute; left: -8px; top: 20px; width: 3px; height: 22px; border-radius: 3px; background: var(--accent);
  box-shadow: 0 0 12px var(--accent-glow);
}

.rail-foot { margin-top: auto; padding-top: 10px; }
.health { display: inline-flex; flex-direction: column; align-items: center; gap: 6px; font-size: 9px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--dim); }
.health .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--dim); }
.health.ok { color: var(--muted); }
.health.ok .dot { background: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.health.bad .dot { background: var(--danger); }

/* Main panel */
.content {
  position: relative; z-index: 1; margin: 14px 14px 14px 12px; min-width: 0; height: calc(100dvh - 28px);
  display: flex; flex-direction: column; background: var(--bg-raised);
  border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-lg); overflow: hidden;
}

.topbar {
  display: flex; align-items: center; gap: 14px; padding: 18px 26px; min-height: 84px;
  border-bottom: 1px solid var(--line); flex: none;
}
.page-head { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.crumb { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); }
.topbar h2 { font-size: 22px; }

.view { flex: 1; min-height: 0; display: flex; overflow: hidden; }
.view:not([hidden]) { animation: rise 0.45s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

#view-folders, #view-helpers, #view-settings, #view-activity {
  flex-direction: column; overflow-y: auto; padding: 26px 30px 40px; gap: 0;
}
#view-files { flex-direction: column; padding: 20px 26px 0; min-height: 0; }

.section-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; flex-wrap: wrap; margin-bottom: 22px; }
.section-head .lead { flex: 1 1 380px; }
.toolbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-bottom: 18px; }

/* ---------- Cards & grids ---------- */

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(270px, 1fr)); gap: 16px; }

.card {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 10px; padding: 22px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); color: var(--text);
  box-shadow: var(--shadow-md); text-align: left;
  transition: transform 0.3s var(--ease), border-color 0.3s, box-shadow 0.3s;
  animation: rise 0.5s var(--ease) both;
}
.card::before {
  content: ""; position: absolute; left: 0; right: 0; top: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); opacity: 0.6;
}
.card:hover { transform: translateY(-3px); border-color: var(--line-strong); box-shadow: 0 26px 50px -28px rgba(0,0,0,0.8); }
.card.active { border-color: var(--accent-line); box-shadow: 0 0 0 1px var(--accent-line), 0 0 40px -18px var(--accent-glow); }
.card.active::after {
  content: "Active"; position: absolute; top: 18px; right: 18px; font-family: var(--mono); font-size: 10px;
  letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent);
}
.card .card-title { font-family: var(--display); font-size: 19px; font-weight: 650; letter-spacing: -0.02em; display: flex; align-items: center; gap: 10px; }
.card .card-sub { color: var(--muted); font-size: 12px; word-break: break-all; }
.card .card-foot { margin-top: auto; display: flex; flex-wrap: wrap; gap: 8px; padding-top: 10px; }
.card .meta { font-size: 12.5px; }
.card-icon {
  width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center;
  background: linear-gradient(145deg, var(--accent-soft), transparent); border: 1px solid var(--accent-line); color: var(--accent);
}
.card-icon .ico { width: 22px; height: 22px; }

.badge {
  display: inline-flex; align-items: center; height: 22px; padding: 0 9px; border-radius: 999px;
  font-size: 10.5px; letter-spacing: 0.1em; text-transform: uppercase;
  background: var(--accent-soft); color: var(--accent); border: 1px solid var(--accent-line);
}

.meter { height: 4px; border-radius: 4px; background: var(--surface-3); overflow: hidden; margin-top: 4px; }
.meter > span { display: block; height: 100%; border-radius: 4px; background: linear-gradient(90deg, var(--accent), var(--accent-hi)); }

/* ---------- Settings ---------- */

.settings-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); gap: 16px; max-width: 1100px; }
.panel {
  display: flex; flex-direction: column; gap: 14px; padding: 24px; border-radius: var(--r-lg);
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-md);
  animation: rise 0.5s var(--ease) both;
}
.panel .eyebrow-sm { font-size: 10.5px; }
.panel .btn { align-self: flex-start; }

.segmented {
  display: inline-flex; flex-wrap: wrap; gap: 4px; padding: 4px; border-radius: 999px; align-self: flex-start;
  background: var(--surface-2); border: 1px solid var(--line);
}
.segmented button {
  display: inline-flex; align-items: center; gap: 7px; height: 34px; padding: 0 14px; border: 0; border-radius: 999px;
  background: transparent; color: var(--muted); font: inherit; font-size: 13.5px; font-weight: 500; cursor: pointer; transition: all 0.2s var(--ease);
}
.segmented button .ico { width: 16px; height: 16px; }
.segmented button[aria-checked="true"] { background: var(--surface-3); color: var(--text); box-shadow: 0 1px 0 var(--line-strong) inset, 0 4px 12px -6px rgba(0,0,0,0.5); }

.switch-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; font-size: 14.5px; color: var(--text-soft); cursor: pointer; padding-top: 4px; }
.switch-row input {
  width: 42px; height: 24px; appearance: none; -webkit-appearance: none; border-radius: 999px; flex: none; margin: 0;
  background: var(--surface-3); border: 1px solid var(--line-strong); position: relative; cursor: pointer; transition: background 0.25s var(--ease);
}
.switch-row input::after {
  content: ""; position: absolute; top: 2px; left: 2px; width: 18px; height: 18px; border-radius: 50%;
  background: var(--text); transition: transform 0.25s var(--ease);
}
.switch-row input:checked { background: var(--accent); border-color: transparent; }
.switch-row input:checked::after { transform: translateX(18px); background: var(--accent-ink); }

/* ---------- Chat ---------- */

#view-chat { display: grid; grid-template-columns: 300px minmax(0, 1fr); min-height: 0; }

.chat-list {
  display: flex; flex-direction: column; gap: 12px; padding: 16px; min-height: 0;
  border-right: 1px solid var(--line); background: var(--surface);
}
.list { display: flex; flex-direction: column; gap: 2px; overflow-y: auto; min-height: 0; margin: 0 -4px; padding: 0 4px; }
.list-label { font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--dim); padding: 12px 10px 6px; }
.empty-note { padding: 10px; font-size: 13.5px; }

.chat-item {
  position: relative; display: flex; flex-direction: column; gap: 3px; padding: 11px 12px 11px 14px; border-radius: 12px;
  border: 1px solid transparent; background: transparent; color: var(--text); font: inherit; text-align: left; cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.chat-item:hover { background: var(--surface-2); }
.chat-item[aria-current="true"] { background: var(--surface-3); border-color: var(--line-strong); }
.chat-item[aria-current="true"]::before {
  content: ""; position: absolute; left: 0; top: 12px; bottom: 12px; width: 2px; border-radius: 2px; background: var(--accent); box-shadow: 0 0 10px var(--accent-glow);
}
.chat-item .t { font-weight: 550; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item .s { font-size: 11px; color: var(--dim); letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-item.busy .s::before { content: "● "; color: var(--accent); }

.thread { display: flex; flex-direction: column; min-width: 0; min-height: 0; position: relative; }
.thread::before {
  content: ""; position: absolute; top: -120px; left: 50%; width: 720px; height: 320px; transform: translateX(-50%);
  background: radial-gradient(closest-side, var(--accent-soft), transparent); pointer-events: none; opacity: 0.7;
}

.thread-head {
  position: relative; display: flex; align-items: center; gap: 12px; padding: 14px 26px; border-bottom: 1px solid var(--line);
}
.thread-title { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 2px; }
#thread-name { font-family: var(--display); font-weight: 650; font-size: 16.5px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#thread-folder { font-family: var(--mono); font-size: 11px; color: var(--dim); letter-spacing: 0.04em; }
.thread-actions { display: flex; gap: 4px; flex: none; }
.thread-actions .btn { height: 34px; padding: 0 12px; font-size: 13px; }

.banner {
  position: relative; display: flex; align-items: center; gap: 10px; margin: 14px 26px 0; padding: 11px 16px;
  border-radius: var(--r-md); background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--text-soft); font-size: 13.5px;
}

.welcome { position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; animation: rise 0.6s var(--ease) both; }
.welcome h3 { font-size: 36px; letter-spacing: -0.035em; line-height: 1.1; margin-top: 16px; }
.welcome > .meta { font-size: 15px; }
.hero-mark {
  width: 58px; height: 58px; border-radius: 19px; display: grid; place-items: center; color: var(--accent);
  background: linear-gradient(145deg, var(--accent-soft), transparent); border: 1px solid var(--accent-line);
  box-shadow: 0 0 60px -10px var(--accent-glow);
}
.hero-mark .ico { width: 26px; height: 26px; }

.suggestions { display: grid; grid-template-columns: repeat(3, minmax(0, 220px)); gap: 12px; margin-top: 26px; }
.suggest {
  display: flex; flex-direction: column; align-items: flex-start; gap: 22px; min-height: 104px; padding: 16px; text-align: left;
  border-radius: var(--r-md); background: var(--surface); border: 1px solid var(--line); color: var(--text-soft);
  font: inherit; font-size: 14px; line-height: 1.4; cursor: pointer; transition: border-color 0.25s, transform 0.25s var(--ease), background 0.25s;
}
.suggest:hover { border-color: var(--accent-line); transform: translateY(-2px); color: var(--text); background: var(--surface-2); }
.suggest-k { font-size: 11px; color: var(--accent); letter-spacing: 0.1em; }

.messages {
  position: relative; flex: 1; min-height: 0; overflow-y: auto; padding: 30px 26px 14px;
  display: flex; flex-direction: column; gap: 26px; scroll-behavior: smooth;
}
.messages:empty { display: none; }
.msg { display: flex; width: 100%; max-width: 800px; margin: 0 auto; gap: 14px; animation: rise 0.35s var(--ease) both; }
.msg.from-user { justify-content: flex-end; }
.bubble-user {
  max-width: 78%; padding: 11px 16px; border-radius: 18px 18px 5px 18px; white-space: pre-wrap; word-break: break-word;
  background: var(--surface-3); border: 1px solid var(--line-strong); color: var(--text); font-size: 15px; line-height: 1.55;
}
.avatar {
  width: 30px; height: 30px; border-radius: 10px; flex: none; display: grid; place-items: center; margin-top: 2px;
  background: var(--accent-soft); border: 1px solid var(--accent-line); color: var(--accent); font-family: var(--mono); font-size: 12px; font-weight: 600;
}
.msg-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 10px; }
.assistant-text { font-size: 15px; line-height: 1.72; color: var(--text-soft); word-break: break-word; }
.assistant-text > :first-child { margin-top: 0; }
.assistant-text > :last-child { margin-bottom: 0; }
.assistant-text p { margin: 0.6em 0; }
.assistant-text h3, .assistant-text h4, .assistant-text h5 { margin: 1em 0 0.35em; font-size: 16px; color: var(--text); }
.assistant-text strong { color: var(--text); font-weight: 600; }
.assistant-text ul, .assistant-text ol { margin: 0.5em 0; padding-left: 1.3em; }
.assistant-text li::marker { color: var(--accent); }
.assistant-text blockquote { margin: 0.7em 0; padding: 4px 14px; border-left: 2px solid var(--accent); color: var(--muted); }
.assistant-text a { color: var(--accent-hi); text-decoration: none; border-bottom: 1px solid var(--accent-line); }
.assistant-text code {
  font-family: var(--mono); font-size: 0.86em; padding: 1px 6px; border-radius: 6px; background: var(--surface-3); color: var(--text);
}
.assistant-text pre {
  margin: 0.8em 0; padding: 14px 16px; overflow-x: auto; border-radius: var(--r-md);
  background: var(--code-bg); border: 1px solid var(--line-strong);
}
.assistant-text pre code { padding: 0; background: none; color: var(--text-soft); font-size: 13px; line-height: 1.6; }

.typing { display: inline-flex; gap: 5px; padding: 8px 0; }
.typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--accent); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: 0.15s; }
.typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 80%, 100% { opacity: 0.2; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-2px); } }

.tools { display: flex; flex-wrap: wrap; gap: 6px; }
.tool-pill {
  display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px;
  background: var(--surface-2); border: 1px solid var(--line); color: var(--muted); font-size: 11.5px;
}
.tool-pill[data-running] { animation: shimmer 1.6s infinite linear; }
.tool-pill.done { color: var(--accent); border-color: var(--accent-line); background: var(--accent-soft); }
.tool-pill .ico { width: 12px; height: 12px; stroke-width: 2.4; }
@keyframes shimmer { 0%, 100% { opacity: 1; } 50% { opacity: 0.55; } }

.approval {
  position: relative; padding: 18px 20px; border-radius: var(--r-lg); gap: 12px;
  background: var(--surface); border: 1px solid var(--line-strong); box-shadow: var(--shadow-md);
}
.approval::before { content: ""; position: absolute; left: -1px; top: 16px; bottom: 16px; width: 2px; border-radius: 2px; background: var(--warn); }
.approval h4 { margin: 0; font-family: var(--display); font-size: 15.5px; letter-spacing: -0.01em; color: var(--text); }
.approval .meta { font-size: 13.5px; }
.approval code.cmd {
  display: block; padding: 11px 13px; border-radius: var(--r-sm); background: var(--code-bg); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 12.5px; white-space: pre-wrap; word-break: break-all; color: var(--text-soft);
}
.approval .choices { display: flex; flex-wrap: wrap; gap: 8px; }
.approval .choices:empty { display: none; }
.clarify-form { display: flex; gap: 8px; }
.clarify-form .field { flex: 1; min-width: 0; }

.composer {
  position: relative; display: flex; align-items: flex-end; gap: 10px; margin: 6px auto 0; width: min(800px, calc(100% - 52px));
  padding: 9px 9px 9px 18px; border-radius: 22px; background: var(--surface); border: 1px solid var(--line-strong);
  box-shadow: var(--shadow-md); transition: border-color 0.25s, box-shadow 0.25s;
}
.composer:focus-within { border-color: var(--accent-line); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-md); }
.composer-input {
  flex: 1; min-width: 0; resize: none; border: 0; outline: none; background: transparent; color: var(--text);
  font: inherit; font-size: 15.5px; line-height: 1.5; padding: 9px 0; max-height: 180px;
}
.composer-input::placeholder { color: var(--dim); }
.composer-hint { position: relative; text-align: center; padding: 10px 16px 14px; font-size: 11px; letter-spacing: 0.02em; }

/* ---------- Files ---------- */

.files-bar { flex-wrap: nowrap; }
.crumbs {
  display: flex; flex-wrap: wrap; align-items: center; gap: 2px; font-size: 13px; color: var(--dim); min-width: 0;
  padding: 4px; border-radius: 12px; background: var(--surface-2); border: 1px solid var(--line);
}
.crumbs button { border: 0; background: transparent; color: var(--text-soft); font: inherit; cursor: pointer; padding: 5px 9px; border-radius: 8px; }
.crumbs button:hover { background: var(--surface-3); color: var(--accent-hi); }
.crumbs .sep { color: var(--dim); }

.files-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 16px; }
.files-body:not(:has(.preview:not([hidden]))) { grid-template-columns: minmax(0, 1fr); }
.file-list { overflow-y: auto; display: flex; flex-direction: column; gap: 2px; padding: 4px 4px 28px; min-height: 0; }
.tile {
  display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 12px; width: 100%;
  padding: 9px 12px; border-radius: 12px; border: 1px solid transparent; background: transparent; color: var(--text);
  font: inherit; text-align: left; cursor: pointer; transition: background 0.18s, border-color 0.18s;
}
.tile:hover { background: var(--surface-2); }
.tile.selected { background: var(--accent-soft); border-color: var(--accent-line); }
.tile-icon { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--surface-2); color: var(--muted); border: 1px solid var(--line); }
.tile.folder .tile-icon { background: var(--accent-soft); color: var(--accent); border-color: var(--accent-line); }
.tile-icon .ico { width: 17px; height: 17px; }
.tile-name { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-meta { font-size: 11.5px; color: var(--dim); }

.preview {
  display: flex; flex-direction: column; gap: 12px; min-height: 0; overflow: hidden; padding: 20px;
  border-radius: var(--r-lg); background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-md);
  animation: rise 0.35s var(--ease) both;
}
.preview h3 { word-break: break-all; font-family: var(--mono); font-size: 14px; font-weight: 500; letter-spacing: 0; }
.preview .preview-body { flex: 1; min-height: 0; overflow: auto; }
.preview pre {
  margin: 0; padding: 14px; border-radius: var(--r-md); background: var(--code-bg); border: 1px solid var(--line);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.6; white-space: pre-wrap; word-break: break-word; color: var(--text-soft);
}
.preview img { max-width: 100%; border-radius: var(--r-md); }
.preview .actions { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- Dialog, palette, toasts ---------- */

.dlg, .palette {
  border: 1px solid var(--line-strong); border-radius: var(--r-xl); padding: 0; color: var(--text);
  background: var(--surface); box-shadow: var(--shadow-lg);
  animation: rise 0.3s var(--ease) both;
}
.dlg { width: min(440px, calc(100% - 32px)); }
.dlg::backdrop, .palette::backdrop { background: rgba(0, 0, 0, 0.55); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px); }
.dlg-form { display: flex; flex-direction: column; gap: 14px; padding: 26px; }
.dlg-form h3 { font-size: 21px; }
.dlg-actions { display: flex; flex-direction: row-reverse; flex-wrap: wrap; justify-content: flex-start; gap: 8px; margin-top: 6px; }
.dlg-actions .btn.danger, .dlg-actions .btn.primary.danger { background: var(--danger); color: #fff; }

.palette { width: min(640px, calc(100% - 32px)); margin: 12vh auto 0; }
.palette-box { display: flex; flex-direction: column; max-height: 62vh; }
.palette-input-row { display: flex; align-items: center; gap: 12px; padding: 0 20px; border-bottom: 1px solid var(--line); color: var(--muted); }
.palette-input-row .ico { width: 19px; height: 19px; }
.palette-input-row input {
  flex: 1; height: 58px; border: 0; outline: none; background: transparent; color: var(--text); font: inherit; font-size: 16px;
}
.palette-list { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }
.palette-list li {
  display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 11px 12px; border-radius: 11px;
  font-size: 14.5px; cursor: pointer; color: var(--text-soft);
}
.palette-list li[aria-selected="true"] { background: var(--accent-soft); color: var(--text); box-shadow: inset 2px 0 0 var(--accent); }
.palette-list li .hint { font-family: var(--mono); font-size: 11px; color: var(--dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.palette-list li.empty { color: var(--muted); cursor: default; }
.palette-foot {
  display: flex; align-items: center; gap: 6px; padding: 11px 16px; border-top: 1px solid var(--line);
  font-size: 11px; color: var(--dim); background: var(--surface-2);
}
.palette-foot kbd { margin-right: 2px; }

.toasts { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 8px; z-index: 60; pointer-events: none; width: min(460px, calc(100% - 32px)); }
.toast {
  padding: 11px 18px; border-radius: 999px; background: var(--glass); backdrop-filter: blur(16px); -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--line-strong); color: var(--text); font-size: 14px; box-shadow: var(--shadow-md); animation: rise 0.25s var(--ease) both;
}
.toast.err { border-color: rgba(229, 100, 92, 0.5); color: var(--danger); }

/* ---------- Narrow screens ---------- */

@media (max-width: 860px) {
  .shell { grid-template-columns: 1fr; grid-template-rows: minmax(0, 1fr) auto; }
  .content { grid-row: 1; margin: 8px 8px 0; height: auto; min-height: 0; border-radius: 22px; }
  .rail {
    grid-row: 2; flex-direction: row; justify-content: space-around; margin: 8px 10px calc(10px + env(safe-area-inset-bottom));
    padding: 6px; border-radius: 24px; z-index: 5;
  }
  .brand, .rail-foot { display: none; }
  .nav-btn { width: auto; flex: 1; height: 54px; font-size: 9px; }
  .nav-btn[aria-current="page"]::after { display: none; }
  .topbar { padding: 14px 16px; min-height: 66px; }
  .topbar h2 { font-size: 19px; }
  .kbd-btn span, .kbd-btn kbd { display: none; }
  #view-folders, #view-helpers, #view-settings { padding: 18px 16px 30px; }
  #view-chat { grid-template-columns: 1fr; }
  #view-chat .chat-list { border-right: 0; }
  #view-chat[data-mobile-thread="true"] .chat-list { display: none; }
  #view-chat:not([data-mobile-thread="true"]) .thread { display: none; }
  .thread-head { padding: 10px 14px; }
  .thread-actions .btn span { display: none; }
  .messages { padding: 18px 14px 8px; }
  .bubble-user { max-width: 88%; }
  .composer { width: calc(100% - 24px); }
  .composer-hint { display: none; }
  .welcome h3 { font-size: 28px; }
  .suggestions { grid-template-columns: 1fr; width: 100%; }
  .files-body { grid-template-columns: 1fr; }
  .files-bar { flex-wrap: wrap; }
  .preview { position: fixed; inset: auto 10px 90px; max-height: 66vh; z-index: 30; }
  .field.select { min-width: 0; flex: 1; }
  .toasts { bottom: 96px; }
  .palette { margin-top: 8vh; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

:root.big-text { --text-scale: 1.12; }

/* ---------- Composer tools (helper, model, folder) ---------- */

.composer-tools {
  position: relative; display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  width: min(800px, calc(100% - 52px)); margin: 0 auto 8px;
}
.tool-chip {
  display: inline-flex; align-items: center; gap: 7px; max-width: 100%; height: 30px; padding: 0 12px; border-radius: 999px;
  border: 1px solid var(--line-strong); background: var(--surface-2); color: var(--text-soft); font: inherit; font-size: 13px; cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.tool-chip:hover { border-color: var(--accent-line); background: var(--surface-3); }
.tool-chip .tool-glyph { font-size: 14px; line-height: 1; }
.tool-chip span.trunc { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }
.tool-chip .caret { color: var(--dim); font-size: 10px; }

/* ---------- Avatars ---------- */

.avatar-glyph {
  width: 46px; height: 46px; border-radius: 15px; display: grid; place-items: center; font-size: 22px; line-height: 1; flex: none;
  background: linear-gradient(145deg, var(--accent-soft), var(--surface-3)); border: 1px solid var(--accent-line);
}
.avatar-glyph.sm { width: 32px; height: 32px; border-radius: 11px; font-size: 16px; }
.avatar.glyph { font-size: 16px; font-family: inherit; text-transform: none; letter-spacing: 0; }
.avatar-grid { display: grid; grid-template-columns: repeat(6, 1fr); gap: 8px; }
.avatar-choice {
  height: 52px; border-radius: 14px; border: 1px solid var(--line); background: var(--surface-2); font-size: 24px; cursor: pointer;
  transition: transform 0.15s var(--ease), border-color 0.2s;
}
.avatar-choice:hover { transform: translateY(-2px); border-color: var(--accent-line); }
.avatar-choice[aria-selected="true"] { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- Picker & nav dot ---------- */

.palette-list li .hint.tag { color: var(--accent-hi); }
.nav-dot {
  position: absolute; top: 9px; right: 14px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent-glow); animation: pulse 2.2s infinite;
}

/* ---------- Activity ---------- */

.activity-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(360px, 1fr)); gap: 16px; }
.activity-card {
  position: relative; overflow: hidden; display: flex; flex-direction: column; gap: 14px; padding: 20px;
  background: var(--surface); border: 1px solid var(--accent-line); border-radius: var(--r-lg); box-shadow: 0 0 40px -22px var(--accent-glow);
  animation: rise 0.4s var(--ease) both;
}
.activity-card::before {
  content: ""; position: absolute; inset: 0 0 auto 0; height: 2px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent); background-size: 200% 100%; animation: sweep 2.4s linear infinite;
}
@keyframes sweep { from { background-position: 150% 0; } to { background-position: -50% 0; } }
.activity-head { display: flex; align-items: center; gap: 14px; min-width: 0; }
.activity-head .info { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.activity-head .title { font-family: var(--display); font-weight: 650; font-size: 16.5px; letter-spacing: -0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.activity-status { display: inline-flex; align-items: center; gap: 8px; font-family: var(--mono); font-size: 11.5px; color: var(--accent-hi); }
.activity-status .pulse { width: 6px; height: 6px; }
.activity-live {
  min-height: 74px; max-height: 140px; overflow: hidden; padding: 12px 14px; border-radius: var(--r-md);
  background: var(--code-bg); border: 1px solid var(--line); font-size: 13.5px; line-height: 1.6; color: var(--text-soft);
  white-space: pre-wrap; word-break: break-word; mask-image: linear-gradient(180deg, #000 60%, transparent);
}
.activity-live.empty { color: var(--dim); font-style: normal; }
.activity-foot { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.activity-foot .meta { margin-right: auto; font-family: var(--mono); font-size: 11.5px; }
.empty-state {
  grid-column: 1 / -1; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 60px 20px; text-align: center;
  border: 1px dashed var(--line-strong); border-radius: var(--r-xl); color: var(--muted);
}
.empty-state h3 { color: var(--text); }

@media (max-width: 860px) {
  .activity-list { grid-template-columns: 1fr; }
  .composer-tools { width: calc(100% - 24px); }
  .tool-chip span.trunc { max-width: 120px; }
}
