/* =========================================================
   Tägliches Deutsch — Design System & Styles
   ========================================================= */

/* --- Google Fonts (Lora for reading body) --- */
/* Loaded via <link> in index.html */

/* =========================================================
   1. DESIGN TOKENS (CSS custom properties)
   ========================================================= */
:root {
  /* Light theme (default) */
  --bg:          #FAF6EE;
  --surface:     #FFFDF8;
  --muted:       #F2EBDD;
  --text:        #2B2620;
  --text2:       #6F665B;
  --text3:       #A99E8E;
  --border:      #E7DDCC;
  --accent:      #0F8B7E;
  --accent-ink:  #fff;
  --warm:        #C77A22;
  --word-new:    #2563EB;
  --word-learning: #C77A22;
  --del:         #B23B3B;
  --ins-bg:      #DCF1E7;
  --ins-text:    #0F6B4E;
  --shadow-sm:   0 1px 3px rgba(43,38,32,.07), 0 1px 2px rgba(43,38,32,.04);
  --shadow-md:   0 4px 12px rgba(43,38,32,.10), 0 2px 4px rgba(43,38,32,.06);
  --shadow-lg:   0 12px 32px rgba(43,38,32,.14), 0 4px 8px rgba(43,38,32,.08);

  /* Grade colors */
  --grade-again: #B23B3B;
  --grade-hard:  #B5792A;
  --grade-good:  #0F8B7E;
  --grade-easy:  #3F7A52;

  /* Diff / error category colors */
  --err-grammar: #B23B3B;
  --err-word-order: #C2670F;
  --err-vocab:   #B5792A;
  --err-register: #0F8B7E;
  --err-case:    #2563EB;

  /* Typography */
  --font-ui:     system-ui, -apple-system, sans-serif;
  --font-read:   'Lora', ui-serif, Georgia, serif;

  /* Layout */
  --tab-h:       calc(56px + env(safe-area-inset-bottom));
  --topbar-h:    calc(52px + env(safe-area-inset-top));
  --radius-sm:   8px;
  --radius-md:   12px;
  --radius-lg:   18px;
  --radius-xl:   24px;

  /* Motion */
  --transition: 160ms ease;
}

/* Dark theme via media query */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg:          #1A1814;
    --surface:     #242220;
    --muted:       #2C2A28;
    --text:        #F0EDE6;
    --text2:       #A8A29E;
    --text3:       #6B6862;
    --border:      #3C3A37;
    --accent:      #2DD4BF;
    --accent-ink:  #04342C;
    --warm:        #D98A3D;
    --word-new:    #60A5FA;
    --word-learning: #D98A3D;
    --del:         #F87171;
    --ins-bg:      #14532D;
    --ins-text:    #86EFAC;
    --shadow-sm:   0 1px 3px rgba(0,0,0,.25);
    --shadow-md:   0 4px 12px rgba(0,0,0,.35);
    --shadow-lg:   0 12px 32px rgba(0,0,0,.45);
  }
}

/* Manual dark override */
[data-theme="dark"] {
  --bg:          #1A1814;
  --surface:     #242220;
  --muted:       #2C2A28;
  --text:        #F0EDE6;
  --text2:       #A8A29E;
  --text3:       #6B6862;
  --border:      #3C3A37;
  --accent:      #2DD4BF;
  --accent-ink:  #04342C;
  --warm:        #D98A3D;
  --word-new:    #60A5FA;
  --word-learning: #D98A3D;
  --del:         #F87171;
  --ins-bg:      #14532D;
  --ins-text:    #86EFAC;
  --shadow-sm:   0 1px 3px rgba(0,0,0,.25);
  --shadow-md:   0 4px 12px rgba(0,0,0,.35);
  --shadow-lg:   0 12px 32px rgba(0,0,0,.45);
}

/* Manual light override */
[data-theme="light"] {
  --bg:          #FAF6EE;
  --surface:     #FFFDF8;
  --muted:       #F2EBDD;
  --text:        #2B2620;
  --text2:       #6F665B;
  --text3:       #A99E8E;
  --border:      #E7DDCC;
  --accent:      #0F8B7E;
  --accent-ink:  #fff;
  --warm:        #C77A22;
  --word-new:    #2563EB;
  --word-learning: #C77A22;
  --del:         #B23B3B;
  --ins-bg:      #DCF1E7;
  --ins-text:    #0F6B4E;
  --shadow-sm:   0 1px 3px rgba(43,38,32,.07), 0 1px 2px rgba(43,38,32,.04);
  --shadow-md:   0 4px 12px rgba(43,38,32,.10), 0 2px 4px rgba(43,38,32,.06);
  --shadow-lg:   0 12px 32px rgba(43,38,32,.14), 0 4px 8px rgba(43,38,32,.08);
}

/* =========================================================
   2. RESET & BASE
   ========================================================= */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-ui);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100dvh;
  /* Prevent horizontal scroll */
  overflow-x: hidden;
}

a {
  color: var(--accent);
  text-decoration: none;
}

button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

img, svg {
  display: block;
  max-width: 100%;
}

/* Focus visible for keyboard nav */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    transition-duration: .01ms !important;
  }
}

/* =========================================================
   3. LAYOUT SHELL
   ========================================================= */
#app {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
}

/* Top bar */
.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: env(safe-area-inset-top) 1rem 0;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  padding-bottom: 8px;
  gap: .5rem;
}

.topbar__title {
  flex: 1;
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__back {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--accent);
  font-size: 1.4rem;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: background var(--transition);
}
.topbar__back:hover { background: var(--muted); }

