:root {
  --bg: #f3efe6;
  --ink: #1c1915;
  --line: #2c2620;
  --accent: #2f6b4f;
  --card: #fffcf7;
  --muted: #5c5348;
  --top-bg: #fffdf8;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: "Segoe UI", system-ui, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
body > main {
  flex: 1 0 auto;
}
.top {
  display: flex;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
  padding: 14px 22px;
  border-bottom: 1px solid var(--line);
  background: var(--top-bg);
}
.brand {
  font-weight: 800;
  text-decoration: none;
  color: var(--ink);
  font-size: 1.55rem;
}
.view-tabs {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}
.view-tab {
  text-decoration: none;
  color: var(--muted);
  padding: 10px 18px;
  border-radius: 10px;
  font-weight: 700;
  font-size: 1.2rem;
}
.view-tab:hover { color: var(--ink); background: rgba(0,0,0,0.05); }
.view-tab.is-active {
  color: #fff;
  background: var(--accent);
}
.top-settings {
  margin-left: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
}
.top-settings:hover {
  color: var(--ink);
  background: rgba(0,0,0,0.06);
}
.hint { color: var(--muted); font-size: 0.9rem; }
main { padding: 22px; max-width: 1100px; margin: 0 auto; }
main.main-gallery {
  max-width: none;
  width: 100%;
  margin: 0;
  padding: 14px 14px 48px;
}
.panel {
  background: var(--card);
  border: 2px solid var(--line);
  padding: 18px;
}
.panel.two {
  display: grid;
  grid-template-columns: 1.2fr 1fr;
  gap: 22px;
}
@media (max-width: 860px) {
  .panel.two { grid-template-columns: 1fr; }
}
.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 14px;
}
label { display: grid; gap: 4px; font-size: 0.85rem; }
input, select, textarea, button {
  font: inherit;
  border: 1.5px solid var(--line);
  padding: 8px 10px;
  background: #fff;
}
button {
  background: var(--accent);
  color: #fff;
  border-color: var(--line);
  cursor: pointer;
  font-weight: 600;
}
.grid {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}
.grid th, .grid td {
  border-bottom: 1px solid #d8d0c4;
  text-align: left;
  padding: 8px 6px;
  vertical-align: top;
}
.badge {
  display: inline-block;
  border: 1.5px solid var(--line);
  padding: 2px 8px;
  background: #eef6f1;
  font-size: 0.8rem;
}
.tag {
  display: inline-block;
  background: #efe8dc;
  border: 1px solid #cbbfae;
  padding: 1px 6px;
  margin: 1px;
  font-size: 0.78rem;
}
.note { color: var(--muted); font-size: 0.88rem; }
.error { color: #8b1e1e; }
.preview {
  width: 100%;
  max-height: 420px;
  background: #111;
}
.stack { display: grid; gap: 10px; margin-bottom: 18px; }
.check { display: flex; gap: 8px; align-items: center; }
fieldset { border: 1.5px solid var(--line); }
.captions fieldset { display: grid; gap: 8px; padding: 10px; }
a { color: var(--accent); }
code {
  background: #efe8dc;
  padding: 1px 5px;
  border: 1px solid #d5cbb8;
  border-radius: 4px;
  font-size: 0.92em;
  word-break: break-all;
}

/* —— Dark gallery (like Disk / Photos) —— */
body.theme-dark {
  --bg: #0b0b0b;
  --ink: #f2f2f2;
  --line: #2a2a2a;
  --accent: #3d8b63;
  --card: #141414;
  --muted: #9a9a9a;
  --top-bg: #111;
}
body.theme-dark code {
  background: #1c1c1c;
  border-color: #333;
  color: #f2f2f2;
}
body.theme-dark .view-tab:hover { background: rgba(255,255,255,0.06); }
body.theme-dark .view-tab.is-active {
  background: #e8e8e8;
  color: #111;
}
.gallery-date {
  margin: 8px 0 14px;
  font-size: 1.55rem;
  font-weight: 700;
  letter-spacing: 0.01em;
  color: var(--ink);
}
.gallery-day { margin-bottom: 22px; }
.gallery-grid {
  display: grid;
  /* fixed card width → denser left pack, no stretch into empty space */
  grid-template-columns: repeat(auto-fill, 268px);
  gap: 8px;
  justify-content: start;
}
.gallery-card {
  position: relative;
  display: block;
  width: 268px;
  aspect-ratio: 16 / 10;
  border-radius: 10px;
  overflow: hidden;
  background: #2a2a2a;
  text-decoration: none;
  color: inherit;
}
.gallery-card:hover { outline: 2px solid rgba(255,255,255,0.35); outline-offset: 0; }
.gallery-thumb {
  width: 100%;
  height: 100%;
  background: #333 center/cover no-repeat;
}
.gallery-thumb.is-empty { background: #333; }
.gallery-badge {
  position: absolute;
  left: 8px;
  bottom: 7px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 7px;
  border-radius: 6px;
  background: rgba(0,0,0,0.62);
  color: #fff;
  font-size: 0.78rem;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.gallery-cam {
  width: 14px;
  height: 14px;
  opacity: 0.95;
}
.gallery-empty {
  color: var(--muted);
  padding: 40px 8px;
  font-size: 1rem;
}
.gallery-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 0 0 18px;
}
.gallery-filter {
  text-decoration: none;
  color: #bbb;
  font-size: 0.92rem;
  font-weight: 700;
  padding: 8px 14px;
  border-radius: 999px;
  background: #1f1f1f;
  border: 1px solid #333;
}
.gallery-filter:hover { color: #fff; border-color: #555; }
.gallery-filter.is-active {
  color: #111;
  background: #e8e8e8;
  border-color: #e8e8e8;
}
.gallery-card-wrap {
  position: relative;
  width: 268px;
}
.gallery-card-wrap .gallery-card { width: 100%; }
.gallery-pub {
  position: static;
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-transform: lowercase;
}
.gallery-pub.is-off {
  background: rgba(196, 54, 54, 0.92);
  color: #fff;
}
.gallery-pub.is-on {
  background: rgba(46, 140, 87, 0.92);
  color: #fff;
}
.gallery-actions {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 2;
  margin: 0;
}
.gallery-action {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 0.72rem;
  font-weight: 800;
  padding: 6px 10px;
  border-radius: 8px;
  background: rgba(0,0,0,0.72);
  color: #fff;
  border: 1px solid rgba(255,255,255,0.18);
}
.gallery-action:hover { background: #e4572e; border-color: #e4572e; }

.gallery-flash { margin: 0 0 14px; }
.gallery-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 18px;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 16px;
  padding: 12px 14px;
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 12px;
}
.gallery-toolbar-left {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.gallery-check-all {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  color: var(--muted);
  font-size: 0.95rem;
}
.gallery-pick {
  position: absolute;
  z-index: 3;
  top: 8px;
  left: 8px;
  width: 22px;
  height: 22px;
  margin: 0;
  background: rgba(0,0,0,0.55);
  border-radius: 6px;
  display: grid;
  place-items: center;
}
.gallery-pick input { width: 14px; height: 14px; margin: 0; }
.gallery-card-wrap { position: relative; }
.gallery-sku {
  position: absolute;
  right: 8px;
  bottom: 8px;
  left: auto;
  z-index: 2;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: #111;
  background: rgba(232,232,232,0.92);
  padding: 3px 7px;
  border-radius: 6px;
}
.gallery-status-stack {
  position: absolute;
  left: 8px;
  top: 8px;
  z-index: 3;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 4px;
  max-width: calc(100% - 96px);
  pointer-events: none;
}
.gallery-status-stack .gallery-status,
.gallery-status-stack .gallery-pub {
  position: static;
}
.gallery-status {
  position: static;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  padding: 4px 8px;
  border-radius: 6px;
}
.gallery-status.is-ai_plus,
.gallery-status.is-processed_ai {
  background: #0f3d28;
  color: #7dffa8;
  box-shadow: 0 0 0 1px rgba(125, 255, 168, 0.35);
}
.gallery-status.is-processed,
.gallery-status.is-manual {
  background: #2a1540;
  color: #e0b3ff;
  box-shadow: 0 0 0 1px rgba(224, 179, 255, 0.4);
}
.gallery-caption {
  margin: 6px 2px 0;
  font-size: 0.78rem;
  line-height: 1.25;
  color: var(--text, #e8e8e8);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  word-break: break-word;
}
.gallery-ai {
  position: absolute;
  right: 8px;
  top: 8px;
  z-index: 2;
  font-size: 0.72rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 6px;
}
.gallery-ai.is-queue { background: #3a3a1a; color: #e6d96a; }
.gallery-ai.is-run { background: #1a3a2a; color: #7dcea0; }
.gallery-ai.is-fail { background: #3d1e1e; color: #f5a3a3; }
.gallery-ai.is-disk { background: #2a2a3a; color: #a8b4d8; }
.gallery-ai.is-idle { display: none; }
.gallery-ai.is-wait { background: #3a2a1a; color: #f0c27a; }
.gallery-ai-track[hidden] { display: none !important; }
.gallery-ai-track {
  display: none;
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 5px;
  background: rgba(0, 0, 0, 0.45);
  z-index: 3;
}
.gallery-ai-track.is-on { display: block; }
.gallery-ai-track-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5a9e6f, #8fd4a0);
  transition: width 0.35s ease;
}
.gallery-card:has(.gallery-ai-track.is-on) .gallery-badge {
  bottom: 12px;
}

.wave-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 0 0 14px;
  padding: 10px 14px;
  border-radius: 10px;
  border: 1px solid #3a3a3a;
  background: #1c1c1c;
  color: #ddd;
  font-size: 0.92rem;
}
.wave-banner.is-busy { border-color: #5a4a1a; background: #241f12; }
.wave-banner.is-ready { border-color: #2a4a32; background: #152018; }

.ai-queue-banner {
  margin: 0 0 14px;
  padding: 12px 14px;
  border: 1px solid #2a4a32;
  background: #121a16;
  border-radius: 8px;
  display: grid;
  gap: 8px;
}
.ai-queue-banner[hidden] { display: none !important; }
.ai-queue-banner-main {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  align-items: baseline;
}
.ai-queue-banner-main strong {
  font-size: 0.95rem;
  color: #c8f0d4;
}
.ai-queue-banner-stage {
  color: var(--muted, #9aa);
  font-size: 0.88rem;
}
.ai-queue-banner-track {
  height: 6px;
  border-radius: 999px;
  background: #1e2a24;
  overflow: hidden;
}
.ai-queue-banner-bar {
  height: 100%;
  background: linear-gradient(90deg, #2f8f5b, #7dcea0);
  transition: width 0.35s ease;
}
.ai-queue-banner-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  font-size: 0.82rem;
  color: #b7c4bc;
  font-variant-numeric: tabular-nums;
}
.wave-chip {
  padding: 2px 8px;
  border-radius: 999px;
  background: #2a2a2a;
  color: #cfcfcf;
  font-size: 0.82rem;
}
.wave-ok { color: #8fd4a0; font-weight: 700; }
.wave-wait { color: #e6d96a; font-weight: 600; }

/* Operator debug errors */
.debug-fab {
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 90;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 0;
  background: #a33;
  color: #fff;
  font: inherit;
  font-weight: 900;
  font-size: 1.2rem;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.35);
}
.debug-panel {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 95;
  width: min(420px, calc(100vw - 28px));
  max-height: min(380px, 55vh);
  display: flex;
  flex-direction: column;
  background: #1a1212;
  border: 1px solid #5a3030;
  border-radius: 12px;
  color: #f0d0d0;
  box-shadow: 0 8px 28px rgba(0,0,0,0.45);
  overflow: hidden;
}
.debug-panel[hidden] { display: none !important; }
.debug-panel-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: #241616;
  border-bottom: 1px solid #3a2222;
}
.debug-panel-toggle {
  appearance: none;
  border: 0;
  background: transparent;
  color: #f5a3a3;
  font: inherit;
  font-weight: 800;
  cursor: pointer;
  padding: 0;
}
.debug-count {
  display: inline-flex;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: #a33;
  color: #fff;
  font-size: 0.75rem;
  margin-left: 6px;
}
.debug-panel-clear {
  margin-left: auto;
  appearance: none;
  border: 1px solid #5a3838;
  background: #2a1818;
  color: #f0c0c0;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 6px;
  cursor: pointer;
}
.debug-panel-clear:hover {
  background: #3a2020;
  color: #fff;
}
.debug-panel-close {
  margin-left: 4px;
  appearance: none;
  border: 0;
  background: transparent;
  color: #aaa;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.debug-panel-body {
  overflow: auto;
  padding: 8px 10px 12px;
}
.debug-meta {
  margin: 0 0 8px;
  font-size: 0.78rem;
  color: #b89898;
}
.debug-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
}
.debug-item {
  background: #221818;
  border: 1px solid #3a2626;
  border-radius: 8px;
  padding: 8px;
}
.debug-item-head {
  display: block;
  color: #ffc9c9;
  font-weight: 700;
  font-size: 0.82rem;
  text-decoration: none;
  margin-bottom: 4px;
}
.debug-item-head:hover { text-decoration: underline; }
.debug-item-err {
  margin: 0;
  white-space: pre-wrap;
  word-break: break-word;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.72rem;
  line-height: 1.35;
  color: #e8b0b0;
  max-height: 90px;
  overflow: auto;
}
.debug-empty {
  color: #888;
  font-size: 0.85rem;
}
.sources-search {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin: 0 0 14px;
}
.sources-search-label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.9rem;
  min-width: min(360px, 100%);
}
.sources-search input {
  background: #1c1c1c;
  border: 1px solid #333;
  color: #f2f2f2;
  border-radius: 8px;
  padding: 10px 12px;
  font-size: 1rem;
}

@media (max-width: 720px) {
  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  }
  .gallery-card {
    width: 100%;
  }
}

/* —— Editor (CapCut-like dark workspace) —— */
body.theme-dark.editor-page,
body.theme-dark:has(.main-editor) {
  --ed-bg: #121212;
  --ed-panel: #1a1a1a;
  --ed-panel-2: #222;
  --ed-line: #2e2e2e;
  --ed-text: #ececec;
  --ed-muted: #9b9b9b;
  --ed-accent: #e4572e;
  --ed-accent-2: #3d8b63;
}
main.main-editor {
  max-width: none;
  margin: 0;
  padding: 0;
  height: calc(100vh - 62px);
  overflow: hidden;
  background: #121212;
}
.editor {
  display: grid;
  /* Wide tools left, player center, slim properties right */
  grid-template-columns: minmax(400px, 1.15fr) minmax(0, 1.45fr) 212px;
  grid-template-rows: minmax(0, 1fr);
  height: 100%;
  color: #ececec;
  background: #121212;
}
.ed-left {
  grid-row: 1;
  grid-column: 1;
  display: grid;
  grid-template-columns: 128px minmax(0, 1fr);
  border-right: 1px solid #2e2e2e;
  background: #1a1a1a;
  min-height: 0;
}
.ed-tools {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px 10px;
  border-right: 1px solid #2e2e2e;
  background: #151515;
}
.ed-tool {
  appearance: none;
  border: 0;
  background: transparent;
  color: #9b9b9b;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  text-align: left;
  padding: 16px 12px;
  border-radius: 12px;
  cursor: pointer;
  line-height: 1.2;
}
.ed-tool:hover { color: #fff; background: #242424; }
.ed-tool.is-active {
  color: #fff;
  background: rgba(228, 87, 46, 0.18);
  box-shadow: inset 4px 0 0 #e4572e;
}
.ed-left-scroll {
  overflow: auto;
  padding: 16px 18px 28px;
  min-height: 0;
}
.ed-panel { display: none; }
.ed-panel.is-active { display: block; }
.ed-h {
  margin: 0 0 14px;
  font-size: 1.45rem;
  font-weight: 800;
  color: #fff;
}
.ed-panel .ed-h:not(:first-child) { margin-top: 22px; }
.editor .stack { gap: 12px; margin-bottom: 18px; }
.editor label { color: #c8c8c8; font-size: 1.05rem; font-weight: 600; }
.editor input,
.editor select,
.editor textarea,
.editor button {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #f0f0f0;
  border-radius: 10px;
  font-size: 1.05rem;
  padding: 12px 14px;
}
.editor textarea { min-height: 110px; }
.editor button {
  background: #333;
  font-weight: 800;
  font-size: 1.1rem;
  padding: 14px 16px;
}
.editor button:hover { background: #3d3d3d; }
.editor button:disabled { opacity: 0.45; cursor: not-allowed; }
.editor .btn-accent {
  background: #e4572e;
  border-color: #e4572e;
  color: #fff;
}
.editor .btn-accent:hover { background: #f06a42; }
.editor .btn-ghost {
  background: transparent;
  border-color: #555;
}
.editor fieldset {
  border: 1px solid #3a3a3a;
  border-radius: 12px;
  padding: 14px;
  background: #1f1f1f;
}
.editor legend { padding: 0 8px; color: #ddd; font-size: 1.05rem; font-weight: 700; }
.editor .note { color: #9a9a9a; font-size: 1rem; }
.editor .error { color: #ff7b7b; font-size: 1.05rem; }
.editor .check { color: #ddd; font-size: 1.05rem; gap: 10px; }
.editor a { color: #7dcea0; }

.ed-center {
  grid-row: 1;
  grid-column: 2;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  background: #101010;
  border-right: 1px solid #2e2e2e;
}
.ed-player-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px 10px;
  border-bottom: 1px solid #2e2e2e;
}
.ed-back {
  color: #9b9b9b !important;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 600;
}
.ed-back:hover { color: #fff !important; }
.ed-title {
  margin: 4px 0 0;
  font-size: 1.2rem;
  font-weight: 800;
  color: #fff;
}
.ed-badges { display: flex; gap: 8px; flex-wrap: wrap; }
.ed-pill {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 999px;
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  font-size: 0.9rem;
  font-weight: 700;
  color: #ddd;
}
.ed-error { margin: 0; padding: 8px 14px; }
.ed-player-stage {
  flex: 0 0 auto;
  min-height: 0;
  display: grid;
  place-items: center;
  padding: 10px;
  background: #0a0a0a;
  /* Keep preview compact — tools matter more */
  max-height: 42vh;
}
.ed-video {
  width: 100%;
  height: auto;
  max-height: min(38vh, 360px);
  object-fit: contain;
  background: #000;
  border-radius: 8px;
}
.ed-video-empty {
  color: #777;
  padding: 24px;
  font-size: 1.05rem;
}
.ed-player-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  padding: 10px 14px 12px;
  border-top: 1px solid #2e2e2e;
  font-variant-numeric: tabular-nums;
  font-size: 1rem;
  color: #bbb;
  margin-top: auto;
}
.ed-links a { margin-left: 2px; font-size: 1rem; }

.ed-right {
  grid-row: 1;
  grid-column: 3;
  overflow: auto;
  padding: 12px 12px 16px;
  background: #171717;
  min-height: 0;
  border-left: 1px solid #2e2e2e;
}
.ed-right .ed-h {
  font-size: 0.95rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #9b9b9b;
  margin-bottom: 10px;
}
.ed-props {
  margin: 0;
  display: grid;
  gap: 8px;
}
.ed-props div {
  display: grid;
  gap: 2px;
  padding-bottom: 8px;
  border-bottom: 1px solid #2a2a2a;
}
.ed-props dt {
  font-size: 0.72rem;
  color: #7a7a7a;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.ed-props dd {
  margin: 0;
  color: #ddd;
  font-size: 0.88rem;
  font-weight: 600;
  word-break: break-word;
  line-height: 1.3;
}
.ed-pubs {
  margin: 0 0 14px;
  padding-left: 20px;
  color: #ccc;
  font-size: 1.1rem;
}
.ed-right .note {
  margin-top: 12px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: #777;
}

/* AI Shorts wait — stage scale + bar while pipeline runs */
.ai-wait {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 22px 12px;
  margin-bottom: 16px;
  border: 1px dashed #3a3a3a;
  border-radius: 12px;
  background: #1f1f1f;
  text-align: center;
}
.ai-wait[hidden] { display: none; }
.ai-wait-gif {
  width: 180px;
  height: 180px;
  object-fit: contain;
  border-radius: 12px;
  background: #87ceeb;
}
.ai-wait-text {
  margin: 0;
  color: #ddd;
  font-size: 1.05rem;
  font-weight: 700;
}
.ai-scale {
  list-style: none;
  margin: 4px 0 0;
  padding: 0 4px;
  width: 100%;
  max-width: 420px;
  display: flex;
  justify-content: space-between;
  gap: 2px;
  position: relative;
}
.ai-scale::before {
  content: "";
  position: absolute;
  left: 8%;
  right: 8%;
  top: 7px;
  height: 2px;
  background: #333;
  z-index: 0;
}
.ai-scale-step {
  position: relative;
  z-index: 1;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}
.ai-scale-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #2a2a2a;
  border: 2px solid #555;
  box-sizing: border-box;
  transition: background 0.25s ease, border-color 0.25s ease, box-shadow 0.25s ease;
}
.ai-scale-name {
  font-size: 0.68rem;
  line-height: 1.15;
  color: #777;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.ai-scale-step.is-done .ai-scale-dot {
  background: #5a9e6f;
  border-color: #5a9e6f;
}
.ai-scale-step.is-done .ai-scale-name { color: #9bbfa3; }
.ai-scale-step.is-current .ai-scale-dot {
  background: #8fd4a0;
  border-color: #c5f0cf;
  box-shadow: 0 0 0 3px rgba(143, 212, 160, 0.28);
}
.ai-scale-step.is-current .ai-scale-name {
  color: #dff5e4;
  font-weight: 700;
}
.ai-progress {
  width: min(320px, 92%);
  height: 8px;
  border-radius: 999px;
  background: #2a2a2a;
  overflow: hidden;
  border: 1px solid #3a3a3a;
}
.ai-progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #5a9e6f, #8fd4a0);
  transition: width 0.4s ease;
}
.ai-wait-pct {
  margin: 0;
  color: #b8d4be;
  font-size: 0.95rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.ai-wait-sub {
  margin: 0;
  color: #8f8f8f;
  font-size: 0.9rem;
}

@media (max-width: 1200px) {
  .editor {
    grid-template-columns: minmax(360px, 1.2fr) minmax(0, 1fr) 180px;
  }
}
@media (max-width: 980px) {
  .editor {
    grid-template-columns: minmax(320px, 1.1fr) minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr) auto;
  }
  .ed-right {
    grid-row: 2;
    grid-column: 1 / -1;
    border-top: 1px solid #2e2e2e;
    border-left: 0;
    max-height: 160px;
  }
}
@media (max-width: 780px) {
  main.main-editor { height: auto; overflow: auto; }
  .editor {
    display: flex;
    flex-direction: column;
    height: auto;
  }
  .ed-left {
    display: block;
  }
  .ed-tools {
    flex-direction: row;
    flex-wrap: wrap;
    border-right: 0;
    border-bottom: 1px solid #2e2e2e;
  }
  .ed-player-stage { max-height: none; }
  .ed-video { max-height: 280px; }
}

/* Schedule board */
main.main-schedule {
  max-width: none;
  width: 100%;
  padding: 14px 18px 48px;
  color: #e8e8e8;
}
.schedule-head {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-end;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.schedule-head h1 { margin: 0 0 6px; font-size: 1.55rem; }
.schedule-day-form label { color: #bbb; font-weight: 700; }
.schedule-day-form input[type="date"] {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
}
.schedule-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 28px;
}
@media (max-width: 900px) {
  .schedule-slots { grid-template-columns: 1fr; }
}
.schedule-slot {
  background: #171717;
  border: 1px solid #333;
  border-radius: 14px;
  overflow: hidden;
  min-height: 220px;
  display: flex;
  flex-direction: column;
}
.schedule-slot-head {
  display: flex;
  justify-content: space-between;
  padding: 12px 14px;
  border-bottom: 1px solid #2e2e2e;
  background: #1f1f1f;
}
.schedule-drop {
  flex: 1;
  min-height: 160px;
  padding: 12px;
  transition: background 0.15s ease, outline-color 0.15s ease;
  outline: 2px dashed transparent;
  outline-offset: -8px;
}
.schedule-drop.is-over {
  background: rgba(228, 87, 46, 0.12);
  outline-color: #e4572e;
}
.schedule-empty {
  margin: 48px 0;
  text-align: center;
  color: #777;
  font-size: 0.95rem;
}
.schedule-pool-title {
  margin: 8px 0 6px;
  font-size: 1.2rem;
}
.schedule-pool {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  min-height: 100px;
  padding: 12px;
  border-radius: 12px;
  background: #141414;
  border: 1px solid #2e2e2e;
}
.schedule-card {
  width: 220px;
  background: #222;
  border: 1px solid #3a3a3a;
  border-radius: 12px;
  overflow: hidden;
  cursor: grab;
  color: inherit;
}
.schedule-card.is-dragging { opacity: 0.45; }
.schedule-card.is-placed { width: 100%; cursor: grab; }
.schedule-thumb {
  height: 110px;
  background: #333 center/cover no-repeat;
}
.schedule-card-meta { padding: 10px; }
.schedule-card-title {
  font-size: 0.88rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 8px;
}
.schedule-clear { margin: 0; }
.schedule-hidden {
  margin-top: 18px;
  color: #bbb;
}
.schedule-hidden summary {
  cursor: pointer;
  font-weight: 700;
  margin-bottom: 10px;
}
.schedule-card.is-hidden-pool {
  opacity: 0.72;
}
.schedule-card-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}
.plan-quick {
  margin-top: 28px;
  margin-bottom: 28px;
  padding: 16px;
  border-radius: 14px;
  background: #171717;
  border: 1px solid #333;
}
.plan-quick-grid {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  gap: 24px;
  align-items: stretch;
  justify-content: space-between;
  width: 100%;
}
.plan-quick-left {
  flex: 0 0 360px;
  max-width: 380px;
  min-width: 280px;
}
.plan-quick-form {
  display: grid;
  gap: 12px;
  max-width: none;
}
.plan-quick-form > label {
  display: grid;
  gap: 4px;
  color: #bbb;
  font-weight: 700;
  font-size: 0.85rem;
}
.plan-quick-form select {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
}
.plan-quick-form .btn-accent {
  justify-self: start;
  min-width: 200px;
}
.plan-journal {
  flex: 0 1 520px;
  width: min(520px, 100%);
  margin-left: auto;
  min-width: 0;
  border-left: 1px solid #2e2e2e;
  padding-left: 20px;
}
@media (max-width: 820px) {
  .plan-quick-grid {
    flex-direction: column;
    flex-wrap: wrap;
  }
  .plan-quick-left {
    flex: 1 1 auto;
    max-width: none;
    width: 100%;
  }
  .plan-journal {
    border-left: 0;
    padding-left: 0;
    border-top: 1px solid #2e2e2e;
    padding-top: 16px;
    width: 100%;
  }
}
.plan-journal-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: end;
  margin-bottom: 12px;
}
.plan-journal-filters label {
  display: grid;
  gap: 3px;
  color: #999;
  font-size: 0.78rem;
  font-weight: 700;
}
.plan-journal-filters input,
.plan-journal-filters select {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #fff;
  border-radius: 8px;
  padding: 6px 8px;
  min-width: 110px;
}
.plan-journal-list {
  max-height: 420px;
  overflow: auto;
  display: grid;
  gap: 10px;
  padding-right: 4px;
}
.plan-journal-item {
  background: #1c1c1c;
  border: 1px solid #2e2e2e;
  border-radius: 10px;
  overflow: hidden;
}
.plan-journal-head {
  display: flex;
  gap: 10px;
  padding: 8px 10px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid #2a2a2a;
}
.plan-journal-head:hover { background: #222; }
.plan-journal-thumb {
  width: 64px;
  height: 42px;
  border-radius: 6px;
  background: #333 center/cover no-repeat;
  flex-shrink: 0;
}
.plan-journal-title {
  font-size: 0.85rem;
  font-weight: 700;
  line-height: 1.3;
  margin-bottom: 4px;
}
.plan-journal-table td {
  padding: 5px 8px;
  font-size: 0.82rem;
}
.plan-queue {
  margin-top: 32px;
}
.plan-queue-table {
  background: #171717;
  border: 1px solid #333;
  border-radius: 12px;
  overflow: hidden;
}
.schedule-commit {
  margin-top: 22px;
  display: flex;
  justify-content: center;
}
.btn-commit {
  appearance: none;
  border: 0;
  cursor: pointer;
  font: inherit;
  font-size: 1.15rem;
  font-weight: 800;
  padding: 16px 28px;
  border-radius: 12px;
  background: #2e8c57;
  color: #fff;
  min-width: 280px;
  justify-self: start;
}
.btn-commit:hover { background: #37a366; }
.btn-commit:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Plan / Journal hybrid */
.pub-subtabs {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}
.pub-subtab {
  color: #aaa;
  text-decoration: none;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid #333;
  background: #1a1a1a;
}
.pub-subtab:hover { color: #fff; border-color: #555; }
.pub-subtab.is-active {
  color: #fff;
  background: #2a2a2a;
  border-color: #e4572e;
}
.slot-config {
  display: grid;
  gap: 8px;
  margin: 8px 0;
  padding: 8px;
  border-radius: 10px;
  background: #1a1a1a;
  border: 1px solid #333;
}
.slot-time-label {
  display: grid;
  gap: 4px;
  color: #bbb;
  font-size: 0.85rem;
  font-weight: 700;
}
.slot-time-label input[type="time"] {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #fff;
  border-radius: 8px;
  padding: 6px 8px;
}
.slot-time-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.publish-when {
  border: 1px solid #333;
  border-radius: 10px;
  padding: 10px 12px;
  display: grid;
  gap: 8px;
}
.publish-when legend {
  padding: 0 4px;
  color: #bbb;
  font-weight: 700;
}
.publish-at-wrap {
  display: grid;
  gap: 4px;
  color: #bbb;
  font-size: 0.85rem;
  font-weight: 700;
}
.publish-at-wrap[hidden] {
  display: none !important;
}
.publish-at-wrap input[type="datetime-local"] {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
}
.slot-platforms {
  border: 0;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 4px;
}
.slot-platforms legend {
  font-size: 0.8rem;
  color: #999;
  margin-bottom: 4px;
}
.slot-platforms .check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 0.88rem;
  color: #ddd;
}
.journal-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: end;
  margin-bottom: 18px;
  padding: 14px;
  border-radius: 12px;
  background: #171717;
  border: 1px solid #333;
}
.journal-filters label {
  display: grid;
  gap: 4px;
  color: #bbb;
  font-weight: 700;
  font-size: 0.85rem;
}
.journal-filters input,
.journal-filters select {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #fff;
  border-radius: 8px;
  padding: 8px 10px;
  min-width: 160px;
}
.journal-filters .btn-commit {
  min-width: 120px;
  padding: 10px 16px;
  font-size: 1rem;
}
.journal-groups {
  display: grid;
  gap: 14px;
}
.journal-asset {
  background: #171717;
  border: 1px solid #333;
  border-radius: 14px;
  overflow: hidden;
}
.journal-asset-head {
  display: flex;
  gap: 12px;
  padding: 12px;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid #2e2e2e;
}
.journal-asset-head:hover { background: #1f1f1f; }
.journal-thumb {
  width: 96px;
  height: 64px;
  border-radius: 8px;
  background: #333 center/cover no-repeat;
  flex-shrink: 0;
}
.journal-asset-title {
  font-weight: 800;
  margin-bottom: 8px;
  line-height: 1.3;
}
.journal-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}
.journal-table th,
.journal-table td {
  text-align: left;
  padding: 8px 12px;
  border-top: 1px solid #2a2a2a;
  vertical-align: top;
}
.journal-table th {
  color: #888;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.journal-err {
  font-size: 0.8rem;
  margin-top: 4px;
}
.pub-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.ed-pub-badges { margin-bottom: 8px; }
.pub-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 2px 7px;
  border-radius: 6px;
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.02em;
  background: #333;
  color: #ccc;
  border: 1px solid #444;
}
.pub-badge.is-success { background: #1e3d2a; color: #7dcea0; border-color: #2e8c57; }
.pub-badge.is-failed { background: #3d1e1e; color: #f5a3a3; border-color: #a33; }
.pub-badge.is-scheduled,
.pub-badge.is-pending { background: #3a3018; color: #e8c56a; border-color: #8a7020; }
.pub-badge.is-publishing { background: #1e2f3d; color: #8ec5f5; border-color: #3a6a8a; }
.pub-badge.is-skipped { opacity: 0.55; }

/* Settings + publish modal */
main.main-settings {
  max-width: 820px;
}
.settings-page { color: #e8e8e8; }
.settings-head h1 {
  margin: 0 0 8px;
  font-size: 1.6rem;
}
.settings-ok {
  color: #7dcea0;
  font-weight: 700;
}
.settings-form {
  display: grid;
  gap: 16px;
}
.settings-block {
  border: 1px solid #333;
  border-radius: 12px;
  padding: 16px;
  background: #1a1a1a;
  display: grid;
  gap: 10px;
}
.settings-block legend {
  padding: 0 8px;
  font-weight: 800;
  color: #fff;
}
.settings-block label {
  color: #c8c8c8;
  font-size: 0.95rem;
  font-weight: 600;
}
.settings-block input[type="text"],
.settings-block input:not([type="checkbox"]) {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #f0f0f0;
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
}
.settings-block textarea {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #f0f0f0;
  border-radius: 8px;
  padding: 10px 12px;
  width: 100%;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 0.85rem;
}
.settings-page .error { color: #ff8f8f; font-weight: 700; }
.settings-slots {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.acct-status { margin: 0; font-size: 0.92rem; font-weight: 700; }
.acct-status.is-ready { color: #7dcea0; }
.acct-status.is-bad { color: #ff8f8f; }
.settings-form .btn-accent {
  justify-self: start;
  background: #e4572e;
  border: 1px solid #e4572e;
  color: #fff;
  font-weight: 800;
  padding: 12px 18px;
  border-radius: 10px;
  cursor: pointer;
}
body.theme-dark .top-settings { color: #9b9b9b; }
body.theme-dark .top-settings:hover {
  color: #fff;
  background: rgba(255,255,255,0.08);
}
.pub-modal {
  border: 1px solid #3a3a3a;
  border-radius: 14px;
  padding: 0;
  background: #1a1a1a;
  color: #eee;
  max-width: 480px;
  width: calc(100% - 24px);
}
.pub-modal::backdrop { background: rgba(0,0,0,0.65); }
.pub-modal-card {
  display: grid;
  gap: 10px;
  padding: 18px;
  margin: 0;
}
.pub-modal-card h3 { margin: 0 0 4px; }
.pub-modal-card input[type="datetime-local"] {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: #f0f0f0;
  border-radius: 8px;
  padding: 10px 12px;
}
.pub-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 8px;
}

.top-logout {
  margin: 0;
}
.top-logout button {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  border-radius: 10px;
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 600;
}
.top-logout button:hover {
  color: var(--ink);
  background: rgba(255,255,255,0.06);
}

.site-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.55rem;
  padding: 1.25rem 1rem 1.75rem;
  margin-top: auto;
  border-top: 1px solid var(--line);
  font-size: 0.85rem;
  color: var(--muted);
}
.site-footer a {
  color: var(--muted);
  text-decoration: none;
}
.site-footer a:hover {
  color: var(--ink);
  text-decoration: underline;
}
.site-footer-sep { opacity: 0.45; }
body.theme-dark .site-footer {
  border-top-color: #2a2a2a;
  color: #9a9a9a;
}
body.theme-dark .site-footer a { color: #9a9a9a; }
body.theme-dark .site-footer a:hover { color: #f2f2f2; }

body.login-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: #0b0b0b;
}
.site-footer--login {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  border-top: none;
  background: transparent;
}

body.legal-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: #0b0b0b;
  color: #f2f2f2;
}
.legal-wrap {
  max-width: 42rem;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2.5rem;
  line-height: 1.55;
  flex: 1;
  width: 100%;
  box-sizing: border-box;
}
.legal-wrap h1 { font-size: 1.75rem; margin: 0 0 0.35rem; color: #f2f2f2; }
.legal-wrap h2 { font-size: 1.15rem; margin-top: 1.75rem; color: #e8e8e8; }
.legal-wrap .muted { color: #9a9a9a; font-size: 0.9rem; }
.legal-wrap ul, .legal-wrap ol { padding-left: 1.25rem; color: #d8d8d8; }
.legal-wrap p { color: #d8d8d8; }
.legal-wrap a { color: #7ec89a; text-decoration: underline; }
.legal-wrap code {
  background: #1c1c1c;
  border: 1px solid #333;
  color: #f2f2f2;
  padding: 2px 6px;
  border-radius: 4px;
}
.legal-nav {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
}
.legal-nav a { color: #9a9a9a; text-decoration: none; }
.legal-nav a:hover { color: #f2f2f2; }

.login-wrap { width: min(420px, 92vw); }
.login-card {
  display: grid;
  gap: 12px;
  padding: 28px 24px;
  background: #141414;
  border: 1px solid #2a2a2a;
  border-radius: 14px;
}
.login-card h1 { margin: 0; font-size: 1.8rem; }
.login-card label {
  display: grid;
  gap: 6px;
  color: #cfcfcf;
  font-size: 0.95rem;
}
.login-card input {
  background: #1c1c1c;
  border: 1px solid #333;
  color: #f2f2f2;
  border-radius: 8px;
  padding: 12px;
  font-size: 1rem;
}
.login-card button {
  margin-top: 6px;
  background: #e8e8e8;
  color: #111;
  border: 0;
  border-radius: 10px;
  padding: 12px;
  font-weight: 700;
  cursor: pointer;
}
.login-error {
  margin: 0;
  color: #ff8e8e;
  background: rgba(180,40,40,0.15);
  border: 1px solid rgba(180,40,40,0.35);
  border-radius: 8px;
  padding: 10px 12px;
}
