/* styles.css -- MyBest24 app */

:root {
    --bg-main: #0a0a0a;       /* dark mode default */
    --bg-panel: #121212;      /* popup bg color */
    --box-border: #333333;
    --accent-color: #46a5ce;
    --accent-glow: rgba(70, 165, 206, 0.4);
    --text-main: #ffffff;
    --text-muted: #999999;
    --icon-size: 64px;
    --icon-size-past-or-future: 58px;
    --icon-size-slices-grid-cols-1: 80px;
    --icon-size-slices-grid-cols-2: 64px;
    --icon-size-slices-grid-cols-3: 48px;
    --icon-accent-filter: sepia(1) hue-rotate(170deg) saturate(320%) brightness(0.90);
}

html, body {
    width: 100%;
    overflow-x: hidden;
    overflow-y: auto; /* vertical scroll container */
    height: 100%; /* new, nearest scroll container for sticky context */
}

/* safari start */
html {
    -webkit-text-size-adjust: 100%;
}

body {
    -webkit-text-size-adjust: 100%;
}
/* safari end */

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    margin: 0;
    min-height: 100vh; 
    display: flex;
    flex-direction: column;
    font-family: 'Outfit', sans-serif;
    /*font-family: 'IBM Plex Sans', system-ui, sans-serif;*/
}

button, input, select {
  font-family: inherit;
}


/* --- PRIMARY ACTION BUTTONS --- */
.btn-primary {
    background-color: var(--accent-color);
    color: white;
    border: none;
    padding: 12px 32px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    min-width: 160px;
    transition: transform 0.1s, filter 0.2s;
    white-space: nowrap;
}

.btn-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

/* -------- HEADER ------------*/

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 40px;
    border-bottom: 1px solid var(--box-border); /* Subtle separation */
    background-color: var(--bg-main);
    position: sticky;
    top: 0;
    z-index: 100;
}

/* Ensure the center section is truly centered */
.header-section {
    flex: 1;
    display: flex;
}

.header-section.center {
    justify-content: center;
}

.header-section.right {
    justify-content: flex-end;
}

/* Branding Styles */
.brand-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    user-select: none;
    cursor: pointer; /* Shows it's clickable */
}

.logo-text {
    color: #ffffff; /* Sets "Day" to white */
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.text-accent {
    color: var(--accent-color); /* Updating branding blue */
}

/* Buttons */
/* header-section left button */
.action-button {
    background: #2a2a2a;
    color: var(--accent-color);
    border: 1px solid #444;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
}

.action-button:hover {
    background: #333;
    border-color: var(--accent-color);
    box-shadow: 0 0 10px var(--accent-glow);
}

#manage-day-button {
    font-size:1.5rem;
    padding:0 6px;
}

/* --- COUNTDOWN COLUMN 3 ----- */
.sleep-container {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 8px;
}

#sleep-text-display {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* START MINI-GRID HOURS UNTIL SLEEP LAYOUT (Desktop First: 6 across) */
.mini-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr); 
    gap: 4px;
}

.mini-sleep-box {
    width: 8px;
    height: 8px;
    background-color: var(--accent-color);
}
/* END MINI-GRID HOURS UNTIL SLEEP */

/* start INFO BAR area */
/* tells user 24 boxes = 24 hours */

.info-bar, #app-info-modal h2, #app-wizard-modal h2 {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    padding: 14px 0;
    background: rgba(255, 255, 255, 0.03);
    border-bottom: 1px solid #222;
    font-size: 1.1rem; /* Bold, readable desktop size */
    letter-spacing: 1px;
    color: #999;
    text-transform: uppercase;
}

.info-bar .text-accent {
    color: var(--accent-color);
    font-weight: bold;
}

.info-divider {
    color: #333;
}

/* end INFO BAR area */

/* Main Grid Area */
.workspace {
    flex: 1; 
    display: flex;
    justify-content: center;
    align-items: flex-start; /* scrolls from the top */
    padding: 0 20px;
    width: 100%;
    box-sizing: border-box;
}

.allocation-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr); 
    gap: 16px;
    width: 100%;
    max-width: 1000px;
    margin: 40px auto; /* Centered with breathing room */
}

/* HOURS STYLING ON MAIN GRID BOXES */
/* handle PNGs */
.hour-block {
    position: relative; /* Ensure children can be pinned to corners */
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100px; 
    padding: 20px 10px;
    filter: brightness(0.7); /* This is now the "Future" default */
    overflow: hidden;
}

.progress-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 3px;
    width: 0%;
    background: var(--accent-color); /* progress bar fill color */
}

