:root {
  --bg: #f5f5f5;
  --sidebar-bg: #2c2c2c;
  --sidebar-fg: #e0e0e0;
  --accent: #4a9eff;
  --danger: #e05252;
  --border: #ddd;
  --text: #222;
  --muted: #888;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body { font: 14px/1.5 system-ui, sans-serif; color: var(--text); background: var(--bg); }

/* ── Layout ── */
#layout { display: flex; height: calc(100vh - 48px); overflow: hidden; }

header {
  height: 48px;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  display: flex;
  align-items: center;
  padding: 0 12px;
  gap: 12px;
  flex-shrink: 0;
}
header .brand { font-weight: 700; font-size: 1.1em; color: #fff; text-decoration: none; flex: 0 0 auto; }
header form { flex: 1; max-width: 300px; display: flex; gap: 6px; }
header input[type=search] { flex: 1; padding: 4px 8px; border-radius: 4px; border: none; }
header .user-info { margin-left: auto; font-size: 0.85em; color: #aaa; white-space: nowrap; }
header a { color: var(--accent); }

#sidebar {
  width: 260px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-fg);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}
#sidebar-actions { padding: 8px; display: flex; gap: 6px; border-bottom: 1px solid #444; }

/* ── Tree ── */
.tree-list { list-style: none; padding: 0; margin: 0; }
.tree-list .tree-list { padding-left: 16px; }
.tree-row {
  display: flex;
  align-items: center;
  padding: 3px 8px;
  gap: 4px;
  position: relative;
}
.tree-row:hover { background: #3a3a3a; }
.tree-node.selected > .tree-row { background: #1a4a7a; }
.tree-toggle {
  background: none;
  border: none;
  color: var(--sidebar-fg);
  cursor: pointer;
  width: 18px;
  flex-shrink: 0;
  font-size: 12px;
  padding: 0;
}
.tree-spacer { width: 18px; flex-shrink: 0; display: inline-block; }
.tree-name {
  color: var(--sidebar-fg);
  text-decoration: none;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.9em;
}
.tree-name:hover { color: #fff; }
.tree-actions { display: none; gap: 2px; }
.tree-row:hover .tree-actions { display: flex; }
.btn-icon { background: none; border: none; cursor: pointer; color: #aaa; padding: 0 3px; font-size: 12px; }
.btn-icon:hover { color: #fff; }
.btn-icon.danger:hover { color: var(--danger); }

/* ── Main content ── */
#content { flex: 1; overflow-y: auto; padding: 12px; }
.content-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  flex-wrap: wrap;
}
.breadcrumb { color: var(--muted); font-size: 0.85em; }
.breadcrumb a { color: var(--muted); text-decoration: none; }
.breadcrumb a:hover { color: var(--accent); }

/* ── Bookmark table ── */
.bm-table { width: 100%; border-collapse: collapse; }
.bm-table th {
  text-align: left;
  padding: 6px 8px;
  background: #eee;
  border-bottom: 2px solid var(--border);
  font-weight: 600;
}
.bm-table th a { color: var(--text); text-decoration: none; }
.bm-table th a:hover { color: var(--accent); }
.bm-table td { padding: 6px 8px; border-bottom: 1px solid var(--border); vertical-align: top; }
.bm-table tr:hover td { background: #fafafa; }
.bm-title a { color: var(--text); font-weight: 500; }
.bm-title a:hover { color: var(--accent); }
.bm-desc { color: var(--muted); font-size: 0.85em; }
.bm-date { color: var(--muted); font-size: 0.8em; white-space: nowrap; }
.bm-actions { display: flex; gap: 4px; }
.bm-actions button { font-size: 11px; padding: 2px 6px; }

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 13px;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: #2a7edf; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #c03030; }
.btn-secondary { background: #e0e0e0; color: var(--text); }
.btn-secondary:hover { background: #ccc; }
.btn-sm { padding: 3px 8px; font-size: 12px; }

/* ── Flash messages ── */
.flash { padding: 8px 14px; border-radius: 4px; margin-bottom: 10px; }
.flash.info    { background: #d4edff; color: #0a5a8a; }
.flash.success { background: #d4edda; color: #155724; }
.flash.error   { background: #f8d7da; color: #721c24; }

/* ── Modals ── */
dialog {
  border: none;
  border-radius: 8px;
  padding: 0;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  min-width: 380px;
  max-width: 95vw;
}
dialog::backdrop { background: rgba(0,0,0,0.4); }
.dialog-header {
  padding: 14px 16px;
  background: var(--sidebar-bg);
  color: #fff;
  border-radius: 8px 8px 0 0;
  font-weight: 600;
}
.dialog-body { padding: 16px; }
.dialog-footer {
  padding: 10px 16px;
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  border-top: 1px solid var(--border);
}

/* ── Form groups ── */
.form-group { margin-bottom: 12px; }
.form-group label {
  display: block;
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
  text-transform: uppercase;
}
.form-group input[type=text],
.form-group input[type=url],
.form-group input[type=password],
.form-group input[type=file],
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 7px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: inherit;
  background: #fff;
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-group input[type=checkbox] { width: auto; margin-right: 6px; }
.form-group label:has(input[type=checkbox]) {
  text-transform: none;
  font-size: 14px;
  font-weight: 400;
  color: var(--text);
}

/* ── Login page ── */
.login-wrap { display: flex; align-items: center; justify-content: center; height: 100vh; }
.login-box {
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  padding: 32px;
  min-width: 300px;
}
.login-box h1 { margin-bottom: 20px; font-size: 1.4em; text-align: center; }
.login-box .btn { width: 100%; justify-content: center; }
