:root {
    /* --- Base Colors (Dark Mode Default) --- */
    --bg-color: #1C1B1F;
    --on-bg-color: #F5F2F0; /* Light text for dark mode */
    --primary-color: #D0BCFF; /* Headings, purple */
    --primary-color-darker: #6750A4; /* For links in light mode */
    --tertiary-container-color: #633B48;
    --on-tertiary-container-color: #FFD8E4;
    --surface-variant-color: #49454F;
    --on-surface-variant-color: #F5F2F0; /* Light icons for dark mode */

    /* --- State/Component Specific Colors (Mostly mode-agnostic) --- */
    --start-bg-color: #99ff99;
    --start-text-color: #003800;
    --pause-bg-color: #ffcccc;
    --pause-text-color: #5c0000;

    /* --- Timer Specific Colors (Dark Mode Default) --- */
    --timer-display-color: #FFFFFF;
    --timer-display-running-fresh-color: var(--start-bg-color);
    --timer-display-running-low-color: var(--pause-bg-color);

    /* --- Progress Strip Specific Colors (Dark Mode Default) --- */
    --progress-strip-bg-color: var(--on-surface-variant-color);
    --progress-strip-rest-bg-color: var(--primary-color);
    --progress-strip-running-fresh-bg-color: var(--start-bg-color);
    --progress-strip-running-low-bg-color: var(--pause-bg-color);

    /* --- Link Colors --- */
    --link-color: var(--start-bg-color); /* Default green for dark mode */
    --link-hover-color: var(--primary-color);
}
body.light-mode {
    --bg-color: #F5F2F0; /* Light mode base */
    --on-bg-color: #1C1B1F; /* Dark text for light mode */
    --primary-color: #350E84; /* Darker purple for headings in light mode (WCAG AAA) */
    --tertiary-container-color: #EADDFF; /* Light purple container */
    --on-tertiary-container-color: #21005D; /* Dark text on light purple container */
    --surface-variant-color: #E7E0EC; /* Lighter surface variant */
    --on-surface-variant-color: #49454F; /* Darker icons for light mode */

    --timer-display-color: #1C1B1F; /* Dark text for timer in light mode */
    --timer-display-running-fresh-color: #00573D; /* Darker green for counter (WCAG AAA) */
    --timer-display-running-low-color: #B80000;   /* Darker red/pink for counter (WCAG AAA) */

    --progress-strip-bg-color: var(--on-surface-variant-color);
    /* Ensure progress strip running colors match updated timer display colors for light mode */
    --progress-strip-running-fresh-bg-color: #00573D;
    --progress-strip-running-low-bg-color: #B80000;

    --link-color: #00573D; /* Dark green for links (WCAG AAA on #F5F2F0 is 7.16:1) */
    --link-hover-color: #00573D; /* Dark green for link hover */
    --light-mode-start-btn-bg: #00573D;    /* Dark green for start button bg */
    --light-mode-start-btn-text: #F5F2F0;  /* Light text for start button */
    --light-mode-pause-btn-bg: #B80000;    /* Darker red for pause button bg */
    --light-mode-pause-btn-text: #F5F2F0; /* Light text for pause button */
}

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

html {
    scroll-behavior: smooth;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    overflow-x: hidden; 
    touch-action: pan-x pan-y;
   -ms-touch-action: pan-x pan-y;
  }

body {
    font-family: 'Chivo Mono', Menlo, Monaco, Consolas, 'Courier New', monospace;
    background-color: var(--bg-color);
    color: var(--on-bg-color);
    line-height: 1.5;
}

body.fullscreen-active {
    overflow: hidden;
    /* Optional: Ensure no scrollbars even if content overflows somehow */
    /* position: fixed; width: 100%; height: 100%; */
}

 
.timer-container{
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    width: 100%;
    min-height: 100vh;
    padding: 1rem;
    padding-top: 5rem;
    text-align: center;
    position: relative;
    overflow: hidden;
    font-variant-numeric: tabular-nums;
}

#logo-link {
    position: absolute;
    top: 1.5rem;
    left: 1rem;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--on-surface-variant-color);
    opacity: 0.7;
    transition: opacity 0.2s;
    z-index: 20;
    text-decoration: none; /* Remove underline from link */
    display: inline-flex; /* To align icon and text */
    align-items: center; /* Vertically align icon and text */
}
#logo-link .logo-text {
    display: inline-block; /* Needed for transform to work correctly */
    transform: rotate(90deg);
}
footer #logo-link {
    position: relative!important;
    top: auto;
    left: auto;

}
#top-buttons {
    position: absolute;
    top: 1.5rem;
    right: 1rem;
    z-index: 20;
}
#darkmode-btn,#fullscreen-btn {
    float: right;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--on-surface-variant-color);
    opacity: 0.7;
    transition: opacity 0.2s;
    z-index: 20;
}
#fullscreen-btn {
    margin-left: 1.5rem;
}
#sound-toggle-btn {
    position: absolute;
    bottom: 12%;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--on-surface-variant-color);
    opacity: 0.7;
    transition: opacity 0.2s;
    z-index: 20;
}