.topbar__action {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  color: var(--text2);
  border-radius: var(--radius-sm);
  flex-shrink: 0;
  transition: background var(--transition);
}
.topbar__action:hover { background: var(--muted); }

/* Main scrollable area */
.main-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: var(--tab-h);
}

/* When no tab bar (login, writing with keyboard focus) */
.main-content--no-tabs {
  padding-bottom: calc(env(safe-area-inset-bottom) + 1rem);
}

/* Bottom tab bar */
.tabbar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  height: var(--tab-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  padding-bottom: env(safe-area-inset-bottom);
}

.tabbar__item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  color: var(--text3);
  font-size: .7rem;
  font-weight: 500;
  min-height: 44px;
  padding: 6px 0;
  transition: color var(--transition);
  cursor: pointer;
  border: none;
  background: none;
  font-family: inherit;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.tabbar__item--active {
  color: var(--accent);
}

.tabbar__item svg {
  width: 22px;
  height: 22px;
}

/* =========================================================
   4. COMMON COMPONENTS
   ========================================================= */

/* --- Page wrapper --- */
.page {
  padding: 1.25rem 1rem;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}

/* --- Card --- */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.card + .card {
  margin-top: .75rem;
}

.card__label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: .5rem;
}

.card__title {
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .35rem;
}

.card__body {
  font-size: .9rem;
  color: var(--text2);
  line-height: 1.5;
}

/* --- Buttons --- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  min-height: 44px;
  padding: .6rem 1.2rem;
  border-radius: var(--radius-md);
  font-size: .95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity var(--transition), background var(--transition);
  border: none;
  white-space: nowrap;
}

.btn:disabled {
  opacity: .4;
  cursor: not-allowed;
}

.btn--primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.btn--primary:not(:disabled):hover { opacity: .88; }

.btn--secondary {
  background: var(--muted);
  color: var(--text);
}
.btn--secondary:not(:disabled):hover { background: var(--border); }

.btn--ghost {
  background: transparent;
  color: var(--accent);
  border: 1.5px solid var(--accent);
}
.btn--ghost:not(:disabled):hover { background: var(--muted); }

.btn--danger {
  background: transparent;
  color: var(--del);
  border: 1.5px solid var(--del);
}

.btn--full {
  width: 100%;
}

.btn--sm {
  min-height: 36px;
  padding: .4rem .9rem;
  font-size: .85rem;
}

/* --- Pill / chip --- */
.chip {
  display: inline-flex;
  align-items: center;
  gap: .3rem;
  padding: .2rem .6rem;
  border-radius: 100px;
  font-size: .75rem;
  font-weight: 600;
  line-height: 1.4;
}

.chip--level {
  background: var(--muted);
  color: var(--text2);
}

.chip--accent {
  background: color-mix(in srgb, var(--accent) 15%, transparent);
  color: var(--accent);
}

.chip--warm {
  background: color-mix(in srgb, var(--warm) 15%, transparent);
  color: var(--warm);
}

.chip--contrast {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  cursor: pointer;
  border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent);
  transition: background var(--transition);
}
.chip--contrast:hover { background: color-mix(in srgb, var(--accent) 22%, transparent); }

/* --- Divider --- */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1rem 0;
}

/* --- Loading spinner --- */
.spinner {
  display: inline-block;
  width: 32px;
  height: 32px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; border-top-color: var(--accent); }
}

.spinner--sm {
  width: 18px;
  height: 18px;
  border-width: 2px;
}
.peek-card__loading {
  display: flex;
  align-items: center;
  gap: .6rem;
  color: var(--text2);
  font-size: .95rem;
  margin: .35rem 0 1rem;
}
.peek-card__cancel {
  width: 100%;
}

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 3rem 1rem;
  color: var(--text2);
  text-align: center;
}

.loading-state p {
  font-size: .95rem;
}

/* --- Toast / Snack --- */
.toast {
  position: fixed;
  bottom: calc(var(--tab-h) + .75rem);
  left: 50%;
  transform: translateX(-50%) translateY(0);
  background: var(--text);
  color: var(--bg);
  padding: .65rem 1.2rem;
  border-radius: 100px;
  font-size: .875rem;
  font-weight: 500;
  box-shadow: var(--shadow-md);
  z-index: 300;
  white-space: nowrap;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none;
}
.toast--visible {
  opacity: 1;
}

/* --- Form elements --- */
.form-group {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  margin-bottom: 1rem;
}

/* Self-service password change — a clean form card (cf. .admin-form), with even
   spacing so fields and the submit button share one rhythm. */
.pw-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
}
.pw-form .form-group,
.pw-form .login__error { margin-bottom: 0; }

.form-label {
  font-size: .85rem;
  font-weight: 600;
  color: var(--text2);
}

.form-input {
  font-family: inherit;
  font-size: 1rem;
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: .7rem .9rem;
  min-height: 44px;
  width: 100%;
  transition: border-color var(--transition);
  appearance: none;
  -webkit-appearance: none;
}

.form-input:focus {
  outline: none;
  border-color: var(--accent);
}

.form-input::placeholder { color: var(--text3); }

/* --- Select row --- */
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 56px;
  padding: .5rem 0;
  border-bottom: 1px solid var(--border);
}

.setting-row:last-child { border-bottom: none; }

.setting-row__label {
  font-size: .95rem;
  color: var(--text);
  font-weight: 500;
}

.setting-row__sub {
  font-size: .8rem;
  color: var(--text3);
  margin-top: 1px;
}

