/* ── Reset ────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:         #12121a;
  --surface:    #1c1c28;
  --surface2:   #24243a;
  --surface3:   #2e2e46;
  --border:     #3a3a58;
  --border2:    #50507a;
  --purple:     #8878e8;
  --purple-d:   #534ab7;
  --purple-bg:  #28244a;
  --purple-lt:  #b0a8ff;
  --teal:       #48c8a0;
  --teal-bg:    #143a37;
  --teal-txt:   #64dab8;
  --coral:      #e06450;
  --coral-bg:   #46201a;
  --coral-txt:  #f08870;
  --amber:      #d8a532;
  --amber-bg:   #413210;
  --amber-txt:  #f0c050;
  --text1:      #eeeef4;
  --text2:      #a0a0b8;
  --text3:      #64647a;
  --nav-h:      68px;
  --topbar-h:   54px;
  --sidebar-w:  220px;
  --safe-top:   env(safe-area-inset-top, 0px);
  --safe-bot:   env(safe-area-inset-bottom, 0px);
  --radius:     14px;
  --radius-sm:  9px;
  --text-sm:    15px;
  --text-md:    19px;
  --text-lg:    23px;
}

html {
  -webkit-text-size-adjust: 100%;
  touch-action: manipulation;
}

body {
  background: var(--bg);
  color: var(--text1);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  font-size: var(--text-md);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
  touch-action: manipulation;
  height: 100dvh;
  overflow: hidden;
}

/* ══════════════════════════════════════════════════════
   LAYOUT — Mobile First
══════════════════════════════════════════════════════ */
#app {
  display: flex;
  height: 100dvh;
  overflow: hidden;
}

/* Sidebar hidden on mobile */
.sidebar { display: none; }

.main-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
}

/* ── Mobile Topbar ── */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #1a1a28;
  border-bottom: 1px solid var(--border);
  padding: 10px 18px;
  padding-top: calc(10px + var(--safe-top));
  flex-shrink: 0;
  z-index: 10;
}
.topbar-left { display: flex; align-items: center; gap: 10px; }
.topbar-titles { display: flex; flex-direction: column; gap: 1px; }
.topbar-title { font-size: var(--text-md); font-weight: 700; color: var(--text1); line-height: 1.2; }
.topbar-sub   { font-size: var(--text-sm); color: var(--text3); line-height: 1.2; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.app-version { font-size: var(--text-sm); color: var(--text3); font-weight: 600; letter-spacing: 0.03em; }
.lock-icon { font-size: var(--text-md); opacity: 0.6; }

/* Desktop page header — hidden on mobile */
.page-header { display: none; }

/* ── Screen Container ── */
.screen-container {
  flex: 1;
  overflow: hidden;
  position: relative;
}

.screen {
  position: absolute; inset: 0;
  overflow-y: auto; overflow-x: hidden;
  display: none;
  -webkit-overflow-scrolling: touch;
  /* Smooth scroll for desktop mouse wheel */
  scroll-behavior: smooth;
}
.screen.active { display: block; }

.screen-inner {
  padding: 14px 16px 24px;
  display: flex; flex-direction: column; gap: 16px;
  min-height: 100%;
}

/* ── Bottom Nav (Mobile) ── */
.bottom-nav {
  display: flex;
  background: #1a1a28;
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bot);
  flex-shrink: 0;
  /* Bei vielen Einträgen (Ablauf + 8 weitere) reicht die Breite auf schmalen
     Smartphones nicht — dann horizontal scrollen statt (durch overflow:hidden
     des .main-wrapper) rechts abzuschneiden. */
  overflow-x: auto;
  scrollbar-width: none;
}
.bottom-nav::-webkit-scrollbar { display: none; }
.nav-btn {
  flex: 1 0 auto;
  min-width: 60px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 9px 4px 7px;
  background: none; border: none; color: var(--text3);
  cursor: pointer; border-top: 2px solid transparent;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}
.nav-btn.active { color: var(--purple); border-top-color: var(--purple); }
.nav-btn:hover:not(.active) { color: var(--text2); }
.nav-icon  { font-size: var(--text-lg); line-height: 1; }
.nav-label { font-size: var(--text-sm); font-weight: 500; white-space: nowrap; }

