:root {
  --ink: #16130f;
  --muted: #5e564c;
  --paper: #f3efe6;
  --paper-2: #e7e0d2;
  --white: #fffdf8;
  --red: #c4161c;
  --red-dark: #8e1014;
  --line: rgba(22, 19, 15, 0.12);
  --serif: "Newsreader", Georgia, "Times New Roman", serif;
  --sans: "Outfit", "Segoe UI", sans-serif;
  --shadow: 0 18px 40px rgba(48, 28, 12, 0.08);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(900px 420px at 0% -10%, rgba(196, 22, 28, 0.08), transparent 55%),
    var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.5;
}
body::before {
  content: "";
  display: block;
  height: 6px;
  background: linear-gradient(90deg, var(--red), #8e1014 40%, var(--ink));
}
img { max-width: 100%; }
a { color: inherit; }
button, input, textarea, select { font: inherit; color: inherit; }
code {
  font-family: "Segoe UI", Consolas, monospace;
  font-size: 0.92em;
}
:focus-visible { outline: 2px solid var(--red); outline-offset: 2px; }

.wrap { width: min(1120px, calc(100% - 32px)); margin: 0 auto; }
.masthead {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 18px 0 14px;
  border-bottom: 1px solid var(--line);
}
.brand { display: flex; gap: 12px; align-items: center; text-decoration: none; }
.brand-logo {
  height: 72px;
  width: auto;
  display: block;
  background: transparent;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.45));
}
body.page-editor .brand-logo { height: 56px; }
.brand-text { display: flex; flex-direction: column; line-height: 1.1; }
.brand-text strong { font-family: var(--serif); font-size: 1.25rem; font-weight: 650; }
.brand-text small { color: var(--muted); letter-spacing: 0.04em; }
.nav { display: flex; gap: 6px; overflow-x: auto; }
.nav a {
  text-decoration: none;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  white-space: nowrap;
}
.nav a.is-active { color: var(--ink); box-shadow: inset 0 -2px 0 var(--red); }
.nav form { margin: 0; }
.nav button {
  border: 0;
  background: transparent;
  padding: 8px 12px;
  border-radius: 999px;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
}
body.page-editor .nav button { color: rgba(244, 239, 232, 0.7); }

.hero { padding: 42px 0 18px; }
.hero.narrow { max-width: 720px; }
.kicker {
  margin: 0 0 8px;
  color: var(--red);
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 0.78rem;
}
h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(2.3rem, 5vw, 4.4rem);
  font-weight: 650;
  letter-spacing: -0.03em;
  line-height: 0.98;
}
h2 { margin: 0; font-family: var(--serif); font-size: 1.8rem; font-weight: 650; }
h3 { margin: 0; font-size: 1.05rem; }
.lede { max-width: 62ch; color: var(--muted); font-size: 1.08rem; }
.page-intro { padding: 28px 0 8px; }
.page-intro h1 { font-size: clamp(2rem, 4vw, 3.3rem); }

.hero-actions, .form-actions, .card-actions, .submit-bar, .dock, .lightbox-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 11px 16px;
  text-decoration: none;
  background: transparent;
  cursor: pointer;
  font-weight: 650;
}
.btn-primary { background: var(--red); color: white; }
.btn-primary:hover { background: var(--red-dark); }
.btn-ghost { background: var(--white); border-color: var(--line); color: var(--ink); }
.custom-size[hidden] { display: none !important; }
.btn-sm { padding: 7px 11px; font-size: 0.92rem; }
.btn-xl { padding: 14px 22px; font-size: 1.05rem; }
.btn:disabled { opacity: 0.6; cursor: wait; }
.btn-download {
  background: var(--red);
  color: #fff;
  letter-spacing: 0.03em;
  padding: 14px 18px;
}
.btn-download:hover { background: var(--red-dark); }
.text-btn {
  border: 0;
  background: none;
  padding: 0;
  color: var(--red);
  cursor: pointer;
  font-weight: 650;
}

.steps {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  padding: 10px 0 20px;
  margin: 0;
}
.steps li {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  box-shadow: var(--shadow);
}
.steps strong { display: block; font-family: var(--serif); font-size: 1.15rem; }
.steps span { color: var(--muted); font-size: 0.92rem; }

.block { padding: 12px 0 28px; }
.block-head, .inspector-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  margin-bottom: 14px;
}
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 12px;
}
.choice {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-align: left;
  text-decoration: none;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px;
  cursor: pointer;
  min-height: 124px;
}
.choice small, .hint, .when, .filename, .drag-hint, .status, .site-foot { color: var(--muted); }
.choice b { font-family: var(--serif); font-size: 1.15rem; }
.choice.is-selected {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(196, 22, 28, 0.16);
}
.choice-icon { font-size: 1.3rem; }

