/* Konzentrations-Timer – ruhiges Himmelblau/Mint, reizarm */
:root {
  --blue: #38bdf8;
  --blue-deep: #0ea5e9;
  --mint: #5eead4;
  --mint-deep: #14b8a6;

  --bg: #f7fbfd;
  --bg-soft: #eef6fb;
  --surface: #ffffff;
  --surface-2: #f1f7fb;
  --text: #1f3a4d;
  --text-soft: #5a7689;
  --border: #d9e8f1;
  --ring-track: #e3eef5;
  --shadow: 0 10px 30px rgba(56, 189, 248, 0.12);
  --shadow-soft: 0 4px 14px rgba(20, 60, 90, 0.06);
  --focus: #0284c7;

  --grad: linear-gradient(135deg, var(--blue), var(--mint));
  --radius: 20px;
  --radius-sm: 12px;
}

[data-theme="dark"] {
  --bg: #0d1b24;
  --bg-soft: #11242f;
  --surface: #152935;
  --surface-2: #1b323f;
  --text: #e6f3fa;
  --text-soft: #9bb6c5;
  --border: #244456;
  --ring-track: #243c49;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.35);
  --shadow-soft: 0 4px 14px rgba(0, 0, 0, 0.25);
  --focus: #7dd3fc;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
  overflow-x: hidden;
  transition: background-color .3s ease, color .3s ease;
}

.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;
}

.skip-link {
  position: absolute;
  left: -999px;
  top: 8px;
  background: var(--surface);
  color: var(--text);
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  z-index: 50;
  box-shadow: var(--shadow);
}
.skip-link:focus { left: 12px; }

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

/* Header */
.app-header {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px 18px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.brand-mark {
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border-radius: 12px;
  background: var(--grad);
  color: #fff;
  flex: 0 0 auto;
  box-shadow: var(--shadow-soft);
}
.brand h1 {
  font-size: 1.15rem;
  margin: 0;
  font-weight: 700;
  letter-spacing: .2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.icon-btn {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: grid;
  place-items: center;
  box-shadow: var(--shadow-soft);
  transition: transform .15s ease, background-color .2s ease;
}
.icon-btn:hover { transform: translateY(-1px); }
.icon-btn:active { transform: translateY(0); }
.theme-icon {
  width: 20px; height: 20px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, var(--mint), var(--blue));
  box-shadow: inset -4px -4px 0 0 var(--surface);
}
[data-theme="dark"] .theme-icon {
  background: var(--blue);
  box-shadow: none;
}

/* Main layout */
.app-main {
  max-width: 560px;
  margin: 0 auto;
  padding: 8px 18px 40px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

/* Timer card */
.timer-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 26px 20px 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
  text-align: center;
}

.phase-label {
  margin: 0;
  font-weight: 700;
  font-size: 1.05rem;
  letter-spacing: .3px;
  padding: 6px 16px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--text-soft);
}
.phase-label[data-phase="lernen"] { color: var(--blue-deep); }
.phase-label[data-phase="pause"]  { color: var(--mint-deep); }
.phase-label[data-phase="fertig"] { color: var(--text); }

/* Progress ring */
.ring-wrap {
  position: relative;
  width: min(74vw, 280px);
  height: min(74vw, 280px);
}
.ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
}
.ring-track {
  fill: none;
  stroke: var(--ring-track);
  stroke-width: 12;
}
.ring-progress {
  fill: none;
  stroke: url(#ringGrad);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 603.2;          /* 2*pi*96 */
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 1s linear;
}
.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.time-display {
  font-size: clamp(2.6rem, 14vw, 3.6rem);
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 1px;
  line-height: 1;
  color: var(--text);
}
.round-display {
  font-size: .85rem;
  color: var(--text-soft);
  font-weight: 600;
}

/* Round dots */
.dots {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  min-height: 14px;
}
.dot {
  width: 12px; height: 12px;
  border-radius: 50%;
  background: var(--ring-track);
  transition: background-color .3s ease, transform .3s ease;
}
.dot.done { background: var(--mint-deep); }
.dot.active {
  background: var(--blue-deep);
  transform: scale(1.25);
}

/* Controls */
.controls {
  display: flex;
  gap: 12px;
  width: 100%;
  max-width: 360px;
}
.btn {
  flex: 1 1 auto;
  border: none;
  border-radius: 14px;
  padding: 15px 18px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: transform .12s ease, box-shadow .2s ease, background-color .2s ease, opacity .2s ease;
  min-width: 0;
}
.btn-primary {
  background: var(--grad);
  color: #07313f;
  box-shadow: var(--shadow-soft);
}
.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }
.btn-ghost {
  background: var(--surface-2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--bg-soft); }

/* Settings card */
.settings-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-soft);
}
.settings-card h2 {
  margin: 0 0 16px;
  font-size: 1.05rem;
  font-weight: 700;
}
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }
.field-label {
  display: block;
  font-size: .85rem;
  font-weight: 700;
  color: var(--text-soft);
  margin-bottom: 8px;
}

/* Segmented choices */
.seg {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.seg-btn {
  flex: 1 1 auto;
  min-width: 64px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  border-radius: 12px;
  padding: 11px 8px;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: background-color .2s ease, border-color .2s ease, color .2s ease, transform .12s ease;
}
.seg-btn:hover { transform: translateY(-1px); }
.seg-btn[aria-pressed="true"] {
  background: var(--grad);
  color: #07313f;
  border-color: transparent;
}

/* Stepper */
.stepper {
  display: flex;
  align-items: center;
  gap: 14px;
}
.step-btn {
  width: 46px; height: 46px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text);
  font-size: 1.5rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: transform .12s ease, background-color .2s ease;
}
.step-btn:hover { transform: translateY(-1px); }
.step-btn:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.stepper-value {
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  min-width: 40px;
  text-align: center;
}

/* Toggle switch */
.field-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.field-toggle .field-label { margin-bottom: 0; }
.switch {
  position: relative;
  width: 56px; height: 32px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--ring-track);
  cursor: pointer;
  padding: 0;
  flex: 0 0 auto;
  transition: background-color .25s ease;
}
.switch[aria-checked="true"] { background: var(--mint-deep); border-color: transparent; }
.switch-knob {
  position: absolute;
  top: 3px; left: 3px;
  width: 24px; height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 4px rgba(0,0,0,.2);
  transition: transform .25s ease;
}
.switch[aria-checked="true"] .switch-knob { transform: translateX(24px); }

/* Toasts */
.toast-region {
  position: fixed;
  left: 50%;
  bottom: calc(20px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  gap: 8px;
  z-index: 60;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
  border-left: 4px solid var(--blue-deep);
  border-radius: 14px;
  padding: 14px 16px;
  box-shadow: var(--shadow);
  font-weight: 600;
  font-size: .95rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity .3s ease, transform .3s ease;
}
.toast.pause { border-left-color: var(--mint-deep); }
.toast.show { opacity: 1; transform: translateY(0); }

@media (max-width: 360px) {
  .controls { flex-direction: column; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.001ms !important;
    transition-duration: 0.001ms !important;
  }
  .ring-progress { transition: none; }
}
