:root {
  --bg: #0a0a0a;
  --surface: #141414;
  --surface2: #1a1a1a;
  --border: #262626;
  --accent: #3b82f6;
  --accent-dim: rgba(59,130,246,0.15);
  --text: #e5e5e5;
  --text2: #a3a3a3;
  --text3: #737373;
  --green: #22c55e;
  --yellow: #eab308;
  --red: #ef4444;
  --orange: #f97316;
  --purple: #a855f7;
}
* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}
[hidden] { display: none !important; }

/* ── Layout ── */
.app { display: flex; min-height: 100vh; }

/* ── Sidebar ── */
.sidebar {
  width: 280px; flex-shrink: 0;
  background: var(--surface); border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  position: fixed; top: 0; left: 0; bottom: 0; z-index: 200;
}
.sidebar-header { padding: 20px 16px 12px; border-bottom: 1px solid var(--border); }
.sidebar-header h2 { font-size: 15px; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.sidebar-header h2 a { color: var(--text3); text-decoration: none; font-size: 12px; font-weight: 400; }
.sidebar-header h2 a:hover { color: var(--accent); }
.sidebar-sub { font-size: 11px; color: var(--text3); margin-top: 2px; }
.sidebar-select { width: 100%; margin-top: 12px; font-size: 12px; }
.summary-btn {
  width: 100%; margin-top: 8px; padding: 7px 10px;
  background: var(--surface2); border: 1px solid var(--border); border-radius: 8px;
  color: var(--text2); font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit;
}
.summary-btn:hover { border-color: var(--accent); color: var(--text); }
.summary-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.sidebar-search { padding: 10px 12px 6px; }
.sidebar-search input {
  width: 100%; padding: 8px 12px; background: var(--bg);
  border: 1px solid var(--border); border-radius: 8px;
  color: var(--text); font-size: 13px; outline: none;
}
.sidebar-search input:focus { border-color: var(--accent); }
.sidebar-search input::placeholder { color: var(--text3); }
.sidebar-filters { padding: 4px 12px 8px; display: flex; gap: 4px; flex-wrap: wrap; }
.filter-btn {
  padding: 3px 10px; border: 1px solid var(--border); background: transparent;
  border-radius: 14px; font-size: 10px; font-weight: 600; color: var(--text3);
  cursor: pointer; text-transform: uppercase; letter-spacing: 0.4px; transition: all 0.15s;
}
.filter-btn:hover { border-color: var(--accent); color: var(--text2); }
.filter-btn.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.filter-btn .n { opacity: 0.7; margin-left: 4px; font-weight: 500; }
.sidebar-list { flex: 1; overflow-y: auto; padding: 4px 8px 16px; }
.sidebar-empty { padding: 30px 12px; text-align: center; color: var(--text3); font-size: 12px; }
.sidebar-client {
  display: flex; align-items: center; gap: 10px; padding: 10px 12px;
  border-radius: 10px; cursor: pointer; transition: all 0.12s; border: 1px solid transparent;
}
.sidebar-client:hover { background: var(--surface2); }
.sidebar-client.active { background: var(--accent-dim); border-color: var(--accent); }
.sidebar-avatar {
  width: 36px; height: 36px; border-radius: 8px; background: var(--surface2);
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  font-size: 12px; font-weight: 700; color: var(--text3); overflow: hidden;
}
.sidebar-avatar img { width: 100%; height: 100%; object-fit: contain; padding: 3px; background: #4b4b4b; }
.sidebar-info { min-width: 0; }
.sidebar-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-meta { font-size: 11px; color: var(--text3); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.sidebar-dot { margin-left: auto; flex-shrink: 0; width: 8px; height: 8px; border-radius: 50%; background: var(--text3); }
.sidebar-dot.pending_review { background: var(--yellow); }
.sidebar-dot.approved { background: var(--green); }
.sidebar-dot.rejected { background: var(--red); }
.sidebar-dot.failed { background: var(--orange); }
.sidebar-dot.published, .sidebar-dot.publishing { background: var(--accent); }
.sidebar-foot { border-top: 1px solid var(--border); padding: 10px 12px 8px; }
.sidebar-foot .btn { width: 100%; }
.sidebar-count { padding-top: 6px; font-size: 11px; color: var(--text3); text-align: center; }

/* ── Main panel ── */
.main { flex: 1; margin-left: 280px; min-width: 0; display: flex; flex-direction: column; min-height: 100vh; }
.main > section { flex: 1; display: flex; flex-direction: column; }
#template-editor { flex: 1; display: flex; flex-direction: column; }
.main-empty { padding: 120px 20px; text-align: center; color: var(--text3); font-size: 14px; }
.page-hint { font-size: 13px; color: var(--text3); margin-bottom: 16px; }
.notice {
  margin: 16px 30px 0; padding: 9px 14px;
  background: rgba(234,179,8,0.08); border: 1px solid rgba(234,179,8,0.3);
  border-radius: 8px; font-size: 12px; color: var(--yellow);
}
.detail-scroll { flex: 1; padding: 22px 30px 30px; max-width: 1240px; width: 100%; }
.detail-footer {
  position: sticky; bottom: 0; z-index: 50;
  border-top: 1px solid var(--border); background: var(--surface);
  padding: 12px 30px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.detail-footer .spacer { flex: 1; }
.detail-footer .field-inline { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--text3); }
.detail-footer .input { width: 210px; }
.post-pills { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 14px; }
.back-btn { background: none; border: none; color: var(--text3); font-size: 12px; cursor: pointer; margin-bottom: 10px; font-family: inherit; padding: 0; }
.back-btn:hover { color: var(--accent); }

/* ── Hamburger (hidden on desktop) ── */
.hamburger {
  display: none; position: fixed; top: 12px; right: 12px; z-index: 310;
  width: 36px; height: 36px; background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; cursor: pointer; flex-direction: column; align-items: center; justify-content: center;
  gap: 4px; padding: 0;
}
.hamburger span { display: block; width: 18px; height: 2px; background: var(--text); border-radius: 1px; transition: all 0.2s; }
.hamburger.open span:nth-child(1) { transform: rotate(45deg) translate(4px, 4px); }
.hamburger.open span:nth-child(2) { opacity: 0; }
.hamburger.open span:nth-child(3) { transform: rotate(-45deg) translate(4px, -4px); }
.sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.6); z-index: 190; }

.select, .input, .textarea {
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  border-radius: 6px; padding: 7px 10px; font-size: 13px; font-family: inherit; width: 100%;
}
.select { width: auto; }
.select:focus, .input:focus, .textarea:focus { outline: none; border-color: var(--accent); }
.textarea { resize: vertical; min-height: 110px; line-height: 1.5; }
.textarea.code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px;
  white-space: pre; overflow: auto; tab-size: 2;
}

