/* ==========================================================================
   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;
}

/* Prevent background body scroll when settings settings-dialog is open */
body:has(dialog[open]) {
  overflow: hidden;
}

/* --- Timeline Viewport Bounding Box --- */
.timeline-viewport {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  max-width: 100vw;
  height: 128px;
  overflow: hidden;
  z-index: 100;
  pointer-events: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08); /* Clean translucent bottom border */
  box-sizing: border-box;
}

/* --- 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: 100%; /* Sized to parent viewport height */
  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;
}

.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: var(--tick-digit-top, 50%); /* Start centered vertically, moves to 25% on scroll */
  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: var(--tick-minute-height, 32px); /* Start at 32px, scales to 50% of height on scroll */
  background-color: var(--timetrack-tick-color);
  width: 1px;
}

.tick-line.half-minute-line {
  height: var(--tick-half-height, 22px); /* Start at 22px, scales to 35% of height on scroll */
  background-color: var(--timetrack-tick-color);
  width: 1px;
}

.tick-line.ten-sec-line {
  height: var(--tick-ten-height, 14px); /* Start at 14px, scales to 22% of height on scroll */
  background-color: var(--timetrack-tick-minor-color);
  width: 1px;
}

.progress-bg-glow {
  position: fixed;
  top: 0; /* Extended all the way to the top of the viewport */
  left: 50%;
  width: 2px;
  height: 159px; /* Runs through the center of the tomato icon when resting */
  background: #ffffff;
  opacity: 0.85;
  transform: translateX(-50%);
  z-index: 101;
  pointer-events: none;
  transition: height 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Subpage active overrides (forces timeline track, ticks, and header to collapsed/scrolled state by default) */
body.subpage-active .timeline-viewport {
  height: 32px;
  animation: none !important; /* Disable entry animations on subpages */
  opacity: 1 !important;
}

body.subpage-active .progress-bg-glow {
  height: 32px;
}

/* Disable all entry reveal and sliding animations on subpages */
body.subpage-active .reveal-item,
body.subpage-active .progress-bg-container,
body.subpage-active .progress-bg-glow {
  animation: none !important;
  opacity: 1 !important;
}

body.subpage-active .app-header {
  top: 32px;
  background-color: rgba(18, 18, 18, 0.72);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

body.theme-light.subpage-active .app-header {
  background-color: rgba(250, 250, 250, 0.72);
}

body.subpage-active .app-container {
  padding-top: 112px;
}

body.subpage-active .tick-digit {
  top: 25% !important;
}

body.subpage-active .minute-line {
  height: 50% !important;
}

body.subpage-active .half-minute-line {
  height: 35% !important;
}

body.subpage-active .ten-sec-line {
  height: 22% !important;
}

@media (max-height: 660px) {
  body.subpage-active .timeline-viewport {
    height: 20px;
  }
  body.subpage-active .progress-bg-glow {
    height: 20px;
  }
  body.subpage-active .app-header {
    top: 20px;
  }
  body.subpage-active .app-container {
    padding-top: 100px;
  }
}

@media (max-width: 600px) {
  body.subpage-active .app-container {
    padding-top: 90px;
  }
}

@media (max-width: 600px) and (max-height: 660px) {
  body.subpage-active .app-container {
    padding-top: 78px;
  }
}


/* --- 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 + 6.75rem) 2rem 2.5rem 2rem; /* Padding top pushes content under fixed header, 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 {
  position: fixed;
  top: 128px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
  max-width: 1200px;
  padding: 1.5rem 2rem;
  z-index: 99;
  box-sizing: border-box;
  pointer-events: none;
  transition: background-color 0.3s ease, border-color 0.3s ease, backdrop-filter 0.3s ease, -webkit-backdrop-filter 0.3s ease;
}

/* Responsive top position for short viewports */
@media (max-height: 660px) {
  .app-header {
    top: 80px;
  }
}

.logo {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.05em;
  opacity: 0.9;
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
  user-select: none;
  pointer-events: auto;
}

.header-controls {
  pointer-events: auto;
}

/* Header Centered Logo Icon and Countdown Containers */
.header-logo-center {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 120px;
  height: 48px;
  z-index: 10;
  pointer-events: none;
}

.logo-icon-centered {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(1);
  width: 24px;
  height: 24px;
  color: currentColor; /* Matches primary text color */
  opacity: 1;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.header-countdown-digits {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) scale(0.6) translateY(20px);
  font-family: var(--font-mono); /* Tabular figures to prevent horizontal jittering */
  font-variant-numeric: tabular-nums;
  font-size: 1.75rem;
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.02em;
  text-indent: -0.03em;
  text-align: center;
  color: var(--text-primary);
  opacity: 0;
  user-select: none;
  pointer-events: auto; /* Enable pointer events when visible/active */
  cursor: pointer;
  visibility: hidden; /* Start hidden so it doesn't intercept pointer events while resting */
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), visibility 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Subpage active states: tomato icon scrolls up, header timer takes center stage */
body.subpage-active .logo-icon-centered {
  opacity: 0;
  transform: translate(-50%, -50%) translateY(-40px) scale(0.5);
  pointer-events: none;
}

body.subpage-active .header-countdown-digits {
  opacity: 0.9;
  transform: translate(-50%, -50%) translateY(0) scale(1);
  pointer-events: auto;
  visibility: visible;
}

/* --- Primary Countdown Display & Elapsed --- */
.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 */
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
  text-align: center;
  position: relative;
  z-index: 2;
}

body.teaser-mode .countdown-digits {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}


/* --- 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-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%;
}

/* Dynamically color-match session state text to the active track's HSL base colors */
.mode-pomodoro .countdown-state-label {
  color: hsl(var(--h-pomodoro), var(--s-pomodoro), var(--l-pomodoro-base));
  --q-active: hsla(var(--h-pomodoro), var(--s-pomodoro), var(--l-pomodoro-base), 1);
  --q-inactive: hsla(var(--h-pomodoro), var(--s-pomodoro), var(--l-pomodoro-base), 0.2);
}

.mode-short-break .countdown-state-label {
  color: hsl(var(--h-short), var(--s-short), var(--l-short-base));
  --q-active: hsla(var(--h-short), var(--s-short), var(--l-short-base), 1);
  --q-inactive: hsla(var(--h-short), var(--s-short), var(--l-short-base), 0.2);
}

.mode-long-break .countdown-state-label {
  color: hsl(var(--h-long), var(--s-long), var(--l-long-base));
  --q-active: hsla(var(--h-long), var(--s-long), var(--l-long-base), 1);
  --q-inactive: hsla(var(--h-long), var(--s-long), var(--l-long-base), 0.2);
}

/* 16px diameter circle spinner positioned perfectly between the session texts */
.session-spinner {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: conic-gradient(
    var(--q-active) 0deg 90deg,
    var(--q-inactive) 90deg 180deg,
    var(--q-active) 180deg 270deg,
    var(--q-inactive) 270deg 360deg
  );
  pointer-events: none;
  z-index: 3;
}

/* Spin clockwise a full rotation every second when the timer is running */
body.timer-running .session-spinner {
  animation: spin-clockwise 1s linear infinite;
}

@keyframes spin-clockwise {
  0% {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  100% {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}

.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;
  margin-top: 8px; /* Increased spacing between play controls and track name by 8px */
}

.action-buttons-minimal {
  display: grid;
  grid-template-columns: 1fr 1fr 1.5fr 1fr 1fr; /* Play button is 50% wider */
  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.2rem; /* Move icons closer to text in resting state */
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  border-radius: 9999px;
  padding: 0.75rem 0.2rem;
  height: 64px; /* Fixed height to match original and prevent size changing on hover */
  box-sizing: border-box;
  transition: 
    background 0.3s cubic-bezier(0.25, 1, 0.5, 1),
    transform 0.1s ease,
    border-color 0.3s ease,
    gap 0.3s cubic-bezier(0.25, 1, 0.5, 1), /* Fluid gap separation transition */
    color 0.3s ease;
}

.btn:hover {
  gap: 0.4rem; /* Slide icons/text back to original positions on hover */
}

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

.btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
  transform: none !important;
  box-shadow: none !important;
  pointer-events: none;
}

.btn-ctrl {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-secondary);
  border: none;
  transition: 
    background 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
    opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1),
    color 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.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;
  box-shadow: 0 0 0 0px #ffffff;
  min-width: 120px;
  transition: 
    background 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.2s cubic-bezier(0.16, 1, 0.3, 1),
    color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    box-shadow 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    min-width 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}