/* ══════════════════════════════════════════════════════
   TABLET (768px+)
══════════════════════════════════════════════════════ */
@media (min-width: 768px) {
  .bottom-nav { display: none; }

  .sidebar {
    display: flex;
    flex-direction: column;
    width: var(--sidebar-w);
    flex-shrink: 0;
    background: #16162a;
    border-right: 1px solid var(--border);
    padding: 0;
    overflow: hidden;
  }

  .sidebar-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 18px 16px;
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
  }
  .sidebar-titles { display: flex; flex-direction: column; gap: 2px; }
  .sidebar-title { font-size: var(--text-md); font-weight: 700; color: var(--text1); }
  .sidebar-sub   { font-size: var(--text-sm); color: var(--text3); }

  .sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 12px 10px;
    gap: 4px;
    overflow-y: auto;
  }

  .nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    background: none; border: none;
    border-radius: var(--radius-sm);
    color: var(--text2);
    font-size: var(--text-md); font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.12s, color 0.12s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    user-select: none;
    text-align: left;
  }
  .nav-item:hover { background: var(--surface2); color: var(--text1); }
  .nav-item.active {
    background: var(--purple-bg);
    color: var(--purple-lt);
    border: 1px solid var(--purple-d);
    padding: 10px 13px;
  }
  .nav-item .nav-icon {
    font-size: var(--text-lg);
    flex-shrink: 0;
    width: 28px;
    min-width: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }
  .nav-item .nav-label { font-size: var(--text-md); }

  .sidebar-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 18px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
  }

  .page-header {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 18px 28px 0;
    flex-shrink: 0;
  }
  .page-title {
    font-size: var(--text-lg); font-weight: 700; color: var(--text1);
  }
  .page-date {
    font-size: var(--text-sm); color: var(--text3);
  }

  .screen-inner {
    padding: 18px 28px 32px;
    gap: 20px;
  }
}

/* ══════════════════════════════════════════════════════
   Mobile baseline for multi-column layouts
══════════════════════════════════════════════════════ */
.session-layout,
.export-layout,
.session-col-left,
.session-col-right,
.export-col-main,
.export-col-side {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ══════════════════════════════════════════════════════
   DESKTOP (1024px+)
══════════════════════════════════════════════════════ */
@media (min-width: 1024px) {
  :root { --sidebar-w: 240px; }

  .page-header { padding: 20px 32px 0; }
  .screen-inner { padding: 20px 32px 36px; gap: 24px; }

  /* Sitzung: two-column layout */
  .session-layout {
    display: grid;
    grid-template-columns: 1fr 340px;
    gap: 16px;
    align-items: start;
  }

  /* Export: two-column layout */
  .export-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 16px;
    align-items: start;
  }

  /* Proband list: grid */
  .proband-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 10px;
  }

  /* Log list: grid */
  .log-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
    gap: 10px;
  }

  /* Detail grid in session detail overlay */
  .detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}

@media (min-width: 1280px) {
  :root { --sidebar-w: 260px; }
  .proband-grid { grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); }
  .log-grid { grid-template-columns: repeat(auto-fill, minmax(400px, 1fr)); }
}


/* ── Logo (shared by topbar + sidebar) ── */
.logo {
  width: 34px; height: 34px;
  background: var(--purple-d);
  border-radius: 9px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: var(--text-md); color: #ddd8ff;
  flex-shrink: 0;
}

/* ══════════════════════════════════════════════════════
   CARDS
══════════════════════════════════════════════════════ */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
}
.card-label {
  font-size: var(--text-sm); font-weight: 700; color: var(--text3);
  letter-spacing: 0.06em; text-transform: uppercase; margin-bottom: 12px;
}
.card-label-row {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.purple-label { color: var(--purple-lt); }
.form-card  { background: var(--purple-bg); border-color: var(--purple-d); }
.privacy-card { background: var(--purple-bg); border: 1px solid var(--purple-d); }
.privacy-text { font-size: var(--text-sm); color: var(--purple-lt); line-height: 1.6; }
.privacy-text strong { font-weight: 700; }

/* ══════════════════════════════════════════════════════
   FORM ELEMENTS
══════════════════════════════════════════════════════ */
.field-label {
  display: block; font-size: var(--text-sm); color: var(--text3);
  margin-bottom: 6px; margin-top: 12px;
}
.field-label:first-child { margin-top: 0; }

/* form-grid: side-by-side fields on wider screens */
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}
.form-grid > div { display: flex; flex-direction: column; }
.form-grid-full { grid-column: 1 / -1; }

@media (max-width: 500px) {
  .form-grid { grid-template-columns: 1fr; }
  .form-grid-full { grid-column: 1; }
}

/* edit modal rows */
.edit-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 12px;
}
.edit-row-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px 12px;
}
@media (max-width: 560px) {
  .edit-row-2 { grid-template-columns: 1fr; }
  .edit-row-3 { grid-template-columns: 1fr; }
}

