:root {
  --bg: #0f172a;
  --card: #1e293b;
  --text: #f1f5f9;
  --muted: #94a3b8;
  --primary: #6366f1;
  --primary-hover: #818cf8;
  --danger: #ef4444;
  --ring: rgba(99, 102, 241, 0.35);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
}

body {
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(1200px 600px at 50% -10%, #243049, var(--bg));
  color: var(--text);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  -webkit-font-smoothing: antialiased;
}

.card {
  width: 100%;
  max-width: 440px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0)), var(--card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 20px;
  padding: 1.75rem 2rem 2.25rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 0.25rem;
  padding: 0.3rem;
  margin-bottom: 1.75rem;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
}

.tab {
  flex: 1;
  font: inherit;
  font-weight: 600;
  font-size: 0.9rem;
  letter-spacing: 0.04em;
  padding: 0.55rem 0.5rem;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.tab:hover {
  color: var(--text);
}

.tab.is-active {
  background: var(--primary);
  color: #fff;
}

.tab:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ring);
}

/* Panels */
.panel.hidden {
  display: none;
}

/* Display */
.display {
  font-variant-numeric: tabular-nums;
  font-feature-settings: "tnum";
  margin-bottom: 1.75rem;
  user-select: none;
  border-radius: 14px;
  padding: 0.25rem 0;
  transition: box-shadow 0.2s ease;
}

.time-main {
  font-size: clamp(2.75rem, 13vw, 4.5rem);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1;
}

.colon {
  margin: 0 0.02em;
}

.time-ms {
  font-size: clamp(1.4rem, 6.5vw, 2.1rem);
  font-weight: 600;
  color: var(--muted);
}

.display.running .time-main {
  color: var(--primary-hover);
}

/* Settable segments (timer, when idle) */
.seg {
  display: inline-block;
  border-radius: 10px;
  padding: 0 0.06em;
}

.display.settable .seg {
  cursor: ns-resize;
  touch-action: none;
  background: rgba(99, 102, 241, 0.14);
  box-shadow: inset 0 -3px 0 rgba(129, 140, 248, 0.5);
}

.display.settable .seg:hover,
.display.settable .seg:focus-visible {
  outline: none;
  background: rgba(99, 102, 241, 0.28);
}

.hint {
  font-size: 0.8rem;
  color: var(--muted);
  margin: -1rem 0 1.5rem;
  min-height: 1em;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.display.settable + .hint {
  opacity: 1;
}

/* Attention pulse when a timer elapses */
.display.elapsed {
  animation: pulse 0.8s ease-in-out infinite;
}

@keyframes pulse {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(239, 68, 68, 0.45);
  }
}

.display.elapsed .time-main,
.display.elapsed .time-ms {
  color: var(--danger);
}

/* Controls */
.controls {
  display: flex;
  gap: 0.75rem;
  justify-content: center;
}

.btn {
  flex: 1;
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 12px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease, border-color 0.15s ease, opacity 0.15s ease;
  color: var(--text);
}

.btn:active {
  transform: translateY(1px);
}

.btn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 4px var(--ring);
}

.btn-primary {
  background: var(--primary);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-primary.is-running {
  background: var(--danger);
}

.btn-primary.is-running:hover {
  background: #f05252;
}

.btn-ghost {
  background: transparent;
  border-color: rgba(255, 255, 255, 0.14);
  color: var(--muted);
}

.btn-ghost:hover:not(:disabled) {
  border-color: rgba(255, 255, 255, 0.3);
  color: var(--text);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