#sound-toggle-btn {
    right: 1rem;
}

#logo-link .material-symbols-outlined, 
#fullscreen-btn .material-symbols-outlined, 
#sound-icon,
#darkmode-btn .material-symbols-outlined {
    font-size: 2.5rem;
}

/* Styles for the new start page button */
.start-page-button {
    font-family: 'Chivo Mono', Menlo, Monaco, Consolas, 'Courier New', monospace;
    font-size: 3vw;
    font-weight: 400;
    text-transform: uppercase;
    background: transparent;
    color: #F5F2F0;           /* light text on dark bg (dark mode default) */
    border: 2px solid #F5F2F0;
    border-radius: 20px; /* Rounded corners */
    padding: clamp(1rem, 4vw, 2rem) clamp(2rem, 8vw, 4rem); /* Generous padding */
    cursor: pointer;
    opacity: 0.85;
    transition: opacity 0.15s, color 0.15s, border-color 0.15s, background-color 0.15s;
    text-decoration: none;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    width: 100%;
    max-width: 1000px;
}


.display-line, .controls-container {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.display-line {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
}

#round-display, #rest-display {
    font-size: clamp(1.5rem, 6vw, 6rem);
    font-weight: 400;
    color: var(--on-surface-variant-color);
}

.display-text-label {
    margin: 0 0.5em;
    display: none; 
}
.timer-container.is-editing .display-text-label {
    display: inline-block;
}

#round-display-value {
    width: 2ch;
    text-align: right;
}
#rest-display-value {
    width: 5ch;
    text-align: center;
}
.display-number-value {
     display: inline-block;
     /* FIX: Added margin for consistent spacing */
     margin: 0 0.5em;
}

#timer-display {
    font-size: clamp(4rem, 22vw, 22rem);
    font-weight: 400;
    line-height: 1;
    color: var(--timer-display-color);
    transition: all 0.5s ease-in-out;
}

#timer-display-value, #hours-value, #minutes-value, #seconds-value {
     width: 5ch;
     text-align: center;
     margin: 0 0.1em;
     padding:5vh 0;
     font-size: calc(16vw + 0vh);
}
@media (orientation: landscape) and (max-height: 500px) {
    #timer-display-value {
        padding: 0;         
    }
    #round-display, #rest-display {
        font-size: clamp(1.5rem, 5vw, 6rem);
    }
    .controls-container{
        padding-top:0!important;
    }
    .timer-btn {
        height: 2.7rem!important;
    }
    .controls-container {
        min-height: 3.4rem!important;
    }
}
.edit-btn {
    font-family: 'Material Symbols Outlined';
    background: none;
    color: var(--on-surface-variant-color);
    cursor: pointer;
    opacity: 0.7;
    transition: opacity 0.2s, visibility 0.2s;
    display: none; 
    width: 1.5em;
    height: 1.5em;
    border-radius: 50%;
    border: 1px solid var(--on-surface-variant-color);
    justify-content: center;
    align-items: center;
    padding: 0;
    margin: 1.5rem; 
}


.timer-container.is-editing .edit-btn {
    display: inline-flex;
    font-size: clamp(1.5rem, 5vw, 3rem);
}


#rest-display {
    display: flex; /* Always part of the layout to maintain space */
    visibility: hidden; /* Hidden by default, but still occupies space */
}

.timer-container.is-editing #rest-display {
    /* display: flex; is now the base style for #rest-display */
    visibility: visible; /* Make it visible when editing */
}

.controls-container {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 1rem;
    min-height: clamp(2rem, 10vw, 4rem);
    padding-top: 3vh;
}

.timer-btn {
    border: .2rem solid var(--bg-color);
    border-radius: 1.5rem;
    font-family: 'Chivo Mono', Menlo, Monaco, Consolas, 'Courier New', monospace;
    font-weight: 400;
    text-transform: uppercase;
    cursor: pointer;
    height: clamp(2rem, 15vw, 4rem);
    min-width: 150px;
    font-size: clamp(0.9rem, 4vw, 2rem);
    padding: 0 2rem;
    z-index: 10;
    transition: background-color 0.3s, color 0.3s, filter 0.2s; /* Added filter for hover */
}

