/* ==========================================================================
   POMODORON - ULTRA-MINIMALIST DESIGN SYSTEM & STYLING
   ========================================================================== */

/* --- Custom Variables & Theme System --- */
:root {
  /* HSL Palette Tokens (H, S, L) */
  /* Pomodoro Column Theme: Pastel Terracotta Red */
  --h-pomodoro: 4;
  --s-pomodoro: 68%;
  --l-pomodoro-base: 54%;
  --l-pomodoro-fill: 64%;

  /* Short Break Column Theme: Vermilion (Red-Orange) */
  --h-short: 15;
  --s-short: 82%;
  --l-short-base: 53%;
  --l-short-fill: 63%;

  /* Long Break Column Theme: Orange */
  --h-long: 26;
  --s-long: 95%;
  --l-long-base: 53%;
  --l-long-fill: 63%;

  /* Fonts */
  --font-main: 'Outfit', sans-serif;
  --font-mono: 'Space Mono', monospace;

  /* Glassmorphism/Translucency Defaults (Sparsely used for premium settings) */
  --glass-bg: rgba(255, 255, 255, 0.08);
  --glass-border: rgba(255, 255, 255, 0.12);
  --glass-border-hover: rgba(255, 255, 255, 0.25);
  --glass-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.35);
  --text-primary: #ffffff;
  --text-secondary: rgba(255, 255, 255, 0.75);
  --text-muted: rgba(255, 255, 255, 0.45);

  /* Timetrack Tick & Digit Colors (Dark theme - colored segments, dark ticks) */
  --timetrack-tick-color: rgba(0, 0, 0, 0.65);
  --timetrack-tick-minor-color: rgba(0, 0, 0, 0.22);
  --timetrack-digit-color: rgba(0, 0, 0, 0.75);

  /* Progress Positions */
  --progress-px: 0px;
  --w-pomodoro: 2000px;
  --w-short: 400px;
  --w-long: 800px;
  --w-total: 3200px;
}

/* --- General Reset & Setup --- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-main);
  background-color: #161616;
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  overflow-x: hidden;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* --- Timeline Viewport Bounding Box --- */
.timeline-viewport {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  max-width: 100vw;
  height: 128px;
  overflow: hidden;
  z-index: 1;
  pointer-events: none;
}

/* --- Fullscreen Segmented 3-Column Background --- */
.progress-bg-container {
  position: absolute;
  top: 0; /* Move all the way to the top of the page */
  left: 0;
  width: var(--w-total, 3200px);
  height: 128px; /* Update the height of the timeline to 128px */
  z-index: 1; /* Above back layers, below UI */
  overflow: visible;
  display: flex;
  pointer-events: none;
  transform: translateX(calc(50vw - var(--progress-px, 0px)));
  transition: transform 0.05s linear;
  will-change: transform;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08); /* Clean translucent bottom border */
}

.progress-bg-container::before {
  content: '';
  position: absolute;
  right: 100%;
  top: 0;
  width: 100vw;
  height: 100%;
  background-color: hsl(var(--h-pomodoro), var(--s-pomodoro), var(--l-pomodoro-base));
}

.progress-bg-container::after {
  content: '';
  position: absolute;
  left: 100%;
  top: 0;
  width: 100vw;
  height: 100%;
  background-color: hsl(var(--h-pomodoro), var(--s-pomodoro), var(--l-pomodoro-base));
}

.bg-column {
  height: 100%;
  flex-shrink: 0;
  transition: width 0.6s cubic-bezier(0.25, 1, 0.5, 1);
  border-right: 1.5px solid rgba(255, 255, 255, 0.22); /* Clean high-contrast segment borders */
}

.col-pomodoro {
  width: var(--w-pomodoro, 2000px);
  background-color: hsl(var(--h-pomodoro), var(--s-pomodoro), var(--l-pomodoro-base));
}

.col-short {
  width: var(--w-short, 400px);
  background-color: hsl(var(--h-short), var(--s-short), var(--l-short-base));
}

.col-long {
  width: var(--w-long, 800px);
  background-color: hsl(var(--h-long), var(--s-long), var(--l-long-base));
}

/* Ticks rendering layer */
.ticks-layer {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;
  pointer-events: none;
  z-index: 2;
}

/* Center digits vertically, align lines to the bottom of the track */
.tick-element {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 48px;
  transform: translateX(-50%);
  pointer-events: none;
}