input[type="text"],
input[type="number"],
input[type="datetime-local"],
textarea,
select {
  width: 100%;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text1);
  font-size: var(--text-md);
  font-family: inherit;
  padding: 10px 12px;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  transition: border-color 0.15s;
}
input:focus, textarea:focus, select:focus { border-color: var(--purple); }
input::placeholder, textarea::placeholder { color: var(--text3); font-size: var(--text-md); }
input.field-invalid { border-color: var(--coral); }
input.field-invalid:focus { border-color: var(--coral); }
.field-error {
  color: var(--coral-txt); font-size: var(--text-sm); margin-top: 4px;
}
textarea { resize: vertical; line-height: 1.5; min-height: 72px; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2364647a' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

input[type="datetime-local"],
input[type="time"] { color-scheme: dark; }

/* ══════════════════════════════════════════════════════
   BUTTONS
══════════════════════════════════════════════════════ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface2); color: var(--text1);
  font-size: var(--text-md); font-weight: 600; font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  transition: opacity 0.12s, transform 0.08s, background 0.12s;
  white-space: nowrap;
}
.btn:hover   { opacity: 0.9; }
.btn:active  { opacity: 0.75; transform: scale(0.97); }

.btn-primary { background: var(--purple-d); border-color: var(--purple-d); color: #fff; }
.btn-primary:hover { background: #6058d0; }
.btn-ghost   { background: transparent; border-color: var(--border2); color: var(--text2); }
.btn-ghost:hover { background: var(--surface2); }
.btn-start   { background: var(--purple-d); border-color: var(--purple-d); color: #fff; font-size: var(--text-md); padding: 14px; }
.btn-start:hover { background: #6058d0; }
.btn-stop    { background: var(--coral-bg); border-color: var(--coral); color: var(--coral-txt); font-size: var(--text-md); padding: 14px; }
.btn-stop:hover { background: #5a2820; }
.btn-pause   { background: var(--amber-bg); border-color: var(--amber); color: var(--amber-txt); font-size: var(--text-md); padding: 14px; }
.btn-pause:hover { background: #5a4318; }
.btn-save    { background: var(--teal-bg); border-color: var(--teal); color: var(--teal-txt); }
.btn-save:hover { background: #1d4e49; }
.btn-danger  { background: var(--coral-bg); border-color: var(--coral); color: var(--coral-txt); }
.btn-danger:hover { background: #5a2820; }

.btn-text {
  background: none; border: none; font-size: var(--text-sm);
  color: var(--purple-lt); cursor: pointer; padding: 2px 4px;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  user-select: none;
  transition: opacity 0.12s;
  font-family: inherit;
}
.btn-text:hover { opacity: 0.8; }

.btn-icon {
  width: 42px; height: 42px;
  border-radius: var(--radius-sm); border: none;
  font-size: var(--text-lg); font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; flex-shrink: 0;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  user-select: none;
  transition: opacity 0.12s, transform 0.08s;
}
.btn-icon:hover  { opacity: 0.85; }
.btn-icon:active { opacity: 0.7; transform: scale(0.95); }
.btn-icon.btn-primary { background: var(--purple-d); color: #fff; }

.btn-icon-sm {
  width: 30px; height: 30px; border-radius: var(--radius-sm);
  border: 1px solid var(--border); background: var(--surface3); color: var(--text2);
  font-size: var(--text-md); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  user-select: none;
  transition: background 0.12s;
}
.btn-icon-sm:hover { background: var(--surface2); }

.full-width { width: 100%; }
.flex-1 { flex: 1; }
.btn-row { display: flex; gap: 10px; margin-top: 14px; }
.btn-col { display: flex; flex-direction: column; gap: 10px; }

/* ── Search Row ── */
.search-row { display: flex; gap: 10px; align-items: center; }
.search-row input { flex: 1; }

/* ── Section Label ── */
.section-label {
  font-size: var(--text-sm); font-weight: 700; color: var(--text3);
  letter-spacing: 0.06em; padding: 4px 2px 2px;
}

.filter-row { display: flex; gap: 8px; flex-wrap: wrap; }
.filter-row .small-select { flex: 1; min-width: 140px; }
.small-select { font-size: var(--text-md); padding: 8px 28px 8px 10px; }

/* ══════════════════════════════════════════════════════
   PROBAND ITEMS
══════════════════════════════════════════════════════ */
.item-list { display: flex; flex-direction: column; gap: 8px; }

/* Override for grid layouts */
@media (min-width: 1024px) {
  .proband-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
  .log-grid     { display: grid; grid-template-columns: repeat(auto-fill, minmax(340px, 1fr)); }
}
@media (min-width: 1280px) {
  .proband-grid { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
  .log-grid     { grid-template-columns: repeat(auto-fill, minmax(380px, 1fr)); }
}

.proband-item {
  width: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.12s, border-color 0.12s;
  text-align: left; font-family: inherit; font-size: inherit; color: inherit;
  user-select: none;
}
.proband-item:hover  { background: var(--surface2); border-color: var(--border2); }
.proband-item:active { background: var(--surface2); }

.avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: var(--purple-bg); border: 1px solid var(--purple-d);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-sm); font-weight: 700; color: var(--purple-lt); flex-shrink: 0;
}
.proband-info { flex: 1; min-width: 0; }
.proband-name { font-size: var(--text-md); font-weight: 700; color: var(--text1); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.proband-sub  { font-size: var(--text-sm); color: var(--text2); margin-top: 2px; }

.badge {
  font-size: var(--text-sm); font-weight: 600; padding: 4px 10px;
  border-radius: 999px; flex-shrink: 0;
}
.badge-count { background: var(--surface3); color: var(--text2); }

/* ══════════════════════════════════════════════════════
   SCENARIO GRID
══════════════════════════════════════════════════════ */
.scenario-grid { display: flex; gap: 8px; flex-wrap: wrap; }

.scenario-btn {
  flex: 1; min-width: 70px; max-width: 150px;
  padding: 10px 6px 8px;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text2); font-size: var(--text-sm); font-weight: 600; font-family: inherit;
  cursor: pointer; text-align: center;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  user-select: none;
  transition: all 0.12s;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
}
.scenario-btn:hover { background: var(--surface2); border-color: var(--border2); color: var(--text1); }
.scenario-btn .sc-icon { font-size: var(--text-lg); line-height: 1; }
.scenario-btn .sc-abbr { font-size: var(--text-sm); color: var(--text3); margin-top: 1px; }
.scenario-btn.selected {
  background: var(--purple-bg); border-color: var(--purple); color: var(--purple-lt);
}
.scenario-btn.selected .sc-abbr { color: var(--purple-lt); }