.setting-select {
  font-family: inherit;
  font-size: .9rem;
  font-weight: 600;
  color: var(--accent);
  background: var(--muted);
  border: none;
  border-radius: var(--radius-sm);
  padding: .4rem .7rem;
  min-height: 36px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  padding-right: 1.6rem;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' stroke='%230F8B7E' stroke-width='1.5' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .5rem center;
}

.setting-select:focus { outline: 2px solid var(--accent); }

/* =========================================================
   5. SCREEN — LOGIN
   ========================================================= */
.login-screen {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100dvh;
  padding: 2rem 1.5rem;
  padding-top: calc(env(safe-area-inset-top) + 2rem);
  padding-bottom: calc(env(safe-area-inset-bottom) + 2rem);
  background: var(--bg);
}

.login__icon {
  width: 72px;
  height: 72px;
  border-radius: 20px;
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-md);
}

.login__appname {
  font-size: clamp(1.4rem, 5vw, 1.8rem);
  font-weight: 700;
  color: var(--text);
  margin-bottom: .3rem;
  text-align: center;
}

.login__tagline {
  font-size: 1rem;
  color: var(--text2);
  margin-bottom: 2rem;
  text-align: center;
}

.login__form {
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 1.75rem 1.5rem;
  box-shadow: var(--shadow-md);
}

.login__error {
  background: color-mix(in srgb, var(--del) 12%, transparent);
  color: var(--del);
  border-radius: var(--radius-sm);
  padding: .65rem .9rem;
  font-size: .875rem;
  margin-bottom: 1rem;
  display: none;
}
.login__error--visible { display: block; }

.login__note {
  margin-top: 1rem;
  font-size: .78rem;
  color: var(--text3);
  text-align: center;
  line-height: 1.5;
}

/* =========================================================
   6. SCREEN — HOME (Heute)
   ========================================================= */
.home__greeting {
  margin-bottom: 1.5rem;
}

.home__greeting-text {
  font-size: clamp(1.25rem, 4.5vw, 1.5rem);
  font-weight: 700;
  color: var(--text);
}

.home__date {
  font-size: .875rem;
  color: var(--text3);
  margin-top: .15rem;
}

/* Primary story card */
.story-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  box-shadow: var(--shadow-sm);
  margin-bottom: .75rem;
}

.story-card--primary {
  background: linear-gradient(135deg,
    color-mix(in srgb, var(--accent) 8%, var(--surface)) 0%,
    var(--surface) 60%
  );
  border-color: color-mix(in srgb, var(--accent) 25%, var(--border));
}

.story-card__meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .65rem;
  flex-wrap: wrap;
}

.story-card__content {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.story-card__text { flex: 1; }

.story-card__title {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .3rem;
  line-height: 1.35;
}

.story-card__sub {
  font-size: .85rem;
  color: var(--text2);
}

/* Activity row */
.activity-row {
  margin-top: 1.5rem;
}

.activity-row__caption {
  font-size: .78rem;
  color: var(--text3);
  margin-bottom: .6rem;
  font-style: italic;
}

.activity-dots {
  display: flex;
  align-items: center;
  gap: .45rem;
}

.activity-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--muted);
  border: 1.5px solid var(--border);
  flex-shrink: 0;
  transition: background var(--transition);
}

.activity-dot--active {
  background: var(--accent);
  border-color: var(--accent);
}

.activity-dot--today {
  box-shadow: 0 0 0 2.5px var(--bg), 0 0 0 4px var(--accent);
}

.activity-dot--today.activity-dot--active {
  background: var(--accent);
}

/* Review nudge card */
.review-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  background: color-mix(in srgb, var(--warm) 10%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warm) 30%, var(--border));
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: .75rem;
}

.review-card__label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--warm);
  margin-bottom: .2rem;
}

.review-card__count {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

/* =========================================================
   7. SCREEN — LESEN (Read)
   ========================================================= */
.reading-body {
  font-family: var(--font-read);
  font-size: 1.125rem;
  line-height: 1.65;
  color: var(--text);
}

.reading-body p {
  margin-bottom: 1.1em;
}

/* Word tokens */
.word-token {
  cursor: pointer;
  border-radius: 3px;
  transition: background var(--transition);
  /* inline so text wraps naturally */
  display: inline;
  /* iOS: don't treat a tap as a text-selection gesture; snappier taps */
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

/* Keep punctuation/space tokens unclickable */
.word-token--punct {
  cursor: default;
  pointer-events: none;
}

.word-token--new {
  border-bottom: 2px solid var(--word-new);
  color: var(--word-new);
}

.word-token--learning {
  border-bottom: 2px solid var(--word-learning);
  color: var(--word-learning);
}

.word-token--active {
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  border-radius: 3px;
}

/* Story illustrations + their tappable vocab strip */
.scene-fig {
  margin: 1.6rem 0;
}
.scene-fig__img {
  display: block;
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: color-mix(in srgb, var(--warm) 8%, var(--surface));
  box-shadow: var(--shadow-sm);
}
.scene-vocab {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .65rem;
}
.scene-vocab__chip {
  border: 1px solid color-mix(in srgb, var(--warm) 35%, var(--border));
  background: color-mix(in srgb, var(--warm) 8%, var(--surface));
  color: var(--text);
  border-radius: 999px;
  padding: 6px 13px;
  font-family: var(--font-ui, inherit);
  font-size: .82rem;
  line-height: 1.2;
  cursor: pointer;
  min-height: 36px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition), border-color var(--transition);
}
.scene-vocab__chip:active {
  background: color-mix(in srgb, var(--warm) 18%, var(--surface));
}

/* "Illustrations are being made" banner */
.scene-pending {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin-bottom: 1.1rem;
  padding: .7rem .9rem;
  border-radius: var(--radius-md);
  background: color-mix(in srgb, var(--warm) 7%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--warm) 22%, var(--border));
  color: var(--text2);
  font-size: .85rem;
}