/* ── Buttons ── */
.btn {
  padding: 7px 16px; border-radius: 7px; font-size: 13px; font-weight: 600;
  cursor: pointer; border: none; transition: all 0.15s; white-space: nowrap; font-family: inherit;
}
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover:not(:disabled) { opacity: 0.9; }
.btn-secondary { background: var(--surface2); color: var(--text2); border: 1px solid var(--border); }
.btn-secondary:hover:not(:disabled) { background: var(--border); }
.btn-sm { padding: 3px 10px; font-size: 11px; border-radius: 5px; }
.btn-danger { background: rgba(239,68,68,0.12); color: var(--red); }
.btn-danger:hover:not(:disabled) { background: rgba(239,68,68,0.22); }
.btn-success { background: rgba(34,197,94,0.14); color: var(--green); }
.btn-success:hover:not(:disabled) { background: rgba(34,197,94,0.24); }

/* ── Scaled design frames ── */
.frame {
  position: relative; width: 100%; overflow: hidden; border-radius: 6px;
  background: #000; border: 1px solid var(--border);
}
.frame iframe { position: absolute; top: 0; left: 0; border: 0; transform-origin: 0 0; background: #fff; }
.frame.static iframe { pointer-events: none; }

.detail-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 6px; }
.detail-head h2 { font-size: 20px; font-weight: 700; line-height: 1.3; }
.detail-sub { font-size: 12px; color: var(--text3); display: flex; gap: 8px; align-items: center; flex-wrap: wrap; margin-bottom: 18px; }

