/* Global Reset & Layout */
* {
    box-sizing: border-box;
}

:root {
    /* Colors */
    --primary-color: #45B885;
    --secondary-color: #E36A6A;
    --navbar-bg: #2A4A30;
    --bg-color: #F8F6F0;
    --bg-light: #FDEAEA;
    --bg-white: #FEFCF8;
    --bg-notepad: #FDF0F0;
    --bg-notepad-header: #E36A6A;
    --text-color: #2A2320;
    --text-muted: #6A5A52;
    --text-light: #C8B8B0;
    --border-color: #E4D8CC;
    --card-header-bg: #F5D0D0;
    --danger-color: #C4404E;
    --success-color: #2E9E58;
    --card-min-width: 200px;
    --bg-surface: #f5f5f5;
    --shadow-color: rgba(0,0,0,0.12);
    --highlight-mark: #fef08a;
    --link-color: #1a73e8;
    --toast-bg: #333;
    --todo-border: #6b4226;
    --feature-pill-bg: #396D44;
    --feature-arrow-color: #2e4263;
    --navbar-gradient-end: #3a6e45;

    /* Fonts */
    --font-main: 'DM Sans', system-ui, -apple-system, sans-serif;
}

[data-theme="dark"] {
    --primary-color: #4FD198;
    --secondary-color: #D45A5A;
    --navbar-bg: #1A2E20;
    --navbar-gradient-end: #2A4A30;
    --bg-color: #1A1A1E;
    --bg-light: #2A1A1A;
    --bg-white: #242428;
    --bg-notepad: #2A1E1E;
    --bg-notepad-header: #B84A4A;
    --bg-surface: #2A2A2E;
    --text-color: #E0D8D0;
    --text-muted: #A89888;
    --text-light: #5A4A42;
    --border-color: #3A3028;
    --card-header-bg: #3A2020;
    --danger-color: #E45A68;
    --success-color: #3ABB6E;
    --shadow-color: rgba(0,0,0,0.3);
    --highlight-mark: #6B5A00;
    --link-color: #5A9DE0;
    --toast-bg: #1A1A1E;
    --todo-border: #8B5A36;
    --feature-pill-bg: #2A5A34;
    --feature-arrow-color: #5A7A9A;
    --grid-color: rgba(255, 255, 255, 0.12);
    --bench-dot-color: rgba(200, 140, 180, 0.12);
    --resize-handle-color: rgba(224, 216, 208, 0.5);
    --toolbar-border: var(--text-muted);
}

/* Force light theme for print regardless of user preference */
@media print {
    :root, [data-theme="dark"] {
        --primary-color: #45B885;
        --secondary-color: #E36A6A;
        --bg-color: #F8F6F0;
        --bg-white: #FEFCF8;
        --bg-surface: #f5f5f5;
        --text-color: #2A2320;
        --text-muted: #6A5A52;
        --text-light: #C8B8B0;
        --border-color: #E4D8CC;
        --grid-color: rgba(0, 0, 0, 0.12);
    }
}

body {
    margin: 0;
    font-family: var(--font-main);
    color: var(--text-color);
    height: 100vh; 
    display: flex; 
    flex-direction: column; 
    background: var(--bg-color); 
    overflow: hidden; 
}

/* Notification bell + panel */
.notif-badge {
    position: absolute;
    top: 2px;
    right: 0;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    font-size: 0.6em;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
    color: #fff;
    background: var(--danger-color, #c0392b);
    border-radius: 8px;
}
.notif-panel {
    position: absolute;
    top: 42px;
    right: 60px;
    width: 360px;
    max-height: 440px;
    overflow-y: auto;
    background: var(--bg-white);
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,0.2);
    z-index: 1100;
}
.notif-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-color);
    border-radius: 10px 10px 0 0;
}
.notif-header-title {
    font-weight: 600;
    font-size: 0.9em;
    color: var(--text-color);
}
.notif-mark-read {
    font-size: 0.78em;
    color: var(--link-color);
    cursor: pointer;
    background: none;
    border: none;
    padding: 0;
    width: auto;
}
.notif-mark-read:hover { text-decoration: underline; }
.notif-item {
    display: flex;
    gap: 10px;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: background 0.1s;
    text-decoration: none;
    color: inherit;
}
.notif-item:hover { background: var(--bg-main); }
.notif-item.unread { background: rgba(30,120,200,0.04); }
.notif-item.unread .notif-title { font-weight: 600; }
.notif-icon {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-main);
    color: var(--text-muted);
}
.notif-body { flex: 1; min-width: 0; }
.notif-title { font-size: 0.84em; color: var(--text-color); line-height: 1.3; }
.notif-time { font-size: 0.72em; color: var(--text-muted); margin-top: 2px; }
.notif-empty { padding: 30px 16px; text-align: center; color: var(--text-muted); font-size: 0.88em; }

