:root {
  --bg: #f6f6f4; --surface: #ffffff; --surface-2: #f0f0ed; --text: #1b1b1a; --muted: #6a6a66;
  --line: #e3e3df; --accent: #b0276f; --accent-soft: #fbeaf3; --on-accent: #ffffff;
  --ok: #17703a; --ok-soft: #e4f4ea; --bad: #b3261e; --bad-soft: #fcebe9; --warn: #8a5a00; --warn-soft: #fbf1dc;
  --radius: 10px; --shadow: 0 1px 2px rgb(0 0 0 / .05);
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141413; --surface: #1e1e1c; --surface-2: #2a2a27; --text: #f1f1ee; --muted: #a3a39d;
    --line: #33332f; --accent: #e9619f; --accent-soft: #3b1a2b; --on-accent: #1a0c13;
    --ok: #5fcf8a; --ok-soft: #17301f; --bad: #ff8a80; --bad-soft: #3b1b18; --warn: #e5b95c; --warn-soft: #362a12;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
h1 { font-size: 22px; line-height: 1.25; margin: 0; letter-spacing: -.01em; }
h2 { font-size: 15px; margin: 0; }
p { margin: 0; }
a { color: var(--accent); }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.shell { display: grid; grid-template-columns: 224px minmax(0, 1fr); min-height: 100vh; }
.sidebar { position: sticky; top: 0; height: 100vh; display: flex; flex-direction: column; gap: 16px; padding: 16px 12px; background: var(--surface); border-right: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; padding: 4px 8px; font-weight: 650; color: var(--text); text-decoration: none; }
.brand-mark { width: 20px; height: 20px; border-radius: 6px; background: var(--accent); }
#nav { display: grid; gap: 2px; flex: 1; align-content: start; }
.nav-link { display: flex; align-items: center; gap: 10px; width: 100%; padding: 8px; border: 0; border-radius: 8px; background: none; color: var(--muted); font: inherit; font-weight: 500; text-decoration: none; cursor: pointer; }
.nav-link svg { flex: none; }
.nav-link:hover { background: var(--surface-2); color: var(--text); }
.nav-link[aria-current="page"] { background: var(--accent-soft); color: var(--accent); }

#view { padding: 28px 32px 64px; max-width: 1120px; width: 100%; margin: 0 auto; outline: none; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 20px; }
.page-head p { color: var(--muted); }
.stack { display: grid; gap: 16px; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.panel-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.two-col { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }

.stats { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.stat { display: block; color: inherit; text-decoration: none; }
.stat:hover { border-color: var(--muted); }
.stat-value { font-size: 28px; font-weight: 650; line-height: 1.2; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: 13px; }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-weight: 550; text-decoration: none; cursor: pointer; white-space: nowrap; }
.btn:hover { background: var(--surface-2); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn.primary:hover { filter: brightness(1.08); }
.btn.danger { color: var(--bad); }
.btn.small { padding: 4px 10px; font-size: 13px; }
.btn:disabled { opacity: .55; cursor: not-allowed; }

.field { display: grid; gap: 4px; font-weight: 550; font-size: 14px; }
.hint { color: var(--muted); font-size: 13px; font-weight: 400; }
input[type="text"], input[type="search"], input[type="password"], input[type="number"], input[type="datetime-local"], textarea {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--surface); color: var(--text); font: inherit; font-weight: 400;
}
textarea { resize: vertical; }
input[type="checkbox"], input[type="radio"] { accent-color: var(--accent); width: 16px; height: 16px; margin: 0; flex: none; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; }

.badge { display: inline-block; padding: 1px 8px; border-radius: 99px; font-size: 12px; font-weight: 600; background: var(--surface-2); color: var(--muted); white-space: nowrap; }
.badge.ok { background: var(--ok-soft); color: var(--ok); }
.badge.bad { background: var(--bad-soft); color: var(--bad); }
.badge.warn { background: var(--warn-soft); color: var(--warn); }
.badge.accent { background: var(--accent-soft); color: var(--accent); }
.text-bad { color: var(--bad); font-size: 14px; }

.list { display: grid; }
.list-row { display: flex; align-items: center; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); min-width: 0; }
.list-row:first-child { border-top: 0; }
.list-main { flex: 1; min-width: 0; }
.truncate { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty { padding: 24px 8px; text-align: center; color: var(--muted); }

.checklist { display: grid; gap: 4px; }
.check-step { display: flex; align-items: center; gap: 10px; padding: 8px; border-radius: 8px; color: var(--text); text-decoration: none; }
a.check-step:hover { background: var(--surface-2); }
.check-dot { flex: none; width: 20px; height: 20px; border-radius: 50%; border: 2px solid var(--line); display: grid; place-items: center; font-size: 12px; font-weight: 700; }
.check-step.done { color: var(--muted); }
.check-step.done .check-dot { border-color: var(--ok); background: var(--ok); color: var(--surface); }

.dropzone { display: block; padding: 32px 16px; text-align: center; border: 1.5px dashed var(--line); border-radius: var(--radius); background: var(--surface); cursor: pointer; }
.dropzone:hover, .dropzone.over { border-color: var(--accent); background: var(--accent-soft); }
.dropzone strong { display: block; }
.progress-row { display: grid; gap: 4px; padding: 8px 0; font-size: 14px; }
progress { width: 100%; height: 6px; accent-color: var(--accent); }
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.media-card { display: flex; flex-direction: column; overflow: hidden; padding: 0; }
.thumb { display: block; width: 100%; aspect-ratio: 9 / 13; object-fit: cover; background: var(--surface-2); }
.media-body { display: grid; gap: 8px; padding: 10px; }
.media-actions { display: flex; gap: 6px; }
.media-actions .btn:first-child { flex: 1; }

.compose { display: grid; grid-template-columns: 240px minmax(0, 1fr); gap: 16px; align-items: start; }
.compose-preview { position: sticky; top: 16px; padding: 0; overflow: hidden; }
.compose-preview video, .compose-preview img { display: block; width: 100%; max-height: 420px; object-fit: contain; background: #000; }
.compose-preview p { padding: 10px; font-size: 13px; }
.option-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.option { display: flex; gap: 10px; padding: 12px; border: 1px solid var(--line); border-radius: var(--radius); cursor: pointer; }
.option:has(input:checked) { border-color: var(--accent); background: var(--accent-soft); }
.option:has(input:disabled) { opacity: .55; cursor: not-allowed; }
.option strong { display: block; }
.page-picks { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px; max-height: 280px; overflow-y: auto; padding: 2px; }
.page-pick { padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; min-width: 0; }
.page-pick span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.page-pick:has(input:checked) { border-color: var(--accent); }
.toolbar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.toolbar input[type="search"] { flex: 1; min-width: 160px; }
.submit-bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 12px; }
.inset { padding-left: 24px; display: grid; gap: 8px; margin-top: 8px; }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 12px; }
.tab { padding: 5px 12px; border: 0; border-radius: 99px; background: none; color: var(--muted); font: inherit; font-size: 14px; font-weight: 550; cursor: pointer; }
.tab[aria-pressed="true"] { background: var(--surface-2); color: var(--text); }
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th { text-align: left; padding: 6px 10px; color: var(--muted); font-size: 12px; font-weight: 600; border-bottom: 1px solid var(--line); white-space: nowrap; }
td { padding: 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
tr:last-child td { border-bottom: 0; }
td.nowrap { white-space: nowrap; }
.error-detail { display: block; margin-top: 4px; color: var(--bad); font-size: 13px; max-width: 340px; }

.avatar { flex: none; width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 650; text-transform: uppercase; }
.page-row { display: grid; gap: 8px; padding: 12px 0; border-top: 1px solid var(--line); }
.page-row:first-child { border-top: 0; padding-top: 0; }
.page-row-head { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.page-info { flex: 1; min-width: 180px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 6px; }
details summary { cursor: pointer; color: var(--muted); font-size: 14px; }
details[open] summary { margin-bottom: 8px; }

.copy-row { display: flex; gap: 6px; }
.copy-row input { font-family: ui-monospace, Menlo, monospace; font-size: 13px; }

.guide { max-width: 760px; }
.guide h1 { margin-bottom: 8px; }
.guide h2 { font-size: 18px; margin: 28px 0 8px; }
.guide h3 { font-size: 15px; margin: 16px 0 4px; }
.guide p, .guide ol, .guide ul { margin: 0 0 10px; }
.guide li { margin-bottom: 4px; }
.guide code { padding: 1px 5px; border-radius: 4px; background: var(--surface-2); font-size: 13px; overflow-wrap: anywhere; }
.guide .note { padding: 10px 12px; border-radius: 8px; background: var(--warn-soft); margin-bottom: 10px; }

#toasts { position: fixed; right: 16px; bottom: 16px; left: 16px; display: grid; justify-items: end; gap: 8px; pointer-events: none; z-index: 10; }
.toast { max-width: 420px; padding: 10px 14px; border-radius: 8px; background: var(--text); color: var(--bg); font-size: 14px; box-shadow: 0 4px 16px rgb(0 0 0 / .2); }
.toast.bad { background: var(--bad); color: #fff; }
dialog { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); color: var(--text); padding: 16px; max-width: min(400px, calc(100vw - 32px)); }
dialog::backdrop { background: rgb(0 0 0 / .4); }
dialog .actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

.login-page { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: 100%; max-width: 360px; display: grid; gap: 14px; }
.doc-page { padding: 32px 16px; display: grid; justify-content: center; }

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar { position: static; height: auto; flex-direction: row; align-items: center; gap: 8px; padding: 8px 12px; border-right: 0; border-bottom: 1px solid var(--line); overflow-x: auto; }
  .brand { font-size: 0; gap: 0; padding: 4px; }
  #nav { display: flex; flex: none; }
  .nav-link { width: auto; white-space: nowrap; }
  .nav-link svg { display: none; }
  #view { padding: 16px 16px 48px; }
  .stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .two-col, .compose { grid-template-columns: minmax(0, 1fr); }
  .compose-preview { position: static; }
  .compose-preview video, .compose-preview img { max-height: 240px; }
}
@media (max-width: 480px) {
  .option-cards { grid-template-columns: minmax(0, 1fr); }
  .media-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
