:root {
  --ink: #1b2b4b;
  --muted: #6e7f98;
  --blue: #3b82f6;
  --blue-deep: #2f6fe0;
  --bg: #f3f6fa;
  --card: #ffffff;
  --line: rgba(27, 43, 75, 0.07);
  --shadow: 0 10px 28px rgba(52, 84, 140, 0.08);
  --green: #1eaf72;
  --green-bg: #e5f8ee;
  --blue-bg: #e7f1ff;
  --pad-t: max(20px, env(safe-area-inset-top, 0px));
  --pad-b: max(12px, env(safe-area-inset-bottom, 0px));
  --hero: linear-gradient(180deg, #4b93f8 0%, #6bb6f6 48%, #97e0d0 100%);
  --track: linear-gradient(180deg, #3e86f8 0%, #5eaef6 34%, #74d0ec 66%, #8fe3c8 100%);
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100dvh;
  height: 100dvh;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-family: Manrope, -apple-system, BlinkMacSystemFont, "SF Pro Text", "Segoe UI", sans-serif;
  color: var(--ink);
  background: #e7eef6;
  line-height: 1.35;
  text-rendering: optimizeLegibility;
  -webkit-font-smoothing: antialiased;
}
button, input { font: inherit; }
button {
  color: var(--ink);
  background: none;
  border: 0;
  padding: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
button:active { transform: scale(0.98); }
button:focus-visible, input:focus-visible {
  outline: 2px solid var(--blue);
  outline-offset: 2px;
}
h1, h2, p { margin: 0; }
::selection { background: rgba(59, 130, 246, 0.18); }

#app {
  width: 393px;
  height: min(852px, calc(100dvh - 32px));
  margin: 0;
  position: relative;
  overflow: hidden;
  background: var(--bg);
  border-radius: 40px;
  box-shadow: 0 24px 60px rgba(40, 70, 120, 0.16);
}

@media (max-width: 500px) {
  body { background: var(--bg); }
  #app {
    width: 100%;
    height: 100dvh;
    max-height: none;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
  }
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  animation: fade 240ms ease;
}
@keyframes fade {
  from { opacity: 0; }
  to { opacity: 1; }
}

.scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}
.scroll::-webkit-scrollbar { display: none; }

