:root {
    --bg: #f4eedf;
    --bg-2: #ede6d3;
    --panel: rgba(255, 255, 255, 0.72);
    --panel-border: rgba(92, 71, 52, 0.12);
    --text: #2f261f;
    --muted: #6f665d;
    --primary: #5c7f67;
    --primary-dark: #45614d;
    --danger: #9a4b4b;
    --shadow: 0 20px 50px rgba(62, 46, 31, 0.12);
    --radius: 22px;
}

* { box-sizing: border-box; }
html, body { min-height: 100%; }
body {
    margin: 0;
    font-family: "Trebuchet MS", "Gill Sans", "Segoe UI", sans-serif;
    color: var(--text);
    background:
        radial-gradient(circle at top left, rgba(255,255,255,0.8), transparent 35%),
        linear-gradient(180deg, #f9f4ea 0%, #f0e6d1 100%);
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
button, input, select, textarea { font: inherit; }

.app-shell {
    width: min(1180px, calc(100% - 32px));
    margin: 0 auto;
    padding: 20px 0 40px;
}

.topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 14px 18px;
    border: 1px solid var(--panel-border);
    background: rgba(255,255,255,0.5);
    backdrop-filter: blur(16px);
    border-radius: 999px;
    box-shadow: var(--shadow);
    position: sticky;
    top: 14px;
    z-index: 20;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-weight: 800;
    letter-spacing: 0.02em;
}

.brand-mark {
    width: 34px;
    height: 34px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(145deg, #fff4aa, #ffd18f);
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

.topbar-actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.topbar-actions a {
    padding: 9px 14px;
    border-radius: 999px;
    color: var(--muted);
}

.topbar-actions a:hover { background: rgba(0,0,0,0.04); color: var(--text); }

.main-content { padding: 24px 4px 0; }

.hero, .page-head {
    display: flex;
    align-items: end;
    justify-content: space-between;
    gap: 20px;
    margin-bottom: 22px;
}

.hero h1, .page-head h1 {
    margin: 8px 0 8px;
    font-size: clamp(2rem, 5vw, 3.5rem);
    line-height: 0.98;
}

.eyebrow {
    margin: 0;
    text-transform: uppercase;
    letter-spacing: 0.18em;
    font-size: 0.72rem;
    color: var(--primary-dark);
    font-weight: 800;
}

.muted { color: var(--muted); }

.search-bar, .toolbar {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    align-items: center;
}

input[type="search"], input[type="text"], input[type="password"], input[type="datetime-local"], select, textarea {
    width: 100%;
    border-radius: 16px;
    border: 1px solid rgba(92,71,52,0.14);
    background: rgba(255,255,255,0.85);
    padding: 12px 14px;
    color: var(--text);
    outline: none;
    box-shadow: inset 0 1px 0 rgba(255,255,255,0.6);
}

input:focus, textarea:focus, select:focus {
    border-color: rgba(92,127,103,0.5);
    box-shadow: 0 0 0 4px rgba(92,127,103,0.12);
}

.search-bar input { min-width: 280px; }
.toolbar { margin-bottom: 20px; }
.toolbar input[type="search"] { flex: 1 1 280px; }
.toolbar select { flex: 0 0 180px; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-radius: 16px;
    border: 1px solid transparent;
    padding: 12px 16px;
    cursor: pointer;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
    font-weight: 700;
}

.btn:hover { transform: translateY(-1px); }
.btn-primary {
    background: linear-gradient(180deg, #688b72, #526c59);
    color: white;
    box-shadow: 0 14px 28px rgba(82,108,89,0.26);
}
.btn-secondary {
    background: rgba(255,255,255,0.72);
    border-color: rgba(92,71,52,0.12);
}
.btn-danger {
    background: #8d4a4a;
    color: white;
}
.ghost {
    background: rgba(255,255,255,0.8);
}

.cards-grid, .content-grid, .action-grid, .toggle-grid, .stats-grid {
    display: grid;
    gap: 18px;
}
.stats-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); margin-bottom: 22px; }
.content-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); margin-bottom: 22px; }
.action-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.notes-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.toggle-grid { grid-template-columns: repeat(3, minmax(0, 1fr)); }

.panel, .stat-card, .note-card, .auth-card {
    border: 1px solid var(--panel-border);
    background: var(--panel);
    backdrop-filter: blur(14px);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}
.panel, .auth-card { padding: 20px; }