.time-label {
    position: absolute;
    top: 8px;
    left: 8px;
    font-size: 0.75rem;
    opacity: 0.6;
}

.category-label {
    position: absolute;
    top: 8px;
    right: 8px;
    font-size: 0.75rem;
    opacity: 0.6;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* 1. Set the default size for ALL icons (Past and Future) */
.slot-icon {
    width: var(--icon-size-past-or-future);
    height: var(--icon-size-past-or-future);
    image-rendering: pixelated;
    object-fit: contain;
    transition: width 0.2s, height 0.2s; /* Smooth transition when hour changes */
    transform: translateY(5px); /*move down a bit */
    filter: var(--icon-accent-filter);
}

/* 2. Override the size ONLY for the current hour icon */
.status-current .slot-icon {
    width: var(--icon-size);
    height: var(--icon-size);
}

/* Animated Class - No duplication of size! */
.animated {
    background-size: auto 100% !important;
    background-repeat: no-repeat;
    image-rendering: pixelated;
    filter: var(--icon-accent-filter);
    display: block;
    margin: 0 auto;
}

.sprite-animation {
    background-size: auto 100%; /* Height is 100%, width scales based on frames */
    image-rendering: pixelated; /* Keeps the 16x16 assets sharp at 48x48 */
    display: block;
    margin: 0 auto;
}

@keyframes play-sprite {
    from { background-position: 0px; }
    to { background-position: -100%; } /* This is adjusted dynamically via JS */
}
/* end Sprite Animation logic */


/* meal badge */
.secondary-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    filter: var(--icon-accent-filter);
}
/* end meal badge */

/* Slice grid badge — sits just below the time label, top-left */
.slice-badge {
    position: absolute;
    top: 22px;
    left: 8px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 2px;
    padding: 2px;
}

/* workspace version */
.hour-block .slice-badge { width: 20px; }

/* modal version */
.modal-header .slice-badge { width: 32px; }

.slice-badge-cell {
    height: 3px;
    border-radius: 1px;
    background: var(--text-muted);
    opacity: 0.5;
}

.status-current .slice-badge-cell {
    background: var(--accent-color);
    opacity: 1;
}

.modal-header .slice-badge {
    position: static;
    margin-top: 3px;
}

/* end slice badge code */

/* Highlight the current hour professionally */
.status-current {
    filter: brightness(1.0);
    border: 2px solid var(--accent-color);
    box-shadow: 0 0 15px var(--accent-glow);
    transform: scale(1.05);
    z-index: 5;
}

/* Make label brighter for the current hour */
.status-current .time-label {
    color: rgba(255, 255, 255, 0.9);
}

.status-past {
    filter: grayscale(1) brightness(0.3);
}

/* clear all button */
/* bottom of page */
.warning-link {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.3);
    font-size: 0.8rem;
    cursor: pointer;
    text-decoration: underline;
    transition: color 0.2s;
}

.warning-link:hover {
    color: #ff4444;
}

.clear-link {
    position: fixed;
    bottom: 20px;
    left: 20px;
}

/* START MODAL POP-UP CSS */

.hidden, .modal-hidden { 
    display: none !important; 
}

/* Unified Modal Overlay */
.modal-overlay,
#anchor-modal,
#box-modal,
#app-info-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 20px 0;
    z-index: 1000;
}

/* Wizard modal - SCROLLING FIX */
#app-wizard-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(8px);
    display: flex; /* Change from block to flex like info modal */
    align-items: flex-start; /* Not center, so it can scroll */
    justify-content: center;
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 9999;
    -webkit-overflow-scrolling: touch;
    padding: 20px 0; /* Add padding for scroll breathing room */
}

/* Remove the margin override, let it inherit from .modal-content-info */
#app-wizard-modal .modal-content {
    width: 500px; /* Match info modal width */
    max-width: 95vw;
    margin: auto 0; /* Vertical auto centering within flex */
}

/* Base Modal Container */
.modal-content,
.modal-content-info {
    background: var(--bg-panel);
    border: 1px solid var(--box-border);
    border-radius: 12px;
    box-shadow: 0 10px 50px rgba(0,0,0,0.8);
    display: flex;
    flex-direction: column;
    margin: auto;
}

/* box modal and anchor modal */
.modal-content-narrow {
    width: 90%; 
    max-width: 450px;
}

/* Modal Header */
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem 0 2rem;
}

.modal-header h3 {
    font-size: 1.5rem;
    margin: 0;
    color: var(--text-main);
}

#app-wizard-modal h4 {
    font-size: 1.2rem;
    color: #aaa;
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 500;
}

.close-button {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 2rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    width: 30px;
    height: 30px;
}