.btn-play-pause:hover {
  background: #ffffff;
  color: #111111;
  box-shadow: 0 0 0 2px #ffffff;
}

/* 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 {
  box-shadow: 0 0 0 2px #ffffff;
}

.btn-primary {
  background: #ffffff;
  color: #111111;
  border: none;
  border-radius: 8px; /* Matches modern 8px input field corner radius */
}

.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);
  width: 34px;
  height: 34px;
  box-sizing: border-box;
  padding: 0;
  border-radius: 50%;
  display: inline-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);
}

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);
}

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

.menu-icon,
.settings-icon,
.info-btn-icon {
  width: 18px;
  height: 18px;
  display: block;
}

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

/* Menu Button and Teaser Mode Overrides */
#open-menu-btn {
  width: 34px;
  margin-left: 0.5rem;
  transition: 
    opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
    width 0.6s cubic-bezier(0.16, 1, 0.3, 1),
    margin-left 0.6s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.6s cubic-bezier(0.16, 1, 0.3, 1),
    background 0.3s cubic-bezier(0.25, 1, 0.5, 1),
    color 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

body.teaser-mode #open-menu-btn {
  opacity: 0;
  pointer-events: none;
  width: 0;
  margin-left: 0;
  transform: translateX(15px);
  overflow: hidden;
}

/* Fade out the hamburger menu button when the sidemenu is open to prevent overlapping */
body:has(#side-menu[open]) #open-menu-btn {
  opacity: 0 !important;
  pointer-events: none;
}

/* Theme Switcher Button & Icons */
.theme-icon {
  width: 18px;
  height: 18px;
  stroke-width: 2px;
  display: block;
}

/* 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;
}

.app-footer {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  align-items: center;
  margin-top: auto;
  padding-top: 80px; /* Symmetrical space at the top ensures a minimum of 80px from the button/content above */
}

.footer-copyright {
  text-align: left;
}

.footer-attribution {
  text-align: right;
}

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

.footer-attribution a {
  color: var(--text-secondary);
  text-decoration: none;
  font-weight: 600;
  transition: color 0.2s cubic-bezier(0.16, 1, 0.3, 1);
}

.footer-attribution a:hover {
  color: var(--text-primary);
}

/* ==========================================================================
   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 1.5rem 1.5rem; /* Bottom padding under the save button increased to match horizontal 1.5rem boundaries */
}

.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-muted);
  margin-bottom: 0.5rem;
  font-weight: 700;
}

/* Grid input layout */
.input-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.5rem; /* Doubled spacing in between the fields */
}

.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: 8px; /* High-end rectangular corner radius */
  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: right;
  direction: rtl;
  outline: none;
  width: 100%;
  min-width: 0;
}

/* Force standard WebKit spin buttons to be always visible and high contrast */
.input-field input[type="number"]::-webkit-inner-spin-button,
.input-field input[type="number"]::-webkit-outer-spin-button {
  opacity: 0.75;
  cursor: pointer;
  transition: opacity 0.2s ease;
  margin-right: 0.25rem;
}

.input-field input[type="number"]::-webkit-inner-spin-button:hover,
.input-field input[type="number"]::-webkit-outer-spin-button:hover {
  opacity: 1;
}

.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: flex-start;
  align-items: center;
  gap: 0.75rem;
  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: 8px; /* Clean rectangular corners */
  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: 6px; /* Curvature matched perfectly to outer 8px border */
  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.95rem;
  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: 20px;
  height: 20px;
  border-radius: 6px; /* Rounded rectangle matching 6px/8px modal switches/knobs shape */
  background: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  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 (2x2 symmetrical grid) */
@media (min-width: 640px) and (max-width: 1024px) {
  .info-grid {
    grid-template-columns: repeat(2, 1fr);
    column-gap: 4rem; /* Increased horizontal spacing between cards */
    row-gap: 2.5rem;
  }
}

/* Desktop screens (4 columns: all cards are side-by-side in one row) */
@media (min-width: 1025px) {
  .info-grid {
    grid-template-columns: repeat(4, 1fr);
    column-gap: 4rem; /* Increased horizontal spacing between cards */
    row-gap: 2.5rem;
  }
}

.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-top: 0;
  margin-bottom: 1.5rem;
  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;
}

.shortcuts-list {
  list-style-type: none;
  padding-left: 0;
  gap: 1.1rem; /* Increased vertical spacing in between rows (buttons) */
}

.shortcuts-list li {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.shortcuts-list strong {
  display: flex;
  align-items: center;
}

kbd {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.2rem 0;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-bottom: 2.5px solid rgba(255, 255, 255, 0.18);
  box-shadow: 0 1.5px 3px rgba(0, 0, 0, 0.3);
  color: var(--text-primary);
  margin-right: 0.85rem; /* Increased horizontal spacing after key buttons */
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3.8rem;
  height: 1.7rem;
  line-height: 1;
  text-align: center;
}

body.theme-light kbd {
  background: rgba(0, 0, 0, 0.03);
  border: 1px solid rgba(0, 0, 0, 0.08);
  border-bottom: 2.5px solid rgba(0, 0, 0, 0.14);
  box-shadow: 0 1.5px 3px rgba(0, 0, 0, 0.05);
}

.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, .shortcuts-intro {
  margin-bottom: 1.25rem !important;
}


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

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

/* Tablet & Mobile Screens */
@media (max-width: 600px) {
  .app-header {
    padding: 1rem 1.25rem;
  }
  .logo {
    font-size: 1.35rem;
  }
  .header-countdown-digits {
    font-size: 1.35rem;
  }
  .logo-icon-centered {
    width: 20px;
    height: 20px;
  }
  .progress-bg-glow {
    height: 157px; /* Runs through the center of the tomato icon on mobile when resting */
  }

  .action-buttons-minimal {
    grid-template-columns: repeat(2, 1fr);
    grid-template-areas:
      'play play'
      'back skip'
      'stop restart';
    row-gap: 1rem;
    column-gap: 1rem;
    width: 100%;
    max-width: 100%; /* Fills the container width */
    padding: 0 2rem;
  }

  .btn-play-pause {
    grid-area: play;
  }

  .btn-stop {
    grid-area: stop;
  }

  .btn-back {
    grid-area: back;
  }

  .btn-forward {
    grid-area: skip;
  }

  .btn-reset-all {
    grid-area: restart;
  }



  .app-footer {
    grid-template-columns: 1fr;
    gap: 0.6rem;
    text-align: center;
    padding-top: 80px; /* Symmetrical space at the top ensures a minimum of 80px from the button/content above */
  }

  .footer-copyright,
  .footer-attribution {
    text-align: center;
  }
}

/* Extremely Small/Narrow Devices */
@media (max-width: 375px) {

  .action-buttons-minimal {
    grid-template-columns: repeat(2, 1fr);
    grid-template-areas:
      'play play'
      'back skip'
      'stop restart';
    row-gap: 1rem;
    column-gap: 1rem;
    width: 100%;
    max-width: 100%; /* Fills the container width */
    padding: 0 2rem;
  }



  .info-grid {
    gap: 6rem; /* Double the previous 3rem vertical spacing between text blocks */
  }
}

/* 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 */
  }
}

