:root {
  --bg: #0f1012;
  --panel: #17181b;
  --panel-2: #1e2024;
  --line: #2a2d32;
  --text: #e8e6e3;
  --muted: #9a9890;
  --accent: #d9a46b;
  --accent-ink: #1a1208;
  --ok: #7cc49a;
  --warn: #e6b450;
  --bad: #e07a6e;
  --radius: 10px;
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 14px/1.5 var(--font); }
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin: 0 0 12px; font-weight: 600; letter-spacing: -0.01em; }
h1 { font-size: 22px; } h2 { font-size: 17px; } h3 { font-size: 14px; color: var(--muted); text-transform: uppercase; letter-spacing: .06em; }
small, .muted { color: var(--muted); }
code { font-family: var(--mono); font-size: 12px; background: var(--panel-2); padding: 1px 5px; border-radius: 4px; }

.layout { display: grid; grid-template-columns: 220px 1fr; min-height: 100vh; }
.side { border-right: 1px solid var(--line); padding: 20px 14px; position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 4px; }
.brand { font-weight: 700; font-size: 15px; margin: 0 8px 18px; display: flex; align-items: center; gap: 8px; }
.brand i { width: 10px; height: 10px; border-radius: 50%; background: var(--accent); display: inline-block; }
.nav a { display: flex; justify-content: space-between; padding: 8px 10px; border-radius: 8px; color: var(--text); }
.nav a:hover { background: var(--panel); text-decoration: none; }
.nav a.on { background: var(--panel-2); }
.nav .badge { background: var(--accent); color: var(--accent-ink); border-radius: 999px; font-size: 11px; padding: 0 7px; font-weight: 700; }
.side .bottom { margin-top: auto; }
main { padding: 24px 28px 60px; max-width: 1280px; width: 100%; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.between { justify-content: space-between; }
.grid { display: grid; gap: 14px; }
.cards { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; }
.card.click { cursor: pointer; transition: border-color .15s; }
.card.click:hover { border-color: #3a3e45; }
.stack > * + * { margin-top: 12px; }

.btn { appearance: none; border: 1px solid var(--line); background: var(--panel-2); color: var(--text); padding: 7px 12px; border-radius: 8px; font: inherit; cursor: pointer; white-space: nowrap; }
.btn:hover { border-color: #444; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 4px 9px; font-size: 12px; }
.btn:disabled { opacity: .45; cursor: not-allowed; }

input, textarea, select { width: 100%; background: var(--bg); color: var(--text); border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; font: inherit; }
textarea { min-height: 70px; resize: vertical; }
input:focus, textarea:focus, select:focus { outline: none; border-color: var(--accent); }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.field { margin-bottom: 12px; }
.form2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 16px; }
.form2 .wide { grid-column: 1 / -1; }
.hint { font-size: 12px; color: var(--muted); margin-top: 3px; }

.tabs { display: flex; gap: 2px; border-bottom: 1px solid var(--line); margin: 6px 0 18px; }
.tabs a { padding: 8px 14px; color: var(--muted); border-bottom: 2px solid transparent; margin-bottom: -1px; }
.tabs a.on { color: var(--text); border-color: var(--accent); }
.tabs a:hover { text-decoration: none; color: var(--text); }

.pill { display: inline-block; font-size: 11px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); }
.pill.ok { color: var(--ok); border-color: #2f5a41; }
.pill.warn { color: var(--warn); border-color: #5c4a22; }
.pill.bad { color: var(--bad); border-color: #5e2f2a; }
.pill.acc { color: var(--accent); border-color: #5c4630; }

.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.thumb { position: relative; border-radius: 8px; overflow: hidden; background: var(--panel-2); border: 2px solid transparent; aspect-ratio: 3/4; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb.sel { border-color: var(--accent); }
.thumb.dim img { opacity: .35; }
.thumb .meta { position: absolute; left: 6px; bottom: 6px; right: 6px; display: flex; justify-content: space-between; gap: 4px; }
.thumb .meta .pill { background: rgba(0,0,0,.65); }
.thumb .acts { position: absolute; top: 6px; right: 6px; display: flex; gap: 4px; opacity: 0; transition: opacity .15s; }
.thumb:hover .acts { opacity: 1; }
.thumb .acts .btn { background: rgba(0,0,0,.7); }
.thumb .acts .btn.primary { background: var(--accent); color: var(--accent-ink); }
@media (hover: none) { .thumb .acts { opacity: 1; } }

.post { display: grid; grid-template-columns: 1fr 340px; gap: 18px; }
.post .imgs { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.post .imgs .thumb { cursor: pointer; }
.post .side-info .caption { white-space: pre-wrap; background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; min-height: 60px; }
.post-head { display: flex; justify-content: space-between; align-items: baseline; gap: 10px; margin-bottom: 10px; }

.steps { counter-reset: s; }
.step { position: relative; padding-left: 40px; }
.step::before { counter-increment: s; content: counter(s); position: absolute; left: 0; top: 0; width: 26px; height: 26px; border-radius: 50%; background: var(--panel-2); border: 1px solid var(--line); display: grid; place-items: center; font-weight: 700; font-size: 12px; }
.step.done::before { content: "✓"; color: var(--ok); border-color: #2f5a41; }

.toast { position: fixed; right: 18px; bottom: 18px; background: var(--panel-2); border: 1px solid var(--line); padding: 10px 14px; border-radius: 8px; max-width: 420px; z-index: 50; box-shadow: 0 8px 24px rgba(0,0,0,.4); }
.toast.err { border-color: #5e2f2a; color: var(--bad); }

.login { min-height: 100vh; display: grid; place-items: center; }
.login .card { width: 320px; }
.empty { text-align: center; color: var(--muted); padding: 40px 10px; }
.kv { display: grid; grid-template-columns: 160px 1fr; gap: 6px 12px; }
.kv div:nth-child(odd) { color: var(--muted); }
table { width: 100%; border-collapse: collapse; }
td, th { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; }
th { color: var(--muted); font-weight: 500; font-size: 12px; }

.lightbox { position: fixed; inset: 0; background: rgba(0,0,0,.85); display: grid; place-items: center; z-index: 60; cursor: zoom-out; }
.lightbox img { max-width: 92vw; max-height: 92vh; border-radius: 8px; }

@media (max-width: 860px) {
  .layout { grid-template-columns: 1fr; }
  .side { position: static; height: auto; flex-direction: row; flex-wrap: wrap; padding: 10px 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .brand { margin: 0 12px 0 0; width: 100%; }
  .nav { display: flex; flex-wrap: wrap; gap: 2px; }
  .nav a { padding: 6px 10px; gap: 6px; }
  .side .bottom { margin: 0; }
  main { padding: 16px; }
  .post { grid-template-columns: 1fr; }
  .post .imgs { grid-template-columns: repeat(2, 1fr); }
  .form2 { grid-template-columns: 1fr; }
}

/* fix: settings layout */
.pill { white-space: nowrap; }
.kv { grid-template-columns: minmax(110px, max-content) 1fr; gap: 8px 14px; align-items: center; }
.card code { display: inline-block; max-width: 100%; overflow-wrap: anywhere; white-space: normal; }

/* ---- світла тема ---- */
[data-theme="light"] {
  --bg: #f6f5f2; --panel: #ffffff; --panel-2: #efede8; --line: #d9d6cf;
  --text: #1c1b19; --muted: #6b6860; --accent: #b87a33; --accent-ink: #ffffff;
  --ok: #2f8f58; --warn: #a87612; --bad: #c0463a;
  color-scheme: light;
}
[data-theme="light"] .card.click:hover, [data-theme="light"] .btn:hover { border-color: #b5b1a8; }
[data-theme="light"] .pill.ok { border-color: #9fd0b3; }
[data-theme="light"] .pill.warn { border-color: #e2cd94; }
[data-theme="light"] .pill.bad { border-color: #e4aaa3; }
[data-theme="light"] .pill.acc { border-color: #e0c19a; }
[data-theme="light"] .toast { box-shadow: 0 8px 24px rgba(0,0,0,.15); }
.theme-toggle { position: fixed; left: 14px; bottom: 14px; z-index: 40; font-size: 12px; padding: 5px 10px; opacity: .85; }
.theme-toggle:hover { opacity: 1; }

.thumbs .thumb .acts { opacity: 1; }
.thumbs .thumb .acts .btn.danger { background: rgba(180,40,40,.9); color: #fff; }

/* кнопки на вузьких мініатюрах не обрізаються */
.thumbs .thumb .acts { flex-wrap: wrap; justify-content: flex-end; left: 6px; right: 6px; top: 6px; }
.thumbs .thumb .acts .btn { padding: 3px 7px; }
