:root {
  --bg-primary: #0a0a0f;
  --bg-secondary: #14141f;
  --bg-tertiary: #1e1e2e;
  --text-primary: #ffffff;
  --text-secondary: #a0a0b0;
  --text-muted: #606070;
  --accent: #00d4ff;
  --accent-secondary: #00ff88;
  --danger: #ff4466;
  --warning: #ffaa00;
  --focus-ring: #00d4ff;
  --focus-glow: rgba(0, 212, 255, 0.4);
  --radius-md: 12px;
  --radius-sm: 8px;
  --radius-lg: 18px;
}

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

html, body {
  width: 600px;
  height: 600px;
  overflow: hidden;
  background: #000;
  color: var(--text-primary);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

#app { width: 100%; height: 100%; position: relative; }

.screen {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
  display: flex;
  flex-direction: column;
  padding: 24px;
  gap: 18px;
}
.screen.hidden { display: none; }

.focusable {
  transition: all 0.15s ease;
  border: 2px solid transparent;
  cursor: pointer;
  outline: none;
}
.focusable:focus {
  border-color: var(--focus-ring);
  box-shadow: 0 0 20px var(--focus-glow);
}

.hidden { display: none !important; }

/* ---------- HEADER ---------- */
.app-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  border: 1px solid var(--bg-tertiary);
}
.app-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--accent);
}
.app-sub {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-secondary);
}

/* ---------- TIME ROW (HOME) ---------- */
.time-row {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--bg-tertiary);
  padding: 18px 14px;
}

.seg-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.seg {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 84px;
  font-weight: 800;
  line-height: 1;
  min-width: 130px;
  height: 120px;
  padding: 0 10px;
  background: var(--bg-secondary);
  border-radius: var(--radius-md);
  color: var(--text-primary);
  font-variant-numeric: tabular-nums;
  letter-spacing: -2px;
}
.seg.focusable:focus {
  background: var(--bg-tertiary);
  color: var(--accent);
  transform: scale(1.04);
}
.seg.editing {
  color: var(--accent);
}

.seg-label {
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text-muted);
}

.colon {
  font-size: 64px;
  font-weight: 700;
  color: var(--text-muted);
  margin-top: -28px;
  user-select: none;
}

/* ---------- PRESETS ---------- */
.presets {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}
.preset {
  background: var(--bg-secondary);
  color: var(--text-primary);
  border-radius: var(--radius-md);
  height: 50px;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 1px;
  font-family: inherit;
}
.preset.focusable:focus {
  background: var(--bg-tertiary);
  color: var(--accent);
}

/* ---------- ACTION BUTTONS ---------- */
.actions-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.actions-row.single {
  grid-template-columns: 1fr;
  padding: 0 60px;
}

.btn {
  height: 88px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  border-radius: var(--radius-md);
  font-family: inherit;
  font-size: 22px;
  font-weight: 800;
  letter-spacing: 2px;
  color: var(--text-primary);
}
.btn-icon {
  font-size: 22px;
  line-height: 1;
}
.btn-primary {
  background: var(--bg-secondary);
  color: var(--accent);
}
.btn-primary.focusable:focus {
  background: var(--accent);
  color: var(--bg-primary);
  box-shadow: 0 0 28px var(--focus-glow);
}
.btn-secondary {
  background: var(--bg-secondary);
  color: var(--text-secondary);
}
.btn-secondary.focusable:focus {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.btn-danger {
  background: var(--bg-secondary);
  color: var(--danger);
}
.btn-danger.focusable:focus {
  background: var(--danger);
  color: var(--text-primary);
  box-shadow: 0 0 28px rgba(255, 68, 102, 0.4);
}

/* ---------- HINT BAR ---------- */
.hint-bar {
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 14px;
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--text-muted);
}

/* ---------- RUNNING SCREEN ---------- */
.running-display {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 128px;
  font-weight: 800;
  letter-spacing: -4px;
  color: var(--text-primary);
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 1px solid var(--bg-tertiary);
  font-variant-numeric: tabular-nums;
  line-height: 1;
}

.running-display.paused {
  color: var(--warning);
}

.running-display.low {
  color: var(--danger);
  animation: pulse-low 1s ease-in-out infinite;
}

@keyframes pulse-low {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

.progress-track {
  height: 12px;
  background: var(--bg-secondary);
  border-radius: 6px;
  overflow: hidden;
  border: 1px solid var(--bg-tertiary);
}
.progress-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent-secondary), var(--accent));
  transition: width 0.25s linear;
  border-radius: 6px;
}
.progress-fill.low {
  background: linear-gradient(90deg, var(--warning), var(--danger));
}

.initial-label {
  text-align: center;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text-muted);
}

/* ---------- DONE SCREEN ---------- */
#done {
  justify-content: space-between;
}
.done-pulse {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg-primary);
  border-radius: var(--radius-lg);
  border: 2px solid var(--danger);
  animation: alarm-flash 0.9s ease-in-out infinite;
}
@keyframes alarm-flash {
  0%, 100% {
    border-color: var(--danger);
    box-shadow: 0 0 0 rgba(255, 68, 102, 0);
  }
  50% {
    border-color: var(--warning);
    box-shadow: 0 0 40px rgba(255, 68, 102, 0.6);
  }
}
.done-icon {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  background: var(--danger);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 72px;
  font-weight: 800;
  color: var(--text-primary);
}
.done-label {
  font-size: 48px;
  font-weight: 800;
  letter-spacing: 4px;
  color: var(--text-primary);
}
.done-sub {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 3px;
  color: var(--text-secondary);
}