.close-button:hover {
    color: var(--text-main);
}

/* ── BOX MODAL: VIEW TOGGLE ─────────────────────────────────────────────── */
.box-view-toggle {
    display: flex;
    gap: 3px;
    align-items: center;
    margin-left: 10px;
}

.box-view-btn {
    background: #1a1a1a;
    border: 1px solid var(--box-border);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 0.65rem;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 3px 7px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.box-view-btn:hover { color: var(--text-main); border-color: var(--accent-color); }
.box-view-btn.active { color: var(--accent-color); border-color: var(--accent-color); }
/* ── END BOX MODAL: VIEW TOGGLE ─────────────────────────────────────────── */
/* end modal header */

/* Modal Body */
.modal-body {
    padding: 1rem 2rem 2rem 2rem;
}

/* Anchor Saved Notification */
.anchor-saved-notice {
    color: var(--accent-color);
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
    opacity: 0;
    transition: opacity 0.3s;
    min-height: 1.2rem;
    display: block;
    text-align: center;
}

/* Anchor Rows */
.anchor-row {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 1rem;
}

.anchor-label {
    min-width: 70px;
    font-size: 0.95rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.7);
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom:15px /* adjust up a bit to align w/ input selectors */
}

.input-subgroup span { margin-bottom: 15px; } /* adjust the word 'to' up between start time and end time selector inputs */

/* Anchor icons inline with labels */
.anchor-icon {
    width: 20px;
    height: 20px;
    image-rendering: pixelated;
}

.input-subgroup {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 1rem;
    flex: 1;
}

.input-subgroup select {
    font-size: 1rem;
    padding: 8px;
    background: #1a1a1a;
    color: white;
    border: 1px solid var(--box-border);
    border-radius: 4px;
    outline: none;
    flex: 1;
    min-width: 50px; /* make am/pm a bit wider */

}

.input-subgroup select:focus {
    border-color: var(--accent-color);
}

.input-subgroup span {
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.85rem;
}

/* Remove Anchor Button */
.remove-anchor {
    background: transparent;
    border: 1px solid #ff4444;
    color: #ff4444;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.8rem;
    line-height: 1;
    padding: 0;
    flex-shrink: 0;
    opacity: 0.6;
    margin-bottom: 15px; /* move up a bit from the bottom of the row */
}

.remove-anchor:hover {
    background: #ff4444;
    color: white;
}

/* Add Anchor Controls */
.add-anchor-controls {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px dashed var(--box-border);
}

#anchor-selector {
    width: 100%;
    background: #1a1a1a;
    border: 1px solid var(--box-border);
    color: var(--text-main);
    border-radius: 6px;
    padding: 8px;
    margin-bottom: 0.5rem;
    outline: none;
    max-height: 10rem;
}

#anchor-selector option {
    padding: 6px;
}

#anchor-selector:focus {
    border-color: var(--accent-color);
}

#anchor-selector-container {
    margin-top: 0.5rem;
}

#show-anchor-selector {
    margin-bottom: 0;
}

#additional-anchors .anchor-row {
    margin-top: 1rem;
}

/* Box Modal - Icon Display */
.box-icon-display {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

#box-icon {
    --icon-size: 100px;
    width: var(--icon-size);
    height: var(--icon-size);
    image-rendering: pixelated;
}

/* #box-icon.animated {
    background-size: auto var(--icon-size);
    background-repeat: no-repeat;
}*/

/* Form Groups */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-bottom: 1.5rem;
}

.form-group label {
    font-size: 0.95rem;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.6);
}

.form-group select {
    width: 100%;
    box-sizing: border-box;
    font-size: 1.1rem;
    padding: 8px 12px;
    background: #1a1a1a;
    border: 1px solid var(--box-border);
    color: var(--text-main);
    border-radius: 6px;
    outline: none;
}

.form-group select:focus {
    border-color: var(--accent-color);
}

/* Modal Actions (Buttons) */
.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 1rem;
}

/* anchor modal buttons */

.btn-primary {
    background-color: var(--accent-color);
    border: none;
    color: white;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.btn-secondary {
    white-space: nowrap;  /* Forces text to stay on one line */
    width: 100%;
    background: transparent;
    border: 1px solid var(--box-border);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: color 0.2s;
}

.btn-secondary:hover {
    background: #333;
}

.modal-body .button-row, 
.modal-body .centered-container {
    display: flex;
    justify-content: center;
    width: 100%;
    /*margin-top: 15px;*/
}

/* anchor modal -- two buttons in a row */
.button-row {
    display: flex;
    gap: 12px;
    justify-content: center;
    width: 100%;
}

/* Ensure hidden works on flex containers */
.button-row.hidden {
    display: none !important;
}



/* Never show the remove button for the Sleep row */
#anchor-row-sleep .remove-anchor { display: none !important; }

/* Keep the selector container hidden by default */
#anchor-selector-container.hidden { display: none; }

/* -- END ANCHOR MODAL -- */


/* --- APP INFO MODAL & WIZARD MODAL (SHARED BRANDING) --- */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95); /* Nearly solid black for focus */
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999; /* Ensure it sits on top of everything */
}

