:root {
  --brand: #0A7480;
  --ink: #0F1F1E;
  --paper: #F1F4F4;
  --surface: #FFFFFF;
  --surface-2: #E9EEEE;
  --muted: #566768;
  --faint: #7C8D8E;
  --line: #CBD6D6;
  --line-soft: #E0E7E7;
  --ok: #2C6638;
  --ok-bg: #E2EFE4;
  --warn: #8C5406;
  --warn-bg: #F7EBD8;
  --crit: #97292B;
  --crit-bg: #F7E4E4;
  --radius: 4px;
  --shadow: 0 1px 2px rgba(15,31,30,.06), 0 10px 28px -20px rgba(15,31,30,.4);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper: #0D1516;
    --surface: #141E20;
    --surface-2: #1C2829;
    --ink: #E4EDEC;
    --muted: #A2B4B4;
    --faint: #7A8C8D;
    --line: #2A3A3C;
    --line-soft: #202E30;
    --ok: #74C283;
    --ok-bg: #17291B;
    --warn: #D9A443;
    --warn-bg: #2F2412;
    --crit: #E38181;
    --crit-bg: #311B1B;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 10px 28px -20px rgba(0,0,0,.9);
  }
}

* { box-sizing: border-box; }

html, body { margin: 0; padding: 0; }

body {
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font);
  font-size: 15.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-underline-offset: 2px; }
a:hover { text-decoration: underline; }

h1 { font-size: 26px; line-height: 1.2; margin: 0 0 6px; letter-spacing: -.015em; }
h2 { font-size: 19px; line-height: 1.25; margin: 30px 0 12px; letter-spacing: -.01em; }
h3 { font-size: 16px; margin: 20px 0 8px; }
p  { margin: 0 0 12px; }

.lead { color: var(--muted); margin: 0 0 22px; max-width: 70ch; }

/* ---------- Kopfzeile ---------- */

.topbar {
  display: flex;
  align-items: center;
  gap: 8px 24px;
  flex-wrap: wrap;
  padding: 12px 22px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}
.topbar .logo { font-weight: 700; color: var(--ink); text-decoration: none; font-size: 16px; letter-spacing: -.01em; }
.topbar .logo img { height: 26px; display: block; }
.topbar nav { display: flex; gap: 18px; flex: 1; flex-wrap: wrap; }
.topbar nav a { color: var(--muted); text-decoration: none; font-size: 14.5px; }
.topbar nav a:hover { color: var(--brand); }
.topbar-right { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.who { color: var(--muted); font-size: 14px; }
.bereich-picker { display: flex; align-items: center; gap: 7px; }
.bereich-picker label { font-size: 12px; color: var(--faint); text-transform: uppercase; letter-spacing: .07em; }
.bereich-single { font-size: 14px; color: var(--muted); }

main { max-width: 900px; margin: 0 auto; padding: 28px 22px 70px; }
main.wide { max-width: 1240px; }
body.bare main { max-width: 560px; padding-top: 56px; }

.pagefoot { text-align: center; padding: 0 22px 32px; color: var(--faint); font-size: 13px; display: flex; gap: 10px; justify-content: center; }
.pagefoot a { color: var(--faint); }

/* ---------- Karten und Listen ---------- */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px 22px;
  margin-bottom: 16px;
}
.card.pad-0 { padding: 0; overflow: hidden; }
.grid { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }

.rows { display: flex; flex-direction: column; }
.row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 4px 18px;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line-soft);
}
.row:last-child { border-bottom: none; }
.row .main { min-width: 0; }
.row .title { font-weight: 600; }
.row .sub { color: var(--faint); font-size: 13.5px; }
.row .actions { display: flex; gap: 8px; flex-wrap: wrap; }

.empty { padding: 34px 20px; text-align: center; color: var(--faint); }

/* ---------- Statuspillen ---------- */

.pill {
  display: inline-block;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: .05em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 100px;
  background: var(--surface-2);
  color: var(--muted);
  white-space: nowrap;
}
.pill.geplant       { background: var(--surface-2); color: var(--muted); }
.pill.laufend       { background: var(--ok-bg); color: var(--ok); }
.pill.verarbeitung  { background: var(--warn-bg); color: var(--warn); }
.pill.entwurf       { background: var(--warn-bg); color: var(--warn); }
.pill.freigegeben   { background: var(--ok-bg); color: var(--ok); }
.pill.kunde_sichtbar{ background: var(--ok-bg); color: var(--ok); }
.pill.fehler        { background: var(--crit-bg); color: var(--crit); }
.pill.verworfen     { background: var(--surface-2); color: var(--faint); }

