:root {
    --accent-color: #00ff00;
    --bg: #121212;
    --surface: #1e1e1e;
    --surface2: #1a1a1a;
    --border: #2a2a2a;
    --text-muted: #888;
    --header-height: 56px;
}

*, *::before, *::after {
    box-sizing: border-box;
}

body, html {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    font-family: monospace;
    background-color: var(--bg);
    color: #e0e0e0;
    /* Prevent the document itself from ever scrolling */
    overflow: hidden;
    overscroll-behavior: none;
}

/* ========== AUTH ========== */

#auth-overlay {
    position: fixed;
    inset: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 24px;
}

#master-password {
    width: 100%;
    max-width: 320px;
    padding: 12px 14px;
    margin-bottom: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--accent-color);
    font-family: monospace;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#master-password:focus {
    border-color: var(--accent-color);
}

#unlock-btn {
    width: 100%;
    max-width: 320px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--accent-color);
    font-family: monospace;
    font-size: 1rem;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

#unlock-btn:hover, #unlock-btn:active {
    border-color: var(--accent-color);
    background: #252525;
}

.auth-actions {
    margin-top: 16px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.secondary-btn {
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-muted);
    padding: 8px 14px;
    font-family: monospace;
    font-size: 0.85rem;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s;
    min-height: 40px;
}

.secondary-btn:hover, .secondary-btn:active {
    color: var(--accent-color);
    border-color: var(--accent-color);
}

/* ========== HIDDEN ========== */

.hidden {
    display: none !important;
}

/* ========== DASHBOARD ========== */

/* Fill the viewport absolutely — no flex height math, no dvh guessing */
#dashboard {
    position: fixed;
    inset: 0;
}

/* ========== HEADER ========== */

/* Pinned to the top, exact height, never moves */
header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    display: flex;
    align-items: center;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    overflow: hidden;
    z-index: 10;
    padding: 0;
    gap: 0;
}

header h2 {
    margin: 0;
    padding: 0 12px;
    font-size: 1rem;
    color: var(--accent-color);
    white-space: nowrap;
    letter-spacing: 0.05em;
    flex-shrink: 0;
}

#file-status {
    font-size: 0.75rem;
    white-space: nowrap;
    color: orange;
    flex-shrink: 0;
    padding-right: 8px;
}

/* ========== HEADER ACTIONS ========== */

.actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex: 1;
    min-width: 0;
    overflow-x: auto;
    overflow-y: hidden;
    height: 100%;
    padding: 0 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
    -webkit-overflow-scrolling: touch;
}

.actions::-webkit-scrollbar {
    display: none;
}

.actions button,
.actions select {
    height: 36px;
    padding: 0 12px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: #e0e0e0;
    font-family: monospace;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: border-color 0.2s, color 0.2s;
    appearance: none;
    -webkit-appearance: none;
}

.actions button:hover,
.actions button:active,
.actions select:hover,
.actions select:focus {
    border-color: var(--accent-color);
    color: var(--accent-color);
    outline: none;
}

.actions select {
    padding: 0 10px;
}

/* ========== NOTES GRID ========== */

/* Pinned to fill exactly the space below the header — no math needed */
#notes-grid {
    position: absolute;
    top: var(--header-height);
    left: 0;
    right: 0;
    bottom: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 16px;
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 14px;
    align-content: start;
}

.note-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 14px;
    cursor: pointer;
    /* Fixed height — every card is the same size, predictable, no squishing */
    height: 180px;
    overflow: hidden;
    position: relative;
    transition: border-color 0.2s;
    user-select: none;
    -webkit-user-select: none;
}

.note-card:hover,
.note-card:active {
    border-color: var(--accent-color);
}

.note-card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 48px;
    background: linear-gradient(transparent, var(--surface));
    border-radius: 0 0 8px 8px;
}

/* ========== EDITOR MODAL ========== */

#editor-modal {
    position: fixed;
    inset: 0;
    background: var(--bg);
    z-index: 500;
    display: flex;
    flex-direction: column;
}

.editor-header {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 0 14px;
    height: var(--header-height);
    flex-shrink: 0;
    background: var(--surface2);
    border-bottom: 1px solid var(--border);
    z-index: 10;
}

.editor-header button {
    height: 36px;
    padding: 0 12px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: #e0e0e0;
    font-family: monospace;
    font-size: 0.8rem;
    cursor: pointer;
    white-space: nowrap;
    transition: border-color 0.2s, color 0.2s;
}

.editor-header button:hover,
.editor-header button:active {
    border-color: var(--accent-color);
    color: var(--accent-color);
}

#delete-note-btn {
    border-color: #5a0000;
    color: #ff6b6b;
}

#delete-note-btn:hover,
#delete-note-btn:active {
    border-color: #ff6b6b;
    color: #ff6b6b;
}

#date-label {
    color: var(--text-muted);
    font-size: 0.75rem;
    flex: 1;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    padding: 0 6px;
}

.header-actions {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* ========== WORKSPACE ========== */

#workspace {
    flex: 1;
    display: flex;
    overflow: hidden;
    min-height: 0;
}

#markdown-input,
#note-preview {
    flex: 1;
    min-height: 0;
    padding: 18px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

#markdown-input {
    background-color: var(--surface);
    color: var(--accent-color);
    border: none;
    border-right: 1px solid var(--border);
    resize: none;
    outline: none;
    font-family: monospace;
    font-size: 0.95rem;
    line-height: 1.6;
    caret-color: var(--accent-color);
}

#note-preview {
    background-color: var(--surface2);
    line-height: 1.7;
}

/* ========== MOBILE ========== */

@media (max-width: 600px) {
    header h2 {
        font-size: 0.9rem;
        padding: 0 8px;
    }

    .actions button,
    .actions select {
        font-size: 0.75rem;
        padding: 0 10px;
        height: 34px;
    }

    #workspace {
        flex-direction: column;
    }

    #markdown-input {
        border-right: none;
        border-bottom: 1px solid var(--border);
    }

    .editor-header {
        padding: 0 10px;
    }

    .editor-header button {
        font-size: 0.75rem;
        padding: 0 9px;
    }
}