:root {
  color-scheme: dark;
  --bg: #0d0f14;
  --panel: #171a21;
  --panel-2: #1e222b;
  --fg: #e8eaf0;
  --muted: #8b93a3;
  --border: #262b35;
  --accent: #6c8cff;
  --accent-fg: #0d0f14;
  --unhappy: #e0708a;
  --neutral: #c9a227;
  --happy: #4fb286;
  --line-overall: #6c8cff;
  --line-hoofd: #b98cf0;
  --line-lichaam: #4fb286;
  --line-denken: #d9a441;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: system-ui, -apple-system, "SF Pro Text", sans-serif;
  line-height: 1.45;
  overscroll-behavior: none;
}

#app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  padding-top: var(--safe-top);
}

#views {
  flex: 1;
  min-height: 0;
  position: relative;
}

.view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
}

.view[hidden] {
  display: none;
}

/* ---------- Nu / flow ---------- */

.flow {
  flex: 1;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
}

.step-progress {
  text-align: center;
  padding: 14px 0 0;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.steps {
  flex: 1;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

.step {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  padding: 36px 28px 16px;
  text-align: center;
  overflow-y: auto;
}

.step.is-active {
  display: flex;
}

.step-title {
  font-size: 1.6rem;
  margin: 0;
}

.step-sub {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.mood-row {
  display: flex;
  gap: 18px;
}

.mood-btn {
  font-size: 2.4rem;
  line-height: 1;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  cursor: pointer;
}

.mood-btn.is-selected[data-mood="unhappy"] { border-color: var(--unhappy); background: color-mix(in srgb, var(--unhappy) 18%, var(--panel)); }
.mood-btn.is-selected[data-mood="neutral"] { border-color: var(--neutral); background: color-mix(in srgb, var(--neutral) 18%, var(--panel)); }
.mood-btn.is-selected[data-mood="happy"] { border-color: var(--happy); background: color-mix(in srgb, var(--happy) 18%, var(--panel)); }

.score-block {
  width: 100%;
  max-width: 320px;
  display: none;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.score-block.is-revealed {
  display: flex;
}

.score-grid {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.score-row {
  position: relative;
  display: none;
  justify-content: center;
}

.score-row.is-visible {
  display: flex;
}

/* Fixed to the widest row's width (4 buttons: mega ruk) so every row's
   column lines up, and a lone 0/10 button centers under it (and under the
   middle mood smiley above, since both are centered the same way in their
   parent). */
.score-row-btns {
  display: flex;
  justify-content: center;
  gap: 8px;
  width: 192px;
}

.score-row-label {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  margin-right: 12px;
  text-align: right;
  color: var(--muted);
  font-size: 0.8rem;
  white-space: nowrap;
}

.score-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  font-size: 0.95rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  cursor: pointer;
}

.score-btn.is-selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-fg);
}

.step-note {
  display: none;
  width: 100%;
  max-width: 320px;
  flex-direction: column;
  gap: 6px;
}

.step-note.is-revealed {
  display: flex;
}

.step-note-label {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
}

.step-note-row {
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.step-note-input {
  flex: 1;
  min-width: 0;
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 12px;
  /* iOS Safari auto-zooms the page on focus if a text input's font-size
     is under 16px — keep this at 1rem/16px minimum, always. */
  font-size: 1rem;
  font-family: inherit;
  resize: none;
}

.step-note-mic {
  display: none;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--fg);
  font-size: 1.1rem;
  cursor: pointer;
}

body.is-mobile .step-note-mic {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.step-note-mic.is-listening {
  border-color: var(--unhappy);
  background: color-mix(in srgb, var(--unhappy) 22%, var(--panel-2));
  animation: mic-pulse 1.2s ease-in-out infinite;
}

.mic-btn {
  display: none;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  border: 2px solid var(--accent);
  background: color-mix(in srgb, var(--accent) 16%, var(--panel));
  font-size: 2.6rem;
  line-height: 1;
  color: var(--fg);
  cursor: pointer;
}

.mic-btn.is-listening {
  border-color: var(--unhappy);
  background: color-mix(in srgb, var(--unhappy) 18%, var(--panel));
  animation: mic-pulse 1.2s ease-in-out infinite;
}

@keyframes mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--unhappy) 45%, transparent); }
  50% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--unhappy) 0%, transparent); }
}

