:root {
  color-scheme: dark;
  --bg: #090d18;
  --bg-soft: #0f1524;
  --surface: rgba(18, 26, 43, 0.78);
  --surface-solid: #121a2b;
  --surface-2: #182136;
  --border: rgba(255,255,255,.09);
  --border-strong: rgba(255,255,255,.15);
  --text: #f7f9fc;
  --muted: #9ba8bd;
  --subtle: #6f7b90;
  --accent: #8eb8ff;
  --accent-strong: #b8d1ff;
  --accent-ink: #08111f;
  --success: #91ddb2;
  --danger: #ff9f9f;
  --shadow: 0 22px 70px rgba(0,0,0,.28);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f7fb;
  --bg-soft: #eef2f8;
  --surface: rgba(255,255,255,.86);
  --surface-solid: #ffffff;
  --surface-2: #f4f6fa;
  --border: rgba(24,35,52,.09);
  --border-strong: rgba(24,35,52,.15);
  --text: #111827;
  --muted: #5e6a7f;
  --subtle: #8691a4;
  --accent: #356fd1;
  --accent-strong: #2459b7;
  --accent-ink: #ffffff;
  --success: #267647;
  --danger: #bc3e3e;
  --shadow: 0 22px 70px rgba(25,42,70,.11);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background:
    radial-gradient(circle at 8% -8%, rgba(100,145,255,.15), transparent 30%),
    radial-gradient(circle at 95% 0%, rgba(157,112,255,.09), transparent 24%),
    var(--bg);
  color: var(--text);
  letter-spacing: -0.015em;
}

button, input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.page-shell {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  height: 84px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 11px;
  color: var(--text);
  text-decoration: none;
  font-size: 17px;
  font-weight: 760;
  letter-spacing: -0.03em;
}

.brand-mark {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 11px;
  background: var(--surface);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.05);
}

.brand-mark svg {
  display: block;
  color: var(--accent);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mini-clock,
.icon-button {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  backdrop-filter: blur(14px);
}

.mini-clock {
  padding: 10px 14px;
  border-radius: 12px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, background .18s ease;
}
.icon-button:hover { transform: translateY(-1px); border-color: var(--border-strong); }

.hero {
  padding: 70px 0 48px;
  max-width: 820px;
}

.eyebrow,
.tool-kicker {
  margin: 0;
  color: var(--accent);
  text-transform: uppercase;
  letter-spacing: .11em;
  font-size: 12px;
  font-weight: 820;
}

.hero h1 {
  margin: 13px 0 14px;
  font-size: clamp(42px, 7vw, 76px);
  line-height: .98;
  letter-spacing: -0.055em;
  max-width: 760px;
}

.hero p {
  margin: 0;
  max-width: 650px;
  color: var(--muted);
  font-size: clamp(17px, 2vw, 20px);
  line-height: 1.65;
}

.tool-shell {
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
  overflow: hidden;
}

.tablist {
  display: flex;
  gap: 6px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  overflow-x: auto;
  scrollbar-width: none;
}
.tablist::-webkit-scrollbar { display: none; }

.tab {
  border: 0;
  border-radius: 12px;
  background: transparent;
  color: var(--muted);
  padding: 11px 15px;
  cursor: pointer;
  white-space: nowrap;
  font-weight: 700;
  transition: background .18s ease, color .18s ease, transform .18s ease;
}
.tab:hover { color: var(--text); background: rgba(255,255,255,.04); }
.tab.is-active {
  background: var(--surface-2);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border);
}

.panels { min-height: 510px; }

.tool-panel {
  padding: clamp(24px, 4vw, 46px);
  min-height: 510px;
}

.clock-layout {
  min-height: 410px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 260px;
  align-items: center;
  gap: 34px;
}

.display-time {
  margin-top: 18px;
  font-size: clamp(64px, 12vw, 132px);
  font-weight: 760;
  line-height: .95;
  letter-spacing: -0.07em;
  font-variant-numeric: tabular-nums;
}

.clock-display { white-space: nowrap; }

@media (min-width: 821px) {
  .clock-display {
    letter-spacing: -0.025em;
  }
}

.sub-display {
  margin: 18px 0 0;
  color: var(--muted);
  font-size: 18px;
}

