/* ========== Schrift (lokal gehostet, Inter Variable v20) ========== */
/* Selbst gehostet statt Google Fonts CDN: kein Drittanbieter-Request (Privacy/DSGVO) und offline verfügbar. */
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../fonts/inter-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'Inter';
  font-style: normal;
  font-weight: 300 700;
  font-display: swap;
  src: url('../fonts/inter-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}

/* ========== Reset ========== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { touch-action: manipulation; }

/* ========== Light Theme (Default / Mobile First) ========== */
:root, [data-theme="light"] {
  --primary: #009688;
  --primary-dark: #00796b;
  --primary-glow: rgba(0, 150, 136, 0.25);
  --accent: #ab47bc;
  --accent-dark: #8e24aa;
  --accent-glow: rgba(171, 71, 188, 0.3);
  --danger: #e53935;
  --bg-base: #f0f4f8;
  --bg-elevated: #ffffff;
  --bg-subtle: #f7f9fb;
  --text-primary: #1b2a3d;
  --text-secondary: #546e7a;
  --text-muted: #90a4ae;
  --border: #e0e8ee;
  --border-subtle: #edf2f7;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.04);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.08), 0 1px 4px rgba(0,0,0,0.04);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.12);
  --radius: 14px;
  --radius-lg: 20px;
  --radius-full: 100px;
  --ease: cubic-bezier(0.4, 0, 0.2, 1);
  color-scheme: light;
}

/* ========== Dark Theme ========== */
[data-theme="dark"] {
  --primary: #4db6ac;
  --primary-dark: #00897b;
  --primary-glow: rgba(77, 182, 172, 0.2);
  --accent: #ce93d8;
  --accent-dark: #ab47bc;
  --accent-glow: rgba(206, 147, 216, 0.25);
  --danger: #ef5350;
  --bg-base: #0d1117;
  --bg-elevated: #161b22;
  --bg-subtle: #1c2128;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #545d68;
  --border: #21262d;
  --border-subtle: #1c2128;
  --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
  --shadow-sm: 0 1px 4px rgba(0,0,0,0.25);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.35);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
  color-scheme: dark;
}

/* ========== Auto (System Preference) ========== */
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] {
    --primary: #4db6ac;
    --primary-dark: #00897b;
    --primary-glow: rgba(77, 182, 172, 0.2);
    --accent: #ce93d8;
    --accent-dark: #ab47bc;
    --accent-glow: rgba(206, 147, 216, 0.25);
    --danger: #ef5350;
    --bg-base: #0d1117;
    --bg-elevated: #161b22;
    --bg-subtle: #1c2128;
    --text-primary: #e6edf3;
    --text-secondary: #8b949e;
    --text-muted: #545d68;
    --border: #21262d;
    --border-subtle: #1c2128;
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.2);
    --shadow-sm: 0 1px 4px rgba(0,0,0,0.25);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.35);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
    color-scheme: dark;
  }
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-base);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden;
  height: 100vh;
  height: 100dvh;
}

/* ========== App Shell ========== */
.app {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  /* Safe-area additiv: 16px Designabstand PLUS Geräte-Inset (Notch/Home-Indicator) */
  padding-top: calc(16px + env(safe-area-inset-top));
  padding-bottom: calc(16px + env(safe-area-inset-bottom));
  height: 100vh;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ========== Header ========== */
.header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 20px;
}
.header-title {
  display: flex;
  flex-direction: column;
}
.header h1 {
  font-size: 1.5em;
  font-weight: 700;
  color: var(--primary);
  letter-spacing: -0.03em;
  line-height: 1.2;
}
.header p {
  font-size: 0.78em;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ========== Theme Toggle ========== */
.theme-toggle {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease);
  color: var(--text-secondary);
  font-size: 1.1em;
  padding: 0;
}
.theme-toggle:active {
  transform: scale(0.92);
}
.theme-toggle svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ========== Info Button (Header) ========== */
.info-btn {
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s var(--ease);
  flex-shrink: 0;
}
.info-btn:active {
  transform: scale(0.92);
}
.info-btn img {
  width: 18px;
  height: 18px;
  opacity: 0.45;
}
[data-theme="dark"] .info-btn img,
[data-theme="dark"] .theme-toggle img {
  filter: invert(1);
}
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] .info-btn img {
    filter: invert(1);
  }
}

