:root {
  color-scheme: light;
  --bg: #f3f5f8;
  --surface: #ffffff;
  --surface-soft: #f8fafc;
  --ink: #111827;
  --muted: #667085;
  --line: #d9e0ea;
  --primary: #2563eb;
  --primary-dark: #1d4ed8;
  --danger: #dc2626;
  --success: #16a34a;
  --shadow: 0 24px 80px rgba(15, 23, 42, .08);
}

* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(37, 99, 235, .12), transparent 34rem),
    linear-gradient(135deg, #f8fafc 0%, #eef2f7 100%);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }

.app-shell { display: grid; grid-template-columns: 280px 1fr; min-height: 100vh; }
.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 24px;
  background: rgba(255,255,255,.78);
  border-right: 1px solid var(--line);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 28px;
}
.brand { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 44px; height: 44px; border-radius: 14px;
  display: grid; place-items: center;
  color: white; background: linear-gradient(135deg, var(--primary), #7c3aed);
  font-weight: 800;
}
.brand span, small { display: block; color: var(--muted); }
nav { display: grid; gap: 8px; }
nav a {
  color: var(--muted); text-decoration: none; padding: 12px 14px; border-radius: 12px; font-weight: 700;
}
nav a.active, nav a:hover { background: #eff6ff; color: var(--primary); }
.session-card {
  margin-top: auto; padding: 14px; border: 1px solid var(--line); border-radius: 18px;
  background: var(--surface); display: flex; gap: 10px; align-items: center;
}
.status-dot { width: 10px; height: 10px; border-radius: 999px; background: #cbd5e1; flex: none; }
.status-dot.live { background: var(--success); box-shadow: 0 0 0 5px rgba(22,163,74,.12); }

.main { padding: 34px; }
.login-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) 420px; align-items: center; gap: 42px; min-height: calc(100vh - 68px); }
.login-copy h1, .topbar h1 { font-size: clamp(38px, 5vw, 72px); line-height: .96; margin: 0; letter-spacing: -.05em; }
.login-copy p { font-size: 18px; max-width: 620px; color: var(--muted); }
.eyebrow { margin: 0 0 8px; color: var(--primary); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; font-size: 12px; }

.panel, .metric {
  background: rgba(255,255,255,.92);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.panel { padding: 24px; margin-bottom: 22px; }
.login-card { padding: 30px; }
h2 { margin: 0 0 14px; font-size: 24px; letter-spacing: -.02em; }
h3 { margin: 0 0 8px; }
p { color: var(--muted); }
label { display: grid; gap: 8px; margin: 14px 0; color: #344054; font-weight: 700; }
input, select, textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px;
  background: #fff; color: var(--ink); outline: none;
}
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--primary); box-shadow: 0 0 0 4px rgba(37,99,235,.12); }