/* ══════════════════════════════════════════════════════
   LOG ENTRIES
══════════════════════════════════════════════════════ */
.log-entry {
  width: 100%;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  border-left: 3px solid var(--purple-d);
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.12s, border-color 0.12s;
  text-align: left; font-family: inherit; font-size: inherit; color: inherit;
  user-select: none;
}
.log-entry:hover  { background: var(--surface2); border-color: var(--border2); }
.log-entry:active { background: var(--surface2); }
.log-entry.has-deviation { border-left-color: var(--coral); }

.log-row-top { display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; margin-bottom: 4px; }
.log-id   { font-size: var(--text-md); font-weight: 700; color: var(--text1); }
.log-time { font-size: var(--text-sm); color: var(--text2); white-space: nowrap; flex-shrink: 0; }
.log-meta { font-size: var(--text-sm); color: var(--text2); margin-top: 2px; }
.log-dev  { font-size: var(--text-sm); color: var(--coral-txt); margin-top: 4px; }
.log-pause { font-size: var(--text-sm); color: var(--amber-txt); margin-top: 4px; }

/* ── Confirm badge ── */
.confirm-badge {
  margin-top: 8px; font-size: var(--text-sm); color: var(--purple-lt); padding: 2px 0;
}

/* ══════════════════════════════════════════════════════
   TIMER
══════════════════════════════════════════════════════ */
.timer-card { text-align: center; }
.timer-status { margin-bottom: 6px; font-size: var(--text-sm); font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; }
.status-idle    { color: var(--text3); }
.status-running { color: var(--coral-txt); }
.status-paused  { color: var(--amber-txt); }
.status-done    { color: var(--teal-txt); }
.timer-display {
  font-size: 54px; font-weight: 700; letter-spacing: -1px;
  font-variant-numeric: tabular-nums; color: var(--text1);
  line-height: 1; margin: 4px 0 8px;
}

@media (min-width: 1024px) {
  .timer-display { font-size: 68px; }
}

.timer-meta { font-size: var(--text-sm); color: var(--text2); margin-bottom: 14px; min-height: 16px; }
.timer-btn-row { display: flex; flex-direction: column; gap: 8px; }

/* ══════════════════════════════════════════════════════
   TAGS
══════════════════════════════════════════════════════ */
.tag-row { display: flex; flex-wrap: wrap; gap: 7px; }
.tag {
  font-size: var(--text-sm); padding: 6px 12px; border-radius: 999px;
  border: 1px solid var(--border2); background: var(--surface3); color: var(--text2);
  font-family: inherit; cursor: pointer;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  user-select: none;
  transition: all 0.12s;
}
.tag:hover  { background: var(--surface2); color: var(--text1); }
.tag.active { background: var(--coral-bg); border-color: var(--coral); color: var(--coral-txt); }

/* ══════════════════════════════════════════════════════
   STATS GRID
══════════════════════════════════════════════════════ */
.stats-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.stat-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 14px 12px; text-align: center;
}
.stat-value { font-size: var(--text-lg); font-weight: 700; color: var(--text1); }
.stat-label { font-size: var(--text-sm); color: var(--text3); margin-top: 4px; }

.danger-zone { margin-top: 4px; }
.meta-text { font-size: var(--text-sm); color: var(--text3); }

/* ══════════════════════════════════════════════════════
   EINSTELLUNGEN
══════════════════════════════════════════════════════ */
.settings-row {
  display: flex; align-items: center; gap: 14px;
  margin-top: 4px;
}
.settings-row-text { flex: 1; min-width: 0; }
.settings-row-title { font-size: var(--text-md); font-weight: 700; color: var(--text1); }
.settings-row-desc  { font-size: var(--text-sm); color: var(--text2); margin-top: 3px; line-height: 1.5; }