.clock-meta {
  display: grid;
  gap: 12px;
}

.meta-card {
  min-height: 96px;
  padding: 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: rgba(255,255,255,.025);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 14px;
}

.meta-label {
  color: var(--subtle);
  font-size: 13px;
}

.meta-card strong {
  font-size: 17px;
  line-height: 1.25;
}

.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: end;
  gap: 24px;
  margin-bottom: 30px;
}

.section-heading h2 {
  margin: 8px 0 0;
  font-size: clamp(26px, 4vw, 38px);
  letter-spacing: -0.045em;
}

.helper {
  color: var(--muted);
  margin: 0;
  font-size: 14px;
}

.alarm-form,
.timer-custom {
  display: flex;
  gap: 12px;
  align-items: end;
}

.alarm-form { margin-bottom: 28px; }

.field {
  display: grid;
  gap: 8px;
}

.field.grow { flex: 1; }

.field > span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.field input {
  height: 48px;
  min-width: 155px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface-2);
  color: var(--text);
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease;
}

.field input:focus {
  border-color: color-mix(in srgb, var(--accent) 70%, transparent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 16%, transparent);
}

.button {
  min-height: 48px;
  border: 1px solid transparent;
  border-radius: 12px;
  padding: 0 18px;
  cursor: pointer;
  font-weight: 800;
  transition: transform .16s ease, opacity .16s ease, background .16s ease, border-color .16s ease;
}
.button:hover:not(:disabled) { transform: translateY(-1px); }
.button:active:not(:disabled) { transform: translateY(0); }
.button:disabled { opacity: .38; cursor: not-allowed; }

.button.primary {
  background: var(--accent);
  color: var(--accent-ink);
}
.button.secondary {
  background: var(--surface-2);
  color: var(--text);
  border-color: var(--border);
}
.button.ghost {
  background: transparent;
  color: var(--muted);
  border-color: var(--border);
}

.button.large { min-width: 125px; }
.button.full { width: 100%; }
.align-end { align-self: end; }

.empty-state {
  min-height: 240px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  color: var(--muted);
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
}

.empty-icon { font-size: 28px; opacity: .85; }

.alarm-list {
  display: grid;
  gap: 10px;
}

.alarm-item {
  display: grid;
  grid-template-columns: auto 1fr auto auto;
  align-items: center;
  gap: 14px;
  padding: 15px 16px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.022);
}

.alarm-time {
  min-width: 80px;
  font-size: 23px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.alarm-label {
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toggle {
  width: 46px;
  height: 26px;
  padding: 3px;
  border: 0;
  border-radius: 999px;
  background: var(--surface-2);
  cursor: pointer;
  transition: background .18s ease;
}
.toggle span {
  width: 20px;
  height: 20px;
  display: block;
  border-radius: 50%;
  background: var(--muted);
  transition: transform .18s ease, background .18s ease;
}
.toggle.is-on { background: color-mix(in srgb, var(--accent) 36%, var(--surface-2)); }
.toggle.is-on span {
  transform: translateX(20px);
  background: var(--accent);
}

.delete-button {
  width: 38px;
  height: 38px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}
.delete-button:hover { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 34%, var(--border)); }

.timer-wrap {
  min-height: 360px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 26px;
}

.preset-row,
.control-row {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
}

.chip {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  padding: 9px 13px;
  border-radius: 999px;
  cursor: pointer;
  font-weight: 750;
}
.chip.is-active,
.chip:hover {
  background: var(--surface-2);
  color: var(--text);
}

.timer-custom {
  justify-content: center;
}

.field.compact input {
  min-width: 0;
  width: 110px;
}

.stopwatch-display { font-size: clamp(60px, 11vw, 118px); }

.laps {
  width: min(540px, 100%);
  max-height: 180px;
  overflow: auto;
  display: grid;
  gap: 8px;
}

.lap-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}
.lap-row strong { color: var(--text); }

.segmented {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,.02);
}

.segment {
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  padding: 10px 13px;
  cursor: pointer;
  font-weight: 750;
}
.segment.is-active {
  background: var(--surface-2);
  color: var(--text);
}

.pomo-message {
  margin: -10px 0 0;
  color: var(--muted);
}