/* ---------- Formulare ---------- */

label.field { display: block; margin-bottom: 14px; }
label.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
label.field > small { display: block; color: var(--faint); font-size: 12.5px; margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=url],
input[type=number], input[type=datetime-local], select, textarea {
  width: 100%;
  padding: 9px 11px;
  font: inherit;
  font-size: 15px;
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
}
textarea { min-height: 110px; resize: vertical; line-height: 1.5; }
input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--brand);
  outline-offset: 1px;
  border-color: var(--brand);
}
.field-row { display: grid; gap: 0 16px; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); }

.btn {
  display: inline-block;
  padding: 9px 16px;
  font: inherit;
  font-size: 14.5px;
  font-weight: 600;
  border-radius: var(--radius);
  border: 1px solid var(--brand);
  background: var(--brand);
  color: #fff;
  cursor: pointer;
  text-decoration: none;
  line-height: 1.3;
}
.btn:hover { filter: brightness(1.08); text-decoration: none; }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; color: var(--brand); }
.btn-quiet { background: var(--surface-2); border-color: var(--line); color: var(--ink); }
.btn-danger { background: var(--crit); border-color: var(--crit); color: #fff; }
.btn-sm { padding: 5px 11px; font-size: 13.5px; }
.btnbar { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }

/* ---------- Hinweise ---------- */

.notice { border-radius: var(--radius); padding: 13px 16px; margin: 0 0 18px; border-left: 3px solid var(--muted); background: var(--surface-2); }
.notice strong { display: block; margin-bottom: 3px; }
.notice p { margin: 0; font-size: 14.5px; }
.notice.ok   { background: var(--ok-bg);   border-left-color: var(--ok);   }
.notice.warn { background: var(--warn-bg); border-left-color: var(--warn); }
.notice.crit { background: var(--crit-bg); border-left-color: var(--crit); }

.mono { font-family: var(--mono); font-size: 13px; word-break: break-all; }
.copybox { display: flex; gap: 8px; align-items: stretch; }
.copybox input { font-family: var(--mono); font-size: 13px; }

table.data { width: 100%; border-collapse: collapse; font-size: 14px; }
table.data th, table.data td { text-align: left; padding: 9px 12px 9px 0; border-bottom: 1px solid var(--line-soft); vertical-align: top; }
table.data th { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--faint); font-weight: 600; }
.scroll-x { overflow-x: auto; }

/* ---------- Beitrittsseite ---------- */

.join-wrap { max-width: 520px; margin: 0 auto; }
.join-brand { text-align: center; margin-bottom: 26px; }
.join-brand img { max-height: 46px; }
.join-brand .name { font-size: 20px; font-weight: 700; }
.consent { background: var(--surface-2); border-radius: var(--radius); padding: 16px 18px; margin: 18px 0; font-size: 14.5px; }
.consent ul { margin: 8px 0 0; padding-left: 18px; }
.consent li { margin-bottom: 5px; }
.checkline { display: flex; gap: 10px; align-items: flex-start; margin: 16px 0; }
.checkline input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.checkline label { font-size: 14.5px; }

/* ---------- Besprechungsraum ---------- */