.switch {
  position: relative; flex-shrink: 0;
  width: 50px; height: 30px;
  display: inline-block;
  -webkit-tap-highlight-color: transparent;
}
.switch input {
  position: absolute; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer;
}
.switch-slider {
  position: absolute; inset: 0;
  background: var(--surface3); border: 1px solid var(--border2);
  border-radius: 999px; transition: background 0.15s, border-color 0.15s;
  pointer-events: none;
}
.switch-slider::before {
  content: ''; position: absolute;
  width: 22px; height: 22px; left: 3px; top: 3px;
  background: var(--text2); border-radius: 50%;
  transition: transform 0.15s, background 0.15s;
}
.switch input:checked + .switch-slider { background: var(--purple-bg); border-color: var(--purple); }
.switch input:checked + .switch-slider::before { background: var(--purple); transform: translateX(20px); }

/* ══════════════════════════════════════════════════════
   TEILNEHMENDE MULTI-SELECT (Sitzung)
══════════════════════════════════════════════════════ */
.proband-multi-list {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 260px; overflow-y: auto;
}
.proband-multi-item {
  width: 100%;
  display: flex; align-items: center; gap: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 9px 12px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  text-align: left; font-family: inherit; color: var(--text2);
  font-size: var(--text-sm); font-weight: 600;
  transition: background 0.12s, border-color 0.12s;
  user-select: none;
}
.proband-multi-item:hover { background: var(--surface2); border-color: var(--border2); }
.proband-multi-item.selected {
  background: var(--purple-bg); border-color: var(--purple); color: var(--purple-lt);
}
.pm-check {
  flex-shrink: 0; width: 20px; height: 20px;
  border: 1px solid var(--border2); border-radius: 5px;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; color: var(--purple-lt);
}
.proband-multi-item.selected .pm-check { background: var(--purple); border-color: var(--purple); color: #fff; }

/* ══════════════════════════════════════════════════════
   SCENARIO MANAGER ITEMS
══════════════════════════════════════════════════════ */
.scenario-manager-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--surface3); border-radius: var(--radius-sm);
  margin-bottom: 8px;
}
.sm-icon  { font-size: var(--text-lg); flex-shrink: 0; }
.sm-info  { flex: 1; min-width: 0; }
.sm-name  { font-size: var(--text-md); font-weight: 600; color: var(--text1); }
.sm-abbr  { font-size: var(--text-sm); color: var(--text3); }
.sm-btns  { display: flex; gap: 6px; flex-shrink: 0; }
.sm-btn {
  font-size: var(--text-sm); padding: 4px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border2); background: transparent; color: var(--text2);
  cursor: pointer; font-family: inherit;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
  user-select: none;
  transition: background 0.12s;
}
.sm-btn:hover { background: var(--surface2); }
.sm-btn.del { border-color: var(--coral); color: var(--coral-txt); }
.sm-btn.del:hover { background: var(--coral-bg); }

/* ══════════════════════════════════════════════════════
   EMPTY STATE
══════════════════════════════════════════════════════ */
.empty-state { display: flex; flex-direction: column; align-items: center; padding: 48px 24px; gap: 8px; }
.empty-icon { font-size: 40px; opacity: 0.4; }
.empty-text { font-size: var(--text-md); color: var(--text3); font-weight: 500; text-align: center; }
.empty-sub  { font-size: var(--text-sm); color: var(--text3); text-align: center; opacity: 0.7; }

/* ══════════════════════════════════════════════════════
   TOAST
══════════════════════════════════════════════════════ */
.toast {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px + var(--safe-bot));
  left: 50%; transform: translateX(-50%);
  background: var(--surface2); border: 1px solid var(--border2);
  border-radius: 999px; padding: 10px 20px;
  font-size: var(--text-md); color: var(--text1);
  z-index: 400; white-space: nowrap;
  box-shadow: 0 4px 24px rgba(0,0,0,0.5);
  transition: opacity 0.3s;
}
.toast.hidden { display: none !important; }

/* On desktop, toast sits at bottom of screen */
@media (min-width: 768px) {
  .toast {
    bottom: 24px;
  }
}

/* ══════════════════════════════════════════════════════
   OVERLAYS & DIALOGS
══════════════════════════════════════════════════════ */
.overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex; align-items: center; justify-content: center;
  padding: 20px;
  /* Enable click-outside detection */
  -webkit-tap-highlight-color: transparent;
}
.overlay.hidden { display: none; }

#confirm-overlay { z-index: 300; }

.dialog-box {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: var(--radius);
  padding: 20px; width: 100%;
  max-width: 380px;
  max-height: 90vh; overflow-y: auto;
  position: relative;
}
.dialog-box.wide { max-width: 520px; }