/* Short Height Viewports scale dial height to maintain vertical balance */
@media (max-height: 660px) {
  .timeline-viewport {
    height: 80px;
  }
  .progress-bg-glow {
    top: 0;
    height: 103px; /* Extended to run to the centered circle icon in short viewports */
  }
  .tick-digit {
    font-size: 0.58rem; /* Slightly smaller to fit inside short viewport's top 50% space */
  }
  .app-container {
    padding-top: calc(80px + 6.75rem); /* Increased padding to prevent view contents from overlapping the fixed header */
  }
}

/* ==========================================================================
   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 .timeline-viewport {
  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;
}

/* 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;
  box-shadow: 0 0 0 0px #111111;
}

body.theme-light .btn-play-pause:hover {
  background: #000000;
  color: #ffffff;
  box-shadow: 0 0 0 2px #000000;
}


/* 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;
  box-shadow: 0 0 0 2px #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: #ffffff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* 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) */
body:not(.entry-completed) .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 */
body:not(.entry-completed) .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 */
}

.timer-title-container.reveal-item {
  animation-delay: 0.4s;
}

.timer-state-container.reveal-item {
  animation-delay: 0.6s;
}

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

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

/* --- Header Entrance & Scroll-Driven Animations --- */

@keyframes header-reveal-down {
  0% {
    opacity: 0;
    transform: translate(-50%, -20px);
  }
  100% {
    opacity: 1;
    transform: translate(-50%, 0);
  }
}

.app-header.reveal-item {
  animation-name: header-reveal-down;
}

@keyframes shrink-header {
  to {
    height: 32px;
  }
}

@keyframes shrink-needle {
  to {
    height: 32px; /* Same height as collapsed timeline track */
  }
}

@keyframes scale-tick-digit {
  to {
    top: 25%;
  }
}

@keyframes scale-minute-line {
  to {
    height: 50%;
  }
}

@keyframes scale-half-line {
  to {
    height: 35%;
  }
}

@keyframes scale-ten-line {
  to {
    height: 22%;
  }
}

@keyframes shrink-header-short {
  to {
    height: 20px;
  }
}

@keyframes shrink-needle-short {
  to {
    height: 20px; /* Same height as collapsed timeline track in short viewports */
  }
}

@keyframes shrink-needle-mobile {
  to {
    height: 32px; /* Same height as collapsed timeline track */
  }
}

@keyframes shrink-needle-short-mobile {
  to {
    height: 20px; /* Same height as collapsed timeline track in short viewports */
  }
}

/* Scroll-driven animations for the fixed header */
@keyframes header-scroll-dark {
  to {
    top: 32px;
    background-color: rgba(18, 18, 18, 0.72);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
}

@keyframes header-scroll-light {
  to {
    top: 32px;
    background-color: rgba(250, 250, 250, 0.72);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
}

@keyframes header-scroll-dark-short {
  to {
    top: 20px;
    background-color: rgba(18, 18, 18, 0.72);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
}

@keyframes header-scroll-light-short {
  to {
    top: 20px;
    background-color: rgba(250, 250, 250, 0.72);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
  }
}

/* Keyframes for sliding out the tomato icon and showing the countdown */
@keyframes hide-tomato-on-scroll {
  to {
    opacity: 0;
    transform: translate(-50%, -50%) translateY(-40px) scale(0.5);
  }
}

@keyframes show-countdown-on-scroll {
  0% {
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -50%) scale(0.6) translateY(20px);
  }
  75% {
    opacity: 0;
    visibility: hidden;
    transform: translate(-50%, -50%) scale(0.6) translateY(20px);
  }
  100% {
    opacity: 0.9;
    visibility: visible;
    transform: translate(-50%, -50%) translateY(0) scale(1);
  }
}

@keyframes fade-scale-body-timer {
  to {
    opacity: 0;
    transform: scale(0.6) translateY(-40px);
  }
}

@supports ((animation-timeline: scroll()) and (animation-range: 0% 100%)) {
  .entry-completed:not(.subpage-active) .timeline-viewport {
    animation: shrink-header auto linear both;
    animation-timeline: scroll(block root);
    animation-range: 0px 96px;
  }
  .entry-completed:not(.subpage-active) .progress-bg-glow {
    animation: shrink-needle auto linear both;
    animation-timeline: scroll(block root);
    animation-range: 0px 96px;
  }
  .entry-completed:not(.subpage-active) .app-header {
    animation: header-scroll-dark auto linear both;
    animation-timeline: scroll(block root);
    animation-range: 0px 96px;
  }
  body.theme-light.entry-completed:not(.subpage-active) .app-header {
    animation-name: header-scroll-light;
  }
  .entry-completed:not(.subpage-active) .tick-digit {
    animation: scale-tick-digit auto linear both;
    animation-timeline: scroll(block root);
    animation-range: 0px 96px;
  }
  .entry-completed:not(.subpage-active) .minute-line {
    animation: scale-minute-line auto linear both;
    animation-timeline: scroll(block root);
    animation-range: 0px 96px;
  }
  .entry-completed:not(.subpage-active) .half-minute-line {
    animation: scale-half-line auto linear both;
    animation-timeline: scroll(block root);
    animation-range: 0px 96px;
  }
  .entry-completed:not(.subpage-active) .ten-sec-line {
    animation: scale-ten-line auto linear both;
    animation-timeline: scroll(block root);
    animation-range: 0px 96px;
  }

  /* Scroll animations for cross-fading body timer, logo icon, and header timer */
  .entry-completed:not(.subpage-active) .logo-icon-centered {
    animation: hide-tomato-on-scroll auto linear both;
    animation-timeline: scroll(block root);
    animation-range: 0px 96px;
  }
  .entry-completed:not(.subpage-active) .header-countdown-digits {
    animation: show-countdown-on-scroll auto linear both;
    animation-timeline: scroll(block root);
    animation-range: 0px 96px;
  }
  .entry-completed:not(.subpage-active) .countdown-digits {
    animation: fade-scale-body-timer auto linear both;
    animation-timeline: scroll(block root);
    animation-range: 64px 96px;
  }

  @media (max-height: 660px) {
    .entry-completed:not(.subpage-active) .timeline-viewport {
      animation-name: shrink-header-short;
      animation-range: 0px 60px;
    }
    .entry-completed:not(.subpage-active) .progress-bg-glow {
      animation-name: shrink-needle-short;
      animation-range: 0px 60px;
    }
    .entry-completed:not(.subpage-active) .app-header {
      animation-name: header-scroll-dark-short;
      animation-range: 0px 60px;
    }
    body.theme-light.entry-completed:not(.subpage-active) .app-header {
      animation-name: header-scroll-light-short;
    }
    .entry-completed:not(.subpage-active) .tick-digit {
      animation-range: 0px 60px;
    }
    .entry-completed:not(.subpage-active) .minute-line {
      animation-range: 0px 60px;
    }
    .entry-completed:not(.subpage-active) .half-minute-line {
      animation-range: 0px 60px;
    }
    .entry-completed:not(.subpage-active) .ten-sec-line {
      animation-range: 0px 60px;
    }
    .entry-completed:not(.subpage-active) .countdown-digits {
      animation-range: 40px 60px;
    }
  }
}

/* --- Sidemenu Dialog & Animations --- */
#side-menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: auto;
  transform: translateX(100%);
  width: 320px;
  max-width: 85vw;
  height: 100dvh;
  max-height: 100dvh;
  margin: 0;
  border: none;
  background: transparent; /* Rely on inner .dialog-content for glassmorphism */
  opacity: 1; /* Retain opacity and animate via translation */
  transition-property: transform, display, overlay;
  transition-duration: 0.45s;
  transition-timing-function: cubic-bezier(0.16, 1, 0.3, 1);
  transition-behavior: allow-discrete;
  display: flex;
  flex-direction: column;
  z-index: 150;
}

#side-menu[open] {
  transform: translateX(0);
}

