:root {
  --bg: #0d0e10;
  --panel: #141518;
  --panel-2: #1a1c20;
  --line: #24272c;
  --line-2: #2f3339;
  --text: #e7e6e1;
  --muted: #8a8d93;
  --faint: #5c6066;
  --accent: #f0b429;
  --accent-ink: #1a1405;
  --ok: #4cc38a;
  --warn: #f0b429;
  --bad: #ef5b5b;
  --radius: 10px;
  --sans: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "IBM Plex Mono", ui-monospace, "Cascadia Mono", Consolas, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--sans);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}
button, input, textarea { font: inherit; color: inherit; }
::selection { background: var(--accent); color: var(--accent-ink); }
[hidden] { display: none !important; }
.mono { font-family: var(--mono); }
.muted { color: var(--muted); }
.small { font-size: 12px; }

/* ---------- header ---------- */
.top {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 28px; border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 20;
  background: rgba(13,14,16,.92); backdrop-filter: blur(6px);
}
.top-left, .top-right { display: flex; align-items: center; gap: 14px; }
.wordmark { font-family: var(--mono); font-weight: 500; font-size: 15px; display: flex; align-items: center; gap: 9px; letter-spacing: .02em; }
.wordmark .sq { width: 10px; height: 10px; background: var(--accent); border-radius: 2px; }
.clock { text-align: right; font-family: var(--mono); line-height: 1.1; }
.clock-time { font-size: 26px; font-weight: 500; letter-spacing: -.01em; font-variant-numeric: tabular-nums; }
.clock-time .sec { font-size: 13px; color: var(--muted); margin-left: 4px; vertical-align: top; }
.clock-date { font-size: 12px; color: var(--muted); margin-top: 3px; }