@media (min-width: 768px) {
  .dialog-box      { max-width: 440px; }
  .dialog-box.wide { max-width: 600px; }
}

.dialog-title { font-size: var(--text-md); font-weight: 700; color: var(--text1); margin-bottom: 10px; }
.dialog-msg   { font-size: var(--text-md); color: var(--text2); margin-bottom: 18px; line-height: 1.5; }

.detail-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 14px; }
.detail-content { display: flex; flex-direction: column; gap: 8px; }
.edit-content   { display: flex; flex-direction: column; gap: 4px; }

/* Detail grid inside session detail overlay */
.detail-grid {
  display: flex; flex-direction: column; gap: 8px;
}
@media (min-width: 768px) {
  .detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }
}

.detail-row {
  padding: 10px 12px; background: var(--surface3); border-radius: var(--radius-sm);
}
.detail-key { font-size: var(--text-sm); font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.05em; margin-bottom: 2px; }
.detail-val { font-size: var(--text-md); color: var(--text1); line-height: 1.4; }

/* ── Date info row in edit modal ── */
.date-info-row {
  font-size: var(--text-sm); color: var(--purple-lt);
  background: var(--purple-bg); border-radius: var(--radius-sm);
  padding: 8px 12px; margin: 6px 0 2px;
}

/* ── Time row in edit modal ── */
.time-row { display: flex; gap: 10px; margin-top: 2px; }
.time-col { flex: 1; display: flex; flex-direction: column; }

/* ── Time capture row (Sensorik angelegt/abgelegt: Feld + Jetzt-Button) ── */
.time-capture-row { display: flex; gap: 8px; align-items: center; }
.time-capture-row input[type="time"] { flex: 1; min-width: 0; }
.btn-time-now { white-space: nowrap; padding: 8px 12px; flex-shrink: 0; }

/* ── Tag manager inline edit row ── */
.tag-edit-row {
  padding: 8px 12px 10px;
  background: var(--surface2);
  border-radius: var(--radius-sm);
  margin-top: -4px;
  margin-bottom: 4px;
}
.tag-edit-input { width: 100%; margin-bottom: 0; }

#bew-form-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ══════════════════════════════════════════════════════
   BEWERTUNGSBOGEN
══════════════════════════════════════════════════════ */
.bew-dim-label {
  color: var(--purple-lt);
  font-size: var(--text-sm);
  font-weight: 700;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  margin-bottom: 14px;
}

.bew-items {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.bew-item {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.bew-item-label {
  font-size: var(--text-md);
  color: var(--text2);
  line-height: 1.4;
}

.bew-scale {
  display: flex;
  align-items: center;
  gap: 8px;
}

.bew-scale-endlabel {
  flex: 0 0 auto;
  font-size: var(--text-sm);
  color: var(--text3);
  line-height: 1.2;
  white-space: nowrap;
}
.bew-scale-endlabel-left  { text-align: right; }
.bew-scale-endlabel-right { text-align: left; }

.bew-scale-btns {
  display: flex;
  gap: 6px;
  flex: 1 1 auto;
  min-width: 0;
}

.bew-scale-btn-cell {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  justify-content: center;
}

.bew-pip-btn {
  width: 100%;
  max-width: 38px;
  aspect-ratio: 1 / 1;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border2);
  background: var(--surface3);
  color: var(--text2);
  font-size: var(--text-md);
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.12s;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
}

.bew-pip-btn:hover { background: var(--surface2); color: var(--text1); }

/* Note-spezifische Farben bei Selection */
.bew-pip-btn.selected.bew-pip-1 { background: var(--teal-bg);   border-color: var(--teal);   color: var(--teal-txt);   }
.bew-pip-btn.selected.bew-pip-2 { background: #1e3820;          border-color: #4caf50;        color: #80e880;           }
.bew-pip-btn.selected.bew-pip-3 { background: var(--amber-bg);  border-color: var(--amber);   color: var(--amber-txt);  }
.bew-pip-btn.selected.bew-pip-4 { background: #3a2c10;          border-color: #c88030;        color: #f0a850;           }
.bew-pip-btn.selected.bew-pip-5 { background: var(--coral-bg);  border-color: var(--coral);   color: var(--coral-txt);  }
.bew-pip-btn.selected.bew-pip-6 { background: #3a1010;          border-color: #c03030;        color: #f06060;           }

.bew-legend {
  background: var(--surface3);
}

.bew-legend-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
}

.bew-legend-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: var(--text-sm);
  color: var(--text2);
}

.bew-pip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border2);
  background: var(--surface2);
  font-size: var(--text-sm);
  font-weight: 700;
}

.bew-info-card {
  padding: 12px 14px;
}