.modal-content-info {
    width: 500px;
    max-width: 95vw;
}

/* Center Branding in Header - SHARED by both info modal and wizard */
#app-info-modal .modal-header,
#app-wizard-modal .modal-header {
    position: relative;
    display: flex;
    justify-content: center; 
    padding: 2.5rem 2rem 0.5rem;
}

/* Correct class from your HTML - SHARED */
#app-info-modal .brand-logo-centered,
#app-wizard-modal .brand-logo-centered {
    display: flex;
    flex-direction: row; 
    align-items: center; 
    justify-content: center;
    gap: 12px;
    cursor: default;
}

/* Wizard gets smaller logo */
#app-info-modal .logo-icon { 
    height: 48px;
    width: auto;
    display: block;
    flex-shrink: 0;
}

#app-wizard-modal .logo-icon { 
    height: 32px;
    width: auto;
    display: block;
    flex-shrink: 0;
}

/* Wizard gets smaller app name text */
#app-info-modal h1.logo-text { 
    font-size: 2.5rem; 
    margin: 0;
    line-height: 1;
    display: block; 
    white-space: nowrap;
}

#app-wizard-modal h1.logo-text { 
    font-size: 1.8rem; 
    margin: 0;
    line-height: 1;
    display: block; 
    white-space: nowrap;
}

/* Pin Close Button to Corner */
#app-info-modal .close-button {
    position: absolute;
    top: 10px;
    right: 10px;
}

/* Wizard tagline - smaller size and tighter spacing */
#app-wizard-modal h2 { 
    display: block;
    gap: 0;
    font-size: 0.9rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #999;
    text-align: center;
    margin: -1rem 0 1rem;
    line-height: 1.4;
}


#app-info-modal h3 { 
    font-size: 1.5rem; 
    color: var(--accent-color); 
    margin: 1.5rem 0 0.8rem; /* Adjusted margin for better spacing */
    line-height: 1.0; 
    text-align: left; 
}

/* click the anchor text to open anchor modal */
.clickable-link { 
    color: var(--accent-color); 
    text-decoration: none; /* No underline */
}

/* Optional: Make the blue word slightly brighter when hovering anywhere on the line */
#trigger-anchor-modal:hover .clickable-link {
    filter: brightness(1.2);
}

/* List & Body Text */
#app-info-modal p, 
#app-info-modal ul { 
    color: rgba(255, 255, 255, 0.85); 
    line-height: 1.6; 
    text-align: left;
}

#app-info-modal ul li { 
    font-size: 1.1rem; 
    margin-bottom: 0.8rem; 
}

#app-info-modal strong { 
    color: var(--accent-color); 
}

/* Footer Distinction */
#app-info-modal .modal-footer-note {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--box-border);
    font-size: 1rem;
    opacity: 0.6;
}

#app-info-modal ul {
    margin-top: 0;        /* Remove top gap from list */
}

.info-modal-footer {
    display: flex;
    justify-content: center;
    padding: 1rem 0 0.5rem;
    margin-top: auto;
    border-top: 1px solid var(--box-border);
}

/* END MODAL POP-UP CSS */

/* WIZARD CODE */

#app-wizard-modal h3 {
    font-size: 2rem;
    color: #aaa;
    margin-bottom: 1rem;
    text-align: center;
    font-weight: 500;
}

/* Wizard icons inline with titles */
.wizard-icon {
    width: 32px;
    height: 32px;
    image-rendering: pixelated;
    vertical-align: middle;
    margin-right: 8px;
    margin-bottom: 10px;
}

.wizard-label {
    display: block;
    font-size: 1.5rem;
    color: #aaa;
    margin-bottom: 5px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    text-align: center;
}

.wizard-content {
    text-align: center;
}