/* Peek card (bottom sheet) */
.peek-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.3);
  z-index: 150;
  opacity: 0;
  transition: opacity var(--transition);
  pointer-events: none; /* when hidden, must not swallow taps on content/tab bar */
}
.peek-backdrop--visible { opacity: 1; pointer-events: auto; }

.peek-card {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 151;
  background: var(--surface);
  border-top-left-radius: var(--radius-xl);
  border-top-right-radius: var(--radius-xl);
  border-top: 1px solid var(--border);
  padding: 1.25rem 1.25rem calc(env(safe-area-inset-bottom) + 1.25rem);
  box-shadow: var(--shadow-lg);
  transform: translateY(100%);
  transition: transform 240ms cubic-bezier(.32,.72,0,1);
  max-height: 70dvh;
  overflow-y: auto;
  pointer-events: none;
}

.peek-card--visible {
  transform: translateY(0);
  pointer-events: auto;
}

.peek-card__handle {
  width: 36px;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
  margin: 0 auto 1rem;
}

.peek-card__word {
  font-family: var(--font-read);
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: .25rem;
}

.peek-card__article {
  font-size: .9rem;
  color: var(--text3);
  margin-bottom: .5rem;
}

.peek-card__gloss {
  font-size: 1rem;
  color: var(--text2);
  margin-bottom: .3rem;
}

.peek-card__example {
  font-family: var(--font-read);
  font-size: .9rem;
  font-style: italic;
  color: var(--text3);
  margin-bottom: 1rem;
  line-height: 1.5;
}

.peek-card__actions {
  display: flex;
  gap: .65rem;
}

.peek-card__translate {
  margin-top: .9rem;
  padding-top: .85rem;
  border-top: 1px solid var(--border);
}
.peek-card__sentence {
  font-family: var(--font-read);
  font-size: .9rem;
  font-style: italic;
  color: var(--text2);
  line-height: 1.5;
  margin-bottom: .5rem;
}
.peek-card__trans {
  font-size: .95rem;
  color: var(--text);
  line-height: 1.45;
}
.peek-card__trans--en {
  margin-top: .3rem;
  font-size: .85rem;
  color: var(--text2);
}

/* --- Topic chips (library picker + settings interests) --- */
.topic-row { margin-bottom: 1rem; }
.topic-row__label { display: block; font-size: .8rem; color: var(--text2); margin-bottom: .5rem; }
.topic-chips { display: flex; flex-wrap: wrap; gap: .5rem; }
.topic-chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text2);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: .85rem;
  font-family: inherit;
  cursor: pointer;
  min-height: 40px;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition), color var(--transition), border-color var(--transition);
}
.topic-chip--active {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}
/* Tappable settings row (e.g. opens the Kosten screen) */
.setting-row--link {
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.setting-row--link:active { background: color-mix(in srgb, var(--accent) 6%, transparent); }
.setting-row--link svg { color: var(--text3); }

/* Cost dashboard */
.cost-hero {
  text-align: center;
  padding: 1.5rem 1rem 1.25rem;
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 18%, var(--border));
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
}
.cost-hero__label { font-size: .8rem; color: var(--text2); letter-spacing: .02em; }
.cost-hero__amount {
  font-size: 2.4rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  margin: .15rem 0 .1rem;
}
.cost-hero__sub { font-size: .78rem; color: var(--text3); }
.cost-empty { color: var(--text2); font-size: .9rem; line-height: 1.6; padding: .5rem .25rem; }

.cost-breakdown { margin-top: .5rem; }
.cost-row { margin-bottom: 1rem; }
.cost-row__head { display: flex; justify-content: space-between; align-items: baseline; gap: .5rem; margin-bottom: .35rem; }
.cost-row__name { font-size: .9rem; color: var(--text); }
.cost-row__amount { font-size: .9rem; font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; }
.cost-row__track { height: 8px; background: color-mix(in srgb, var(--border) 60%, transparent); border-radius: 999px; overflow: hidden; }
.cost-row__fill { height: 100%; background: var(--accent); border-radius: 999px; }
.cost-row__count { font-size: .72rem; color: var(--text3); margin-top: .25rem; }

.cost-stories { display: flex; flex-direction: column; gap: .55rem; }
.cost-story {
  border: 1px solid var(--border);
  background: var(--surface);
  border-radius: var(--radius-md);
  padding: .8rem .9rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
.cost-story:active { background: color-mix(in srgb, var(--accent) 6%, var(--surface)); }
.cost-story__top { display: flex; justify-content: space-between; align-items: baseline; gap: .75rem; }
.cost-story__title { font-family: var(--font-read); font-size: 1rem; color: var(--text); }
.cost-story__total { font-weight: 600; color: var(--text); font-variant-numeric: tabular-nums; white-space: nowrap; }
.cost-story__split { font-size: .76rem; color: var(--text3); margin-top: .2rem; }

.cost-note { font-size: .74rem; color: var(--text3); line-height: 1.6; margin-top: 1.5rem; }

/* Per-story cost line in the reader */
.lesen-cost {
  font-size: .74rem;
  color: var(--text3);
  font-variant-numeric: tabular-nums;
  margin: -.5rem 0 1rem;
}

.settings-interests { margin-top: 1.5rem; }
.settings-interests__label { font-size: .95rem; font-weight: 500; color: var(--text); margin-bottom: .2rem; }
.settings-interests__hint { font-size: .8rem; color: var(--text3); margin-bottom: .65rem; }

/* Grammar spotlight */
.spotlight-card {
  background: color-mix(in srgb, var(--accent) 6%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--accent) 20%, var(--border));
  border-radius: var(--radius-lg);
  padding: 1.35rem;
  margin-top: 1.5rem;
}

