:root {
  --bg: #0b0e11;
  --bg-2: #0f1317;
  --panel: #161b21;
  --panel-2: #1c232b;
  --panel-3: #222b34;
  --line: #262f39;
  --line-2: #313c48;
  --ink: #e8eef4;
  --muted: #8492a0;
  --faint: #5c6773;
  --accent: #e8b046;   /* mining amber */
  --accent-2: #56a8dd; /* signal blue */
  --up: #43d183;
  --down: #e5546b;
  --radius: 12px;
  --side-w: 236px;
  font-synthesis: none;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font: 14px/1.55 ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.hidden { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 12px; }
h1 { font-size: 21px; margin: 0 0 2px; letter-spacing: -.2px; }
.view-head p { margin: 0; font-size: 13px; }

button {
  background: var(--accent); color: #241800; border: 0; border-radius: 9px;
  padding: 9px 15px; font-weight: 600; cursor: pointer; font-size: 13px;
  transition: filter .12s, background .12s, border-color .12s, color .12s;
}
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .5; cursor: default; }
button.ghost { background: transparent; color: var(--muted); border: 1px solid var(--line-2); }
button.ghost:hover { color: var(--ink); border-color: var(--muted); filter: none; }
button.small { padding: 6px 11px; font-size: 12px; }
input, textarea, select {
  background: var(--panel-2); border: 1px solid var(--line-2); color: var(--ink);
  border-radius: 9px; padding: 9px 12px; font: inherit; outline: none; transition: border-color .12s;
}
input::placeholder, textarea::placeholder { color: var(--faint); }
input:focus, textarea:focus, select:focus { border-color: var(--accent-2); }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
.logo { color: var(--accent); font-size: 15px; }

/* ---------- login ---------- */
.login { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); z-index: 40; }
.login-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 30px; width: 330px; display: flex; flex-direction: column; gap: 13px; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.brand { font-weight: 700; letter-spacing: .2px; font-size: 17px; display: flex; align-items: center; gap: 9px; }
.err { color: var(--down); font-size: 13px; min-height: 16px; }

