/* VoiceTutor app and operator pages. Same tokens and building blocks as the
   website (website/assets/site.css), i.e. the design system of BYOD-Bot and
   EdPilot. Admin surfaces are flat: borders instead of shadows (EdPilot DESIGN). */

@font-face {
  font-family: "Outfit";
  src: url("fonts/Outfit-Variable.98ccc2b7f189.woff2") format("woff2");
  font-weight: 100 900;
  font-display: swap;
}

:root {
  --background: #f5f5f0;
  --foreground: #0c1330;
  --card: #ffffff;
  --primary: #2443d6;
  --primary-foreground: #ffffff;
  --fill: #0c13300f;
  --fill-hover: #0c13301a;
  --muted: #ecece6;
  --muted-foreground: #4f566b;
  --subtle: #61677a; /* 4.5:1 also on --tinte-soft (TD-82); was #646a7d */
  --border: #0c13301a;
  --line-strong: #868c9e;
  --ring: #2443d6;
  --tinte-soft: #e5e9fd;
  --marker: #ffe14a;
  --marker-soft: #fff5c4;
  --on-marker: #0c1330;
  --destructive: #c42d1f;
  --destructive-soft: #fde7e3;
  --ok: #157a45;
  --ok-soft: #dcf2e4;
  --warn: #8a5700;
  --warn-soft: #fdf0cc;
  --nacht: #0b1640;
  --font-sans: "Outfit", ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  --font-mono: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  color-scheme: light;
}

*, *::before, *::after { box-sizing: border-box; }
body {
  margin: 0;
  background: var(--background);
  color: var(--foreground);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1, h2, h3 { margin: 0; text-wrap: balance; }
p { margin: 0; }
a { color: var(--primary); }
:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; border-radius: 6px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
/* skip link (as on the website): first stop of the keyboard, visible only when focused */
.skip-link { position: absolute; left: 1rem; top: -100px; z-index: 100; padding: 0.75rem 1rem; border-radius: 999px; background: var(--primary); color: var(--primary-foreground); font-weight: 600; text-decoration: none; }
.skip-link:focus { top: 1rem; }
/* the skip link's target takes focus (tabindex="-1") without a frame around the whole page */
main[tabindex="-1"]:focus { outline: none; }
/* Reduced motion: no animation or transition anywhere; state is always shown by text too. */
@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; }
  .btn:active { transform: none !important; }
}

/* logo */
.logo { display: inline-flex; align-items: center; gap: 8px; font-weight: 700; font-size: 19px; letter-spacing: -0.02em; color: var(--foreground); text-decoration: none; }
.logo img { width: 26px; height: 26px; }
.logo .tag { margin-left: 4px; }

/* buttons */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; height: 44px; padding: 0 20px; border-radius: 999px; border: 1px solid transparent; font: inherit; font-size: 15px; font-weight: 600; letter-spacing: -0.005em; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:active { transform: scale(0.98); }
.btn:disabled { opacity: 0.6; cursor: progress; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: color-mix(in srgb, var(--primary) 90%, white); }
.btn-outline { background: var(--card); color: var(--foreground); border-color: var(--border); }
.btn-outline:hover { border-color: var(--line-strong); background: var(--fill); }
.btn-ghost { background: transparent; color: var(--muted-foreground); }
.btn-ghost:hover { background: var(--fill); color: var(--foreground); }
.btn-danger { background: var(--card); color: var(--destructive); border-color: var(--border); }
.btn-danger:hover { background: var(--destructive-soft); }
.btn-sm { height: 36px; padding: 0 14px; font-size: 14px; }
.btn-block { width: 100%; }

/* badges */
.badge { display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 10px; border-radius: 999px; font-size: 12.5px; font-weight: 600; background: var(--tinte-soft); color: var(--primary); }
.badge-ok { background: var(--ok-soft); color: var(--ok); }
.badge-warn { background: var(--warn-soft); color: var(--warn); }
.badge-danger { background: var(--destructive-soft); color: var(--destructive); }
.badge-muted { background: var(--fill); color: var(--muted-foreground); }