.spotlight-card__label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .4rem;
}

.spotlight-card__title {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .6rem;
}

.spotlight-card__explanation {
  font-size: .95rem;
  color: var(--text2);
  line-height: 1.6;
  margin-bottom: .75rem;
}

.spotlight-frames {
  display: flex;
  flex-direction: column;
  gap: .5rem;
  margin: .75rem 0;
}

.spotlight-frame {
  font-family: var(--font-read);
  font-size: .95rem;
  font-style: italic;
  color: var(--text);
  background: var(--muted);
  border-left: 3px solid var(--accent);
  padding: .55rem .75rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  line-height: 1.5;
}

/* Tasks section */
.tasks-section {
  margin-top: 1.25rem;
}

.task-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1rem;
  margin-bottom: .65rem;
}

.task-item__type {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: .4rem;
}

.task-item__prompt {
  font-size: .95rem;
  color: var(--text);
  line-height: 1.5;
}

/* =========================================================
   8. SCREEN — SCHREIBEN (Write/Correct)
   ========================================================= */
.write-screen {
  display: flex;
  flex-direction: column;
  /* fills parent, used for keyboard avoidance */
}

.prompt-card {
  background: var(--muted);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
  font-size: .95rem;
  color: var(--text2);
  line-height: 1.5;
  border-left: 3px solid var(--accent);
}

.prompt-card__label {
  font-size: .7rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: .3rem;
}

.write-area {
  font-family: var(--font-read);
  font-size: 1rem;  /* ≥ 16px to prevent iOS zoom */
  color: var(--text);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-md);
  padding: .9rem;
  width: 100%;
  min-height: 160px;
  resize: vertical;
  line-height: 1.65;
  transition: border-color var(--transition);
}

.write-area:focus {
  outline: none;
  border-color: var(--accent);
}

.write-char-hint {
  font-size: .78rem;
  color: var(--text3);
  margin-top: .3rem;
  text-align: right;
}

/* Correction result */
.correction-result {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: .5rem;
}

.reassurance-box {
  background: var(--ins-bg);
  color: var(--ins-text);
  border-radius: var(--radius-md);
  padding: 1rem 1.1rem;
  font-size: .95rem;
  line-height: 1.5;
  font-weight: 500;
}

.text-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.text-panel__header {
  padding: .6rem 1rem;
  background: var(--muted);
  border-bottom: 1px solid var(--border);
  font-size: .78rem;
  font-weight: 600;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--text3);
}

.text-panel__body {
  padding: .9rem 1rem;
  font-family: var(--font-read);
  font-size: .95rem;
  line-height: 1.65;
  color: var(--text);
}

/* Diff highlights */
.diff-del {
  color: var(--del);
  text-decoration: line-through;
  text-decoration-color: var(--del);
  text-decoration-thickness: 2px;
}

.diff-ins {
  background: var(--ins-bg);
  color: var(--ins-text);
  border-radius: 3px;
  padding: 0 .2em;
  font-weight: 600;
}

/* Changes list */
.changes-list {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

.change-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .85rem 1rem;
}

.change-item__header {
  display: flex;
  align-items: flex-start;
  gap: .5rem;
  margin-bottom: .4rem;
  flex-wrap: wrap;
}

.change-item__original {
  font-family: var(--font-read);
  font-size: .9rem;
  color: var(--del);
  text-decoration: line-through;
  word-break: break-word;
}

.change-item__arrow {
  color: var(--text3);
  font-size: .85rem;
  flex-shrink: 0;
  margin-top: 1px;
}

.change-item__corrected {
  font-family: var(--font-read);
  font-size: .9rem;
  font-weight: 600;
  color: var(--ins-text);
  word-break: break-word;
}

.change-item__note {
  font-size: .85rem;
  color: var(--text2);
  line-height: 1.5;
}

/* Error category chip colors */
.chip--grammar  { background: color-mix(in srgb, var(--err-grammar) 14%, transparent);     color: var(--err-grammar); }
.chip--wordorder{ background: color-mix(in srgb, var(--err-word-order) 14%, transparent);  color: var(--err-word-order); }
.chip--vocab    { background: color-mix(in srgb, var(--err-vocab) 14%, transparent);       color: var(--err-vocab); }
.chip--register { background: color-mix(in srgb, var(--err-register) 14%, transparent);    color: var(--err-register); }
.chip--case     { background: color-mix(in srgb, var(--err-case) 14%, transparent);        color: var(--err-case); }

/* Patterns list */
.patterns-section__title {
  font-size: .85rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .65rem;
  letter-spacing: .01em;
}

.pattern-item {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: .85rem 1rem;
  margin-bottom: .55rem;
}

.pattern-item__num {
  font-size: .7rem;
  font-weight: 700;
  color: var(--accent);
  margin-bottom: .25rem;
  text-transform: uppercase;
  letter-spacing: .06em;
}

.pattern-item__title {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .3rem;
}

