:root {
    --bg: #121212;
    --text: #e0e0e0;
    --accent: #FFEB3B;
    --ribbon-bg: rgba(40, 40, 40, 0.85);
}

/* --- RESET & LAYOUT LOCK --- */
* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    
    /* THE FIX: Lock the document completely */
    position: fixed; 
    overflow: hidden; 
    
    background-color: var(--bg);
    color: var(--text);
    font-family: 'Courier New', Courier, monospace;
    
    /* Prevent mobile rubber-banding */
    overscroll-behavior: none;
    touch-action: none;
}

/* --- MAIN CONTAINER --- */
#container {
    /* Use fixed positioning to pin it to the glass */
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    
    /* THE FIX: 100svh = "Smallest Viewport Height" 
       This calculates height assuming bars are always visible, 
       so content never jumps when they hide. */
    height: 100svh; 
    
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

/* --- HUD (Info Icon) --- */
#hud { 
    position: absolute; 
    top: 20px; 
    right: 20px; 
    z-index: 1000; 
    cursor: pointer; 
    opacity: 0.3; 
    transition: opacity 0.2s; 
}
#hud:hover { opacity: 1; }
.hidden { display: none !important; }

/* --- VIEWS --- */
.view { 
    width: 100%; 
    max-height: 100%; /* Ensure view fits in container */
    
    display: flex; 
    flex-direction: column; /* Stack content vertically */
    justify-content: center; 
    align-items: center;
    
    padding: 0 20px;
}

/* --- DO MODE --- */
.focus-card { 
    text-align: center; 
    width: 100%;
    max-width: 800px; 
    /* Prevent shrinking too small */
    flex-shrink: 0; 
}

#active-task-text { 
    font-size: 3rem; 
    margin: 0; 
    word-wrap: break-word; 
    line-height: 1.2;
}
#active-task-body { 
    font-size: 1.2rem; 
    color: #888; 
    margin-top: 1.5rem; 
    white-space: pre-wrap; 
}

/* --- ADD MODE --- */
.immersive-input-container { 
    width: 100%; 
    max-width: 900px; 
    display: flex; 
    flex-direction: column; 
    /* Ensure it doesn't grow taller than screen */
    max-height: 80svh; 
}
#input-title, #input-body { 
    background: transparent; 
    border: none; 
    color: var(--text); 
    outline: none; 
    width: 100%; 
    font-family: inherit; 
}
#input-title { 
    font-size: 3rem; 
    font-weight: bold; 
    border-bottom: 2px solid transparent; 
    margin-bottom: 20px; 
    padding: 0;
}
#input-title:focus { border-bottom: 2px solid var(--accent); }
#input-body { 
    font-size: 1.5rem; 
    height: 40vh; 
    max-height: 400px;
    resize: none; 
    color: #aaa; 
}

/* --- EDIT MODE --- */
#task-list-container { 
    width: 100%; 
    max-width: 800px; 
    
    /* Scroll logic */
    max-height: 75svh; /* Leave room for ribbon */
    overflow-y: auto; 
    
    /* Spacing for the scrollbar */
    padding-right: 10px;
}
.task-item { 
    padding: 15px 10px; 
    border-bottom: 1px solid #333; 
    display: flex; 
    align-items: baseline;
    gap: 15px; 
}
.task-item.completed { opacity: 0.4; text-decoration: line-through; }
.task-id { color: var(--accent); font-weight: bold; min-width: 40px; font-size: 0.9em; }
.task-text { word-break: break-word; line-height: 1.4; }

/* --- RIBBON --- */
#action-ribbon {
    position: fixed; 
    bottom: 0; left: 0; 
    width: 100%; 
    height: 80px; /* Taller touch area */
    padding: 0 20px 20px 20px; /* Push up slightly */
    
    display: flex; 
    justify-content: space-between; 
    align-items: flex-end; /* Align to bottom */
    
    pointer-events: none; 
    z-index: 1000;
}

.ribbon-group { display: flex; gap: 8px; pointer-events: auto; }
.ribbon-group.center { position: absolute; left: 50%; transform: translateX(-50%); bottom: 20px; }