/* ========== Aktiver Zaehler ========== */
.live-counter {
  text-align: center;
  font-weight: 600;
  font-size: 0.92em;
  padding: 10px 20px;
  border-radius: var(--radius-full);
  margin: 0 auto 10px;
  display: none;
  letter-spacing: -0.01em;
  transition: all 0.3s var(--ease);
}
.live-counter.activeWehe {
  display: block;
  background: linear-gradient(135deg, rgba(171,71,188,0.12), rgba(142,36,170,0.18));
  color: var(--accent);
  box-shadow: 0 0 20px var(--accent-glow);
  animation: counterGlow 2s ease-in-out infinite;
}
.live-counter.activePause {
  display: block;
  background: linear-gradient(135deg, rgba(0,150,136,0.1), rgba(0,121,107,0.15));
  color: var(--primary);
  box-shadow: 0 0 12px var(--primary-glow);
}
@keyframes counterGlow {
  0%, 100% { box-shadow: 0 0 20px var(--accent-glow); }
  50% { box-shadow: 0 0 30px var(--accent-glow), 0 0 60px rgba(171,71,188,0.08); }
}

/* ========== Bottom Area (Button + Actions) ========== */
.bottom-area {
  flex-shrink: 0;
  padding-top: 12px;
}

/* ========== Button Row ========== */
.btn-row {
  display: flex;
  gap: 10px;
  margin-bottom: 10px;
  align-items: stretch;
}

/* ========== Main Button ========== */
.main-btn {
  flex: 1;
  padding: 18px;
  font-size: 1.1em;
  font-weight: 600;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-lg);
  color: #fff;
  cursor: pointer;
  transition: all 0.2s var(--ease);
  position: relative;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  box-shadow: 0 4px 20px var(--primary-glow), var(--shadow-sm);
}
.main-btn:active {
  transform: scale(0.97);
}
.main-btn.stopp {
  background: linear-gradient(135deg, var(--accent), var(--accent-dark));
  box-shadow: 0 4px 20px var(--accent-glow), var(--shadow-sm);
  animation: btnPulse 1.8s ease-in-out infinite;
}
@keyframes btnPulse {
  0%, 100% { box-shadow: 0 4px 20px var(--accent-glow), var(--shadow-sm); }
  50% { box-shadow: 0 4px 32px var(--accent-glow), 0 0 60px rgba(171,71,188,0.1), var(--shadow-sm); }
}

