/* =====================================================
   Clockwork — Warm Retro Terminal Theme
   ===================================================== */

@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:ital,wght@0,400;0,500;0,600;0,700;1,400&display=swap');

:root {
  --font-mono: 'JetBrains Mono', 'Cascadia Code', 'Fira Code', 'SF Mono', 'Consolas', monospace;

  /* Type Scale */
  --text-xs: 11px;
  --text-sm: 13px;
  --text-base: 14px;
  --text-lg: 16px;
  --text-xl: 20px;
  --text-2xl: 26px;

  /* Backgrounds */
  --bg: #0c0c0a;
  --surface: #161614;
  --surface-raised: #1e1e1c;
  --surface-overlay: rgba(0, 0, 0, 0.6);

  /* Text */
  --text: #c8c2b0;
  --text-secondary: #7a7568;
  --text-tertiary: #4a4740;

  /* Amber Accent */
  --amber: #d4a017;
  --amber-bright: #e8b839;
  --amber-dim: rgba(212, 160, 23, 0.12);
  --amber-glow: rgba(212, 160, 23, 0.25);

  /* Borders */
  --border: #2a2826;
  --border-strong: #3a3834;
  --border-focus: var(--amber);

  /* Semantic */
  --red: #c75050;
  --green: #5a9a5a;
  --yellow: var(--amber);

  /* Utility */
  --hover: rgba(255, 255, 255, 0.03);
  --active: rgba(255, 255, 255, 0.06);

  /* Spacing */
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-5: 20px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;

  --radius: 0px;
  --shadow-amber: 0 0 8px rgba(212, 160, 23, 0.15);
  --duration: 100ms;
  --easing: ease-out;

  /* Legacy aliases — JS components reference these */
  --color-primary: var(--amber);
  --color-error: var(--red);
  --color-error-emphasis: var(--red);
  --color-success: var(--green);
  --color-success-emphasis: var(--green);
  --color-text-secondary: var(--text-secondary);
  --color-text-tertiary: var(--text-tertiary);
  --color-text-muted: var(--text-secondary);
  --color-border: var(--border);
  --color-border-strong: var(--border-strong);
  --color-surface-elevated: var(--surface-raised);
  --color-text: var(--text);
  --color-text-inverse: var(--bg);
  --color-surface: var(--surface);
  --color-background: var(--bg);
}

/* =====================================================
   Base
   ===================================================== */

*, *::before, *::after {
  box-sizing: border-box;
  border-radius: var(--radius);
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  line-height: 1.5;
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

#app {
  max-width: 960px;
  margin: 0 auto;
  padding: var(--sp-4);
}

/* =====================================================
   Focus & Keyboard Navigation
   ===================================================== */

:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 2px;
}

input:focus-visible,
textarea:focus-visible,
select:focus-visible {
  outline: none;
  border-color: var(--amber);
  box-shadow: var(--shadow-amber);
}

/* =====================================================
   Skip Link (a11y)
   ===================================================== */

.skip-link {
  position: absolute;
  left: -9999px;
  top: var(--sp-2);
  z-index: 10000;
  padding: var(--sp-2) var(--sp-4);
  background: var(--surface);
  color: var(--amber);
  border: 1px solid var(--amber);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  text-decoration: none;
}

.skip-link:focus,
.skip-link:focus-visible {
  left: var(--sp-2);
  outline: 1px solid var(--amber);
  outline-offset: 2px;
  box-shadow: var(--shadow-amber);
}

/* =====================================================
   Global Transitions
   ===================================================== */

button,
a,
input,
textarea,
select {
  transition: color var(--duration) var(--easing),
              background-color var(--duration) var(--easing),
              border-color var(--duration) var(--easing),
              box-shadow var(--duration) var(--easing),
              opacity var(--duration) var(--easing),
              filter var(--duration) var(--easing);
}

/* Button press: brightness, NOT scale */
button:active:not(:disabled) {
  filter: brightness(0.85);
}

/* =====================================================
   Utility Classes
   ===================================================== */

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border-width: 0;
}

/* =====================================================
   Scrollbar
   ===================================================== */

::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: transparent;
}

::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 0;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--text-tertiary);
}

/* Firefox */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}

/* =====================================================
   Atmospheric — Scanlines
   ===================================================== */

.scanlines {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  background: repeating-linear-gradient(
    0deg,
    rgba(0, 0, 0, 0.08) 0px,
    rgba(0, 0, 0, 0.08) 1px,
    transparent 1px,
    transparent 3px
  );
}