@starting-style {
  #side-menu[open] {
    transform: translateX(100%);
  }
}

/* Sidemenu Backdrop */
#side-menu::backdrop {
  background-color: rgba(0, 0, 0, 0);
  backdrop-filter: blur(0px);
  -webkit-backdrop-filter: blur(0px);
  transition:
    display 0.45s allow-discrete,
    overlay 0.45s allow-discrete,
    background-color 0.45s cubic-bezier(0.16, 1, 0.3, 1),
    backdrop-filter 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

#side-menu[open]::backdrop {
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

@starting-style {
  #side-menu[open]::backdrop {
    background-color: rgba(0, 0, 0, 0);
    backdrop-filter: blur(0px);
    -webkit-backdrop-filter: blur(0px);
  }
}

/* Light Theme backdrop for Sidemenu */
body.theme-light #side-menu[open]::backdrop {
  background-color: rgba(0, 0, 0, 0.12);
  backdrop-filter: blur(8px);
}

/* Sidemenu Glass Panel Override */
.side-menu-content {
  height: 100%;
  max-height: 100%; /* Override default .dialog-content max-height of 85vh */
  border-radius: 0; /* Align perfectly with viewport edges */
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  border-top: none;
  border-bottom: none;
  border-right: none;
  background: rgba(22, 22, 22, 0.85); /* Slightly darker frosted glass */
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  box-sizing: border-box;
  position: relative; /* Containing block for absolute positioned close button */
}

body.theme-light .side-menu-content {
  border-left: 1px solid rgba(0, 0, 0, 0.06);
  background: rgba(245, 245, 247, 0.85);
}

/* Sidemenu Layout & Navigation */
.side-menu-header {
  height: calc(var(--close-btn-top, 2.5rem) + var(--close-btn-height, 34px) + 1.5rem);
  padding: 0;
  border-bottom: none;
}

body.theme-light .side-menu-header {
  border-bottom: none;
}

/* Absolute position the Menu heading to align horizontally with the close button */
#side-menu .side-menu-header h2 {
  position: absolute;
  top: var(--close-btn-top, 2.5rem);
  left: 2rem;
  height: var(--close-btn-height, 34px);
  display: flex;
  align-items: center;
  margin: 0;
  font-weight: 300; /* Light weight */
  color: var(--text-primary);
  font-size: 1.35rem;
  letter-spacing: -0.02em;
}

/* Position close button exactly over the hamburger menu button and match its style */
#side-menu #close-menu-btn {
  position: absolute;
  top: var(--close-btn-top, 2.5rem);
  right: var(--close-btn-right, 1.5rem);
  width: var(--close-btn-width, 34px);
  height: var(--close-btn-height, 34px);
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: none;
  cursor: pointer;
  transition: 
    background 0.3s cubic-bezier(0.25, 1, 0.5, 1),
    color 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

body.theme-light #side-menu #close-menu-btn {
  background: rgba(0, 0, 0, 0.05);
}

#side-menu #close-menu-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text-primary);
}

body.theme-light #side-menu #close-menu-btn:hover {
  background: rgba(0, 0, 0, 0.09);
}

#side-menu #close-menu-btn .icon {
  width: 18px;
  height: 18px;
  stroke-width: 2px;
  display: block;
}

.side-menu-body {
  flex-grow: 1;
  padding: 1.5rem 0.75rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.side-menu-nav {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  flex-grow: 1;
}

#menu-btn-auth {
  margin-top: auto;
}

/* Menu Items (Links/Buttons) */
.menu-item {
  background: transparent;
  border: none;
  outline: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  width: 100%;
  padding: 1rem 1.25rem;
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 600; /* Bold weight */
  color: var(--text-secondary);
  border-radius: 10px;
  text-align: left;
  text-decoration: none;
  transition: background 0.3s ease, color 0.3s ease;
  box-sizing: border-box;
}

/* Menu Item Hover States */
.menu-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

body.theme-light .menu-item:hover {
  background: rgba(0, 0, 0, 0.03);
}

/* ==========================================================================
   ONBOARDING TEASER STATE AND TRANSITIONS
   ========================================================================== */

/* Teaser wrappers */
.timer-title-container,
.timer-state-container {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* Teaser Title Overlay */
.teaser-title {
  font-family: var(--font-mono);
  font-size: 6.2rem; /* Matches .countdown-digits */
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-primary);
  text-align: center;
  line-height: 1;
  pointer-events: none;
  white-space: nowrap;
  
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translateY(0);
  opacity: 0;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  z-index: 3;
}

body.teaser-mode .teaser-title {
  opacity: 1;
  transform: translate(-50%, -50%) translateY(0);
  pointer-events: auto;
}

body:not(.teaser-mode) .teaser-title {
  opacity: 0;
  transform: translate(-50%, -50%) translateY(-20px);
}

/* Teaser Subtitle Overlay */
.teaser-subtitle {
  font-family: var(--font-mono); /* Matches .countdown-state-label */
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.35em;
  color: var(--text-primary); /* Same color as the text above it */
  text-transform: uppercase;
  text-align: center;
  pointer-events: none;
  
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) translateY(0);
  opacity: 0;
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
  width: 100%;
  z-index: 3;
}

body.teaser-mode .teaser-subtitle {
  opacity: 1;
  transform: translate(-50%, -50%) translateY(0);
  pointer-events: auto;
}

body:not(.teaser-mode) .teaser-subtitle {
  opacity: 0;
  transform: translate(-50%, -50%) translateY(-20px);
}

/* Normal Timer & Label transition when teaser is active vs inactive */
.countdown-state-label {
  transition: opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1), transform 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

body.teaser-mode .countdown-state-label {
  opacity: 0;
  transform: translateY(20px);
  pointer-events: none;
}

/* Teaser Play Button Styling */
.btn-text-teaser {
  display: none;
}

body.teaser-mode .btn-text-teaser {
  display: inline;
}

body.teaser-mode .btn-text-normal {
  display: none !important;
}

body.teaser-mode .btn-play-pause .icon {
  display: none !important;
}

body.teaser-mode .btn-play-pause {
  min-width: 240px; /* Double width of play button */
}

/* Fanning-out control buttons centering under play button in teaser mode */
body.teaser-mode #btn-stop {
  transform: translate(calc(225% + 0.4rem), 0) scale(0);
  opacity: 0;
  pointer-events: none;
}

body.teaser-mode #btn-back {
  transform: translate(calc(125% + 0.2rem), 0) scale(0);
  opacity: 0;
  pointer-events: none;
}

body.teaser-mode #btn-forward {
  transform: translate(calc(-125% - 0.2rem), 0) scale(0);
  opacity: 0;
  pointer-events: none;
}

body.teaser-mode #btn-reset-all {
  transform: translate(calc(-225% - 0.4rem), 0) scale(0);
  opacity: 0;
  pointer-events: none;
}

/* Fanning-out staggering/delay transition rules when teaser mode is deactivated */
body:not(.teaser-mode) #btn-back,
body:not(.teaser-mode) #btn-forward {
  transition: 
    background 0.3s cubic-bezier(0.16, 1, 0.3, 1) 0s,
    transform 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.5s,
    opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.5s,
    color 0.3s cubic-bezier(0.16, 1, 0.3, 1) 0s;
}