body.is-mobile .mic-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

body.is-mobile .note-input {
  max-height: 96px;
}

.note-input {
  width: 100%;
  max-width: 420px;
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
  font-size: 1rem;
  font-family: inherit;
  resize: none;
}

.timer-track {
  width: 100%;
  max-width: 420px;
  height: 6px;
  border-radius: 4px;
  background: var(--border);
  overflow: hidden;
}

.timer-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  transition: width 1s linear;
}

.step-done .btn-primary { margin-top: 8px; }

.flow-actions {
  display: flex;
  gap: 12px;
  padding: 12px 20px calc(16px + var(--safe-bottom));
}

.btn-flow {
  flex: 1;
  border-radius: 14px;
  padding: 16px 20px;
  font-size: 1.05rem;
  font-weight: 700;
  cursor: pointer;
}

.btn-flow-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
}

.btn-flow-secondary {
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border);
  flex: 0 0 auto;
  min-width: 100px;
}

.btn-flow[hidden] { display: none; }
.btn-flow:disabled { opacity: 0.35; }

/* ---------- shared panels ---------- */

.panel-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px 20px calc(20px + var(--safe-bottom));
}

.view-title {
  margin: 4px 0 16px;
  font-size: 1.4rem;
}

.btn-primary {
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
}

.btn-secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 20px;
  font-size: 1rem;
  cursor: pointer;
}

/* ---------- Gezondheid ---------- */

.health-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 16px;
  margin-bottom: 20px;
}

.field-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.health-form textarea {
  background: var(--panel-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-family: inherit;
  font-size: 1rem;
  resize: vertical;
}

.form-actions {
  display: flex;
  gap: 10px;
  margin-top: 4px;
}

.health-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.health-item {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 14px;
}

.health-item-date {
  color: var(--muted);
  font-size: 0.8rem;
  margin-bottom: 4px;
}

.health-item-reason {
  font-weight: 600;
  margin-bottom: 8px;
}

.health-item-actions {
  display: flex;
  gap: 10px;
  margin-top: 10px;
}

.health-item-actions button {
  background: transparent;
  border: none;
  color: var(--accent);
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0;
}

.health-item-actions button.is-danger {
  color: var(--unhappy);
}

.empty-hint {
  color: var(--muted);
  font-size: 0.9rem;
  text-align: center;
  padding: 20px 0;
}

/* ---------- Grafiek ---------- */

.chart-controls {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.granularity-switch {
  display: inline-flex;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  width: fit-content;
}

.gran-btn {
  background: var(--panel);
  color: var(--muted);
  border: none;
  padding: 8px 16px;
  font-size: 0.9rem;
  cursor: pointer;
}

.gran-btn.is-active {
  background: var(--accent);
  color: var(--accent-fg);
}

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

.legend-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 12px;
  font-size: 0.8rem;
  color: var(--fg);
  cursor: pointer;
  opacity: 1;
}

.legend-btn.is-off {
  opacity: 0.35;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.chart-wrap {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 12px;
  min-height: 260px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chart-wrap svg { width: 100%; height: auto; }

.empty-state {
  color: var(--muted);
  font-size: 0.9rem;
}

/* ---------- Export ---------- */

.export-status {
  color: var(--muted);
  font-size: 0.85rem;
  min-height: 1.2em;
}

.export-output {
  width: 100%;
  background: var(--panel);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px;
  font-family: ui-monospace, monospace;
  font-size: 1rem;
  margin: 10px 0;
}

/* ---------- Log ---------- */

.log-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.log-day {
  background: var(--panel);
  border-radius: 14px;
  padding: 12px 14px;
}

.log-day-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  text-transform: uppercase;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--muted);
  padding-bottom: 8px;
}

.log-grid-row {
  display: grid;
  grid-template-columns: 50px repeat(4, 1fr);
  align-items: center;
  gap: 4px;
}

.log-cols {
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}

.log-col-icon {
  text-align: center;
  font-size: 1rem;
}

.log-entry {
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.log-entry:first-of-type {
  border-top: none;
}

.log-entry-time {
  font-size: 0.75rem;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
  margin-bottom: 4px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.log-block-badge {
  background: var(--panel-2);
  border-radius: 999px;
  padding: 1px 8px;
  font-size: 0.68rem;
}

.log-row-mood span,
.log-row-score span {
  text-align: center;
}

.log-row-mood {
  font-size: 1.1rem;
}

.log-row-score {
  font-size: 0.85rem;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  color: var(--fg);
}

.log-cell-empty {
  color: var(--muted);
}

.log-row-note {
  margin-top: 6px;
  font-size: 0.85rem;
  color: var(--fg);
  background: var(--panel-2);
  border-radius: 10px;
  padding: 8px 10px;
}

/* ---------- Tab bar ---------- */

.tab-bar {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--panel);
  padding-bottom: var(--safe-bottom);
}

.tab-btn {
  flex: 1;
  background: none;
  border: none;
  color: var(--muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 0 6px;
  font-size: 0.7rem;
  cursor: pointer;
}

.tab-btn.is-active {
  color: var(--accent);
}

.tab-icon {
  font-size: 1.3rem;
}

.tab-icon-nu {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1;
  color: var(--happy);
}

/* ---------- Info button + splash ---------- */

.menu-wrap {
  position: fixed;
  top: calc(12px + var(--safe-top));
  right: 16px;
  z-index: 50;
}

.menu-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--fg);
  font-size: 1.05rem;
  cursor: pointer;
}

.menu-dropdown {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  min-width: 168px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 6px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.4);
  flex-direction: column;
  gap: 2px;
}

