/* style.css — all styling */
:root {
  color-scheme: dark;
  --bg-0: #0d1018;
  --bg-1: #141926;
  --fg: #eef2fb;
  --fg-dim: #aab3c7;
  --fg-mute: #6f7a92;
  --surface: rgba(255, 255, 255, 0.05);
  --surface-2: rgba(255, 255, 255, 0.08);
  --border: rgba(255, 255, 255, 0.1);
  --accent: #8b7bf0;
  --accent-soft: rgba(139, 123, 240, 0.18);
  --ring-bg: rgba(255, 255, 255, 0.07);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

html[data-theme="dark"] { color-scheme: dark; }
html[data-theme="light"] {
  color-scheme: light;
  --bg-0: #eef1f7;
  --bg-1: #e2e7f2;
  --fg: #1a2030;
  --fg-dim: #4a5468;
  --fg-mute: #8793a8;
  --surface: rgba(20, 30, 60, 0.05);
  --surface-2: rgba(20, 30, 60, 0.09);
  --border: rgba(20, 30, 60, 0.12);
  --ring-bg: rgba(20, 30, 60, 0.1);
  --shadow: 0 24px 60px rgba(40, 60, 100, 0.18);
}

@media (prefers-color-scheme: light) {
  html:not([data-theme="dark"]) {
    color-scheme: light;
    --bg-0: #eef1f7;
    --bg-1: #e2e7f2;
    --fg: #1a2030;
    --fg-dim: #4a5468;
    --fg-mute: #8793a8;
    --surface: rgba(20, 30, 60, 0.05);
    --surface-2: rgba(20, 30, 60, 0.09);
    --border: rgba(20, 30, 60, 0.12);
    --ring-bg: rgba(20, 30, 60, 0.1);
    --shadow: 0 24px 60px rgba(40, 60, 100, 0.18);
  }
}

/* Mode accents */
html[data-accent="focus"] { --accent: #8b7bf0; --accent-soft: rgba(139,123,240,0.18); }
html[data-accent="short"] { --accent: #4fb6a6; --accent-soft: rgba(79,182,166,0.18); }
html[data-accent="long"]  { --accent: #6aa8e8; --accent-soft: rgba(106,168,232,0.18); }

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-0);
  color: var(--fg);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
  overflow: hidden;
}

body {
  touch-action: manipulation;
  position: relative;
}

/* ---------- Calming animated background ---------- */
.bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  background:
    radial-gradient(120% 120% at 50% 0%, var(--bg-1) 0%, var(--bg-0) 60%);
}
.blob {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.55;
  mix-blend-mode: screen;
  will-change: transform;
}
html[data-theme="light"] .blob { mix-blend-mode: multiply; opacity: 0.35; }

.blob1 {
  width: 520px; height: 520px;
  background: radial-gradient(circle, #6d5acd 0%, transparent 70%);
  top: -140px; left: -120px;
  animation: drift1 26s ease-in-out infinite;
}
.blob2 {
  width: 620px; height: 620px;
  background: radial-gradient(circle, #2c7da0 0%, transparent 70%);
  bottom: -180px; right: -120px;
  animation: drift2 32s ease-in-out infinite;
}
.blob3 {
  width: 460px; height: 460px;
  background: radial-gradient(circle, #b388eb 0%, transparent 70%);
  top: 38%; left: 48%;
  animation: drift3 22s ease-in-out infinite;
}
.blob4 {
  width: 380px; height: 380px;
  background: radial-gradient(circle, #4fb6a6 0%, transparent 70%);
  top: 8%; right: 10%;
  animation: drift1 30s ease-in-out infinite reverse;
}

@keyframes drift1 {
  0%, 100% { transform: translate(0,0) scale(1); }
  33% { transform: translate(90px,-60px) scale(1.12); }
  66% { transform: translate(-70px,70px) scale(0.92); }
}
@keyframes drift2 {
  0%, 100% { transform: translate(0,0) scale(1); }
  40% { transform: translate(-110px,-50px) scale(1.08); }
  75% { transform: translate(60px,-90px) scale(0.95); }
}
@keyframes drift3 {
  0%, 100% { transform: translate(-50%,-50%) scale(1); }
  50% { transform: translate(-30%,-65%) scale(1.15); }
}

.grain {
  position: absolute; inset: 0;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.5'/%3E%3C/svg%3E");
  opacity: 0.04;
  pointer-events: none;
}

/* ---------- App shell ---------- */
.app {
  position: relative;
  z-index: 1;
  height: 100%;
  max-width: 560px;
  margin: 0 auto;
  padding: 20px 22px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 22px;
}

.top {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  letter-spacing: 0.02em;
  font-size: 17px;
}
.brand .logo {
  color: var(--accent);
  font-size: 20px;
  display: inline-block;
  transition: color .6s ease;
}
.icon-btn {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-dim);
  border-radius: 12px;
  font-size: 18px;
  cursor: pointer;
  transition: background .2s, color .2s, transform .15s;
}
.icon-btn:hover { background: var(--surface-2); color: var(--fg); }
.icon-btn:active { transform: scale(0.94); }

/* ---------- Modes ---------- */
.modes {
  display: inline-flex;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px;
  gap: 2px;
}
.mode {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--fg-dim);
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  padding: 8px 14px;
  border-radius: 999px;
  cursor: pointer;
  transition: color .2s, background .25s;
  white-space: nowrap;
}
.mode:hover { color: var(--fg); }
.mode.active {
  color: var(--fg);
  background: var(--accent-soft);
  box-shadow: inset 0 0 0 1px var(--border);
}

/* ---------- Timer ring ---------- */
.timer-wrap {
  position: relative;
  width: min(78vw, 320px);
  aspect-ratio: 1 / 1;
  display: grid;
  place-items: center;
  margin-top: 4px;
}
.ring {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  overflow: visible;
}
.ring-bg {
  fill: none;
  stroke: var(--ring-bg);
  stroke-width: 6;
}
.ring-fg {
  fill: none;
  stroke: var(--accent);
  stroke-width: 6;
  stroke-linecap: round;
  filter: drop-shadow(0 0 14px var(--accent-soft));
  transition: stroke-dashoffset .9s linear, stroke .6s ease;
}
.time-display {
  position: relative;
  text-align: center;
  z-index: 1;
}
.time {
  font-size: clamp(46px, 14vw, 64px);
  font-weight: 600;
  letter-spacing: 0.01em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.status {
  margin-top: 12px;
  font-size: 13px;
  color: var(--fg-mute);
  letter-spacing: 0.02em;
  min-height: 18px;
}

/* ---------- Controls ---------- */
.controls {
  display: flex;
  align-items: center;
  gap: 14px;
}
.ctrl {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  border-radius: 999px;
  transition: transform .15s, background .2s, box-shadow .2s, color .2s;
}
.ctrl:active { transform: scale(0.95); }
.ctrl-ghost {
  width: 52px; height: 52px;
  display: grid; place-items: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--fg-dim);
  font-size: 20px;
}
.ctrl-ghost:hover { background: var(--surface-2); color: var(--fg); }
.ctrl-primary {
  min-width: 132px;
  height: 56px;
  padding: 0 30px;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, #ffffff 30%));
  box-shadow: 0 10px 30px var(--accent-soft), inset 0 1px 0 rgba(255,255,255,0.2);
}
html[data-theme="light"] .ctrl-primary { color: #fff; }
.ctrl-primary:hover { box-shadow: 0 14px 38px var(--accent-soft), inset 0 1px 0 rgba(255,255,255,0.25); }

/* ---------- Sessions ---------- */
.sessions {
  display: flex;
  align-items: center;
  gap: 12px;
  color: var(--fg-mute);
  font-size: 13px;
}
.sessions .label { letter-spacing: 0.08em; text-transform: uppercase; font-size: 11px; }
.dots { display: flex; gap: 8px; }
.dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--surface-2);
  border: 1px solid var(--border);
  transition: background .3s, transform .2s;
}
.dot.on {
  background: var(--accent);
  border-color: transparent;
  transform: scale(1.1);
}
.sessions .count { color: var(--fg-dim); }

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s;
}
html[data-theme="light"] .modal { background: rgba(40, 60, 100, 0.35); }
.modal.open { opacity: 1; pointer-events: auto; }
.modal-card {
  width: 100%;
  max-width: 380px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 24px;
  box-shadow: var(--shadow);
  transform: translateY(12px) scale(0.98);
  transition: transform .25s;
}
.modal.open .modal-card { transform: translateY(0) scale(1); }
.modal-card h2 { margin: 0 0 4px; font-size: 18px; }
.modal-card .muted { margin: 0 0 18px; color: var(--fg-mute); font-size: 13px; }
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 0;
  border-top: 1px solid var(--border);
}
.form-row:first-of-type { border-top: 0; }
.form-row label { color: var(--fg-dim); font-size: 14px; }
.form-row input[type="number"] {
  width: 84px;
  padding: 8px 10px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--fg);
  font: inherit;
  font-size: 15px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.form-row input[type="number"]:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.suffix { color: var(--fg-mute); font-size: 13px; margin-left: -8px; padding-right: 84px; }