body:not(.teaser-mode) #btn-stop,
body:not(.teaser-mode) #btn-reset-all {
  transition: 
    background 0.3s cubic-bezier(0.16, 1, 0.3, 1) 0s,
    transform 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.75s,
    opacity 0.5s cubic-bezier(0.16, 1, 0.3, 1) 0.75s,
    color 0.3s cubic-bezier(0.16, 1, 0.3, 1) 0s;
}

/* Responsive Font Size Overrides for Onboarding Teaser (placed at the bottom of stylesheet to respect cascading order) */
@media (max-width: 600px) {
  .teaser-title {
    font-size: 4.8rem;
  }
}

@media (max-width: 375px) {
  .teaser-title {
    font-size: 3.8rem;
  }
}

@media (max-height: 600px) and (orientation: landscape) {
  .teaser-title {
    font-size: 3.8rem;
  }
}

/* ==========================================================================
   GAMIFIED STREAK TRACKER & STATISTICS DASHBOARD STYLES
   ========================================================================== */

/* Stats Button Flame & Badge */
#open-stats-btn {
  position: relative;
}

.stats-icon {
  width: 20px;
  height: 20px;
  stroke: var(--text-primary);
  transition: transform 0.3s ease;
}

#open-stats-btn:hover .stats-icon {
  transform: scale(1.1);
}

.streak-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: hsl(var(--h-pomodoro), var(--s-pomodoro), var(--l-pomodoro-base));
  color: #ffffff;
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  border: 1.5px solid #111111;
  z-index: 5;
  box-sizing: border-box;
}

body.theme-light .streak-badge {
  border-color: #ffffff;
}

@keyframes streak-pop {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.3);
  }
  100% {
    transform: scale(1);
  }
}

.streak-badge.pop {
  animation: streak-pop 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.stats-integrated-section {
  width: 100%;
  max-width: 100%; /* Extended to full viewport/container width */
  margin-top: 4rem;
  margin-bottom: 0;
  margin-left: auto;
  margin-right: auto;
  background: none; /* Removed background */
  border: none; /* Removed outlines/borders */
  padding: 0; /* Align content flush with the layout grid */
  box-sizing: border-box;
  opacity: 1;
  transform: translateY(0);
  max-height: 2500px;
  overflow: visible;
  transition: opacity 0.8s cubic-bezier(0.16, 1, 0.3, 1), 
              transform 0.8s cubic-bezier(0.16, 1, 0.3, 1),
              max-height 1.2s cubic-bezier(0.16, 1, 0.3, 1),
              margin-top 1.2s cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: 0.5s; /* Staggered build-in after fanning controls */
}

/* Hide in teaser mode and slide down slightly */
body.teaser-mode .stats-integrated-section {
  opacity: 0;
  pointer-events: none;
  transform: translateY(30px);
  max-height: 0;
  margin-top: 0;
  overflow: hidden;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              max-height 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              margin-top 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  transition-delay: 0s; /* Instant hide when in teaser mode */
}

.stats-overview-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 480px) {
  .stats-overview-grid {
    grid-template-columns: repeat(3, 1fr); /* 3 columns on tablets (2 rows of 3) */
  }
}

@media (min-width: 768px) {
  .stats-overview-grid {
    grid-template-columns: repeat(6, 1fr); /* 6 columns on desktops (1 row of 6) */
  }
}

.stats-card {
  background: rgba(255, 255, 255, 0.04);
  border: none; /* Removed borders */
  border-radius: 12px;
  padding: 1.5rem 0.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: background-color 0.3s ease;
}

.stats-card-icon {
  font-size: 1.3rem;
  margin-bottom: 0.25rem;
}

.stats-card-val {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
  word-break: break-all;
  font-size: clamp(0.95rem, 3.8vw, 1.4rem); /* Responsive font size to prevent overflow for long unrounded numbers */
}

.stats-card-label {
  font-size: 0.68rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 0.2rem;
}

body.theme-light .stats-card {
  background: rgba(0, 0, 0, 0.02);
}

/* Stats Collapse/Expand Trigger & Container */
.stats-trigger-container {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.btn-stats-trigger {
  width: 100%; /* Extended to fill width */
  background: rgba(255, 255, 255, 0.04); /* Matched to stats card background */
  border: none; /* Removed border */
  border-radius: 12px; /* Same border radius as stats cards */
  padding: 1rem 1.5rem; /* Sized comfortably for full-width card */
  color: var(--text-secondary); /* Matched to back button resting text color */
  font-family: var(--font-main);
  font-size: 0.72rem; /* Matched to back button text size */
  font-weight: 600; /* Matched to back button font weight */
  text-transform: uppercase; /* Matched to back button text transform */
  letter-spacing: 0.05em; /* Matched to back button letter spacing */
  cursor: pointer;
  display: flex;
  flex-direction: row; /* Override .btn flex-direction column */
  height: auto; /* Override .btn fixed height 64px to let padding control height */
  align-items: center;
  justify-content: center; /* Centered label and icon */
  gap: 0.35rem; /* Subtly tighter resting gap to align with other controls */
  transition: 
    background 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
    color 0.3s cubic-bezier(0.16, 1, 0.3, 1),
    gap 0.4s cubic-bezier(0.16, 1, 0.3, 1); /* Animated gap spacing */
  outline: none;
  box-shadow: none; /* Removed shadow */
}

.btn-stats-trigger:hover {
  background: rgba(255, 255, 255, 0.14); /* Matched to back button hover background */
  color: var(--text-primary); /* Matched to back button hover text color */
  transform: translateY(-1px);
  gap: 0.5rem; /* Hover gap spacing decreased to 0.5rem */
  box-shadow: none; /* Removed shadow on hover */
}

body.theme-light .btn-stats-trigger {
  background: rgba(0, 0, 0, 0.02); /* Matched to stats card Light Theme background */
  color: var(--text-secondary);
}

body.theme-light .btn-stats-trigger:hover {
  background: rgba(0, 0, 0, 0.09); /* Matched to back button Light Theme hover background */
  color: var(--text-primary);
  box-shadow: none;
}

.btn-stats-trigger .icon-chevron {
  width: 16px; /* Matched to back button icon width */
  height: 16px; /* Matched to back button icon height */
  stroke-width: 2.5px; /* Matched to back button icon stroke-width */
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  stroke: currentColor;
}

/* Left chevron rotation (clockwise) */
.btn-stats-trigger[aria-expanded="true"] .icon-chevron:first-of-type {
  transform: rotate(180deg);
}

/* Right chevron rotation (counter-clockwise/opposite direction) */
.btn-stats-trigger[aria-expanded="true"] .icon-chevron:last-of-type {
  transform: rotate(-180deg);
}

/* Collapsable Grid Container for Height Animation */
.stats-collapsable-content {
  display: grid;
  grid-template-rows: 0fr; /* Collapsed state */
  overflow: hidden;
  transition: grid-template-rows 0.6s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1), margin-top 0.6s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0;
  margin-top: 0;
  width: 100%; /* Guarantee full horizontal container scaling */
}

.stats-collapsable-content.expanded {
  grid-template-rows: 1fr; /* Expanded state */
  opacity: 1;
  margin-top: 2.5rem;
}

.stats-collapsable-inner {
  min-height: 0; /* Required for the 0fr -> 1fr grid transition trick */
  width: 100%; /* Guarantee full horizontal container scaling */
  box-sizing: border-box;
  display: grid;
  grid-template-columns: minmax(0, 1fr); /* Prevent content-based grid expansion and horizontal layout overflows */
  gap: 2.5rem; /* Spacious gap between vertical sections */
}

/* Weekly Bar Chart */
.stats-section {
  margin-bottom: 0; /* Rely on grid gap instead of margin-bottom */
  min-width: 0; /* Prevent horizontal container expansion under grid layouts */
}