.wizard-nav {
    display: flex;
    justify-content: space-between; /* Puts Back on left, Next on right */
    gap: 12px;
    align-items: center;
    padding: 20px 30px;
    margin-top: auto; 
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

/* If ONLY the "Start My Journey" button exists, center it */
.wizard-nav:has(> :only-child) {
    justify-content: center;
}

/* WIZARD BUTTON STYLES - FIX */
.btn-wizard-primary {
    background-color: var(--accent-color);
    border: none;
    color: white;
    padding: 12px 32px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    min-width: 160px;
    transition: transform 0.1s, filter 0.2s;
    white-space: nowrap;
    font-size: 1rem;
}

.btn-wizard-primary:hover {
    filter: brightness(1.1);
    transform: translateY(-1px);
}

.btn-wizard-secondary {
    background: transparent;
    border: 1px solid var(--box-border);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    min-width: 100px;
    transition: background 0.2s;
    white-space: nowrap;
    font-size: 1rem;
}

.btn-wizard-secondary:hover {
    background: #333;
}

/* Wizard Progress Dots */
.dots-container {
    display: flex;
    gap: 10px;
    justify-content: center;
    padding: 20px 0;
}

.dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    border: 2px solid #555; 
    transition: all 0.3s ease;
    box-sizing: border-box;
}

/* Blue filled for completed */
.dot.completed {
    background-color: var(--accent-color);
    border-color: var(--accent-color);
}

/* White-ish border for current */
.dot.current {
    border-color: #9dc6d8;
    /* This adds a glow/halo effect without increasing size */
    box-shadow: 0 0 0 2px rgba(157, 198, 216, 0.4); 
}

/* If it is BOTH completed and current, keep it blue but show the border */
.dot.completed.current {
    background-color: var(--accent-color);
    border-color: #ffffff; /* Bright white to pop against blue */
}

.dot.skipped {
    background-color: #333;
    border-color: #555;
}

/* Dark Mode Time Inputs */
.dark-time-input {
    background: #222;
    color: white;
    border: 1px solid #444;
    padding: 10px;
    border-radius: 6px;
    font-size: 1.2rem;
    width: 100%;
    max-width: 100px;
    margin: 0 auto 15px auto;  /* Center it */
}

.review-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* 2 columns for desktop */
    gap: 10px;
    margin-top: 20px;
    text-align: left;
}

.review-item {
    background: #2a2a2a;
    padding: 10px;
    border-radius: 8px;
    border: 1px solid #444;
    display: flex;
    justify-content: space-between;
}

.text-muted {
    color: #777;
    font-style: italic;
}
/* END WIZARD CODE */


/* ── COLOR PICKER ───────────────────────────────────────────────────────────── */

/* Grayscale theme — one rule, affects the whole page */
body.theme-grayscale {
    filter: grayscale(1);
}

/* Toggles */
.cp-toggles {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 4px;
}

.cp-toggle-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    user-select: none;
}

.cp-toggle-label {
    font-size: 0.8rem;
    color: #aaa;
    letter-spacing: 0.3px;
}

/* Track */
.cp-toggle-track {
    position: relative;
    width: 36px;
    height: 20px;
    border-radius: 10px;
    background: #333;
    border: 1px solid #444;
    transition: background 0.2s, border-color 0.2s;
    flex-shrink: 0;
    cursor: pointer;
    outline: none;
}

.cp-toggle-track:focus-visible {
    box-shadow: 0 0 0 2px var(--accent-color);
}

.cp-toggle-track.cp-toggle-on {
    background: var(--accent-color);
    border-color: var(--accent-color);
}

/* Thumb */
.cp-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #777;
    transition: transform 0.2s, background 0.2s;
    pointer-events: none;
}

.cp-toggle-on .cp-toggle-thumb {
    transform: translateX(16px);
    background: #fff;
}

.cp-divider {
    height: 1px;
    background: #222;
    margin: 4px 0 8px;
}

/* Dim sliders when color effects are off */
.cp-slider-dim {
    opacity: 0.35;
    pointer-events: none;
}

.cp-label-dim {
    opacity: 0.35;
}

/* Toggles */
.color-pick-trigger {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.25);
    font-size: 0.75rem;
    cursor: pointer;
    letter-spacing: 0.5px;
    padding: 4px 6px;
    transition: color 0.2s;
    z-index: 200;
    font-family: inherit;
}

.color-pick-trigger:hover {
    color: var(--accent-color);
}

/* Panel */
.color-pick-panel {
    position: fixed;
    bottom: 50px;
    right: 20px;
    width: 300px;
    background: var(--bg-panel);
    border: 1px solid #333;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.04);
    z-index: 500;
    overflow: hidden;
    animation: cp-fade-in 0.15s ease;
}

.color-pick-hidden {
    display: none !important;
}

@keyframes cp-fade-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* Header */
.color-pick-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 16px 10px;
    border-bottom: 1px solid #222;
}