#start-pause-btn.is-startable {
    background-color: var(--start-bg-color);
    color: var(--start-text-color);
}
#start-pause-btn.is-pausable {
    background-color: var(--pause-bg-color);
    color: var(--pause-text-color);
}
/* Light Mode Overrides for Button States */
body.light-mode #start-pause-btn.is-startable {
    background-color: var(--light-mode-start-btn-bg);
    color: var(--light-mode-start-btn-text);
}
body.light-mode #start-pause-btn.is-pausable {
    background-color: var(--light-mode-pause-btn-bg);
    color: var(--light-mode-pause-btn-text);
}
/* Revert reset button colors for light mode */
body.light-mode #reset-btn {
    background-color: var(--on-tertiary-container-color); /* Darker purple background */
    color: var(--tertiary-container-color); /* Lighter purple text */
}
#reset-btn {
    background-color: var(--tertiary-container-color);
    color: var(--on-tertiary-container-color);
    display: none;
}
span#round-display-value {
    text-transform: uppercase;
}
#progress-strip {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 5vh;
    width: 100%;
    background-color: var(--progress-strip-bg-color);
    transition: width 1s linear, background-color 0.5s ease-in-out; 
}

.rest #progress-strip {
    background-color: var(--progress-strip-rest-bg-color);
}

#timer-display.is-running-fresh { color: var(--timer-display-running-fresh-color); }
#timer-display.is-running-low  { color: var(--timer-display-running-low-color); }
#progress-strip.is-running-fresh { background-color: var(--progress-strip-running-fresh-bg-color); }
#progress-strip.is-running-low { background-color: var(--progress-strip-running-low-bg-color); }

.content-below-fold {
    max-width: 720px;
    margin: 4rem auto;
    padding: 2rem;
    text-align: left;
}
.content-below-fold h1 { font-size: 3.5rem; color: var(--primary-color); margin-bottom: 1.5rem; }
.content-below-fold h2 { font-size: 2.5rem; color: var(--primary-color); margin-bottom: 1rem; }
.content-below-fold h3 { font-size: 1.8rem; color: var(--primary-color); margin-top: 2.5rem; margin-bottom: 1rem; }
.content-below-fold p, .content-below-fold li { font-size: 1.1rem; color: var(--on-bg-color); margin-bottom: 1rem; }
.content-below-fold li { font-size: 1.5rem; }
.content-below-fold ul { padding: 1.5rem 0 1rem 2rem; }







/* Light Mode: Paused/Rest uses --pause-text-color (#5c0000) */
body.light-mode .timer-container.is-paused #timer-display,
body.light-mode.rest #timer-display,
body.light-mode .timer-container.is-paused #round-display,
body.light-mode .timer-container.is-paused #rest-display,
body.light-mode.rest #round-display,
body.light-mode.rest #rest-display {
    color: var(--on-tertiary-container-color) !important; /* Dark Purple for Light Mode Pause/Rest Text */
}
body.light-mode .timer-container.is-paused #progress-strip,
body.light-mode.rest #progress-strip {
    background-color: var(--on-tertiary-container-color) !important; /* Dark Purple for Light Mode Pause/Rest Progress Bar */
}
/* Ensure #round-display-value (BREAK text) keeps standard font color in light mode during pause/rest */
body.light-mode .timer-container.is-paused #round-display-value,
body.light-mode.rest #round-display-value {
    color: var(--on-bg-color) !important; /* Standard light mode text color */
}

/* Dark Mode (default): Paused/Rest uses --tertiary-container-color (#633B48) */
body:not(.light-mode) .timer-container.is-paused #timer-display-value,
body:not(.light-mode).rest #timer-display-value,
body:not(.light-mode) .timer-container.is-paused #round-display,
body:not(.light-mode) .timer-container.is-paused #rest-display,
body:not(.light-mode).rest #round-display,
body:not(.light-mode).rest #rest-display,
.timer-container.is-paused .display-number-value {
    color: var(--primary-color) !important; /* Purple for Dark Mode Pause/Rest Text */
}
body:not(.light-mode) .timer-container.is-paused #progress-strip,
body:not(.light-mode).rest #progress-strip {
    background-color: var(--primary-color) !important; /* Purple for Dark Mode Pause/Rest Progress Bar */
}
/* Ensure #round-display-value (BREAK text) keeps standard font color in dark mode during pause/rest */
body:not(.light-mode) .timer-container.is-paused #round-display-value,
body:not(.light-mode).rest #round-display-value {
    color: var(--on-bg-color) !important; /* Standard dark mode text color */
}
/* --- End Paused and Rest State Colors --- */