/* ========== Undo Button ========== */
.undo-btn {
  width: 56px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elevated);
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  font-size: 0.7em;
  font-weight: 500;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  -webkit-tap-highlight-color: transparent;
  transition: all 0.2s var(--ease);
  animation: undoSlideIn 0.25s var(--ease);
}
.undo-btn.visible {
  display: flex;
}
.undo-btn:active {
  transform: scale(0.92);
  background: var(--bg-subtle);
}
.undo-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.undo-timer {
  position: absolute;
  bottom: 4px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 2px;
  border-radius: 1px;
  background: var(--text-muted);
  opacity: 0.3;
  animation: undoTimerShrink 5s linear forwards;
}
@keyframes undoSlideIn {
  from { opacity: 0; transform: translateX(10px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes undoTimerShrink {
  from { width: 24px; }
  to { width: 0px; }
}

/* ========== Stats Grid ========== */
.stats {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 16px;
}
.stats.hidden { display: none; }
.stat-card {
  background: var(--bg-elevated);
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.stat-label {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 0.65em;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 4px;
}
.stat-label svg {
  width: 12px;
  height: 12px;
  stroke: var(--text-muted);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
}
.stat-value {
  font-size: 1.25em;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

/* ========== Data Table ========== */
.table-wrap {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-xs);
  min-height: 0;
}
.table-wrap::-webkit-scrollbar { width: 3px; }
.table-wrap::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.78em;
}
thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.82em;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 10px 10px;
  text-align: left;
  border-bottom: 2px solid var(--border);
}
td {
  padding: 10px 10px;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-variant-numeric: tabular-nums;
}
tbody tr:last-child td { border-bottom: none; }
.row-delete {
  width: 24px;
  height: 24px;
  border: none;
  border-radius: 50%;
  background: none;
  color: var(--text-muted);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: all 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent;
  opacity: 0.4;
}
.row-delete:active {
  transform: scale(0.85);
  opacity: 1;
  color: var(--danger);
  background: rgba(229,57,53,0.08);
}
.row-delete svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
td.td-delete {
  padding: 6px 4px 6px 0;
  width: 28px;
  text-align: center;
}
th.th-delete {
  width: 28px;
  padding: 10px 4px 10px 0;
}

/* ========== Empty State ========== */
.empty {
  text-align: center;
  padding: 36px 20px;
  color: var(--text-muted);
}
.empty-icon {
  font-size: 2em;
  margin-bottom: 10px;
  opacity: 0.35;
}
.empty-text {
  font-size: 0.85em;
  line-height: 1.5;
}

/* ========== Footer Actions ========== */
.actions {
  display: flex;
  gap: 8px;
}
.action-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  padding: 10px 8px;
  font-size: 0.72em;
  font-weight: 500;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.action-btn:active {
  transform: scale(0.96);
  background: var(--bg-subtle);
}
.action-btn svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  flex-shrink: 0;
}
.action-btn.danger {
  color: var(--danger);
  border-color: rgba(229,57,53,0.15);
}
.action-btn.danger svg {
  stroke: var(--danger);
}

/* ========== Confirm Dialog ========== */
.confirm-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0,0,0,0);
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
  transition: all 0.25s var(--ease);
  align-items: center;
  justify-content: center;
}
.confirm-overlay.visible {
  display: flex;
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.confirm-box {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  width: calc(100% - 40px);
  max-width: 320px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: scale(0.95) translateY(10px);
  opacity: 0;
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.confirm-overlay.visible .confirm-box {
  transform: scale(1) translateY(0);
  opacity: 1;
}
.confirm-body {
  padding: 24px 20px 16px;
  text-align: center;
}
.confirm-title {
  font-size: 1em;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.confirm-detail {
  font-size: 0.82em;
  color: var(--text-secondary);
  line-height: 1.5;
}
.confirm-actions {
  display: flex;
  border-top: 1px solid var(--border);
}
.confirm-actions button {
  flex: 1;
  padding: 14px;
  border: none;
  background: none;
  font-family: inherit;
  font-size: 0.88em;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.confirm-cancel {
  color: var(--text-muted);
  border-right: 1px solid var(--border);
}
.confirm-cancel:active {
  background: var(--bg-subtle);
}
.confirm-ok {
  color: var(--primary);
  font-weight: 600;
}
.confirm-ok:active {
  background: var(--bg-subtle);
}
.confirm-ok.danger {
  color: var(--danger);
}

/* ========== Modals ========== */
.modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 200;
  overflow: auto;
  background: rgba(0,0,0,0);
  backdrop-filter: blur(0);
  -webkit-backdrop-filter: blur(0);
  transition: all 0.3s var(--ease);
}
.modal.visible {
  background: rgba(0,0,0,0.45);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.modal-card {
  background: var(--bg-elevated);
  margin: 8vh auto;
  border-radius: var(--radius-lg);
  width: calc(100% - 32px);
  max-width: 380px;
  box-shadow: var(--shadow-lg);
  transform: translateY(24px) scale(0.96);
  opacity: 0;
  transition: all 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}
.modal.visible .modal-card {
  transform: translateY(0) scale(1);
  opacity: 1;
}
.modal-top {
  background: linear-gradient(135deg, var(--primary-dark), var(--primary));
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-top h2 {
  color: #fff;
  font-size: 1.05em;
  font-weight: 600;
  margin: 0;
}
.modal-close {
  color: rgba(255,255,255,0.6);
  font-size: 22px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  line-height: 1;
  transition: color 0.2s;
}
.modal-close:hover { color: #fff; }
.modal-body {
  padding: 20px;
}
.modal-body p {
  color: var(--text-secondary);
  font-size: 0.88em;
  line-height: 1.7;
  margin-bottom: 10px;
}
.info-section {
  margin: 16px 0;
}
.info-section h3 {
  font-size: 0.85em;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.info-section p {
  margin-bottom: 6px;
}
.info-section a {
  color: var(--primary);
  text-decoration: none;
  font-weight: 500;
}
.info-section a:hover {
  text-decoration: underline;
}
.support-links {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 12px;
}
.support-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 13px 14px;
  background: var(--bg-subtle);
  border-radius: 10px;
  text-decoration: none;
  color: var(--text-primary);
  font-size: 0.85em;
  font-weight: 500;
  border: 1px solid var(--border);
  transition: all 0.15s var(--ease);
}
.support-link:active {
  transform: scale(0.98);
  background: var(--border);
}
.modal-footer-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.82em;
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}
.modal-xonatec-footer {
  text-align: center;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.modal-xonatec-footer .xonatec-label {
  display: block;
  font-size: 0.75em;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: var(--text-secondary);
  margin-bottom: 8px;
}
.modal-xonatec-footer span:not(.xonatec-label) {
  display: block;
  font-size: 0.68em;
  color: var(--text-muted);
  margin-bottom: 5px;
}
.modal-xonatec-footer a {
  display: inline-block;
  opacity: 1;
  transition: opacity 0.2s;
}
.modal-xonatec-footer a:hover { opacity: 0.7; }
.modal-xonatec-footer svg {
  height: 30px;
  fill: var(--text-primary);
}

/* ========== Welcome Dialog ========== */
.welcome-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 400;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  align-items: center;
  justify-content: center;
  transition: all 0.3s var(--ease);
}
.welcome-overlay.visible {
  display: flex;
}
.welcome-box {
  background: var(--bg-elevated);
  border-radius: var(--radius-lg);
  width: calc(100% - 40px);
  max-width: 340px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: scale(0.92) translateY(16px);
  opacity: 0;
  transition: all 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.welcome-overlay.visible .welcome-box {
  transform: scale(1) translateY(0);
  opacity: 1;
}
.welcome-header {
  padding: 24px 20px 12px;
  text-align: center;
}
.welcome-header h2 {
  font-size: 1.2em;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.welcome-header p {
  font-size: 0.82em;
  color: var(--text-secondary);
  line-height: 1.5;
}
.welcome-choices {
  display: flex;
  gap: 10px;
  padding: 16px 20px 24px;
}
.welcome-choice {
  flex: 1;
  padding: 16px 10px;
  border: 2px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-subtle);
  cursor: pointer;
  text-align: center;
  transition: all 0.2s var(--ease);
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}
.welcome-choice:active {
  transform: scale(0.96);
}
.welcome-choice:hover, .welcome-choice:focus {
  border-color: var(--primary);
  background: var(--bg-elevated);
}
.welcome-choice-icon {
  font-size: 1.8em;
  margin-bottom: 6px;
  display: block;
}
.welcome-choice-label {
  font-size: 0.95em;
  font-weight: 600;
  color: var(--text-primary);
  display: block;
}
.welcome-choice-sub {
  font-size: 0.7em;
  color: var(--text-muted);
  margin-top: 3px;
  display: block;
}
.modus-switch {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-full);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.78em;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent;
  margin-top: 10px;
}
.modus-switch:active {
  transform: scale(0.96);
  background: var(--border);
}

/* ========== Export Modal (Personalisierung) ========== */
.export-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.export-field label {
  display: block;
  font-size: 0.7em;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 4px;
}
.export-field input,
.export-field textarea {
  width: 100%;
  padding: 10px 12px;
  font-size: 0.88em;
  font-family: inherit;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg-subtle);
  color: var(--text-primary);
  transition: border-color 0.15s var(--ease);
  outline: none;
  -webkit-appearance: none;
}
.export-field input:focus,
.export-field textarea:focus {
  border-color: var(--primary);
}
.export-field input::placeholder,
.export-field textarea::placeholder {
  color: var(--text-muted);
  opacity: 0.6;
}
.export-field textarea {
  resize: vertical;
  min-height: 52px;
  line-height: 1.5;
}
.export-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.export-actions {
  display: flex;
  gap: 8px;
  margin-top: 4px;
}
.export-actions button {
  flex: 1;
  padding: 12px;
  font-family: inherit;
  font-size: 0.88em;
  font-weight: 600;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: all 0.15s var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.export-actions button:active {
  transform: scale(0.97);
}
.export-btn-skip {
  background: var(--bg-subtle);
  color: var(--text-secondary);
  border: 1px solid var(--border) !important;
}
.export-btn-go {
  background: linear-gradient(135deg, var(--primary), var(--primary-dark));
  color: #fff;
}

/* ========== Tracking Bar (Phase Indicator) ========== */
.tracking-bar {
  display: none;
  flex-shrink: 0;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
  box-shadow: var(--shadow-xs);
  margin-bottom: 12px;
}
.tracking-bar.visible { display: flex; }
.phase-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--text-muted);
}
.phase-dot.info { background: var(--primary); }
.phase-dot.early { background: #f9a825; }
.phase-dot.active { background: #ff7043; }
.phase-dot.urgent { background: var(--danger); animation: dotPulse 1.2s ease-in-out infinite; }
@keyframes dotPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229,57,53,0.4); }
  50% { box-shadow: 0 0 0 6px rgba(229,57,53,0); }
}
.phase-label {
  font-size: 0.78em;
  font-weight: 500;
  color: var(--text-secondary);
  flex: 1;
}
.phase-detail-btn {
  font-size: 0.68em;
  font-weight: 600;
  color: var(--primary);
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  transition: background 0.15s var(--ease);
  font-family: inherit;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.phase-detail-btn:active { background: var(--bg-subtle); }

/* ========== Hint Banner ========== */
.hint-banner {
  display: none;
  position: relative;
  flex-shrink: 0;
  padding: 12px 38px 12px 14px;
  border-radius: var(--radius);
  margin-bottom: 12px;
  font-size: 0.8em;
  line-height: 1.5;
}
.hint-banner.visible { display: block; }
.hint-banner.info {
  background: rgba(0,150,136,0.06);
  color: var(--primary-dark);
}
.hint-banner.early {
  background: rgba(249,168,37,0.08);
  color: #e68a00;
}
.hint-banner.active {
  background: rgba(255,112,67,0.08);
  color: #e64a19;
}
.hint-banner.urgent {
  background: rgba(229,57,53,0.08);
  color: var(--danger);
}
.hint-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.4em;
  line-height: 1;
  opacity: 0.6;
  cursor: pointer;
  border-radius: 50%;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}
/* Neutrales Press-Feedback, sichtbar in Light- UND Dark-Mode */
.hint-close:active { opacity: 1; background: rgba(128,128,128,0.22); }
[data-theme="dark"] .hint-banner.info { background: rgba(77,182,172,0.08); color: var(--primary); }
[data-theme="dark"] .hint-banner.early { background: rgba(249,168,37,0.08); color: #fdd835; }
[data-theme="dark"] .hint-banner.active { background: rgba(255,112,67,0.1); color: #ff8a65; }
[data-theme="dark"] .hint-banner.urgent { background: rgba(239,83,80,0.1); color: #ef5350; }
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] .hint-banner.info { background: rgba(77,182,172,0.08); color: var(--primary); }
  [data-theme="auto"] .hint-banner.early { background: rgba(249,168,37,0.08); color: #fdd835; }
  [data-theme="auto"] .hint-banner.active { background: rgba(255,112,67,0.1); color: #ff8a65; }
  [data-theme="auto"] .hint-banner.urgent { background: rgba(239,83,80,0.1); color: #ef5350; }
}
.hint-title {
  font-weight: 600;
  margin-bottom: 2px;
}
.hint-text {
  font-weight: 400;
  opacity: 0.9;
}

/* ========== Stat Card Extensions ========== */
.stat-card.wide {
  grid-column: 1 / -1;
}
.stat-trend {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: 0.65em;
  font-weight: 600;
  margin-left: 6px;
  vertical-align: middle;
}
.stat-trend.up { color: #ff7043; }
.stat-trend.down { color: var(--primary); }
.stat-trend.stable { color: var(--text-muted); }
.stat-trend svg {
  width: 10px;
  height: 10px;
  stroke: currentColor;
  fill: none;
  stroke-width: 2.5;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.stat-sub {
  font-size: 0.65em;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
}

/* ========== Progress Bar (511 Rule) ========== */
.stat-progress {
  margin-top: 6px;
  height: 4px;
  border-radius: 2px;
  background: var(--border);
  overflow: hidden;
}
.stat-progress-fill {
  height: 100%;
  border-radius: 2px;
  background: var(--primary);
  transition: width 0.5s var(--ease);
}

/* ========== Analyse Modal ========== */
.analyse-section {
  margin-bottom: 16px;
}
.analyse-section:last-child { margin-bottom: 0; }
.analyse-heading {
  font-size: 0.82em;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.analyse-heading svg {
  width: 14px;
  height: 14px;
  stroke: var(--primary);
  fill: none;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.analyse-values {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.analyse-val-item {
  background: var(--bg-subtle);
  padding: 8px 10px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}
.analyse-val-label {
  font-size: 0.65em;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.analyse-val-value {
  font-size: 0.95em;
  font-weight: 600;
  color: var(--text-primary);
  margin-top: 1px;
}
.method-section {
  background: var(--bg-subtle);
  border: 1px solid var(--border-subtle);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 8px;
}
.method-section:last-child { margin-bottom: 0; }
.method-title {
  font-size: 0.75em;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 6px;
}
.method-text {
  font-size: 0.72em;
  color: var(--text-secondary);
  line-height: 1.6;
}
.method-formula {
  font-family: 'Courier New', monospace;
  font-size: 0.7em;
  color: var(--primary);
  background: var(--bg-elevated);
  padding: 6px 10px;
  border-radius: 6px;
  border: 1px solid var(--border);
  margin: 6px 0;
  display: block;
}
.method-table {
  width: 100%;
  font-size: 0.7em;
  border-collapse: collapse;
  margin-top: 6px;
}
.method-table th, .method-table td {
  padding: 5px 6px;
  text-align: left;
  border-bottom: 1px solid var(--border-subtle);
}
.method-table th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.method-table td { color: var(--text-secondary); }
.disclaimer-box {
  background: rgba(249,168,37,0.08);
  border: 1px solid rgba(249,168,37,0.2);
  border-radius: 10px;
  padding: 12px;
  margin-top: 12px;
}
.disclaimer-box p {
  font-size: 0.72em !important;
  color: #e68a00 !important;
  line-height: 1.6 !important;
  margin-bottom: 0 !important;
}
[data-theme="dark"] .disclaimer-box { background: rgba(249,168,37,0.06); border-color: rgba(249,168,37,0.15); }
[data-theme="dark"] .disclaimer-box p { color: #fdd835 !important; }
@media (prefers-color-scheme: dark) {
  [data-theme="auto"] .disclaimer-box { background: rgba(249,168,37,0.06); border-color: rgba(249,168,37,0.15); }
  [data-theme="auto"] .disclaimer-box p { color: #fdd835 !important; }
}
.source-list {
  font-size: 0.68em;
  color: var(--text-muted);
  line-height: 1.7;
  margin-top: 8px;
}
.source-list a {
  color: var(--primary);
  text-decoration: none;
}

/* ========== Desktop ========== */
@media (min-width: 600px) {
  .app {
    max-width: 520px;
    padding: 24px 20px;
  }
  .header h1 { font-size: 1.7em; }
  .main-btn { padding: 20px; font-size: 1.15em; }
  .stat-card { padding: 16px; }
  .stat-value { font-size: 1.4em; }
  table { font-size: 0.84em; }
  thead th, td { padding: 12px 14px; }
  .action-btn {
    padding: 12px 14px;
    font-size: 0.78em;
  }
  .action-btn:hover {
    background: var(--bg-subtle);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
  }
  .theme-toggle:hover, .info-btn:hover {
    background: var(--bg-subtle);
    transform: translateY(-1px);
  }
  .table-wrap {
    /* flex: 1 + min-height: 0 handles sizing in the sticky layout */
  }
}

/* ========== Compact Stats for Short Viewports ========== */
/* Sehr kurze / Landscape-Viewports: das feste 100dvh-Layout (overflow:hidden)
   kann die Wehen-Liste auf 0 quetschen und Inhalte unerreichbar machen.
   Hier erlauben wir stattdessen normales Seiten-Scrollen. */
@media (orientation: landscape) and (max-height: 560px) {
  body { overflow-y: auto; height: auto; min-height: 100dvh; }
  .app { height: auto; min-height: 100dvh; overflow: visible; }
  .table-wrap { overflow-y: visible; }
}

@media (max-height: 700px) {
  .stats {
    gap: 4px;
    margin-bottom: 8px;
  }
  .stat-card {
    padding: 6px 10px;
    display: flex;
    align-items: center;
    gap: 6px;
  }
  .stat-label {
    margin-bottom: 0;
    white-space: nowrap;
  }
  .stat-value {
    font-size: 1em;
    white-space: nowrap;
  }
  .stat-sub {
    display: none;
  }
  /* 5-1-1: compact single row */
  .stat-card.wide {
    flex-wrap: wrap;
  }
  .stat-card.wide .stat-label {
    flex: 0 0 auto;
  }
  .stat-card.wide .stat-value {
    flex: 1;
  }
  .stat-card.wide .stat-progress {
    flex: 0 0 100%;
    margin-top: 2px;
  }
  .stat-card.wide .stat-sub {
    display: none;
  }
  /* Expanded state: restore full layout on tap */
  .stat-card.expanded {
    display: block;
    padding: 10px 12px;
    position: relative;
    z-index: 2;
    box-shadow: var(--shadow-sm, 0 2px 8px rgba(0,0,0,0.1));
    animation: statPop 0.2s var(--ease);
  }
  .stat-card.expanded .stat-label {
    margin-bottom: 3px;
  }
  .stat-card.expanded .stat-value {
    font-size: 1.25em;
  }
  .stat-card.expanded .stat-sub {
    display: block;
  }
  .stat-card.wide.expanded {
    display: block;
  }
  .stat-card.wide.expanded .stat-sub {
    display: block;
  }
  .stat-card.wide.expanded .stat-progress {
    margin-top: 4px;
  }
  @keyframes statPop {
    0% { transform: scale(0.97); }
    60% { transform: scale(1.02); }
    100% { transform: scale(1); }
  }
  .hint-banner {
    padding: 8px 34px 8px 10px;
    margin-bottom: 8px;
    font-size: 0.75em;
  }
  .tracking-bar {
    padding: 6px 10px;
  }
}

@media (max-width: 360px) {
  .header h1 { font-size: 1.3em; }
  .stat-value { font-size: 1.1em; }
  .stat-label { font-size: 0.6em; }
  table { font-size: 0.72em; }
  thead th, td { padding: 8px 7px; }
}