.color-pick-title {
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #888;
}

.color-pick-close {
    background: none;
    border: none;
    color: #666;
    font-size: 1.4rem;
    cursor: pointer;
    line-height: 1;
    padding: 0 2px;
    transition: color 0.15s;
    font-family: inherit;
}

.color-pick-close:hover {
    color: #fff;
}

/* Body */
.color-pick-body {
    padding: 16px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.color-pick-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #666;
    margin-bottom: 2px;
}

/* Slider wrapper — the track gradient lives here */
.color-pick-slider-wrap {
    position: relative;
    border-radius: 8px;
    overflow: hidden; /* clips the gradient bg to rounded corners */
    height: 28px;
}

/* Hue track: full rainbow */
.hue-wrap {
    background: linear-gradient(
        to right,
        hsl(0,   80%, 57%),
        hsl(30,  80%, 57%),
        hsl(60,  80%, 57%),
        hsl(90,  80%, 57%),
        hsl(120, 80%, 57%),
        hsl(150, 80%, 57%),
        hsl(180, 80%, 57%),
        hsl(210, 80%, 57%),
        hsl(240, 80%, 57%),
        hsl(270, 80%, 57%),
        hsl(300, 80%, 57%),
        hsl(330, 80%, 57%),
        hsl(359, 80%, 57%)
    );
}

/* Brightness track: white (left) → vivid hue color (right) */
.lit-wrap {
    --lit-vivid-color: hsl(200, 70%, 38%);
    background: linear-gradient(to right, #ffffff, var(--lit-vivid-color));
}

/* Base slider — invisible track, styled thumb */
.cp-slider {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 28px;
    background: transparent; /* track is on the wrapper */
    margin: 0;
    padding: 0;
    cursor: pointer;
    display: block;
    position: relative;
    z-index: 1;
}

.cp-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 28px;
    border-radius: 4px;
    background: var(--thumb-color, var(--accent-color));
    border: 2px solid rgba(255,255,255,0.85);
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    cursor: grab;
    transition: border-color 0.1s, box-shadow 0.1s;
}

.cp-slider::-webkit-slider-thumb:active {
    cursor: grabbing;
    border-color: #fff;
    box-shadow: 0 0 0 3px rgba(255,255,255,0.2);
}

.cp-slider::-moz-range-thumb {
    width: 20px;
    height: 24px;
    border-radius: 4px;
    background: var(--thumb-color, var(--accent-color));
    border: 2px solid rgba(255,255,255,0.85);
    box-shadow: 0 2px 8px rgba(0,0,0,0.5);
    cursor: grab;
}

/* Preview swatch */
.cp-preview {
    height: 10px;
    border-radius: 6px;
    margin-top: 4px;
    transition: background-color 0.08s;
}

/* Footer */
.color-pick-footer {
    padding: 8px 16px 14px;
    text-align: center;
    border-top: 1px solid #1a1a1a;
}

.cp-reset-link {
    background: none;
    border: none;
    color: #555;
    font-size: 0.72rem;
    cursor: pointer;
    text-decoration: underline;
    letter-spacing: 0.3px;
    padding: 0;
    font-family: inherit;
    transition: color 0.2s;
}

.cp-reset-link:hover {
    color: #aaa;
}

/* ── END COLOR PICKER ────────────────────────────────────────────────────────── */


/* ── SLICES FEATURE ──────────────────────────────────────────────────────────── */

.slices-featured-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 0;
    color: var(--text-muted);
    font-size: 0.8rem;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* Section container */

.slices-section {
    margin: 0 0 1.5rem 0;
    padding-top: 1rem;
    /*border-top: 1px solid var(--box-border);*/
}

/* Ghost */
.ghost-thumb {
    display: grid;
    gap: 3px;
    padding: 4px;
    width: 48px;
    height: 16px;
    border: 1px dashed var(--box-border);
    border-radius: 4px;
    opacity: 0.25;
    cursor: pointer;
    transition: opacity 0.15s, border-color 0.15s;
    box-sizing: border-box;
}
.ghost-thumb:hover { opacity: 0.6; }
.ghost-thumb.active {
    opacity: 1;
    border-color: var(--accent-color);
    border-style: solid;
}

.ghost-1col { grid-template-columns: 1fr; }
.ghost-2col { grid-template-columns: 1fr 1fr; }
.ghost-3col { grid-template-columns: 1fr 1fr 1fr; }

.ghost-cell {
    background: var(--text-muted);
    border-radius: 1px;
}

.ghost-thumb.active .ghost-cell {
    background: var(--accent-color);
}