/* =====================================================
   Atmospheric — Vignette
   ===================================================== */

.vignette {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9998;
  background: radial-gradient(
    ellipse at center,
    transparent 50%,
    rgba(0, 0, 0, 0.35) 100%
  );
}

/* =====================================================
   Atmospheric — Noise
   ===================================================== */

.noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9997;
  opacity: 0.015;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  background-size: 256px 256px;
  animation: noise-shift 0.3s steps(4) infinite;
}

@keyframes noise-shift {
  0%   { background-position: 0 0; }
  25%  { background-position: 64px 64px; }
  50%  { background-position: 128px 0; }
  75%  { background-position: 0 128px; }
  100% { background-position: 64px 64px; }
}

/* =====================================================
   Atmospheric — Boot Flicker
   ===================================================== */

.boot-flicker {
  animation: boot-flicker 0.8s ease-out 1 forwards;
}

@keyframes boot-flicker {
  0%   { opacity: 0; }
  10%  { opacity: 0.6; }
  15%  { opacity: 0.1; }
  25%  { opacity: 0.8; }
  30%  { opacity: 0.3; }
  50%  { opacity: 0.9; }
  60%  { opacity: 0.5; }
  80%  { opacity: 1; }
  100% { opacity: 1; }
}

/* =====================================================
   Atmospheric — Blinking Cursor
   ===================================================== */

.cursor::after {
  content: '';
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  background: var(--amber);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: cursor-blink 1s steps(1) infinite;
}

@keyframes cursor-blink {
  0%, 50% { opacity: 1; }
  51%, 100% { opacity: 0; }
}

/* =====================================================
   Atmospheric — Typewriter
   ===================================================== */

.typewriter {
  overflow: hidden;
  white-space: nowrap;
  border-right: 2px solid var(--amber);
  animation:
    typewriter-reveal 0.6s steps(30) forwards,
    typewriter-blink 1s steps(1) infinite 0.6s;
  width: 0;
}

@keyframes typewriter-reveal {
  from { width: 0; }
  to { width: 100%; }
}

@keyframes typewriter-blink {
  0%, 50% { border-color: var(--amber); }
  51%, 100% { border-color: transparent; }
}

/* =====================================================
   Atmospheric — Glitch
   ===================================================== */

.glitch {
  position: relative;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.glitch::before {
  color: var(--red);
  clip-path: inset(0 0 66% 0);
  animation: glitch-top 3s steps(1) infinite;
}

.glitch::after {
  color: var(--green);
  clip-path: inset(33% 0 0 0);
  animation: glitch-bottom 3s steps(1) infinite 0.1s;
}

@keyframes glitch-top {
  0%, 92% { transform: translate(0); }
  93%     { transform: translate(-2px, -1px); }
  94%     { transform: translate(2px, 1px); }
  95%     { transform: translate(-1px, 0); }
  96%, 100% { transform: translate(0); }
}

@keyframes glitch-bottom {
  0%, 90% { transform: translate(0); }
  91%     { transform: translate(1px, 1px); }
  92%     { transform: translate(-2px, 0); }
  93%     { transform: translate(1px, -1px); }
  94%, 100% { transform: translate(0); }
}

/* =====================================================
   Atmospheric — Phosphor Persist (timer numbers)
   ===================================================== */

.phosphor-persist {
  position: relative;
}

.phosphor-flash {
  animation: phosphor-flash 150ms ease-out;
}

@keyframes phosphor-flash {
  0%   { text-shadow: 0 0 8px var(--amber-glow); }
  100% { text-shadow: none; }
}

/* =====================================================
   Buttons — Base
   ===================================================== */

.btn,
.btn-primary,
.btn-ghost,
.btn-danger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: var(--sp-3) var(--sp-6);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  border-radius: var(--radius);
  background: transparent;
  text-decoration: none;
}

.btn:disabled,
.btn-primary:disabled,
.btn-ghost:disabled,
.btn-danger:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.btn:focus-visible,
.btn-primary:focus-visible,
.btn-ghost:focus-visible,
.btn-danger:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 2px;
  box-shadow: var(--shadow-amber);
}

/* =====================================================
   Buttons — Primary (amber outlined, fills on hover)
   ===================================================== */

.btn-primary {
  color: var(--amber);
  border: 1px solid var(--amber);
  background: transparent;
}