.pattern-item__contrast {
  font-size: .85rem;
  color: var(--text2);
  margin-top: .25rem;
  line-height: 1.5;
}

/* Accordion */
.accordion {
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.accordion__trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: .85rem 1rem;
  background: var(--muted);
  font-size: .9rem;
  font-weight: 600;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
  border: none;
  text-align: left;
  min-height: 44px;
  gap: .5rem;
}

.accordion__icon {
  color: var(--text3);
  transition: transform var(--transition);
  flex-shrink: 0;
}

.accordion--open .accordion__icon {
  transform: rotate(180deg);
}

.accordion__body {
  padding: .85rem 1rem;
  font-size: .9rem;
  color: var(--text2);
  line-height: 1.6;
  display: none;
  background: var(--surface);
}

.accordion--open .accordion__body {
  display: block;
}

/* Bottom action bar for write screen */
.write-actions {
  display: flex;
  gap: .65rem;
  padding: .75rem 0;
  padding-bottom: calc(env(safe-area-inset-bottom) + .75rem);
  background: var(--bg);
  position: sticky;
  bottom: 0;
  margin: 0 -1rem;
  padding-left: 1rem;
  padding-right: 1rem;
  border-top: 1px solid var(--border);
}

/* =========================================================
   9. SCREEN — WIEDERHOLUNG (Review)
   ========================================================= */
.review-progress {
  display: flex;
  align-items: center;
  gap: .75rem;
  margin-bottom: 1.25rem;
}

.review-progress__bar {
  flex: 1;
  height: 5px;
  background: var(--muted);
  border-radius: 3px;
  overflow: hidden;
}

.review-progress__fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  transition: width 300ms ease;
}

.review-progress__label {
  font-size: .8rem;
  color: var(--text3);
  white-space: nowrap;
  font-weight: 600;
}

.review-card-face {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  padding: 2rem 1.5rem;
  box-shadow: var(--shadow-md);
  text-align: center;
  min-height: 200px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  margin-bottom: 1.25rem;
}

.review-card-face__type {
  font-size: .7rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: .25rem;
}

.review-card-face__front {
  font-family: var(--font-read);
  font-size: clamp(1.4rem, 6vw, 2rem);
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}

.review-card-face__article {
  font-size: 1rem;
  color: var(--text3);
}

/* Revealed back */
.review-back {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  width: 100%;
  text-align: left;
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}

.review-back__gloss {
  font-size: 1rem;
  color: var(--text2);
}

.review-back__example {
  font-family: var(--font-read);
  font-size: .9rem;
  font-style: italic;
  color: var(--text3);
  line-height: 1.5;
}

.review-back__explanation {
  font-size: .9rem;
  color: var(--text2);
  line-height: 1.55;
}

/* Grade buttons */
.grade-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .5rem;
  margin-bottom: 1rem;
}

.grade-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: .2rem;
  padding: .6rem .3rem;
  border-radius: var(--radius-md);
  min-height: 60px;
  cursor: pointer;
  border: 2px solid transparent;
  font-family: inherit;
  transition: opacity var(--transition), transform var(--transition);
}

.grade-btn:active { transform: scale(.96); }

.grade-btn__label {
  font-size: .85rem;
  font-weight: 700;
  color: #fff;
}

.grade-btn__interval {
  font-size: .7rem;
  font-weight: 500;
  color: rgba(255,255,255,.75);
  white-space: nowrap;
}

.grade-btn--again { background: var(--grade-again); }
.grade-btn--hard  { background: var(--grade-hard); }
.grade-btn--good  { background: var(--grade-good); }
.grade-btn--easy  { background: var(--grade-easy); }

/* Review done screen */
.review-done {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 3rem 1.5rem;
  gap: 1rem;
}

.review-done__icon {
  font-size: 3rem;
  line-height: 1;
  color: var(--accent);
}

.review-done__title {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text);
}

.review-done__sub {
  font-size: .95rem;
  color: var(--text2);
  max-width: 280px;
  line-height: 1.5;
}

.review-done__note {
  font-size: .75rem;
  color: var(--text3);
  margin-top: .5rem;
}

/* =========================================================
   10. SCREEN — GRAMMATIK
   ========================================================= */
.grammar-list {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.grammar-point {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.grammar-point__title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: .4rem;
}

.grammar-point__explanation {
  font-size: .9rem;
  color: var(--text2);
  line-height: 1.55;
  margin-bottom: .65rem;
}

.grammar-point__frames {
  display: flex;
  flex-direction: column;
  gap: .35rem;
  margin-top: .55rem;
}

.grammar-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3.5rem 1.5rem;
  text-align: center;
  gap: .75rem;
  color: var(--text2);
}

.grammar-empty__icon {
  color: var(--text3);
  opacity: .6;
}

.grammar-empty__text {
  font-size: .95rem;
  line-height: 1.6;
  max-width: 260px;
}

/* In-review badge */
.badge-review {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  font-size: .68rem;
  font-weight: 600;
  letter-spacing: .06em;
  text-transform: uppercase;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 100px;
  padding: .15rem .5rem;
}

/* =========================================================
   11. SCREEN — EINSTELLUNGEN (Settings)
   ========================================================= */
.settings-avatar {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  margin-bottom: 1.25rem;
  box-shadow: var(--shadow-sm);
}

.settings-avatar__initials {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: 700;
  flex-shrink: 0;
}

.settings-avatar__name {
  font-size: 1rem;
  font-weight: 600;
  color: var(--text);
}

