/* MYO Ders Bilgi Paketi Asistanı v2: a calm, bright chatbot surface around the brand navy #0054A0.
   System fonts only; no external assets; no inline styles (CSP). Tokens first, then layout, then components. */

:root {
  --navy: #0054a0;
  --navy-600: #0a62b8;
  --navy-700: #00427f;
  --navy-800: #0b2f57;
  --azure: #1478d4;
  --cyan: #19b3e0;
  --ink: #0f1e33;
  --ink-2: #2a3a52;
  --muted: #52627a;
  --bg: #f3f6fb;
  --surface: #ffffff;
  --surface-2: #f7f9fd;
  --tint: #e8f0fa;
  --tint-2: #d6e4f5;
  --line: #e1e7f0;
  --line-2: #c9d4e3;
  --ok: #13653a;
  --ok-soft: #e4f4ea;
  --warn: #7a4a00;
  --warn-soft: #fdf1d8;
  --bad: #9d2626;
  --bad-soft: #fbeaea;
  --wait: #3b4a60;
  --wait-soft: #edf1f6;
  --focus: #0054a0;
  --grad: linear-gradient(135deg, #0054a0 0%, #0d6cc6 60%, #1478d4 100%);
  --grad-glow: linear-gradient(120deg, rgba(0, 84, 160, 0.55), rgba(25, 179, 224, 0.55), rgba(108, 92, 231, 0.4));
  --r-xl: 24px;
  --r-lg: 18px;
  --r-md: 12px;
  --r-sm: 8px;
  --shadow-1: 0 1px 2px rgba(15, 30, 51, 0.05), 0 2px 6px rgba(15, 30, 51, 0.04);
  --shadow-2: 0 1px 2px rgba(15, 30, 51, 0.06), 0 10px 30px rgba(15, 30, 51, 0.08);
  --shadow-3: 0 2px 4px rgba(0, 66, 127, 0.08), 0 18px 48px rgba(0, 66, 127, 0.14);
  --font: "Segoe UI Variable Text", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, "Noto Sans", Arial, sans-serif;
  --font-display: "Segoe UI Variable Display", "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Roboto, "Noto Sans", Arial, sans-serif;
  --content: 52rem;
  --ease: cubic-bezier(0.2, 0.7, 0.2, 1);
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-bottom: 14rem; }
body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  overflow-wrap: anywhere;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
h1, h2, h3 { font-family: var(--font-display); line-height: 1.25; margin: 0; font-weight: 650; letter-spacing: -0.01em; }
h1 { font-size: 1.5rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0; }
.h-small { font-size: 0.98rem; font-weight: 650; }
.small { font-size: 0.875rem; }
.muted { color: var(--muted); }
.center-text { text-align: center; }
.pre-line { white-space: pre-line; }
a { color: var(--navy); text-underline-offset: 3px; }
a:hover { color: var(--navy-700); }
.icon { width: 1.15em; height: 1.15em; flex: none; }

.sr-only {
  position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.skip-link {
  position: absolute; left: 1rem; top: -4rem; z-index: 50; padding: 0.6rem 1rem;
  background: var(--navy); color: #fff; border-radius: var(--r-sm); text-decoration: none; font-weight: 600;
}
.skip-link:focus { top: 1rem; color: #fff; }

/* ---------- ambient background ---------- */

.aurora {
  position: fixed; inset: 0 0 auto 0; height: 34rem; z-index: -1; pointer-events: none;
  background:
    radial-gradient(40rem 22rem at 12% -8%, rgba(0, 84, 160, 0.16), transparent 70%),
    radial-gradient(34rem 20rem at 88% -6%, rgba(25, 179, 224, 0.16), transparent 70%),
    radial-gradient(30rem 16rem at 55% 8%, rgba(108, 92, 231, 0.08), transparent 70%);
}

/* ---------- top bar ---------- */

.topbar {
  position: sticky; top: 0; z-index: 20;
  background: rgba(243, 246, 251, 0.78);
  backdrop-filter: saturate(160%) blur(14px);
  -webkit-backdrop-filter: saturate(160%) blur(14px);
  border-bottom: 1px solid rgba(201, 212, 227, 0.55);
}
.topbar-row {
  max-width: var(--content); margin: 0 auto; padding: 0.7rem clamp(0.9rem, 3vw, 1.5rem);
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
}
.brand { display: inline-flex; align-items: center; gap: 0.7rem; text-decoration: none; color: var(--ink); min-width: 0; }
.brand:hover { color: var(--ink); }
.brand-mark { width: 34px; height: 34px; border-radius: 10px; box-shadow: var(--shadow-1); flex: none; }
.brand-text { display: flex; flex-direction: column; line-height: 1.2; min-width: 0; }
.brand-app { font-family: var(--font-display); font-weight: 680; font-size: 1rem; letter-spacing: -0.01em; }
.brand-org { font-size: 0.78rem; color: var(--muted); }
.topbar-tools { display: flex; align-items: center; gap: 0.6rem; }

/* ---------- buttons ---------- */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.45rem;
  min-height: 2.75rem; padding: 0.55rem 1.15rem; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--ink);
  font: inherit; font-weight: 600; font-size: 0.95rem; line-height: 1.2; cursor: pointer;
  transition: background-color 0.15s var(--ease), border-color 0.15s var(--ease), box-shadow 0.2s var(--ease), transform 0.15s var(--ease);
}
.btn:hover:not(:disabled) { border-color: var(--navy); color: var(--navy-700); }
.btn:active:not(:disabled) { transform: translateY(1px); }
.btn:disabled { cursor: not-allowed; opacity: 0.55; }
.btn-primary { background: var(--grad); border-color: transparent; color: #fff; box-shadow: 0 6px 16px rgba(0, 84, 160, 0.22); }
.btn-primary:hover:not(:disabled) { color: #fff; border-color: transparent; box-shadow: 0 8px 22px rgba(0, 84, 160, 0.32); }
.btn-primary:disabled { background: #9fb1c8; box-shadow: none; opacity: 1; color: #fff; }
.btn-ghost { background: transparent; border-color: var(--line-2); }
.btn-small { min-height: 2.25rem; padding: 0.35rem 0.9rem; font-size: 0.875rem; }
.btn-danger-ghost { background: transparent; border-color: rgba(157, 38, 38, 0.35); color: var(--bad); }
.btn-danger-ghost:hover:not(:disabled) { border-color: var(--bad); color: var(--bad); background: var(--bad-soft); }
.btn-glow:not(:disabled) { position: relative; }

.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 2.4rem; height: 2.4rem;
  border-radius: 999px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer;
}
.icon-btn:hover:not(:disabled) { background: var(--tint); color: var(--navy); }
.icon-btn:disabled { opacity: 0.45; cursor: not-allowed; }

/* ---------- pills ---------- */

.pill {
  display: inline-flex; align-items: center; gap: 0.4rem; white-space: nowrap;
  padding: 0.2rem 0.7rem; border-radius: 999px; font-size: 0.78rem; font-weight: 650; line-height: 1.4;
  background: var(--wait-soft); color: var(--wait);
}
.pill-ok { background: var(--ok-soft); color: var(--ok); }
.pill-warn { background: var(--warn-soft); color: var(--warn); }
.pill-bad { background: var(--bad-soft); color: var(--bad); }
.pill-run { background: var(--tint); color: var(--navy-700); }
.pill-wait { background: var(--wait-soft); color: var(--wait); }
.pill-dot::before { content: ""; width: 0.5rem; height: 0.5rem; border-radius: 50%; background: currentColor; }

/* ---------- main and views ---------- */

.main {
  flex: 1; width: 100%; max-width: var(--content); margin: 0 auto;
  padding: clamp(1rem, 3vw, 2rem) clamp(0.9rem, 3vw, 1.5rem) 0;
  display: flex; flex-direction: column;
}
.main:focus { outline: none; }
.view { flex: 1; }
.view-center { display: flex; align-items: center; justify-content: center; padding: 2rem 0 4rem; }
.notice-card {
  width: 100%; max-width: 30rem; background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--r-xl); box-shadow: var(--shadow-2); padding: clamp(1.5rem, 4vw, 2.25rem);
  display: flex; flex-direction: column; gap: 1rem;
}
.notice-mark { width: 48px; height: 48px; border-radius: 14px; }
.actions { display: flex; flex-wrap: wrap; gap: 0.6rem; }
.actions:empty { display: none; }
.form { display: flex; flex-direction: column; gap: 0.9rem; }
.field { display: flex; flex-direction: column; gap: 0.35rem; }
.field label { font-weight: 600; font-size: 0.9rem; }
input[type="text"], input[type="url"], input[type="email"], input[type="password"], input[type="date"], textarea, select {
  font: inherit; color: var(--ink); background: var(--surface);
  border: 1px solid var(--line-2); border-radius: var(--r-md); padding: 0.65rem 0.8rem; min-height: 2.75rem;
}
input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 3px solid rgba(0, 84, 160, 0.35); outline-offset: 0; border-color: var(--navy); }
.form-error { color: var(--bad); font-size: 0.9rem; font-weight: 550; }
.form-error p + p { margin-top: 0.25rem; }

.spinner {
  width: 2.25rem; height: 2.25rem; border-radius: 50%;
  border: 3px solid var(--tint-2); border-top-color: var(--navy); animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.queue-number { display: flex; align-items: baseline; justify-content: center; gap: 0.6rem; }
.queue-label { color: var(--muted); }
.queue-number strong { font-size: 2.6rem; font-family: var(--font-display); color: var(--navy); }
.dots { display: flex; justify-content: center; gap: 0.4rem; }
.dots span, .typing-dots span {
  width: 0.45rem; height: 0.45rem; border-radius: 50%; background: var(--navy); opacity: 0.25;
  animation: blink 1.2s infinite var(--ease);
}
.dots span:nth-child(2), .typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.dots span:nth-child(3), .typing-dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes blink { 0%, 100% { opacity: 0.2; transform: translateY(0); } 40% { opacity: 0.9; transform: translateY(-2px); } }

/* ---------- chat thread ---------- */

.chat { display: flex; flex-direction: column; min-height: 100%; }
.thread { flex: 1; display: flex; flex-direction: column; gap: 1.1rem; padding-bottom: 1.25rem; }
.timeline { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1.1rem; }
.timeline:empty { display: none; }

.msg { display: flex; gap: 0.75rem; align-items: flex-start; animation: rise 0.35s var(--ease) both; }
@keyframes rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
.msg-body { min-width: 0; flex: 1; display: flex; flex-direction: column; gap: 0.3rem; }
.avatar { width: 34px; height: 34px; border-radius: 11px; flex: none; overflow: hidden; box-shadow: var(--shadow-1); }
.avatar img { width: 100%; height: 100%; display: block; }
.ev-time { font-size: 0.72rem; color: var(--muted); padding: 0 0.25rem; }
.ev-text { white-space: pre-line; }

.bubble {
  background: var(--surface); border: 1px solid var(--line); border-radius: 6px var(--r-lg) var(--r-lg) var(--r-lg);
  padding: 0.75rem 1rem; box-shadow: var(--shadow-1); max-width: 40rem; width: fit-content;
}
.bubble-welcome { padding: 1rem 1.15rem; display: flex; flex-direction: column; gap: 0.25rem; }
.welcome-lead { font-family: var(--font-display); font-size: 1.12rem; font-weight: 650; letter-spacing: -0.01em; }
.card-head-main { display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap; min-width: 0; }
.model-chip { font-size: 0.75rem; font-weight: 600; color: var(--muted); }
.rights-badge {
  font-size: 0.78rem; font-weight: 650; color: var(--navy-700); background: var(--tint);
  border-radius: 999px; padding: 0.3rem 0.65rem; white-space: nowrap; font-variant-numeric: tabular-nums;
}
.rights-badge.is-low { color: var(--warn); background: var(--warn-soft); }


.msg-user { justify-content: flex-end; }
.msg-user .msg-body { align-items: flex-end; flex: 0 1 auto; max-width: min(36rem, 88%); }
.msg-user .bubble {
  background: var(--grad); color: #fff; border: 0; border-radius: var(--r-lg) 6px var(--r-lg) var(--r-lg);
  box-shadow: 0 6px 16px rgba(0, 84, 160, 0.18);
}
.user-files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.35rem; }
.user-file { display: flex; align-items: center; gap: 0.5rem; font-weight: 600; }
.user-files + .ev-text { margin-top: 0.4rem; opacity: 0.95; }

.sysline { display: flex; justify-content: center; }
.sysline p {
  font-size: 0.82rem; color: var(--muted); background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line); border-radius: 999px; padding: 0.25rem 0.85rem; text-align: center;
}