.hero {
  flex: none;
  padding: calc(var(--pad-t) + 8px) 16px 20px;
  color: #fff;
  background: var(--hero);
  border-bottom-left-radius: 32px;
  border-bottom-right-radius: 32px;
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand-pill {
  display: inline-flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.28);
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.01em;
  backdrop-filter: blur(10px);
}
.brand-mark {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #fff;
  color: var(--blue);
  display: grid;
  place-items: center;
  box-shadow: 0 6px 16px rgba(20, 60, 120, 0.14);
}
.brand-mark svg { width: 20px; height: 20px; }
.hero h1 {
  margin-top: 18px;
  font-size: 30px;
  line-height: 1.12;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.start-card {
  margin-top: 18px;
  padding: 16px;
  background: #fff;
  color: var(--ink);
  border-radius: 24px;
  box-shadow: 0 14px 32px rgba(30, 70, 140, 0.14);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.start-meta { display: flex; gap: 12px; align-items: center; }
.meta-kicker {
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}
.meta-time {
  margin-top: 1px;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.meta-sub {
  margin-top: 1px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.btn-start {
  width: 100%;
  height: 54px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: linear-gradient(180deg, #5b9bff 0%, #3d7ef5 100%);
  color: #fff;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
  box-shadow: 0 8px 18px rgba(47, 111, 228, 0.28);
}
.btn-start svg { width: 14px; height: 14px; }
.btn-ghost {
  width: 100%;
  height: 46px;
  border-radius: 999px;
  color: var(--blue-deep);
  font-size: 16px;
  font-weight: 800;
}

.home .scroll { padding: 18px 16px calc(var(--pad-b) + 104px); }
.section-head { margin: 2px 6px 10px; }
.section-head h2 {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.plan {
  background: #fff;
  border-radius: 24px;
  box-shadow: var(--shadow);
  padding: 4px 14px;
}
.plan-row {
  display: grid;
  grid-template-columns: 42px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.plan-row:last-child { border-bottom: 0; }
.plan-text strong {
  display: block;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.plan-text small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.plan-time {
  font-style: normal;
  font-weight: 800;
  color: #7e8da6;
  font-size: 13px;
  font-variant-numeric: tabular-nums;
}

.tile {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  display: grid;
  place-items: center;
}
.tile svg { width: 22px; height: 22px; }
.tile.green { background: var(--green-bg); color: var(--green); }
.tile.blue { background: var(--blue-bg); color: var(--blue); }

.dock {
  position: absolute;
  left: 16px;
  right: 16px;
  bottom: calc(var(--pad-b) + 10px);
  height: 66px;
  padding: 6px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  background: #fff;
  border-radius: 24px;
  z-index: 5;
  box-shadow: 0 12px 32px rgba(40, 70, 120, 0.12), 0 0 0 1px rgba(27, 43, 75, 0.04);
}
.dock button {
  border-radius: 18px;
  color: #93a0b5;
  font-size: 11px;
  font-weight: 800;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
}
.dock button svg { width: 22px; height: 22px; }
.dock button.active { color: var(--blue-deep); background: #f3f7ff; }
.screen.home::after,
.screen.settings::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: calc(var(--pad-b) + 112px);
  background: linear-gradient(180deg, rgba(243, 246, 250, 0), var(--bg) 42%);
  pointer-events: none;
  z-index: 4;
}

.page-head {
  flex: none;
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 6px;
  padding: calc(var(--pad-t) + 6px) 12px 16px 8px;
  color: #fff;
  background: linear-gradient(180deg, #4b93f8 0%, #67b2f6 100%);
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
}
.page-head h1 {
  text-align: center;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.icon-btn {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  color: #fff;
}
.icon-btn svg { width: 22px; height: 22px; }
.text-btn {
  height: 32px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
}
.settings .scroll { padding: 14px 16px calc(var(--pad-b) + 108px); }
.settings-total {
  margin: 2px 6px 12px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}
.settings-total strong { color: var(--ink); font-weight: 800; }
.settings-list { display: flex; flex-direction: column; gap: 12px; }
.set-card {
  background: #fff;
  border-radius: 22px;
  box-shadow: var(--shadow);
  padding: 14px 14px 12px;
}
.set-head, .sound-row { display: flex; gap: 12px; align-items: center; }
.set-head h2, .sound-copy h2 {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
}
.set-head p, .sound-copy p {
  margin-top: 2px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.sound-copy { flex: 1; min-width: 0; }
.field {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.field-name { font-size: 14px; font-weight: 800; letter-spacing: -0.02em; }
.field-unit { margin-top: 2px; color: var(--muted); font-size: 12px; font-weight: 650; }
.stepper {
  flex: none;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 14px;
  background: #f3f6fb;
}
.stepper button {
  width: 36px;
  height: 36px;
  border-radius: 11px;
  background: #fff;
  color: var(--blue-deep);
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
  box-shadow: 0 1px 2px rgba(30, 60, 100, 0.06);
}
.stepper button:disabled { opacity: 0.35; transform: none; }
.stepper input {
  width: 48px;
  border: 0;
  background: transparent;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}
.stepper input:focus { outline: none; }
.card-note {
  margin-top: 10px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 650;
}
.card-note:empty { display: none; }
.switch {
  width: 52px;
  height: 32px;
  border-radius: 999px;
  background: #d5deea;
  position: relative;
  flex: none;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(20, 40, 80, 0.16);
  transition: transform 180ms ease;
}
.switch[aria-checked="true"] { background: #3dcb8e; }
.switch[aria-checked="true"]::after { transform: translateX(20px); }
.switch:active { transform: none; }

.session { touch-action: none; user-select: none; -webkit-user-select: none; }
.session[data-theme="track"] {
  color: #fff;
  background: var(--track);
}
.session[data-theme="focus"] {
  color: var(--ink);
  background: var(--bg);
}
.session[data-theme="rest"] {
  color: #fff;
  background: radial-gradient(90% 70% at 50% 40%, #1c406e 0%, #101e36 72%);
}
.session-top {
  flex: none;
  display: grid;
  grid-template-columns: 72px 1fr 72px;
  gap: 8px;
  align-items: center;
  padding: calc(var(--pad-t) + 8px) 14px 8px;
}
.session[data-theme="focus"] .session-top {
  color: #fff;
  background: linear-gradient(180deg, #4b93f8 0%, #67b2f6 100%);
  border-bottom-left-radius: 24px;
  border-bottom-right-radius: 24px;
  padding-bottom: 14px;
}
.session-titles { min-width: 0; text-align: center; }
.session-kicker { font-size: 12px; font-weight: 800; opacity: 0.78; }
.session-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.03em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.session-hint {
  margin-top: 2px;
  font-size: 13px;
  font-weight: 700;
  opacity: 0.9;
}
.session-hint:empty { display: none; }
.session-hint.pop { animation: pop 360ms ease; }
@keyframes pop {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 0.9; transform: none; }
}
.stop, .clock {
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
}
.stop {
  justify-self: start;
  min-width: 64px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 14px;
  font-weight: 800;
  backdrop-filter: blur(10px);
}
.clock {
  justify-self: end;
  min-width: 68px;
  padding: 0 10px;
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  font-size: 15px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(10px);
}
.session[data-theme="focus"] .clock,
.session[data-theme="rest"] .clock,
.session[data-theme="rest"] .session-titles { visibility: hidden; }
.stage { position: relative; flex: 1; min-height: 0; }
.stage-canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
.session-bottom { flex: none; padding: 8px 22px calc(var(--pad-b) + 14px); }
.session-progress {
  height: 4px;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.28);
  overflow: hidden;
}
.session-progress > span {
  display: block;
  height: 100%;
  width: 100%;
  background: #fff;
  border-radius: inherit;
  transform: scaleX(0);
  transform-origin: left center;
}
.session[data-theme="focus"] .session-progress { background: rgba(47, 111, 228, 0.12); }
.session[data-theme="focus"] .session-progress > span {
  background: linear-gradient(90deg, #4c8dff, #7ee0b8);
}
.session[data-theme="rest"] .session-progress { background: rgba(255, 255, 255, 0.1); }
.session[data-theme="rest"] .session-progress > span { background: rgba(255, 255, 255, 0.55); }

.timer-view, .rest-view { position: absolute; inset: 0; }
.timer-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 22px;
  padding: 22px 22px 8px;
}
.ring-box {
  position: relative;
  width: min(64vw, 248px);
  aspect-ratio: 1;
}
.ring-box svg { width: 100%; height: 100%; display: block; }
.ring-track { fill: none; stroke: #e4eef8; stroke-width: 12; }
.ring-value {
  fill: none;
  stroke: url(#ringGrad);
  stroke-width: 12;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 110px 110px;
}
.ring-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ring-num {
  font-size: 52px;
  font-weight: 800;
  letter-spacing: -0.045em;
  font-variant-numeric: tabular-nums;
  line-height: 1;
}
.ring-center span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
}
.hint-card {
  width: min(100%, 320px);
  background: #fff;
  border-radius: 20px;
  padding: 14px 16px;
  text-align: center;
  box-shadow: var(--shadow);
}
.hint-card p {
  font-size: 16px;
  font-weight: 800;
  letter-spacing: -0.02em;
  line-height: 1.3;
}
.hint-card small {
  display: block;
  margin-top: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

.rest-view {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
}
.rest-glow {
  position: absolute;
  left: 50%;
  top: 46%;
  width: 300px;
  height: 300px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(150, 200, 255, 0.34), rgba(150, 200, 255, 0) 68%);
  animation: restPulse 5s ease-in-out infinite;
}
@keyframes restPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(0.94); opacity: 0.75; }
  50% { transform: translate(-50%, -50%) scale(1.06); opacity: 1; }
}
.rest-kicker, .rest-title, .rest-num, .rest-hint { position: relative; }
.rest-kicker {
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  opacity: 0.7;
}
.rest-title {
  margin-top: 8px;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.03em;
}
.rest-num {
  margin: 8px 0 12px;
  font-size: 88px;
  font-weight: 800;
  letter-spacing: -0.05em;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.rest-hint {
  max-width: 240px;
  color: rgba(255, 255, 255, 0.74);
  font-size: 15px;
  font-weight: 700;
}

.screen.done {
  background: linear-gradient(165deg, #4b93f8 0%, #6ebef4 46%, #a7e7d4 100%);
}
.done-card {
  margin: auto 20px;
  width: calc(100% - 40px);
  background: #fff;
  border-radius: 28px;
  padding: 32px 20px 12px;
  text-align: center;
  box-shadow: 0 16px 40px rgba(30, 60, 110, 0.14);
}
.done-mark {
  width: 84px;
  height: 84px;
  margin: 0 auto 16px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  color: #fff;
  background: linear-gradient(180deg, #67e4b5, #1eaf72);
  box-shadow: 0 10px 24px rgba(30, 175, 114, 0.28);
}
.done-mark svg { width: 38px; height: 38px; }
.done-card h1 {
  font-size: 28px;
  font-weight: 800;
  letter-spacing: -0.04em;
}
.done-card > p {
  margin-top: 6px;
  color: var(--muted);
  font-weight: 700;
}
.time-pill {
  display: inline-flex;
  margin-top: 12px;
  padding: 6px 12px;
  border-radius: 999px;
  background: #f3f7ff;
  color: var(--blue-deep);
  font-size: 13px;
  font-weight: 800;
}
.done-card .btn-start { margin-top: 22px; }

.toast {
  position: absolute;
  left: 50%;
  bottom: calc(var(--pad-b) + 92px);
  transform: translateX(-50%);
  z-index: 8;
  padding: 10px 14px;
  border-radius: 999px;
  background: #1b2b4b;
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  pointer-events: none;
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .screen, .session-hint.pop, .rest-glow, .switch::after { animation: none; transition: none; }
}