.tick-digit {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%); /* Perfectly centered vertically and horizontally */
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--timetrack-digit-color);
  letter-spacing: -0.4px;
  white-space: nowrap;
}

/* Digits color-matched timeline ticks */
.tick-line {
  position: absolute;
  bottom: 0; /* Aligned precisely to the bottom of the track row */
  left: 50%;
  transform: translateX(-50%);
}

.tick-line.minute-line {
  height: 32px; /* Balanced height for 128px container */
  background-color: var(--timetrack-tick-color);
  width: 1px;
}

.tick-line.half-minute-line {
  height: 22px; /* Balanced height for 128px container */
  background-color: var(--timetrack-tick-color);
  width: 1px;
}

.tick-line.ten-sec-line {
  height: 14px; /* Balanced height for 128px container */
  background-color: var(--timetrack-tick-minor-color);
  width: 1px;
}

/* Divider line at the boundary */
.progress-bg-glow {
  position: absolute;
  top: 0; /* Move all the way to the top of the page */
  left: 50%;
  width: 2px;
  height: 128px; /* Confined to the 128px dial */
  background-color: #ffffff;
  opacity: 0.85;
  transform: translateX(-50%);
  z-index: 2; /* Sits perfectly above the ticks */
  pointer-events: none;
}


/* --- Application Container Overlay --- */
.app-container {
  position: relative;
  z-index: 5;
  width: 100%;
  max-width: 1200px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  padding: calc(128px + 1.5rem) 2rem 2.5rem 2rem; /* Padding top pushes content under 128px dial, bottom pushes footer */
}

/* --- Unified Central Console Stack --- */
.timer-console {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 32px;
  width: 100%;
  padding-top: 4rem;
}

/* --- Header Section --- */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  margin-bottom: 0;
}

.logo {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  opacity: 0.9;
}