.bew-existing-hint {
  font-size: var(--text-sm);
  color: var(--amber-txt);
  background: var(--amber-bg);
  border: 1px solid var(--amber);
  border-radius: var(--radius-sm);
  padding: 8px 12px;
}

.bew-new-hint {
  font-size: var(--text-md);
  color: var(--text2);
}

.bew-new-hint strong { color: var(--text1); }

@media (min-width: 480px) {
  .bew-pip-btn {
    max-width: 42px;
    font-size: var(--text-md);
  }
}

/* ══════════════════════════════════════════════════════
   UTILITIES
══════════════════════════════════════════════════════ */
.hidden { display: none !important; }

/* Scrollbar styling for desktop */
@media (min-width: 768px) {
  .screen::-webkit-scrollbar,
  .dialog-box::-webkit-scrollbar,
  .sidebar-nav::-webkit-scrollbar { width: 6px; }
  .screen::-webkit-scrollbar-track,
  .dialog-box::-webkit-scrollbar-track,
  .sidebar-nav::-webkit-scrollbar-track { background: transparent; }
  .screen::-webkit-scrollbar-thumb,
  .dialog-box::-webkit-scrollbar-thumb,
  .sidebar-nav::-webkit-scrollbar-thumb {
    background: var(--border2); border-radius: 3px;
  }
  .screen::-webkit-scrollbar-thumb:hover,
  .dialog-box::-webkit-scrollbar-thumb:hover { background: var(--text3); }
}

/* ══════════════════════════════════════════════════════
   SENSORIK-CHECKLISTE
══════════════════════════════════════════════════════ */
.sensorik-list { display: flex; flex-direction: column; gap: 8px; }

.sensorik-item {
  width: 100%;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px 16px;
  display: flex; align-items: center; gap: 14px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.12s, border-color 0.12s;
  text-align: left; font-family: inherit; font-size: inherit; color: inherit;
  user-select: none;
}
.sensorik-item:hover  { background: var(--surface2); border-color: var(--border2); }
.sensorik-item:active { background: var(--surface2); }
.sensorik-item.checked { background: var(--teal-bg); border-color: var(--teal); }

.sensorik-check {
  width: 26px; height: 26px; border-radius: 50%; flex-shrink: 0;
  border: 2px solid var(--border2);
  display: flex; align-items: center; justify-content: center;
  font-size: var(--text-md); font-weight: 700; color: #fff;
}
.sensorik-item.checked .sensorik-check { background: var(--teal); border-color: var(--teal); }

.sensorik-info { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.sensorik-name { font-size: var(--text-md); font-weight: 700; color: var(--text1); }
.sensorik-time { font-size: var(--text-sm); color: var(--text2); }
.sensorik-item.checked .sensorik-time { color: var(--teal-txt); }

/* ══════════════════════════════════════════════════════
   ABLAUF (Studien-Zeitleiste)
══════════════════════════════════════════════════════ */
/* Kompakte Personen-Kopfzeile: Label neben dem Dropdown statt darüber */
.ablauf-proband-card { padding: 10px 12px; }
.ablauf-proband-row { display: flex; gap: 8px; align-items: center; }
.ablauf-proband-row .field-select { flex: 1; min-width: 0; }
.ablauf-proband-label { margin-bottom: 0; flex-shrink: 0; white-space: nowrap; }
.ablauf-proband-card .ablauf-progress { margin-top: 8px; }

/* Kopfzeile der Vollbild-Dialoge (Teilnehmende verwalten / Export) */
.subview-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px;
}
.subview-title { font-size: var(--text-lg); font-weight: 700; color: var(--text1); }

.ablauf-progress { margin-top: 12px; }
.ablauf-progress-bar {
  height: 8px; border-radius: 999px;
  background: var(--surface3); border: 1px solid var(--border);
  overflow: hidden;
}
.ablauf-progress-bar span {
  display: block; height: 100%;
  background: var(--teal); border-radius: 999px;
  transition: width 0.3s ease;
}
.ablauf-progress-text { margin-top: 6px; font-size: var(--text-sm); color: var(--text2); }

/* schmal (Smartphone / Tablet hochkant): einspaltig, Detailspalte ausgeblendet */
.ablauf-layout { display: block; }
.ablauf-detail { display: none; }

.ablauf-timeline { display: flex; flex-direction: column; gap: 8px; }
.ablauf-step-wrap { display: flex; flex-direction: column; }

.ablauf-step {
  width: 100%;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-left: 4px solid var(--border2);
  border-radius: var(--radius);
  padding: 12px 14px;
  display: flex; align-items: center; gap: 12px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  transition: background 0.12s, border-color 0.12s;
  text-align: left; font-family: inherit; font-size: inherit; color: inherit;
  user-select: none;
}
.ablauf-step:hover  { background: var(--surface2); border-color: var(--border2); }
.ablauf-step:active { background: var(--surface2); }
.ablauf-step[data-state="teilweise"] {
  background: var(--amber-bg); border-color: var(--amber); border-left-color: var(--amber);
}
.ablauf-step[data-state="komplett"] {
  background: var(--teal-bg); border-color: var(--teal); border-left-color: var(--teal);
}