.btn-primary:hover:not(:disabled) {
  background: var(--amber);
  color: var(--bg);
}

/* =====================================================
   Buttons — Ghost (border color)
   ===================================================== */

.btn-ghost {
  color: var(--text-secondary);
  border: 1px solid var(--border);
  background: transparent;
}

.btn-ghost:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--border-strong);
  background: var(--hover);
}

/* =====================================================
   Buttons — Danger (red outlined, fills on hover)
   ===================================================== */

.btn-danger {
  color: var(--red);
  border: 1px solid var(--red);
  background: transparent;
}

.btn-danger:hover:not(:disabled) {
  background: var(--red);
  color: var(--bg);
}

/* =====================================================
   Form Inputs
   ===================================================== */

.form-input,
.auth-input {
  display: block;
  width: 100%;
  padding: var(--sp-3) var(--sp-4);
  margin-bottom: var(--sp-4);
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  box-sizing: border-box;
  outline: none;
  transition: border-color var(--duration) var(--easing), box-shadow var(--duration) var(--easing);
}

.form-input:focus,
.auth-input:focus {
  border-color: var(--amber);
  box-shadow: var(--shadow-amber);
}

.form-input:focus-visible,
.auth-input:focus-visible {
  border-color: var(--amber);
  box-shadow: var(--shadow-amber);
  outline: none;
}

.form-input::placeholder,
.auth-input::placeholder {
  color: var(--text-tertiary);
}

.form-label {
  display: block;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: var(--sp-1);
}

/* =====================================================
   Auth & Login
   ===================================================== */

.auth-card {
  max-width: 400px;
  margin: var(--sp-16) auto 0;
  padding: var(--sp-6);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

.auth-heading {
  margin: 0 0 var(--sp-1);
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
}

.auth-subtext {
  margin: 0 0 var(--sp-6);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-base);
}

.auth-button {
  display: block;
  width: 100%;
  padding: var(--sp-3) var(--sp-6);
  background: transparent;
  color: var(--amber);
  border: 1px solid var(--amber);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 600;
  cursor: pointer;
  transition: background var(--duration) var(--easing), color var(--duration) var(--easing);
}

.auth-button:hover {
  background: var(--amber);
  color: var(--bg);
}

.auth-button:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 2px;
  box-shadow: var(--shadow-amber);
}

.auth-button:active:not(:disabled) {
  filter: brightness(0.85);
}

.auth-button:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.auth-error {
  color: var(--red);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  min-height: 1.25em;
  margin-bottom: var(--sp-2);
}

/* =====================================================
   PIN Login
   ===================================================== */

.pin-screen {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--sp-4);
  gap: var(--sp-6);
}

.pin-screen::before {
  content: 'Clockwork';
  display: block;
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--amber);
  margin-bottom: var(--sp-2);
  letter-spacing: 0.02em;
}

.pin-container {
  display: flex;
  gap: var(--sp-3);
}

.pin-input {
  width: 48px;
  height: 56px;
  text-align: center;
  font-size: var(--text-xl);
  font-weight: 600;
  font-family: var(--font-mono);
  background: var(--surface);
  color: var(--amber);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color var(--duration) var(--easing), box-shadow var(--duration) var(--easing);
  box-sizing: border-box;
}

.pin-input:focus {
  border-color: var(--amber);
  box-shadow: var(--shadow-amber);
}

.pin-input:focus-visible {
  border-color: var(--amber);
  box-shadow: var(--shadow-amber);
}

.pin-input.error {
  border-color: var(--red);
}

/* =====================================================
   Navigation
   ===================================================== */

.nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--sp-2) 0;
  margin-bottom: var(--sp-6);
  border-bottom: 1px solid var(--border);
}

.nav-brand {
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 700;
  color: var(--amber);
  text-decoration: none;
  letter-spacing: 0.02em;
}

.nav-brand:hover {
  color: var(--amber-bright);
}

.nav-brand:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 2px;
  box-shadow: var(--shadow-amber);
}

.nav-links {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
}

.nav-link {
  color: var(--text-secondary);
  text-decoration: none;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  padding: var(--sp-1) 0;
  border: none;
  background: none;
  cursor: pointer;
  transition: color var(--duration) var(--easing);
  position: relative;
}

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

.nav-link:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 2px;
  box-shadow: var(--shadow-amber);
}

.nav-link.active {
  color: var(--amber);
}

.nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 1px;
  background: var(--amber);
}

.version-pill {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  padding: 2px var(--sp-2);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-tertiary);
  cursor: pointer;
  transition: background-color var(--duration) var(--easing),
              color var(--duration) var(--easing),
              border-color var(--duration) var(--easing);
  margin-left: var(--sp-2);
}

.version-pill:hover {
  background: var(--surface-raised);
  color: var(--amber);
  border-color: var(--border-strong);
}

.version-pill:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 2px;
  box-shadow: var(--shadow-amber);
}

.version-pill:active {
  filter: brightness(0.85);
}

.nav-logout {
  color: var(--text-secondary);
  margin-left: var(--sp-2);
}

.nav-logout:hover {
  color: var(--red);
}

.nav-logout:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 2px;
  box-shadow: var(--shadow-amber);
}

.nav-logout:active {
  filter: brightness(0.85);
}

/* =====================================================
   Cards
   ===================================================== */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  padding: var(--sp-5);
  border-radius: var(--radius);
  transition: border-color var(--duration) var(--easing);
}

.card:hover {
  border-color: var(--border-strong);
}

/* =====================================================
   Section Headers
   ===================================================== */

.section-header {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: var(--sp-6) 0 var(--sp-2);
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-2);
}

/* =====================================================
   Timer Bar
   ===================================================== */

.timer-bar {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--sp-5);
  margin-bottom: var(--sp-6);
  transition: border-color var(--duration) var(--easing);
}

.timer-bar.running {
  border-color: var(--amber);
}

.timer-bar.idle {
  border-color: var(--border);
}

.timer-top-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  margin-bottom: var(--sp-2);
}

.pulse-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--amber);
  animation: pulse 2s steps(2) infinite;
  flex-shrink: 0;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.timer-time {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--amber);
  letter-spacing: 0.02em;
  line-height: 1.1;
  flex: 1;
  min-width: 0;
}

.timer-stop-btn {
  flex-shrink: 0;
}

.timer-bottom-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex-wrap: wrap;
}

.timer-description {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  flex: 1;
  min-width: 0;
  outline: none;
  border-bottom: 1px solid var(--border);
  padding: var(--sp-1) 0;
  cursor: text;
  transition: border-color var(--duration) var(--easing);
  max-width: 65ch;
}

.timer-description:focus {
  border-bottom-color: var(--amber);
}

.timer-description:focus-visible {
  border-bottom-color: var(--amber);
  box-shadow: 0 2px 0 0 var(--amber);
  outline: none;
}

.timer-tags {
  display: flex;
  gap: var(--sp-1);
  flex-wrap: wrap;
}

/* Timer start form */
.timer-start-form {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.timer-desc-input {
  margin-bottom: 0;
}

.timer-controls-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.timer-start-btn {
  flex-shrink: 0;
}

.timer-error {
  color: var(--red);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  margin-top: var(--sp-2);
}

/* =====================================================
   Tag Badges & Chips
   ===================================================== */

.tag-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--sp-2);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
  border: 1px solid var(--border);
  background: transparent;
  white-space: nowrap;
}

/* Tag picker (inline chips for selecting) */
.tag-picker {
  display: flex;
  gap: var(--sp-1);
  flex-wrap: wrap;
  flex: 1;
  min-width: 0;
}

.tag-chip {
  display: inline-flex;
  align-items: center;
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text);
  background: transparent;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: border-color var(--duration) var(--easing), opacity var(--duration) var(--easing);
  opacity: 0.5;
}

.tag-chip:hover {
  opacity: 0.8;
  border-color: var(--border-strong);
}

.tag-chip:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 2px;
}

.tag-chip.selected {
  border-color: var(--amber);
  opacity: 1;
  color: var(--amber);
}

/* =====================================================
   Recent List
   ===================================================== */

.recent-section {
  margin-bottom: var(--sp-4);
}

.recent-list {
  display: flex;
  flex-direction: column;
}

.recent-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 44px;
  padding: var(--sp-2) var(--sp-4);
  cursor: default;
  background: var(--surface);
  border: 1px solid var(--border);
  border-bottom: none;
  transition: border-color var(--duration) var(--easing);
}

.recent-item:last-child {
  border-bottom: 1px solid var(--border);
}

.recent-item:hover {
  border-color: var(--border-strong);
}

.recent-info {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  flex: 1;
  min-width: 0;
  flex-wrap: wrap;
}