button {
  border: 0; border-radius: 999px; padding: 12px 17px; font-weight: 800;
  background: #e7eef9; color: #1f3b70;
}
button:hover { filter: brightness(.98); }
button.primary, .primary { background: var(--primary); color: white; }
button.primary:hover { background: var(--primary-dark); }
button.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
button.danger, .danger { color: var(--danger); }
button.small { padding: 8px 12px; font-size: 13px; }
.icon-button { width: 36px; height: 36px; padding: 0; display: grid; place-items: center; }
.actions, .topbar-actions, .draft-actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.topbar { display: flex; justify-content: space-between; gap: 24px; align-items: start; margin-bottom: 24px; }
.metrics { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.metric { padding: 18px; }
.metric span { color: var(--muted); font-weight: 700; }
.metric strong { display: block; font-size: 28px; margin: 7px 0 2px; }
.grid { display: grid; gap: 22px; }
.two { grid-template-columns: minmax(0, .8fr) minmax(0, 1.2fr); }
.section-head { display: flex; justify-content: space-between; gap: 20px; align-items: start; margin-bottom: 18px; }
.section-head p { margin: 4px 0 0; }

.example-stack { display: grid; gap: 12px; margin: 18px 0; }
.example-block { border: 1px solid var(--line); background: var(--surface-soft); border-radius: 18px; padding: 14px; }
.example-block-head { display: flex; justify-content: space-between; gap: 12px; margin-bottom: 10px; }
.example-block-head select { max-width: 180px; }
.list { display: grid; gap: 10px; margin-top: 18px; }
.compact-item { border: 1px solid var(--line); border-radius: 16px; padding: 14px; background: var(--surface-soft); }
.compact-item div { display: flex; justify-content: space-between; gap: 12px; color: var(--muted); }
.compact-item p { margin: 8px 0 0; color: var(--ink); }

.voice-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 16px; }
.summary-card { padding: 14px; background: var(--surface-soft); border: 1px solid var(--line); border-radius: 16px; }
.summary-card span { color: var(--muted); font-size: 12px; font-weight: 800; text-transform: uppercase; }
.summary-card strong { display: block; margin-top: 6px; }
.chip-section { margin-top: 16px; }
.chip-section h3 { font-size: 14px; color: #344054; }
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.chip, .platform-pill {
  display: inline-flex; align-items: center; border-radius: 999px; padding: 6px 10px;
  background: #eef4ff; color: #1d4ed8; font-size: 13px; font-weight: 800;
}
.chip.danger { background: #fef2f2; color: var(--danger); }
.readable-empty { color: var(--muted); background: var(--surface-soft); border: 1px dashed var(--line); border-radius: 16px; padding: 18px; }

.draft-list { display: grid; gap: 16px; }
.draft-card { border: 1px solid var(--line); border-radius: 20px; padding: 18px; background: #fff; }
.draft-head { display: flex; justify-content: space-between; gap: 18px; align-items: start; margin-bottom: 14px; }
.draft-body { white-space: pre-wrap; line-height: 1.65; color: #182230; background: var(--surface-soft); border-radius: 16px; padding: 16px; }
details { margin-top: 12px; color: var(--muted); }
.hint, .message { font-size: 13px; color: var(--muted); }
.message { min-height: 20px; color: var(--danger); }
.toast {
  position: fixed; right: 26px; bottom: 26px; z-index: 10;
  background: #111827; color: white; padding: 14px 18px; border-radius: 16px; box-shadow: var(--shadow);
}
.toast.error { background: var(--danger); }

@media (max-width: 1050px) {
  .app-shell { grid-template-columns: 1fr; }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; overflow-x: auto; }
  nav { display: flex; }
  .session-card { margin-left: auto; margin-top: 0; min-width: 260px; }
  .login-layout, .two { grid-template-columns: 1fr; }
  .metrics { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 650px) {
  .main { padding: 18px; }
  .sidebar { padding: 16px; flex-wrap: wrap; }
  .metrics, .voice-grid { grid-template-columns: 1fr; }
  .topbar, .section-head, .draft-head { flex-direction: column; }
}

.lead { max-width: 720px; margin: 10px 0 0; font-size: 17px; }
.help-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.help-card, .coach-note, .subpanel {
  background: rgba(255,255,255,.86);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  box-shadow: 0 12px 40px rgba(15, 23, 42, .05);
}
.help-card h3 { margin-bottom: 8px; }
.help-card p { margin: 0; line-height: 1.55; }
.coach-note { margin: 12px 0 18px; color: #344054; background: #eff6ff; border-color: #bfdbfe; }
.section-head.compact { margin-bottom: 10px; }
.compact-item a { color: var(--primary); font-weight: 800; }
.admin-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; align-items: start; }
.admin-grid fieldset { grid-column: 1 / -1; border: 1px solid var(--line); border-radius: 18px; padding: 16px; background: var(--surface-soft); }
.admin-grid legend { font-weight: 800; color: #344054; padding: 0 8px; }
.check { display: flex; grid-template-columns: auto 1fr; align-items: center; gap: 10px; margin: 10px 0; font-weight: 700; }
.check input { width: auto; }
.admin-split { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 18px; margin-top: 20px; }
.subpanel { box-shadow: none; background: var(--surface-soft); }
@media (max-width: 1050px) {
  .help-grid, .admin-grid, .admin-split { grid-template-columns: 1fr; }
}

.metrics.embedded { margin: 0 0 14px; box-shadow: none; }
.usage-grid { display: grid; gap: 14px; }
.usage-table { display: grid; gap: 10px; }
.admin-mode > :not(#admin):not(#toast) { display: none !important; }
.admin-mode #admin { display: block !important; }
.help-bot { position: fixed; right: 22px; bottom: 22px; z-index: 30; }
.help-bot-button {
  width: 54px; height: 54px; border-radius: 999px; background: var(--primary); color: white;
  font-size: 24px; box-shadow: var(--shadow);
}
.help-bot-panel {
  width: min(360px, calc(100vw - 32px)); max-height: 70vh; overflow: auto;
  background: white; border: 1px solid var(--line); border-radius: 22px; padding: 16px; box-shadow: var(--shadow);
  margin-bottom: 12px;
}
.help-bot.collapsed .help-bot-panel { display: none; }
.help-bot-messages { display: grid; gap: 8px; max-height: 320px; overflow: auto; }
.help-bot-messages p { margin: 0; background: var(--surface-soft); border-radius: 14px; padding: 10px; }
#helpBotForm { display: grid; grid-template-columns: 1fr auto; gap: 8px; margin-top: 12px; }
@media (max-width: 650px) {
  .help-bot { right: 12px; bottom: 12px; }
  .help-bot-button { width: 48px; height: 48px; }
  #helpBotForm { grid-template-columns: 1fr; }
}