/* forms */
.field { display: grid; gap: 6px; }
.field + .field { margin-top: 16px; }
.field label { font-size: 15px; font-weight: 600; }
.field .hint { font-size: 13.5px; color: var(--subtle); }
.input { height: 44px; width: 100%; padding: 0 14px; border-radius: 0.75rem; border: 1px solid var(--line-strong); background: var(--card); color: var(--foreground); font: inherit; }
textarea.input { height: auto; min-height: 96px; padding: 10px 14px; resize: vertical; }
.check-row { display: flex; gap: 10px; align-items: flex-start; margin-top: 16px; font-size: 15px; color: var(--muted-foreground); }
.check-row input { width: 18px; height: 18px; margin-top: 3px; accent-color: var(--primary); }
.form-actions { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-top: 24px; }

/* notices (EdPilot "Outcome": inline, no toasts) */
.notice { padding: 12px 16px; border-radius: 0.875rem; font-size: 15px; }
.notice ul { margin: 6px 0 0; padding-left: 1.1rem; }
.notice-ok { background: var(--ok-soft); color: var(--ok); }
.notice-error { background: var(--destructive-soft); color: var(--destructive); }
.notices { display: grid; gap: 10px; margin-bottom: 20px; }

/* auth layout */
.auth { min-height: 100vh; display: grid; place-items: center; padding: 40px 20px; }
.auth-card { width: 100%; max-width: 440px; background: var(--card); border: 1px solid var(--border); border-radius: 1.25rem; padding: 32px 28px; }
.auth-card .logo { margin-bottom: 24px; }
.auth-card h1 { font-size: 28px; line-height: 1.15; letter-spacing: -0.025em; }
.auth-card .lead { margin-top: 8px; color: var(--muted-foreground); }
.auth-card form { margin-top: 24px; }
.auth-links { margin-top: 20px; display: flex; flex-wrap: wrap; justify-content: space-between; gap: 8px; font-size: 14.5px; }
.auth-links a { text-decoration: none; }
.auth-links a:hover { text-decoration: underline; }
.auth-foot { margin-top: 20px; font-size: 13.5px; color: var(--subtle); text-align: center; }
.auth-foot a { color: inherit; }

/* app shell */
.shell { min-height: 100vh; display: grid; grid-template-columns: 1fr; }
.sidebar { display: flex; flex-direction: column; gap: 24px; padding: 20px; border-bottom: 1px solid var(--border); background: var(--background); }
.sidebar nav { display: flex; flex-wrap: wrap; gap: 4px; }
.sidebar nav a { display: flex; align-items: center; gap: 10px; min-height: 40px; padding: 0 12px; border-radius: 0.75rem; font-size: 15px; font-weight: 600; color: var(--muted-foreground); text-decoration: none; }
.sidebar nav a:hover { background: var(--fill); color: var(--foreground); }
.sidebar nav a[aria-current="page"] { background: var(--tinte-soft); color: var(--primary); }
.sidebar nav svg { width: 18px; height: 18px; }
/* Menu groups with a title (decision 85): «Unterricht», «Verwaltung», then the rest. */
.sidebar nav ul { display: flex; flex-wrap: wrap; gap: 4px; margin: 0; padding: 0; list-style: none; }
.sidebar .nav-title { display: block; padding: 0 12px 6px; font-size: 12px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; color: var(--subtle); }
.sidebar .who { font-size: 14px; color: var(--subtle); }
.sidebar .who strong { display: block; color: var(--foreground); font-weight: 600; }
.sidebar form { margin: 0; }
.main { padding: 24px 20px 64px; min-width: 0; }
@media (min-width: 900px) {
  .shell { grid-template-columns: 260px 1fr; }
  .sidebar { position: sticky; top: 0; height: 100vh; border-bottom: 0; border-right: 1px solid var(--border); padding: 24px 16px; }
  .sidebar nav, .sidebar nav ul { flex-direction: column; flex-wrap: nowrap; }
  .sidebar .nav-group + .nav-group { margin-top: 16px; }
  .sidebar .spacer { flex: 1; }
  .main { padding: 40px 48px 80px; }
}
.page { max-width: 1200px; }
.page-header { display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 28px; }
.page-header h1 { font-size: clamp(1.75rem, 3vw, 2.25rem); line-height: 1.1; letter-spacing: -0.03em; font-weight: 700; }
.page-header p { margin-top: 6px; color: var(--muted-foreground); }