.alert {
  border-radius: 8px; padding: 10px 14px; font-size: 12px; margin-bottom: 16px;
  background: rgba(239,68,68,0.08); border: 1px solid rgba(239,68,68,0.3); color: #fca5a5;
}
.alert ul { margin: 4px 0 0 18px; }
.alert.info { background: var(--accent-dim); border-color: rgba(59,130,246,0.35); color: #93c5fd; }

.section { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 16px 18px; margin-bottom: 14px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.section-head h3 { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.6px; color: var(--text2); }
.section-hint { font-size: 12px; color: var(--text3); }

.design-grid { display: grid; grid-template-columns: 1.25fr 1fr; gap: 16px; align-items: start; }
.design-grid.single { grid-template-columns: minmax(0, 560px); }
.design-label { font-size: 11px; font-weight: 600; color: var(--text3); margin-bottom: 6px; display: flex; justify-content: space-between; align-items: center; }
.design-source { margin-top: 8px; }
.design-source .textarea { min-height: 260px; }

.field { margin-bottom: 12px; }
.field:last-child { margin-bottom: 0; }
.field label { display: flex; justify-content: space-between; font-size: 11px; font-weight: 600; color: var(--text3); margin-bottom: 4px; }
.field label .counter.over { color: var(--orange); }
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.caption-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; }
.caption-grid .textarea { min-height: 240px; }

.article-frame { width: 100%; height: 560px; border: 1px solid var(--border); border-radius: 6px; background: #fff; display: block; }

/* ── Templates ── */
.template-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 14px; }
.template-card { background: var(--surface); border: 1px solid var(--border); border-radius: 10px; padding: 12px; }
.template-card h4 { font-size: 13px; font-weight: 700; margin-bottom: 2px; }
.template-card .slug { font-size: 11px; color: var(--text3); margin-bottom: 10px; }
.template-pair { display: grid; grid-template-columns: 1.4fr 1fr; gap: 8px; align-items: end; }
.template-variant { cursor: pointer; }
.template-variant .frame { transition: border-color 0.15s; }
.template-variant:hover .frame { border-color: var(--accent); }
.template-variant .cap { font-size: 10px; color: var(--text3); margin-top: 4px; text-transform: uppercase; letter-spacing: 0.5px; }

.editor-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; align-items: start; }
.editor-grid .textarea.code { min-height: 640px; height: calc(100vh - 300px); }
.sample-row { display: flex; gap: 12px; flex-wrap: wrap; margin-top: 10px; }
.sample-row .field { margin: 0; }
.sample-row input[type=color] { width: 44px; height: 30px; padding: 0; border: 1px solid var(--border); background: none; border-radius: 4px; cursor: pointer; }
.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 10px; }
.chip { font-family: ui-monospace, Menlo, monospace; font-size: 10px; padding: 1px 7px; border-radius: 4px; background: var(--surface2); border: 1px solid var(--border); color: var(--text2); }