.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 18px;
}
.btn-flat, .btn-solid {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: 10px;
  transition: background .2s, transform .15s;
}
.btn-flat { background: var(--surface); color: var(--fg-dim); }
.btn-flat:hover { background: var(--surface-2); color: var(--fg); }
.btn-solid { background: var(--accent); color: #fff; }
.btn-solid:hover { filter: brightness(1.08); }
.btn-flat:active, .btn-solid:active { transform: scale(0.96); }

/* Switch */
.switch { position: relative; display: inline-block; width: 44px; height: 26px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute; inset: 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 999px;
  transition: background .25s;
}
.slider::before {
  content: "";
  position: absolute;
  width: 18px; height: 18px;
  left: 3px; top: 3px;
  background: var(--fg-dim);
  border-radius: 50%;
  transition: transform .25s, background .25s;
}
.switch input:checked + .slider { background: var(--accent-soft); }
.switch input:checked + .slider::before { transform: translateX(18px); background: var(--accent); }

/* ---------- Small screens ---------- */
@media (max-width: 380px) {
  .app { padding: 16px 14px 22px; gap: 16px; }
  .mode { padding: 7px 10px; font-size: 12px; }
  .ctrl-primary { min-width: 116px; height: 52px; padding: 0 22px; font-size: 15px; }
  .ctrl-ghost { width: 48px; height: 48px; }
}

@media (prefers-reduced-motion: reduce) {
  .blob { animation: none !important; }
  .ring-fg { transition: stroke-dashoffset .2s linear; }
}