.session-badge {
  padding: 8px 10px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  color: var(--accent);
  font-weight: 800;
  font-size: 12px;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 14px;
  padding: 28px 0 14px;
}

.info-card {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: rgba(255,255,255,.018);
  padding: 22px;
}

.info-number {
  color: var(--accent);
  font-size: 12px;
  font-weight: 900;
}

.info-card h3 {
  margin: 20px 0 8px;
  font-size: 18px;
}

.info-card p,
.seo-copy p {
  margin: 0;
  color: var(--muted);
  line-height: 1.65;
}

.seo-copy {
  margin: 64px auto;
  max-width: 820px;
  text-align: center;
}
.seo-copy h2 {
  margin: 0 0 16px;
  font-size: clamp(28px, 4vw, 42px);
  letter-spacing: -0.045em;
}
.seo-copy p + p { margin-top: 14px; }
.notice { font-size: 14px; }

footer {
  min-height: 96px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: var(--subtle);
  border-top: 1px solid var(--border);
  font-size: 13px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 26px;
  transform: translate(-50%, 20px);
  min-width: min(360px, calc(100% - 32px));
  max-width: 520px;
  padding: 12px 16px;
  border: 1px solid var(--border-strong);
  border-radius: 12px;
  background: var(--surface-solid);
  color: var(--text);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease, transform .2s ease;
  text-align: center;
  z-index: 50;
}
.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(3, 7, 15, .74);
  backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
  padding: 20px;
}

.modal-backdrop[hidden] { display: none; }

.alarm-modal {
  width: min(430px, 100%);
  border: 1px solid var(--border-strong);
  border-radius: 24px;
  background: var(--surface-solid);
  padding: 30px;
  text-align: center;
  box-shadow: var(--shadow);
}

.ring-icon {
  width: 72px;
  height: 72px;
  margin: 0 auto 18px;
  display: grid;
  place-items: center;
  border: 1px solid var(--border);
  border-radius: 22px;
  background: var(--surface-2);
  color: var(--accent);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.04);
  animation: ring .65s ease-in-out infinite alternate;
}

.ring-icon svg {
  display: block;
}

.alarm-modal h2 {
  margin: 8px 0 4px;
  font-size: 34px;
}

.alarm-modal p:not(.tool-kicker) {
  margin: 0 0 24px;
  color: var(--muted);
}

@keyframes ring {
  from { transform: rotate(-8deg) scale(.98); }
  to { transform: rotate(8deg) scale(1.02); }
}

@media (max-width: 820px) {
  .hero { padding-top: 48px; }
  .clock-layout {
    grid-template-columns: 1fr;
    min-height: 390px;
  }
  .clock-meta {
    grid-template-columns: repeat(2, 1fr);
  }
  .display-time { font-size: clamp(58px, 18vw, 108px); }
  .info-grid { grid-template-columns: 1fr; }
}

@media (max-width: 620px) {
  .page-shell { width: min(100% - 20px, 1180px); }
  .topbar { height: 72px; }
  .hero { padding: 40px 4px 34px; }
  .hero h1 { font-size: 46px; }
  .hero p { font-size: 16px; }
  .mini-clock { display: none; }
  .tool-panel { padding: 24px 16px; min-height: 500px; }
  .panels { min-height: 500px; }
  .section-heading {
    align-items: start;
    flex-direction: column;
    gap: 10px;
  }
  .alarm-form,
  .timer-custom {
    align-items: stretch;
    flex-direction: column;
  }
  .field input,
  .field.compact input { width: 100%; }
  .alarm-item {
    grid-template-columns: auto 1fr auto;
  }
  .delete-button { grid-column: 3; }
  .alarm-time { font-size: 20px; min-width: 68px; }
  .clock-meta { grid-template-columns: 1fr; }
  .display-time { font-size: clamp(52px, 18vw, 88px); }
  .control-row { width: 100%; }
  .control-row .button {
    flex: 1;
    min-width: 92px;
    padding-inline: 12px;
  }
  .segmented { width: 100%; }
  .segment { flex: 1; min-width: 94px; }
  .footer-dot { display: none; }
  footer { flex-direction: column; gap: 4px; }
}

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