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

:root {
    --bg: #0f1117;
    --surface: #1a1d27;
    --surface2: #22263a;
    --border: #2e3350;
    --accent: #f0b429;
    --accent2: #3b82f6;
    --text: #e2e8f0;
    --muted: #8892a4;
    --danger: #ef4444;
    --success: #22c55e;
    --radius: 8px;
    --sidebar: 340px;
}

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── TOPBAR ── */
#topbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}
#topbar h1 { font-size: 1rem; font-weight: 700; color: var(--accent); letter-spacing: .5px; margin-right: auto; }
#topbar h1 span { color: var(--muted); font-weight: 400; }

/* ── LAYOUT ── */
#layout {
    display: flex;
    flex: 1;
    overflow: hidden;
}

/* ── MAIN ── */
#main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    padding: 20px;
    gap: 14px;
}

#note-form { display: flex; flex-direction: column; gap: 10px; flex: 1; overflow: hidden; }

.form-row { display: flex; gap: 10px; }
.form-row input, .form-row select {
    flex: 1;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 8px 12px;
    border-radius: var(--radius);
    font-size: .875rem;
}
.form-row input:focus, .form-row select:focus { outline: none; border-color: var(--accent2); }
.form-row select option { background: var(--surface2); }

#editor-wrap { flex: 1; overflow: hidden; display: flex; flex-direction: column; }
.note-editor { flex: 1; }

/* Summernote dark override */
.note-editor.note-frame { border: 1px solid var(--border) !important; border-radius: var(--radius) !important; }
.note-toolbar { background: var(--surface2) !important; border-bottom: 1px solid var(--border) !important; }
.note-editable { background: var(--surface) !important; color: var(--text) !important; min-height: 200px; }
.note-statusbar { background: var(--surface2) !important; border-top: 1px solid var(--border) !important; }
.note-btn { background: var(--surface) !important; border-color: var(--border) !important; color: var(--text) !important; }
.note-btn:hover { background: var(--border) !important; }
.note-dropdown-menu { background: var(--surface2) !important; border-color: var(--border) !important; }
.note-dropdown-item { color: var(--text) !important; }
.note-dropdown-item:hover { background: var(--border) !important; }

/* read view */
#read-view {
    display: none;
    flex: 1;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    overflow-y: auto;
}
#read-view h2 { color: var(--accent); margin-bottom: 8px; }
#read-view .meta { font-size: .75rem; color: var(--muted); margin-bottom: 16px; display: flex; gap: 12px; flex-wrap: wrap; }
#read-view .meta span { background: var(--surface2); padding: 2px 8px; border-radius: 20px; }

.form-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── BUTTONS ── */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: .875rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity .15s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}
.btn:hover { opacity: .85; }
.btn-primary  { background: var(--accent2); color: #fff; }
.btn-accent   { background: var(--accent);  color: #000; }
.btn-danger   { background: var(--danger);  color: #fff; }
.btn-ghost    { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-sm       { padding: 5px 10px; font-size: .8rem; }
.btn-icon     { padding: 6px 8px; }

/* ── SIDEBAR ── */
#sidebar {
    width: var(--sidebar);
    flex-shrink: 0;
    background: var(--surface);
    border-left: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

#sidebar-header {
    padding: 14px 16px 10px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.filter-tabs { display: flex; gap: 4px; }
.filter-tab {
    flex: 1;
    padding: 5px;
    text-align: center;
    font-size: .78rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    background: var(--surface2);
    color: var(--muted);
    border: 1px solid transparent;
    transition: all .15s;
}
.filter-tab.active { background: var(--accent2); color: #fff; border-color: var(--accent2); }

.filter-inputs { display: flex; flex-direction: column; gap: 6px; }
.filter-inputs input, .filter-inputs select {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 6px 10px;
    border-radius: 6px;
    font-size: .8rem;
    width: 100%;
}
.filter-inputs input:focus, .filter-inputs select:focus { outline: none; border-color: var(--accent2); }

#notes-list {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#notes-list::-webkit-scrollbar { width: 4px; }
#notes-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 4px; }

.note-card {
    background: var(--surface2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 10px 12px;
    cursor: pointer;
    transition: border-color .15s;
}
.note-card:hover, .note-card.active { border-color: var(--accent2); }
.note-card .nc-title { font-size: .875rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.note-card .nc-meta { font-size: .72rem; color: var(--muted); margin-top: 4px; display: flex; gap: 8px; flex-wrap: wrap; }
.note-card .nc-cat { font-size: .7rem; padding: 1px 7px; border-radius: 20px; font-weight: 600; }

.cat-news       { background: #1e3a5f; color: #60a5fa; }
.cat-idea       { background: #1a3a2a; color: #4ade80; }
.cat-position   { background: #3a2a1a; color: #fb923c; }
.cat-result     { background: #2a1a3a; color: #c084fc; }

.status-badge { font-size: .7rem; padding: 1px 7px; border-radius: 20px; font-weight: 600; }
.status-draft     { background: #2a2a1a; color: #facc15; }
.status-published { background: #1a3a2a; color: #4ade80; }
.status-archived  { background: #2a1a1a; color: #f87171; }

.empty-state { text-align: center; color: var(--muted); font-size: .85rem; padding: 40px 20px; }

/* synthesis panel */
#synthesis-panel {
    border-top: 1px solid var(--border);
    padding: 12px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
#synthesis-panel label { font-size: .75rem; color: var(--muted); font-weight: 600; text-transform: uppercase; letter-spacing: .5px; display: flex; justify-content: space-between; align-items: center; }
#synthesis-text {
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    border-radius: 6px;
    padding: 8px 10px;
    font-size: .8rem;
    resize: none;
    height: 80px;
    width: 100%;
}
#synthesis-text:focus { outline: none; border-color: var(--accent2); }

/* toast */
#toast {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: var(--surface2);
    border: 1px solid var(--border);
    color: var(--text);
    padding: 10px 18px;
    border-radius: var(--radius);
    font-size: .875rem;
    opacity: 0;
    transform: translateY(10px);
    transition: all .25s;
    z-index: 9999;
    pointer-events: none;
}
#toast.show { opacity: 1; transform: translateY(0); }
#toast.success { border-color: var(--success); color: var(--success); }
#toast.error   { border-color: var(--danger);  color: var(--danger); }

/* modal */
#modal-overlay {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.6);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
#modal-overlay.show { display: flex; }
#modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    width: 400px;
    max-width: 90vw;
}
#modal h3 { margin-bottom: 12px; }
#modal p  { color: var(--muted); font-size: .875rem; margin-bottom: 20px; }
#modal .modal-actions { display: flex; gap: 8px; justify-content: flex-end; }

@media (max-width: 768px) {
    #layout { flex-direction: column; }
    #sidebar { width: 100%; height: 300px; border-left: none; border-top: 1px solid var(--border); }
}