/* --- Predominant Countdown Display & Elapsed --- */
.timer-section {
  text-align: center;
  width: 100%;
  user-select: none;
  flex-grow: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.countdown-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.countdown-digits {
  font-family: var(--font-mono); /* Rock-solid monospace to fit tabular widths */
  font-variant-numeric: tabular-nums;
  font-size: 6.2rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  text-indent: -0.03em; /* Perfectly centers the middle gap between digits on the central vertical spine */
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  transition: transform 0.4s ease;
  width: 100%;
  text-align: center;
  position: relative;
  z-index: 2;
}

.countdown-digits:hover {
  transform: scale(1.02);
}




.countdown-state-label {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 0; /* Reset margin to keep spacing exactly 32px */
  font-weight: 700;
  position: relative;
  z-index: 2;
  display: flex;
  justify-content: center;
  width: 100%;
}

.countdown-state-label span {
  display: inline-block;
  box-sizing: border-box;
}

.countdown-state-label span:first-child {
  text-align: right;
  flex: 1 1 50%;
  padding-right: 18px; /* Balanced horizontal spacing around the center vertical line */
}

.countdown-state-label span:last-child {
  text-align: left;
  flex: 1 1 50%;
  padding-left: 18px; /* Balanced horizontal spacing around the center vertical line */
}


/* --- Minimalist Floating Controls (No Glass panel, Container, or Drop Shadows) --- */
.controls-section-minimal {
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

.action-buttons-minimal {
  display: grid;
  grid-template-columns: repeat(5, 1fr); /* Symmetrical 5 buttons */
  gap: 0.65rem;
  width: 100%;
  max-width: 500px; /* Increased from 420px to accommodate 5 buttons beautifully */
}

/* --- Flat Glassmorphic Floating Buttons --- */
.btn {
  font-family: var(--font-main);
  border: none;
  outline: none;
  cursor: pointer;
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 9999px;
  padding: 0.75rem 0.2rem;
  transition: 
    background 0.3s cubic-bezier(0.25, 1, 0.5, 1),
    transform 0.1s ease,
    border-color 0.3s ease,
    color 0.3s ease;
}

.btn:active {
  transform: scale(0.95);
}

.btn-ctrl {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border: none;
}

.btn-ctrl:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
}

.btn-play-pause {
  background: #ffffff;
  color: #111111;
  border: none;
  position: relative;
  transition: 
    background 0.3s cubic-bezier(0.25, 1, 0.5, 1),
    transform 0.2s cubic-bezier(0.25, 1, 0.5, 1),
    color 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.btn-play-pause::before {
  content: '';
  position: absolute;
  bottom: 50%;
  left: 50%;
  transform: translateX(-50%);
  width: 2px;
  height: 120vh;
  background-color: #ffffff;
  opacity: 0.85;
  pointer-events: none;
  z-index: -1;
}

.btn-play-pause:hover {
  background: #ffffff;
  color: #111111;
  transform: scale(1.08); /* slight size increase */
}

/* Ensure play/pause stays premium solid white on all active and paused states */
body.timer-running .btn-play-pause,
body.timer-paused:not(.timer-stopped) .btn-play-pause {
  background: #ffffff;
  color: #111111;
  border: none;
}

body.timer-running .btn-play-pause:hover,
body.timer-paused:not(.timer-stopped) .btn-play-pause:hover {
  transform: scale(1.08);
}

.btn-primary {
  background: #ffffff;
  color: #111111;
  border: none;
}

.btn-primary:hover {
  background: rgba(255, 255, 255, 0.9);
}

/* Button icons */
.icon {
  width: 16px;
  height: 16px;
  stroke-width: 2.5px;
}

.play-icon, .pause-icon {
  width: 16px;
  height: 16px;
}

/* Icon Buttons (Header) */
.icon-btn {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  outline: none;
  cursor: pointer;
  color: var(--text-primary);
  padding: 0.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 
    background 0.3s cubic-bezier(0.25, 1, 0.5, 1),
    color 0.3s cubic-bezier(0.25, 1, 0.5, 1),
    transform 0.2s cubic-bezier(0.25, 1, 0.5, 1);
}

body.theme-light .icon-btn {
  background: rgba(0, 0, 0, 0.05);
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
  transform: scale(1.08);
}

body.theme-light .icon-btn:hover {
  background: rgba(0, 0, 0, 0.09);
}

.icon-btn:active {
  transform: scale(0.93);
}

.settings-icon {
  width: 18px;
  height: 18px;
}

/* Header Controls Container */
.header-controls {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* Theme Switcher Button & Icons */
.theme-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2px;
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.icon-btn:hover .theme-icon {
  transform: rotate(15deg);
}

/* Default is Dark mode: show Sun icon, hide Moon icon */
body:not(.theme-light) .theme-icon-light {
  display: block;
}
body:not(.theme-light) .theme-icon-dark {
  display: none;
}

/* Light theme: show Moon icon, hide Sun icon */
body.theme-light .theme-icon-light {
  display: none;
}
body.theme-light .theme-icon-dark {
  display: block;
}

/* --- Footer Section --- */
.app-footer {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: auto;
  padding-top: 4rem; /* Generous spacing above the footer when content overflows */
}

.footer-copyright,
.footer-tagline {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.02em;
}

/* ==========================================================================
   NATIVE SETTINGS DIALOG LAYOUT & ANIMATIONS
   ========================================================================== */

dialog {
  border: none;
  background: transparent;
  max-width: 480px;
  width: calc(100% - 2rem);
  outline: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.92);
  margin: 0;
  opacity: 0;
  z-index: 100;
  box-sizing: border-box;

  /* Modern transition settings for top-layer elements */
  transition-property: opacity, transform, display, overlay;
  transition-duration: 0.35s;
  transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
  transition-behavior: allow-discrete;
}

/* Dialog Backdrop styling */
dialog::backdrop {
  background-color: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition:
    display 0.35s allow-discrete,
    overlay 0.35s allow-discrete,
    background-color 0.35s cubic-bezier(0.16, 1, 0.3, 1),
    backdrop-filter 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Open State */
dialog[open] {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);

  /* Starting styles for enter transition */
  @starting-style {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.92);
  }
}

dialog[open]::backdrop {
  background-color: rgba(255, 255, 255, 0.14);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);

  @starting-style {
    background-color: rgba(255, 255, 255, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
  }
}

/* Respect user motion preferences */
@media (prefers-reduced-motion: reduce) {
  dialog {
    transform: translate(-50%, -50%) !important;
    transition-duration: 0.15s;
  }
  dialog[open] {
    @starting-style {
      transform: translate(-50%, -50%) !important;
    }
  }
  dialog::backdrop {
    transition-duration: 0.15s;
  }
}

/* Dialog Container Inner content */
.dialog-content {
  overflow: hidden;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  background: #161616;
  box-shadow: var(--glass-shadow);
  color: #ffffff;
  border-radius: 20px;
}

.settings-form {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 85vh;
}

.dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
}

