:root {
  --bg: #0a0a0a;
  --text: #ffffff;
  --muted: #b0b0b0;
  --surface: #1a1a1a;
  --border: #333333;
  --primary: #0066ff;
  --primary-light: #4d94ff;
  --accent: #00cc44;
  --hold: #ff9900;
  --exhale: #3399ff;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --text: #000000;
    --muted: #555555;
    --surface: #f5f5f5;
    --border: #cccccc;
    --primary: #0052cc;
    --primary-light: #4d94ff;
    --accent: #008a00;
    --hold: #cc7a00;
    --exhale: #0052cc;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Ubuntu, Cantarell, Noto Sans, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  max-width: 840px;
  margin: 0 auto;
  padding: 16px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 16px;
}

.app-header h1 {
  margin: 0 0 4px;
  font-size: 1.75rem;
}
.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.config-section, #session {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
}

.form-row {
  margin: 12px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  align-items: center;
}
.form-row > label { min-width: 96px; }
.form-row label:has(input[type="checkbox"]) {
  min-width: auto;
  cursor: pointer;
  user-select: none;
}
fieldset.form-row { border: none; padding: 0; }
legend { font-weight: 600; margin-bottom: 4px; }

select, input[type="radio"], input[type="checkbox"] {
  accent-color: var(--primary);
}

.form-actions {
  margin-top: 8px;
  display: flex;
  gap: 12px;
}

.btn {
  appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  padding: 10px 14px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.05s ease, background 0.2s ease, border-color 0.2s ease;
  font-weight: 500;
}
.btn:hover { 
  transform: translateY(-1px); 
  background: var(--border);
}
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-primary { 
  background: var(--primary); 
  border-color: var(--primary); 
  color: white; 
  font-weight: 600;
}
.btn-primary:hover {
  background: var(--primary-light);
  border-color: var(--primary-light);
}
.btn-accent { 
  background: var(--accent); 
  border-color: var(--accent); 
  color: white; 
  font-weight: 600;
}
.btn-secondary { 
  background: var(--surface); 
  color: var(--text);
}

.statusbar {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 8px;
  align-items: center;
  margin-bottom: 10px;
}
.badge {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 8px 12px;
  text-align: center;
  color: var(--text);
  font-weight: 500;
}
.phase { text-align: center; font-weight: 600; }

.visual-section { display: grid; place-items: center; padding: 12px 0; }
.breath-svg { width: min(72vw, 320px); height: auto; }
.breath-circle { fill: var(--primary); }

/* Phase-driven coloring */
.phase-breathing .breath-circle { fill: var(--primary); }
.phase-retention .breath-circle { fill: var(--accent); }
.phase-hold .breath-circle { fill: var(--hold); }
.phase-exhale .breath-circle { fill: var(--exhale); }

/* Ademhalingsnummer styling */
.breath-number {
  font-size: 18px;
  font-weight: 700;
  fill: var(--text);
  text-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
  pointer-events: none;
  user-select: none;
  dominant-baseline: middle;
}

/* Verbeterde zichtbaarheid voor lichte modus */
@media (prefers-color-scheme: light) {
  .breath-number {
    text-shadow: 0 0 6px rgba(255, 255, 255, 0.9);
  }
}

.timers { display: flex; gap: 12px; justify-content: center; margin-top: 8px; }
.timer { 
  font-variant-numeric: tabular-nums; 
  background: var(--surface); 
  border: 1px solid var(--border); 
  border-radius: 10px; 
  padding: 8px 12px; 
  color: var(--text);
  font-weight: 500;
}

.actions { display: flex; gap: 12px; justify-content: center; margin-top: 12px; }

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

button:focus-visible, select:focus-visible, input[type="radio"]:focus-visible {
  outline: 3px solid var(--primary);
  outline-offset: 3px;
  border-radius: 6px;
}

/* Verbeterde hover states voor betere interactiviteit */
select:hover, input[type="radio"]:hover {
  border-color: var(--primary);
}

/* Verbeterde contrast voor radio buttons en labels */
input[type="radio"] + label {
  color: var(--text);
  font-weight: 500;
}



/* Verbeterde styling voor radio buttons en labels */
input[type="radio"] {
  margin-right: 8px;
  transform: scale(1.2);
}

label {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 4px 0;
  color: var(--text);
  font-weight: 500;
}

label:hover {
  color: var(--primary);
}

/* Verbeterde legend styling */
legend {
  font-weight: 600;
  margin-bottom: 8px;
  color: var(--text);
  font-size: 1rem;
}

/* Verbeterde form row spacing */
.form-row {
  margin: 16px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 16px 20px;
  align-items: center;
}

/* Verbeterde select styling */
select {
  background: var(--surface);
  color: var(--text);
  border: 2px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  min-width: 80px;
  cursor: pointer;
}

select:hover {
  border-color: var(--primary);
}

select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(0, 102, 255, 0.2);
  outline: none;
}

/* Utility when [hidden] is used */
[hidden] { display: none !important; }

/* Responsive layout tweaks */
@media (max-width: 640px) {
  .statusbar { grid-template-columns: 1fr; gap: 6px; }
}

/* Samenvatting sectie */
.summary-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 20px;
  margin-top: 16px;
}

.summary-section h2 {
  margin: 0 0 16px 0;
  color: var(--text);
  font-size: 1.5rem;
}

.summary-content p {
  margin: 0 0 16px 0;
  color: var(--muted);
  font-size: 1rem;
}

.retention-results {
  margin: 16px 0;
  padding: 16px;
  background: var(--bg);
  border-radius: 8px;
  border: 1px solid var(--border);
}

.retention-result-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.retention-result-item:last-child {
  border-bottom: none;
}

.retention-result-item .round-label {
  font-weight: 600;
  color: var(--text);
}

.retention-result-item .retention-time {
  color: var(--accent);
  font-weight: 500;
  font-family: monospace;
  font-size: 1.1rem;
}

.summary-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  margin-top: 20px;
}