body.room { background: #0B1112; color: #E6EEEE; height: 100vh; overflow: hidden; }
body.room main { max-width: none; padding: 0; }
.room-shell { display: flex; flex-direction: column; height: 100vh; }
.room-head {
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  padding: 9px 16px; background: #121B1D; border-bottom: 1px solid #22302F; flex: none;
}
.room-head .rtitle { font-weight: 600; font-size: 15px; }
.room-head .spacer { flex: 1; }
.rec-dot {
  display: inline-flex; align-items: center; gap: 7px;
  background: rgba(151,41,43,.18); color: #F0A0A0;
  padding: 4px 11px; border-radius: 100px; font-size: 12.5px; font-weight: 600;
}
.rec-dot i { width: 9px; height: 9px; border-radius: 50%; background: #E05B5B; display: block; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
@media (prefers-reduced-motion: reduce) { .rec-dot i { animation: none; } }

.stage { flex: 1; display: grid; gap: 8px; padding: 10px; overflow: auto; align-content: start; }
.stage.g1 { grid-template-columns: 1fr; }
.stage.g2 { grid-template-columns: repeat(2, 1fr); }
.stage.g3, .stage.g4 { grid-template-columns: repeat(2, 1fr); }
.stage.g5, .stage.g6, .stage.g7, .stage.g8, .stage.g9 { grid-template-columns: repeat(3, 1fr); }
.stage.has-share { grid-template-columns: minmax(0, 3fr) minmax(200px, 1fr); }

.tile {
  position: relative; background: #16201F; border: 1px solid #22302F;
  border-radius: 6px; overflow: hidden; aspect-ratio: 16/9; min-height: 120px;
}
.tile.share { aspect-ratio: auto; grid-row: span 3; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #0E1617; }
.tile.share video { object-fit: contain; }
.tile .nametag {
  position: absolute; left: 8px; bottom: 8px;
  background: rgba(0,0,0,.6); color: #fff; font-size: 12.5px;
  padding: 3px 9px; border-radius: 4px; display: flex; gap: 6px; align-items: center;
}
.tile .avatar {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 30px; font-weight: 700; color: #6C8384; background: #16201F;
}
.tile.speaking { border-color: var(--brand); box-shadow: 0 0 0 2px var(--brand); }
.muted-icon { opacity: .75; }

.room-bar {
  display: flex; gap: 10px; justify-content: center; flex-wrap: wrap;
  padding: 12px 16px; background: #121B1D; border-top: 1px solid #22302F; flex: none;
}
.cbtn {
  min-width: 52px; padding: 10px 14px; border-radius: 6px; cursor: pointer;
  background: #1F2C2E; border: 1px solid #2C3B3D; color: #DCE7E6;
  font: inherit; font-size: 13.5px; font-weight: 600;
}
.cbtn:hover { background: #26373A; }
.cbtn.on { background: var(--brand); border-color: var(--brand); color: #fff; }
.cbtn.off { background: #4A1F21; border-color: #5E2A2C; color: #F0B6B6; }
.cbtn.leave { background: #97292B; border-color: #97292B; color: #fff; }

.sidepanel {
  position: fixed; right: 0; top: 0; bottom: 0; width: min(340px, 86vw);
  background: #121B1D; border-left: 1px solid #22302F; display: flex; flex-direction: column; z-index: 40;
}
.sidepanel header { padding: 12px 16px; border-bottom: 1px solid #22302F; display: flex; justify-content: space-between; align-items: center; }
.sidepanel .body { flex: 1; overflow: auto; padding: 12px 16px; }
.sidepanel .foot { padding: 12px 16px; border-top: 1px solid #22302F; }
.sidepanel input { background: #1B2628; border-color: #2C3B3D; color: #E6EEEE; }
.chatmsg { margin-bottom: 11px; font-size: 14px; }
.chatmsg .from { color: var(--brand); font-weight: 600; font-size: 12.5px; display: block; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: 88px; z-index: 60;
  background: rgba(0,0,0,.85); color: #fff; padding: 10px 18px; border-radius: 6px; font-size: 14px;
}

/* ---------- Protokoll ---------- */

.proto h2 { margin-top: 26px; }
.proto ul { padding-left: 20px; }
.proto li { margin-bottom: 7px; }
.tasklist { list-style: none; padding: 0; }
.tasklist li { border-bottom: 1px solid var(--line-soft); padding: 11px 0; display: grid; grid-template-columns: 1fr auto; gap: 4px 14px; }
.tasklist .who { font-size: 13px; color: var(--faint); }
.transcript { font-family: var(--mono); font-size: 13.5px; line-height: 1.7; }
.transcript .seg { margin-bottom: 9px; display: grid; grid-template-columns: 62px 120px 1fr; gap: 12px; }
.transcript .t { color: var(--faint); }
.transcript .s { color: var(--brand); font-weight: 600; }
.frames { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); }
.frames figure { margin: 0; }
.frames img { width: 100%; border: 1px solid var(--line); border-radius: var(--radius); display: block; }
.frames figcaption { font-size: 12.5px; color: var(--faint); margin-top: 4px; }

@media (max-width: 620px) {
  .stage.has-share { grid-template-columns: 1fr; }
  .tile.share { grid-row: auto; }
  .row { grid-template-columns: 1fr; }
  .row .actions { margin-top: 8px; }
  .transcript .seg { grid-template-columns: 1fr; gap: 2px; }
}