.recent-desc {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  max-width: 65ch;
}

.recent-tags {
  display: flex;
  gap: var(--sp-1);
  flex-wrap: wrap;
}

/* Play button */
.play-btn {
  width: 36px;
  height: 36px;
  min-width: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: transparent;
  color: var(--amber);
  border: 1px solid var(--amber);
  font-size: var(--text-sm);
  cursor: pointer;
  transition: background-color var(--duration) var(--easing), color var(--duration) var(--easing);
  flex-shrink: 0;
  font-family: var(--font-mono);
}

.play-btn:hover:not(:disabled) {
  background: var(--amber);
  color: var(--bg);
}

.play-btn:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 2px;
  box-shadow: var(--shadow-amber);
}

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

/* =====================================================
   Entry List
   ===================================================== */

.entry-list-section {
  margin-bottom: var(--sp-8);
}

.entry-row {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  min-height: 48px;
  padding: var(--sp-3) var(--sp-4);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: border-color var(--duration) var(--easing), background-color var(--duration) var(--easing);
}

.entry-row:first-of-type {
  border-top: none;
}

.entry-row:hover {
  border-color: var(--border-strong);
  background: var(--hover);
}

.entry-time {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 90px;
}

.entry-duration {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  white-space: nowrap;
  flex-shrink: 0;
  min-width: 50px;
}

.entry-desc {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  flex: 1;
  min-width: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 65ch;
}

.entry-tags {
  display: flex;
  gap: var(--sp-1);
  flex-wrap: wrap;
  flex-shrink: 0;
}

.entry-actions {
  display: flex;
  gap: var(--sp-1);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--duration) var(--easing);
}

.entry-row:hover .entry-actions {
  opacity: 1;
}

.entry-row:focus-within .entry-actions {
  opacity: 1;
}

.entry-action-btn {
  padding: var(--sp-1);
  font-size: var(--text-base);
  min-width: 32px;
  min-height: 32px;
}

.add-manual-btn {
  margin-top: var(--sp-4);
  font-size: var(--text-base);
  padding: var(--sp-2) 0;
}

.add-manual-btn:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 2px;
  box-shadow: var(--shadow-amber);
}

/* =====================================================
   Tags View
   ===================================================== */

.tags-view {
  margin-top: var(--sp-4);
}

.tags-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--sp-6);
}

.tags-title {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  font-weight: 700;
  color: var(--text);
  margin: 0;
  letter-spacing: 0.02em;
  line-height: 1.2;
}

.tags-list {
  display: flex;
  flex-direction: column;
}

.tag-row {
  display: flex;
  align-items: center;
  gap: var(--sp-4);
  padding: var(--sp-3) var(--sp-4);
  cursor: pointer;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  transition: border-color var(--duration) var(--easing), background-color var(--duration) var(--easing);
}

.tag-row:first-child {
  border-top: 1px solid var(--border);
}

.tag-row:hover {
  border-color: var(--border-strong);
  background: var(--hover);
}

.tag-row:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: -1px;
  box-shadow: var(--shadow-amber);
}

.tag-row:active {
  filter: brightness(0.85);
}

.tag-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface-raised);
  flex-shrink: 0;
}

.tag-name {
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 500;
  flex: 1;
  min-width: 0;
}

.tag-meta {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  white-space: nowrap;
}

/* =====================================================
   Empty States
   ===================================================== */

.empty-state {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  text-align: center;
  padding: var(--sp-12) 0;
}

.empty-state::before {
  content: '> ';
  color: var(--amber);
}

.empty-state::after {
  content: '';
  display: inline-block;
  width: 0.6em;
  height: 1.1em;
  background: var(--amber);
  vertical-align: text-bottom;
  margin-left: 2px;
  animation: cursor-blink 1s steps(1) infinite;
}

.empty-report {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  text-align: center;
  padding: var(--sp-16);
  font-size: var(--text-base);
}

.empty-report::before {
  content: '> ';
  color: var(--amber);
}

/* =====================================================
   Tag Form
   ===================================================== */

.tag-form-content {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

/* Color picker */
.color-picker {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--sp-2);
  padding: var(--sp-2) 0;
  justify-items: center;
}

.color-swatch {
  width: 32px;
  height: 32px;
  border-radius: 0;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color var(--duration) var(--easing);
  padding: 0;
  outline: none;
}

.color-swatch:hover {
  border-color: var(--border-strong);
}