.settings-avatar__email {
  font-size: .82rem;
  color: var(--text3);
  margin-top: 1px;
  word-break: break-all;
}

.settings-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 0 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow-sm);
}

/* =========================================================
   12. UTILITY HELPERS
   ========================================================= */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  white-space: nowrap;
  border: 0;
}

.text-center { text-align: center; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-sm { gap: .5rem; }

/* Section heading */
.section-heading {
  font-size: .78rem;
  font-weight: 700;
  letter-spacing: .09em;
  text-transform: uppercase;
  color: var(--text3);
  margin-bottom: .6rem;
  margin-top: 1.35rem;
}

.section-heading:first-child { margin-top: 0; }

/* Inline icon button */
.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  color: var(--text2);
  background: none;
  border: none;
  cursor: pointer;
  transition: background var(--transition), color var(--transition);
  flex-shrink: 0;
}
.icon-btn:hover { background: var(--muted); color: var(--text); }

/* =========================================================
   13. SCREEN — BIBLIOTHEK (Story Library)
   ========================================================= */
.bibliothek-list {
  display: flex;
  flex-direction: column;
  gap: .65rem;
}

/* Individual story card in the list */
.bibliothek-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1.1rem 1.25rem;
  box-shadow: var(--shadow-sm);
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  transition: background var(--transition), box-shadow var(--transition);
  display: flex;
  flex-direction: column;
  gap: .3rem;
}

.bibliothek-card:hover,
.bibliothek-card:focus-visible {
  background: color-mix(in srgb, var(--accent) 5%, var(--surface));
  box-shadow: var(--shadow-md);
}

.bibliothek-card__top {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-bottom: .15rem;
}

/* Unread indicator dot */
.bibliothek-unread {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  flex-shrink: 0;
  margin-left: auto;
}

.bibliothek-card__title {
  font-family: var(--font-read);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.35;
}

.bibliothek-card__topic {
  font-size: .875rem;
  color: var(--text2);
}

.bibliothek-card__meta {
  font-size: .78rem;
  color: var(--text3);
  margin-top: .1rem;
}

/* Empty state */
.bibliothek-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem 1.5rem;
  text-align: center;
  gap: .75rem;
  color: var(--text2);
}

.bibliothek-empty__icon {
  color: var(--text3);
  opacity: .55;
}

.bibliothek-empty__text {
  font-size: .95rem;
  line-height: 1.6;
  max-width: 260px;
}

/* =========================================================
   14. RESPONSIVE (desktop widening)
   ========================================================= */
@media (min-width: 600px) {
  .page {
    padding: 1.5rem 1.5rem;
  }

  .grade-buttons {
    gap: .75rem;
  }

  .grade-btn {
    min-height: 68px;
  }

  .peek-card {
    left: 50%;
    right: auto;
    transform: translateX(-50%) translateY(100%);
    width: 480px;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border);
  }

  .peek-card--visible {
    transform: translateX(-50%) translateY(0);
  }
}

/* =========================================================
   15. SCREEN — ADMIN / VERWALTUNG
   ========================================================= */

/* --- Page wrapper ---
   The generic .page already provides padding and max-width.
   We only add a small bottom breathing room. */
.admin-page {
  padding-bottom: 2rem;
}

/* -------------------------------------------------------
   ADD-USER BLOCK
   ------------------------------------------------------- */

/* Container that separates the add-user section from the
   user list below it. */
.admin-add {
  margin-bottom: 1.5rem;
}

/* The collapsible form revealed after clicking "+ Neuer Nutzer".
   Uses the [hidden] attribute for hide/show — no display override
   needed here. The card look matches .settings-section / .card. */
.admin-form {
  margin-top: .75rem;
  padding: 1.25rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
/* Author `display` overrides the UA [hidden] rule, so restore it explicitly. */
.admin-form[hidden] { display: none; }

/* Initial-feature switches inside the add-user form, visually
   separated from the text fields above by a subtle rule. */
.admin-form__features {
  border-top: 1px solid var(--border);
  padding-top: 1rem;
  margin-top: .25rem;
  display: flex;
  flex-direction: column;
  gap: .15rem;
}

/* -------------------------------------------------------
   FEATURE SWITCH ROWS  (shared by form + user cards)
   ------------------------------------------------------- */

/* Flex row: text block left, toggle right.
   Mirrors the rhythm of .setting-row but lighter (no border-bottom
   by default — contexts add their own dividers). */
.admin-feature {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: .45rem 0;
  gap: .75rem;
}

/* Primary label text — matches .setting-row__label weight. */
.admin-feature__label {
  font-size: .95rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.35;
}

/* Supplementary hint beneath the label. */
.admin-feature__hint {
  font-size: .78rem;
  color: var(--text3);
  margin-top: 1px;
  line-height: 1.4;
}

/* -------------------------------------------------------
   TOGGLE SWITCH  (styled checkbox)
   ------------------------------------------------------- */

/* Track wrapper — fixed size so it never shifts layout. */
.switch {
  position: relative;
  display: inline-flex;
  width: 44px;
  height: 26px;
  flex-shrink: 0;
}

/* The real <input> is kept accessible but visually hidden. */
.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  margin: 0;
  cursor: pointer;
  z-index: 1;
}

/* The pill-shaped track. The ::before pseudo-element is the knob. */
.switch__slider {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: var(--muted);
  border: 1.5px solid var(--border);
  transition: background var(--transition), border-color var(--transition);
  pointer-events: none;
}