.stats-section h3 {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-secondary);
  margin-bottom: 1rem; /* Added margin since underline is removed */
}

.chart-container {
  background: rgba(255, 255, 255, 0.04);
  border: none; /* Removed border */
  border-radius: 12px;
  padding: 2.5rem 2rem; /* Doubled top, bottom, and side padding */
  box-sizing: border-box;
}

body.theme-light .chart-container {
  background: rgba(0, 0, 0, 0.02);
}

.chart-bars {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  height: 120px;
  padding-top: 1.5rem;
  position: relative;
}

.chart-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: calc(100% / 7 - 1rem); /* Doubled gap between daily groups */
  height: 100%;
  justify-content: flex-end;
}

.chart-bar-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: row; /* Lay out the 3 bars side-by-side */
  align-items: flex-end; /* Align bars to bottom */
  justify-content: space-between;
  gap: 3px; /* Minimal gap between the 3 bars of the same day */
  position: relative;
}

.chart-bar {
  flex: 1; /* Allow each of the 3 bars to take equal width */
  min-width: 6px; /* Ensure a minimum width so they don't collapse too much */
  background: rgba(255, 255, 255, 0.12);
  border-radius: 2px 2px 0 0; /* Slightly rounder top corners for thin bars */
  height: var(--bar-height, 0%);
  transition: height 0.8s cubic-bezier(0.16, 1, 0.3, 1), background-color 0.3s ease, opacity 0.3s ease;
  position: relative;
  min-height: 2px;
}

/* Color Coding for Focus, Short Break, and Long Break Bars */
.chart-bar.focus, body.theme-light .chart-bar.focus {
  background: hsl(var(--h-pomodoro), var(--s-pomodoro), var(--l-pomodoro-fill));
}

.chart-bar.short-break, body.theme-light .chart-bar.short-break {
  background: hsl(var(--h-short), var(--s-short), var(--l-short-fill));
}

.chart-bar.long-break, body.theme-light .chart-bar.long-break {
  background: hsl(var(--h-long), var(--s-long), var(--l-long-fill));
}

/* Hover effects */
.chart-bar:hover {
  opacity: 1 !important; /* Ensure hovered bar is fully bright */
}

/* Opacity states for today vs other days (subtle highlight, keeping them saturated) */
.chart-column:not(.active) .chart-bar {
  opacity: 0.8;
}
.chart-column.active .chart-bar {
  opacity: 1;
}

/* Style for today's active day label */
.chart-column.active .chart-bar-label {
  color: var(--text-primary);
  font-weight: 600;
}

.chart-bar-val {
  position: absolute;
  top: -1.25rem;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-primary);
}

.chart-bar-label {
  font-family: var(--font-main);
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 0.4rem;
  text-align: center;
}

body.theme-light .chart-bar {
  background: rgba(0, 0, 0, 0.08);
}

/* Mobile responsive overrides for the weekly chart */
@media (max-width: 600px) {
  .chart-container {
    padding: 1.5rem 1rem; /* Muted padding on mobile */
  }
  .chart-column {
    width: calc(100% / 7 - 0.5rem); /* Doubled gaps on mobile to give more breathing room */
  }
  .chart-bar-wrapper {
    gap: 1.5px; /* Tiny gap on mobile */
  }
  .chart-bar {
    min-width: 3.5px;
    border-radius: 1px 1px 0 0;
  }
  .chart-bar-val {
    font-size: 0.58rem; /* Smaller font on mobile to prevent overlaps */
    top: -1.05rem;
  }
  .chart-bar-label {
    font-size: 0.55rem;
  }
}

/* Achievements Badges Grid */
.badges-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr); /* 4 columns on wider viewports */
  gap: 0.75rem;
}

@media (max-width: 640px) {
  .badges-grid {
    grid-template-columns: repeat(2, 1fr); /* Break into 2x2 grid on lower breakpoints */
  }
}

.badge-card {
  background: rgba(255, 255, 255, 0.04);
  border: none; /* Removed borders */
  border-radius: 12px;
  padding: 1.7rem 0.6rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.3s ease, background-color 0.3s ease;
  position: relative;
  box-sizing: border-box;
}

.badge-card:hover {
  transform: translateY(-2px);
}

.badge-icon {
  font-size: 1.8rem;
  margin-bottom: 0.4rem;
  transition: transform 0.4s ease;
}

.badge-card:hover .badge-icon {
  transform: scale(1.15) rotate(5deg);
}

.badge-title {
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.15rem 0;
}

.badge-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.3;
}

/* Badge States */
.badge-locked .badge-icon {
  opacity: 0.25; /* Only icon is dimmed/deactivated */
  filter: grayscale(100%);
}

.badge-unlocked {
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 4px 20px -5px rgba(255, 87, 51, 0.15);
}

.badge-unlocked .badge-icon {
  opacity: 1;
  filter: none;
}

/* Light Theme overrides for badges */
body.theme-light .badge-card {
  background: rgba(0, 0, 0, 0.02);
}

body.theme-light .badge-unlocked {
  background: rgba(0, 0, 0, 0.03);
  box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.08);
}

/* --- Achievements Section (Horizontally Scrollable) --- */
.achievements-scroll-container {
  display: flex;
  gap: 1rem;
  overflow-x: auto;
  padding: 0.5rem 0.25rem 1.2rem 0.25rem;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}

/* Custom Minimalist Scrollbar */
.achievements-scroll-container::-webkit-scrollbar {
  height: 6px;
}

.achievements-scroll-container::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.02);
  border-radius: 10px;
}

body.theme-light .achievements-scroll-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.01);
}

.achievements-scroll-container::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 10px;
}

.achievements-scroll-container::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.2);
}

body.theme-light .achievements-scroll-container::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.08);
}

body.theme-light .achievements-scroll-container::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.16);
}

.achievement-card {
  width: 150px;
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.04);
  border: none;
  border-radius: 12px;
  padding: 1.5rem 0.5rem;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, background-color 0.3s ease;
  box-sizing: border-box;
}

.achievement-card:hover {
  transform: translateY(-2px);
}

.achievement-icon {
  font-size: 1.6rem;
  margin-bottom: 0.4rem;
  transition: transform 0.4s ease;
}

.achievement-card:hover .achievement-icon {
  transform: scale(1.15) rotate(5deg);
}

.achievement-title {
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 0.15rem 0;
  white-space: normal;
  line-height: 1.2;
}

.achievement-desc {
  font-size: 0.72rem;
  color: var(--text-muted);
  margin: 0;
  line-height: 1.2;
  white-space: normal;
}

/* Achievement States */
.achievement-locked .achievement-icon {
  opacity: 0.25;
  filter: grayscale(100%);
}

.achievement-unlocked {
  background: rgba(255, 255, 255, 0.07);
  box-shadow: 0 4px 20px -5px rgba(255, 87, 51, 0.12);
}

.achievement-unlocked .achievement-icon {
  opacity: 1;
  filter: none;
}

/* Light Theme overrides for achievements */
body.theme-light .achievement-card {
  background: rgba(0, 0, 0, 0.02);
}

body.theme-light .achievement-unlocked {
  background: rgba(0, 0, 0, 0.03);
  box-shadow: 0 4px 20px -5px rgba(0, 0, 0, 0.06);
}

/* --- SPA Views & Article Routing Layouts --- */

/* Base View class */
.app-view {
  width: 100%;
  box-sizing: border-box;
}

/* Info Subpage View */
.info-view {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  gap: 2rem;
  padding-top: 2rem;
}

@media (max-height: 600px) and (orientation: landscape) {
  .info-view {
    padding-top: 1rem;
  }
}

.info-view-content {
  width: 100%;
}



