:root {
  color-scheme: light;
  --ink: #17202a;
  --muted: #667085;
  --paper: #f6f1e7;
  --card: #fffdf8;
  --line: #ded8cc;
  --green: #35b56f;
  --green-soft: #e7f6ed;
  --orange: #f0a229;
  --orange-soft: #fff0d7;
  --red: #e95555;
  --red-soft: #fde6e4;
  --shadow: 0 24px 70px rgba(66, 55, 37, 0.1);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 8%, rgba(240, 162, 41, 0.08), transparent 24rem),
    radial-gradient(circle at 92% 95%, rgba(53, 181, 111, 0.08), transparent 28rem),
    var(--paper);
}

button, input { font: inherit; }
button { color: inherit; }

.app-shell { min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 clamp(20px, 4vw, 64px);
  border-bottom: 1px solid rgba(124, 112, 92, 0.18);
  background: rgba(246, 241, 231, 0.86);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--ink);
  text-decoration: none;
  font-size: 1.3rem;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-mark { display: flex; align-items: flex-end; gap: 2px; width: 27px; height: 27px; transform: rotate(-2deg); }
.brand-mark span { width: 7px; border-radius: 4px; }
.brand-mark span:nth-child(1) { height: 17px; background: var(--green); }
.brand-mark span:nth-child(2) { height: 23px; background: var(--orange); }
.brand-mark span:nth-child(3) { height: 12px; background: var(--red); }