/* Navbar */
.navbar {
    height: 45px;
    background: linear-gradient(135deg, var(--navbar-bg) 0%, var(--navbar-gradient-end) 100%);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    flex-shrink: 0;
}
.navbar, .navbar a, .navbar button { color: #fff; }
.navbar-logo {
    height: 20px;
    transform: scaleX(-1);
}
.navbar-brand {
    font-weight: bold;
    font-size: 1.1em;
    letter-spacing: 1px;
    text-decoration: none;
    display: flex;
    align-items: center;
    padding:2px;
    height: 10px;
}
.navbar-wordmark {
    font-family: 'Italiana', serif;
    font-size: 1.0em;
    margin-left: 8px;
}
.brand-wordmark {
    font-family: 'Italiana', serif;
}
.navbar-links { display: flex; align-items: center; gap: 12px; }
.navbar-links a { text-decoration: none; font-size: 0.9em; }
.navbar-links a:hover { text-decoration: underline; }
.navbar-nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-right: 15px;
    opacity: 0.85;
    transition: opacity 0.15s;
    position: relative;
}
.navbar-nav-link:hover { opacity: 1; text-decoration: none !important; }
.navbar-nav-active { opacity: 1; }
.navbar-nav-active::after {
    content: '';
    position: absolute;
    bottom: -13px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-bottom: 6px solid var(--bg-white);
}