.ribbon-btn {
    background: var(--ribbon-bg); 
    border: 1px solid #555; 
    color: #e0e0e0;
    padding: 10px 18px; 
    border-radius: 8px; 
    cursor: pointer; 
    text-align: center;
    backdrop-filter: blur(4px); 
    min-width: 80px; 
    transition: all 0.1s;
    user-select: none;
}
.ribbon-btn:hover { background: #444; border-color: var(--accent); }
.ribbon-btn:active { transform: translateY(2px); }

.btn-label { display: block; font-size: 0.9rem; font-weight: bold; }
.btn-shortcut { display: block; font-size: 0.7rem; color: #aaa; margin-top: 2px; }

/* --- TOAST --- */
.toast {
    position: fixed; bottom: 100px; left: 50%; transform: translateX(-50%);
    background-color: #222; color: #fff; padding: 12px 24px;
    border-radius: 6px; font-size: 0.9rem; border: 1px solid #444;
    opacity: 0; transition: opacity 0.3s; pointer-events: none; z-index: 2000;
    box-shadow: 0 4px 12px rgba(0,0,0,0.5);
}
.toast.show { opacity: 1; }

/* --- MINIMALIST FLOATING SCROLLBAR --- */

/* 1. Target Webkit (Chrome/Edge/Safari) */
::-webkit-scrollbar {
    width: 6px;  /* Vertical width */
    height: 6px; /* Horizontal height */
}

/* 2. Track (Invisible) */
::-webkit-scrollbar-track {
    background: transparent; 
}

/* 3. Thumb (The Pill) */
::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2); /* Subtle Grey */
    border-radius: 10px; /* Pill shape */
    
    /* Trick to make it look 'floating': add a transparent border */
    background-clip: padding-box;
    border: 1px solid transparent;
}

/* 4. Hover State */
::-webkit-scrollbar-thumb:hover {
    background-color: rgba(255, 255, 255, 0.5);
}

/* 5. Firefox Support */
html {
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

/* --- SEARCH OVERLAY --- */
#search-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.8); /* Dim background */
    z-index: 2000;
    display: flex; justify-content: center; align-items: flex-start;
    padding-top: 100px; /* Position from top */
    backdrop-filter: blur(5px);
}

.search-box {
    width: 600px;
    max-width: 90%;
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    display: flex; flex-direction: column;
    overflow: hidden;
    max-height: 70vh;
}

/* Shared Input Styles for both Search and ID Select */
#search-input, #id-select-input {
    width: 100%;
    padding: 20px;
    font-size: 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 1px solid #333;
    color: var(--text);
    font-family: inherit;
    outline: none;
}

#search-results {
    overflow-y: auto;
    padding: 10px 0;
}

/* Section Headers */
.search-section-title {
    padding: 8px 20px;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--accent);
    font-weight: bold;
    background: rgba(255, 255, 255, 0.03);
    margin-top: 10px;
}
.search-section-title:first-child { margin-top: 0; }

/* Result Items */
.search-item {
    padding: 12px 20px;
    border-bottom: 1px solid #2a2a2a;
    cursor: pointer;
    display: flex; flex-direction: column; gap: 4px;
}
.search-item:hover { background: #333; }
.search-item-main { font-size: 1rem; color: #fff; }
.search-item-sub { font-size: 0.85rem; color: #888; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Add to style.css */
.highlight-match {
    background-color: var(--accent); /* Bright Yellow */
    color: #000;
    font-weight: bold;
    border-radius: 2px;
    padding: 0 2px;
}

/* --- QUICK EDIT VIEW --- */
/* We reuse .immersive-input-container logic from Add View */
#edit-input-title {
    font-size: 3rem;
    font-weight: bold;
    border: none; border-bottom: 2px solid transparent;
    background: transparent; color: var(--text);
    outline: none; margin-bottom: 20px;
    font-family: inherit; width: 100%;
}
#edit-input-title:focus { border-bottom: 2px solid var(--accent); }

#edit-input-body {
    font-size: 1.5rem;
    background: transparent; border: none;
    color: #aaa; outline: none;
    width: 100%; height: 40vh; max-height: 400px;
    resize: none; font-family: inherit;
}

/* --- TEXT SELECTION COLOR --- */
::selection {
    background: var(--accent);
    color: #000; /* Black text on Yellow background for readability */
}

/* --- QUICK EDIT VIEW (Fix Vertical Center) --- */
#quick-edit-view {
    /* Use Fixed positioning to overlay correctly */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg); /* Ensure it covers the list behind it */
    z-index: 10; /* Sit above the list */
    
    /* Perfect Center Alignment */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center Vertically */
    align-items: center;     /* Center Horizontally */
    
    padding: 0 20px;
}

/* --- ID SELECT OVERLAY (Fix Alignment) --- */
#id-select-overlay {
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%;
    
    /* Flex Center Horizontal, Top Vertical with padding */
    display: flex; 
    justify-content: center; /* Centers box horizontally */
    align-items: flex-start; /* Starts from top */
    padding-top: 100px; /* Push down from ceiling */
    
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    backdrop-filter: blur(5px);
}

/* Ensure the box inside doesn't stretch weirdly */
#id-select-overlay .search-box {
    width: 600px;
    max-width: 90%;
    /* Re-assert styles if they were missing */
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 12px;
}

/* --- QUICK EDIT VIEW (Fix Vertical Center) --- */
#quick-edit-view {
    /* Use Fixed positioning to overlay correctly */
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: var(--bg); /* Ensure it covers the list behind it */
    z-index: 10; /* Sit above the list */
    
    /* Perfect Center Alignment */
    display: flex;
    flex-direction: column;
    justify-content: center; /* Center Vertically */
    align-items: center;     /* Center Horizontally */
    
    padding: 0 20px;
}