:root {
  --bg: #f6f4f0;
  --panel: #ffffff;
  --panel-2: #f0ede7;
  --ink: #1d1b19;
  --ink-2: #5d5853;
  --ink-3: #8b857e;
  --line: #e3ded6;
  --accent: #c2410c;
  --accent-ink: #ffffff;
  --accent-soft: #fdeee4;
  --ok: #15803d;
  --ok-soft: #e6f4ea;
  --warn: #b45309;
  --warn-soft: #fdf3e1;
  --bad: #b91c1c;
  --bad-soft: #fdeaea;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(0,0,0,.05), 0 4px 16px rgba(0,0,0,.04);
  --font: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #141312; --panel: #1d1c1a; --panel-2: #262422; --ink: #ece8e2; --ink-2: #b3ada5; --ink-3: #847e77;
    --line: #34312e; --accent: #f97316; --accent-ink: #1a1009; --accent-soft: #3a2314;
    --ok: #4ade80; --ok-soft: #13291b; --warn: #fbbf24; --warn-soft: #33270f; --bad: #f87171; --bad-soft: #3a1717;
    --shadow: none;
  }
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.55 var(--font); }
a { color: var(--accent); }
h1, h2, h3 { line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 1.6rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.02rem; }
p { margin: 0 0 .8em; }
code { background: var(--panel-2); padding: 1px 5px; border-radius: 4px; font-size: .9em; }

/* layout */
.layout { display: grid; grid-template-columns: 230px minmax(0, 1fr); min-height: 100vh; }
.side { background: var(--panel); border-right: 1px solid var(--line); padding: 18px 12px; position: sticky; top: 0; height: 100vh; overflow-y: auto; }
.brand { font-weight: 800; font-size: 1.1rem; padding: 0 10px 14px; letter-spacing: -.01em; }
.brand span { color: var(--accent); }
.side nav a { display: flex; gap: 10px; align-items: center; padding: 7px 10px; border-radius: 8px; color: var(--ink-2); text-decoration: none; font-size: .93rem; }
.side nav a:hover { background: var(--panel-2); color: var(--ink); }
.side nav a.on { background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.side nav .n { width: 20px; height: 20px; border-radius: 50%; border: 1.5px solid var(--line); display: grid; place-items: center; font-size: .72rem; flex: none; }
.side nav .n.done { background: var(--ok); border-color: var(--ok); color: var(--panel); }
.side .sep { border-top: 1px solid var(--line); margin: 10px 6px; }
.side .label { font-size: .72rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); padding: 8px 10px 4px; }
main { padding: 28px clamp(16px, 4vw, 44px) 80px; max-width: 1180px; width: 100%; }
.topbar { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; margin-bottom: 18px; flex-wrap: wrap; }
.sub { color: var(--ink-2); max-width: 760px; }
.mobile-nav { display: none; }

@media (max-width: 860px) {
  .layout { grid-template-columns: minmax(0, 1fr); }
  .side { display: none; position: fixed; inset: 0; z-index: 40; height: 100vh; width: 100%; }
  .side.open { display: block; }
  .mobile-nav { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 30; }
  main { padding: 20px 16px 80px; }
}

/* cards */
.card { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow); margin-bottom: 16px; }
.card.soft { background: var(--panel-2); box-shadow: none; }
.card.accent { border-color: var(--accent); background: var(--accent-soft); }
.grid { display: grid; gap: 16px; }
.g2 { grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); }
.g3 { grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); }
.two-col { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 20px; align-items: start; }
.sticky { position: sticky; top: 16px; }
@media (max-width: 1050px) { .two-col { grid-template-columns: minmax(0, 1fr); } .sticky { position: static; } }

