:root {
  --bg: #0f1419;
  --bg-card: #1a1f2e;
  --bg-elevated: #232a3d;
  --border: #2a3245;
  --border-strong: #3a4359;
  --text: #e7ecf3;
  --text-muted: #8a94a7;
  --text-subtle: #5d6678;
  --accent: #6366f1;
  --accent-hover: #7c7ff5;
  --accent-soft: rgba(99, 102, 241, 0.12);
  --success: #10b981;
  --danger: #ef4444;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --radius: 14px;
  --radius-sm: 10px;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f5f7fb;
    --bg-card: #ffffff;
    --bg-elevated: #f0f3f9;
    --border: #e3e8f0;
    --border-strong: #c9d1de;
    --text: #1a1f2e;
    --text-muted: #5d6678;
    --text-subtle: #8a94a7;
    --accent-soft: rgba(99, 102, 241, 0.08);
    --shadow: 0 10px 30px rgba(15, 20, 25, 0.08);
  }
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* --- Layout ---------------------------------------------------------------*/
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--bg-card);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 12px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 6px 12px;
  border-bottom: 1px solid var(--border);
}
.sidebar-head strong { flex: 1; font-size: 15px; }
.logo-icon { font-size: 22px; }

.history-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 4px; }

.history-item {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid transparent;
  transition: background 0.15s ease;
  position: relative;
}
.history-item:hover { background: var(--bg-elevated); }
.history-item.active { background: var(--accent-soft); border-color: rgba(99,102,241,0.3); }
.history-item .hi-title { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.history-item .hi-date { font-size: 11px; color: var(--text-subtle); }
.history-item .hi-del {
  position: absolute; right: 8px; top: 50%; transform: translateY(-50%);
  background: none; border: none; color: var(--text-subtle); cursor: pointer;
  font-size: 16px; opacity: 0; transition: opacity 0.15s ease;
}
.history-item:hover .hi-del { opacity: 1; }
.history-item .hi-del:hover { color: var(--danger); }

.history-empty { color: var(--text-subtle); font-size: 13px; padding: 12px; text-align: center; }
.sidebar-note { font-size: 11px; color: var(--text-subtle); padding: 0 6px; }

.app {
  flex: 1;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  padding: 40px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.header { margin-bottom: 4px; }
.logo { display: flex; align-items: center; gap: 12px; }
.logo h1 { font-size: 26px; font-weight: 700; letter-spacing: -0.02em; flex: 1; }
.subtitle { color: var(--text-muted); font-size: 15px; margin-top: 4px; }

/* --- Karten & Schritte ----------------------------------------------------*/
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
}

.step-label { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 600; margin-bottom: 16px; }
.step-num {
  display: inline-flex; align-items: center; justify-content: center;
  width: 24px; height: 24px; border-radius: 50%;
  background: var(--accent); color: #fff; font-size: 13px; font-weight: 700;
}

/* --- Tabs -----------------------------------------------------------------*/
.tabs { display: flex; gap: 6px; background: var(--bg-elevated); padding: 4px; border-radius: var(--radius-sm); margin-bottom: 18px; }
.tab {
  flex: 1; padding: 9px; border: none; background: none; color: var(--text-muted);
  font-size: 14px; font-weight: 600; cursor: pointer; border-radius: 8px; font-family: inherit;
  transition: all 0.15s ease;
}
.tab.active { background: var(--bg-card); color: var(--text); box-shadow: 0 1px 4px rgba(0,0,0,0.15); }

/* --- Recorder -------------------------------------------------------------*/
.recorder { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 16px 0; }
.record-btn {
  width: 76px; height: 76px; border-radius: 50%;
  background: var(--accent); border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s ease; box-shadow: 0 6px 20px rgba(99,102,241,0.35);
}
.record-btn:hover { background: var(--accent-hover); transform: scale(1.04); }
.record-dot { width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: all 0.2s ease; }
.record-btn.recording { background: var(--danger); box-shadow: 0 6px 24px rgba(239,68,68,0.5); animation: pulse 1.6s infinite; }
.record-btn.recording .record-dot { width: 22px; height: 22px; border-radius: 5px; }
@keyframes pulse { 0%,100% { box-shadow: 0 6px 24px rgba(239,68,68,0.5); } 50% { box-shadow: 0 6px 34px rgba(239,68,68,0.85); } }

.recorder-info { text-align: center; }
.record-time { display: block; font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.record-hint { font-size: 13px; color: var(--text-muted); }
.visualizer { width: 240px; max-width: 100%; height: 48px; opacity: 0.85; }

/* --- Dropzone -------------------------------------------------------------*/
.dropzone {
  border: 2px dashed var(--border-strong); border-radius: var(--radius-sm);
  padding: 36px 24px; text-align: center; transition: all 0.2s ease; cursor: pointer;
  background: var(--bg-elevated);
}
.dropzone:hover, .dropzone.dragover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone.has-file { cursor: default; padding: 18px; }
.dropzone-content { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.dropzone.has-file .dropzone-content { display: none; }
.dropzone-icon { width: 40px; height: 40px; color: var(--text-muted); margin-bottom: 4px; }
.dropzone-title { font-size: 16px; font-weight: 600; }
.dropzone-hint { color: var(--text-muted); font-size: 14px; }
.dropzone-formats { color: var(--text-subtle); font-size: 12px; margin-top: 4px; }

.file-preview { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.file-info { display: flex; align-items: center; gap: 12px; min-width: 0; flex: 1; }
.file-icon { font-size: 26px; flex-shrink: 0; }
.file-meta { display: flex; flex-direction: column; min-width: 0; }
.file-name { font-weight: 600; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { color: var(--text-muted); font-size: 12px; }
.remove-btn {
  background: var(--bg-card); border: 1px solid var(--border); color: var(--text-muted);
  width: 30px; height: 30px; border-radius: 50%; cursor: pointer; font-size: 18px; line-height: 1;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; transition: all 0.15s ease;
}
.remove-btn:hover { background: var(--danger); color: #fff; border-color: var(--danger); }

/* --- Controls -------------------------------------------------------------*/
.controls { display: flex; gap: 18px; margin-top: 18px; align-items: center; flex-wrap: wrap; }
.control-group { display: flex; flex-direction: column; gap: 6px; flex: 1; min-width: 180px; }
.control-group.full { display: flex; width: 100%; margin-top: 16px; }
.optional { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--text-subtle); }
.field-hint { font-size: 12px; color: var(--text-subtle); }
.readonly-view { white-space: pre-wrap; overflow-y: auto; max-height: 420px; }
.control-label { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.select, .input {
  background: var(--bg-elevated); border: 1px solid var(--border); color: var(--text);
  padding: 10px 12px; border-radius: var(--radius-sm); font-size: 14px; font-family: inherit;
  transition: border-color 0.15s ease; width: 100%;
}
.select { cursor: pointer; }
.select:focus, .input:focus { outline: none; border-color: var(--accent); }
textarea.input { resize: vertical; }

/* --- Toggle ---------------------------------------------------------------*/
.toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; padding-top: 18px; }
.toggle input { display: none; }
.toggle-track { width: 42px; height: 24px; border-radius: 12px; background: var(--border-strong); position: relative; transition: background 0.2s ease; flex-shrink: 0; }
.toggle-thumb { position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; transition: transform 0.2s ease; }
.toggle input:checked + .toggle-track { background: var(--accent); }
.toggle input:checked + .toggle-track .toggle-thumb { transform: translateX(18px); }
.toggle-label { font-size: 14px; display: flex; align-items: center; gap: 6px; }
.badge { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.03em; background: var(--accent-soft); color: var(--accent); padding: 2px 6px; border-radius: 6px; }

/* --- Buttons --------------------------------------------------------------*/
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  padding: 11px 20px; border-radius: var(--radius-sm); font-size: 14px; font-weight: 600;
  cursor: pointer; border: 1px solid transparent; transition: all 0.15s ease; font-family: inherit;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.block { width: 100%; margin-top: 18px; }
.btn-primary { background: var(--accent); color: #fff; min-width: 140px; }
.btn-primary:hover:not(:disabled) { background: var(--accent-hover); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(99,102,241,0.3); }
.btn-secondary { background: var(--bg-elevated); color: var(--text); border-color: var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); border-color: var(--border-strong); }
.btn-secondary.success, .btn.success { background: var(--success); color: #fff; border-color: var(--success); }

.icon-btn { background: none; border: none; color: var(--text-muted); cursor: pointer; font-size: 20px; padding: 2px 6px; border-radius: 6px; }
.icon-btn:hover { background: var(--bg-elevated); color: var(--text); }
.link-btn { background: none; border: none; color: var(--accent); cursor: pointer; font-weight: 600; font-size: inherit; padding: 0; text-decoration: underline; text-underline-offset: 2px; }
.link-btn:hover { color: var(--accent-hover); }

.spinner { width: 14px; height: 14px; border: 2px solid rgba(255,255,255,0.3); border-top-color: #fff; border-radius: 50%; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* --- Status ---------------------------------------------------------------*/
.status { margin-top: 16px; padding: 12px 16px; border-radius: var(--radius-sm); font-size: 14px; }
.status.error { background: rgba(239,68,68,0.12); color: var(--danger); border: 1px solid rgba(239,68,68,0.3); }
.status.info { background: var(--accent-soft); color: var(--accent); border: 1px solid rgba(99,102,241,0.3); }

/* --- Ergebnis-Bereiche ----------------------------------------------------*/
.result-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; flex-wrap: wrap; }
.result-header .step-label { margin-bottom: 0; }
.result-meta { font-size: 12px; color: var(--text-muted); }

.view-switch { display: inline-flex; gap: 4px; background: var(--bg-elevated); padding: 3px; border-radius: 8px; margin-bottom: 12px; }
.view-btn { padding: 6px 14px; border: none; background: none; color: var(--text-muted); font-size: 13px; font-weight: 600; cursor: pointer; border-radius: 6px; font-family: inherit; }
.view-btn.active { background: var(--bg-card); color: var(--text); }
.view-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.result-text {
  width: 100%; min-height: 200px; background: var(--bg-elevated); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 16px; color: var(--text); font-size: 15px;
  font-family: inherit; line-height: 1.6; resize: vertical;
}
.result-text:focus { outline: none; border-color: var(--accent); }

.speaker-view { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 8px 16px; max-height: 420px; overflow-y: auto; }
.speaker-turn { padding: 8px 0; border-bottom: 1px solid var(--border); }
.speaker-turn:last-child { border-bottom: none; }
.speaker-name { font-weight: 700; font-size: 13px; color: var(--accent); display: block; margin-bottom: 2px; }
.speaker-text { font-size: 14px; }

.result-actions { display: flex; gap: 10px; margin-top: 16px; flex-wrap: wrap; align-items: center; }
.export-actions { padding-top: 16px; border-top: 1px solid var(--border); }
.export-label { font-size: 13px; font-weight: 600; color: var(--text-muted); margin-right: 4px; }

/* --- Hints ----------------------------------------------------------------*/
.hints-box { display: flex; flex-direction: column; gap: 10px; padding: 16px; background: var(--bg-elevated); border-radius: var(--radius-sm); margin-bottom: 18px; }

/* --- Protokoll-Ansicht ----------------------------------------------------*/
.protocol-view h2.p-title { font-size: 22px; margin-bottom: 4px; }
.protocol-view .p-meta { font-size: 12px; color: var(--text-muted); margin-bottom: 18px; }
.protocol-view section { margin-bottom: 20px; }
.protocol-view h3 { font-size: 14px; text-transform: uppercase; letter-spacing: 0.05em; color: var(--accent); margin-bottom: 8px; }
.protocol-view h4 { font-size: 15px; margin: 10px 0 4px; }
.protocol-view p { font-size: 15px; }
.protocol-view ul { list-style: none; padding: 0; }
.protocol-view li { position: relative; padding-left: 18px; margin-bottom: 5px; font-size: 14px; }
.protocol-view li::before { content: '•'; position: absolute; left: 4px; color: var(--accent); }
.protocol-view .chips { display: flex; flex-wrap: wrap; gap: 6px; }
.protocol-view .chip { background: var(--bg-elevated); border: 1px solid var(--border); border-radius: 20px; padding: 4px 12px; font-size: 13px; }

.todo-table { width: 100%; border-collapse: collapse; margin-top: 4px; }
.todo-table th, .todo-table td { text-align: left; padding: 8px 10px; font-size: 13px; border-bottom: 1px solid var(--border); vertical-align: top; }
.todo-table th { color: var(--text-muted); text-transform: uppercase; font-size: 11px; letter-spacing: 0.04em; }
.todo-table td:first-child { width: 55%; }

.footer { text-align: center; color: var(--text-subtle); font-size: 12px; margin-top: auto; padding-top: 16px; }
.hidden { display: none !important; }
.mobile-only { display: none; }

/* ==========================================================================
   Ergänzungen: Topbar, Login/Registrierung, Konto-Seite
   ========================================================================== */

/* --- Topbar (App & Konto) -------------------------------------------------*/
.topbar {
  display: flex; align-items: center; gap: 14px;
  padding: 12px 22px; background: var(--bg-card);
  border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 20;
}
.topbar .brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 15px; }
.topbar .spacer { flex: 1; }
.topbar a.navlink, .topbar .navlink { color: var(--text-muted); text-decoration: none; font-size: 14px; font-weight: 600; padding: 6px 10px; border-radius: 8px; }
.topbar a.navlink:hover, .topbar .navlink:hover { background: var(--bg-elevated); color: var(--text); }
.topbar a.navlink.active { color: var(--text); background: var(--bg-elevated); }
.topbar .email { font-size: 13px; color: var(--text-subtle); }

/* --- Zentrierte Seiten (Login) --------------------------------------------*/
.center-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 400px; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 30px 26px; box-shadow: var(--shadow);
}
.auth-card h1 { font-size: 24px; margin-bottom: 4px; }
.auth-card .sub { color: var(--text-muted); font-size: 14px; margin-bottom: 20px; }
.pane { display: none; flex-direction: column; gap: 14px; }
.pane.active { display: flex; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field span { font-size: 12px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }

.msg { margin-top: 14px; font-size: 14px; min-height: 18px; }
.msg.err { color: var(--danger); }
.msg.ok { color: var(--success); }

/* --- Konto-Seite ----------------------------------------------------------*/
.konto { max-width: 640px; margin: 0 auto; width: 100%; padding: 32px 20px; display: flex; flex-direction: column; gap: 18px; }
.konto h2 { font-size: 17px; margin-bottom: 6px; }
.konto .card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: var(--text-muted); margin-top: 12px; }
.konto .card .btn { margin-top: 16px; }
.hint { font-size: 13px; color: var(--text-subtle); }
.tg-status { font-size: 15px; margin-bottom: 12px; }
.link-cmd { display: block; background: var(--bg-elevated); border: 1px solid var(--border-strong); border-radius: var(--radius-sm); padding: 12px 14px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 16px; margin: 10px 0; user-select: all; }

/* --- Responsive -----------------------------------------------------------*/
@media (max-width: 820px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 30; transform: translateX(-100%);
    transition: transform 0.25s ease; box-shadow: var(--shadow);
  }
  .sidebar.open { transform: translateX(0); }
  .mobile-only { display: inline-flex; }
  .app { padding: 24px 16px; }
}
@media (max-width: 520px) {
  .logo h1 { font-size: 20px; }
  .controls { flex-direction: column; align-items: stretch; }
  .toggle { padding-top: 0; }
  .topbar { padding: 10px 14px; gap: 8px; }
  .topbar .email { display: none; }
}