.menu-dropdown.is-open {
  display: flex;
}

.menu-item {
  background: none;
  border: none;
  color: var(--fg);
  text-align: left;
  padding: 10px 12px;
  border-radius: 8px;
  font-size: 0.92rem;
  cursor: pointer;
}

.menu-item:active {
  background: var(--panel-2);
}

.splash-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(13, 15, 20, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: splash-fade 0.18s ease-out;
}

.splash-overlay.is-open {
  display: flex;
}

@keyframes splash-fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.splash-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 36px 28px 28px;
  max-width: 320px;
  text-align: center;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.45);
}

.splash-icon {
  font-size: 2rem;
  line-height: 1;
}

.splash-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: var(--panel-2);
  color: var(--muted);
  font-size: 0.9rem;
  cursor: pointer;
}

.splash-text {
  margin: 0;
  font-size: 0.98rem;
  line-height: 1.55;
  color: var(--fg);
}

/* ---------- Settings ---------- */

.settings-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(13, 15, 20, 0.35);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: splash-fade 0.18s ease-out;
}

.settings-overlay.is-open {
  display: flex;
}

.settings-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 22px 22px 24px;
  box-shadow: 0 20px 48px rgba(0, 0, 0, 0.45);
}

.settings-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.settings-head h2 {
  margin: 0;
  font-size: 1.15rem;
}

.settings-hint {
  margin: 0 0 16px;
  font-size: 0.82rem;
  color: var(--muted);
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.settings-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.settings-row.is-disabled {
  opacity: 0.45;
}

.settings-toggle {
  flex: 0 0 auto;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--panel-2);
  color: var(--fg);
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1;
  cursor: pointer;
}

.settings-row:not(.is-disabled) .settings-toggle {
  border-color: var(--unhappy);
  color: var(--unhappy);
}

.settings-row.is-disabled .settings-toggle {
  border-color: var(--happy);
  color: var(--happy);
}

.settings-text {
  flex: 1;
  min-width: 0;
  background: var(--panel-2);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px;
  font-size: 1rem;
  font-family: inherit;
}

.settings-text:disabled {
  color: var(--muted);
}