/* buttons */
.btn { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); background: var(--panel); color: var(--ink); padding: 7px 13px; border-radius: 8px; font: inherit; font-size: .9rem; cursor: pointer; text-decoration: none; white-space: nowrap; }
.btn:hover { border-color: var(--ink-3); }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); font-weight: 600; }
.btn.small { padding: 3px 9px; font-size: .8rem; }
.btn.ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn.ghost:hover { background: var(--panel-2); }
.btn.danger { color: var(--bad); }
.btn.ai { border-color: var(--accent); color: var(--accent); background: transparent; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.spacer { flex: 1; }

/* forms */
label.lbl { display: block; font-weight: 650; margin-bottom: 4px; }
input[type=text], input[type=number], input[type=url], textarea, select {
  width: 100%; font: inherit; color: var(--ink); background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 9px 11px;
}
textarea { min-height: 80px; resize: vertical; }
textarea.big { min-height: 420px; font-family: ui-monospace, "SFMono-Regular", Menlo, monospace; font-size: .88rem; line-height: 1.5; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent); outline-offset: -1px; border-color: transparent; }
input[type=range] { width: 100%; accent-color: var(--accent); }
input[type=checkbox] { accent-color: var(--accent); width: 17px; height: 17px; }

.field { padding: 18px 0; border-top: 1px solid var(--line); }
.field:first-child { border-top: 0; padding-top: 4px; }
.field .help { color: var(--ink-2); font-size: .92rem; margin: 2px 0 8px; }
.field .why { font-size: .86rem; color: var(--ink-2); background: var(--panel-2); border-radius: 8px; padding: 8px 11px; margin: 0 0 8px; }
.field .tip { font-size: .86rem; color: var(--ink-2); border-left: 3px solid var(--accent); padding: 2px 10px; margin: 0 0 8px; }
.field .bad { font-size: .84rem; color: var(--bad); margin-top: 6px; }
.req { font-size: .7rem; text-transform: uppercase; letter-spacing: .05em; color: var(--accent); margin-left: 6px; font-weight: 700; }
.hint { font-size: .82rem; color: var(--ink-3); margin-top: 5px; min-height: 1em; }
.hint.ok { color: var(--ok); } .hint.warn { color: var(--warn); } .hint.bad { color: var(--bad); }
.group-title { font-size: 1.05rem; font-weight: 750; margin: 26px 0 0; padding-top: 18px; border-top: 2px solid var(--line); }

.examples { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; align-items: center; }
.examples .t { font-size: .75rem; color: var(--ink-3); text-transform: uppercase; letter-spacing: .05em; margin-right: 2px; }
.ex { font: inherit; font-size: .82rem; background: var(--panel-2); border: 1px dashed var(--line); color: var(--ink-2); padding: 3px 9px; border-radius: 99px; cursor: pointer; text-align: left; }
.ex:hover { border-color: var(--accent); color: var(--ink); }
.links { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: .84rem; margin-top: 8px; }
.links a::after { content: " ↗"; }

.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip { font: inherit; font-size: .86rem; border: 1px solid var(--line); background: var(--panel); color: var(--ink-2); border-radius: 99px; padding: 4px 12px; cursor: pointer; }
.chip.on { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.chip-add { width: 160px !important; padding: 4px 10px !important; border-radius: 99px !important; font-size: .86rem !important; }

/* progress */
.bar { height: 7px; background: var(--panel-2); border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); border-radius: 99px; transition: width .3s; }
.bar.ok > i { background: var(--ok); }
.pill { display: inline-block; font-size: .74rem; padding: 2px 9px; border-radius: 99px; background: var(--panel-2); color: var(--ink-2); font-weight: 600; }
.pill.ok { background: var(--ok-soft); color: var(--ok); }
.pill.warn { background: var(--warn-soft); color: var(--warn); }
.pill.bad { background: var(--bad-soft); color: var(--bad); }
.pill.acc { background: var(--accent-soft); color: var(--accent); }