/* ---------- shell ---------- */
.shell { display: flex; min-height: 100vh; }
.sidebar {
  width: var(--side-w); flex: none; background: var(--bg-2);
  border-right: 1px solid var(--line); display: flex; flex-direction: column;
  position: sticky; top: 0; height: 100vh;
}
.side-brand { display: flex; align-items: center; gap: 11px; padding: 18px 18px 14px; }
.side-title { font-weight: 700; font-size: 16px; letter-spacing: -.2px; }
.side-nav { display: flex; flex-direction: column; gap: 3px; padding: 8px 12px; flex: 1; }
.nav-item {
  display: flex; align-items: center; gap: 11px; width: 100%; text-align: left;
  background: transparent; color: var(--muted); border: 0; border-radius: 9px;
  padding: 10px 12px; font-weight: 600; font-size: 13.5px;
}
.nav-item svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; flex: none; }
.nav-item span:nth-child(2) { flex: 1; }
.nav-item:hover { background: var(--panel); color: var(--ink); filter: none; }
.nav-item.active { background: var(--panel-2); color: var(--ink); }
.nav-item.active svg { stroke: var(--accent); }
.count { background: var(--panel-3); color: var(--muted); font-size: 11px; font-weight: 700; padding: 1px 8px; border-radius: 999px; min-width: 20px; text-align: center; }
.nav-item.active .count { background: var(--accent); color: #241800; }
.side-foot { border-top: 1px solid var(--line); padding: 12px 16px; display: flex; align-items: center; justify-content: space-between; gap: 8px; }

.main-wrap { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.topbar { display: none; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--line); position: sticky; top: 0; background: rgba(11,14,17,.92); backdrop-filter: blur(8px); z-index: 20; }
.topbar-title { font-weight: 700; }
.hamburger { padding: 6px 11px; }
main { padding: 26px 30px; max-width: 1180px; width: 100%; margin: 0 auto; }
@media (max-width: 900px) {
  .sidebar { position: fixed; z-index: 30; transform: translateX(-100%); transition: transform .2s; box-shadow: 0 0 40px rgba(0,0,0,.6); }
  .sidebar.open { transform: none; }
  .topbar { display: flex; }
  main { padding: 18px 16px; }
}

/* ---------- view header ---------- */
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.head-actions { display: flex; align-items: center; gap: 9px; }
.head-actions input[type=search], .head-actions input { min-width: 180px; }

/* ---------- filters ---------- */
.filters { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; flex-wrap: wrap; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { background: var(--panel-2); border: 1px solid var(--line-2); color: var(--muted); padding: 5px 12px; border-radius: 999px; cursor: pointer; font-size: 12px; font-weight: 600; }
.chip:hover { color: var(--ink); }
.chip.active { background: var(--accent); color: #241800; border-color: var(--accent); }
.toggle { color: var(--muted); font-size: 12px; display: flex; align-items: center; gap: 7px; cursor: pointer; }

/* ---------- cards / grid ---------- */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 14px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 15px 16px; display: flex; flex-direction: column; gap: 9px; position: relative; transition: border-color .14s, transform .14s; }
.card:hover { border-color: var(--line-2); }
.card.dim { opacity: .5; }
.card .top { display: flex; align-items: center; gap: 9px; }
.card .name { font-weight: 700; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.card .name a { color: var(--ink); }
.card .name a:hover { color: var(--accent-2); }
.status { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.status.up { background: var(--up); box-shadow: 0 0 9px var(--up); }
.status.down { background: var(--down); }
.meta { display: flex; flex-wrap: wrap; gap: 6px; }
.badge { font-size: 11px; padding: 2px 8px; border-radius: 6px; background: var(--panel-2); color: var(--muted); border: 1px solid var(--line); }
.badge.public { color: var(--up); border-color: #234b38; }
.badge.ip { color: var(--accent); border-color: #55431f; }
.badge.cat { color: var(--accent-2); border-color: #274456; }
.card .url { font-size: 12px; color: var(--accent-2); word-break: break-all; }
.card .sub { font-size: 12px; color: var(--muted); }
.card .note { font-size: 12.5px; color: #cbd4dd; }
.card .edit { position: absolute; top: 11px; right: 11px; background: transparent; border: 0; color: var(--faint); cursor: pointer; font-size: 13px; padding: 4px; opacity: 0; }
.card:hover .edit { opacity: 1; }
.card .edit:hover { color: var(--ink); filter: none; }
.tags { display: flex; gap: 5px; flex-wrap: wrap; }
.tag { font-size: 11px; background: var(--panel-2); border: 1px solid var(--line); color: var(--accent-2); padding: 1px 7px; border-radius: 5px; }
.card .del { color: var(--down); border-color: transparent; background: transparent; padding: 4px; }
.card .del:hover { text-decoration: underline; }
.empty { color: var(--muted); padding: 46px; text-align: center; grid-column: 1 / -1; border: 1px dashed var(--line-2); border-radius: var(--radius); }

/* ---------- inline form ---------- */
.inline-form { display: grid; grid-template-columns: 1.1fr 2fr 1fr 2fr auto; gap: 9px; margin-bottom: 18px; }
@media (max-width: 820px) { .inline-form { grid-template-columns: 1fr; } }

/* ---------- todos board ---------- */
.board { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 16px; align-items: start; }
.todo-list { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); display: flex; flex-direction: column; overflow: hidden; }
.tl-head { display: flex; align-items: center; gap: 8px; padding: 13px 15px 10px; }
.tl-title { font-weight: 700; font-size: 15px; flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; cursor: text; }
.tl-title[contenteditable]:focus { outline: 1px solid var(--accent-2); border-radius: 5px; padding: 0 3px; }
.tl-menu { background: transparent; border: 0; color: var(--faint); padding: 3px 6px; cursor: pointer; }
.tl-menu:hover { color: var(--down); filter: none; }
.progress { height: 4px; background: var(--panel-3); }
.progress > i { display: block; height: 100%; background: var(--up); transition: width .25s; }
.tl-items { list-style: none; margin: 0; padding: 6px 8px; display: flex; flex-direction: column; gap: 2px; }
.tl-item { display: flex; align-items: flex-start; gap: 9px; padding: 7px 8px; border-radius: 8px; }
.tl-item:hover { background: var(--panel-2); }
.tl-item input[type=checkbox] { appearance: none; width: 17px; height: 17px; border: 1.6px solid var(--line-2); border-radius: 5px; cursor: pointer; flex: none; margin-top: 1px; position: relative; }
.tl-item input[type=checkbox]:checked { background: var(--up); border-color: var(--up); }
.tl-item input[type=checkbox]:checked::after { content: "✓"; position: absolute; inset: 0; color: #06210f; font-size: 12px; font-weight: 800; display: grid; place-items: center; }
.tl-item .txt { flex: 1; font-size: 13.5px; cursor: text; word-break: break-word; }
.tl-item.done .txt { color: var(--faint); text-decoration: line-through; }
.tl-item .x { opacity: 0; background: transparent; border: 0; color: var(--faint); cursor: pointer; padding: 0 2px; font-size: 15px; }
.tl-item:hover .x { opacity: 1; }
.tl-item .x:hover { color: var(--down); filter: none; }
.tl-add { display: flex; gap: 7px; padding: 9px 12px 12px; border-top: 1px solid var(--line); }
.tl-add input { flex: 1; }
.tl-foot { padding: 0 12px 11px; }
.tl-foot button { color: var(--faint); background: transparent; border: 0; font-size: 12px; padding: 2px; cursor: pointer; }
.tl-foot button:hover { color: var(--muted); filter: none; }

/* ---------- notes ---------- */
.notes-layout { display: grid; grid-template-columns: 260px 1fr; gap: 18px; align-items: start; }
@media (max-width: 820px) { .notes-layout { grid-template-columns: 1fr; } }
.note-list { display: flex; flex-direction: column; gap: 5px; }
.note-list .nl-item { text-align: left; background: var(--panel); color: var(--ink); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; cursor: pointer; display: flex; flex-direction: column; gap: 2px; }
.note-list .nl-item:hover { border-color: var(--line-2); filter: none; }
.note-list .nl-item.active { border-color: var(--accent-2); background: var(--panel-2); }
.nl-item .nl-title { font-weight: 600; font-size: 13.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.nl-item .nl-date { font-size: 11px; color: var(--faint); }
.note-editor { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; min-height: 380px; }
.ne-bar { display: flex; align-items: center; gap: 9px; margin-bottom: 12px; }
.ne-bar input { flex: 1; font-size: 15px; font-weight: 600; }
.ne-body textarea { width: 100%; min-height: 360px; resize: vertical; line-height: 1.6; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.ne-hint { color: var(--faint); font-size: 11.5px; margin-top: 8px; }
.ne-placeholder { color: var(--muted); display: grid; place-items: center; min-height: 340px; text-align: center; }
.seg { display: inline-flex; border: 1px solid var(--line-2); border-radius: 8px; overflow: hidden; }
.seg button { background: var(--panel-2); color: var(--muted); border: 0; border-radius: 0; padding: 6px 12px; font-size: 12px; }
.seg button.active { background: var(--panel-3); color: var(--ink); }

/* ---------- rendered markdown (docs + note preview) ---------- */
.md h1, .md h2, .md h3 { color: var(--ink); border-bottom: 1px solid var(--line); padding-bottom: 6px; }
.md code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: 12.5px; }
.md pre { background: #0a0d10; border: 1px solid var(--line); padding: 12px; border-radius: 8px; overflow-x: auto; }
.md pre code { background: none; }
.md table { border-collapse: collapse; width: 100%; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 10px; text-align: left; }
.md a { color: var(--accent-2); }
.md blockquote { border-left: 3px solid var(--accent); margin: 0; padding-left: 14px; color: var(--muted); }

/* ---------- reference ---------- */
.docs-layout { display: grid; grid-template-columns: 240px 1fr; gap: 20px; align-items: start; }
@media (max-width: 820px) { .docs-layout { grid-template-columns: 1fr; } }
.doc-list { display: flex; flex-direction: column; gap: 5px; }
.doc-list button { text-align: left; background: var(--panel); color: var(--muted); border: 1px solid var(--line); border-radius: 10px; padding: 11px 13px; font-weight: 600; font-size: 13px; }
.doc-list button.active, .doc-list button:hover { color: var(--ink); border-color: var(--line-2); filter: none; }
.doc-list button.active { border-color: var(--accent-2); background: var(--panel-2); }
.doc-body { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 8px 26px 26px; max-height: calc(100vh - 200px); overflow: auto; }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.62); display: grid; place-items: center; z-index: 50; }
.modal-card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; width: 410px; display: flex; flex-direction: column; gap: 13px; box-shadow: 0 24px 60px rgba(0,0,0,.5); }
.modal-card h3 { margin: 0; }
.modal-card label { display: flex; flex-direction: column; gap: 5px; font-size: 12px; color: var(--muted); }
.modal-card label.row { flex-direction: row; align-items: center; gap: 8px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 4px; }
