:root {
  --bg: #ffffff;
  --text: #0f0f0f;
  --body-text: #2a2a2a;
  --muted: #6b6b6b;
  --muted2: #9b9b9b;
  --border: #e8e8e8;
  --accent: #0f0f0f;
  --accent-text: #ffffff;
  --danger: #b42318;
  --surface: #fafafa;
  --sans: 'Inter', ui-sans-serif, system-ui, -apple-system, Helvetica, Arial, sans-serif;
}

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

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

.wrap { max-width: 920px; margin: 0 auto; padding: 0 20px; }

/* ── Header ── */
header.site {
  border-bottom: 1px solid var(--border);
  position: sticky; top: 0; background: var(--bg); z-index: 10;
}
header.site .wrap {
  display: flex; align-items: center; gap: 20px;
  height: 64px;
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; letter-spacing: -0.01em; font-size: 16px; color: var(--text); text-decoration: none; }
.brand-mark { width: 18px; height: 18px; border-radius: 5px; flex: none; background: linear-gradient(135deg, #6f7bff, #9aa6ff); box-shadow: 0 0 12px rgba(124,140,255,0.35); }
.brand-tag { font-size: 10.5px; font-weight: 500; letter-spacing: 0.12em; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 3px 9px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
header.site nav { margin-left: auto; display: flex; align-items: center; gap: 18px; }
header.site nav a { color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 500; }
header.site nav a:hover { color: var(--text); }
.userbox { display: flex; align-items: center; gap: 12px; font-size: 14px; color: var(--muted); }

/* ── Buttons ── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  padding: 10px 16px; border-radius: 8px; font: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; text-decoration: none; transition: background .12s, border-color .12s;
}
.btn:hover { background: var(--surface); }
.btn.primary { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.btn.primary:hover { opacity: .9; }
.btn.danger { color: var(--danger); border-color: #f0c9c4; }
.btn.small { padding: 6px 10px; font-size: 13px; }
.btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Login ── */
.center { min-height: calc(100vh - 64px); display: grid; place-items: center; padding: 40px 20px; }
.card {
  width: 100%; max-width: 420px; border: 1px solid var(--border);
  border-radius: 14px; padding: 32px; background: var(--bg);
}
.card h1 { font-size: 22px; letter-spacing: -0.02em; margin-bottom: 6px; }
.card p.sub { color: var(--muted); font-size: 14px; margin-bottom: 24px; }
.divider { display: flex; align-items: center; gap: 12px; color: var(--muted2); font-size: 12px; margin: 20px 0; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--border); }
label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--body-text); }
input[type=email], input[type=text], textarea, select {
  width: 100%; border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px;
  font: inherit; font-size: 14px; background: var(--bg); color: var(--text);
}
textarea { min-height: 160px; resize: vertical; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 13px; }
.field { margin-bottom: 16px; }
.full { width: 100%; }
.msg { font-size: 13px; margin-top: 12px; min-height: 18px; }
.msg.err { color: var(--danger); }
.msg.ok { color: #2f7a34; }

/* ── Docs list ── */
main { padding: 32px 0 80px; }
.page-title { font-size: 26px; letter-spacing: -0.02em; margin-bottom: 4px; }
.page-sub { color: var(--muted); margin-bottom: 28px; }
.doc-list { display: grid; gap: 10px; }
.doc {
  border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px;
  display: flex; align-items: center; gap: 14px; cursor: pointer; background: var(--bg);
  transition: border-color .12s, background .12s;
}
.doc:hover { border-color: var(--muted2); background: var(--surface); }
.doc .ico { font-size: 18px; width: 24px; text-align: center; }
.doc .meta { flex: 1; min-width: 0; }
.doc .meta .t { font-weight: 600; }
.doc .meta .d { font-size: 13px; color: var(--muted); }
.tag { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
       color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; }
.empty, .loading { color: var(--muted); padding: 40px 0; text-align: center; }

/* ── Doc viewer ── */
.viewer { display: none; }
.viewer.active { display: block; }
.viewer .back { margin-bottom: 18px; }
.prose { max-width: 720px; }
.prose h1, .prose h2, .prose h3 { letter-spacing: -0.01em; margin: 1.4em 0 .5em; }
.prose h1 { font-size: 28px; } .prose h2 { font-size: 22px; } .prose h3 { font-size: 18px; }
.prose p, .prose ul, .prose ol { margin: .7em 0; color: var(--body-text); }
.prose pre { background: var(--surface); border: 1px solid var(--border); border-radius: 8px; padding: 14px; overflow:auto; }
.prose code { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 90%; }
.prose img { max-width: 100%; border-radius: 8px; }
.prose a { color: #1a56db; }

/* ── Admin ── */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; }
.section { border: 1px solid var(--border); border-radius: 12px; padding: 22px; margin-bottom: 22px; }
.section h2 { font-size: 16px; margin-bottom: 14px; }
.row { display: flex; gap: 10px; align-items: flex-end; }
.row .field { flex: 1; margin-bottom: 0; }
.list-item { display: flex; align-items: center; gap: 10px; padding: 10px 0; border-bottom: 1px solid var(--border); font-size: 14px; }
.list-item:last-child { border-bottom: none; }
.list-item .grow { flex: 1; min-width: 0; }
.pill { font-size: 12px; color: var(--muted); }
@media (max-width: 720px) { .grid2 { grid-template-columns: 1fr; } }

/* ── Tabs ── */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 24px; }
.tab {
  border: none; background: none; font: inherit; font-size: 14px; font-weight: 600;
  color: var(--muted); padding: 10px 14px; cursor: pointer; border-bottom: 2px solid transparent;
  margin-bottom: -1px;
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--text); border-bottom-color: var(--accent); }

/* ── Website tab ── */
.publish-bar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  border: 1px solid var(--border); border-radius: 12px; padding: 16px 18px; margin-bottom: 22px;
  background: var(--surface);
}
.publish-bar .grow { flex: 1; min-width: 160px; }
.publish-bar .last { font-size: 13px; color: var(--muted); }
.publish-bar #publishNote { min-width: 220px; padding: 8px 10px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; }
a.btn { text-decoration: none; display: inline-flex; align-items: center; }
.hint { font-size: 13px; color: var(--muted); margin: 0 0 12px; max-width: 70ch; }
.subhead { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
           color: var(--muted2); margin: 4px 0 12px; }
.status-draft { color: #9a6700; }
.status-published { color: #2f7a34; }
.preview-pane {
  border: 1px dashed var(--border); border-radius: 8px; padding: 16px; margin-top: 12px;
  max-height: 360px; overflow: auto;
}
.preview-pane:empty::before { content: "Preview appears here."; color: var(--muted2); font-size: 13px; }
.video-embed { position: relative; width: 100%; padding-top: 56.25%; margin: 8px 0; border-radius: 6px; overflow: hidden; background: #000; }
.video-embed iframe, .video-embed video { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; }
.row-actions { display: flex; gap: 6px; }

.hidden { display: none !important; }