/* ── Toast ── */
.toast {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface2); border: 1px solid var(--border); color: var(--text);
  padding: 10px 20px; border-radius: 8px; font-size: 13px; z-index: 400;
  opacity: 0; pointer-events: none; transition: all 0.2s; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.error { border-color: var(--red); color: #fca5a5; }

@media (max-width: 1100px) {
  .design-grid, .caption-grid, .editor-grid, .article-grid, .image-editor-grid, .kw-grid, .client-grid, .social-grid { grid-template-columns: 1fr; }
  .image-preview-col { position: static; order: -1; }
  .links-panel { height: auto; max-height: 420px; }
  .editor-grid .textarea.code { height: 420px; min-height: 0; }
}
@media (max-width: 768px) {
  .hamburger { display: flex; }
  .sidebar { transform: translateX(-100%); transition: transform 0.25s ease; }
  .sidebar.open { transform: translateX(0); }
  .sidebar-overlay.open { display: block; }
  .main { margin-left: 0; }
  .notice { margin: 60px 16px 0; }
  .field-grid { grid-template-columns: 1fr; }
  .detail-scroll { padding: 16px; }
  .detail-footer { padding: 10px 16px; }
}

/* ── Image editor ── */
.detail-scroll.wide { max-width: 1500px; }
.image-editor-grid { display: grid; grid-template-columns: minmax(320px, 440px) 1fr; gap: 20px; align-items: start; }
.image-preview-col { position: sticky; top: 16px; }
.textarea.short { min-height: 0; }
.size-input { width: 64px !important; padding: 2px 6px; font-size: 11px; display: inline-block; margin-left: 4px; }
.field-note { font-size: 11px; color: var(--orange); margin-top: 4px; }
.image-field { display: flex; gap: 10px; align-items: flex-start; }
.image-thumb { width: 72px; height: 54px; object-fit: cover; border-radius: 6px; border: 1px solid var(--border); background: var(--surface2); flex-shrink: 0; }
.image-thumb.logo { object-fit: contain; background: #4b4b4b; padding: 4px; }
.photo-options { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.photo-options img { width: 64px; height: 48px; object-fit: cover; border-radius: 5px; border: 1px solid var(--border); cursor: pointer; }
.photo-options img:hover { border-color: var(--accent); }
.color-field input[type=color] { width: 44px; height: 34px; padding: 0; border: 1px solid var(--border); background: none; border-radius: 4px; cursor: pointer; flex-shrink: 0; }

.nudge { display: flex; align-items: center; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.nudge-label { font-size: 11px; font-weight: 600; color: var(--text3); width: 76px; flex-shrink: 0; }
.nudge-unit { font-size: 11px; color: var(--text3); }
.nudge-btn {
  min-width: 28px; height: 28px; padding: 0 7px; border-radius: 5px; border: 1px solid var(--border);
  background: var(--surface2); color: var(--text2); font-size: 13px; cursor: pointer; font-family: inherit;
}
.nudge-btn:hover { border-color: var(--accent); color: var(--text); }
.nudge-reset { font-size: 11px; margin-left: 2px; }
.nudge-num { width: 62px !important; padding: 4px 6px; font-size: 12px; }
.nudge input[type=range] { flex: 1; min-width: 80px; accent-color: var(--accent); }
.nudge .select { font-size: 12px; padding: 4px 8px; }
.nudge input[type=color] { width: 40px; height: 28px; padding: 0; border: 1px solid var(--border); background: none; border-radius: 4px; cursor: pointer; }
.nudge-group { border-top: 1px solid var(--border); margin-top: 10px; padding-top: 4px; }
.nudge-title { font-size: 11px; font-weight: 700; color: var(--text2); margin-top: 6px; }

.main-tabs { display: flex; gap: 2px; margin-bottom: 14px; }
.main-tabs .tab {
  padding: 6px 16px; border: 1px solid var(--border); background: transparent;
  border-radius: 6px; font-size: 12px; font-weight: 600; color: var(--text3); cursor: pointer; font-family: inherit;
}
.main-tabs .tab:hover { color: var(--text2); border-color: var(--accent); }
.main-tabs .tab.active { background: var(--accent); border-color: var(--accent); color: #fff; }
.client-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.client-grid .section { margin-bottom: 14px; }
.notes-section { border-color: rgba(234,179,8,0.45); }
.link { color: var(--accent); text-decoration: none; overflow-wrap: anywhere; }
.link:hover { text-decoration: underline; }
.brand-row { display: flex; gap: 14px; flex-wrap: wrap; align-items: center; }
.swatch { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--text2); text-transform: capitalize; }
.swatch span { width: 34px; height: 34px; border-radius: 6px; border: 1px solid var(--border); display: inline-block; }
.swatch code { font-size: 10px; color: var(--text3); }
.logo-box { background: #fff; border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; height: 60px; display: flex; align-items: center; }
.logo-box.dark { background: #4b4b4b; }
.logo-box img { max-height: 44px; max-width: 180px; }
.posts-table td { font-size: 12px; }
.kw-table a { color: var(--accent); text-decoration: none; }
.stage-todo td { color: var(--text3); }
.posts-table tr.dim td { color: var(--text3); }
.nowrap { white-space: nowrap; }

.settings-table td:first-child { width: 150px; color: var(--text3); font-size: 12px; }
.settings-table .input, .settings-table .select { padding: 5px 8px; font-size: 12px; }
.chip.editable { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; padding: 3px 6px 3px 10px; }
.chip.editable small { color: var(--text3); font-size: 10px; }
.chip-x { background: none; border: none; color: var(--text3); cursor: pointer; font-size: 14px; line-height: 1; padding: 0 2px; }
.chip-x:hover { color: var(--red); }

.social-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; }
.social-platform label { display: flex; margin: 4px 0; align-items: flex-start; }
.social-platform label input { margin-top: 3px; }
.platform-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 10px 12px; }
.platform-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 6px; font-size: 13px; }
.platform-links { font-size: 12px; overflow-wrap: anywhere; }
.avatar { width: 18px; height: 18px; border-radius: 50%; object-fit: cover; margin-right: 6px; vertical-align: middle; }

.link-flag.ok { background: rgba(34,197,94,0.12); color: var(--green); }
.checks { margin-top: 6px; font-size: 12px; }
.check { padding: 2px 0; }
.check.bad { color: #fca5a5; }
.check.warn { color: var(--yellow); }
.check.ok { color: var(--text3); }
.checks summary { cursor: pointer; color: var(--text3); }

/* ── Image library ── */
.check-inline { font-size: 12px; color: var(--text2); display: flex; align-items: center; gap: 6px; cursor: pointer; }
.lib-clients { display: flex; flex-wrap: wrap; gap: 4px; align-items: center; }
.lib-clients .kw-label { margin: 0 6px 0 0; }
.lib-add { display: flex; gap: 8px; margin-top: 14px; }
.lib-actions { display: flex; gap: 6px; }
.lib-url-row { display: flex; gap: 6px; margin-bottom: 12px; }
.lib-category.dragging { border-color: var(--accent); background: var(--accent-dim); }
.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 12px; }
.lib-drop-hint { grid-column: 1 / -1; padding: 26px; text-align: center; color: var(--text3); font-size: 12px; border: 1px dashed var(--border); border-radius: 8px; }
.lib-card { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; overflow: hidden; display: flex; flex-direction: column; }
.lib-card img { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; display: block; background: var(--surface2); }
.lib-card.removed img { opacity: 0.3; filter: grayscale(1); }
.lib-meta { font-size: 11px; color: var(--text3); padding: 7px 9px 0; line-height: 1.45; }
.lib-card-actions { display: flex; gap: 6px; align-items: center; padding: 8px 9px 9px; margin-top: auto; }
.lib-card-actions .select { flex: 1; min-width: 0; font-size: 11px; padding: 3px 6px; }
.lib-assign { border-top: 1px solid var(--border); padding: 8px 9px 9px; display: flex; flex-direction: column; gap: 6px; }
.lib-assign .select { width: 100%; font-size: 11px; padding: 3px 6px; }
.lib-assign-actions { display: flex; gap: 4px; flex-wrap: wrap; }

/* ── Keyword strategy ── */
.kw-top { display: flex; gap: 28px; flex-wrap: wrap; align-items: flex-end; margin-bottom: 16px; }
.kw-label { font-size: 10px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 4px; }
.kw-main { font-size: 18px; font-weight: 700; }
.kw-value { font-size: 13px; color: var(--text2); text-transform: capitalize; }
.kw-grid { display: grid; grid-template-columns: 1fr 1.4fr; gap: 22px; align-items: start; }
.kw-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.kw-table td, .kw-table th { padding: 5px 8px 5px 0; border-bottom: 1px solid var(--border); text-align: left; vertical-align: top; }
.kw-table th { font-size: 10px; color: var(--text3); text-transform: uppercase; letter-spacing: 0.4px; font-weight: 600; }
.kw-table td:nth-child(2), .kw-table th:nth-child(2) { width: 96px; white-space: nowrap; }
.kw-table .num { width: 50px; text-align: right; color: var(--text2); }
.kw-badge { display: inline-block; font-size: 10px; font-weight: 700; padding: 1px 8px; border-radius: 10px; white-space: nowrap; }
.kw-badge.exact { background: rgba(34,197,94,0.12); color: var(--green); }
.kw-badge.partial { background: rgba(234,179,8,0.12); color: var(--yellow); }
.kw-badge.missing { background: rgba(239,68,68,0.12); color: var(--red); }
.kw-note { font-size: 13px; color: var(--text2); background: var(--surface2); border: 1px solid var(--border); border-radius: 6px; padding: 8px 12px; white-space: pre-wrap; }
.kw-details { margin-top: 14px; font-size: 13px; }
.kw-details summary { cursor: pointer; color: var(--text2); font-weight: 600; font-size: 12px; }
.kw-details summary:hover { color: var(--accent); }
.kw-details .kw-label { margin-top: 12px; }
.kw-list { list-style: none; color: var(--text2); }
.kw-list li { padding: 3px 0; overflow-wrap: anywhere; }
.kw-list.plain { list-style: disc; padding-left: 18px; }
.kw-list a { color: var(--accent); text-decoration: none; }

/* ── Article links ── */
.article-grid { display: grid; grid-template-columns: 1fr 340px; gap: 14px; align-items: start; margin-bottom: 12px; }
.article-grid .field { margin-bottom: 0; min-width: 0; }
.links-panel { height: 560px; overflow-y: auto; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); padding: 8px; position: relative; }
.links-empty { padding: 30px 12px; text-align: center; color: var(--text3); font-size: 12px; }
.link-row { border: 1px solid var(--border); border-radius: 8px; padding: 10px; margin-bottom: 8px; background: var(--surface); cursor: pointer; }
.link-row:hover { border-color: var(--text3); }
.link-row.active { border-color: var(--accent); background: var(--accent-dim); }
.link-row label { display: block; font-size: 10px; font-weight: 600; color: var(--text3); margin: 6px 0 3px; text-transform: uppercase; letter-spacing: 0.4px; }
.link-row .input { font-size: 12px; padding: 5px 8px; }
.link-row-head { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text3); flex-wrap: wrap; }
.link-num { background: var(--surface2); border: 1px solid var(--border); border-radius: 10px; padding: 0 7px; font-weight: 700; color: var(--text2); }
.link-flag { font-size: 10px; font-weight: 700; padding: 0 7px; border-radius: 10px; }
.link-flag.warn { background: rgba(234,179,8,0.12); color: var(--yellow); }
.link-flag.bad { background: rgba(239,68,68,0.12); color: var(--red); }
.link-actions { display: flex; gap: 6px; margin-top: 8px; }
.link-actions .btn { text-decoration: none; }

.side-tabs { display: flex; gap: 4px; margin-bottom: 4px; }
.heading-summary { font-size: 11px; color: var(--text3); padding: 2px 4px 8px; }
.heading-row { padding: 8px; }
.heading-row.level-3 { margin-left: 16px; }
.heading-row.level-4, .heading-row.level-5, .heading-row.level-6 { margin-left: 32px; }
.heading-line { display: flex; gap: 6px; align-items: center; }
.heading-level { width: 62px; padding: 4px 6px; font-size: 11px; font-weight: 700; flex-shrink: 0; color: #fff; border-color: transparent; background: #2563eb; }
.heading-level.h1 { background: #dc2626; }
.heading-level.h3 { background: #0891b2; }
.heading-level.h4, .heading-level.h5, .heading-level.h6 { background: #7c3aed; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }

/* ── Square crop modal (image library uploads) ── */
.crop-modal { position: fixed; inset: 0; background: rgba(0,0,0,0.75); z-index: 400; display: flex; align-items: center; justify-content: center; outline: none; }
.crop-dialog { background: var(--surface); border: 1px solid var(--border); border-radius: 14px; width: min(920px, 94vw); max-height: 94vh; display: flex; flex-direction: column; overflow: hidden; }
.crop-head { padding: 14px 18px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
.crop-stage { position: relative; background: #000; height: min(62vh, 640px); display: flex; align-items: center; justify-content: center; overflow: hidden; user-select: none; touch-action: none; }
.crop-stage img { max-width: 100%; max-height: 100%; display: block; object-fit: contain; pointer-events: none; }
.crop-box { position: absolute; border: 2px solid #fff; box-shadow: 0 0 0 9999px rgba(0,0,0,0.55); cursor: move; box-sizing: border-box; }
.crop-box::before, .crop-box::after { content: ''; position: absolute; inset: 0; pointer-events: none; border: 0 solid rgba(255,255,255,0.35); }
.crop-box::before { border-left-width: 1px; border-right-width: 1px; left: 33.33%; right: 33.33%; }
.crop-box::after { border-top-width: 1px; border-bottom-width: 1px; top: 33.33%; bottom: 33.33%; }
.crop-handle { position: absolute; right: -8px; bottom: -8px; width: 16px; height: 16px; background: var(--accent); border: 2px solid #fff; border-radius: 50%; cursor: nwse-resize; }
.crop-foot { padding: 12px 18px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; border-top: 1px solid var(--border); }
.crop-foot .crop-size { width: 180px; vertical-align: middle; margin-left: 6px; }