.typing { display: inline-flex; align-items: center; min-height: 2.6rem; }
.typing-dots { display: inline-flex; gap: 0.3rem; }

.net-status { text-align: center; font-size: 0.85rem; color: var(--warn); }

/* ---------- cards in the thread ---------- */

.card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg);
  box-shadow: var(--shadow-1); padding: 1rem 1.1rem; display: flex; flex-direction: column; gap: 0.7rem;
  max-width: 40rem;
}
.card-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 0.75rem; }
.card-title { font-size: 1rem; }
.result-text { font-weight: 600; white-space: pre-line; }
.kicker { font-size: 0.75rem; font-weight: 650; letter-spacing: 0.04em; text-transform: uppercase; color: var(--navy); margin-bottom: 0.15rem; }

.job-card.is-running { border-color: var(--tint-2); }
.job-current { font-weight: 600; color: var(--ink-2); }
.job-detail { font-size: 0.875rem; color: var(--muted); }
.bar { height: 0.45rem; border-radius: 999px; background: var(--tint); overflow: hidden; }
.bar-fill {
  display: block; height: 100%; width: 0; border-radius: inherit; background: var(--grad);
  transition: width 0.5s var(--ease);
}
.job-card.is-running .bar-fill {
  background: linear-gradient(90deg, #0054a0, #1478d4, #19b3e0, #1478d4, #0054a0);
  background-size: 300% 100%; animation: flow 2.4s linear infinite;
}
@keyframes flow { to { background-position: -300% 0; } }
.job-card.is-done .bar-fill { background: var(--ok); }
.steps-details summary { cursor: pointer; font-size: 0.85rem; color: var(--muted); width: fit-content; border-radius: 6px; }
.steps-details summary:hover { color: var(--navy); }
.checklist {
  list-style: none; margin: 0.6rem 0 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(11rem, 1fr));
  gap: 0.3rem 0.9rem; font-size: 0.85rem; color: var(--muted);
}
.checklist li { display: flex; align-items: center; gap: 0.45rem; }
.checklist .mark {
  width: 1.15rem; height: 1.15rem; border-radius: 50%; border: 1.5px solid var(--line-2); flex: none;
  display: inline-flex; align-items: center; justify-content: center; font-size: 0.7rem; font-weight: 700;
}
.checklist li.done { color: var(--ink-2); }
.checklist li.done .mark { background: var(--ok); border-color: var(--ok); color: #fff; }
.checklist li.current { color: var(--navy-700); font-weight: 600; }
.checklist li.current .mark { border-color: var(--navy); color: var(--navy); }
.checklist li.failed .mark { background: var(--bad); border-color: var(--bad); color: #fff; }
.job-card.is-failed { border-color: rgba(157, 38, 38, 0.3); }
.job-card.is-cancelled { opacity: 0.85; }

.result-card { border-color: rgba(19, 101, 58, 0.25); box-shadow: var(--shadow-2); }
.result-card.needs-review { border-color: rgba(122, 74, 0, 0.3); }
.files { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.5rem; }
.file-row {
  display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 0.75rem;
  padding: 0.6rem 0.65rem 0.6rem 0.7rem; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2);
}
.file-icon {
  width: 2.25rem; height: 2.25rem; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  background: var(--tint); color: var(--navy);
}
.role-ek4_tr .file-icon, .role-ek3_en .file-icon { background: #e3f4ea; color: var(--ok); }
.role-report .file-icon { background: #efeafd; color: #4b3cb0; }
.file-info { min-width: 0; }
.file-name { font-weight: 600; font-size: 0.92rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-meta { font-size: 0.8rem; color: var(--muted); }
.file-error { grid-column: 1 / -1; color: var(--bad); font-size: 0.85rem; }
.file-error:empty { display: none; }

.error-card { border-color: rgba(157, 38, 38, 0.3); background: #fffafa; }

.question-card { border-color: var(--tint-2); }
.q-fieldset { border: 0; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.7rem; min-width: 0; }
.q-legend { padding: 0; font-weight: 600; font-size: 1rem; color: var(--ink); white-space: pre-line; }
.opts { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.opt { position: relative; }
.opt-input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.opt-chip {
  display: inline-flex; align-items: center; gap: 0.5rem; padding: 0.5rem 0.95rem 0.5rem 0.55rem; min-height: 2.6rem;
  border: 1.5px solid var(--line-2); border-radius: 999px; background: var(--surface); cursor: pointer;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.opt-chip:hover { border-color: var(--navy); }
.opt-key {
  width: 1.6rem; height: 1.6rem; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
  background: var(--tint); color: var(--navy); font-weight: 700; font-size: 0.8rem; flex: none;
}
.opt-default { font-size: 0.72rem; font-weight: 650; color: var(--ok); background: var(--ok-soft); border-radius: 999px; padding: 0.05rem 0.5rem; }
.opt-input:checked + .opt-chip { border-color: var(--navy); background: var(--tint); }
.opt-input:checked + .opt-chip .opt-key { background: var(--navy); color: #fff; }
.opt-input:focus-visible + .opt-chip { outline: 3px solid var(--focus); outline-offset: 2px; }
.opt-input:disabled + .opt-chip { cursor: default; opacity: 0.7; }
.opt-input:disabled + .opt-chip:hover { border-color: var(--line-2); }
.q-text { display: flex; flex-direction: column; gap: 0.35rem; }
.q-text label { font-size: 0.85rem; font-weight: 600; color: var(--muted); }
.q-text textarea { resize: vertical; min-height: 2.75rem; }
.q-state { font-size: 0.85rem; color: var(--muted); }
.q-state:empty { display: none; }
.question-card.is-answered { background: var(--surface-2); }

/* ---------- drop card: the main element before the first version ---------- */

.dropcard { padding-left: calc(34px + 0.75rem); animation: rise 0.45s 0.05s var(--ease) both; }
.dropzone {
  position: relative; border-radius: var(--r-xl); padding: clamp(1.25rem, 3.5vw, 2rem);
  background:
    linear-gradient(var(--surface), var(--surface)) padding-box,
    var(--grad-glow) border-box;
  border: 2px dashed transparent;
  box-shadow: var(--shadow-3);
  display: flex; flex-direction: column; gap: 1.1rem;
  transition: transform 0.2s var(--ease), box-shadow 0.2s var(--ease);
}
.dropzone::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background: radial-gradient(28rem 12rem at 50% 0%, rgba(20, 120, 212, 0.07), transparent 70%);
}
.dropzone.is-over { transform: scale(1.01); box-shadow: 0 0 0 6px rgba(20, 120, 212, 0.15), var(--shadow-3); }
.dropzone.is-attention { animation: nudge 0.8s var(--ease) 2; }
@keyframes nudge {
  0%, 100% { box-shadow: var(--shadow-3); }
  50% { box-shadow: 0 0 0 8px rgba(0, 84, 160, 0.2), var(--shadow-3); }
}
.dropzone.is-disabled { opacity: 0.7; }
.drop-head { display: flex; align-items: center; gap: 0.9rem; position: relative; }
.drop-icon {
  width: 3rem; height: 3rem; border-radius: 15px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: var(--grad); color: #fff; box-shadow: 0 8px 18px rgba(0, 84, 160, 0.28);
}
.drop-icon svg { width: 1.5rem; height: 1.5rem; }
.drop-title { font-size: clamp(1.15rem, 2.6vw, 1.4rem); }
.slots { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; position: relative; }
.slot { position: relative; min-width: 0; }
.slot-pick {
  width: 100%; display: flex; align-items: center; gap: 0.75rem; text-align: left;
  padding: 0.9rem 2.6rem 0.9rem 0.9rem; min-height: 4.6rem;
  border: 1.5px dashed var(--line-2); border-radius: var(--r-lg); background: var(--surface-2);
  font: inherit; color: var(--ink); cursor: pointer;
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease);
}
.slot-pick:hover:not(:disabled) { border-color: var(--navy); background: var(--tint); }
.slot-pick:disabled { cursor: not-allowed; }
.slot-icon {
  width: 2.5rem; height: 2.5rem; border-radius: 12px; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: var(--surface); color: var(--navy); border: 1px solid var(--line);
}
.slot-icon svg { width: 1.3rem; height: 1.3rem; }
.slot-text { display: flex; flex-direction: column; min-width: 0; flex: 1; gap: 0.1rem; }
.slot-title { display: flex; align-items: baseline; gap: 0.45rem; }
.slot-title strong { font-family: var(--font-display); font-size: 1.05rem; }
.slot-sub { font-size: 0.85rem; color: var(--muted); }
.slot-file { font-size: 0.85rem; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slot.has-file .slot-pick { border-style: solid; border-color: rgba(19, 101, 58, 0.45); background: #f3faf6; }
.slot.has-file .slot-icon { background: var(--ok); color: #fff; border-color: var(--ok); }
.slot.has-file .slot-file { color: var(--ok); font-weight: 600; }
.slot-remove {
  position: absolute; top: 50%; right: 0.55rem; transform: translateY(-50%);
  width: 2rem; height: 2rem; border-radius: 50%; border: 0; background: transparent; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.slot-remove:hover { background: var(--bad-soft); color: var(--bad); }
.drop-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 0.6rem; position: relative; }
.dropzone.has-files .btn-glow:not(:disabled) { animation: glow 2.2s var(--ease) infinite; }
@keyframes glow {
  0%, 100% { box-shadow: 0 6px 16px rgba(0, 84, 160, 0.22); }
  50% { box-shadow: 0 6px 26px rgba(20, 120, 212, 0.45); }
}

/* ---------- dock: resume link, panels, busy strip, composer ---------- */

.dock {
  position: sticky; bottom: 0; z-index: 10; display: flex; flex-direction: column; gap: 0.6rem;
  padding: 1.25rem 0 calc(0.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(to top, var(--bg) 78%, rgba(243, 246, 251, 0));
}
.dock-card, .resume-card {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
  padding: 0.85rem 1rem;
}
.dock-row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.resume-card { border-color: var(--tint-2); display: flex; flex-direction: column; gap: 0.6rem; max-width: 40rem; }
.resume-head { display: flex; flex-direction: column; gap: 0.15rem; }
.resume-head p { color: var(--muted); }
.resume-row { display: flex; gap: 0.5rem; align-items: center; }
.resume-input { flex: 1; min-width: 0; font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.82rem; min-height: 2.25rem; padding: 0.35rem 0.65rem; background: var(--surface-2); }
.resume-status { color: var(--ok); }
.resume-status:empty { display: none; }

.busy {
  display: flex; align-items: center; gap: 0.75rem; padding: 0.5rem 0.55rem 0.5rem 1rem;
  background: var(--surface); border: 1px solid var(--tint-2); border-radius: 999px; box-shadow: var(--shadow-1);
}
.busy-pulse {
  width: 1.1rem; height: 1.1rem; border-radius: 50%; flex: none;
  border: 2.5px solid var(--tint-2); border-top-color: var(--azure); animation: spin 0.9s linear infinite;
}
.busy-text { flex: 1; font-weight: 600; font-size: 0.92rem; color: var(--ink-2); }

.closed-line {
  text-align: center; font-weight: 600; color: var(--warn); background: var(--warn-soft);
  border-radius: 999px; padding: 0.6rem 1rem;
}

.composer { display: flex; flex-direction: column; gap: 0.55rem; }
.chips {
  display: flex; gap: 0.45rem; overflow-x: auto; scrollbar-width: none; padding: 0.15rem 0.1rem 0.2rem;
  -webkit-mask-image: linear-gradient(to right, #000 92%, transparent);
  mask-image: linear-gradient(to right, #000 92%, transparent);
}
.chips::-webkit-scrollbar { display: none; }
@media (min-width: 641px) {
  .chips { flex-wrap: wrap; overflow: visible; -webkit-mask-image: none; mask-image: none; }
}
.chip {
  flex: none; font: inherit; font-size: 0.86rem; font-weight: 550; color: var(--ink-2);
  padding: 0.45rem 0.9rem; min-height: 2.25rem; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line-2); background: rgba(255, 255, 255, 0.85);
  transition: border-color 0.15s var(--ease), background-color 0.15s var(--ease), color 0.15s var(--ease);
}
.chip:hover { border-color: var(--navy); color: var(--navy-700); background: var(--surface); }
.chip:first-child { border-color: rgba(0, 84, 160, 0.45); color: var(--navy-700); background: var(--surface); }

.composer-box {
  background: var(--surface); border: 1px solid var(--line-2); border-radius: var(--r-xl);
  box-shadow: var(--shadow-2); padding: 0.7rem 0.7rem 0.6rem 1rem;
  transition: border-color 0.15s var(--ease), box-shadow 0.2s var(--ease);
}
.composer-box:focus-within { border-color: var(--navy); box-shadow: 0 0 0 4px rgba(0, 84, 160, 0.12), var(--shadow-2); }
.composer-box textarea {
  display: block; width: 100%; border: 0; padding: 0.35rem 0.1rem; min-height: 2.6rem; max-height: 12.5rem;
  resize: none; background: transparent; font-size: 1rem; line-height: 1.5;
}
.composer-box textarea:focus-visible { outline: none; }
.composer-box textarea::placeholder { color: #6a7a91; }
.composer-tools { display: flex; align-items: center; gap: 0.4rem; flex-wrap: wrap; margin-top: 0.3rem; }
.tools-spacer { flex: 1; }
.tools-right { display: flex; align-items: center; gap: 0.4rem; margin-left: auto; flex-wrap: nowrap; min-width: 0; }
.counter { font-size: 0.78rem; color: var(--muted); }
.counter.is-near { color: var(--bad); font-weight: 600; }

.seg {
  display: inline-flex; padding: 0.2rem; background: var(--surface-2); border: 1px solid var(--line); border-radius: 999px;
}
.seg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.seg label {
  padding: 0.3rem 0.8rem; border-radius: 999px; font-size: 0.82rem; font-weight: 600; color: var(--muted); cursor: pointer;
  min-height: 2rem; display: inline-flex; align-items: center;
}
.seg input:checked + label { background: var(--surface); color: var(--navy-700); box-shadow: var(--shadow-1); }
.seg input:focus-visible + label { outline: 3px solid var(--focus); outline-offset: 1px; }

.tag {
  display: inline-flex; align-items: center; gap: 0.2rem; padding: 0.2rem 0.25rem 0.2rem 0.75rem; border-radius: 999px;
  background: #efeafd; color: #3f3196; font-size: 0.82rem; font-weight: 650;
}
.tag-x {
  width: 1.75rem; height: 1.75rem; border-radius: 50%; border: 0; background: transparent; color: inherit; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.tag-x:hover { background: rgba(63, 49, 150, 0.12); }

.model-pick {
  position: relative; display: inline-flex; align-items: center; gap: 0.3rem;
  border: 1px solid var(--line); border-radius: 999px; background: var(--surface-2); padding: 0 0.2rem 0 0.65rem;
}
.model-pick:hover { border-color: var(--line-2); }
.model-pick:focus-within { border-color: var(--navy); }
.model-icon { color: var(--azure); width: 0.95rem; height: 0.95rem; }
.model-pick select {
  border: 0; background: transparent; font-size: 0.84rem; font-weight: 600; color: var(--ink-2);
  min-height: 2.2rem; padding: 0.2rem 0.6rem 0.2rem 0.1rem; cursor: pointer; border-radius: 999px;
}
.model-pick select:focus-visible { outline: none; }

.send-btn {
  width: 2.6rem; height: 2.6rem; border-radius: 50%; border: 0; flex: none; cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; color: #fff; background: #b3c1d4;
  transition: background 0.2s var(--ease), transform 0.15s var(--ease), box-shadow 0.2s var(--ease);
}
.send-btn.is-ready { background: var(--grad); box-shadow: 0 6px 16px rgba(0, 84, 160, 0.3); }
.send-btn.is-ready:hover { transform: translateY(-1px); }
.send-btn:disabled { cursor: not-allowed; }
.send-btn .icon { width: 1.25rem; height: 1.25rem; }
.send-btn[aria-busy="true"] .icon { animation: spin 0.9s linear infinite; }

.composer-status { font-size: 0.86rem; color: var(--muted); padding: 0 0.9rem; text-align: center; }
.composer-status.is-error { color: var(--bad); font-weight: 600; }

.human-check { display: flex; justify-content: center; }
.human-check:empty, .human-check:not(.is-visible) { height: 0; overflow: hidden; }
.human-check.is-visible { height: auto; padding: 0.25rem 0; }

/* ---------- footer ---------- */

.site-footer { padding: 0.25rem 1rem calc(1rem + env(safe-area-inset-bottom)); text-align: center; font-size: 0.78rem; color: var(--muted); }
.site-footer a { color: var(--muted); font-weight: 600; }
.site-footer a:hover { color: var(--navy); }

/* ---------- admin page ---------- */

.page-admin .main, .page-admin .topbar-row { max-width: 72rem; }
.admin-login { display: flex; justify-content: center; padding: 2rem 0 4rem; }
.admin-login .notice-card { max-width: 26rem; }
.admin-login .human-check:not(:empty) { height: auto; overflow: visible; justify-content: flex-start; }
.admin-head { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.25rem; }
.tabs { display: inline-flex; padding: 0.25rem; background: var(--surface); border: 1px solid var(--line); border-radius: 999px; box-shadow: var(--shadow-1); }
.tab {
  font: inherit; font-weight: 600; font-size: 0.92rem; color: var(--muted); background: transparent; border: 0;
  border-radius: 999px; padding: 0.45rem 1.1rem; min-height: 2.4rem; cursor: pointer;
}
.tab[aria-selected="true"] { background: var(--grad); color: #fff; }
.panel { display: flex; flex-direction: column; gap: 1rem; }
.toolbar {
  display: flex; align-items: flex-end; gap: 0.75rem; flex-wrap: wrap;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0.9rem 1rem; box-shadow: var(--shadow-1);
}
.toolbar .field { min-width: 10rem; }
.toolbar .grow { flex: 1; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(9rem, 1fr)); gap: 0.75rem; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0.85rem 1rem; box-shadow: var(--shadow-1); }
.stat-label { font-size: 0.8rem; color: var(--muted); font-weight: 600; }
.stat-value { font-family: var(--font-display); font-size: 1.7rem; font-weight: 700; color: var(--navy-800); }
.table-wrap { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-1); overflow-x: auto; }
.table-wrap:focus-visible { outline: 3px solid var(--focus); }
table.report { width: 100%; border-collapse: collapse; font-size: 0.86rem; }
table.report th, table.report td { padding: 0.6rem 0.75rem; text-align: left; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.report th { position: sticky; top: 0; background: var(--surface-2); font-size: 0.76rem; text-transform: uppercase; letter-spacing: 0.04em; color: var(--muted); }
table.report td.course { white-space: normal; min-width: 12rem; max-width: 22rem; }
table.report tbody tr:hover { background: var(--surface-2); }
table.report tbody tr:last-child td { border-bottom: 0; }
.rule { display: inline-flex; align-items: center; justify-content: center; min-width: 1.6rem; height: 1.6rem; padding: 0 0.35rem; border-radius: 8px; font-size: 0.72rem; font-weight: 700; }
.rule-ok { background: var(--ok-soft); color: var(--ok); }
.rule-fixed { background: var(--tint); color: var(--navy-700); }
.rule-failed { background: var(--bad-soft); color: var(--bad); }
.rule-na { background: var(--wait-soft); color: var(--muted); }
.empty-row { padding: 2rem 1rem; text-align: center; color: var(--muted); }
.legend { display: flex; flex-wrap: wrap; gap: 0.5rem 1rem; font-size: 0.8rem; color: var(--muted); }
.legend span { display: inline-flex; align-items: center; gap: 0.35rem; }
.samples-grid { display: grid; grid-template-columns: minmax(18rem, 24rem) 1fr; gap: 1rem; align-items: start; }
.sample-form { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 1.1rem; box-shadow: var(--shadow-2); }
.sample-form input[type="file"] { font: inherit; font-size: 0.85rem; color: var(--muted); }
.sample-form input[type="file"]::file-selector-button {
  font: inherit; font-weight: 600; color: var(--ink); background: var(--surface); cursor: pointer;
  border: 1px solid var(--line-2); border-radius: 999px; padding: 0.4rem 0.9rem; margin-right: 0.6rem;
}
.sample-form input[type="file"]::file-selector-button:hover { border-color: var(--navy); color: var(--navy-700); }
.sample-form textarea { resize: vertical; min-height: 4.5rem; }
.sample-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 0.6rem; }
.sample {
  display: grid; grid-template-columns: 1fr auto; gap: 0.35rem 1rem; align-items: center;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 0.85rem 1rem; box-shadow: var(--shadow-1);
}
.sample.is-archived { background: var(--surface-2); }
.sample-title { font-weight: 650; }
.sample-meta { font-size: 0.82rem; color: var(--muted); display: flex; flex-wrap: wrap; gap: 0.3rem 0.8rem; }
.sample-note { grid-column: 1 / -1; font-size: 0.86rem; color: var(--ink-2); }
.sample-files { grid-column: 1 / -1; display: flex; gap: 0.4rem; flex-wrap: wrap; }
.file-tag { font-size: 0.75rem; font-weight: 600; background: var(--tint); color: var(--navy-700); padding: 0.1rem 0.55rem; border-radius: 999px; }
.ok-line { color: var(--ok); font-weight: 600; font-size: 0.9rem; }

/* ---------- A15: header account, login card, link note, account rights, admin accounts ---------- */

.user-name {
  font-size: 0.86rem; font-weight: 600; color: var(--ink-2); max-width: 16rem;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.login-dialog {
  width: min(28rem, calc(100vw - 2rem)); overflow: auto;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  padding: 0; border: 1px solid var(--line); border-radius: var(--r-xl);
  background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3);
}
.login-dialog::backdrop { background: rgba(15, 30, 51, 0.42); backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); }
.login-dialog .form { padding: clamp(1.25rem, 4vw, 1.75rem); gap: 0.85rem; }
.login-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; }
.login-head h2 { font-size: 1.3rem; }
.login-help { font-size: 0.82rem; color: var(--muted); line-height: 1.45; }
.login-dialog .human-check:not(:empty) { height: auto; overflow: visible; justify-content: flex-start; }
.login-dialog .btn-primary { width: 100%; }
/* lead 11:57: the centred login screen and the password card in its place */
.login-card { max-width: 28rem; }
.login-card h1 { font-size: 1.45rem; }
.login-lead { color: var(--ink-2); line-height: 1.5; }
.login-card .form { gap: 0.85rem; }
.login-card .human-check:not(:empty) { height: auto; overflow: visible; justify-content: flex-start; }
.login-card #login-submit { width: 100%; }
.typing-text { font-size: 0.9rem; color: var(--muted); margin-right: 0.45rem; }
.hm-note { font-size: 0.82rem; color: var(--ink-2); margin-top: 0.35rem; }
.link-note {
  background: var(--warn-soft); color: var(--warn); border-radius: var(--r-md);
  padding: 0.65rem 0.95rem; font-size: 0.9rem; font-weight: 550; margin-bottom: 0.9rem;
}
.rights-account { color: var(--ink-2); background: var(--surface-2); border: 1px solid var(--line); }
.acct-subtitle { margin: 1.25rem 0 0.6rem; }
.acct-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; }
.acct-table tr.is-off td { color: var(--muted); }

/* ---------- responsive ---------- */

@media (max-width: 640px) {
  .brand-org { display: none; }
  .brand-app { font-size: 0.95rem; }
  .topbar-row { padding-top: 0.55rem; padding-bottom: 0.55rem; }
  #new-chat-btn span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0, 0, 0, 0); }
  #new-chat-btn { width: 2.4rem; padding: 0; }
  .avatar { width: 28px; height: 28px; border-radius: 9px; }
  .msg { gap: 0.55rem; }
  .dropcard { padding-left: 0; }
  .slots { grid-template-columns: 1fr; }
  .drop-actions .btn { flex: 1; }
  .card { padding: 0.9rem; }
  .file-row { grid-template-columns: auto 1fr; }
  .file-row .btn { grid-column: 1 / -1; width: 100%; }
  .composer-box { padding-left: 0.85rem; border-radius: var(--r-lg); }
  .model-pick select { font-size: 0.8rem; padding-right: 0.3rem; max-width: 9.5rem; }
  .model-pick { padding-left: 0.5rem; }
  .rights-badge { font-size: 0.72rem; padding: 0.25rem 0.5rem; }
  .composer-tools { row-gap: 0.45rem; }
  .dock { gap: 0.5rem; padding-top: 0.9rem; }
  .dock-card { padding: 0.65rem 0.8rem; }
  .dock-row { flex-wrap: nowrap; gap: 0.6rem; }
  .dock-row .btn { min-height: 2.4rem; padding: 0.4rem 0.85rem; font-size: 0.86rem; flex: none; }
  .dock-row .small { font-size: 0.8rem; }
  .busy { border-radius: var(--r-lg); }
  .resume-row { flex-wrap: wrap; }
  .resume-input { flex-basis: 100%; }
  .samples-grid { grid-template-columns: 1fr; }
  .admin-head h1 { font-size: 1.25rem; }
  .user-name { max-width: 7.5rem; font-size: 0.8rem; }
  .topbar-tools { gap: 0.4rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

@media (forced-colors: active) {
  .btn-primary, .send-btn, .msg-user .bubble, .tab[aria-selected="true"] { border: 1px solid ButtonText; }
  .dropzone { border: 2px dashed ButtonText; }
}

/* ---------- A16 shell (v22): sidebar, chat column, composer dock, preview panel, dialogs ----------
   Scoped to .page-chat so the admin page keeps its own layout. Quiet neutral surfaces with the brand navy as the
   one accent; system fonts; no ornament. */

.page-chat {
  --bg: #ffffff;
  --side: #f6f7f9;
  --hover: #e9ecf1;
  --soft: #eef1f5;
  --surface-2: #f7f8fa;
  --line: #e6e8ec;
  --line-2: #d3d7de;
  --tint: #edf3fa;
  --tint-2: #d9e5f3;
  --ink: #1a2230;
  --ink-2: #333d4d;
  --muted: #5d6878;
  --content: 48rem;
  --side-w: 17rem;
  --shadow-1: 0 1px 2px rgba(16, 24, 40, 0.05);
  --shadow-2: 0 1px 2px rgba(16, 24, 40, 0.06), 0 6px 20px rgba(16, 24, 40, 0.06);
  --shadow-3: 0 8px 28px rgba(16, 24, 40, 0.14);
}
body.page-chat { display: block; height: 100vh; height: 100dvh; min-height: 0; overflow: hidden; background: var(--bg); }

.shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); height: 100%; }
/* an open panel takes about 60 per cent of what the sidebar leaves; the chat column keeps at least 24rem */
.has-preview .shell { grid-template-columns: var(--side-w) minmax(24rem, 2fr) minmax(0, 3fr); }
.side-collapsed .shell { grid-template-columns: 0 minmax(0, 1fr); }
.side-collapsed.has-preview .shell { grid-template-columns: 0 minmax(24rem, 2fr) minmax(0, 3fr); }

/* scrollbars: thin and quiet, standard properties only (the sheet viewer styles its own) */
.scroller, .chat-nav, .dialog, .page-chat textarea, .page-chat .view-center { scrollbar-width: thin; scrollbar-color: #c9ced6 transparent; }

/* sidebar */
.sidebar {
  background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column;
  min-width: 0; min-height: 0; overflow: hidden; padding: 0.6rem; gap: 0.3rem;
}
.side-collapsed .sidebar { visibility: hidden; border: 0; padding: 0; }
.side-top { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; padding: 0.15rem 0 0.45rem 0.4rem; }
.page-chat .brand { gap: 0.55rem; }
.page-chat .brand-mark { width: 28px; height: 28px; border-radius: 8px; box-shadow: none; }
.page-chat .brand-app { font-size: 0.98rem; font-weight: 650; white-space: nowrap; }
.side-item, .menu-item {
  display: flex; align-items: center; gap: 0.6rem; width: 100%; min-height: 2.5rem; padding: 0.45rem 0.6rem;
  border: 0; border-radius: 10px; background: transparent; color: var(--ink); font: inherit; font-size: 0.92rem;
  font-weight: 550; text-align: left; text-decoration: none; cursor: pointer;
}
.side-item:hover, .menu-item:hover { background: var(--hover); color: var(--ink); }
.side-item .icon { color: var(--muted); }
.chat-nav { flex: 1; min-height: 0; overflow-y: auto; margin-top: 0.5rem; }
.chat-group + .chat-group { margin-top: 0.9rem; }
.chat-group-title { font-family: var(--font); font-size: 0.74rem; font-weight: 650; color: var(--muted); padding: 0.3rem 0.6rem; letter-spacing: 0; }
.chat-rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 1px; }
.chat-row { position: relative; display: flex; align-items: center; border-radius: 10px; }
.chat-row:hover, .chat-row:focus-within { background: var(--hover); }
.chat-link {
  flex: 1; min-width: 0; display: flex; align-items: center; gap: 0.5rem; min-height: 2.4rem; padding: 0.45rem 0.6rem;
  color: var(--ink); text-decoration: none; font-size: 0.9rem; border-radius: 10px;
}
.chat-link:hover { color: var(--ink); }
.chat-link[aria-current="page"] { background: #e1e5eb; font-weight: 600; }
.chat-row:hover .chat-link, .chat-row:focus-within .chat-link { padding-right: 2.4rem; }
.chat-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-busy { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--azure); flex: none; animation: pulse 1.4s ease-in-out infinite; }
@keyframes pulse { 0%, 100% { opacity: 0.35; } 50% { opacity: 1; } }
.chat-rename {
  position: absolute; right: 0.25rem; width: 1.9rem; height: 1.9rem; border: 0; border-radius: 8px; background: transparent;
  color: var(--muted); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; opacity: 0;
}
.chat-rename .icon { width: 1rem; height: 1rem; }
.chat-rename:hover { background: #d9dee6; color: var(--ink); }
.chat-row:hover .chat-rename, .chat-row:focus-within .chat-rename { opacity: 1; }
@media (hover: none) {
  .chat-rename { opacity: 1; }
  .chat-link { padding-right: 2.4rem; }
}
.chat-row.is-editing { background: transparent; }
.page-chat .chat-rename-input { width: 100%; min-height: 2.4rem; padding: 0.35rem 0.55rem; font-size: 0.9rem; border-radius: 10px; }
.side-status { font-size: 0.8rem; color: var(--warn); padding: 0.4rem 0.6rem; }
.side-foot { border-top: 1px solid var(--line); padding-top: 0.45rem; display: flex; flex-direction: column; gap: 0.15rem; }
.account { position: relative; }
.account-initial {
  width: 1.75rem; height: 1.75rem; border-radius: 50%; background: var(--navy); color: #fff; font-size: 0.8rem;
  font-weight: 650; display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.page-chat .user-name { flex: 1; min-width: 0; max-width: none; font-size: 0.9rem; color: var(--ink); }
.account-caret { color: var(--muted); }
.menu {
  position: absolute; left: 0; right: 0; bottom: calc(100% + 0.35rem); z-index: 5; display: flex; flex-direction: column;
  background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow-3); padding: 0.3rem;
}
.menu-note {
  font-size: 0.78rem; color: var(--muted); padding: 0.45rem 0.6rem 0.55rem; margin-bottom: 0.25rem;
  border-bottom: 1px solid var(--line); font-variant-numeric: tabular-nums;
}
.menu-note.is-low { color: var(--warn); }
.menu-note-item { white-space: nowrap; }

/* stage: top bar and the chat column */
.stage { display: flex; flex-direction: column; min-width: 0; min-height: 0; height: 100%; }
.stage-bar { display: flex; align-items: center; gap: 0.3rem; min-height: 3.25rem; padding: 0.4rem 0.75rem; flex: none; }
#sidebar-open-btn, #top-new-btn { display: none; }
.side-collapsed #sidebar-open-btn, .side-collapsed #top-new-btn { display: inline-flex; }
.stage-title {
  flex: 1; min-width: 0; font-size: 0.98rem; font-weight: 600; overflow: hidden; text-overflow: ellipsis;
  white-space: nowrap; padding-left: 0.35rem;
}
.stage-title.is-new { color: transparent; user-select: none; }
.page-chat .icon-btn { border-radius: 10px; }
.page-chat .icon-btn:hover:not(:disabled) { background: var(--hover); color: var(--ink); }
.page-chat .main { max-width: none; margin: 0; padding: 0; min-height: 0; }
.page-chat .view { min-height: 0; }
.page-chat .view-center { padding: 2rem 1rem 4rem; overflow-y: auto; }
.page-chat .notice-card { border-radius: 18px; box-shadow: var(--shadow-2); }
.page-chat .chat { min-height: 0; }
.scroller { flex: 1; min-height: 0; overflow-y: auto; }
.page-chat .thread {
  max-width: var(--content); margin: 0 auto; padding: 0.5rem 1.25rem 1.5rem; min-height: 100%; gap: 1.25rem; flex: none;
}
.chat.is-empty .thread { justify-content: center; padding-bottom: 2.5rem; }
.empty-state { display: flex; flex-direction: column; gap: 1.35rem; }
.chat:not(.is-empty) .empty-state { display: none; }
.welcome { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; text-align: center; }
.welcome-mark { width: 44px; height: 44px; border-radius: 12px; margin-bottom: 0.5rem; }
.page-chat .welcome-lead { font-size: clamp(1.3rem, 2.6vw, 1.65rem); font-weight: 650; letter-spacing: -0.015em; }
.welcome-sub { color: var(--muted); }
.card-slot:empty, .chips-slot:empty { display: none; }
.chat.is-empty .chips { justify-content: center; flex-wrap: wrap; overflow: visible; -webkit-mask-image: none; mask-image: none; }

/* drop card: calm in the empty state, compact next to the composer */
.page-chat .dropcard { padding-left: 0; animation: none; }
.page-chat .dropzone {
  border: 1px solid var(--line-2); background: var(--surface); box-shadow: var(--shadow-1); border-radius: 18px;
  padding: 1.1rem 1.15rem; gap: 0.9rem;
}
.page-chat .dropzone::before { display: none; }
.page-chat .dropzone.is-over { transform: none; border-color: var(--navy); box-shadow: 0 0 0 4px rgba(0, 84, 160, 0.12); }
.page-chat .dropzone.is-attention { animation: nudge-calm 0.8s var(--ease) 2; }
@keyframes nudge-calm { 0%, 100% { box-shadow: var(--shadow-1); } 50% { box-shadow: 0 0 0 5px rgba(0, 84, 160, 0.18); } }
.page-chat .drop-icon { width: 2.25rem; height: 2.25rem; border-radius: 10px; background: var(--tint); color: var(--navy); box-shadow: none; }
.page-chat .drop-icon svg { width: 1.2rem; height: 1.2rem; }
.page-chat .drop-title { font-size: 1.05rem; }
.page-chat .slot-pick { min-height: 4rem; border-radius: 12px; }
.dropcard.is-compact .drop-head { display: none; }
.dropcard.is-compact .dropzone { padding: 0.7rem; gap: 0.6rem; border-radius: 16px; }
.dropcard.is-compact .slot-pick { min-height: 3.2rem; padding-top: 0.5rem; padding-bottom: 0.5rem; }

/* messages */
.page-chat .timeline { gap: 1.35rem; }
.page-chat .msg { gap: 0; }
.page-chat .bubble { border: 0; box-shadow: none; background: transparent; padding: 0; max-width: none; width: auto; border-radius: 0; }
.page-chat .msg-user .bubble { background: var(--soft); color: var(--ink); border-radius: 18px; padding: 0.65rem 1rem; box-shadow: none; }
.page-chat .msg-user .msg-body { max-width: min(34rem, 85%); }
.page-chat .ev-text, .md { line-height: 1.65; }
.msg-foot { display: flex; align-items: center; gap: 0.45rem; min-height: 1.75rem; }
.msg-user .msg-foot { justify-content: flex-end; }
.msg-action {
  width: 1.9rem; height: 1.9rem; border: 0; border-radius: 8px; background: transparent; color: var(--muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; margin-left: -0.35rem;
}
.msg-action .icon { width: 1rem; height: 1rem; }
.msg-action:hover { background: var(--soft); color: var(--ink); }
.msg-action.is-done { color: var(--ok); }
.msg-action-note { font-size: 0.78rem; color: var(--muted); }
.msg-action-note:empty { display: none; }
.md { display: flex; flex-direction: column; gap: 0.6rem; }
.md-h { font-family: var(--font-display); font-weight: 650; }
.md-h1 { font-size: 1.15rem; }
.md-h2 { font-size: 1.08rem; }
.md-h3 { font-size: 1rem; }
.md-list { margin: 0; padding-left: 1.35rem; display: flex; flex-direction: column; gap: 0.25rem; }
.md-code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; font-size: 0.9em; background: var(--soft); border-radius: 5px; padding: 0.08em 0.35em; }
.page-chat .sysline p { background: transparent; border: 0; padding: 0; font-size: 0.8rem; }
.page-chat .card { box-shadow: none; border-radius: 14px; max-width: none; }
.page-chat .file-row { grid-template-columns: auto minmax(0, 1fr) auto; }
.file-actions { display: flex; gap: 0.4rem; flex-wrap: wrap; justify-content: flex-end; }
.page-chat .btn-primary { background: var(--navy); box-shadow: none; }
.page-chat .btn-primary:hover:not(:disabled) { background: var(--navy-700); box-shadow: none; }
.page-chat .btn-primary:disabled { background: #a9b6c6; }
.page-chat .link-note { margin-bottom: 0; }
.link-note-ok { background: var(--tint); color: var(--navy-700); }

/* dock: panels, busy strip, the two-file card, chips, composer */
.page-chat .dock { position: static; background: none; padding: 0 1.25rem calc(0.55rem + env(safe-area-inset-bottom)); flex: none; }
.dock-inner { width: 100%; max-width: var(--content); margin: 0 auto; display: flex; flex-direction: column; gap: 0.55rem; }
.page-chat .dock-card, .page-chat .busy { box-shadow: none; border-radius: 14px; }
.page-chat .chips { padding: 0; }
.page-chat .chip, .page-chat .chip:first-child { background: var(--surface); border-color: var(--line-2); color: var(--ink-2); }
.page-chat .chip:hover { border-color: var(--navy); color: var(--navy-700); }
.page-chat .composer-box {
  border-radius: 22px; border-color: var(--line-2); padding: 0.6rem 0.6rem 0.5rem 0.9rem;
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.05), 0 4px 16px rgba(16, 24, 40, 0.06);
}
.page-chat .composer-box:focus-within { border-color: #9db4cf; box-shadow: 0 0 0 3px rgba(0, 84, 160, 0.1), 0 4px 16px rgba(16, 24, 40, 0.06); }
.page-chat .composer-tools { margin-top: 0.2rem; margin-left: -0.45rem; }
.page-chat .model-pick { border: 0; background: transparent; padding: 0; }
.page-chat .model-pick select { border-radius: 10px; padding: 0.2rem 0.5rem; }
.page-chat .model-pick select:hover { background: var(--soft); }
.page-chat .model-pick select:focus-visible { outline: 3px solid rgba(0, 84, 160, 0.35); }
.page-chat .send-btn { width: 2.35rem; height: 2.35rem; background: #c5ccd6; }
.page-chat .send-btn.is-ready { background: var(--navy); box-shadow: none; }
.page-chat .send-btn.is-ready:hover { background: var(--navy-700); transform: none; }
.page-chat .hm-note { text-align: center; color: var(--muted); font-size: 0.8rem; margin-top: 0; padding: 0 0.5rem; }
.dock-foot { text-align: center; font-size: 0.75rem; color: var(--muted); }
.dock-foot a { color: var(--muted); font-weight: 600; }
.dock-foot a:hover { color: var(--navy); }

/* preview panel */
.preview-panel {
  border-left: 1px solid var(--line); background: var(--surface); min-width: 0; min-height: 0; height: 100%;
  display: flex; flex-direction: column; overflow: hidden;
}
.preview-host { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.preview-state { display: flex; flex-direction: column; gap: 0.75rem; padding: 0.6rem 0.75rem; }
.preview-head { display: flex; align-items: center; gap: 0.5rem; }
.preview-name { flex: 1; min-width: 0; font-size: 0.95rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.preview-text { color: var(--muted); padding: 2.5rem 0.5rem 0.5rem; text-align: center; }
.preview-state .form-error { text-align: center; }
.preview-state .form-error:empty { display: none; }
.scrim { position: fixed; inset: 0; background: rgba(16, 24, 40, 0.35); z-index: 30; }
#preview-scrim { display: none; }

/* dialogs */
.dialog {
  width: min(27rem, calc(100vw - 2rem)); overflow: auto; padding: 0;
  max-height: calc(100vh - 2rem);
  max-height: calc(100dvh - 2rem);
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-3);
}
.dialog::backdrop { background: rgba(16, 24, 40, 0.4); }
/* a browser without showModal (Safari before 15.4) knows no dialog element: closed it must not show, open it is
   a fixed, centred box above a dimmed layer (dom.js, ensureModal) */
.dialog:not([open]) { display: none; }
.dialog.dialog-fallback {
  display: block; position: fixed; top: 50%; left: 50%; transform: translate(-50%, -50%); margin: 0; z-index: 60;
}
.dialog-dim { position: fixed; top: 0; right: 0; bottom: 0; left: 0; z-index: 59; background: rgba(16, 24, 40, 0.4); }
.dialog-form { padding: 1.3rem 1.4rem 1.4rem; gap: 0.85rem; }
.dialog-head { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; min-height: 2.4rem; }
.dialog-head h2 { font-size: 1.2rem; }
.dialog-lead { color: var(--ink-2); font-size: 0.92rem; }
.dialog .human-check:not(:empty) { height: auto; overflow: visible; justify-content: flex-start; }
.dialog #login-submit { width: 100%; }

@media (max-width: 1099px) {
  .has-preview .shell { grid-template-columns: var(--side-w) minmax(0, 1fr); }
  .side-collapsed.has-preview .shell { grid-template-columns: 0 minmax(0, 1fr); }
  .preview-panel { position: fixed; top: 0; right: 0; bottom: 0; width: min(100vw, 46rem); z-index: 40; box-shadow: var(--shadow-3); }
  #preview-scrim:not([hidden]) { display: block; }
}

@media (max-width: 899px) {
  .shell, .has-preview .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; width: min(19rem, 86vw); z-index: 35; box-shadow: var(--shadow-3);
    transform: translateX(-100%); visibility: hidden; transition: transform 0.2s var(--ease), visibility 0s linear 0.2s;
  }
  .side-drawer-open .sidebar { transform: none; visibility: visible; transition: transform 0.2s var(--ease), visibility 0s; }
  /* the v21c phone rule shrank this button to an icon in the old top bar; in the drawer it keeps its label */
  .page-chat #new-chat-btn { width: 100%; padding: 0.45rem 0.6rem; }
  .page-chat #new-chat-btn span { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
  #sidebar-open-btn, #top-new-btn { display: inline-flex; }
  #sidebar-close-btn { display: none; }
  .stage-bar { padding: 0.3rem 0.5rem; }
}

@media (max-width: 640px) {
  .page-chat .thread { padding: 0.25rem 0.9rem 1.25rem; }
  .page-chat .dock { padding: 0 0.75rem calc(0.45rem + env(safe-area-inset-bottom)); }
  .page-chat .composer-box { border-radius: 20px; padding-left: 0.8rem; }
  .page-chat .file-row { grid-template-columns: auto minmax(0, 1fr); }
  .file-actions { grid-column: 1 / -1; }
  .file-actions .btn { flex: 1; }
  .page-chat .file-row .btn { grid-column: auto; width: auto; }
  #rules-sentence, .dock-foot-sep { display: none; }
  .page-chat .welcome-lead { font-size: 1.25rem; }
}

@media (forced-colors: active) {
  .chat-link[aria-current="page"] { border: 1px solid Highlight; }
  .page-chat .msg-user .bubble, .composer-box, .dialog, .menu { border: 1px solid ButtonText; }
}

.page-chat ul.md-list { list-style: disc; }
