:root {
  --bg: #f7f3ee;
  --surface: #ffffff;
  --surface-2: #fbf8f4;
  --line: #e7dfd5;
  --ink: #3d3530;
  --muted: #8a7d72;
  --accent: #b07a58;
  --accent-ink: #ffffff;
  --accent-soft: #f1e4d8;
  --ok: #5f8a63;
  --warn: #b8862f;
  --bad: #b5524a;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(61, 53, 48, .06), 0 6px 24px rgba(61, 53, 48, .06);
  color-scheme: light;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--ink); }
body { font: 15px/1.5 Manrope, system-ui, -apple-system, Segoe UI, sans-serif; -webkit-font-smoothing: antialiased; }
[hidden] { display: none !important; }
a { color: var(--accent); }
h1, h2, h3 { font-family: "Cormorant Garamond", Georgia, serif; font-weight: 600; line-height: 1.15; margin: 0 0 .4em; }
h1 { font-size: 30px; } h2 { font-size: 24px; } h3 { font-size: 20px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.err { color: var(--bad); }

input, select, textarea {
  font: inherit; color: inherit; width: 100%; padding: 10px 12px; border: 1px solid var(--line);
  border-radius: 10px; background: var(--surface); outline: none; transition: border-color .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
textarea { resize: vertical; min-height: 90px; }
label { display: block; font-size: 13px; color: var(--muted); font-weight: 500; margin: 0 0 12px; }
label > input, label > select, label > textarea { margin-top: 5px; color: var(--ink); font-size: 15px; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px; font: 600 14px/1 Manrope, sans-serif;
  padding: 10px 14px; border-radius: 10px; border: 1px solid var(--line); background: var(--surface); color: var(--ink);
  cursor: pointer; text-decoration: none; white-space: nowrap; min-height: 40px;
}
.btn:hover { border-color: var(--accent); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn.primary:hover { filter: brightness(1.06); }
.btn.ghost { background: transparent; border-color: transparent; }
.btn.ghost:hover { background: var(--accent-soft); }
.btn.danger { color: var(--bad); }
.btn.sm { padding: 6px 10px; min-height: 32px; font-size: 13px; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .5; cursor: default; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
.chip { display: inline-block; padding: 3px 9px; border-radius: 99px; background: var(--accent-soft); color: var(--accent); font-size: 12px; font-weight: 600; }
.chip.ok { background: #e3eee3; color: var(--ok); } .chip.warn { background: #f6ecd8; color: var(--warn); }
.chip.bad { background: #f5e1df; color: var(--bad); } .chip.grey { background: #eee9e3; color: var(--muted); }
.chip.btnchip { cursor: pointer; border: 0; font-family: inherit; }
.chip.btnchip:hover { filter: brightness(.96); }

/* вход */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; }
.login-card { width: min(380px, 100%); background: var(--surface); padding: 28px; border-radius: 20px; box-shadow: var(--shadow); }
.brand { display: inline-flex; align-items: center; gap: 10px; font: 600 22px "Cormorant Garamond", serif; color: var(--ink); text-decoration: none; }
.brand.big { font-size: 30px; margin-bottom: 4px; }
.logo { width: 26px; height: 26px; border-radius: 7px; background: var(--accent); position: relative; flex: none; }
.logo::after { content: ""; position: absolute; inset: 6px 7px; border: 2px solid #fff; border-radius: 3px; }

/* шапка */
.top { position: sticky; top: 0; z-index: 20; display: flex; align-items: center; gap: 18px; padding: 10px 24px;
  background: rgba(247, 243, 238, .92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; }
.tabs a { padding: 8px 12px; border-radius: 9px; text-decoration: none; color: var(--muted); font-weight: 600; }
.tabs a.on { color: var(--ink); background: var(--surface); box-shadow: var(--shadow); }
.jobs { margin-left: auto; font-size: 13px; color: var(--accent); display: flex; align-items: center; gap: 8px; }
.spin { width: 14px; height: 14px; border: 2px solid var(--accent-soft); border-top-color: var(--accent); border-radius: 50%; animation: sp 0.9s linear infinite; flex: none; }
@keyframes sp { to { transform: rotate(360deg); } }

main { max-width: 1280px; margin: 0 auto; padding: 24px; }
.head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; margin-bottom: 18px; flex-wrap: wrap; }
.head p { margin: 0; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow); }
.empty { text-align: center; padding: 48px 16px; color: var(--muted); }
.filters { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.filters button { border: 1px solid var(--line); background: var(--surface); border-radius: 99px; padding: 6px 12px; font: 600 13px Manrope, sans-serif; color: var(--muted); cursor: pointer; }
.filters button.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* сетка постов */
.posts { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 18px; }
.pcard { background: var(--surface); border-radius: var(--radius); overflow: hidden; border: 1px solid var(--line); text-decoration: none; color: inherit; box-shadow: var(--shadow); display: flex; flex-direction: column; transition: transform .15s; }
.pcard:hover { transform: translateY(-2px); }
.pcard .cover { aspect-ratio: 4/5; background: var(--accent-soft); display: grid; place-items: center; color: var(--muted); }
.pcard .cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.pcard .meta { padding: 12px 14px 14px; display: grid; gap: 6px; }
.pcard .title { font-weight: 600; line-height: 1.3; }

/* редактор */
.editor { display: grid; grid-template-columns: minmax(0, 1fr) 420px; gap: 24px; align-items: start; }
.stage { position: sticky; top: 76px; }
.preview { aspect-ratio: 4/5; max-height: calc(100vh - 250px); margin: 0 auto; background: var(--accent-soft); border-radius: 12px; overflow: hidden; box-shadow: var(--shadow); position: relative; }
.preview img { width: 100%; height: 100%; display: block; object-fit: contain; }
.preview .nav { position: absolute; top: 50%; transform: translateY(-50%); width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(255,255,255,.85); cursor: pointer; font-size: 18px; color: var(--ink); }
.preview .nav.l { left: 10px; } .preview .nav.r { right: 10px; }
.strip { display: flex; gap: 8px; overflow-x: auto; padding: 12px 2px 4px; scrollbar-width: thin; }
.strip .th { flex: none; width: 72px; aspect-ratio: 4/5; border-radius: 6px; overflow: hidden; border: 2px solid transparent; cursor: pointer; position: relative; background: var(--accent-soft); padding: 0; }
.strip .th.on { border-color: var(--accent); }
.strip .th img { width: 100%; height: 100%; object-fit: cover; display: block; }
.strip .th span { position: absolute; left: 4px; bottom: 3px; font-size: 11px; font-weight: 700; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); }
.strip .add { flex: none; width: 72px; aspect-ratio: 4/5; border: 2px dashed var(--line); border-radius: 6px; background: transparent; color: var(--muted); font-size: 24px; cursor: pointer; }
.side { display: grid; gap: 14px; }
.ptabs { display: flex; gap: 2px; background: #efe8e0; padding: 3px; border-radius: 11px; overflow-x: auto; }
.ptabs button { flex: 1; border: 0; background: transparent; padding: 8px 6px; border-radius: 8px; font: 600 13px Manrope, sans-serif; color: var(--muted); cursor: pointer; white-space: nowrap; }
.ptabs button.on { background: var(--surface); color: var(--ink); box-shadow: var(--shadow); }
.bgpick { display: flex; gap: 10px; align-items: center; }
.bgpick img, .bgpick .ph { width: 56px; height: 70px; object-fit: cover; border-radius: 6px; background: var(--accent-soft); flex: none; }
.styles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 14px; }
.styles button { border: 1px solid var(--line); background: var(--surface); border-radius: 10px; padding: 10px 6px; cursor: pointer; font: 600 12px Manrope, sans-serif; color: var(--ink); }
.styles button.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.swatches { display: flex; gap: 10px; margin-bottom: 14px; flex-wrap: wrap; }
.swatches button { width: 44px; height: 44px; border-radius: 50%; border: 3px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.swatches button.on { box-shadow: 0 0 0 2px var(--accent); }
.counter { font-size: 12px; text-align: right; margin-top: -8px; margin-bottom: 10px; }
.counter.bad { color: var(--bad); }
.notice { background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 12px 14px; font-size: 13px; }
.notice.warn { background: #fbf4e6; border-color: #eedcb6; }
.notice.bad { background: #f9ecea; border-color: #ecc9c4; }
.generating { display: grid; place-items: center; gap: 14px; padding: 80px 16px; text-align: center; }
.generating .spin { width: 32px; height: 32px; border-width: 3px; }

/* темы */
.topic-gen { display: grid; grid-template-columns: 1fr 100px 1.3fr 1.5fr auto; gap: 10px; align-items: end; }
.topic-gen label { margin: 0; }
.topics { display: grid; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); gap: 14px; margin-top: 18px; }
.topic { display: flex; flex-direction: column; gap: 8px; }
.topic .hook { font: 600 21px/1.2 "Cormorant Garamond", serif; }
.topic .score { margin-left: auto; font-weight: 700; color: var(--accent); font-size: 13px; }

/* фоны */
.sets { display: grid; gap: 22px; }
.thumbs { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; margin-top: 10px; }
.thumbs .t { position: relative; aspect-ratio: 4/5; border-radius: 8px; overflow: hidden; background: var(--accent-soft); border: 2px solid transparent; padding: 0; cursor: pointer; }
.thumbs .t img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumbs .t.on { border-color: var(--accent); }
.thumbs .t .x { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); color: #fff; cursor: pointer; font-size: 14px; line-height: 1; }

/* настройки */
.settings { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; align-items: start; }
.steps-list { padding-left: 18px; margin: 8px 0; font-size: 14px; }
.steps-list li { margin-bottom: 6px; }

/* модалка */
.modal { position: fixed; inset: 0; background: rgba(40, 33, 28, .45); z-index: 50; display: grid; place-items: center; padding: 16px; }
.modal-card { width: min(640px, 100%); max-height: calc(100vh - 32px); overflow: auto; background: var(--surface); border-radius: 18px; padding: 22px; box-shadow: 0 20px 60px rgba(0,0,0,.2); }
.modal-card.wide { width: min(980px, 100%); }
.mtabs { display: flex; gap: 6px; margin: 6px 0 16px; flex-wrap: wrap; }
.toast { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); background: var(--ink); color: #fff; padding: 11px 16px; border-radius: 12px; z-index: 60; font-size: 14px; max-width: calc(100% - 32px); box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); }

@media (max-width: 960px) {
  .editor { grid-template-columns: 1fr; }
  .stage { position: static; }
  .preview { max-height: none; width: 100%; max-width: 480px; }
  .settings { grid-template-columns: 1fr; }
  .topic-gen { grid-template-columns: 1fr 1fr; }
  .topic-gen .wish { grid-column: 1 / -1; }
}
@media (max-width: 600px) {
  main { padding: 16px; }
  .top { padding: 8px 16px; gap: 8px; }
  .tabs { width: 100%; overflow-x: auto; }
  .tabs a { padding: 7px 10px; font-size: 14px; }
  .jobs { margin-left: 0; width: 100%; }
  .posts { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .pcard .meta { padding: 10px; }
  .topics { grid-template-columns: 1fr; }
  .topic-gen { grid-template-columns: 1fr; }
  h1 { font-size: 26px; }
}