.header-actions { display: flex; gap: 8px; }
.icon-button {
  min-height: 40px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: rgba(255,255,255,.48);
  cursor: pointer;
  font-size: .82rem;
  font-weight: 650;
  transition: .2s ease;
}
.icon-button:hover { background: #fff; border-color: #c9c1b4; transform: translateY(-1px); }
.icon-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-button[aria-pressed="false"] .sound-wave { opacity: .2; }

.main-layout {
  width: min(1440px, 100%);
  margin: auto;
  padding: clamp(22px, 3.5vw, 52px) clamp(18px, 4vw, 64px);
  display: grid;
  grid-template-columns: minmax(520px, 1fr) minmax(330px, 430px);
  gap: clamp(28px, 4vw, 64px);
  align-items: center;
}

.timer-stage { min-width: 0; }
.stage-heading { display: flex; justify-content: space-between; align-items: flex-end; gap: 20px; margin-bottom: 22px; }
.eyebrow { margin: 0 0 6px; color: #8a7250; font-size: .71rem; font-weight: 800; letter-spacing: .17em; text-transform: uppercase; }
h1, h2 { margin: 0; letter-spacing: -.045em; }
h1 { font-family: Georgia, "Times New Roman", serif; font-size: clamp(2rem, 3.2vw, 3.25rem); font-weight: 500; line-height: 1.05; }
h2 { font-size: 1.36rem; line-height: 1.2; }

.status-pill {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  border-radius: 999px;
  background: var(--green-soft);
  color: #197745;
  font-size: .76rem;
  font-weight: 750;
  transition: .25s ease;
}
.status-pill[data-phase="orange"] { background: var(--orange-soft); color: #9a5c05; }
.status-pill[data-phase="red"], .status-pill[data-phase="done"] { background: var(--red-soft); color: #a82e2e; }
.status-pill[data-phase="paused"] { background: #ece9e3; color: #635d54; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; box-shadow: 0 0 0 4px color-mix(in srgb, currentColor 14%, transparent); }

.clock-wrap { display: grid; grid-template-columns: minmax(340px, 570px) 112px; justify-content: center; align-items: center; gap: clamp(18px, 3vw, 38px); }
.clock {
  --green-end: 60%;
  --red-start: 85%;
  position: relative;
  width: min(100%, 570px);
  aspect-ratio: 1;
  border-radius: 50%;
  filter: drop-shadow(0 26px 38px rgba(52, 45, 34, .13));
}
.zone-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--green) 0 var(--green-end), var(--orange) var(--green-end) var(--red-start), var(--red) var(--red-start) 100%);
}
.zone-ring::after { content: ""; position: absolute; inset: 19px; border-radius: 50%; background: var(--card); }
.ticks { position: absolute; inset: 0; z-index: 3; pointer-events: none; }
.tick { position: absolute; inset: 0; width: 2px; height: 100%; margin: auto; transform-origin: center; }
.tick::before { content: ""; display: block; width: 2px; height: 10px; margin-top: 5px; border-radius: 2px; background: rgba(255,255,255,.65); }
.tick.major { width: 3px; }
.tick.major::before { width: 3px; height: 17px; background: rgba(255,255,255,.95); }
.clock-face { position: absolute; z-index: 2; inset: 29px; overflow: hidden; border-radius: 50%; background: var(--card); box-shadow: inset 0 0 0 1px rgba(69, 57, 40, .06); }
.clock-face::before {
  content: "";
  position: absolute;
  inset: 7%;
  border-radius: 50%;
  background: radial-gradient(circle, color-mix(in srgb, var(--phase-color) 14%, white) 0, color-mix(in srgb, var(--phase-color) 6%, white) 58%, transparent 59%);
  transition: background .4s ease;
}
.elapsed-shade { position: absolute; inset: 0; background: conic-gradient(from 0deg, rgba(24,32,42,.075) calc(var(--progress) * 1turn), transparent 0); }
.clock-center { position: absolute; z-index: 4; inset: 23%; display: flex; flex-direction: column; align-items: center; justify-content: center; border-radius: 50%; text-align: center; }
.phase-label { margin-bottom: 7px; color: color-mix(in srgb, var(--phase-color) 78%, #17202a); font-size: clamp(.72rem, 1.2vw, .9rem); font-weight: 800; letter-spacing: .1em; text-transform: uppercase; transition: color .25s; }
.time-display { font-variant-numeric: tabular-nums; font-size: clamp(4rem, 8.2vw, 7.25rem); font-weight: 760; line-height: .95; letter-spacing: -.075em; }
.time-caption { margin-top: 13px; color: var(--muted); font-size: clamp(.72rem, 1.1vw, .88rem); }
.hand { position: absolute; z-index: 3; left: calc(50% - 2px); top: 6%; width: 4px; height: 44%; transform-origin: 50% 100%; transform: rotate(calc(var(--progress) * 1turn)); transition: transform .15s linear; }
.hand::before { content: ""; position: absolute; inset: 0; border-radius: 4px; background: #28323b; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.hand span { position: absolute; top: -3px; left: -3px; width: 10px; height: 10px; border-radius: 50%; background: #28323b; }
.clock-pin { position: absolute; z-index: 5; top: 50%; left: 50%; width: 17px; height: 17px; border: 4px solid var(--card); border-radius: 50%; background: #28323b; transform: translate(-50%,-50%); box-shadow: 0 2px 7px rgba(0,0,0,.22); }

.zone-legend { display: flex; flex-direction: column; gap: 11px; }
.zone-legend > div { display: grid; grid-template-columns: 11px 1fr; column-gap: 9px; align-items: center; padding-bottom: 10px; border-bottom: 1px solid var(--line); }
.zone-legend > div:last-child { border: 0; }
.legend-swatch { grid-row: 1 / span 2; width: 10px; height: 34px; border-radius: 6px; }
.legend-swatch.green { background: var(--green); }
.legend-swatch.orange { background: var(--orange); }
.legend-swatch.red { background: var(--red); }
.zone-legend strong { font-size: .75rem; }
.zone-legend small { color: var(--muted); font-size: .68rem; }

.timer-actions { display: flex; justify-content: center; gap: 10px; margin-top: 24px; }
.primary-button, .secondary-button {
  min-height: 48px;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 9px;
  padding: 12px 23px;
  border-radius: 13px;
  font-weight: 760;
  cursor: pointer;
  transition: .2s ease;
}
.primary-button { border: 1px solid var(--ink); color: #fff; background: var(--ink); box-shadow: 0 8px 20px rgba(23,32,42,.15); }
.primary-button:hover { background: #2b3845; transform: translateY(-1px); }
.primary-button svg { width: 19px; fill: currentColor; }
.primary-button.is-paused svg path { d: path("M7 5h4v14H7V5Zm6 0h4v14h-4V5Z"); }
.secondary-button { border: 1px solid var(--line); background: transparent; }
.secondary-button:hover:not(:disabled) { background: rgba(255,255,255,.6); transform: translateY(-1px); }
.secondary-button:disabled { opacity: .42; cursor: not-allowed; }
.secondary-button svg { width: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.shortcut-hint { margin: 13px 0 0; color: #857f74; text-align: center; font-size: .7rem; }
.shortcut-hint span { margin: 0 6px; }
kbd { padding: 2px 5px; border: 1px solid #d3ccbf; border-bottom-width: 2px; border-radius: 4px; background: rgba(255,255,255,.45); font-family: inherit; font-size: .65rem; }

.settings-panel { padding: 29px; border: 1px solid rgba(129,115,91,.2); border-radius: 24px; background: rgba(255,253,248,.88); box-shadow: var(--shadow); backdrop-filter: blur(12px); }
.panel-heading { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 25px; }
.session-badge { padding: 6px 9px; border-radius: 8px; color: #7e6542; background: #f2eadb; font-size: .65rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.setting-section + .setting-section { margin-top: 27px; padding-top: 24px; border-top: 1px solid var(--line); }
.setting-label { display: block; font-size: .78rem; font-weight: 800; }
.duration-inputs { display: flex; align-items: center; gap: 8px; margin-top: 10px; }
.time-field { flex: 1; position: relative; min-width: 0; }
.time-field input { width: 100%; height: 70px; padding: 7px 12px 22px; border: 1px solid var(--line); border-radius: 14px; outline: none; color: var(--ink); background: #fff; font-size: 1.8rem; font-weight: 760; text-align: center; font-variant-numeric: tabular-nums; transition: .2s; }
.time-field input:focus { border-color: #8d806d; box-shadow: 0 0 0 3px rgba(141,128,109,.12); }
.time-field span { position: absolute; left: 0; right: 0; bottom: 9px; color: var(--muted); text-align: center; font-size: .62rem; }
.time-separator { font-size: 1.5rem; font-weight: 700; }
.presets { display: grid; grid-template-columns: repeat(6, 1fr); gap: 5px; margin-top: 9px; }
.presets button { padding: 7px 2px; border: 1px solid transparent; border-radius: 8px; color: var(--muted); background: #f2eee7; font-size: .65rem; font-weight: 700; cursor: pointer; }
.presets button:hover, .presets button.active { border-color: #cfc6b8; color: var(--ink); background: #fff; }
.setting-title-row { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; }
.setting-title-row p { margin: 4px 0 0; color: var(--muted); font-size: .7rem; }
.text-button { padding: 0; border: 0; color: #8a7250; background: transparent; font-size: .65rem; font-weight: 750; cursor: pointer; white-space: nowrap; }
.text-button:hover { text-decoration: underline; }
.range-setting { display: block; margin-top: 21px; }
.range-copy { display: flex; justify-content: space-between; color: #424b55; font-size: .71rem; font-weight: 650; }
.range-copy span { display: flex; align-items: center; gap: 7px; }
.range-copy i { width: 8px; height: 8px; border-radius: 50%; background: var(--green); }
.orange-range .range-copy i { background: var(--red); }
.range-copy output { font-variant-numeric: tabular-nums; font-weight: 800; }
.range-setting input { width: 100%; margin: 11px 0 0; accent-color: var(--green); cursor: pointer; }
.orange-range input { accent-color: var(--red); }
.timeline { display: flex; gap: 3px; height: 10px; margin-top: 23px; }
.timeline span { width: var(--size); border-radius: 3px; transition: width .2s ease; }
.timeline-green { background: var(--green); }
.timeline-orange { background: var(--orange); }
.timeline-red { background: var(--red); }
.timeline-labels { display: flex; justify-content: space-between; margin-top: 6px; color: #968f84; font-size: .58rem; }
.classroom-tip { display: flex; align-items: flex-start; gap: 11px; margin-top: 25px; padding: 14px; border-radius: 13px; background: #f1ede5; }
.classroom-tip svg { flex: none; width: 20px; fill: none; stroke: #806842; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.classroom-tip p { display: flex; flex-direction: column; gap: 3px; margin: 0; font-size: .67rem; line-height: 1.45; }
.classroom-tip span { color: var(--muted); }

.completion-dialog[hidden] { display: none; }
.completion-dialog { position: fixed; z-index: 20; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(23,32,42,.55); backdrop-filter: blur(8px); }
.dialog-card { width: min(430px, 100%); padding: 38px; border-radius: 24px; background: var(--card); box-shadow: 0 30px 90px rgba(0,0,0,.2); text-align: center; animation: dialog-in .35s ease both; }
.dialog-icon { display: grid; place-items: center; width: 56px; height: 56px; margin: 0 auto 18px; border-radius: 50%; color: #fff; background: var(--green); font-size: 1.5rem; font-weight: 900; }
.dialog-card h2 { font-family: Georgia, "Times New Roman", serif; font-size: 2rem; font-weight: 500; }
.dialog-card > p:not(.eyebrow) { margin: 10px 0 24px; color: var(--muted); }
.dialog-card .primary-button { width: 100%; }
.toast { position: fixed; z-index: 30; left: 50%; bottom: 24px; padding: 10px 15px; border-radius: 10px; color: #fff; background: var(--ink); box-shadow: 0 10px 35px rgba(0,0,0,.18); font-size: .75rem; font-weight: 650; transform: translate(-50%, 20px); opacity: 0; pointer-events: none; transition: .25s ease; }
.toast.visible { transform: translate(-50%, 0); opacity: 1; }

@keyframes dialog-in { from { opacity: 0; transform: translateY(14px) scale(.97); } }

@media (max-width: 980px) {
  .main-layout { grid-template-columns: 1fr; max-width: 760px; }
  .settings-panel { grid-row: 1; }
  .clock-wrap { grid-template-columns: minmax(320px, 520px) 105px; }
}

@media (max-width: 600px) {
  .topbar { height: 64px; padding: 0 16px; }
  .button-label { display: none; }
  .icon-button { width: 40px; padding: 8px; justify-content: center; }
  .main-layout { padding: 22px 14px 34px; }
  .settings-panel { padding: 22px 18px; border-radius: 19px; }
  .stage-heading { align-items: flex-start; flex-direction: column; }
  .clock-wrap { display: flex; flex-direction: column; }
  .clock { width: min(100%, 430px); }
  .clock-face { inset: 23px; }
  .zone-ring::after { inset: 15px; }
  .zone-legend { width: 100%; display: grid; grid-template-columns: repeat(3, 1fr); }
  .zone-legend > div { border: 0; padding: 0; }
  .legend-swatch { height: 28px; }
  .timer-actions { flex-direction: column; }
  .primary-button, .secondary-button { width: 100%; }
  .shortcut-hint { display: none; }
}

@media (max-width: 380px) {
  .presets { grid-template-columns: repeat(3, 1fr); }
  .time-display { font-size: 3.6rem; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition-duration: .01ms !important; animation-duration: .01ms !important; }
}

body.fullscreen-mode .topbar, body.fullscreen-mode .settings-panel, body.fullscreen-mode .stage-heading, body.fullscreen-mode .shortcut-hint { display: none; }
body.fullscreen-mode .main-layout { display: flex; width: 100%; min-height: 100vh; padding: 18px; justify-content: center; }
body.fullscreen-mode .timer-stage { width: 100%; display: flex; flex-direction: column; justify-content: center; }
body.fullscreen-mode .clock-wrap { grid-template-columns: min(78vh, 78vw) 120px; }
body.fullscreen-mode .timer-actions { margin-top: 14px; }