/* sections: flat, as in EdPilot admin */
.section { background: var(--card); border: 1px solid var(--border); border-radius: 1.25rem; padding: 20px; }
.section + .section { margin-top: 20px; }
@media (min-width: 640px) { .section { padding: 24px; } }
.section h2 { font-size: 19px; font-weight: 600; letter-spacing: -0.015em; }
.section .section-lead { margin-top: 4px; color: var(--muted-foreground); font-size: 15px; }
.section-body { margin-top: 16px; }
.empty { padding: 24px; border: 1px dashed var(--line-strong); border-radius: 1rem; color: var(--muted-foreground); text-align: center; }
.cards { display: grid; gap: 16px; }
@media (min-width: 700px) { .cards { grid-template-columns: repeat(3, 1fr); } }
.stat { background: var(--card); border: 1px solid var(--border); border-radius: 1.25rem; padding: 20px; }
.stat .label { font-size: 14px; color: var(--subtle); }
.stat .value { margin-top: 4px; font-size: 32px; font-weight: 700; letter-spacing: -0.03em; font-variant-numeric: tabular-nums; }

/* tables */
.table { width: 100%; border-collapse: collapse; font-size: 15px; }
.table th { text-align: left; font-size: 13px; font-weight: 600; color: var(--subtle); padding: 8px 10px; border-bottom: 1px solid var(--border); }
.table td { padding: 12px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.table tr:last-child td { border-bottom: 0; }
.table .actions { text-align: right; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.inline-form { display: inline; }
.muted { color: var(--muted-foreground); }
.mono { font-family: var(--font-mono); font-size: 13.5px; }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.row .field { flex: 1; min-width: 220px; }
.row .field + .field { margin-top: 0; }
.mt-3 { margin-top: 12px; }
.mt-4 { margin-top: 16px; }
.mb-5 { margin-bottom: 20px; }
.choice { border: 0; padding: 0; margin: 0 0 20px; display: grid; gap: 10px; }
.choice legend { font-size: 15px; font-weight: 600; margin-bottom: 8px; }
.choice-option { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border: 1px solid var(--border); border-radius: 0.875rem; cursor: pointer; }
.choice-option:has(input:checked) { border-color: var(--primary); background: var(--tinte-soft); }
.choice-option input { margin-top: 4px; accent-color: var(--primary); }
.choice-option strong { display: block; font-size: 15px; }
.choice-option small { color: var(--muted-foreground); font-size: 14px; }
.grid-2 { display: grid; gap: 16px; }
@media (min-width: 700px) { .grid-2 { grid-template-columns: 1fr 1fr; } }
.grid-2 .field + .field { margin-top: 0; }
.section-body .grid-2 + .field, .section-body .field + .grid-2 { margin-top: 16px; }
.section-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; }
.section-tools { display: flex; gap: 6px; }
select.input { appearance: auto; }
.input-file { height: auto; padding: 10px 14px; }
.editor-bar { position: sticky; bottom: 0; z-index: 5; display: flex; flex-wrap: wrap; gap: 10px; align-items: center; margin-top: 20px; padding: 14px 16px; background: color-mix(in srgb, var(--background) 92%, transparent); backdrop-filter: blur(12px); border: 1px solid var(--border); border-radius: 1rem; }
.editor-bar .spacer { flex: 1; }
.mt-5 { margin-top: 24px; }
.notice-warn { background: var(--warn-soft); color: var(--warn); }
.spinner { display: inline-block; width: 18px; height: 18px; border: 2px solid var(--tinte-soft); border-top-color: var(--primary); border-radius: 50%; animation: spin 0.9s linear infinite; vertical-align: -3px; margin-right: 8px; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation: none; } }

