:root {
  --bg: #faf7f2;
  --ink: #2a1d08;
  --muted: #8a7c63;
  --brand: #ffc03f;
  --brand-deep: #e0a01f;
  --line: #e8e0d2;
  --panel: #ffffff;
  --ok: #2e9e5b;
  --warn: #c9821a;
  --radius: 14px;
}
* { box-sizing: border-box; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
}
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 16px 28px; background: var(--panel); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 12px; }
.logo-dot { width: 30px; height: 30px; border-radius: 8px; background: var(--brand); box-shadow: inset 0 0 0 3px var(--brand-deep); }
.brand h1 { font-size: 18px; margin: 0; letter-spacing: .3px; }
.brand .sub { margin: 0; font-size: 12px; color: var(--muted); }
.pill { font-size: 12px; padding: 6px 12px; border-radius: 999px; font-weight: 600; }
.pill-muted { background: #f0ece3; color: var(--muted); }
.pill-mock { background: #fff3d6; color: var(--warn); }
.pill-live { background: #e3f6ea; color: var(--ok); }

[hidden] { display: none !important; }

.layout {
  display: grid; grid-template-columns: 1fr 1fr; gap: 22px;
  max-width: 1100px; margin: 26px auto; padding: 0 22px;
}
@media (max-width: 820px) { .layout { grid-template-columns: 1fr; } }

.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; }
.panel h2 { font-size: 13px; text-transform: uppercase; letter-spacing: .8px; color: var(--muted); margin: 18px 0 10px; }
.panel h2:first-child { margin-top: 0; }

textarea, select, input[type=number] {
  width: 100%; font: inherit; color: var(--ink);
  border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; background: #fffdf9;
}
textarea { resize: vertical; }
select { width: auto; }
input[type=number] { width: 110px; }

.chk { display: block; font-size: 14px; margin: 8px 0; line-height: 1.5; }
.chk input { margin-right: 8px; }
.hint { color: var(--muted); font-size: 12px; }
.seed { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; margin: 10px 0 4px; }

.btn {
  display: inline-block; margin-top: 16px; cursor: pointer;
  background: var(--brand); color: var(--ink); font-weight: 700; font-size: 15px;
  border: none; border-radius: 10px; padding: 12px 22px; text-decoration: none;
}
.btn:hover { background: var(--brand-deep); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-ghost { background: transparent; border: 1px solid var(--line); color: var(--ink); font-weight: 600; }
.btn-ghost:hover { background: #f5f1e9; }

.prompt-echo { font-size: 12px; color: var(--muted); margin-top: 14px; white-space: pre-wrap; line-height: 1.5; }

.stage {
  position: relative; aspect-ratio: 4 / 5; width: 100%;
  border: 1px dashed var(--line); border-radius: 10px; overflow: hidden;
  display: flex; align-items: center; justify-content: center; background: #fffdf9;
}
.stage img { width: 100%; height: 100%; object-fit: contain; }
.placeholder { color: var(--muted); font-size: 14px; padding: 0 20px; text-align: center; }
.spinner {
  position: absolute; width: 36px; height: 36px; border-radius: 50%;
  border: 4px solid var(--line); border-top-color: var(--brand-deep);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

.actions { display: flex; gap: 12px; margin-top: 6px; }
.msg { font-size: 13px; margin-top: 12px; min-height: 18px; }
.msg.err { color: #c0392b; }
.msg.ok { color: var(--ok); }

.foot { max-width: 1100px; margin: 8px auto 40px; padding: 0 22px; font-size: 12px; color: var(--muted); }
.foot b { color: var(--ink); }

/* tabs */
.tabs { display: flex; gap: 6px; }
.tab {
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 7px 16px; font: inherit; font-size: 14px; font-weight: 600; color: var(--muted); cursor: pointer;
}
.tab:hover { background: #f5f1e9; }
.tab-active { background: var(--ink); color: #fff; border-color: var(--ink); }
.badge { background: var(--brand-deep); color: var(--ink); border-radius: 999px; padding: 1px 7px; font-size: 11px; margin-left: 4px; }

/* library */
#view-library { max-width: 1100px; margin: 26px auto; padding: 0 22px; }
.lib-head { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 12px; margin-bottom: 18px; }
.lib-head h2 { font-size: 16px; margin: 0; }
.filters { display: flex; gap: 6px; }
.filter {
  background: transparent; border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 13px; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer;
}
.filter:hover { background: #f5f1e9; }
.filter-active { background: var(--brand); color: var(--ink); border-color: var(--brand-deep); font-weight: 600; }

.lib-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 18px; }
.lib-card { background: var(--panel); border: 1px solid var(--line); border-radius: 12px; overflow: hidden; display: flex; flex-direction: column; }
.lib-card.status-approved { border-color: var(--ok); box-shadow: 0 0 0 1px var(--ok) inset; }
.lib-card.status-rejected { opacity: .6; }
.lib-thumb { aspect-ratio: 4/5; background: #fffdf9; }
.lib-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.lib-body { padding: 12px; display: flex; flex-direction: column; gap: 7px; }
.lib-status { align-self: flex-start; font-size: 11px; text-transform: uppercase; letter-spacing: .5px; font-weight: 700; color: var(--muted); }
.status-approved .lib-status { color: var(--ok); }
.status-rejected .lib-status { color: #c0392b; }
.lib-idea { font-size: 13px; margin: 0; line-height: 1.4; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.lib-meta { font-size: 11px; color: var(--muted); margin: 0; }
.lib-cap { width: 100%; font: inherit; font-size: 12px; border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; resize: vertical; background: #fffdf9; }
.lib-actions { display: flex; gap: 6px; margin-top: 2px; }
.mini { flex: 1; text-align: center; font: inherit; font-size: 12px; font-weight: 600; padding: 7px 4px; border-radius: 8px; border: 1px solid var(--line); cursor: pointer; text-decoration: none; background: #fff; color: var(--ink); }
.mini.ok:hover { background: #e3f6ea; border-color: var(--ok); color: var(--ok); }
.mini.no:hover { background: #fdeaea; border-color: #c0392b; color: #c0392b; }
.mini.ghost { color: var(--muted); }
.mini.ghost:hover { background: #f5f1e9; }