.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 18px;
  margin: 14px 0;
  box-shadow: var(--shadow);
}
.stack { display: grid; gap: 8px; }
.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.span-2 { grid-column: span 2; }
.field { display: grid; gap: 6px; font-weight: 650; }
.field input, .field textarea, .field select, .custom-size input {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  border-radius: 12px;
  padding: 11px 12px;
  font-weight: 500;
}
.opt { font-weight: 500; color: var(--muted); }
.label-line { font-weight: 650; }
.check { display: flex; gap: 8px; align-items: center; margin: 8px 0; font-weight: 500; }
.dropzone {
  display: grid;
  gap: 8px;
  place-items: center;
  min-height: 140px;
  border: 1.5px dashed rgba(22, 19, 15, 0.28);
  border-radius: 16px;
  padding: 16px;
  background: #faf7f1;
  cursor: pointer;
  text-align: center;
  font-weight: 500;
}
.dropzone input { max-width: 100%; }
.dropzone.is-drag { border-color: var(--red); background: #fff; }
.dropzone img, .brand-preview {
  max-height: 88px;
  border-radius: 12px;
  background: transparent;
}
.custom-size {
  display: flex;
  gap: 12px;
  margin-top: 12px;
}
.custom-size label { display: grid; gap: 6px; font-weight: 650; }
.submit-bar {
  position: sticky;
  bottom: 10px;
  background: rgba(243, 239, 230, 0.92);
  backdrop-filter: blur(8px);
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 18px;
  justify-content: space-between;
}
.form-error { color: var(--red-dark); margin: 0; font-weight: 650; }
.banner {
  border-radius: 14px;
  padding: 12px 14px;
  margin: 12px 0;
}
.banner.ok { background: #e5f4e8; color: #14532d; }
.banner.err { background: #fde8e8; color: #8e1014; }
.footer-demo {
  margin: 8px 0 0;
  padding: 12px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 12px;
  text-align: center;
}
.identity-strip {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 16px;
  margin-bottom: 20px;
  background: var(--ink);
  color: var(--paper);
  border-radius: 18px;
}
.identity-strip a { color: #ffd0d0; }

.art-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 16px;
}
.art-card {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow);
}
.thumb {
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  background: #1a1814;
  color: #f3efe6;
  text-decoration: none;
  padding: 10px;
}
.thumb img { width: 100%; height: 100%; object-fit: contain; }
.art-meta { padding: 12px 14px 14px; display: grid; gap: 6px; }
.art-meta h3 a { text-decoration: none; }
.empty {
  background: var(--white);
  border: 1px dashed var(--line);
  border-radius: 18px;
  padding: 22px;
}
.chip-row { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 1px solid var(--line);
  background: var(--white);
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  text-decoration: none;
  cursor: pointer;
}
.chip.is-selected { background: var(--ink); color: var(--paper); border-color: var(--ink); }
.filters { margin: 8px 0 18px; }
.pager { display: flex; gap: 14px; align-items: center; justify-content: center; padding: 18px; }

.site-foot {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  border-top: 1px solid var(--line);
  padding: 16px 0 28px;
  font-size: 0.92rem;
}
.noscript {
  margin: 12px auto 24px;
  width: min(1120px, calc(100% - 32px));
  background: #fde8e8;
  padding: 10px 12px;
  border-radius: 10px;
}

body.page-editor {
  background: #12110f;
  color: #f4efe8;
}
body.page-editor::before { position: sticky; top: 0; z-index: 20; }
body.page-editor .wrap { width: min(1440px, calc(100% - 20px)); }
body.page-editor .masthead,
body.page-editor .site-foot { border-color: rgba(255, 255, 255, 0.08); }
body.page-editor .brand-text small,
body.page-editor .site-foot,
body.page-editor .nav a { color: rgba(244, 239, 232, 0.7); }
body.page-editor .nav a.is-active { color: white; }
body.page-editor .btn-ghost { background: #2a2622; color: #f4efe8; border-color: rgba(255,255,255,.16); }
body.page-editor .chip { background: #1c1a17; color: #f4efe8; border-color: rgba(255,255,255,.12); }
body.page-editor .chip.is-selected { background: var(--red); border-color: var(--red); color: white; }
.studio { padding: 14px 0 24px; }
.studio-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 340px;
  gap: 16px;
  align-items: start;
}
.stage-panel { display: grid; gap: 10px; }
.stage {
  display: grid;
  place-items: center;
  min-height: 420px;
  padding: 18px;
  border-radius: 18px;
  background-color: #0c0b09;
  background-image:
    linear-gradient(45deg, #171512 25%, transparent 25%),
    linear-gradient(-45deg, #171512 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #171512 75%),
    linear-gradient(-45deg, transparent 75%, #171512 75%);
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
}
#art, #preview {
  background: #000;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.45);
  touch-action: none;
  cursor: grab;
  max-width: 100%;
}
#art.is-dragging { cursor: grabbing; }
.drag-hint, .filename, .status { margin: 0; }
.filename code { color: #f4efe8; }
.dock .btn-download { margin-left: auto; }
.inspector {
  background: #1c1a17;
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 18px;
  padding: 8px 14px 18px;
  max-height: calc(100vh - 24px);
  overflow: auto;
  position: sticky;
  top: 12px;
}
.inspector summary {
  cursor: pointer;
  font-weight: 700;
  padding: 12px 0 6px;
}
.inspector .field input,
.inspector .field textarea,
.inspector .field select,
.inspector .custom-size input,
.custom-size.dark input {
  background: #0e0d0b;
  color: #f4efe8;
  border-color: rgba(255,255,255,.12);
}
.color-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.color-grid label { display: grid; gap: 4px; font-size: 0.88rem; }
.color-grid input, .field input[type="color"] {
  width: 100%;
  height: 40px;
  padding: 4px;
  background: transparent;
  border: 0;
}
.inspector .text-btn { margin: 4px 0 8px; }
.enhance-photo { width: 100%; margin: 8px 0 4px; }
.enhance-photo.is-busy,
.enhance-photo.is-busy:disabled { cursor: wait; opacity: 0.75; }
.enhance-photo.is-done,
.enhance-photo.is-done:disabled { cursor: default; opacity: 1; }
.enhance-note {
  margin: 0 0 8px;
  color: rgba(244, 239, 232, 0.62);
  font-size: 0.86rem;
  line-height: 1.35;
}
#restore-photo,
#clear-photo { display: block; text-align: left; }
#restore-photo[hidden] { display: none !important; }
.empty.light { background: transparent; color: #f4efe8; border-color: rgba(255,255,255,.2); }

dialog.lightbox {
  border: 0;
  border-radius: 18px;
  background: #100e0c;
  color: #f4efe8;
  width: auto;
  max-width: 96vw;
  padding: 12px;
}
dialog.lightbox::backdrop { background: rgba(0, 0, 0, 0.72); }
.lightbox-bar { margin-bottom: 10px; }
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: #fffdf8;
  color: #16130f;
  padding: 12px 16px;
  border-radius: 999px;
  z-index: 80;
  box-shadow: var(--shadow);
  max-width: min(92vw, 520px);
}

@media (max-width: 980px) {
  .steps, .form-grid, .studio-body { grid-template-columns: 1fr; }
  .span-2 { grid-column: auto; }
  .identity-strip, .masthead { flex-direction: column; align-items: flex-start; }
  .inspector { display: none; max-height: none; position: static; }
  .inspector.is-open {
    display: block;
    position: fixed;
    left: 0;
    right: 0;
    bottom: 74px;
    z-index: 35;
    max-height: min(68vh, 640px);
    border-radius: 18px 18px 0 0;
  }
  .dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 40;
    background: #12110f;
    border-top: 1px solid rgba(255,255,255,.08);
    padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  }
  .dock .btn-download { margin-left: 0; flex: 1; }
  body.page-editor { padding-bottom: 84px; }
  .toast { bottom: 92px; }
  .stage { min-height: 0; }
}

@media (min-width: 981px) {
  body.page-editor:not(.is-preview) .inspector { display: block; }
  #close-inspector { display: none; }
}

body.page-login {
  background: #0c1b33;
  color: #f6f1e8;
}
body.page-login::before { display: none; }
body.page-login .wrap {
  width: min(1040px, calc(100% - 28px));
  min-height: 100vh;
  display: grid;
  align-items: center;
}
body.page-login .masthead,
body.page-login .site-foot { display: none; }
body.page-login main { padding: 28px 0; }
.install-app {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 18px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--white);
}
.install-app p { margin: 0; }
.install-app[hidden] { display: none !important; }
body.page-login .install-app {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.14);
  color: #f6f1e8;
}
.login-shell {
  display: grid;
  grid-template-columns: 1.05fr 0.95fr;
  background: #fffdf8;
  color: var(--ink);
  border-radius: 28px;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.35);
}
.login-brand {
  background:
    radial-gradient(420px 220px at 0% 0%, rgba(196, 22, 28, 0.35), transparent 60%),
    #0c1b33;
  color: #f6f1e8;
  padding: 42px 36px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 32px;
  min-height: 460px;
}
.login-brand img { height: 92px; width: auto; }
.login-brand h1 {
  margin: 8px 0 12px;
  font-family: var(--serif);
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1.05;
  color: white;
}
.login-brand p { margin: 0; color: rgba(246, 241, 232, 0.78); }
.login-panel { padding: 42px 36px; }
.login-panel h2 {
  margin: 0 0 8px;
  font-family: var(--serif);
  font-size: 2.3rem;
}
.pass-line { display: flex; gap: 10px; align-items: center; }
.pass-line input { flex: 1; }
.user-list { display: grid; gap: 12px; }
.user-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 14px 16px;
}
.user-row p { margin: 4px 0 0; color: var(--muted); }
.user-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: flex-end; }
.inline-form { display: flex; gap: 8px; align-items: center; }
.inline-form input {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 12px;
  min-width: 180px;
  background: var(--white);
}
@media (max-width: 800px) {
  .login-shell { grid-template-columns: 1fr; }
  .login-brand { min-height: 0; }
  .user-row { flex-direction: column; align-items: stretch; }
}