/* Operator dashboard (US-21): numbers, hints, sub-headings in panels */
.stat .hint { margin-top: 4px; font-size: 13.5px; color: var(--subtle); }
.table .num { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; }
.panel-subtitle { margin: 20px 0 8px; font-size: 15px; font-weight: 600; }
.text-danger { color: var(--destructive); }
/* assessment editor: questions with model answers (US-26), context text (US-25) */
.question-list { display: grid; gap: 12px; margin-top: 8px; }
.question { border: 1px solid var(--border); border-radius: 1rem; padding: 14px 16px; background: var(--background); }
.question .field + .field, .question .grid-2 + .field { margin-top: 12px; }
.question-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; font-size: 14px; font-weight: 600; color: var(--subtle); }
.subhead { margin-top: 20px; font-size: 16px; font-weight: 600; }
.markdown-view { white-space: pre-wrap; overflow-wrap: anywhere; max-height: 70vh; overflow: auto; padding: 16px; border: 1px solid var(--border); border-radius: 1rem; background: var(--background); font-family: var(--font-mono); font-size: 13.5px; line-height: 1.5; }
/* learner page and transcripts (US-16) */
.practice { max-width: 760px; margin: 0 auto; padding: 24px 16px 40px; }
.practice-head { margin-bottom: 20px; }
.practice h1 { font-size: 28px; line-height: 1.15; letter-spacing: -0.025em; }
.practice .lead { margin-top: 8px; color: var(--muted-foreground); }
.practice ul.section-body { padding-left: 20px; display: grid; gap: 6px; }
.practice .auth-foot { margin-top: 24px; text-align: center; }
.talk-state { font-weight: 600; margin-bottom: 14px; }
.talk .hint { margin-top: 12px; font-size: 13.5px; color: var(--subtle); }
/* live state and captions during the conversation (US-36); --level comes from practice_live.js */
.talk-live { --orb: var(--line-strong); --orb-ring: var(--muted); display: flex; align-items: center; gap: 16px; margin-bottom: 16px; padding: 12px 16px; border: 1px solid var(--border); border-radius: 1rem; background: var(--card); }
.talk-live[hidden], .talk-captions-box[hidden] { display: none; }
/* Waiting queue (US-49, ADR 0019): a calm box; when called it turns to the marker colour. */
.talk-queue { margin-bottom: 16px; padding: 14px 16px; border: 1px solid var(--border); border-radius: 1rem; background: var(--card); }
.talk-queue[hidden] { display: none; }
.talk-queue-state { font-weight: 600; }
.talk-queue .row { margin-top: 12px; }
.talk-queue-called { background: var(--marker-soft); border-color: var(--marker); color: var(--on-marker); }
.talk .btn[hidden] { display: none; }
.talk-live[data-live="agent_speaking"] { --orb: var(--primary); --orb-ring: var(--tinte-soft); }
.talk-live[data-live="listening"], .talk-live[data-live="learner_speaking"] { --orb: var(--ok); --orb-ring: var(--ok-soft); }
.talk-live[data-live="thinking"] { --orb: var(--warn); --orb-ring: var(--warn-soft); }
.talk-live[data-live="ended"] { --orb: var(--subtle); --orb-ring: var(--muted); }
.talk-orb { --level: 0; position: relative; flex: none; display: grid; place-items: center; width: 48px; height: 48px; }
.talk-orb::before { content: ""; position: absolute; inset: 0; border-radius: 50%; background: var(--orb-ring); transform: scale(calc(1 + var(--level) * 0.6)); }
.talk-orb-core { position: relative; width: 26px; height: 26px; border-radius: 50%; background: var(--orb); }
.talk-live[data-live="learner_speaking"] .talk-orb-core { border-radius: 8px; }
.talk-live[data-live="connecting"] .talk-orb::before, .talk-live[data-live="thinking"] .talk-orb::before { animation: orb-pulse 1.4s ease-in-out infinite; }
@keyframes orb-pulse { 50% { transform: scale(1.3); } }
.talk-phase { font-weight: 600; }
.talk-captions-box { margin-top: 18px; }
.talk-captions-title { margin-bottom: 8px; font-size: 15px; }
.talk-captions { padding: 10px; max-height: 300px; overflow-y: auto; border: 1px solid var(--border); border-radius: 1rem; background: var(--card); }
.talk-captions:has(> .talk-captions-list:empty) { display: none; }
.talk-captions-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.caption { max-width: 88%; padding: 8px 12px; border-radius: 0.875rem; background: var(--muted); justify-self: start; overflow-wrap: anywhere; }
.caption-learner { background: var(--tinte-soft); justify-self: end; }
.caption-who { display: block; font-size: 13px; font-weight: 600; color: var(--muted-foreground); }
.caption-interim { color: var(--subtle); font-style: italic; }
@media (prefers-reduced-motion: reduce) { .talk-orb::before, .talk-live[data-live] .talk-orb::before { animation: none; transform: none; } }
.conversation { border: 1px solid var(--border); border-radius: 1rem; padding: 12px 16px; }
.conversation + .conversation { margin-top: 10px; }
.conversation summary { cursor: pointer; }
.conversation h3 { margin-top: 16px; font-size: 16px; }
.conversation h4 { margin: 12px 0 4px; font-size: 15px; }
.transcript { list-style: none; margin: 12px 0 0; padding: 0; display: grid; gap: 10px; }
.turn { padding: 10px 12px; border-radius: 0.875rem; background: var(--muted); }
.turn-lernende { background: var(--tinte-soft); }
.turn-who { font-weight: 600; font-size: 14px; }
.turn .muted { font-size: 13px; }
.answers dt { font-weight: 600; margin-top: 8px; }
.answers dd { margin: 2px 0 0; color: var(--muted-foreground); }
/* School dashboard (US-39): cards that link to the pages behind them */
.school-cards .stat { display: flex; flex-direction: column; gap: 2px; }
.card-link { color: var(--foreground); text-decoration: none; transition: border-color 0.15s; }
.card-link:hover, .card-link:focus-visible { border-color: var(--primary); }
.card-link .label { color: var(--primary); font-weight: 600; }
.stat .value-sm { font-size: 20px; }
.stat .value-of { font-size: 18px; font-weight: 600; color: var(--subtle); }
.address-grid { display: grid; gap: 16px; }
@media (min-width: 700px) { .address-grid { grid-template-columns: 3fr 1fr; } }
.address-grid .field + .field { margin-top: 0; }
.terms-box { padding: 14px 16px; border: 1px solid var(--border); border-radius: 1rem; background: var(--background); font-size: 14.5px; }
.terms-box ul { margin: 6px 0 0; padding-left: 1.1rem; color: var(--muted-foreground); }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 6px 20px; font-size: 15px; }
.facts dt { color: var(--subtle); }
.facts dd { margin: 0; font-variant-numeric: tabular-nums; }
/* Sub-navigation between related pages (MCP: Anleitung, Verbundene Apps). */
.subnav { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 20px; padding: 4px; border: 1px solid var(--border); border-radius: 999px; width: fit-content; max-width: 100%; }
.subnav a { padding: 6px 14px; border-radius: 999px; font-size: 14px; font-weight: 600; color: var(--subtle); text-decoration: none; }
.subnav a:hover { color: var(--primary); }
.subnav a[aria-current="page"] { background: var(--tinte-soft); color: var(--primary); }
/* A table that scrolls on its own keeps its visually hidden headers (.sr-only, absolute)
   inside it; otherwise they widen the whole page on phones. */