/* ---- + Slice button — muted, same weight as ADD MEAL ---- */
.slices-add-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-family: inherit;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    cursor: pointer;
    padding: 2px 6px;
    transition: color 0.2s;
    white-space: nowrap;
}
.slices-add-btn:hover { color: var(--text-main); }

/* ---- Active slices control bar ---- */
.slices-control-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

/* Count strip: 0 2 3 4 ... 12 */
.slices-count-strip {
    display: flex;
    gap: 3px;
    flex-wrap: wrap;
}

.count-btn {
    min-width: 22px;
    height: 22px;
    padding: 0 4px;
    background: #1a1a1a;
    border: 1px solid var(--box-border);
    border-radius: 4px;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-family: inherit;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s;
}
.count-btn:hover { color: var(--text-main); border-color: var(--accent-color); }
.count-btn.active { color: var(--accent-color); border-color: var(--accent-color); }

/* ---- Slice cards grid ---- */
.slices-grid {
    display: grid;
    gap: 6px;
}
.slices-grid-cols-1 { grid-template-columns: 1fr; }
.slices-grid-cols-2 { grid-template-columns: 1fr 1fr; }
.slices-grid-cols-3 { grid-template-columns: 1fr 1fr 1fr; }

.slice-card {
    background: #1a1a1a;
    border: 1px solid var(--box-border);
    border-radius: 6px;
    padding: 6px 8px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-height: 40px;
    transition: border-color 0.15s, background 0.15s;
}
.slice-card:hover { border-color: var(--accent-color); background: #222; }

.slice-time {
    font-size: 0.65rem;
    color: var(--text-muted);
    font-variant-numeric: tabular-nums;
}

.slice-name {
    font-size: 0.8rem;
    color: var(--text-main);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---- Workspace grid — slice underline indicator ----
   data-slices set by app.js. CSS only, no extra DOM. */
.category-label[data-slices] {
    text-decoration-line: underline;
    text-decoration-style: dashed;
    text-decoration-color: var(--accent-color);
    text-underline-offset: 3px;
    text-decoration-skip-ink: none;
}
.category-label[data-slices="2"] { letter-spacing: 0.05em; }
.category-label[data-slices="3"] { letter-spacing: 0.08em; }
.category-label[data-slices="4"] { letter-spacing: 0.12em; }

/* ---- Slice edit modal ---- */
.slice-edit-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 20px 0;
    z-index: 2000; /* above box-modal (1000) */
}

.slice-edit-modal-content {
    background: var(--bg-panel);
    border: 1px solid var(--box-border);
    border-radius: 12px;
    box-shadow: 0 10px 50px rgba(0,0,0,0.8);
    width: 90%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    margin: auto;
}

/* Reuse .form-group select styles for the slice start-time select */
.slice-edit-modal-content select {
    width: 100%;
    box-sizing: border-box;
    font-size: 1.1rem;
    padding: 8px 12px;
    background: #1a1a1a;
    border: 1px solid var(--box-border);
    color: var(--text-main);
    border-radius: 6px;
    outline: none;
    font-family: inherit;
}
.slice-edit-modal-content select:focus { border-color: var(--accent-color); }

/* Reuse input styling for slice name field */
.slice-text-input {
    width: 100%;
    box-sizing: border-box;
    padding: 8px 12px;
    font-size: 1rem;
    background: #1a1a1a;
    border: 1px solid var(--box-border);
    border-radius: 6px;
    color: var(--text-main);
    font-family: inherit;
    outline: none;
}
.slice-text-input:focus { border-color: var(--accent-color); }

/* ── END SLICES FEATURE ──────────────────────────────────────────────────────── */

/* ── BOX MODAL: COLLAPSIBLE SECTIONS ────────────────────────────────────────
   Header row reuses .warning-link opacity and .category-label sizing.
   ──────────────────────────────────────────────────────────────────────────── */

.collapsible-section {
    margin-bottom: 1rem;
    border-top: 1px solid var(--box-border);
    padding-top: 0.5rem;
}

.collapsible-header {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-family: inherit;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    cursor: pointer;
    padding: 4px 0 8px;
    text-align: left;
    transition: color 0.15s;
}
.collapsible-header:hover { color: var(--text-main); }

.collapsible-carat { font-size: 0.6rem; flex-shrink: 0; }

.collapsible-body { padding-top: 0.5rem; }

/* ── END BOX MODAL: COLLAPSIBLE SECTIONS ────────────────────────────────────*/

/* ── BOX MODAL: TYPE STRIP & VARIANT GRID ────────────────────────────────────
   Extends existing .count-btn tile pattern — see those rules above.
   ──────────────────────────────────────────────────────────────────────────── */

/* Shared base for type and variant tiles — mirrors col-btn/count-btn pattern */
.picker-tile {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: #1a1a1a;
    border: 1px solid var(--box-border);
    border-radius: 6px;
    cursor: pointer;
    transition: color 0.15s, border-color 0.15s, background 0.15s;
}
.picker-tile:hover { background: #222; border-color: var(--accent-color); }
.picker-tile.active { border-color: var(--accent-color); background: rgba(70, 165, 206, 0.12); }

.picker-tile img {
    image-rendering: pixelated;
    object-fit: contain;
    filter: var(--icon-accent-filter);
}
.picker-tile.active img { filter: var(--icon-accent-filter) brightness(1.3); }

/* Reuses .time-label / .category-label conventions: tiny, uppercase, muted */
.picker-tile span {
    font-size: 0.6rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    text-align: center;
    line-height: 1.2;
    white-space: nowrap;
}
.picker-tile.active span { color: var(--accent-color); }

/* Type strip — equal-width tiles across the modal */
.type-strip { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 1.25rem; }
.type-tile { flex: 1 1 0; min-width: 44px; padding: 6px 8px; }
.type-tile img { width: 28px; height: 28px; }

/* Variant grid — wrapping, scrollable if many (e.g. Fitness ~25 variants) */
.variant-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 1.25rem;
    max-height: 220px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--box-border) transparent;
}
.variant-tile { width: 60px; padding: 6px 4px 5px; flex-shrink: 0; }
.variant-tile img { width: 48px; height: 48px; }
.variant-tile span { line-clamp: 2; -webkit-line-clamp: 2; display: -webkit-box; -webkit-box-orient: vertical; overflow: hidden; white-space: normal; }