/* Knob */
.switch__slider::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 3px;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--surface);
  box-shadow: var(--shadow-sm);
  transition: transform var(--transition), background var(--transition);
}

/* Checked state: accent track + knob slides right. */
.switch input:checked + .switch__slider {
  background: var(--accent);
  border-color: var(--accent);
}

.switch input:checked + .switch__slider::before {
  transform: translateY(-50%) translateX(18px);
  background: var(--accent-ink);
}

/* Focus-visible ring using box-shadow so it works on the pill shape. */
.switch input:focus-visible + .switch__slider {
  outline: none;
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--accent);
}

/* Disabled state: muted and non-interactive. */
.switch input:disabled {
  cursor: not-allowed;
}

.switch input:disabled + .switch__slider {
  opacity: .5;
}

/* -------------------------------------------------------
   USER CARDS LIST
   ------------------------------------------------------- */

/* Vertical stack of user cards. */
.admin-users {
  display: flex;
  flex-direction: column;
  gap: .75rem;
  margin-top: .5rem;
}

/* Individual user card — matches .card conventions. */
.admin-user {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 1rem;
  box-shadow: var(--shadow-sm);
}

/* De-emphasise blocked accounts; left accent border in --del. */
.admin-user--blocked {
  opacity: .72;
  border-left: 3px solid var(--del);
}

/* Card header row: identity left, badge chips right. */
.admin-user__head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: .65rem;
}

/* Left identity block */
.admin-user__id {
  min-width: 0; /* allow text truncation inside flex */
}

.admin-user__name {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  line-height: 1.3;
}

.admin-user__email {
  font-size: .8rem;
  color: var(--text2);
  margin-top: 2px;
  word-break: break-all;
  line-height: 1.35;
}

/* Badge chip cluster on the right — wraps on narrow screens. */
.admin-user__badges {
  display: flex;
  gap: .35rem;
  flex-wrap: wrap;
  flex-shrink: 0;
  align-items: flex-start;
}

/* -------------------------------------------------------
   BADGE CHIP COLOR VARIANTS
   (extend the base .chip defined in section 4)
   ------------------------------------------------------- */

/* Admin role — accent tint, matches .chip--accent pattern. */
.chip--admin {
  background: color-mix(in srgb, var(--accent) 14%, transparent);
  color: var(--accent);
}

/* Blocked status — del tint. */
.chip--blocked {
  background: color-mix(in srgb, var(--del) 13%, transparent);
  color: var(--del);
}

/* "You" indicator — neutral muted. */
.chip--self {
  background: var(--muted);
  color: var(--text2);
}

/* -------------------------------------------------------
   USER STATS GRID
   ------------------------------------------------------- */

/* Responsive mini-grid of stat cells. Bordered top and bottom
   to visually separate from head and features. */
.admin-user__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(64px, 1fr));
  gap: .5rem;
  margin: .75rem 0;
  padding: .6rem 0;
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

/* Individual stat cell — centred column. */
.admin-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: .1rem;
}

.admin-stat__value {
  font-size: .95rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  line-height: 1.2;
}

.admin-stat__label {
  font-size: .68rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text3);
  line-height: 1.3;
}

/* -------------------------------------------------------
   PER-USER FEATURE SWITCHES WRAPPER
   ------------------------------------------------------- */

/* Small gap between the .admin-feature rows in a user card. */
.admin-user__features {
  display: flex;
  flex-direction: column;
  gap: .1rem;
}

/* -------------------------------------------------------
   MUTED NOTE TEXT
   ------------------------------------------------------- */

/* Used for "Alle Funktionen" note (admin has all) and the
   empty-events placeholder. */
.admin-user__allnote {
  font-size: .8rem;
  color: var(--text3);
  font-style: italic;
  line-height: 1.45;
  padding: .25rem 0;
}

/* -------------------------------------------------------
   ACTIONS ROW + EXPANDED DETAIL PANEL
   ------------------------------------------------------- */

/* Action button row — wraps if there isn't enough room. */
.admin-user__actions {
  display: flex;
  gap: .5rem;
  margin-top: .75rem;
  flex-wrap: wrap;
}

/* The expandable detail panel uses [hidden] for hide/show.
   A top border separates it from the actions row above. */
.admin-user__detail {
  margin-top: .75rem;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}

/* Small uppercase-ish label inside the detail panel
   (e.g. "Aktivität" or "Zahlungsereignisse"). */
.admin-detail__label {
  font-size: .78rem;
  font-weight: 600;
  color: var(--text2);
  letter-spacing: .04em;
  margin-bottom: .4rem;
}

/* Vertical list of billing/event rows. */
.admin-events {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  margin-top: .4rem;
}

/* Single event row: name | date | amount — compact and aligned. */
.admin-event {
  display: flex;
  align-items: baseline;
  gap: .5rem;
}

.admin-event__name {
  flex: 1;
  font-size: .82rem;
  color: var(--text2);
  line-height: 1.35;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.admin-event__date {
  font-size: .72rem;
  color: var(--text3);
  white-space: nowrap;
  flex-shrink: 0;
}

.admin-event__usd {
  font-size: .82rem;
  font-weight: 600;
  color: var(--text);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  margin-left: auto;
  flex-shrink: 0;
}

/* -------------------------------------------------------
   ACTIVITY DOTS INSIDE DETAIL PANEL
   Allow the 30-dot strip to wrap on narrow cards.
   (Overrides the flex no-wrap assumption in .activity-dots)
   ------------------------------------------------------- */
.admin-user__detail .activity-dots {
  flex-wrap: wrap;
  gap: .4rem;
}