.table-wrap { position: relative; }
/* Phones and narrow windows: logo and «Abmelden» in one row, the navigation as one
   row that scrolls sideways (app.js keeps the current page in view), so the content
   starts right below instead of after the whole menu. */
@media (max-width: 899px) {
  .sidebar { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 12px; padding: 12px 16px 8px; }
  .sidebar .logo { grid-row: 1; grid-column: 1; }
  .sidebar form { grid-row: 1; grid-column: 2; }
  .sidebar nav { grid-row: 2; grid-column: 1 / -1; flex-wrap: nowrap; overflow-x: auto; margin: 0 -16px; padding: 0 16px 4px; scrollbar-width: thin; }
  .sidebar nav a { flex: none; }
  /* One row: the groups side by side with a line between them; the titles still name
     the lists for screen readers (aria-labelledby reads hidden text). */
  .sidebar .nav-group { display: flex; gap: 4px; }
  .sidebar .nav-group, .sidebar nav ul { flex: none; flex-wrap: nowrap; }
  .sidebar .nav-group + .nav-group { padding-left: 4px; border-left: 1px solid var(--border); }
  .sidebar .nav-title { display: none; }
  .sidebar .spacer, .sidebar .who { display: none; }
}
/* First steps on «Start» while the account has no assessment yet */
.steps { margin: 0; padding-left: 1.3rem; display: grid; gap: 8px; color: var(--muted-foreground); }
.steps strong { color: var(--foreground); }
/* Charts of the bot server statistics (US-54): inline SVG from bots/charts.py, colours
   only here (CSP). Series 0 and 1 differ in colour and in line style. */
