:root {
  color-scheme: light;
  --bg: #f6f3ec;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: #ffffff;
  --text: #17202a;
  --muted: #687385;
  --line: rgba(23, 32, 42, 0.12);
  --accent: #1d7a8c;
  --accent-strong: #0e5f70;
  --accent-soft: rgba(29, 122, 140, 0.14);
  --danger: #b64747;
  --shadow: 0 22px 70px rgba(31, 47, 60, 0.16);
}

:root.dark {
  color-scheme: dark;
  --bg: #171819;
  --panel: rgba(37, 40, 42, 0.78);
  --panel-strong: #24282b;
  --text: #f4f1ea;
  --muted: #a7afb8;
  --line: rgba(244, 241, 234, 0.14);
  --accent: #6ec7b8;
  --accent-strong: #91ddcf;
  --accent-soft: rgba(110, 199, 184, 0.16);
  --danger: #ff8a82;
  --shadow: 0 22px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(circle at 18% 16%, rgba(48, 132, 154, 0.22), transparent 28%),
    linear-gradient(145deg, var(--bg), #e8ece9 72%);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
}

:root.dark body {
  background:
    radial-gradient(circle at 18% 16%, rgba(110, 199, 184, 0.16), transparent 28%),
    linear-gradient(145deg, var(--bg), #202326 72%);
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 980px);
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(320px, 0.8fr);
  gap: 20px;
  align-items: stretch;
}

.watch-panel,
.laps-panel {
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(20px);
}

.watch-panel {
  min-height: 620px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 30px;
  border-radius: 8px;
}

.laps-panel {
  max-height: 620px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  padding: 24px;
  border-radius: 8px;
}

.top-bar,
.laps-header,
.controls,
.hint-row,
.lap-row {
  display: flex;
  align-items: center;
}

.top-bar,
.laps-header {
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent-strong);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 1;
}

h2 {
  font-size: 1.35rem;
}

.icon-button,
.text-button,
.control-button {
  border: 0;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background-color 160ms ease,
    opacity 160ms ease;
}

.icon-button {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 1.25rem;
}

.icon-button:hover,
.text-button:hover,
.control-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.dial {
  position: relative;
  width: min(78vw, 420px);
  aspect-ratio: 1;
  margin: 26px auto;
  display: grid;
  place-items: center;
}

.progress-ring {
  width: 100%;
  height: 100%;
  transform: rotate(-90deg);
  filter: drop-shadow(0 18px 22px rgba(22, 55, 64, 0.14));
}

.ring-track,
.ring-progress {
  fill: none;
  stroke-width: 10;
}

.ring-track {
  stroke: var(--line);
}

.ring-progress {
  stroke: var(--accent);
  stroke-linecap: round;
  stroke-dasharray: 603.19;
  stroke-dashoffset: 603.19;
  transition: stroke-dashoffset 120ms linear;
}

.time-wrap {
  position: absolute;
  inset: 12%;
  display: grid;
  place-items: center;
  align-content: center;
  border-radius: 50%;
  background: var(--panel-strong);
  border: 1px solid var(--line);
}

.time {
  width: 100%;
  padding: 0 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  font-size: clamp(2.45rem, 8vw, 5.2rem);
  font-weight: 850;
  line-height: 1;
}

.status {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.98rem;
}

.controls {
  justify-content: center;
  gap: 12px;
}

.control-button {
  min-width: 112px;
  min-height: 52px;
  padding: 0 22px;
  border-radius: 999px;
  font-weight: 800;
}

.control-button.primary {
  min-width: 148px;
  background: var(--accent);
  color: #fff;
}

:root.dark .control-button.primary {
  color: #102224;
}

.control-button.secondary,
.text-button {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.control-button:disabled,
.text-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.hint-row {
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px 16px;
  color: var(--muted);
  font-size: 0.9rem;
}

kbd {
  min-width: 28px;
  display: inline-grid;
  place-items: center;
  padding: 3px 7px;
  border-radius: 6px;
  border: 1px solid var(--line);
  background: var(--panel-strong);
  color: var(--text);
  font-size: 0.78rem;
  font-weight: 800;
}

.text-button {
  min-height: 36px;
  padding: 0 14px;
  border-radius: 999px;
  font-weight: 800;
}

.laps-list {
  min-height: 0;
  margin: 22px 0 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.empty-state {
  padding: 34px 14px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.lap-row {
  justify-content: space-between;
  gap: 14px;
  padding: 14px 4px;
  border-bottom: 1px solid var(--line);
}

.lap-index {
  width: 50px;
  color: var(--muted);
  font-weight: 800;
}

.lap-time {
  font-variant-numeric: tabular-nums;
  font-size: 1.15rem;
  font-weight: 850;
}

.lap-delta {
  min-width: 88px;
  text-align: right;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

@media (max-width: 820px) {
  body {
    display: block;
    padding: 16px;
  }

  .app-shell {
    grid-template-columns: 1fr;
  }

  .watch-panel {
    min-height: auto;
    padding: 22px;
  }

  .laps-panel {
    max-height: 380px;
  }
}

@media (max-width: 520px) {
  .controls {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .control-button {
    width: 100%;
    min-width: 0;
  }

  .control-button.primary {
    grid-column: 1 / -1;
    grid-row: 1;
  }

  .hint-row {
    margin-top: 18px;
  }
}