.ablauf-step-nr {
  width: 30px; min-width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); border: 1px solid var(--border2);
  font-size: var(--text-sm); font-weight: 700; color: var(--text2);
}
.ablauf-step[data-state="teilweise"] .ablauf-step-nr {
  background: var(--amber); border-color: var(--amber); color: #2a1f04;
}
.ablauf-step[data-state="komplett"] .ablauf-step-nr {
  background: var(--teal); border-color: var(--teal); color: #06231c;
}

.ablauf-step-body  { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex: 1; }
.ablauf-step-label { font-size: var(--text-md); font-weight: 700; color: var(--text1); }
.ablauf-step-sub   { font-size: var(--text-sm); color: var(--text2); }
.ablauf-step[data-state="teilweise"] .ablauf-step-sub { color: var(--amber-txt); }
.ablauf-step[data-state="komplett"] .ablauf-step-sub  { color: var(--teal-txt); }
.ablauf-step-chevron { color: var(--text3); font-size: var(--text-md); flex-shrink: 0; }

.ablauf-step-panel {
  margin-top: 6px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px;
}

.ablauf-detail-head {
  font-size: var(--text-md); font-weight: 700; color: var(--text1);
  margin-bottom: 12px;
}

/* Trainerbewertungsbogen-Abschnitt im Schritt-Detail */
.bew-section {
  margin-top: 14px; padding-top: 14px;
  border-top: 1px solid var(--border);
}
.bew-list { display: flex; flex-direction: column; gap: 6px; }
.bew-list-item {
  width: 100%; text-align: left; font-family: inherit; color: inherit;
  background: var(--surface3); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: 10px 12px;
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.bew-list-item:hover { background: var(--surface2); border-color: var(--border2); }
.bew-list-label { font-weight: 700; color: var(--text1); }
.bew-list-meta  { font-size: var(--text-sm); color: var(--text2); white-space: nowrap; }

/* Inline-Durchlauf (Schritt 6 Tutorial / Schritt 7 Hologate) */
.ablauf-sz-run { margin-bottom: 12px; }
.ablauf-sz-run + .ablauf-sz-run { padding-top: 12px; border-top: 1px solid var(--border); }
.ablauf-sz-label {
  width: 100%; font-family: inherit; font-size: var(--text-md); font-weight: 700;
  background: var(--surface3); border: 1px solid var(--border2);
  border-radius: var(--radius-sm); padding: 8px 10px; color: var(--text1);
}
/* Feste Durchlauf-Bezeichnung (Schritt 7 Hologate) — nicht editierbar, nur Überschrift */
.ablauf-sz-runname { font-weight: 700; color: var(--text1); font-size: var(--text-md); }
/* Reminder-Zeile (Schritt 6 Tutorial) — nicht abhakbar, nur Ablauf-Hinweis */
.ablauf-sz-reminder {
  display: flex; align-items: baseline; gap: 8px;
  padding: 8px 12px; font-size: var(--text-sm); color: var(--text3);
}
.ablauf-sz-reminder-mark { color: var(--text3); flex-shrink: 0; }
.ablauf-detail-empty { font-size: var(--text-sm); color: var(--text3); line-height: 1.5; }

/* Tablet/Desktop (ab 768px): Ablauf = linke Schritt-Leiste (eigene Scrollbar) +
   rechtes Detailfeld. Kein Inline-Aufklappen. */
@media (min-width: 768px) {
  #screen-ablauf.screen { overflow: hidden; }
  #screen-ablauf .screen-inner { min-height: 0; height: 100%; }

  .ablauf-layout {
    display: grid;
    grid-template-columns: minmax(280px, 360px) 1fr;
    gap: 20px;
    flex: 1;
    min-height: 0;
  }
  .ablauf-timeline {
    overflow-y: auto;
    min-height: 0;
    padding-right: 4px;
  }
  .ablauf-detail {
    display: block;
    overflow-y: auto;
    min-height: 0;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
  }
  .ablauf-step-chevron { display: none; }
  .ablauf-step.selected {
    border-color: var(--purple);
    box-shadow: inset 0 0 0 1px var(--purple);
  }
  /* schmale Detailspalte: Start/Ende untereinander statt nebeneinander */
  .ablauf-detail .edit-row-2 { grid-template-columns: 1fr; }
}

/* Keyboard focus styles for accessibility */
:focus-visible {
  outline: 2px solid var(--purple);
  outline-offset: 2px;
}
button:focus:not(:focus-visible),
input:focus:not(:focus-visible),
select:focus:not(:focus-visible),
textarea:focus:not(:focus-visible) { outline: none; }