.color-swatch:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 2px;
}

.color-swatch.selected {
  border-color: var(--text);
  box-shadow: 0 0 0 2px var(--bg), 0 0 0 4px var(--text);
}

/* =====================================================
   Modal
   ===================================================== */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: var(--surface-overlay);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: var(--sp-4);
  animation: fadeIn 150ms var(--easing);
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-card {
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: var(--sp-6);
  width: 100%;
  max-width: 420px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-amber);
  animation: modal-enter 150ms var(--easing);
}

@keyframes modal-enter {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-title {
  margin: 0 0 var(--sp-4);
  font-family: var(--font-mono);
  font-size: var(--text-lg);
  font-weight: 600;
  color: var(--amber);
  letter-spacing: 0.02em;
}

.modal-body {
  margin-bottom: var(--sp-6);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  max-width: 65ch;
}

.modal-body p {
  margin: 0;
}

.modal-actions {
  display: flex;
  gap: var(--sp-2);
  justify-content: flex-end;
  flex-wrap: wrap;
}

/* =====================================================
   Entry Form in Modal
   ===================================================== */

.entry-form {
  display: flex;
  flex-direction: column;
}

/* =====================================================
   Reports
   ===================================================== */

.reports-container {
  min-height: 200px;
}

.reports-placeholder {
  text-align: center;
  padding: var(--sp-16) var(--sp-4);
  font-family: var(--font-mono);
}

.report-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  margin-bottom: var(--sp-6);
}

.report-tab {
  padding: var(--sp-2) var(--sp-4);
  color: var(--text-secondary);
  cursor: pointer;
  border-bottom: 1px solid transparent;
  background: none;
  border-top: none;
  border-left: none;
  border-right: none;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  font-weight: 500;
  transition: color var(--duration) var(--easing), border-color var(--duration) var(--easing);
  margin-bottom: -1px;
}

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

.report-tab:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 2px;
  box-shadow: var(--shadow-amber);
}

.report-tab:active:not(:disabled) {
  filter: brightness(0.85);
}

.report-tab.active {
  color: var(--amber);
  border-bottom-color: var(--amber);
  font-weight: 600;
}

.period-nav {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--sp-6);
  margin-bottom: var(--sp-6);
}

.period-nav button {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  padding: var(--sp-1) var(--sp-3);
  border-radius: var(--radius);
  cursor: pointer;
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  transition: color var(--duration) var(--easing),
              border-color var(--duration) var(--easing),
              background-color var(--duration) var(--easing);
}

.period-nav button:hover {
  color: var(--amber);
  border-color: var(--amber);
  background: var(--amber-dim);
}

.period-nav button:focus-visible {
  outline: 1px solid var(--amber);
  outline-offset: 2px;
  box-shadow: var(--shadow-amber);
}

.period-nav button:active:not(:disabled) {
  filter: brightness(0.85);
}

.period-label {
  font-family: var(--font-mono);
  font-size: var(--text-base);
  font-weight: 500;
  color: var(--text);
  min-width: 160px;
  text-align: center;
}

.total-hours {
  font-family: var(--font-mono);
  font-size: var(--text-2xl);
  font-weight: 700;
  color: var(--amber);
  letter-spacing: 0.02em;
  line-height: 1.1;
  margin-bottom: var(--sp-6);
}

.chart-section {
  margin-bottom: var(--sp-8);
}

.donut-container {
  display: flex;
  align-items: center;
  gap: var(--sp-8);
  flex-wrap: wrap;
}

.donut-legend {
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
}

.legend-item {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  font-family: var(--font-mono);
  font-size: var(--text-sm);
}

.legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 0;
  flex-shrink: 0;
}

.legend-name {
  color: var(--text);
}

.legend-value {
  color: var(--text-secondary);
  margin-left: auto;
  white-space: nowrap;
}

.reports-loading {
  color: var(--text-secondary);
  font-family: var(--font-mono);
  text-align: center;
  padding: var(--sp-8);
}

.reports-error {
  color: var(--red);
  font-family: var(--font-mono);
  text-align: center;
  padding: var(--sp-8);
  font-size: var(--text-base);
}

/* =====================================================
   Changelog Modal
   ===================================================== */