.pill {
  font-family: var(--mono); font-size: 12px; padding: 4px 10px; border-radius: 999px;
  border: 1px solid var(--line-2); background: var(--panel); color: var(--muted); cursor: pointer;
}
.pill.soon { color: var(--accent); border-color: rgba(240,180,41,.4); }
.pill.now { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.pill.done { color: var(--faint); }

.lunch-banner {
  display: flex; align-items: center; gap: 12px; justify-content: center;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; font-weight: 600; position: sticky; top: 0; z-index: 30;
}
.lunch-banner .lb-mark { width: 8px; height: 8px; border-radius: 50%; background: var(--accent-ink); animation: blink 1s steps(2) infinite; }
.lunch-banner .btn { background: var(--accent-ink); color: var(--accent); border-color: var(--accent-ink); }
@keyframes blink { 50% { opacity: 0; } }

/* ---------- grid ---------- */
.grid {
  display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); gap: 16px;
  padding: 22px 28px 40px; max-width: 1500px; margin: 0 auto;
}
.span-3 { grid-column: span 3; } .span-4 { grid-column: span 4; }
.span-5 { grid-column: span 5; } .span-7 { grid-column: span 7; }
.span-12 { grid-column: 1 / -1; }
@media (max-width: 1100px) {
  .span-3, .span-4, .span-5, .span-7 { grid-column: span 6; }
}
@media (max-width: 720px) {
  .grid { grid-template-columns: minmax(0, 1fr); padding: 14px 16px 30px; gap: 12px; }
  .span-3, .span-4, .span-5, .span-7 { grid-column: auto; }
  .top { padding: 12px 16px; }
  .clock-time { font-size: 20px; }
  .top-left, .top-right { gap: 8px; }
  .filter { width: 100px !important; }
  .link-form { flex-wrap: wrap; }
  .link-form #link-url { flex-basis: 100%; }
  .link-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

.card {
  background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; display: flex; flex-direction: column; min-height: 0; min-width: 0; max-height: 560px;
}
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card h2 {
  margin: 0; font: 500 12px/1 var(--mono); text-transform: lowercase; letter-spacing: .06em;
  color: var(--muted); display: flex; align-items: center; gap: 8px;
}
.count { font-size: 11px; color: var(--faint); }

/* ---------- inputs & buttons ---------- */
input:not([type=checkbox]), textarea {
  background: var(--bg); border: 1px solid var(--line); border-radius: 7px;
  padding: 8px 10px; width: 100%; outline: none; transition: border-color .12s;
}
input:focus, textarea:focus { border-color: var(--line-2); box-shadow: 0 0 0 2px rgba(240,180,41,.12); }
textarea { resize: vertical; }
input::placeholder, textarea::placeholder { color: var(--faint); }
.filter { width: 130px !important; padding: 5px 9px !important; font-size: 12px; }

.btn {
  border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 7px;
  padding: 7px 14px; cursor: pointer; font-size: 13px; white-space: nowrap; transition: background .12s, border-color .12s;
}
.btn:hover { background: #22252a; }
.btn.small { padding: 4px 10px; font-size: 12px; }
.btn.ghost { background: transparent; }
.btn.danger { color: var(--bad); border-color: rgba(239,91,91,.35); }
.btn.danger:hover { background: rgba(239,91,91,.1); }
.btn:disabled { opacity: .5; cursor: default; }
#snip-form .btn[type=submit] { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.link-btn { background: none; border: 0; color: var(--faint); cursor: pointer; font-size: 12px; padding: 0; }
.link-btn:hover { color: var(--text); }
.icon-btn {
  background: none; border: 1px solid transparent; color: var(--faint); cursor: pointer;
  border-radius: 6px; width: 26px; height: 26px; display: inline-grid; place-items: center; flex: none;
}
.icon-btn:hover { color: var(--text); background: var(--panel-2); border-color: var(--line); }
.icon-btn.lg { width: 36px; height: 36px; border-color: var(--line); color: var(--muted); }
.check { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: 12px; cursor: pointer; }
.check input { accent-color: var(--accent); width: 15px; height: 15px; margin: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.row.end { justify-content: flex-end; }

/* ---------- lists ---------- */
.list { list-style: none; margin: 0; padding: 0; overflow-y: auto; min-height: 0; }
.list::-webkit-scrollbar { width: 8px; }
.list::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 4px; }
.list .empty { color: var(--faint); font-size: 13px; padding: 14px 2px; }

/* snippets */
.snip-form { display: grid; gap: 8px; margin-bottom: 12px; }
.snips li.snip {
  display: flex; align-items: center; gap: 10px; padding: 9px 10px; border-radius: 7px;
  cursor: pointer; border: 1px solid transparent; transition: background .1s;
}
.snips li.snip:hover { background: var(--panel-2); border-color: var(--line); }
.snips li.snip.copied { border-color: var(--ok); background: rgba(76,195,138,.07); }
.snip-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.snip-label { font-weight: 500; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snip-value { font-family: var(--mono); font-size: 12px; color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snip-value.secret { letter-spacing: .1em; }

/* todos */
.inline-form { margin-bottom: 10px; }
.todos li { display: flex; align-items: flex-start; gap: 10px; padding: 7px 4px; border-bottom: 1px solid var(--line); }
.todos li:last-child { border-bottom: 0; }
.tick {
  width: 17px; height: 17px; margin-top: 1px; border-radius: 4px; border: 1.5px solid var(--line-2);
  background: none; cursor: pointer; flex: none; display: grid; place-items: center; padding: 0;
}
.tick:hover { border-color: var(--muted); }
.todos li.done .tick { background: var(--accent); border-color: var(--accent); }
.todos li.done .tick::after { content: ""; width: 8px; height: 4px; border: 2px solid var(--accent-ink); border-top: 0; border-right: 0; transform: rotate(-45deg) translate(1px,-1px); }
.todo-text { flex: 1; min-width: 0; word-break: break-word; outline: none; border-radius: 4px; padding: 0 2px; }
.todo-text[contenteditable=true] { background: var(--bg); box-shadow: 0 0 0 1px var(--line-2); }
.todos li.done .todo-text { color: var(--faint); text-decoration: line-through; }
.todos li .icon-btn { opacity: 0; }
.todos li:hover .icon-btn { opacity: 1; }
@media (hover: none) { .todos li .icon-btn { opacity: 1; } }

/* system */
.sys { display: grid; gap: 14px; }
.stat-top { display: flex; justify-content: space-between; font-size: 12px; margin-bottom: 6px; }
.stat-top b { font-weight: 500; color: var(--muted); }
.stat-top span { font-family: var(--mono); }
.bar { height: 5px; background: var(--bg); border-radius: 3px; overflow: hidden; }
.bar i { display: block; height: 100%; background: var(--text); border-radius: 3px; transition: width .4s; }
.bar i.warn { background: var(--warn); }
.bar i.bad { background: var(--bad); }

/* files */
.drop {
  display: flex; flex-direction: column; align-items: center; gap: 4px; justify-content: center;
  border: 1.5px dashed var(--line-2); border-radius: 8px; padding: 20px; cursor: pointer;
  margin-bottom: 12px; position: relative; transition: border-color .12s, background .12s;
}
.drop:hover, .drop.over { border-color: var(--accent); background: rgba(240,180,41,.04); }
.drop-main { font-size: 13px; }
.drop-main u { text-decoration-color: var(--accent); text-underline-offset: 3px; }
.drop-sub { font-size: 11px; color: var(--faint); }
.progress { position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: var(--line); border-radius: 0 0 8px 8px; overflow: hidden; }
.progress span { display: block; height: 100%; width: 0; background: var(--accent); transition: width .15s; }
.files li { display: flex; align-items: center; gap: 12px; padding: 8px 6px; border-radius: 6px; }
.files li:hover { background: var(--panel-2); }
.ext {
  font: 500 10px/1 var(--mono); text-transform: uppercase; width: 38px; flex: none; text-align: center;
  padding: 5px 0; border-radius: 4px; background: var(--bg); border: 1px solid var(--line); color: var(--muted);
  overflow: hidden; text-overflow: ellipsis;
}
.file-main { flex: 1; min-width: 0; }
.file-name { color: var(--text); text-decoration: none; display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-name:hover { color: var(--accent); }
.file-meta { font-size: 11px; color: var(--faint); font-family: var(--mono); }
.file-actions { display: flex; gap: 2px; }

/* links */
.link-form { display: flex; gap: 8px; margin-bottom: 12px; }
.link-form #link-url { flex: 2; }
.link-form #link-name { flex: 1; }
.link-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.link-grid .empty { color: var(--faint); font-size: 13px; padding: 6px 2px; grid-column: 1 / -1; }
.link-tile {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px; min-width: 0; position: relative;
  border: 1px solid var(--line); border-radius: 8px; background: var(--panel-2);
  color: var(--text); text-decoration: none; transition: border-color .12s, background .12s;
}
.link-tile:hover { border-color: var(--accent); background: #1e2025; }
.link-ico { width: 22px; height: 22px; border-radius: 5px; flex: none; object-fit: contain; }
.link-ico.letter {
  display: grid; place-items: center; font: 600 12px var(--mono);
  background: hsl(var(--h) 38% 20%); color: hsl(var(--h) 80% 74%);
}
.link-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; outline: none; border-radius: 3px; }
.link-name[contenteditable=true] { background: var(--bg); box-shadow: 0 0 0 1px var(--line-2); padding: 0 3px; }
.link-del {
  display: none; position: absolute; top: -8px; right: -8px; width: 20px; height: 20px; border-radius: 50%;
  background: var(--bad); color: #fff; border: 0; cursor: pointer; place-items: center; padding: 0;
}
.links-card.editing .link-tile { border-style: dashed; cursor: text; }
.links-card.editing .link-tile:hover { border-color: var(--line-2); background: var(--panel-2); }
.links-card.editing .link-del { display: grid; }
.links-card.editing #link-edit { color: var(--accent); }

/* notes */
.notes {
  flex: 1; min-height: 260px; font-family: var(--mono); font-size: 13px; line-height: 1.6;
  resize: none; background: var(--bg);
}

/* drag overlay */
.drag-overlay {
  position: fixed; inset: 0; z-index: 50; background: rgba(13,14,16,.85);
  display: grid; place-items: center; pointer-events: none;
}
.drag-overlay span { font: 500 18px var(--mono); border: 2px dashed var(--accent); padding: 30px 50px; border-radius: 12px; color: var(--accent); }

/* ---------- drawer ---------- */
.scrim { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; }
.drawer {
  position: fixed; top: 0; right: 0; bottom: 0; width: min(460px, 100vw); z-index: 41;
  background: var(--panel); border-left: 1px solid var(--line); display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform .2s ease; visibility: hidden;
}
.drawer.open { transform: none; visibility: visible; }
.drawer-head { display: flex; justify-content: space-between; align-items: center; padding: 18px 20px; border-bottom: 1px solid var(--line); }
.drawer-head h2 { margin: 0; font: 500 14px var(--mono); }
.drawer-body { overflow-y: auto; padding: 6px 20px 30px; }
.ctl-section { padding: 16px 0; border-bottom: 1px solid var(--line); }
.ctl-section:last-child { border-bottom: 0; }
.ctl-title { font: 500 11px var(--mono); color: var(--faint); letter-spacing: .08em; margin-bottom: 10px; display: flex; justify-content: space-between; }
.ctl-row { display: flex; align-items: center; justify-content: space-between; gap: 14px; padding: 8px 0; }
.ctl-row div { display: flex; flex-direction: column; min-width: 0; }
.ctl-row b { font-weight: 500; font-size: 13px; }
.ctl-row span { font-size: 12px; color: var(--muted); }
.health { display: grid; gap: 6px; }
.health-row { display: flex; align-items: center; gap: 10px; font-size: 13px; }
.health-row .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--ok); flex: none; }
.health-row .dot.bad { background: var(--bad); }
.health-row .detail { margin-left: auto; font-family: var(--mono); font-size: 11px; color: var(--muted); }
.health-meta { font: 11px var(--mono); color: var(--faint); margin-top: 8px; line-height: 1.7; }
.backups { font: 11px var(--mono); color: var(--faint); margin-top: 6px; }
.backups div { display: flex; justify-content: space-between; padding: 2px 0; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { border: 1px solid var(--line-2); background: var(--panel-2); border-radius: 999px; padding: 5px 12px; font-size: 12px; cursor: pointer; }
.chip:hover { border-color: var(--bad); color: var(--bad); }

/* ---------- confirm ---------- */
.confirm {
  background: var(--panel); color: var(--text); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 22px; width: min(400px, calc(100vw - 32px));
}
.confirm::backdrop { background: rgba(0,0,0,.6); }
.confirm h3 { margin: 0 0 8px; font-size: 16px; font-weight: 600; }
.confirm p { margin: 0 0 16px; color: var(--muted); font-size: 13px; }
.confirm input { margin-bottom: 16px; font-family: var(--mono); }

/* ---------- toasts ---------- */
.toasts { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); display: grid; gap: 8px; z-index: 60; }
.toast {
  background: var(--text); color: var(--bg); padding: 8px 14px; border-radius: 7px; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0,0,0,.4); animation: up .18s ease; transition: opacity .3s, transform .3s;
}
.toast.err { background: var(--bad); color: #fff; }
.toast.out { opacity: 0; transform: translateY(6px); }
@keyframes up { from { opacity: 0; transform: translateY(8px); } }

/* ---------- login ---------- */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login {
  width: min(340px, 100%); background: var(--panel); border: 1px solid var(--line);
  border-radius: 12px; padding: 26px; display: grid; gap: 14px;
}
.login .wordmark { margin-bottom: 4px; }
.login .btn { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; padding: 9px; }
.login .err { color: var(--bad); font-size: 12px; min-height: 16px; }