.dialog-header h2 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.close-btn {
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  color: var(--text-secondary);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease, color 0.2s ease;
}

.close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.dialog-scroll-area {
  padding: 1.5rem;
  overflow-y: auto;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  max-height: calc(85vh - 140px);
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
}

.dialog-scroll-area::-webkit-scrollbar {
  width: 6px;
}
.dialog-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 10px;
}

.dialog-footer {
  padding: 1.25rem 1.5rem;
}

.btn-full {
  width: 100%;
}

/* --- Form Fields & Custom Controls --- */
.settings-group {
  border: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.settings-group legend {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

/* Grid input layout */
.input-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.75rem;
}

.input-field {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.input-field label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 600;
}

/* Pill input wrapper */
.pill-input-wrap {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 99px;
  padding: 0.5rem 0.9rem;
  gap: 0.25rem;
  transition: background 0.2s ease;
}

.pill-input-wrap:focus-within {
  background: rgba(255, 255, 255, 0.16);
}

.input-field input[type="number"] {
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  font-size: 1rem;
  color: #ffffff;
  font-family: var(--font-main);
  font-weight: 600;
  text-align: center;
  outline: none;
  width: 100%;
  min-width: 0;
}

.pill-unit {
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Toggle List styles */
.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.toggle-label {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.95rem;
  cursor: pointer;
  font-weight: 600;
  color: var(--text-secondary);
  transition: color 0.2s ease;
}

.toggle-label:hover {
  color: #ffffff;
}

/* Premium iOS Switch styling */
.ios-switch {
  appearance: none;
  -webkit-appearance: none;
  width: 44px;
  height: 24px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 99px;
  position: relative;
  cursor: pointer;
  outline: none;
  transition: background 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.ios-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 20px;
  height: 20px;
  background: #ffffff;
  border-radius: 50%;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  transition: transform 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.ios-switch:checked {
  background: #4cd964;
}

.ios-switch:checked::after {
  transform: translateX(20px);
}

/* Slider Controls */
.slider-field {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.slider-label-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
}

.slider-field input[type="range"] {
  appearance: none;
  -webkit-appearance: none;
  width: 100%;
  height: 4px;
  border-radius: 99px;
  background: linear-gradient(
    to right,
    rgba(255, 255, 255, 0.9) 0%,
    rgba(255, 255, 255, 0.9) var(--fill, 75%),
    rgba(255, 255, 255, 0.2) var(--fill, 75%),
    rgba(255, 255, 255, 0.2) 100%
  );
  outline: none;
  cursor: pointer;
}

.slider-field input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.35);
  transition: transform 0.1s ease;
}

.slider-field input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

/* --- Info Grid & SEO Section --- */
.info-grid-section {
  margin-top: 64px;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 2.5rem;
}

.info-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 2.5rem;
  width: 100%;
}

/* Tablet screens (2 columns: About lead spans full width, How/Features are side-by-side) */
@media (min-width: 640px) and (max-width: 1024px) {
  .info-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .info-about {
    grid-column: span 2;
  }
}

/* Desktop screens (3 columns: all cards are side-by-side in one row) */
@media (min-width: 1025px) {
  .info-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 3rem; /* Extra breathing space on desktop */
  }
}

.info-card {
  flex: 1;
  min-width: 0; /* Prevents flex items from overflowing horizontally and shifting layout center */
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
}

.info-card:hover {
  transform: none;
  box-shadow: none;
}