.steps { display: grid; gap: 10px; }
.step { display: grid; grid-template-columns: 38px 1fr auto; gap: 14px; align-items: center; background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 16px; text-decoration: none; color: inherit; }
.step:hover { border-color: var(--ink-3); }
.step .num { width: 34px; height: 34px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; border: 2px solid var(--line); }
.step.done .num { background: var(--ok); border-color: var(--ok); color: var(--panel); }
.step.next { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.step .d { color: var(--ink-2); font-size: .88rem; }
.step .r { width: 150px; text-align: right; font-size: .8rem; color: var(--ink-3); }
@media (max-width: 640px) { .step { grid-template-columns: 34px 1fr; } .step .r { grid-column: 2; width: auto; text-align: left; } }

/* save status */
#saveStatus { position: fixed; bottom: 16px; left: 16px; font-size: .8rem; background: var(--panel); border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; color: var(--ink-2); opacity: 0; transition: opacity .2s; z-index: 50; }
#saveStatus.show { opacity: 1; }

/* table */
table.t { width: 100%; border-collapse: collapse; font-size: .9rem; }
table.t th, table.t td { text-align: left; padding: 8px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
table.t th { font-size: .74rem; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); font-weight: 650; }
table.t td input, table.t td textarea, table.t td select { padding: 5px 7px; font-size: .86rem; }
table.t td textarea { min-height: 38px; }
.scroll-x { overflow-x: auto; }

/* tabs */
.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs button { font: inherit; background: none; border: 0; border-bottom: 2px solid transparent; padding: 9px 13px; color: var(--ink-2); cursor: pointer; white-space: nowrap; }
.tabs button.on { color: var(--accent); border-color: var(--accent); font-weight: 650; }
.tabs button .pill { margin-left: 4px; }
.tabpane { display: none; } .tabpane.on { display: block; }

.checklist label { display: flex; gap: 10px; align-items: flex-start; padding: 7px 0; border-bottom: 1px dashed var(--line); cursor: pointer; }
.checklist label:last-child { border-bottom: 0; }
.checklist input { margin-top: 3px; flex: none; }

/* AI drawer */
.ai-fab { position: fixed; right: 18px; bottom: 18px; z-index: 45; box-shadow: 0 6px 24px rgba(0,0,0,.18); }
.drawer { position: fixed; top: 0; right: 0; height: 100vh; width: min(480px, 100vw); background: var(--panel); border-left: 1px solid var(--line); z-index: 60; transform: translateX(100%); transition: transform .25s; display: flex; flex-direction: column; box-shadow: -10px 0 40px rgba(0,0,0,.12); }
.drawer.open { transform: none; }
.drawer header { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; gap: 8px; }
.drawer .body { padding: 16px 18px; overflow-y: auto; flex: 1; }
.drawer textarea { min-height: 110px; }
.ai-out { margin-top: 14px; font-size: .93rem; }
.ai-out h1, .ai-out h2, .ai-out h3 { font-size: 1rem; margin-top: 1em; }
.ai-out ul, .ai-out ol { padding-left: 20px; }
.ai-out table { border-collapse: collapse; font-size: .85rem; }
.ai-out td, .ai-out th { border: 1px solid var(--line); padding: 4px 6px; }
.spinner { width: 16px; height: 16px; border: 2px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; }
@keyframes spin { to { transform: rotate(360deg); } }

/* character card */
.pcard h3 { font-size: 1.15rem; margin-bottom: 2px; }
.pcard .q { font-style: italic; color: var(--ink-2); margin-bottom: 10px; }
.pcard dl { margin: 0; font-size: .86rem; }
.pcard dt { font-size: .7rem; text-transform: uppercase; letter-spacing: .06em; color: var(--ink-3); margin-top: 8px; }
.pcard dd { margin: 1px 0 0; }
.swatches { display: flex; gap: 0; border-radius: 8px; overflow: hidden; height: 34px; }
.swatches i { flex: 1; }
.swatches i:last-child { flex: .6; }

/* palette input */
.palette { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.palette label { font-size: .78rem; color: var(--ink-3); display: grid; gap: 4px; }
.palette input[type=color] { width: 100%; height: 52px; border: 1px solid var(--line); border-radius: 8px; padding: 2px; background: var(--panel); cursor: pointer; }
.presets { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 10px; margin-top: 10px; }
.preset { border: 1px solid var(--line); border-radius: 8px; padding: 8px; cursor: pointer; background: var(--panel); text-align: left; font: inherit; color: inherit; }
.preset:hover { border-color: var(--accent); }
.preset .swatches { height: 22px; margin-bottom: 6px; }
.preset small { color: var(--ink-3); display: block; font-size: .74rem; line-height: 1.3; }

/* thumbnail mock */
.thumb { aspect-ratio: 16/9; border-radius: 10px; position: relative; overflow: hidden; display: flex; align-items: flex-end; padding: 6%; }
.thumb .face { position: absolute; right: 8%; bottom: 0; width: 38%; aspect-ratio: 3/4; border-radius: 50% 50% 8px 8px; }
.thumb .txt { position: relative; font-size: 2.2rem; line-height: .95; font-weight: 800; text-transform: uppercase; max-width: 55%; }
.thumb.mini { width: 160px; padding: 8px; }
.thumb.mini .txt { font-size: .85rem; }
.font-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 8px; }
.font-opt { border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; cursor: pointer; background: var(--panel); text-align: left; color: inherit; font-size: 1.3rem; }
.font-opt small { display: block; font-family: var(--font); font-size: .72rem; color: var(--ink-3); }
.font-opt.on { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent-soft); }
.moodboard { display: grid; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); gap: 8px; margin-top: 10px; }
.moodboard img { width: 100%; aspect-ratio: 1; object-fit: cover; border-radius: 6px; background: var(--panel-2); }