.charts { display: grid; gap: 20px; margin-top: 20px; }
@media (min-width: 1100px) { .charts { grid-template-columns: repeat(2, 1fr); } }
.chart { margin: 0; padding: 16px; background: var(--card); border: 1px solid var(--border); border-radius: 1.25rem; min-width: 0; }
.chart-title { margin: 0 0 6px; font-size: 16px; }
.chart-legend { display: flex; flex-wrap: wrap; gap: 12px; margin: 0 0 6px; font-size: 13px; color: var(--muted-foreground); }
.chart-key::before { content: ""; display: inline-block; width: 12px; height: 4px; margin-right: 6px; vertical-align: middle; border-radius: 2px; background: var(--primary); }
.chart-key.chart-s1::before { background: var(--warn); }
.chart-svg { display: block; width: 100%; height: auto; }
.chart-grid { stroke: var(--border); stroke-width: 1; }
.chart-axis { fill: var(--subtle); font-size: 12px; font-family: var(--font-sans); }
.chart-bar { fill: var(--primary); }
.chart-bar.chart-s1 { fill: var(--warn); }
.chart-line { fill: none; stroke: var(--primary); stroke-width: 2.5; stroke-linejoin: round; }
.chart-line.chart-s1 { stroke: var(--warn); stroke-dasharray: 6 4; }
.chart-table { margin-top: 8px; font-size: 14px; }
.chart-table summary { cursor: pointer; color: var(--primary); }
/* Creation of an assessment (ADR 0020): only the fields of the chosen kind, no script. */
.kind-fields { display: none; border: 1px solid var(--border); border-radius: 0.875rem; padding: 12px 16px 16px; margin: 0 0 16px; }
.kind-fields legend { font-size: 15px; font-weight: 600; padding: 0 6px; }
.kind-form:has(input[name="kind"][value="werkgespraech"]:checked) .kind-fields[data-kind="werkgespraech"],
.kind-form:has(input[name="kind"][value="projektarbeit"]:checked) .kind-fields[data-kind="projektarbeit"] { display: block; }