.info-card h2 {
  font-family: var(--font-main);
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 1.25rem;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.info-card h3 {
  font-family: var(--font-main);
  font-size: 1.05rem;
  font-weight: 600;
  margin-top: 1.75rem;
  margin-bottom: 0.75rem;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}

.info-card p {
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.info-card p:last-of-type {
  margin-bottom: 0;
}

.info-card strong {
  color: var(--text-primary);
  font-weight: 600;
}

.features-list, .how-list {
  padding-left: 1.25rem;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--text-muted);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.features-list {
  list-style-type: square;
}

.how-list {
  list-style-type: decimal;
}

.how-list li {
  padding-left: 0.25rem;
}

.how-list li::marker {
  color: var(--text-primary);
  font-weight: 700;
}

.how-intro {
  margin-bottom: 1.25rem !important;
}


@media (max-width: 640px) {
  .info-grid {
    gap: 1.5rem;
  }
  .info-grid-section {
    margin-top: 48px;
    gap: 1.5rem;
  }
}

/* ==========================================================================
   RESPONSIVENESS & MEDIA QUERIES
   ========================================================================== */

/* Tablet & Mobile Screens */
@media (max-width: 600px) {
  .countdown-digits {
    font-size: 4.8rem; /* Fit milliseconds beautifully */
  }

  .app-container {
    padding: calc(128px + 1rem) 0.75rem 1.5rem 0.75rem;
  }

  .logo {
    font-size: 1.5rem;
  }

  .action-buttons-minimal {
    gap: 0.4rem;
  }

  .btn {
    padding: 0.7rem 0.1rem;
    font-size: 0.65rem;
  }
  
  .icon {
    width: 14px;
    height: 14px;
  }
}

/* Extremely Small/Narrow Devices */
@media (max-width: 375px) {
  .countdown-digits {
    font-size: 3.8rem;
  }

  .action-buttons-minimal {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.4rem;
  }
  
  .btn-forward, .btn-back {
    grid-column: span 1;
  }
  .btn-play-pause, .btn-stop {
    grid-column: span 1;
  }
  
  /* Symmetrical full width grids on tight viewports */
  .action-buttons-minimal {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
  }
  
  .btn {
    flex: 1 1 18%;
    padding: 0.8rem 0.2rem;
    font-size: 0.7rem;
  }
}

/* Landscape orientation on short heights */
@media (max-height: 600px) and (orientation: landscape) {
  .app-container {
    min-height: 100vh;
    height: auto;
    padding: calc(80px + 0.8rem) 1rem 0.8rem 1rem;
  }

  .timer-console {
    gap: 20px; /* Tighter layout spacing in landscape mode */
  }

  .countdown-digits {
    font-size: 3.8rem;
  }
}

/* Short Height Viewports scale dial height to maintain vertical balance */
@media (max-height: 660px) {
  .timeline-viewport {
    height: 80px;
  }
  .progress-bg-container {
    height: 80px;
  }
  .progress-bg-glow {
    height: 80px;
  }
  .app-container {
    padding-top: calc(80px + 1rem);
  }
}

/* ==========================================================================
   LIGHT MODE DESIGN SYSTEM OVERRIDES (APPLE-STYLE SILENT MATTE AESTHETIC)
   ========================================================================== */
body.theme-light {
  background-color: #fafafa; /* Near-white bright canvas */
  --text-primary: #111111; /* Sleek high-contrast solid black */
  --text-secondary: rgba(0, 0, 0, 0.75); /* Rich dark gray */
  --text-muted: rgba(0, 0, 0, 0.42); /* Subdued gray */

  /* Light Frosted Settings Modal Properties */
  --glass-bg: rgba(255, 255, 255, 0.82);
  --glass-border: rgba(0, 0, 0, 0.08);
  --glass-border-hover: rgba(0, 0, 0, 0.18);
  --glass-shadow: 0 16px 40px -10px rgba(0, 0, 0, 0.12);

  /* Timetrack Tick & Digit Colors (Light theme - soft colored backgrounds, white ticks) */
  --timetrack-tick-color: rgba(255, 255, 255, 0.85);
  --timetrack-tick-minor-color: rgba(255, 255, 255, 0.35);
  --timetrack-digit-color: rgba(255, 255, 255, 0.9);

  /* Soft pastel timeline backgrounds for light theme */
  --l-pomodoro-base: 56%;
  --l-short-base: 54%;
  --l-long-base: 55%;
}

/* Timeline borders and separator needle inversion */
body.theme-light .progress-bg-container {
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

body.theme-light .bg-column {
  border-right: 1.5px solid rgba(0, 0, 0, 0.14);
}

body.theme-light .progress-bg-glow {
  background-color: #111111;
}

body.theme-light .countdown-digits {
  text-shadow: 0 10px 30px rgba(0, 0, 0, 0.06);
}

/* Premium Matte Control Buttons in Light Mode */
body.theme-light .btn-ctrl {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-secondary);
}

body.theme-light .btn-ctrl:hover {
  background: rgba(0, 0, 0, 0.09);
  color: var(--text-primary);
}

/* Play/Pause Button - Sleek solid matte black with white icon in Light Theme */
body.theme-light .btn-play-pause {
  background: #111111;
  color: #ffffff;
}

body.theme-light .btn-play-pause:hover {
  background: #000000;
  color: #ffffff;
}

body.theme-light .btn-play-pause::before {
  background-color: #111111;
}

/* Ensure active/paused states keep solid black styling */
body.theme-light.timer-running .btn-play-pause,
body.theme-light.timer-paused:not(.timer-stopped) .btn-play-pause {
  background: #111111;
  color: #ffffff;
}

body.theme-light.timer-running .btn-play-pause:hover,
body.theme-light.timer-paused:not(.timer-stopped) .btn-play-pause:hover {
  background: #000000;
}

/* Frosted light settings modal */
body.theme-light .dialog-content {
  background: #f5f5f7;
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  color: #111111;
  box-shadow: var(--glass-shadow);
}

body.theme-light dialog[open]::backdrop {
  background-color: rgba(0, 0, 0, 0.09);
}

body.theme-light .dialog-header {
}

body.theme-light .close-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  color: #000000;
}

body.theme-light .dialog-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
}