/* ── Global Search ── */
.navbar-search-container {
    position: relative;
    margin-right: 12px;
}
.navbar-search-input {
    width: 160px;
    padding: 5px 10px 5px 30px;
    border: 1px solid rgba(255,255,255,0.3);
    border-radius: 6px;
    background: rgba(255,255,255,0.12);
    color: #fff;
    font-size: 0.82em;
    font-family: inherit;
    outline: none;
    transition: width 0.2s, background 0.2s, border-color 0.2s;
}
.navbar-search-input::placeholder { color: rgba(255,255,255,0.55); }
.navbar-search-input:focus {
    width: 260px;
    background: rgba(255,255,255,0.2);
    border-color: rgba(255,255,255,0.5);
}
.navbar-search-icon {
    position: absolute;
    left: 9px;
    top: 50%;
    transform: translateY(-50%);
    opacity: 0.6;
    pointer-events: none;
}
.navbar-search-results {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    width: 380px;
    max-height: 420px;
    overflow-y: auto;
    background: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    box-shadow: 0 8px 32px var(--shadow-color);
    z-index: 10000;
}
.navbar-search-results.open { display: block; }
.search-category { border-bottom: 1px solid var(--border-color); }
.search-category:last-child { border-bottom: none; }
.search-category-heading {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px 4px;
    font-size: 0.72em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-muted);
}
.search-result-item {
    display: block;
    padding: 7px 14px;
    text-decoration: none;
    color: var(--text-color);
    cursor: pointer;
    transition: background 0.1s;
}
.search-result-item:hover, .search-result-item.active { background: var(--bg-main); }
.search-result-title {
    color: var(--text-color);
    font-size: 0.85em;
    font-weight: 500;
    line-height: 1.3;
    display: flex;
    align-items: baseline;
    gap: 6px;
    flex-wrap: wrap;
}
.search-result-title mark { background: var(--highlight-mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.search-result-type {
    color: #fff;
    font-weight: 500;
    font-size: 0.78em;
    padding: 1px 6px;
    border-radius: 3px;
    margin-right: 4px;
    white-space: nowrap;
}
.search-result-type-experiment { background: #27ae60; }
.search-result-type-shared     { background: #8e44ad; }
.search-result-type-protocol   { background: #2e7cb8; }
.search-result-date {
    font-size: 0.82em;
    color: var(--text-muted);
    font-weight: 400;
    margin-left: auto;
    white-space: nowrap;
}
.search-result-sub {
    font-size: 0.78em;
    color: var(--text-muted);
    margin-top: 1px;
    line-height: 1.3;
}
.search-result-context {
    font-size: 0.78em;
    color: var(--text-muted);
    margin-top: 2px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.search-result-context mark { background: var(--highlight-mark); color: inherit; border-radius: 2px; padding: 0 1px; }
.search-result-item:has(.search-result-thumb) {
    display: flex;
    align-items: center;
    gap: 8px;
}
.search-result-thumb {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}
.search-no-results {
    padding: 20px 14px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85em;
}
.search-no-results p { margin: 0 0 6px; }
.search-no-results-hint {
    font-size: 0.82em;
    color: var(--text-light);
    line-height: 1.4;
}
.search-loading {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    padding: 18px;
}
.search-loading-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--text-light);
    animation: search-dot-pulse 1s ease-in-out infinite;
}
.search-loading-dot:nth-child(2) { animation-delay: 0.15s; }
.search-loading-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes search-dot-pulse {
    0%, 100% { opacity: 0.3; transform: scale(0.8); }
    50% { opacity: 1; transform: scale(1.1); }
}

/* Auth Components (Login/Register/Reset) */
.auth-container { flex: 1; display: flex; justify-content: center; align-items: center; }
.auth-two-col { display: flex; align-items: stretch; gap: 32px; }
.card-container { background: var(--bg-white); padding: 40px; border-radius: 8px; box-shadow: 0 4px 6px var(--shadow-color); width: 300px; }
.card-container h2 { text-align: center; color: var(--text-color); margin-top: 0; }
.card-container a { color: var(--link-color); }
.card-container p { color: var(--text-color); }

/* Feature card */
.feature-card {
    background: var(--bg-white);
    padding: 40px 36px 20px 36px;
    border-radius: 8px;
    box-shadow: 0 4px 6px var(--shadow-color);
    width: 320px;
    display: flex;
    flex-direction: column;
    border-left: 4px solid var(--primary-color);
}
.feature-card-heading {
    font-size: 1.35em;
    font-weight: 700;
    color: var(--text-color);
    margin: 0 0 24px 0;
    line-height: 1.5;
}
.feature-pill {
    position: relative;
}
.feature-free-arrow {
    position: absolute;
    width: 94px;
    height: 75px;
    top: -65px;
    left: -56px;
    background-color: var(--feature-arrow-color);
    -webkit-mask-image: url('../images/free-arrow.png');
    mask-image: url('../images/free-arrow.png');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-mode: luminance;
    mask-mode: luminance;
    pointer-events: none;
}
.feature-pill {
    background: var(--feature-pill-bg);
    color: #fff;
    padding: 2px 10px;
    border-radius: 20px;
    white-space: nowrap;
}
.feature-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 18px;
}
.feature-list li {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    font-size: 0.88em;
    color: var(--text-color);
    line-height: 1.45;
}
.feature-list li svg {
    flex-shrink: 0;
    color: var(--primary-color);
    margin-top: 1px;
}
.feature-card-art {
    flex: 1;
    min-height: 140px;
    margin-top: 24px;
    position: relative;
}
.feature-card-art::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 160px;
    background-color: var(--navbar-bg);
    -webkit-mask-image: url('../images/feather_mask.png');
    mask-image: url('../images/feather_mask.png');
    -webkit-mask-size: contain;
    mask-size: contain;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: bottom center;
    mask-position: bottom center;
    -webkit-mask-mode: luminance;
    mask-mode: luminance;
    pointer-events: none;
    opacity: 0.7;
}
@media (max-width: 720px) {
    .auth-two-col { flex-direction: column; align-items: center; gap: 20px; }
    .feature-card { width: 300px; }
}

/* Form Elements */
input { width: 100%; padding: 10px; margin: 10px 0; border: 1px solid var(--border-color); border-radius: 10px; box-sizing: border-box; background: var(--bg-white); color: var(--text-color); }
input::placeholder { color: var(--text-muted); opacity: 0.7; }
button { width: 100%; padding: 10px; background: var(--text-color); color: var(--bg-white); border: none; border-radius: 20px; cursor: pointer; font-weight: bold; }