/* === Force fresh (green) color when timer is running === */
body:not(.light-mode) .timer-container.is-running #timer-display-value,
body:not(.light-mode) .timer-container.is-running .display-number-value {
    color: var(--timer-display-running-fresh-color) !important;
}

body.light-mode .timer-container.is-running #timer-display-value,
body.light-mode .timer-container.is-running .display-number-value {
    color: var(--timer-display-running-fresh-color) !important;
}

/* Progress strip greens */
body:not(.light-mode) .timer-container.is-running #progress-strip {
    background-color: var(--progress-strip-running-fresh-bg-color) !important;
}
body.light-mode .timer-container.is-running #progress-strip {
    background-color: var(--progress-strip-running-fresh-bg-color) !important;
}

/* Hover effects for desktop devices */
@media (hover: hover) {
    #start-pause-btn.is-startable:hover {
        filter: brightness(90%);
    }
    #start-pause-btn.is-pausable:hover {
        filter: brightness(90%);
    }
    #reset-btn:hover {
        filter: brightness(110%); /* Lighten reset button as it's darker */
    }
}
.timer-display-active {
    font-size: clamp(4rem, 30vw, 22rem) !important;
    margin-bottom: -4.5rem !important;
}

/* Light mode base: dark text on light bg — applies on ALL devices including iOS */
body.light-mode .start-page-button {
    color: #1C1B1F;
    border-color: #1C1B1F;
}

/* Hover effects only on devices that support hover and have a fine pointer */
@media (hover: hover) and (pointer: fine) {
    #logo-link:hover,
    #fullscreen-btn:hover,
    #sound-toggle-btn:hover,
    #darkmode-btn:hover {
        opacity: 1;
    }
    /* Dark mode hover: fill light, dark text */
    .start-page-button:hover {
        opacity: 1;
        background-color: #F5F2F0;
        color: #1C1B1F;
        border-color: #F5F2F0;
    }
    /* Light mode hover: fill dark, light text */
    body.light-mode .start-page-button:hover {
        background-color: #1C1B1F;
        color: #F5F2F0;
        border-color: #1C1B1F;
    }
    .edit-btn:hover {
        opacity: 1;
    }
    /* Link colour in long-form content matches START button */
.content-below-fold a{
    color: var(--link-color);
}
    .content-below-fold a:hover {
        color: var(--link-hover-color);
        text-decoration: none;
        text-decoration-color: var(--link-hover-color);
    }
}
/* ==== FOOTER ==== */
.site-footer{
    background: var(--md-sys-color-surface-container-low,#1F1B24);
    color: var(--md-sys-color-on-surface,#E6E1E5);
    margin-top: 4rem;
    font-size:.875rem;
  }
  
  body.light-mode .site-footer{
    background: var(--md-sys-color-surface,#FFF);
    color: var(--md-sys-color-on-surface,#1C1B1F);
  }
  
  .site-footer a{color:inherit;text-decoration:none}
  .site-footer a:hover{text-decoration:underline}
  
  .footer-inner{
    display:flex;
    flex-wrap:wrap;
    gap:2rem;
    padding:2rem clamp(1rem,4vw,3rem);
    justify-content:space-between;
  }
  
  .footer-column{min-width:160px}
  .footer-column h2{font-size:.8rem;font-weight:700;letter-spacing:.1em;text-transform:uppercase;margin:0 0 1rem;opacity:.6}
  .footer-column ul{list-style:none;margin:0;padding:0}
  
  .footer-bottom{
    border-top:1px solid var(--md-sys-color-outline-variant,#444);
    text-align:center;
    padding:1.25rem 1rem 1.5rem;
  }
  body.light-mode .footer-bottom{
    border-color:var(--md-sys-color-outline-variant,#CCC);
  }

  .footer-legal-links{
    display:flex;
    flex-wrap:wrap;
    justify-content:center;
    align-items:center;
    gap:.25rem .5rem;
    margin-bottom:.6rem;
    font-size:.875rem;
  }
  .footer-legal-links a{opacity:.85}
  .footer-legal-links a:hover{opacity:1;text-decoration:underline}
  .footer-dot{opacity:.4;font-size:1.1rem;line-height:1}
  .footer-copyright{margin:.4rem 0 .2rem;font-size:.875rem}
  .footer-legal-note{margin:0;font-size:.75rem;opacity:.6}
  .footer-legal-note a{text-decoration:underline;opacity:1}