:root{
  --bg:#161310; --panel:#1e1a15; --line:rgba(220,200,170,.14); --ink:#efe7d8; --muted:#a08e72;
  --rust:#c46a3f; --rust-ink:#fff;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
  margin:0; background:var(--bg); color:var(--ink);
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,Helvetica,Arial,sans-serif;
  -webkit-font-smoothing:antialiased; overflow:hidden;
}
button,select,textarea{font:inherit}

.topbar{display:flex;align-items:center;gap:10px;padding:12px 16px;border-bottom:1px solid var(--line)}
.topbar .logo{width:26px;height:26px;border-radius:7px}
.topbar b{font-weight:600;font-size:15px}
.topbar .home{margin-left:auto;color:var(--muted);text-decoration:none;font-size:13px}
.topbar .home:hover{color:var(--ink)}

.app{display:flex;flex-direction:column;height:calc(100% - 51px)}
@media(min-width:820px){ .app{flex-direction:row-reverse} }

/* preview stage */
.stage{flex:1;display:grid;place-items:center;padding:18px;overflow:hidden;min-height:0}
.card-wrap{overflow:hidden;border-radius:14px;box-shadow:0 20px 50px rgba(0,0,0,.5)}
canvas#card{display:block}
/* the real, full-size card — scaled down for preview via JS transform */
.card{
  transform-origin:top left;
  display:flex;flex-direction:column;justify-content:center;
  font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Georgia,serif;
}
.card .body{padding:9% 10%;font-size:34px;line-height:1.5;overflow:hidden;flex:1;display:flex;flex-direction:column;justify-content:center}
.card .body :first-child{margin-top:0}
.card .body :last-child{margin-bottom:0}
.card .body h1{font-size:1.7em;line-height:1.15;margin:.2em 0 .35em;font-weight:700;letter-spacing:-.01em}
.card .body h2{font-size:1.35em;margin:.6em 0 .3em;font-weight:700}
.card .body p{margin:.55em 0}
.card .body strong{font-weight:700}
.card .body em{font-style:italic}
.card .body ul,.card .body ol{margin:.5em 0;padding-left:1.3em}
.card .body li{margin:.25em 0}
.card .body code{font-family:ui-monospace,Menlo,monospace;font-size:.85em;padding:.08em .3em;border-radius:6px;background:rgba(128,128,128,.18)}
.card .body blockquote{margin:.4em 0;padding-left:.7em;border-left:4px solid currentColor;opacity:.85}
.card .body a{color:inherit;text-decoration:underline;text-underline-offset:2px}
.card .credit{padding:0 10% 7%;font-size:19px;letter-spacing:.02em;opacity:.5;font-family:-apple-system,sans-serif}

/* themes */
.card.paper{background:linear-gradient(160deg,#fdf9f1,#efe3ce);color:#241f18}
.card.paper .body h1,.card.paper .body h2{color:#9c4a26}
.card.ink{background:linear-gradient(160deg,#211c16,#14100a);color:#efe7d8}
.card.ink .body h1,.card.ink .body h2{color:#e0894f}
.card.sky{background:linear-gradient(160deg,#eef4fb,#d6e4f3);color:#1a2230}
.card.sky .body h1,.card.sky .body h2{color:#2f6f8f}

/* controls */
.controls{background:var(--panel);border-top:1px solid var(--line);padding:14px 16px;display:flex;flex-direction:column;gap:12px}
@media(min-width:820px){ .controls{width:380px;border-top:0;border-right:1px solid var(--line);overflow-y:auto} }
.controls textarea{
  width:100%;min-height:180px;max-height:60vh;resize:vertical;padding:12px;border-radius:12px;
  border:1px solid var(--line);background:#181510;color:var(--ink);line-height:1.5;
  font-family:ui-monospace,Menlo,monospace;font-size:15px;
}
@media(min-width:820px){ .controls textarea{min-height:240px} }
.controls textarea:focus{outline:2px solid var(--rust);outline-offset:1px}
.row{display:flex;flex-direction:column;gap:6px}
.row .label{font-size:11px;text-transform:uppercase;letter-spacing:.1em;color:var(--muted)}
.chips{display:flex;gap:8px;flex-wrap:wrap}
.chip{padding:8px 14px;border-radius:999px;border:1px solid var(--line);background:transparent;color:var(--ink);cursor:pointer}
.chip[aria-pressed="true"]{background:var(--rust);border-color:var(--rust);color:var(--rust-ink)}
.swatch{width:22px;height:22px;border-radius:6px;border:1px solid rgba(0,0,0,.2);vertical-align:-5px;margin-right:6px;display:inline-block}
.save{margin-top:2px;padding:14px;border:0;border-radius:12px;background:var(--rust);color:#fff;font-weight:600;font-size:16px;cursor:pointer}
.save:active{transform:translateY(1px)}
.save:disabled{opacity:.6}
.note{color:var(--muted);font-size:12px;text-align:center;line-height:1.5}
.note a{color:var(--muted)}
