/* ============ Theme tokens (Design.md palette) ============ */
:root,
:root[data-theme="light"] {
  --bg: #FFFFFF;
  --fg: #1A1A1A;
  --muted: #6B7280;
  --subtle: #F3F4F6;
  --border: #E5E7EB;
  --raised: #FFFFFF;
  --pop: #FFFFFF;
  --pop-shadow: 0 12px 40px rgba(0, 0, 0, .10);
  --seg-shadow: 0 1px 2px rgba(0, 0, 0, .08);
  --focus: #2F8F62;
  --brk: #D9772B;
  color-scheme: light;
}

:root[data-theme="dark"] {
  --bg: #0A0A0A;
  --fg: #EDEDED;
  --muted: #8A8A8A;
  --subtle: #1A1A1A;
  --border: #262626;
  --raised: #262626;
  --pop: #141414;
  --pop-shadow: 0 12px 40px rgba(0, 0, 0, .6);
  --seg-shadow: none;
  --focus: #4FBF8A;
  --brk: #F0974D;
  color-scheme: dark;
}

.fc-root { --accent: var(--focus); }
.fc-root[data-mode="break"] { --accent: var(--brk); }

html, body {
  background: var(--bg);
  color: var(--fg);
  font-family: 'Geist', system-ui, sans-serif;
  transition: background-color .3s ease, color .3s ease;
}
body { margin: 0; overflow-x: hidden; }

button { cursor: pointer; font-family: inherit; }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============ Animations ============ */
@keyframes fcPulse { 0%, 100% { opacity: 1 } 50% { opacity: .25 } }
@keyframes fcBlink { 0%, 100% { opacity: 1 } 50% { opacity: .35 } }

/* ============ Zen mode ============ */
.fc-chrome { transition: opacity .5s ease; }
.fc-root.is-zen:not(.is-awake) .fc-chrome { opacity: .2; }
/* Main button stays reachable; the hidden cursor keeps the screen clean */
.fc-root.is-zen:not(.is-awake) { cursor: none; }

/* ============ Timer ============ */
.fc-timer {
  font-size: clamp(84px, min(17vw, 30vh), 216px);
  line-height: 1;
  font-weight: 200;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  margin: 18px 0 22px;
  color: var(--fg);
  transition: color .3s ease;
}
.fc-progress { transition: width 1s linear, background-color .3s; }

.fc-root[data-status="running"] .fc-status-dot { animation: fcPulse 2s ease-in-out infinite; }
.fc-root[data-status="alarm"] .fc-timer { color: var(--accent); animation: fcBlink 1s ease-in-out infinite; }

.fc-alarm-ring {
  display: none;
  box-shadow: inset 0 0 0 3px var(--accent);
  animation: fcPulse 1.6s ease-in-out infinite;
}
.fc-root[data-status="alarm"] .fc-alarm-ring { display: block; }

/* ============ Buttons ============ */
.fc-icon-btn {
  width: 38px; height: 38px;
  flex: none;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--fg);
  display: grid; place-items: center;
  transition: opacity .5s ease, border-color .3s, background-color .2s;
}
.fc-icon-btn:hover { background: var(--subtle); }
.fc-icon-btn--lg { width: 56px; height: 56px; }

/* Theme icon: sun in dark, moon in light */
:root[data-theme="dark"] .fc-icon-moon,
:root:not([data-theme="dark"]) .fc-icon-sun { display: none; }

.fc-icon-shrink { display: none; }
.fc-root.is-fs .fc-icon-shrink { display: block; }
.fc-root.is-fs .fc-icon-expand { display: none; }

.fc-main-btn {
  height: 56px; min-width: 168px;
  padding: 0 32px;
  border-radius: 999px;
  border: 0;
  background: var(--fg);
  color: var(--bg);
  font-size: 15px; font-weight: 500; letter-spacing: 0.01em;
  display: flex; align-items: center; justify-content: center; gap: 10px;
  transition: transform .15s, background-color .3s, color .3s;
}
.fc-main-btn:active { transform: scale(.97); }

/* Play/pause icon swap — driven by [data-playing] on the button */
.fc-main-btn .fc-icon-pause, .fc-play-btn .fc-icon-pause { display: none; }
[data-playing="true"] > .fc-icon-pause { display: block; }
[data-playing="true"] > .fc-icon-play { display: none; }

/* Preset pills */
.fc-pill {
  height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  font-size: 13px; font-weight: 500;
  font-variant-numeric: tabular-nums;
  transition: all .2s;
}
.fc-pill:hover { color: var(--fg); }
.fc-pill--dashed { border-style: dashed; }
.fc-pill[aria-pressed="true"] { background: var(--fg); color: var(--bg); border-color: var(--fg); }

.fc-custom-edit {
  height: 34px;
  display: flex; align-items: center; gap: 4px;
  padding: 0 6px 0 14px;
  border-radius: 999px;
  border: 1px solid var(--fg);
}
.fc-custom-edit input {
  width: 34px; border: 0; outline: 0; background: transparent;
  color: var(--fg); font: 500 13px 'Geist', sans-serif; text-align: right;
}
.fc-custom-edit span { font-size: 13px; color: var(--muted); padding-right: 8px; }

/* Mode segmented control */
.fc-seg {
  height: 34px;
  padding: 0 16px;
  border-radius: 999px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 13px; font-weight: 500;
  display: flex; align-items: center; gap: 8px;
  white-space: nowrap;
  transition: all .2s;
}
.fc-seg .fc-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--border); }
.fc-seg[aria-selected="true"] { background: var(--raised); box-shadow: var(--seg-shadow); color: var(--fg); }
.fc-seg[aria-selected="true"][data-key="focus"] .fc-dot { background: var(--focus); }
.fc-seg[aria-selected="true"]:not([data-key="focus"]) .fc-dot { background: var(--brk); }

/* Player */
.fc-play-btn {
  width: 36px; height: 36px;
  flex: none;
  border-radius: 50%;
  border: 0;
  background: var(--fg);
  color: var(--bg);
  display: grid; place-items: center;
  transition: background-color .3s, color .3s;
}
.fc-chevron { transform: rotate(180deg); transition: transform .2s; }
[aria-expanded="true"] .fc-chevron { transform: rotate(0deg); }

.fc-popover { box-shadow: var(--pop-shadow); }
.fc-popover[hidden] { display: none; }

.fc-list-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px;
  border-radius: 10px;
  border: 0;
  background: transparent;
  color: var(--fg);
  text-align: left;
  width: 100%;
}
.fc-list-item:hover { background: var(--subtle); }
.fc-track { gap: 12px; }
.fc-track[aria-selected="true"] { background: var(--subtle); }
.fc-track .fc-dot { width: 6px; height: 6px; border-radius: 50%; flex: none; background: transparent; }
.fc-track[aria-selected="true"] .fc-dot { background: var(--muted); }
.fc-track[aria-selected="true"][data-playing="true"] .fc-dot { background: var(--accent); }
.fc-track[aria-selected="true"] .fc-track-name { font-weight: 500; }

/* Volume slider */
.fc-range {
  -webkit-appearance: none; appearance: none;
  background: transparent; height: 16px; cursor: pointer;
}
.fc-range::-webkit-slider-runnable-track { height: 2px; border-radius: 2px; background: var(--border); }
.fc-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 12px; height: 12px; border-radius: 50%;
  background: var(--fg); margin-top: -5px;
}
.fc-range::-moz-range-track { height: 2px; background: var(--border); }
.fc-range::-moz-range-thumb { width: 12px; height: 12px; border: 0; border-radius: 50%; background: var(--fg); }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition-duration: 0s !important; }
}