/* arquetipos */
.arq { display: flex; flex-direction: column; gap: 6px; }
.arq h3 { margin: 0; }
.arq p { font-size: .88rem; color: var(--ink-2); margin: 0; }
.arq .q { font-style: italic; font-size: .86rem; }
.arq .row { margin-top: auto; padding-top: 8px; }

/* biblia */
.biblia { max-width: 820px; }
.biblia h2 { margin-top: 2em; padding-top: .6em; border-top: 1px solid var(--line); scroll-margin-top: 16px; }
.biblia h3 { margin-top: 1.5em; scroll-margin-top: 16px; }
.biblia table { border-collapse: collapse; width: 100%; font-size: .9rem; margin: 1em 0; display: block; overflow-x: auto; }
.biblia th, .biblia td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.biblia pre { background: var(--panel-2); padding: 12px; border-radius: 8px; overflow-x: auto; font-size: .82rem; }
.biblia blockquote { border-left: 3px solid var(--accent); margin: 0; padding: 4px 14px; color: var(--ink-2); }
.biblia :target { background: var(--accent-soft); }
.bref { font-size: .78rem; text-decoration: none; color: var(--ink-3); border: 1px solid var(--line); padding: 1px 8px; border-radius: 99px; white-space: nowrap; }
.bref:hover { color: var(--accent); border-color: var(--accent); }

/* tools */
.tool h2 { display: flex; gap: 8px; align-items: center; }
.feed { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 14px; }
.feed .vid img, .feed .vid .ph { width: 100%; aspect-ratio: 16/9; object-fit: cover; border-radius: 8px; background: var(--panel-2); display: block; }
.feed .vid .tt { font-size: .85rem; font-weight: 600; margin-top: 6px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.feed .vid .ch { font-size: .75rem; color: var(--ink-3); }
.sizes { display: flex; gap: 16px; align-items: flex-end; flex-wrap: wrap; }
.sizes figure { margin: 0; text-align: center; font-size: .75rem; color: var(--ink-3); }
.sizes img { display: block; border-radius: 6px; margin-bottom: 4px; }
.safe { position: relative; width: 270px; aspect-ratio: 9/16; background: var(--panel-2); border-radius: 10px; overflow: hidden; }
.safe img { width: 100%; height: 100%; object-fit: cover; }
.safe .z { position: absolute; background: rgba(220, 38, 38, .35); border: 1px dashed #dc2626; font-size: .65rem; color: #fff; display: grid; place-items: center; text-shadow: 0 1px 2px #000; }
.title-row { padding: 10px 0; border-bottom: 1px solid var(--line); }
.title-row .mob { font-weight: 600; }
.muted { color: var(--ink-3); font-size: .85rem; }
.kbd-list li { margin-bottom: 4px; }
.flag { background: var(--warn-soft); color: var(--warn); border-radius: 3px; padding: 0 2px; }
.flag.bad { background: var(--bad-soft); color: var(--bad); }
.beat { display: grid; grid-template-columns: 130px 1fr auto; gap: 8px; align-items: start; margin-bottom: 8px; }
.beat select { font-size: .85rem; }
@media (max-width: 640px) { .beat { grid-template-columns: 1fr; } }
.score { display: grid; grid-template-columns: 1fr 44px; gap: 10px; align-items: center; }
.score b { font-size: 1.2rem; text-align: right; }
.big-num { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.mobile-only { display: none; }
@media (max-width: 860px) { .mobile-only { display: inline-flex; } }
