:root {
    --bg: #1e1f24;
    --panel: #26272e;
    --panel-2: #2e2f38;
    --border: #383944;
    --text: #eceef2;
    --text-dim: #9a9ba5;
    --accent: #6c8cff;
    --accent-2: #ffd166;
    --danger: #ff6b6b;
    --radius: 10px;
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg);
    color: var(--text);
}

/* ---------- Login ---------- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: radial-gradient(circle at 30% 20%, #2a2c36, #17181c 70%);
}

.login-box {
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 36px 32px;
    width: 100%;
    max-width: 360px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.4);
}

.login-box h1 { margin: 0 0 4px; font-size: 22px; }
.login-sub { margin: 0 0 20px; color: var(--text-dim); font-size: 14px; }

.login-box form { display: flex; flex-direction: column; gap: 14px; }
.login-box label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--text-dim); }
.login-box input {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 15px;
}
.login-box input:focus { outline: none; border-color: var(--accent); }

.login-box button {
    margin-top: 6px;
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 11px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
}
.login-box button:hover { filter: brightness(1.08); }

.alert {
    background: rgba(255,107,107,0.15);
    border: 1px solid rgba(255,107,107,0.4);
    color: #ffb3b3;
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 13px;
    margin-bottom: 16px;
}

/* ---------- App layout ---------- */
.app {
    display: flex;
    height: 100vh;
}

.sidebar {
    width: 300px;
    min-width: 260px;
    background: var(--panel);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
}

.sidebar-top {
    padding: 16px 16px 8px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.sidebar-top h1 { font-size: 16px; margin: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.btn-new {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 7px 12px;
    border-radius: 7px;
    font-size: 13px;
    cursor: pointer;
    white-space: nowrap;
}
.btn-new:hover { filter: brightness(1.1); }

.search-wrap { padding: 8px 16px; }
.search-wrap input {
    width: 100%;
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 13px;
}
.search-wrap input:focus { outline: none; border-color: var(--accent); }

.notes-list {
    list-style: none;
    margin: 0;
    padding: 4px 8px;
    overflow-y: auto;
    flex: 1;
}

.note-item {
    padding: 10px 10px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 3px;
    border: 1px solid transparent;
}
.note-item:hover { background: var(--panel-2); }
.note-item.active { background: var(--panel-2); border-color: var(--accent); }
.note-item.pinned .note-item-title { color: var(--accent-2); }

.note-item-title {
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.note-item-preview {
    font-size: 12px;
    color: var(--text-dim);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}
.note-item-date {
    font-size: 11px;
    color: #6d6e78;
    margin-top: 4px;
}

.empty-hint {
    text-align: center;
    color: var(--text-dim);
    font-size: 13px;
    padding: 24px 8px;
}

.sidebar-bottom {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
}
.logout-link {
    color: var(--text-dim);
    text-decoration: none;
    font-size: 13px;
}
.logout-link:hover { color: var(--danger); }

/* ---------- Editor ---------- */
.editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.editor-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
}

#noteTitle {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text);
    font-size: 19px;
    font-weight: 700;
}
#noteTitle:focus { outline: none; }

.toolbar-actions { display: flex; align-items: center; gap: 6px; }
.toolbar-actions button {
    background: var(--panel-2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 7px 10px;
    border-radius: 7px;
    cursor: pointer;
    font-size: 15px;
}
.toolbar-actions button:hover { border-color: var(--accent); }
.toolbar-actions button#pinBtn.active { background: rgba(255,209,102,0.15); border-color: var(--accent-2); }
.toolbar-actions button#deleteBtn:hover { border-color: var(--danger); }

.save-status {
    font-size: 12px;
    color: var(--text-dim);
    min-width: 110px;
    text-align: right;
}

#noteContent {
    flex: 1;
    background: var(--bg);
    border: none;
    color: var(--text);
    padding: 20px;
    font-size: 15px;
    line-height: 1.6;
    resize: none;
    font-family: inherit;
}
#noteContent:focus { outline: none; }

/* ---------- Responsive ---------- */
@media (max-width: 720px) {
    .app { flex-direction: column; }
    .sidebar { width: 100%; height: 40vh; border-right: none; border-bottom: 1px solid var(--border); }
    .editor { height: 60vh; }
}