body.theme-light .dialog-footer {
}

/* Numeric Input overrides */
body.theme-light .pill-input-wrap {
  background: rgba(0, 0, 0, 0.06);
}

body.theme-light .pill-input-wrap:focus-within {
  background: rgba(0, 0, 0, 0.1);
}

body.theme-light .input-field input[type="number"] {
  color: #111111;
}

body.theme-light .pill-unit {
  color: rgba(0, 0, 0, 0.4);
}

body.theme-light .toggle-label {
  color: var(--text-secondary);
}

body.theme-light .toggle-label:hover {
  color: #000000;
}

/* iOS Switches */
body.theme-light .ios-switch {
  background: rgba(0, 0, 0, 0.12);
}

body.theme-light .ios-switch::after {
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

body.theme-light .ios-switch:checked {
  background: #4cd964; /* Keep the beautiful signature green toggle */
}

/* Sliders */

body.theme-light .slider-field input[type="range"] {
  background: linear-gradient(
    to right,
    rgba(0, 0, 0, 0.75) 0%,
    rgba(0, 0, 0, 0.75) var(--fill, 75%),
    rgba(0, 0, 0, 0.12) var(--fill, 75%),
    rgba(0, 0, 0, 0.12) 100%
  );
}

body.theme-light .slider-field input[type="range"]::-webkit-slider-thumb {
  background: #111111;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Save Button */
body.theme-light .btn-primary {
  background: #111111;
  color: #ffffff;
}

body.theme-light .btn-primary:hover {
  background: #000000;
}

/* ==========================================================================
   PREMIUM STAGGERED ENTRY REVEAL ANIMATIONS (LOADS FROM TOP-DOWN)
   ========================================================================== */

/* Keyframe for standard elements: slight opacity fade + subtle glide down from top */
@keyframes reveal-down {
  0% {
    opacity: 0;
    transform: translateY(-20px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Keyframe for timeline: deepest drop and slowest slide in */
@keyframes timeline-reveal-down {
  0% {
    opacity: 0;
    transform: translateY(-64px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Base style for revealing items (starts invisible and animates) */
.reveal-item {
  opacity: 0;
  animation: reveal-down 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Timeline/Dial is slowest reveal (starts invisible, longer duration, deep slide) */
.timeline-viewport {
  opacity: 0;
  animation: timeline-reveal-down 1.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

/* Dial Background scrolls horizontally from right to left as it is revealed */
.progress-bg-container {
  animation: progress-reveal-scroll 1.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes progress-reveal-scroll {
  0% {
    transform: translateX(calc(50vw - var(--progress-px, 0px) + 300px));
  }
  100% {
    transform: translateX(calc(50vw - var(--progress-px, 0px)));
  }
}

/* Precise Staggered Delays (Header -> Dial -> Console Digits -> Label -> Controls -> About -> How -> Features -> Footer) */
.app-header.reveal-item {
  animation-delay: 0.1s;
}

.timeline-viewport {
  animation-delay: 0.25s; /* Slow dial reveal starts right after header begins fading in */
}

.progress-bg-container {
  animation-delay: 0.25s; /* Syncs with timeline-viewport reveal delay */
}

.countdown-digits.reveal-item {
  animation-delay: 0.4s;
}

.countdown-state-label.reveal-item {
  animation-delay: 0.5s;
}

.controls-section-minimal.reveal-item {
  animation-delay: 0.6s;
}

.info-about.reveal-item {
  animation-delay: 0.75s;
}

.info-how.reveal-item {
  animation-delay: 0.85s;
}

.info-features.reveal-item {
  animation-delay: 0.95s;
}

.app-footer.reveal-item {
  animation-delay: 1.1s;
}