/* Custom Overrides to make info-card blend beautifully as a full-page article */
.info-view .info-card {
  background: rgba(255, 255, 255, 0.04);
  border: none;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: none;
}

body.theme-light .info-view .info-card {
  background: rgba(0, 0, 0, 0.02);
  border: none;
  box-shadow: none;
}

/* Feedback Link Styling */
.feedback-email-link {
  color: #ff5733; /* Terracotta highlight */
  text-decoration: none;
  font-weight: 600;
  border-bottom: 1px dashed rgba(255, 87, 51, 0.4);
  transition: border-color 0.3s ease, color 0.3s ease, transform 0.3s ease;
  display: inline-block;
}

.feedback-email-link:hover {
  color: var(--text-primary);
  border-bottom-color: var(--text-primary);
  transform: scale(1.02);
}

/* View Header containing Back Button */
.view-header {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
}

/* Glassmorphic Back Button styling */
.back-to-timer-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 100px;
  padding: 0.6rem 1.2rem;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.back-to-timer-btn span {
  transition: color 0.3s ease;
}

.back-to-timer-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.12);
  color: var(--text-primary);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  transform: translateY(-1px);
}

.back-to-timer-btn:active {
  transform: translateY(1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

/* Back Arrow Animation */
.icon-back-arrow {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.back-to-timer-btn:hover .icon-back-arrow {
  transform: translateX(-4px);
}

/* Light Theme Back Button Overrides */
body.theme-light .back-to-timer-btn {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.05);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.02);
}

body.theme-light .back-to-timer-btn:hover {
  background: rgba(0, 0, 0, 0.06);
  border-color: rgba(0, 0, 0, 0.08);
  color: var(--text-primary);
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.04);
}

/* Logo Acting as Home Link */
.logo {
  cursor: pointer;
  transition: opacity 0.2s ease, transform 0.2s ease;
  user-select: none;
}

.logo:hover {
  opacity: 1;
}

.logo:active {
  transform: scale(0.98);
}

/* Smooth Entrance Transition Animation */
.view-enter {
  animation: viewEntrance 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes viewEntrance {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Full-Page Settings Layout Overrides --- */
.info-view .settings-form {
  display: flex;
  flex-direction: column;
  gap: 2.25rem;
  height: auto;
  max-height: none;
}


/* --- Gamified Achievement Popup System --- */

/* Blurred Background Overlay */
.achievement-popup-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.achievement-popup-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

/* Achievement Popup Modal Card */
.achievement-popup-modal {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.08);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 24px;
  padding: 2.5rem 2rem;
  width: 320px;
  text-align: center;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.15), 0 0 40px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  align-items: center;
  position: relative;
  overflow: hidden;
  
  /* Entrance Animation: Bounce Up/Scale In */
  transform: scale(0.8) translateY(50px);
  opacity: 0;
  transition: transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.6s ease;
}

.achievement-popup-overlay.active .achievement-popup-modal {
  transform: scale(1) translateY(0);
  opacity: 1;
}

/* Dismiss State: Bounce Down */
.achievement-popup-overlay.dismissing .achievement-popup-modal {
  transform: scale(0.85) translateY(120px);
  opacity: 0;
  transition: transform 0.5s cubic-bezier(0.175, 0.885, 0.32, 1.1), opacity 0.4s ease;
}

.achievement-popup-overlay.dismissing {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease 0.1s;
}

/* Badge Icon styles */
.achievement-popup-badge-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.08));
  animation: popupIconPop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

@keyframes popupIconPop {
  0% { transform: scale(0) rotate(-15deg); }
  70% { transform: scale(1.2) rotate(10deg); }
  100% { transform: scale(1) rotate(0); }
}

/* Title & Labels */
.achievement-popup-title {
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: #1d1d1f; /* Dark text */
  margin: 0 0 1rem 0; /* Add space below the repositioned title */
}

.achievement-popup-name {
  font-family: var(--font-main);
  font-size: 1.5rem;
  font-weight: 800;
  color: #1d1d1f; /* Force dark text in both themes */
  margin: 0 0 0.5rem 0;
  line-height: 1.2;
}

.achievement-popup-desc {
  font-size: 0.85rem;
  color: #515154; /* Force dark gray text in both themes */
  margin: 0;
  line-height: 1.4;
}

/* Shimmer Effect overlaying the card */
.achievement-popup-shimmer {
  position: absolute;
  top: 0;
  left: -150%;
  width: 100%;
  height: 100%;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.6) 50%,
    rgba(255, 255, 255, 0) 100%
  );
  transform: skewX(-25deg);
  pointer-events: none;
}

.achievement-popup-overlay.active .achievement-popup-shimmer {
  animation: popupShimmer 1.5s cubic-bezier(0.16, 1, 0.3, 1) 0.4s both;
}

@keyframes popupShimmer {
  0% { left: -150%; }
  100% { left: 150%; }
}

/* ==========================================================================
   EMBEDDED ACCOUNT PORTAL DIALOG (v3.0.0)
   ========================================================================== */

/* Native Dialog Element Styling */
#auth-modal {
  background: transparent;
  border: none;
  padding: 0;
  max-width: 420px;
  width: calc(100% - 2.5rem);
  max-height: 90vh;
  box-shadow: none;
  outline: none;
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.9);
  opacity: 0;
  z-index: 10000;
  transition: opacity 0.4s cubic-bezier(0.16, 1, 0.3, 1), transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-sizing: border-box;
}

#auth-modal[open] {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* Custom Backdrop Blur */
#auth-modal::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  opacity: 0;
  transition: opacity 0.4s ease;
}

#auth-modal[open]::backdrop {
  opacity: 1;
}

/* Modal Inner Body & Card Content */
.auth-modal-content {
  background: rgba(22, 22, 22, 0.95);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 24px !important;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  overflow: hidden;
}

body.theme-light .auth-modal-content {
  background: #ffffff;
  border: 1px solid rgba(0, 0, 0, 0.06);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.1);
}

.auth-modal-header {
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  padding: 1.5rem 2rem !important;
}

body.theme-light .auth-modal-header {
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.auth-modal-body {
  padding: 2rem;
  overflow-y: auto;
  max-height: calc(90vh - 80px);
  box-sizing: border-box;
}

/* --- Mode Tabs --- */
.auth-tabs,
.segmented-control {
  display: flex;
  background: rgba(255, 255, 255, 0.05);
  border: none;
  border-radius: 12px;
  padding: 0.25rem;
}

body.theme-light .auth-tabs,
body.theme-light .segmented-control {
  background: rgba(0, 0, 0, 0.02);
  border: none;
}

.tab-btn {
  flex: 1;
  background: transparent;
  border: none;
  border-radius: 9px;
  padding: 0.6rem 0;
  font-family: var(--font-main);
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background 0.25s ease, color 0.25s ease;
}

.tab-btn.active {
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
  color: var(--text-primary);
}

body.theme-light .tab-btn.active {
  background: #ffffff;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  color: var(--text-primary);
}

/* --- Forms & Inputs --- */
.auth-form {
  display: none;
  flex-direction: column;
}

.auth-form.active {
  display: flex;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-label {
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-secondary);
}

.input-wrap {
  position: relative;
  width: 100%;
}

.form-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  padding: 0.8rem 1rem;
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text-primary);
  outline: none;
  transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}

body.theme-light .form-input {
  background: rgba(0, 0, 0, 0.02);
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.form-input:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 87, 51, 0.5);
  box-shadow: 0 0 0 3px rgba(255, 87, 51, 0.15);
}

body.theme-light .form-input:focus {
  background: #ffffff;
  border-color: rgba(255, 87, 51, 0.5);
}