.changelog-list {
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

.changelog-section-header {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  text-transform: uppercase;
}

.changelog-item {
  padding: var(--sp-3) var(--sp-4);
  border-radius: var(--radius);
  background: var(--surface-raised);
  border: 1px solid var(--border);
}

.changelog-item-header {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  margin-bottom: var(--sp-1);
}

.changelog-version {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--amber);
}

.changelog-type-badge {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 1px var(--sp-2);
  border-radius: var(--radius);
  border: 1px solid currentColor;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: transparent;
}

.changelog-build {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.changelog-desc {
  font-family: var(--font-mono);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0 0 var(--sp-1);
  max-width: 65ch;
}

.changelog-date {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin: 0;
}

/* =====================================================
   Badges — Amber Variant
   ===================================================== */

.badge-amber {
  display: inline-flex;
  align-items: center;
  padding: 2px var(--sp-2);
  border: 1px solid var(--amber);
  color: var(--amber);
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  border-radius: var(--radius);
  background: transparent;
}

/* =====================================================
   Skeleton Loading — Step-function pulse
   ===================================================== */

@keyframes skeleton-pulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.15; }
}

.skeleton {
  background: var(--surface-raised);
  border-radius: var(--radius);
  animation: skeleton-pulse 1.5s steps(2) infinite;
}

.skeleton-text {
  height: 14px;
  margin-bottom: var(--sp-2);
  border-radius: var(--radius);
}

.skeleton-text-wide { width: 80%; }
.skeleton-text-medium { width: 60%; }
.skeleton-text-short { width: 40%; }

.skeleton-heading {
  height: 20px;
  margin-bottom: var(--sp-4);
  width: 50%;
  border-radius: var(--radius);
}

.skeleton-bar {
  height: 32px;
  margin-bottom: var(--sp-2);
  border-radius: var(--radius);
}

.skeleton-bar:nth-child(2) { width: 85%; }
.skeleton-bar:nth-child(3) { width: 60%; }
.skeleton-bar:nth-child(4) { width: 45%; }

.reports-skeleton {
  padding: var(--sp-6) 0;
}

.reports-skeleton .skeleton-bar:first-child {
  width: 30%;
  height: 40px;
  margin-bottom: var(--sp-6);
}

/* =====================================================
   Responsive — Tablet (max-width: 767px)
   ===================================================== */

@media (max-width: 767px) {
  .entry-actions {
    opacity: 1;
  }

  .entry-time {
    min-width: auto;
  }

  .donut-container {
    flex-direction: column;
    align-items: flex-start;
  }

  .period-label {
    min-width: auto;
  }
}

/* =====================================================
   Responsive — Mobile (max-width: 480px)
   ===================================================== */

@media (max-width: 480px) {
  .nav {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-2);
  }

  .nav-links {
    width: 100%;
    justify-content: space-between;
  }

  .timer-time {
    font-size: var(--text-xl);
  }

  .timer-controls-row {
    flex-direction: column;
    align-items: stretch;
  }

  .timer-start-btn {
    width: 100%;
  }

  .entry-row {
    flex-wrap: wrap;
    min-height: auto;
    padding: var(--sp-2);
  }

  .entry-actions {
    opacity: 1;
  }

  .entry-time {
    min-width: auto;
  }

  .entry-desc {
    width: 100%;
    order: 1;
    white-space: normal;
  }

  .recent-info {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--sp-1);
  }

  .modal-card {
    margin: var(--sp-4);
    max-width: none;
  }

  .color-picker {
    grid-template-columns: repeat(4, 1fr);
    justify-items: center;
  }

  .pin-screen::before {
    font-size: var(--text-xl);
  }

  .total-hours {
    font-size: var(--text-xl);
  }

  .tags-title {
    font-size: var(--text-lg);
  }
}

/* =====================================================
   Responsive — Narrow Mobile (PIN fix)
   ===================================================== */

@media (max-width: 400px) {
  .pin-input {
    width: 40px;
    height: 48px;
    font-size: var(--text-base);
  }

  .pin-container {
    gap: var(--sp-2);
  }
}

/* =====================================================
   Reduced Motion
   ===================================================== */

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

  .scanlines,
  .vignette,
  .noise {
    display: none;
  }

  .boot-flicker {
    animation: none;
    opacity: 1;
  }

  .cursor::after {
    animation: none;
    opacity: 1;
  }

  .typewriter {
    animation: none;
    width: auto;
    border-right: none;
  }

  .glitch::before,
  .glitch::after {
    display: none;
  }

  .phosphor-flash {
    animation: none;
  }
}