/* ── END BOX MODAL: TYPE STRIP & VARIANT GRID ────────────────────────────────*/

/* ── BOX MODAL: MEAL TOGGLE ──────────────────────────────────────────────────
   Single button — reuses .picker-tile base. Wider, horizontal layout.
   ──────────────────────────────────────────────────────────────────────────── */

.meal-toggle {
    flex-direction: row;       /* icon + label side by side */
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    justify-content: center;
}

.meal-toggle img {
    width: 24px;
    height: 24px;
}

.meal-toggle.disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

/* ── END BOX MODAL: MEAL TOGGLE ──────────────────────────────────────────────*/

/* ---- MOBILE ------ */

/* This handles the switch from 6 columns to 4 columns */
@media (max-width: 800px) {

    :root {
        --icon-size: 48px;
        --icon-size-past-or-future: 44px;
    }

    .hour-block {
        min-height: 50px;
    }

    /* 1. Shrink the info bar */
    .info-bar {
        display: none;
    }

    .workspace {
        padding-top: 0px;
    }

    /* 2. SWITCH TO 4 COLUMNS (6 rows of 4 = 24) */
    .allocation-grid {
        grid-template-columns: repeat(4, 1fr); 
        gap: 8px;
        margin: 8px auto;
        aspect-ratio: auto; /* Remove fixed ratio so it can grow vertically */
    }

    /* 3. Adjust mini-grid */
    .mini-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 2px;
    }

    .mini-sleep-box {
        width: 4px;
        height: 4px;
    }

    /* meal icon */
    .secondary-badge {
        width: 16px;
        height: 16px
    }

    .slice-badge {
        gap: 1px;
        width: 18px;
        padding: 1px;
    }

    /* 4. Header adjustments for tight spaces */
    .app-header {
        padding: 15px 20px;
    }
    
    /* 5. MOBILE WIZARD SCROLLING FIX */
    #app-wizard-modal .modal-content {
        margin: 0; /* Remove margin on mobile */
        min-height: 100vh; /* Ensure full height */
        border-radius: 0; /* Remove rounded corners on mobile */
    }

    #sleep-text-display {
        /* Use !important to override Safari user-agent styles */
        display: none !important;
        
        /* Forces Safari to treat the element as non-existent in the accessibility tree */
        visibility: hidden;
        opacity: 0;
        pointer-events: none;
    }

    /* anchor modal */
    .input-subgroup select { appearance: none; } /* remove the arrows on selectors */
    .input-subgroup {
        max-height: 2.5rem; /* reduce what looks like "padding" height between anchor rows */
        gap: 0; /* no horizontal space between inputs */
    }
    #anchor-selector { max-height: 5rem; } /* reduce height on "add more" selector */
}

@media (max-width: 600px) {
    /* wizard */
    .review-grid { grid-template-columns: 1fr; }
}
