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

:root {
    --bg:       #0f1117;
    --surface:  #1a1d27;
    --surface2: #23263a;
    --border:   #2e3148;
    --text:     #e8eaf0;
    --muted:    #7a7f9a;
    --accent:   #6c8ef7;
    --danger:   #e84040;
    --radius:   10px;
}

body { background: var(--bg); color: var(--text); font-family: system-ui, sans-serif; height: 100vh; }

/* ── Layout ── */
.layout { display: flex; height: 100vh; }
.sidebar { width: 220px; background: var(--surface); border-right: 1px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; }
.sidebar-header { padding: 1.2rem 1rem; font-size: 1rem; display: flex; gap: 0.5rem; align-items: center; border-bottom: 1px solid var(--border); }
nav#folderTree { flex: 1; overflow-y: auto; padding: 0.5rem; }
.folder-item { padding: 0.5rem 0.75rem; border-radius: 6px; cursor: pointer; font-size: 0.9rem; color: var(--muted); }
.folder-item:hover, .folder-item.active { background: var(--surface2); color: var(--text); }

/* folder rows with rename/delete */
.folder-row { display: flex; align-items: center; padding: 0.35rem 0.5rem; border-radius: 6px; cursor: pointer; font-size: 0.9rem; color: var(--muted); }
.folder-row:hover, .folder-row.active { background: var(--surface2); color: var(--text); }
.folder-row:hover .folder-actions, .folder-row.active .folder-actions { opacity: 1; }
.folder-row.drag-over { border: 1px dashed var(--accent); }
.folder-row.dragging { opacity: 0.4; }
.folder-label { flex: 1; }
.folder-actions { display: flex; gap: 0.2rem; opacity: 0; transition: opacity .15s; }
.folder-action-btn { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.8rem; padding: 0.15rem 0.3rem; border-radius: 4px; line-height: 1; }
.folder-action-btn:hover { background: var(--surface); color: var(--text); }
.folder-action-btn.danger:hover { color: var(--danger); }
.sidebar-footer { padding: 0.75rem; display: flex; flex-direction: column; gap: 0.5rem; border-top: 1px solid var(--border); }

.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.toolbar { padding: 1rem; display: flex; gap: 0.75rem; border-bottom: 1px solid var(--border); }
#searchInput { flex: 1; background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 0.5rem 0.75rem; border-radius: var(--radius); font-size: 0.9rem; outline: none; }
#searchInput:focus { border-color: var(--accent); }

.bookmark-list { flex: 1; overflow-y: auto; padding: 1rem; display: flex; flex-direction: column; gap: 0.5rem; }

.bookmark-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.85rem 1rem; display: flex; align-items: flex-start; gap: 0.75rem; }
.bookmark-item:hover { border-color: #3e4260; }
.bookmark-favicon { width: 20px; height: 20px; flex-shrink: 0; margin-top: 2px; object-fit: contain; }
.bookmark-body { flex: 1; min-width: 0; }
.bookmark-title { font-weight: 600; font-size: 0.95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bookmark-title a { color: var(--text); text-decoration: none; }
.bookmark-title a:hover { color: var(--accent); }
.bookmark-url { font-size: 0.78rem; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bookmark-tags { margin-top: 0.3rem; display: flex; flex-wrap: wrap; gap: 0.3rem; }
.tag { font-size: 0.72rem; background: var(--surface2); border: 1px solid var(--border); border-radius: 4px; padding: 0.1rem 0.4rem; color: var(--muted); }
.bookmark-actions { display: flex; gap: 0.4rem; flex-shrink: 0; }
.btn-icon { background: none; border: none; color: var(--muted); cursor: pointer; font-size: 0.9rem; padding: 0.25rem; border-radius: 4px; }
.btn-icon:hover { color: var(--text); background: var(--surface2); }
.btn-icon.danger:hover { color: var(--danger); }

/* ── Login page ── */
.login-page { display: flex; align-items: center; justify-content: center; min-height: 100vh; }
.login-box { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 2.5rem; width: 100%; max-width: 360px; display: flex; flex-direction: column; gap: 1.25rem; }
.login-box h1 { text-align: center; font-size: 1.4rem; }
.error { color: var(--danger); font-size: 0.88rem; text-align: center; }

/* ── Forms ── */
label { display: flex; flex-direction: column; gap: 0.35rem; font-size: 0.85rem; color: var(--muted); }
input, textarea, select { background: var(--surface2); border: 1px solid var(--border); color: var(--text); padding: 0.5rem 0.75rem; border-radius: 6px; font-size: 0.9rem; outline: none; width: 100%; }
input:focus, textarea:focus, select:focus { border-color: var(--accent); }

/* ── Buttons ── */
.btn-primary { background: var(--accent); color: #fff; border: none; padding: 0.5rem 1.1rem; border-radius: 6px; cursor: pointer; font-size: 0.9rem; font-weight: 600; }
.btn-primary:hover { filter: brightness(1.12); }
.btn-ghost { background: none; border: 1px solid var(--border); color: var(--muted); padding: 0.45rem 0.9rem; border-radius: 6px; cursor: pointer; font-size: 0.85rem; text-decoration: none; text-align: center; }
.btn-ghost:hover { color: var(--text); border-color: #4e5270; }

/* ── Modal ── */
dialog { background: var(--surface); color: var(--text); border: 1px solid var(--border); border-radius: var(--radius); padding: 2rem; width: 100%; max-width: 480px; }
dialog::backdrop { background: rgba(0,0,0,0.6); }
dialog form { display: flex; flex-direction: column; gap: 1rem; }
dialog h2 { font-size: 1.1rem; margin-bottom: 0.25rem; }
.form-actions { display: flex; justify-content: flex-end; gap: 0.75rem; margin-top: 0.5rem; }

@media (max-width: 600px) {
    .sidebar { display: none; }
}
