:root {
    --bg: #0f172a;
    --panel: #1e293b;
    --panel-2: #273449;
    --border: #334155;
    --text: #e2e8f0;
    --muted: #94a3b8;
    --primary: #2563eb;
    --today: #f59e0b;
    --radius: 12px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    padding: 16px;
}

.hidden { display: none !important; }

/* ---------- Topbar ---------- */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1100px;
    margin: 0 auto 16px;
    gap: 12px;
    flex-wrap: wrap;
}
.nav { display: flex; align-items: center; gap: 12px; }
.nav h1 { font-size: 1.4rem; text-transform: capitalize; min-width: 200px; text-align: center; }
.actions { display: flex; gap: 8px; }

.icon-btn {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    width: 40px; height: 40px;
    border-radius: 10px;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: background .15s;
}
.icon-btn:hover { background: var(--panel-2); }

.btn-ghost {
    background: var(--panel);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 9px 16px;
    border-radius: 10px;
    cursor: pointer;
    font-size: .9rem;
}
.btn-ghost:hover { background: var(--panel-2); }

.btn-primary {
    background: var(--primary);
    border: none;
    color: #fff;
    padding: 10px 18px;
    border-radius: 10px;
    cursor: pointer;
    font-size: .95rem;
    font-weight: 600;
}
.btn-primary:hover { filter: brightness(1.1); }

/* ---------- Calendar grid ---------- */
.weekdays, .grid {
    max-width: 1100px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 8px;
}
.weekdays {
    margin-bottom: 8px;
    color: var(--muted);
    font-size: .8rem;
    text-transform: uppercase;
    letter-spacing: .05em;
}
.weekdays span { text-align: center; padding: 4px; }

.cell {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    min-height: 110px;
    padding: 8px;
    cursor: pointer;
    transition: border-color .15s, transform .05s;
    display: flex;
    flex-direction: column;
    gap: 4px;
    overflow: hidden;
}
.cell:hover { border-color: var(--primary); }
.cell:active { transform: scale(.99); }
.cell.empty { background: transparent; border-color: transparent; cursor: default; }
.cell.empty:hover { border-color: transparent; }

.cell .daynum {
    font-size: .9rem;
    font-weight: 600;
    color: var(--muted);
    align-self: flex-start;
}
.cell.today .daynum {
    background: var(--today);
    color: #1a1205;
    width: 26px; height: 26px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
}

.dot-row { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 2px; }
.note-chip {
    font-size: .72rem;
    padding: 2px 6px;
    border-radius: 6px;
    color: #fff;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
}
.more { font-size: .7rem; color: var(--muted); }

/* ---------- Modal ---------- */
.modal-overlay, .login-overlay {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    display: flex; align-items: center; justify-content: center;
    padding: 16px;
    z-index: 50;
}
.modal {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 100%; max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 20px;
}
.modal-head {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 16px;
}
.modal-head h2 { font-size: 1.2rem; text-transform: capitalize; }

.note-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.note-item {
    background: var(--panel-2);
    border-left: 4px solid var(--primary);
    border-radius: 8px;
    padding: 10px 12px;
    display: flex;
    justify-content: space-between;
    gap: 10px;
}
.note-item .nbody { flex: 1; min-width: 0; }
.note-item .ntitle { font-weight: 600; margin-bottom: 2px; }
.note-item .ntext { color: var(--muted); font-size: .9rem; white-space: pre-wrap; word-break: break-word; }
.note-item .nbtns { display: flex; flex-direction: column; gap: 6px; }
.mini-btn {
    background: transparent; border: 1px solid var(--border);
    color: var(--text); border-radius: 6px; padding: 4px 8px;
    cursor: pointer; font-size: .78rem;
}
.mini-btn:hover { background: var(--bg); }
.mini-btn.del:hover { background: #7f1d1d; border-color: #7f1d1d; }
.empty-note { color: var(--muted); font-size: .9rem; font-style: italic; }

/* ---------- Form ---------- */
.note-form { display: flex; flex-direction: column; gap: 10px; border-top: 1px solid var(--border); padding-top: 16px; }
.note-form input[type="text"], .note-form textarea, .login-box input {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 8px;
    padding: 10px 12px;
    font-size: .95rem;
    font-family: inherit;
    resize: vertical;
}
.note-form input:focus, .note-form textarea:focus, .login-box input:focus {
    outline: none; border-color: var(--primary);
}
.form-row { display: flex; justify-content: space-between; align-items: center; gap: 10px; flex-wrap: wrap; }
.colors { display: flex; gap: 8px; }
.colors .swatch {
    width: 26px; height: 26px; border-radius: 50%;
    cursor: pointer; border: 2px solid transparent;
}
.colors .swatch.active { border-color: var(--text); transform: scale(1.15); }
.form-btns { display: flex; gap: 8px; }

/* ---------- Login ---------- */
.login-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    width: 100%; max-width: 360px;
    display: flex; flex-direction: column; gap: 14px;
    text-align: center;
}
.login-box h1 { font-size: 1.6rem; }
.login-box p { color: var(--muted); font-size: .9rem; }
.login-box button { margin-top: 4px; }
.login-error { color: #f87171; font-size: .85rem; min-height: 1em; }

@media (max-width: 640px) {
    .cell { min-height: 76px; padding: 6px; }
    .note-chip { font-size: .65rem; }
    .nav h1 { min-width: auto; font-size: 1.1rem; }
}
