:root {
  color-scheme: light dark;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "PingFang SC", system-ui, sans-serif;
  line-height: 1.5;
  font-weight: 400;
  --accent: #0a84ff;
  --accent-soft: rgba(10, 132, 255, 0.12);
  --accent-dark: #0060df;
  --bg: radial-gradient(circle at top, #e0f0ff 0, #f5f7fb 40%, #f2f2f7 100%);
  --card: rgba(255, 255, 255, 0.82);
  --card-strong: rgba(255, 255, 255, 0.96);
  --border-subtle: rgba(120, 120, 128, 0.12);
  --border-strong: rgba(120, 120, 128, 0.2);
  --text: #111827;
  --text-subtle: #6b7280;
  --shadow-soft: 0 18px 50px rgba(15, 23, 42, 0.18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

.page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 1.5rem clamp(1.5rem, 4vw, 3rem);
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  max-width: 960px;
  margin: 0 auto 1.5rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
}

.brand-mark {
  width: 22px;
  height: 22px;
  border-radius: 8px;
  background: conic-gradient(
    from 190deg,
    #34c759,
    #0a84ff,
    #5e5ce6,
    #ff9500,
    #ff2d55,
    #34c759
  );
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9),
    0 8px 18px rgba(15, 23, 42, 0.35);
}

.brand-text {
  font-weight: 600;
  letter-spacing: 0.04em;
  font-size: 0.95rem;
  text-transform: uppercase;
  color: #111827;
}

.system-time {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1;
  font-size: 0.95rem;
  padding: 0.4rem 0.9rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 8px 18px rgba(15, 23, 42, 0.12);
}

.app-main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.5rem 0 1.5rem;
}

.timer-card {
  width: min(640px, 100%);
  background: linear-gradient(
      135deg,
      rgba(255, 255, 255, 0.85),
      rgba(246, 248, 255, 0.98)
    ),
    radial-gradient(circle at top left, rgba(10, 132, 255, 0.16), transparent 60%);
  border-radius: 32px;
  padding: 1.75rem 1.75rem 1.5rem;
  border: 1px solid var(--border-subtle);
  box-shadow: var(--shadow-soft);
  backdrop-filter: blur(26px);
  -webkit-backdrop-filter: blur(26px);
  display: flex;
  flex-direction: column;
  gap: 1.4rem;
}

.timer-card-top {
  display: flex;
  justify-content: flex-start;
}

.pill-switch {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.9);
  border: 1px solid rgba(120, 120, 128, 0.16);
  box-shadow: inset 0 0 0 0.5px rgba(255, 255, 255, 0.6);
}

.pill-switch-item {
  border: none;
  background: transparent;
  border-radius: 999px;
  padding: 0.35rem 0.9rem;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-subtle);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, transform 0.12s ease;
}

.pill-switch-item.is-active {
  background: #111827;
  color: #f9fafb;
  box-shadow: 0 10px 20px rgba(15, 23, 42, 0.35);
}

.pill-switch-item:active {
  transform: scale(0.97);
}

.time-display {
  border: none;
  background: radial-gradient(
      circle at top left,
      rgba(10, 132, 255, 0.2),
      transparent 55%
    ),
    radial-gradient(circle at bottom right, rgba(88, 86, 214, 0.15), transparent 55%),
    var(--card-strong);
  border-radius: 24px;
  padding: 1.7rem 1.5rem;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.8),
    0 18px 38px rgba(15, 23, 42, 0.2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  cursor: pointer;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.time-display:hover {
  transform: translateY(-1px);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.9),
    0 22px 50px rgba(15, 23, 42, 0.26);
}

.time-main {
  font-size: clamp(3.4rem, 7vw, 4.2rem);
  font-weight: 600;
  letter-spacing: 0.06em;
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum" 1, "ss03" 1;
}

.time-sub {
  font-size: 0.9rem;
  color: var(--text-subtle);
}

.countdown-config {
  display: none;
  flex-direction: column;
  gap: 0.55rem;
}

.countdown-config.is-visible {
  display: flex;
}

.field-label {
  font-size: 0.88rem;
  font-weight: 500;
  color: var(--text-subtle);
}

.countdown-inputs {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.time-input {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.5rem 0.7rem;
  border-radius: 999px;
  background: rgba(249, 250, 251, 0.92);
  border: 1px solid var(--border-subtle);
}

.time-input input {
  width: 4ch;
  border: none;
  background: transparent;
  font-size: 0.95rem;
  font-variant-numeric: tabular-nums;
  text-align: right;
  outline: none;
}

.time-input span {
  font-size: 0.85rem;
  color: var(--text-subtle);
}

.countdown-hint {
  margin: 0;
  font-size: 0.8rem;
  color: var(--text-subtle);
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.control-btn {
  flex: 1;
}

button {
  font-family: inherit;
}

.primary,
.ghost-btn {
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 0.6rem 1.1rem;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease, box-shadow 0.18s ease,
    transform 0.1s ease, border-color 0.18s ease;
}

.primary {
  background: linear-gradient(135deg, #0a84ff, #0c6ce9);
  color: #f9fafb;
  box-shadow: 0 14px 30px rgba(10, 132, 255, 0.35);
}

.primary:hover {
  background: linear-gradient(135deg, #0b74f1, #095fce);
  box-shadow: 0 16px 40px rgba(10, 132, 255, 0.45);
}

.primary:active {
  transform: scale(0.97);
  box-shadow: 0 8px 24px rgba(10, 132, 255, 0.4);
}

.ghost-btn {
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  border-color: rgba(120, 120, 128, 0.2);
  box-shadow: 0 10px 22px rgba(15, 23, 42, 0.12);
}

.ghost-btn:hover {
  background: rgba(250, 250, 251, 0.96);
}

.ghost-btn:active {
  transform: scale(0.97);
}

button:disabled {
  cursor: default;
  opacity: 0.5;
  box-shadow: none;
}

.laps {
  margin-top: 0.25rem;
  border-radius: 24px;
  border: 1px solid var(--border-subtle);
  background: rgba(248, 250, 252, 0.92);
  overflow: hidden;
}

.laps-header,
.laps-row {
  display: grid;
  grid-template-columns: 0.7fr 1fr 1.1fr;
  padding: 0.55rem 1rem;
  font-size: 0.82rem;
}

.laps-header {
  background: rgba(243, 244, 246, 0.98);
  color: var(--text-subtle);
  font-weight: 500;
}

.laps-body {
  max-height: 180px;
  overflow-y: auto;
}

.laps-row {
  border-top: 1px solid rgba(226, 232, 240, 0.9);
  font-variant-numeric: tabular-nums;
}

.laps-row:nth-child(odd) {
  background: rgba(255, 255, 255, 0.9);
}

.laps-row span:nth-child(1) {
  color: var(--text-subtle);
}

.laps-row span:nth-child(2) {
  font-weight: 500;
}

.laps-empty {
  padding: 0.7rem 1rem 0.9rem;
  font-size: 0.8rem;
  color: var(--text-subtle);
}

.app-footer {
  max-width: 960px;
  margin: 0.75rem auto 0;
  font-size: 0.85rem;
  color: var(--text-subtle);
  text-align: center;
}

@media (max-width: 720px) {
  .page {
    padding-inline: 1.1rem;
  }

  .app-header {
    margin-bottom: 1.1rem;
  }

  .timer-card {
    padding-inline: 1.2rem;
    padding-block: 1.4rem 1.2rem;
    border-radius: 26px;
  }

  .laps-header,
  .laps-row {
    padding-inline: 0.75rem;
  }
}