/* --- Buttons --- */
.btn-full {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.divider {
  display: flex;
  align-items: center;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}

.divider::before,
.divider::after {
  content: '';
  flex: 1;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

body.theme-light .divider::before,
body.theme-light .divider::after {
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}

.divider:not(:empty)::before {
  margin-right: .75em;
}

.divider:not(:empty)::after {
  margin-left: .75em;
}

/* --- Alerts & Banners --- */
.demo-banner {
  background: rgba(255, 87, 51, 0.1);
  border: 1px solid rgba(255, 87, 51, 0.25);
  border-radius: 14px;
  padding: 1rem;
  font-size: 0.8rem;
  color: #ff8b72;
  line-height: 1.45;
}

body.theme-light .demo-banner {
  background: rgba(255, 87, 51, 0.08);
  border: 1px solid rgba(255, 87, 51, 0.15);
  color: #c03e22;
}

.demo-banner strong {
  font-weight: 700;
  display: block;
  margin-bottom: 0.25rem;
}

.demo-banner code {
  font-family: var(--font-mono);
  background: rgba(0, 0, 0, 0.2);
  padding: 0.1rem 0.3rem;
  border-radius: 4px;
  font-size: 0.72rem;
}

body.theme-light .demo-banner code {
  background: rgba(0, 0, 0, 0.05);
}

.status-msg {
  font-size: 0.85rem;
  line-height: 1.4;
  padding: 0.75rem 1rem;
  border-radius: 10px;
  box-sizing: border-box;
}

.status-msg.error {
  background: rgba(255, 0, 0, 0.08);
  border: 1px solid rgba(255, 0, 0, 0.15);
  color: #ff5b5b;
}

body.theme-light .status-msg.error {
  background: rgba(255, 0, 0, 0.04);
  color: #c82333;
}

.status-msg.success {
  background: rgba(40, 167, 69, 0.08);
  border: 1px solid rgba(40, 167, 69, 0.15);
  color: #28a745;
}

/* --- Spinners --- */
.spinner {
  width: 18px;
  height: 18px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #ffffff;
  animation: spin 0.8s linear infinite;
  display: none;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Profile Dashboard --- */
.profile-dashboard {
  display: none;
  flex-direction: column;
}

.profile-dashboard.active {
  display: flex;
}

.user-info-card {
  background: rgba(255, 255, 255, 0.03);
  border: none;
  border-radius: 14px;
  padding: 1.25rem;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  box-sizing: border-box;
}

body.theme-light .user-info-card {
  background: rgba(0, 0, 0, 0.02);
  border: none;
}

.user-meta-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.user-meta-label {
  font-size: 0.72rem;
  font-weight: 400;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
}

.user-meta-value {
  font-size: 0.92rem;
  font-weight: 600;
  color: var(--text-primary);
  word-break: break-all;
}

/* --- Branded Authentication Buttons (Guidelines Compliant) --- */
.btn-google,
.btn-apple {
  flex-direction: row !important;
  gap: 0.75rem !important;
  height: 48px !important;
  text-transform: none !important;
  letter-spacing: normal !important;
  font-size: 0.9rem !important;
  font-weight: 500 !important;
  border-radius: 8px !important;
  padding: 0 1.5rem !important;
}

.btn-google {
  background: #ffffff !important;
  color: #3c4043 !important;
  border: 1px solid rgba(0, 0, 0, 0.12) !important;
  transition: background-color 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease !important;
}

.btn-google:hover {
  background: #f8f9fa !important;
  border-color: #dadce0 !important;
  box-shadow: 0 1px 2px 0 rgba(60,64,67,0.3), 0 1px 3px 1px rgba(60,64,67,0.15) !important;
  gap: 0.75rem !important; /* Keep gap fixed */
}

body.theme-light .btn-google {
  border: 1px solid #dadce0 !important;
}

.btn-apple {
  background: #ffffff !important;
  color: #000000 !important;
  border: none !important;
  transition: background-color 0.25s ease, transform 0.1s ease !important;
}

.btn-apple:hover {
  background: #f2f2f2 !important;
  gap: 0.75rem !important; /* Keep gap fixed */
}

body.theme-light .btn-apple {
  background: #000000 !important;
  color: #ffffff !important;
}

body.theme-light .btn-apple:hover {
  background: #1d1d1f !important;
}

/* Constrain auth portal form contents to 480px max width and center it within the full-width card */
#view-auth .auth-modal-body {
  max-width: 480px;
  margin-left: auto;
  margin-right: auto;
  width: 100%;
}

/* Copy-to-clipboard micro-interactions & feedback styling */
#user-email-display {
  cursor: pointer;
  transition: color 0.2s ease, opacity 0.2s ease;
}

#user-email-display:hover {
  opacity: 0.8;
}

.copied-feedback {
  color: #34A853 !important; /* Green feedback color */
}

/* Match logout button corner radius to sign-in buttons & apply theme switcher background hover effects */
#btn-logout {
  border-radius: 8px !important;
  background: rgba(255, 255, 255, 0.08) !important;
  color: var(--text-primary) !important;
  border: none !important;
  transition: background 0.3s cubic-bezier(0.25, 1, 0.5, 1), color 0.3s cubic-bezier(0.25, 1, 0.5, 1) !important;
}

#btn-logout:hover {
  background: rgba(255, 255, 255, 0.14) !important;
  color: var(--text-primary) !important;
}

body.theme-light #btn-logout {
  background: rgba(0, 0, 0, 0.05) !important;
  color: var(--text-primary) !important;
}

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

/* Sidemenu Account status display styling */
#menu-btn-auth {
  display: flex;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.menu-item-status {
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Destructive Action sections & text-link button styling */
.delete-account-section,
.reset-progress-section {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.75rem;
  text-align: left;
  width: 100%;
  box-sizing: border-box;
}

body.theme-light .delete-account-section,
body.theme-light .reset-progress-section {
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.delete-warning,
.reset-warning {
  font-size: 0.72rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin: 0;
}

.btn-text-link {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  border-width: 0 !important;
  outline: none !important;
  outline-width: 0 !important;
  box-shadow: none !important;
  text-shadow: none !important;
  padding: 0 0 0.25rem 0 !important;
  margin: 0 !important;
  cursor: pointer;
  font-family: var(--font-main);
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-decoration: none;
  transition: opacity 0.2s ease, color 0.2s ease;
}

.btn-text-link:focus,
.btn-text-link:active,
.btn-text-link:hover,
.btn-text-link:focus-visible,
.btn-text-link:focus-within {
  -webkit-appearance: none !important;
  -moz-appearance: none !important;
  appearance: none !important;
  background: transparent !important;
  background-color: transparent !important;
  border: none !important;
  border-width: 0 !important;
  outline: none !important;
  outline-width: 0 !important;
  box-shadow: none !important;
  text-shadow: none !important;
}

.btn-text-link.danger-link {
  color: rgba(234, 67, 53, 0.85);
}

.btn-text-link.danger-link:hover {
  color: #ea4335;
  opacity: 0.9;
  text-decoration: underline;
}

/* --- Prevent Flash of Unauthenticated Template (FOUT) --- */
html.auth-state-logged-in .auth-tabs,
html.auth-state-logged-in .auth-form {
  display: none !important;
}

html.auth-state-logged-in .profile-dashboard {
  display: block !important;
}

html.auth-state-logged-out .profile-dashboard {
  display: none !important;
}

html.auth-state-logged-out .auth-tabs {
  display: flex !important;
}

/* Fallback hiding while script evaluates state on page load */
html:not(.auth-state-logged-in):not(.auth-state-logged-out) .auth-tabs,
html:not(.auth-state-logged-in):not(.auth-state-logged-out) .auth-form,
html:not(.auth-state-logged-in):not(.auth-state-logged-out) .profile-dashboard {
  display: none !important;
}



