:root {
  --ink: #111111;
  --paper: #FFF8E7;
  --paper-2: #FFF1CC;
  --yellow: #FFD23F;
  --red: #E63946;
  --red-dark: #B8232F;
  --blue: #1D8FE1;
  --teal: #2EC4B6;
  --green: #3EC300;
  --muted: #5d584c;
  --line: 3px solid var(--ink);
  --radius: 10px;
  --shadow: 5px 5px 0 var(--ink);
  --shadow-sm: 3px 3px 0 var(--ink);
  --ui: "Nunito", system-ui, -apple-system, "Segoe UI", sans-serif;
  --display: "Bangers", "Impact", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
body {
  font-family: var(--ui);
  color: var(--ink);
  background-color: var(--paper);
  background-image: radial-gradient(rgba(17, 17, 17, 0.07) 1.2px, transparent 1.4px);
  background-size: 14px 14px;
  min-height: 100vh;
  line-height: 1.45;
}
a { color: var(--blue); font-weight: 700; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.center { text-align: center; }
.row { display: flex; align-items: center; flex-wrap: wrap; }
.gap-sm { gap: 8px; }
.stack { display: flex; flex-direction: column; gap: 14px; }
.inline-form { display: inline; margin: 0; }

/* ---------- header ---------- */
.site-header {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 10px clamp(12px, 3vw, 32px);
  background: var(--yellow); border-bottom: var(--line);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; color: var(--ink); }
.brand-burst {
  width: 34px; height: 34px; background: var(--red); border: 3px solid var(--ink);
  clip-path: polygon(50% 0, 61% 30%, 95% 20%, 72% 47%, 100% 70%, 65% 70%, 60% 100%, 45% 74%, 15% 95%, 27% 62%, 0 45%, 32% 38%, 18% 8%, 44% 26%);
}
.brand-text {
  font-family: var(--display); font-size: 1.9rem; letter-spacing: 1.5px; color: #fff;
  -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; text-shadow: 3px 3px 0 var(--ink);
}
.site-nav { display: flex; align-items: center; gap: 14px; }
.site-nav a:not(.btn), .link-btn { color: var(--ink); text-decoration: none; font-weight: 800; }
.link-btn { background: none; border: 0; cursor: pointer; font: inherit; font-weight: 800; padding: 0; white-space: nowrap; }

/* ---------- buttons ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--ui); font-weight: 800; font-size: 1rem; line-height: 1;
  padding: 11px 18px; border: var(--line); border-radius: var(--radius);
  background: #fff; color: var(--ink); text-decoration: none; cursor: pointer;
  box-shadow: var(--shadow-sm); transition: transform .08s ease, box-shadow .08s ease; white-space: nowrap;
}
@media (hover: hover) { .btn:hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); } }
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn:disabled { opacity: .55; cursor: not-allowed; transform: none; }
.btn:focus-visible, .icon-btn:focus-visible, .rail-btn:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 3px solid var(--blue); outline-offset: 2px;
}
.btn-red { background: var(--red); color: #fff; }
.btn-yellow { background: var(--yellow); }
.btn-blue { background: var(--blue); color: #fff; }
.btn-teal { background: var(--teal); }
.btn-ghost { background: #fff; }
.btn-danger { background: #fff; color: var(--red-dark); }
.btn-sm { padding: 7px 11px; font-size: .88rem; box-shadow: 2px 2px 0 var(--ink); border-width: 2.5px; }
.btn-lg { padding: 15px 26px; font-size: 1.15rem; }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border: 2.5px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink);
  font-size: 1.1rem; font-weight: 800; cursor: pointer; text-decoration: none; flex: 0 0 auto;
}
.icon-btn:hover { background: var(--paper-2); }
.icon-btn:disabled { opacity: .4; cursor: default; }

/* ---------- forms ---------- */
.field { display: flex; flex-direction: column; gap: 6px; font-weight: 700; min-width: 0; }
.field > span { font-size: .92rem; }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=search], select, textarea {
  font: inherit; font-weight: 600; width: 100%; min-width: 0;
  padding: 10px 12px; border: 2.5px solid var(--ink); border-radius: 8px; background: #fff; color: var(--ink);
}
textarea { resize: vertical; min-height: 44px; }
select { min-width: 9rem; appearance: auto; }
input[type=range] { width: 100%; accent-color: var(--red); }
input[type=color] { width: 42px; height: 34px; padding: 0; border: 2.5px solid var(--ink); border-radius: 6px; background: #fff; cursor: pointer; }
input[type=checkbox] { width: 18px; height: 18px; accent-color: var(--red); }
.form-error { background: #ffe0e3; border: 2.5px solid var(--red-dark); border-radius: 8px; padding: 10px 12px; font-weight: 700; margin: 0 0 12px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; }

/* ---------- cards / pages ---------- */
.page { max-width: 1180px; margin: 0 auto; padding: 24px clamp(12px, 3vw, 32px) 80px; }
.panel-card { background: #fff; border: var(--line); border-radius: 14px; box-shadow: var(--shadow); padding: clamp(16px, 3vw, 28px); }
.card-title { font-family: var(--display); font-size: 2.1rem; letter-spacing: 1px; margin: 0 0 14px; font-weight: 400; }
.shout-title {
  font-family: var(--display); font-weight: 400; letter-spacing: 2px; margin: 0;
  font-size: clamp(2.6rem, 7vw, 5rem); line-height: .95; color: #fff;
  -webkit-text-stroke: 2.5px var(--ink); paint-order: stroke fill; text-shadow: 5px 5px 0 var(--ink);
}
.shout-title.small { font-size: clamp(2rem, 5vw, 3rem); text-shadow: 4px 4px 0 var(--ink); }
.shout-title .hl { color: var(--yellow); }
.page-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 22px; flex-wrap: wrap; }
.auth-card { max-width: 440px; margin: 40px auto; }
.error-card { max-width: 520px; margin: 60px auto; text-align: center; }
.empty-state { text-align: center; max-width: 620px; margin: 30px auto; }
.chip { display: inline-block; padding: 3px 9px; border: 2px solid var(--ink); border-radius: 999px; font-size: .78rem; font-weight: 800; background: #fff; }
.chip-live { background: var(--yellow); animation: pulse 1.4s ease-in-out infinite; }
.chip-bad { background: #ffd5d9; }
@keyframes pulse { 50% { transform: scale(1.06); } }

/* ---------- landing ---------- */
.landing { max-width: 1180px; margin: 0 auto; padding: 30px clamp(12px, 3vw, 32px) 80px; }
.hero { display: grid; grid-template-columns: 1.1fr .9fr; gap: 40px; align-items: center; padding: 30px 0 50px; }
.lead { font-size: 1.2rem; font-weight: 600; max-width: 38rem; }
.hero-cta { display: flex; gap: 14px; flex-wrap: wrap; margin-top: 22px; }
.mock-page {
  aspect-ratio: 2 / 3; background: #fff; border: var(--line); box-shadow: 10px 10px 0 var(--ink); border-radius: 6px;
  padding: 16px; display: grid; gap: 12px; grid-template-rows: 1fr 1.2fr 1fr; transform: rotate(2deg);
}
.mp { border: var(--line); position: relative; overflow: hidden; }
.mp1 { background: linear-gradient(160deg, #7FD3FF, #1D8FE1); clip-path: polygon(0 0, 100% 0, 100% 82%, 0 100%); }
.mp2 { background: repeating-radial-gradient(circle at 70% 40%, #FFD23F 0 8px, #FF9E1B 8px 16px); clip-path: polygon(0 18%, 100% 0, 100% 100%, 0 82%); margin: -18px 0; }
.mp3 { background: linear-gradient(20deg, #E63946, #FFD23F); clip-path: polygon(0 0, 100% 18%, 100% 100%, 0 100%); }
.mock-bubble {
  position: absolute; left: 10%; top: 14%; background: #fff; border: 3px solid var(--ink); border-radius: 50%;
  padding: 14px 18px; font-family: "Comic Neue", var(--ui); font-weight: 800; text-transform: uppercase; font-size: .9rem;
}
.mock-sfx {
  position: absolute; right: 8%; bottom: 18%; font-family: var(--display); font-size: 2.6rem; color: var(--yellow);
  -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill; text-shadow: 4px 4px 0 var(--ink); transform: rotate(-9deg);
}
.features { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 18px; }
.feature { background: #fff; border: var(--line); border-radius: 12px; padding: 18px; box-shadow: var(--shadow-sm); }
.feature:nth-child(3n+1) { background: #FFF6D1; }
.feature:nth-child(3n+2) { background: #E3F4FF; }
.feature:nth-child(3n) { background: #FFE5E7; }
.feature h2 { font-family: var(--display); font-weight: 400; letter-spacing: 1px; font-size: 1.6rem; margin: 0 0 6px; }
.feature p { margin: 0; font-weight: 600; }

/* ---------- dashboard ---------- */
.comic-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 22px; }
.comic-card { background: #fff; border: var(--line); border-radius: 12px; box-shadow: var(--shadow); overflow: hidden; display: flex; flex-direction: column; }
.comic-cover { position: relative; display: block; aspect-ratio: 2 / 3; background: var(--paper-2); border-bottom: var(--line); overflow: hidden; }
.comic-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.comic-cover .chip { position: absolute; top: 8px; right: 8px; }
.cover-fallback { position: absolute; inset: 0; display: flex; align-items: flex-start; justify-content: center; padding: 14px; }
.cover-fallback span {
  font-family: var(--display); font-size: 1.8rem; text-align: center; color: var(--yellow); line-height: 1;
  -webkit-text-stroke: 1.5px var(--ink); paint-order: stroke fill; text-shadow: 3px 3px 0 var(--ink);
}
.comic-cover img + .cover-fallback, .cover-fallback.over-art { background: none; }
.comic-meta { padding: 12px; display: flex; flex-direction: column; gap: 6px; }
.comic-title { font-size: 1.05rem; margin: 0; font-weight: 800; }
.comic-meta p { margin: 0; }

/* ---------- new comic wizard ---------- */
.mode-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 22px; }
.mode-card {
  display: flex; flex-direction: column; align-items: flex-start; gap: 4px; text-align: left; font: inherit;
  padding: 18px; border: var(--line); border-radius: 14px; background: #fff; cursor: pointer; box-shadow: var(--shadow-sm);
}
.mode-card strong { font-size: 1.2rem; }
.mode-card.active { background: var(--yellow); box-shadow: var(--shadow); }
.mode-icon { font-size: 1.6rem; }
.new-form { display: flex; flex-direction: column; gap: 22px; }
.form-section { display: flex; flex-direction: column; gap: 16px; }
.section-head { background: var(--ink); color: #fff; margin: -8px -8px 4px; padding: 10px 14px; border-radius: 8px; }
.section-head h2 { margin: 0; font-family: var(--display); font-weight: 400; letter-spacing: 1px; font-size: 1.6rem; }
.section-head p { margin: 4px 0 0; color: #ddd; }
.section-head .muted { color: #ccc; }
.idea-chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip-btn { font: inherit; font-weight: 700; font-size: .85rem; padding: 6px 12px; border: 2px solid var(--ink); border-radius: 999px; background: var(--paper-2); cursor: pointer; }
.chip-btn:hover { background: var(--yellow); }
.style-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(165px, 1fr)); gap: 12px; }
.style-card { position: relative; display: flex; flex-direction: column; gap: 4px; padding: 10px; border: 2.5px solid var(--ink); border-radius: 10px; background: #fff; cursor: pointer; }
.style-card input { position: absolute; opacity: 0; pointer-events: none; }
.style-card:has(input:checked) { background: #FFF2BF; box-shadow: var(--shadow-sm); outline: 3px solid var(--red); }
.style-card:has(input:focus-visible) { outline: 3px solid var(--blue); }
.style-swatch { height: 46px; border: 2px solid var(--ink); border-radius: 6px; }
.entity-list { display: flex; flex-direction: column; gap: 12px; }
.entity-row { display: grid; grid-template-columns: 96px minmax(0, 1fr); gap: 14px; border: 2.5px solid var(--ink); border-radius: 10px; padding: 12px; background: #FFFCF3; }
.entity-fields { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.entity-fields .span-2 { grid-column: span 2; }
.ref-drop {
  width: 96px; height: 96px; border: 2.5px dashed var(--ink); border-radius: 10px; background: #fff; display: flex; align-items: center; justify-content: center;
  text-align: center; font-size: .75rem; font-weight: 800; cursor: pointer; overflow: hidden; position: relative;
}
.ref-drop img { width: 100%; height: 100%; object-fit: cover; }
.ref-drop input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.entity-remove { justify-self: end; }
.submit-bar { display: flex; align-items: center; justify-content: flex-end; gap: 16px; flex-wrap: wrap; position: sticky; bottom: 0; padding: 14px 0; background: linear-gradient(transparent, var(--paper) 30%); }

/* ---------- modal & toast ---------- */
.modal-backdrop { position: fixed; inset: 0; background: rgba(17, 17, 17, .55); z-index: 100; display: flex; align-items: center; justify-content: center; padding: 16px; }
.modal {
  background: #fff; border: var(--line); border-radius: 14px; box-shadow: 8px 8px 0 var(--ink);
  width: min(560px, 100%); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); display: flex; flex-direction: column; animation: pop .14s ease-out;
}
.modal.wide { width: min(900px, 100%); }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 12px 16px; background: var(--yellow); border-bottom: var(--line); border-radius: 11px 11px 0 0; }
.modal-head h2 { margin: 0; font-family: var(--display); font-weight: 400; letter-spacing: 1px; font-size: 1.6rem; }
.modal-body { padding: 16px; overflow: auto; }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; padding: 12px 16px; border-top: 2px solid #eee; flex-wrap: wrap; }
@keyframes pop { from { transform: scale(.94); opacity: 0; } }
#toast-root { position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%); z-index: 120; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--ink); color: #fff; padding: 10px 16px; border-radius: 10px; font-weight: 700; box-shadow: 3px 3px 0 var(--yellow); max-width: 90vw; animation: pop .15s ease-out; }
.toast.bad { background: var(--red-dark); box-shadow: 3px 3px 0 var(--ink); }
.toast.good { background: #1f7a3a; }

/* ---------- editor ---------- */
.editor-body { overflow: hidden; background-size: 16px 16px; overscroll-behavior: none; -webkit-tap-highlight-color: transparent; }
.editor-main { height: 100vh; height: 100dvh; }
.editor { display: flex; flex-direction: column; height: 100%; }
.ed-top {
  display: flex; align-items: center; gap: 8px; padding: 8px 10px; background: var(--yellow); border-bottom: var(--line); flex: 0 0 auto; min-width: 0;
}
.ed-title { max-width: 320px; font-family: var(--display) !important; font-size: 1.35rem !important; letter-spacing: 1px; padding: 5px 10px !important; }
.save-state { font-size: .8rem; font-weight: 800; color: var(--muted); white-space: nowrap; }
.save-state.dirty { color: var(--red-dark); }
.ed-top-tools { display: flex; align-items: center; gap: 6px; margin-left: auto; }
.ed-view { display: flex; align-items: center; gap: 6px; }
.divider { width: 2px; height: 26px; background: rgba(0, 0, 0, .25); margin: 0 2px; }
.zoom-label { font: inherit; font-weight: 800; font-size: .85rem; min-width: 56px; height: 36px; border: 2.5px solid var(--ink); border-radius: 8px; background: #fff; cursor: pointer; }
.page-label { font-weight: 800; font-size: .9rem; min-width: 64px; text-align: center; }
.ed-status { background: var(--ink); color: #fff; padding: 8px 14px; display: flex; align-items: center; gap: 12px; flex-wrap: wrap; font-weight: 700; }
.ed-status .bar { flex: 1 1 160px; height: 12px; border: 2px solid #fff; border-radius: 999px; overflow: hidden; min-width: 120px; }
.ed-status .bar i { display: block; height: 100%; background: repeating-linear-gradient(45deg, var(--yellow) 0 10px, #ffbf00 10px 20px); transition: width .4s; }
.ed-status .btn { box-shadow: none; }
.ed-body { flex: 1 1 auto; display: flex; min-height: 0; position: relative; }
.ed-rail { flex: 0 0 76px; background: #fff; border-right: var(--line); display: flex; flex-direction: column; gap: 2px; padding: 6px 4px; overflow-y: auto; }
.rail-btn {
  display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 8px 2px; border: 2px solid transparent; border-radius: 10px;
  background: none; cursor: pointer; font: inherit; color: var(--ink);
}
.rail-btn span { font-size: 1.35rem; line-height: 1; }
.rail-btn em { font-style: normal; font-size: .7rem; font-weight: 800; }
.rail-btn:hover { background: var(--paper-2); }
.rail-btn[aria-selected=true] { background: var(--yellow); border-color: var(--ink); }
.ed-drawer { flex: 0 0 300px; background: #fff; border-right: var(--line); display: flex; flex-direction: column; min-height: 0; }
.drawer-head, .props-head { display: flex; align-items: center; justify-content: space-between; padding: 10px 12px; border-bottom: 2.5px solid var(--ink); background: var(--paper-2); }
.drawer-head h2, .props-head h2 { margin: 0; font-family: var(--display); font-weight: 400; letter-spacing: 1px; font-size: 1.45rem; }
.drawer-body, .props-body { overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 14px; min-height: 0; flex: 1 1 auto; }
.ed-canvas-wrap {
  flex: 1 1 auto; position: relative; min-width: 0; background: #E9E3D3; background-image: radial-gradient(rgba(17, 17, 17, .08) 1px, transparent 1.2px); background-size: 12px 12px;
  touch-action: none; -webkit-touch-callout: none; -webkit-user-select: none; user-select: none;
}
.stage-scroller { position: absolute; inset: 0; overflow: auto; display: flex; }
.stage-host { margin: auto; padding: 24px; }
.stage-sizer { position: relative; overflow: hidden; box-shadow: 6px 6px 0 var(--ink); outline: 3px solid var(--ink); background: #fff; }
.ed-canvas-wrap.dragover { box-shadow: inset 0 0 0 3px var(--blue); }
.stage-host.dragover .stage-sizer { outline-color: var(--blue); outline-width: 5px; }
.ed-props { flex: 0 0 310px; background: #fff; border-left: var(--line); display: flex; flex-direction: column; min-height: 0; }
.props-sheet { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.props-head-btns { display: flex; align-items: center; gap: 8px; }
.props-close, .props-toggle { display: none; }
.ed-overlay { position: absolute; inset: 0; background: rgba(255, 248, 231, .92); z-index: 5; display: flex; align-items: center; justify-content: center; padding: 20px; }
.overlay-card { text-align: center; max-width: 480px; }
.overlay-card .shout-title { font-size: clamp(2rem, 6vw, 3.4rem); margin-bottom: 12px; }
.overlay-card p { font-weight: 700; }
.pencil { font-size: 3rem; display: inline-block; animation: scribble .6s ease-in-out infinite alternate; }
@keyframes scribble { from { transform: rotate(-18deg) translateX(-8px); } to { transform: rotate(10deg) translateX(8px); } }

/* drawer & props content */
.tool-section { display: flex; flex-direction: column; gap: 8px; }
.tool-section > h3 { margin: 0; font-size: .8rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 800; }
.tool-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.tool-grid.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tool-tile {
  font: inherit; font-weight: 800; font-size: .8rem; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 8px 6px; border: 2.5px solid var(--ink); border-radius: 10px; background: #fff; cursor: pointer; min-height: 64px; text-align: center; color: var(--ink);
}
@media (hover: hover) { .tool-tile:hover { background: #FFF6D1; transform: translate(-1px, -1px); box-shadow: 2px 2px 0 var(--ink); } }
.tool-tile svg { width: 100%; height: auto; display: block; }
.tool-tile.active { background: var(--yellow); }
.layout-tile { padding: 6px; gap: 6px; }
.layout-tile svg { background: #fff; }
.title-preview { font-size: 1.7rem; line-height: 1.05; letter-spacing: 1px; paint-order: stroke fill; }
.sfx-preview { font-family: var(--display); font-size: 1.6rem; paint-order: stroke fill; -webkit-text-stroke: 1.5px var(--ink); }
.page-list { display: flex; flex-direction: column; gap: 10px; }
.page-item { display: grid; grid-template-columns: 74px minmax(0, 1fr); gap: 10px; align-items: center; padding: 6px; border: 2.5px solid var(--ink); border-radius: 10px; background: #fff; cursor: pointer; }
.page-item.active { background: var(--yellow); }
.page-item img, .page-thumb-empty { width: 74px; aspect-ratio: 2 / 3; object-fit: cover; border: 2px solid var(--ink); background: #fff; display: block; }
.page-item .page-actions { display: flex; gap: 4px; flex-wrap: wrap; margin-top: 4px; }
.page-item .page-actions .icon-btn { width: 30px; height: 30px; font-size: .85rem; border-width: 2px; }
.page-item strong { display: block; }
.cast-card { border: 2.5px solid var(--ink); border-radius: 10px; overflow: hidden; background: #fff; }
.cast-card .sheet { aspect-ratio: 3 / 2; background: var(--paper-2); display: flex; align-items: center; justify-content: center; border-bottom: 2.5px solid var(--ink); cursor: zoom-in; position: relative; }
.cast-card .sheet img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cast-card .sheet .busy { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(255, 255, 255, .75); font-weight: 800; }
.cast-card .cast-info { padding: 8px 10px; display: flex; flex-direction: column; gap: 6px; }
.cast-card .cast-info p { margin: 0; font-size: .82rem; color: var(--muted); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.asset-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.asset-tile { position: relative; border: 2.5px solid var(--ink); border-radius: 8px; overflow: hidden; background: #fff; cursor: pointer; aspect-ratio: 1; padding: 0; }
.asset-tile img { width: 100%; height: 100%; object-fit: cover; display: block; }
.asset-tile .asset-del { position: absolute; top: 4px; right: 4px; width: 26px; height: 26px; font-size: .8rem; border-width: 2px; }
.asset-tile .asset-label { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(17, 17, 17, .75); color: #fff; font-size: .68rem; font-weight: 700; padding: 2px 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.upload-btn { position: relative; overflow: hidden; }
.upload-btn input { position: absolute; inset: 0; opacity: 0; cursor: pointer; }
.upload-btn:focus-within { outline: 3px solid var(--blue); outline-offset: 2px; }
.upload-btn input:focus-visible { outline: none; }
.file-pick { display: flex; align-items: center; gap: 8px; min-width: 0; flex-wrap: wrap; }
.file-pick .upload-btn { flex: 0 0 auto; }
.file-pick .file-name { flex: 1 1 8rem; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 600; font-size: .82rem; color: var(--muted); }
.pf { display: flex; flex-direction: column; gap: 5px; font-weight: 700; font-size: .85rem; min-width: 0; }
.pf-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; align-items: end; }
.pf-row.three { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.pf-inline { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: .85rem; }
.pf input[type=text], .pf select, .pf textarea, .pf input[type=number] { padding: 7px 9px; font-size: .9rem; }
.pf select { min-width: 0; }
.props-group { display: flex; flex-direction: column; gap: 10px; border: 2px solid #e6dfcc; border-radius: 10px; padding: 10px; }
.props-group > h3 { margin: 0 0 2px; font-size: .78rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 800; }
.props-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.char-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.char-chip { display: inline-flex; align-items: center; gap: 5px; border: 2px solid var(--ink); border-radius: 999px; padding: 3px 9px; font-size: .8rem; font-weight: 700; cursor: pointer; background: #fff; }
.char-chip:has(input:checked) { background: var(--yellow); }
.char-chip input { width: 14px; height: 14px; }
.style-swatches { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
.style-swatches button { font: inherit; border: 2px solid var(--ink); border-radius: 8px; background: #f6f1e4; padding: 6px 2px; cursor: pointer; overflow: hidden; }
.style-swatches button.active { outline: 3px solid var(--red); }
.hint { font-size: .8rem; color: var(--muted); font-weight: 600; margin: 0; }
.story-html p { margin: 0 0 8px; }
.sheet-view { width: 100%; border: 2.5px solid var(--ink); border-radius: 8px; }
.color-row { display: flex; align-items: center; gap: 8px; }

/* movie export */
.movie-modal { display: flex; flex-direction: column; gap: 18px; }
.movie-new { background: var(--paper); border: 2.5px solid var(--ink); border-radius: 12px; padding: 14px 16px; display: flex; flex-direction: column; gap: 12px; }
.movie-new p { margin: 0; }
.movie-h { font-family: var(--display); font-weight: 400; letter-spacing: 1px; font-size: 1.35rem; margin: 0; }
.movie-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; }
.movie-grid select { min-width: 0; width: 100%; }
.movie-progress, .movie-bar { display: flex; flex-direction: column; gap: 6px; }
.movie-progress .bar, .movie-bar .bar { display: block; height: 12px; border: 2px solid var(--ink); border-radius: 999px; overflow: hidden; background: #fff; }
.movie-progress .bar i, .movie-bar .bar i { display: block; height: 100%; background: repeating-linear-gradient(45deg, var(--yellow) 0 10px, #ffbf00 10px 20px); transition: width .5s; }
.movie-list { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.movie-card { display: grid; grid-template-columns: 200px minmax(0, 1fr); gap: 14px; align-items: start; border: 2.5px solid var(--ink); border-radius: 12px; padding: 10px; background: #fff; box-shadow: var(--shadow-sm); }
.movie-card.playing { grid-template-columns: 1fr; }
.movie-media { border: 2px solid var(--ink); border-radius: 8px; overflow: hidden; background: var(--ink); aspect-ratio: 16 / 9; display: flex; align-items: center; justify-content: center; }
.movie-media img, .movie-media video { width: 100%; height: 100%; object-fit: contain; display: block; }
.movie-card.playing .movie-media { aspect-ratio: auto; max-height: 70vh; }
.movie-card.playing .movie-media video { max-height: 70vh; }
.movie-ph { font-size: 2.4rem; }
.movie-info { display: flex; flex-direction: column; gap: 8px; min-width: 0; }
.movie-err { color: var(--red-dark); font-weight: 700; margin: 0; }
.movie-confirm { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; background: #ffe9ec; border: 2px solid var(--red-dark); border-radius: 8px; padding: 8px; }
.movie-confirm[hidden] { display: none; }

/* ---------- balance ---------- */
.balance-chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 10px; border: 2.5px solid var(--ink); border-radius: 999px;
  background: #fff; color: var(--ink) !important; text-decoration: none; font-weight: 800; font-size: .9rem; white-space: nowrap; box-shadow: 2px 2px 0 var(--ink);
}
.balance-chip:hover { background: var(--paper-2); }
.balance-chip:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.balance-chip .balance-label { font-weight: 700; font-size: .78rem; color: var(--muted); }
.balance-plus { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; border-radius: 50%; background: var(--green); color: #fff; font-size: .9rem; line-height: 1; border: 2px solid var(--ink); }
.balance-chip.low .balance-plus { background: var(--red); }
.ed-top .balance-chip { padding: 4px 5px 4px 9px; font-size: .85rem; }
.notice { background: #FFF6D1; border: 2.5px solid var(--ink); border-radius: 10px; padding: 10px 14px; font-weight: 700; margin: 0 0 16px; }
.notice-good { background: #DDF6E3; }
.link-blue { color: var(--blue); text-decoration: underline; }
.btn-ink { background: var(--ink); color: #fff; }
.chip-good { background: #DDF6E3; }
.block { display: block; }
.balance-now { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 12px 14px; border: 2.5px solid var(--ink); border-radius: 12px; background: var(--paper-2); margin-bottom: 12px; }
.balance-now span { font-weight: 800; }
.balance-now strong { font-family: var(--display); font-weight: 400; font-size: 2.2rem; letter-spacing: 1px; line-height: 1; }
.balance-block { display: flex; flex-direction: column; gap: 10px; padding: 12px 0; border-top: 2px solid #eee; }
.balance-block h3 { margin: 0; font-size: .82rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 800; }
.pack-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.pack-btn {
  font: inherit; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 14px 8px; cursor: pointer; color: var(--ink);
  border: var(--line); border-radius: 12px; background: var(--yellow); box-shadow: var(--shadow-sm); transition: transform .08s ease;
}
.pack-btn strong { font-family: var(--display); font-weight: 400; font-size: 1.9rem; letter-spacing: 1px; line-height: 1; }
@media (hover: hover) { .pack-btn:not(:disabled):hover { transform: translate(-1px, -1px); box-shadow: 4px 4px 0 var(--ink); } }
.pack-btn:disabled { opacity: .5; cursor: not-allowed; }
.pack-btn:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
.custom-amount { display: flex; align-items: flex-end; gap: 10px; }
.custom-amount .field { flex: 1 1 auto; }
.money-input { display: flex; align-items: center; gap: 6px; font-weight: 800; }
.money-input input { flex: 1 1 auto; }
/* ---------- sharing & public reader ---------- */
a.chip { color: var(--ink); text-decoration: none; }
.chip.fit { align-self: flex-start; }
.share-btn { display: inline-flex; align-items: center; gap: 2px; }
.share-modal { display: flex; flex-direction: column; gap: 16px; }
.share-section { display: flex; flex-direction: column; gap: 10px; }
.share-section + .share-section { border-top: 2px solid #eee; padding-top: 14px; }
.share-section > h3 { margin: 0; font-size: .82rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 800; }
.share-section p { margin: 0; }
.comic-share { display: flex; flex-direction: column; gap: 10px; }
.share-link { display: flex; gap: 8px; }
.share-link input { flex: 1 1 auto; font-size: .88rem; }
.share-bar { display: flex; flex-wrap: wrap; gap: 8px; }
.publish-progress { border-radius: 8px; }
.reader { max-width: 900px; margin: 0 auto; display: flex; flex-direction: column; gap: 22px; }
.reader-head { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }
.reader-head p { margin: 0; }
.reader-pages { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 18px; }
.reader-page img { display: block; width: 100%; height: auto; border: var(--line); border-radius: 6px; box-shadow: var(--shadow); background: #fff; }
.reader-cta { text-align: center; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.reader-cta p { margin: 0; max-width: 34rem; font-weight: 600; }
.billing-layout { display: grid; grid-template-columns: minmax(0, 1.2fr) minmax(0, .8fr); gap: 22px; align-items: start; margin-bottom: 22px; }
.billing-card { display: flex; flex-direction: column; gap: 12px; }
.how-list { margin: 0; padding-left: 20px; display: flex; flex-direction: column; gap: 8px; font-weight: 600; }
.estimate-box { display: flex; flex-direction: column; gap: 2px; margin-right: auto; }
.estimate-box p { margin: 0; }
#cost-estimate.short { color: var(--red-dark); }

/* ---------- feedback ---------- */
.feedback-form { display: flex; flex-direction: column; gap: 16px; margin: 0; }
.feedback-form .form-error { margin: 0; }
.feedback-form textarea { min-height: 120px; }
.star-field { border: 0; margin: 0; padding: 0; min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.star-field legend { font-weight: 700; font-size: .92rem; padding: 0; margin-bottom: 8px; }
.star-row { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.stars { display: flex; gap: 4px; }
.star { position: relative; cursor: pointer; line-height: 1; }
.star input { position: absolute; opacity: 0; width: 1px; height: 1px; margin: 0; pointer-events: none; }
.star span {
  display: block; font-size: 2.3rem; color: #fff; -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill;
  transition: transform .08s ease, color .08s ease; padding: 2px; border-radius: 8px;
}
.star.on span { color: var(--yellow); text-shadow: 2px 2px 0 var(--ink); }
@media (hover: hover) { .star:hover span { transform: scale(1.12) rotate(-6deg); } }
.star input:focus-visible + span { outline: 3px solid var(--blue); outline-offset: 1px; }
.star-caption { font-family: var(--display); font-size: 1.35rem; letter-spacing: 1px; min-height: 1.4em; }
.star-clear { font-size: .85rem; color: var(--muted); text-decoration: underline; }
.feedback-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 12px; }
.feedback-item { border: 2.5px solid var(--ink); border-radius: 10px; padding: 12px 14px; background: #fff; display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.feedback-meta { flex-wrap: wrap; align-items: baseline; }
.feedback-meta a + a { margin-left: 6px; }
.feedback-stars span { font-size: 1.35rem; color: #ddd6c3; }
.feedback-stars span.on { color: #E6A700; }
.feedback-message { margin: 0; white-space: pre-wrap; overflow-wrap: anywhere; font-weight: 600; }
.stat .stat-stars { font-size: 1.5rem; color: #E6A700; text-transform: none; }
.stat .rating-bars { display: flex; flex-wrap: wrap; gap: 4px 10px; margin-top: 4px; }
.stat .rating-bars span { font-size: .9rem; font-weight: 800; text-transform: none; letter-spacing: 0; color: var(--ink); }

/* ---------- tables ---------- */
.table-wrap { overflow-x: auto; }
.data-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.data-table th, .data-table td { text-align: left; padding: 8px 10px; border-bottom: 2px solid #eee; vertical-align: top; }
.data-table th { font-size: .75rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); }
.data-table .num { text-align: right; white-space: nowrap; }
.data-table .pos { color: #1f7a3a; font-weight: 800; }

/* ---------- admin ---------- */
.admin-nav { display: flex; gap: 8px; }
.admin-nav a { padding: 7px 14px; border: 2.5px solid var(--ink); border-radius: 999px; background: #fff; color: var(--ink); text-decoration: none; font-weight: 800; }
.admin-nav a.active { background: var(--yellow); }
.admin-title { font-size: clamp(1.3rem, 3vw, 1.8rem); margin: 2px 0; word-break: break-word; }
.crumbs { margin: 0; }
.admin-card { display: flex; flex-direction: column; gap: 14px; margin-bottom: 22px; }
.admin-card > summary { cursor: pointer; }
.admin-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 22px; align-items: start; }
.admin-form { display: flex; flex-direction: column; gap: 14px; }
.check-row { display: flex; flex-direction: column; gap: 8px; }
.row-between { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.search-row { display: flex; gap: 8px; }
.search-row input { flex: 1 1 auto; }
.stat-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat { background: #fff; border: var(--line); border-radius: 12px; padding: 12px 14px; box-shadow: var(--shadow-sm); display: flex; flex-direction: column; gap: 2px; }
.stat span { font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .5px; color: var(--muted); }
.stat strong { font-family: var(--display); font-weight: 400; font-size: 1.9rem; letter-spacing: 1px; line-height: 1.05; }
.sub-h { margin: 6px 0 0; font-size: .8rem; text-transform: uppercase; letter-spacing: 1px; color: var(--muted); font-weight: 800; }
.plain-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 6px; }
.lettering-list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 10px; }
.lettering-list ul { margin: 4px 0 0; padding-left: 18px; }
.admin-cover { max-width: 160px; border: 2.5px solid var(--ink); border-radius: 8px; }
.admin-comic-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: 14px; }
.admin-comic { border: 2.5px solid var(--ink); border-radius: 10px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.admin-comic-cover { aspect-ratio: 2 / 3; background: var(--paper-2); display: flex; align-items: center; justify-content: center; border-bottom: 2.5px solid var(--ink); overflow: hidden; color: var(--ink); text-align: center; padding: 0; }
.admin-comic-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-comic-cover span { font-family: var(--display); font-size: 1.4rem; padding: 10px; font-weight: 400; }
.admin-comic-meta { padding: 8px 10px; display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.admin-comic-meta strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.admin-image-grid { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
.admin-image { border: 2.5px solid var(--ink); border-radius: 10px; overflow: hidden; background: #fff; display: flex; flex-direction: column; }
.admin-image-btn { padding: 0; border: 0; border-bottom: 2.5px solid var(--ink); background: var(--paper-2); cursor: zoom-in; aspect-ratio: 1; display: block; }
.admin-image-btn img { width: 100%; height: 100%; object-fit: cover; display: block; }
.admin-image-btn:focus-visible { outline: 3px solid var(--blue); outline-offset: -3px; }
.admin-image-meta { padding: 6px 8px 8px; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.admin-image-meta span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lightbox { margin: 0; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.lightbox img { max-width: 100%; max-height: 70vh; max-height: 70dvh; border: 2.5px solid var(--ink); border-radius: 8px; }
.pager { display: flex; align-items: center; justify-content: center; gap: 12px; flex-wrap: wrap; }
.danger-zone { border-color: var(--red-dark); }

@media (max-width: 1180px) {
  .ed-drawer { flex-basis: 260px; }
  .ed-props { flex-basis: 270px; }
}

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr; }
  .features { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .hide-sm { display: none !important; }
  .billing-layout, .admin-cols { grid-template-columns: 1fr; }
  .stat-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }

  /* editor: canvas on top, then the properties peek bar, then the tool tabs */
  .editor { --rail-h: 58px; --peek-h: 52px; position: relative; }
  .ed-top { gap: 6px; padding: 6px 8px; }
  .ed-title { flex: 1 1 auto; width: 0; min-width: 64px; max-width: none; font-size: 1.1rem !important; }
  .save-state { display: none; }
  .ed-top-tools { margin-left: 0; gap: 4px; }
  .ed-view {
    position: absolute; z-index: 6; left: 50%; transform: translateX(-50%); bottom: calc(var(--rail-h) + var(--peek-h) + 10px);
    gap: 4px; padding: 4px 6px; background: #fff; border: 2.5px solid var(--ink); border-radius: 999px; box-shadow: var(--shadow-sm); white-space: nowrap;
  }
  .ed-view .icon-btn, .ed-view .btn { width: 34px; height: 34px; padding: 0; border-width: 2px; border-radius: 999px; box-shadow: none; font-size: 1rem; }
  .ed-view .zoom-label { height: 34px; min-width: 54px; border-width: 2px; border-radius: 999px; }
  .ed-view .page-label { min-width: 56px; font-size: .85rem; }
  .ed-view .divider { height: 22px; }
  .ed-body { flex-direction: column; }
  .ed-canvas-wrap { order: 1; flex: 1 1 auto; min-height: 0; }
  .stage-host { padding: 10px; }

  .ed-rail {
    order: 3; flex: 0 0 var(--rail-h); height: var(--rail-h); flex-direction: row; gap: 2px;
    border-right: 0; border-top: var(--line); overflow-x: auto; overflow-y: hidden; padding: 3px 4px;
  }
  .rail-btn { flex: 1 0 54px; justify-content: center; padding: 4px 2px; }
  .rail-btn span { font-size: 1.2rem; }
  .rail-btn em { font-size: .66rem; }

  .ed-drawer {
    position: absolute; left: 0; right: 0; bottom: var(--rail-h); z-index: 9; max-height: min(64%, calc(100% - var(--rail-h) - 24px));
    border: 0; border-top: var(--line); border-radius: 16px 16px 0 0; box-shadow: 0 -4px 0 rgba(0, 0, 0, .15);
  }
  .drawer-head { border-radius: 14px 14px 0 0; }

  .ed-props { order: 2; position: relative; z-index: 7; flex: 0 0 var(--peek-h); height: var(--peek-h); border: 0; background: transparent; display: block; }
  .props-sheet {
    position: absolute; left: 0; right: 0; bottom: 0; background: #fff;
    border-top: var(--line); border-radius: 14px 14px 0 0; box-shadow: 0 -3px 0 rgba(0, 0, 0, .12);
  }
  .props-head { height: var(--peek-h); flex: 0 0 auto; padding: 6px 10px; border-radius: 12px 12px 0 0; cursor: pointer; }
  .props-head h2 { font-size: 1.3rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
  .ed-props:not(.expanded) .props-head { border-bottom: 0; }
  .props-toggle, .props-close { display: inline-flex; }
  .props-toggle .chev { display: inline-block; font-size: .7rem; transition: transform .15s; }
  .ed-props.expanded .props-toggle .chev { transform: rotate(180deg); }
  .props-body { display: none; }
  .ed-props.expanded .props-body { display: flex; max-height: 55vh; max-height: 55dvh; }
}

@media (max-width: 900px), (pointer: coarse) {
  .pf input[type=text], .pf select, .pf textarea, .pf input[type=number] { font-size: 16px; }
}

@media (pointer: coarse) {
  .page-item .page-actions .icon-btn { width: 38px; height: 38px; }
  .asset-tile .asset-del { width: 34px; height: 34px; }
  .char-chip { padding: 6px 11px; }
}

@media (max-width: 600px) {
  .grid-2, .grid-3, .entity-fields, .mode-switch, .features { grid-template-columns: 1fr; }
  .entity-fields .span-2 { grid-column: auto; }
  .entity-row { grid-template-columns: 1fr; }
  .site-nav { gap: 10px; }
  .site-nav a:not(.btn):not(.balance-chip) { display: none; }
  .pack-grid { gap: 8px; }
  .pack-btn strong { font-size: 1.5rem; }
  .custom-amount { flex-direction: column; align-items: stretch; }
  .reader-page img { box-shadow: var(--shadow-sm); }
  .search-row { flex-direction: column; }
  .data-table thead { display: none; }
  .data-table, .data-table tbody, .data-table tr, .data-table td { display: block; width: 100%; }
  .data-table tr { border: 2px solid #e6dfcc; border-radius: 10px; padding: 6px 10px; margin-bottom: 10px; }
  .data-table td { border: 0; padding: 3px 0; display: flex; justify-content: space-between; gap: 12px; text-align: right; }
  .data-table td::before { content: attr(data-label); font-weight: 800; font-size: .75rem; text-transform: uppercase; color: var(--muted); text-align: left; flex: 0 0 auto; }
  .data-table td[colspan] { justify-content: center; }
  .data-table td[colspan]::before { content: none; }
  .data-table .num { text-align: right; }
  .admin-nav { width: 100%; }
  .admin-comic-grid, .admin-image-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .hide-xs { display: none !important; }
  .brand-text { font-size: 1.6rem; }
  .movie-grid { grid-template-columns: 1fr; }
  .movie-card { grid-template-columns: 1fr; }
  .comic-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; }
}