.panel-head, .note-topline, .note-meta, .card-actions, .mini-row, .upload-row {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
}
.panel-head { margin-bottom: 16px; }
.panel-head h2, .auth-card h1 { margin: 0; }
.stack { display: grid; gap: 14px; }
.field, .toggle { display: grid; gap: 7px; font-weight: 600; }
.field span { font-size: 0.95rem; }
.toggle { grid-template-columns: auto 1fr; align-items: center; background: rgba(255,255,255,0.45); padding: 12px 14px; border-radius: 16px; }

.stat-card {
    padding: 18px;
    display: grid;
    gap: 10px;
    min-height: 140px;
}
.stat-card span, .stat-card em { color: var(--muted); font-style: normal; }
.stat-card strong { font-size: 2rem; }

.note-card {
    padding: 18px;
    overflow: hidden;
    position: relative;
}
.note-card::after {
    content: "";
    position: absolute;
    inset: auto 0 0 0;
    height: 10px;
    opacity: 0.28;
    background: linear-gradient(90deg, transparent, rgba(0,0,0,0.08), transparent);
}
.note-detail { margin-bottom: 22px; }
.note-card h3 { margin: 0; font-size: 1.1rem; }
.note-content {
    white-space: normal;
    font-size: 1.05rem;
    line-height: 1.65;
}
.note-meta { margin-top: 14px; color: rgba(47,38,31,0.68); font-size: 0.92rem; flex-wrap: wrap; }
.card-actions { margin-top: 14px; flex-wrap: wrap; justify-content: flex-start; }
.card-actions.wrap { justify-content: flex-start; }

.compact .note-card { margin-bottom: 14px; }
.empty-state {
    padding: 18px;
    border: 1px dashed rgba(92,71,52,0.22);
    border-radius: 18px;
    color: var(--muted);
    background: rgba(255,255,255,0.4);
}

.badge, .auth-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border-radius: 999px;
    padding: 7px 10px;
    font-size: 0.82rem;
    font-weight: 700;
    background: rgba(255,255,255,0.65);
}

.alert {
    padding: 14px 16px;
    border-radius: 18px;
    margin-bottom: 16px;
    border: 1px solid rgba(0,0,0,0.08);
}
.alert.success { background: #e4f5e8; }
.alert.error { background: #fde3e3; }

.auth-page .app-shell { width: min(640px, calc(100% - 28px)); }
.auth-panel {
    min-height: calc(100vh - 160px);
    display: grid;
    place-items: center;
}
.auth-card { width: 100%; padding: 28px; }

.lock-overlay {
    position: fixed;
    inset: 0;
    background: rgba(22, 18, 13, 0.48);
    display: grid;
    place-items: center;
    z-index: 100;
}
.lock-overlay.hidden { display: none; }
.lock-card {
    width: min(420px, calc(100% - 32px));
    padding: 22px;
    border-radius: 24px;
    background: rgba(255,255,255,0.95);
    box-shadow: var(--shadow);
    text-align: center;
}

.note-color-yellow { background: linear-gradient(180deg, #fff8c9, #fff1a3); }
.note-color-mint { background: linear-gradient(180deg, #e2f7ec, #c2ead6); }
.note-color-blue { background: linear-gradient(180deg, #dff1ff, #c6e2ff); }
.note-color-pink { background: linear-gradient(180deg, #ffe3ea, #ffcad8); }
.note-color-peach { background: linear-gradient(180deg, #ffe4d1, #ffd1b0); }
.note-color-lavender { background: linear-gradient(180deg, #efe2ff, #dcc5ff); }
.note-color-white { background: linear-gradient(180deg, #ffffff, #f5f1ea); }

.list-stack { display: grid; gap: 12px; }
.mini-row, .upload-row {
    padding: 14px 0;
    border-bottom: 1px solid rgba(92,71,52,0.1);
    flex-wrap: wrap;
}
.mini-row:last-child, .upload-row:last-child { border-bottom: 0; }

@media (max-width: 960px) {
    .stats-grid, .content-grid, .notes-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 720px) {
    .topbar { border-radius: 24px; flex-direction: column; align-items: stretch; }
    .topbar-actions { justify-content: center; }
    .hero, .page-head { flex-direction: column; align-items: start; }
    .stats-grid, .content-grid, .notes-grid, .action-grid, .toggle-grid { grid-template-columns: 1fr; }
    .search-bar, .toolbar { width: 100%; }
    .search-bar input { min-width: 0; }
}
