@font-face { font-family: "Baloo 2"; src: url("fonts/Baloo2-Regular.ttf") format("truetype"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Baloo 2"; src: url("fonts/Baloo2-Bold.ttf") format("truetype"); font-weight: 700; font-display: swap; }

:root {
  --paper: #fcfdfe;
  --grid: #e3ebf5;
  --ink: #1d2742;
  --muted: #5b6680;
  --margin: #e0605e;
  --pencil: #f4c542;
  --pencil-dark: #c99a14;
  --desk: #eef2f7;
  --focus: #2f6fd6;
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--desk);
  color: var(--ink);
  font: 400 17px/1.5 "Baloo 2", system-ui, sans-serif;
}

/* ---- header */
.top { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 18px; padding: 18px 28px; background: var(--ink); color: #fff; }
.wordmark { margin: 0; font-weight: 700; font-size: 28px; letter-spacing: -0.01em; }
.wordmark::before { content: ""; display: inline-block; width: 14px; height: 14px; margin-right: 10px; border-radius: 50%; background: var(--pencil); vertical-align: 2px; }
.tagline { margin: 0; color: #c9d2e6; font-size: 16px; }

/* ---- licence gate */
.who { margin: 0 0 0 auto; color: #c9d2e6; font-size: 14px; }
.link { padding: 0; font: inherit; color: #fff; text-decoration: underline; background: none; border: 0; cursor: pointer; }
.gate { padding: 28px 16px; }
.gate-sheet { max-width: 480px; margin: 40px auto; }
.gate-sheet > label { display: block; margin-bottom: 6px; font-weight: 700; font-size: 18px; }
.gate-sheet input { margin-bottom: 4px; letter-spacing: 0.04em; }
.gate-sheet .make { margin-top: 18px; }
input[type="text"][readonly] { background: #eef2f7; color: var(--muted); }

/* ---- layout: the exercise-book sheet (form) beside the desk (preview) */
.bench { display: grid; grid-template-columns: minmax(340px, 480px) 1fr; gap: 28px; padding: 28px; max-width: 1400px; margin: 0 auto; }

.sheet {
  position: relative;
  padding: 26px 28px 30px 58px;
  background-color: var(--paper);
  /* maths exercise-book grid */
  background-image: linear-gradient(var(--grid) 1px, transparent 1px), linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  border: 1px solid #d3dbe7;
  border-radius: 4px;
}
/* the red margin line every exercise book has */
.sheet::before { content: ""; position: absolute; top: 0; bottom: 0; left: 38px; width: 2px; background: var(--margin); opacity: 0.75; }

h1 { margin: 0 0 18px; font-size: 34px; line-height: 1.1; font-weight: 700; }

fieldset { border: 0; margin: 0 0 20px; padding: 0; min-width: 0; }
legend, .field > label { display: block; margin-bottom: 6px; font-weight: 700; font-size: 18px; padding: 0; }
.opt { font-weight: 400; color: var(--muted); }
.hint { margin: 6px 0 0; color: var(--muted); font-size: 15px; line-height: 1.4; }
.field { margin-bottom: 20px; min-width: 0; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }

input[type="text"], input[type="number"] {
  width: 100%; padding: 9px 12px; font: inherit; color: var(--ink);
  background: #fff; border: 2px solid var(--ink); border-radius: 8px;
}
input::placeholder { color: #9aa3b8; }

/* ---- character pack cards */
.packs { display: grid; gap: 10px; }
.pack { position: relative; display: grid; grid-template-columns: 1fr; gap: 2px; padding: 12px 14px; background: #fff; border: 2px solid #c7d0de; border-radius: 12px; cursor: pointer; }
.pack input { position: absolute; opacity: 0; pointer-events: none; }
.pack:has(input:checked) { border-color: var(--ink); box-shadow: 4px 4px 0 var(--pencil); }
.pack:has(input:focus-visible) { outline: 3px solid var(--focus); outline-offset: 2px; }
.pack-cast { display: flex; gap: 6px; margin-bottom: 6px; color: var(--ink); }
.pack-cast span { flex: 1; max-width: 56px; }
.pack-cast svg { display: block; width: 100%; height: 52px; }
.pack-name { font-weight: 700; font-size: 18px; }
.pack-who { color: var(--muted); font-size: 14px; }

/* ---- segmented choices */
.seg { display: inline-flex; border: 2px solid var(--ink); border-radius: 10px; overflow: hidden; background: #fff; }
.seg label { position: relative; }
.seg input { position: absolute; opacity: 0; }
.seg span { display: block; padding: 7px 18px; cursor: pointer; font-weight: 700; }
.seg label + label span { border-left: 2px solid var(--ink); }
.seg input:checked + span { background: var(--ink); color: #fff; }
.seg input:focus-visible + span { outline: 3px solid var(--focus); outline-offset: -5px; }

/* ---- book number stepper */
.stepper { display: flex; }
.stepper input { border-radius: 0; text-align: center; -moz-appearance: textfield; }
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }
.stepper button { width: 42px; flex: none; font: 700 22px/1 "Baloo 2", sans-serif; color: var(--ink); background: #fff; border: 2px solid var(--ink); cursor: pointer; }
.stepper button:first-child { border-right: 0; border-radius: 8px 0 0 8px; }
.stepper button:last-child { border-left: 0; border-radius: 0 8px 8px 0; }

/* ---- the one bold thing: a pencil-yellow make button */
.make {
  width: 100%; margin-top: 6px; padding: 12px 20px;
  font: 700 22px/1.2 "Baloo 2", sans-serif; color: var(--ink);
  background: var(--pencil); border: 2px solid var(--ink); border-radius: 12px;
  box-shadow: 0 5px 0 var(--ink); cursor: pointer;
  transition: transform 80ms ease, box-shadow 80ms ease;
}
.make:hover { background: #f7d062; }
.make:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--ink); }
.make:disabled { opacity: 0.6; cursor: progress; }

.status { min-height: 1.5em; margin: 14px 0 0; font-size: 15px; }
.status[data-kind="error"] { color: #b3261e; font-weight: 700; }
.status[data-kind="done"] { color: #1f6b3a; }
.status[data-kind="warn"] { color: #8a5300; font-weight: 700; }

/* ---- preview desk */
.desk { display: flex; flex-direction: column; min-height: 70vh; min-width: 0; }
.empty { flex: 1; display: flex; flex-direction: column; justify-content: center; align-items: center; padding: 40px; text-align: center; border: 2px dashed #b9c4d6; border-radius: 12px; color: var(--muted); }
.empty p { max-width: 36ch; margin: 0; }
.empty-title { font-size: 24px; font-weight: 700; color: var(--ink); margin-bottom: 8px !important; }
#viewer { flex: 1; width: 100%; min-height: 78vh; border: 1px solid #c7d0de; border-radius: 6px; background: #fff; }
.actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 14px; }
.download, .next { padding: 10px 22px; font: 700 18px/1.2 "Baloo 2", sans-serif; border: 2px solid var(--ink); border-radius: 10px; cursor: pointer; text-decoration: none; }
.cover-info { max-width: 70ch; }
.listing { margin-top: 22px; padding: 18px 20px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; }
.listing h2 { margin: 0 0 4px; font-size: 22px; }
.file-pick { display: inline-block; margin-top: 8px; padding: 6px 14px; font-weight: 700; border: 2px dashed var(--ink); border-radius: 10px; cursor: pointer; }
.file-pick input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.file-pick:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }
.words { margin: 0 0 20px; padding: 12px 14px; background: #fff; border: 2px solid #c7d0de; border-radius: 12px; }
.words[open] { border-color: var(--ink); }
.words summary { font-weight: 700; font-size: 18px; cursor: pointer; }
.words .field { margin: 12px 0 0; }
.words .field > label { font-size: 16px; }
.words textarea { width: 100%; padding: 8px 12px; font: inherit; font-size: 16px; color: var(--ink); background: #fff; border: 2px solid var(--ink); border-radius: 8px; resize: vertical; }
.sub-h { margin: 22px 0 4px !important; font-size: 20px !important; }
.pins-preview { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; margin-top: 12px; }
.pins-preview img { width: 100%; height: auto; border: 1px solid #c7d0de; border-radius: 6px; }
@media (max-width: 600px) { .pins-preview { grid-template-columns: repeat(3, 1fr); } }
.tabs { display: flex; gap: 4px; flex-basis: 100%; margin-top: 6px; }
.tabs button { padding: 6px 14px; font: 700 15px "Baloo 2", sans-serif; color: #c9d2e6; background: none; border: 0; border-bottom: 3px solid transparent; cursor: pointer; }
.tabs button[aria-current="page"] { color: #fff; border-bottom-color: var(--pencil); }
.account { padding: 28px 16px; }
.acct-sheet { max-width: 760px; margin: 0 auto; }
.acct-sheet h2 { margin: 24px 0 8px; font-size: 22px; }
.acct-facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 18px; margin: 0; }
.acct-facts dt { font-weight: 700; }
.acct-facts dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.mini { margin-left: 6px; padding: 1px 10px; font: 700 14px "Baloo 2", sans-serif; color: var(--ink); background: #fff; border: 1.5px solid var(--ink); border-radius: 8px; cursor: pointer; }
.plans { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.plans li { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; align-items: center; padding: 12px 14px; background: #fff; border: 2px solid #c7d0de; border-radius: 12px; }
.plans li.owned { border-color: var(--ink); }
.plans .p-name { font-weight: 700; font-size: 18px; }
.plans .p-what { grid-column: 1; color: var(--muted); font-size: 15px; }
.plans .p-state { grid-row: 1 / span 2; grid-column: 2; font-weight: 700; }
.plans .owned .p-state { color: #1f6b3a; }
.plans a.upgrade { padding: 6px 14px; color: var(--ink); background: var(--pencil); border: 2px solid var(--ink); border-radius: 10px; text-decoration: none; }
@media (max-width: 520px) { .acct-facts { grid-template-columns: 1fr; gap: 2px; } .acct-facts dd { margin-bottom: 8px; } }
.help-topics details { margin: 10px 0; background: #fff; border: 2px solid #c7d0de; border-radius: 12px; }
.help-topics details[open] { border-color: var(--ink); }
.help-topics summary { padding: 12px 14px; font-weight: 700; font-size: 18px; cursor: pointer; }
.help-topics .h-body { padding: 0 16px 14px; }
.help-topics .h-body p, .help-topics .h-body li { font-size: 16px; line-height: 1.5; }
.help-topics .h-body li { margin: 4px 0; }
.help-topics .h-tip { padding: 8px 12px; background: #fff7d6; border-left: 4px solid var(--pencil); border-radius: 6px; }
.help-topics .h-tier { margin-left: 8px; padding: 1px 8px; font-size: 13px; font-weight: 700; color: var(--muted); border: 1.5px solid #c7d0de; border-radius: 999px; }
.welcome { position: relative; margin: 0 0 18px; padding: 12px 16px; background: #fff7d6; border: 2px solid var(--ink); border-radius: 12px; }
.welcome-title { margin: 0 0 4px; font-weight: 700; font-size: 18px; }
.welcome ol { margin: 4px 0; padding-left: 22px; }
.welcome #welcome-close { position: absolute; top: 10px; right: 10px; }
.checks { margin-top: 12px; padding: 10px 14px; background: #eaf6ee; border: 2px solid #1f6b3a; border-radius: 12px; }
.checks summary { font-weight: 700; color: #1f6b3a; cursor: pointer; }
.checks ul { margin: 6px 0 2px; padding-left: 20px; font-size: 15px; }
.money { margin-top: 12px; padding: 12px 16px; background: #fff; border: 2px solid var(--ink); border-radius: 12px; }
.money h2 { margin: 0 0 6px; font-size: 20px; }
.money-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin: 0; }
.money-row input { width: 7em; padding: 6px 10px; font: inherit; border: 2px solid var(--ink); border-radius: 8px; }
#money-out { font-weight: 700; font-size: 18px; }
.check { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.history { margin: 10px 0; padding-left: 22px; }
.history li { margin-bottom: 8px; }
.history button { margin-left: 8px; padding: 2px 10px; font: 700 14px "Baloo 2", sans-serif; color: var(--ink); background: #fff; border: 1.5px solid var(--ink); border-radius: 8px; cursor: pointer; }
.link-dark { padding: 0; font: inherit; font-size: 14px; color: var(--muted); text-decoration: underline; background: none; border: 0; cursor: pointer; }
.listing textarea { width: 100%; margin-top: 10px; padding: 10px 12px; font: 14px/1.45 ui-monospace, Menlo, Consolas, monospace; color: var(--ink); border: 1px solid #c7d0de; border-radius: 8px; resize: vertical; }
.download { background: var(--ink); color: #fff; }
.next { background: #fff; color: var(--ink); }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

@media (max-width: 900px) {
  .bench { grid-template-columns: 1fr; padding: 16px; gap: 18px; }
  .top { padding: 14px 16px; }
  .sheet { padding: 20px 16px 24px 40px; }
  .sheet::before { left: 24px; }
  #viewer { min-height: 70vh; }
  .desk { min-height: 0; }
  .empty { padding: 28px 16px; }
}
@media (max-width: 420px) {
  .row { grid-template-columns: 1fr; gap: 0; }
  .seg span { padding: 7px 13px; }
}
@media (prefers-reduced-motion: reduce) { .make { transition: none; } }
.season { margin: 8px 0 0; padding: 0; list-style: none; font-size: 15px; }
.season li { margin: 4px 0; }
.season button { padding: 1px 10px; margin-right: 6px; font: 700 14px "Baloo 2", sans-serif; color: var(--ink); background: var(--pencil); border: 1.5px solid var(--ink); border-radius: 8px; cursor: pointer; }
#theme-msg[data-kind="error"] { color: #b3261e; font-weight: 700; }
#theme-msg[data-kind="done"] { color: #1f6b3a; }

/* Pro-only options (KDP trims, book lengths): visible to everyone, usable with Pro. */
.pro-opt.locked span { opacity: .45; cursor: not-allowed; }
.pro-opt.locked span::after { content: " Pro"; font-size: 11px; font-weight: 700; vertical-align: super; }

/* Channel picker and "Ready for your shop" box */
.seg-wrap { flex-wrap: wrap; }
.steps-list { margin: 6px 0 10px; padding-left: 20px; }
.steps-list li { margin: 4px 0; }
#code-check[data-kind="warn"] { color: #8a5300; font-weight: 700; }
#code-check[data-kind="done"] { color: #1f6b3a; font-weight: 700; }

.photos-preview img { aspect-ratio: 4 / 3; }
.feedback { margin: 10px 0 14px; padding: 10px 12px; border: 1.5px dashed #9aa5bd; border-radius: 10px; }
.feedback .fb-q { margin: 0 0 6px; font-weight: 700; }
.feedback button { margin-right: 8px; }

/* Theme Studio bonuses (My account) */
.acct-bonus p { margin: 8px 0; }
.make-mini { padding: 8px 14px; min-height: 44px; font: 700 15px "Baloo 2", sans-serif; color: #fff; background: var(--ink); border: 0; border-radius: 10px; cursor: pointer; }
.make-mini:disabled { opacity: .6; cursor: progress; }

/* Step-by-step guide (coach) on the Make tab */
.coach { border: 2px solid var(--ink, #1d2742); border-radius: 14px; background: #fffbea; padding: 12px 14px; margin: 0 0 16px; box-shadow: 3px 3px 0 var(--ink, #1d2742); }
/* Same height on every step, so the form below never jumps while a seller is clicking it. */
.coach .coach-title { min-height: 1.35em; }
.coach .coach-tip { min-height: 4.5em; }
/* On wide screens the guide stays in view while the seller scrolls down the form. */
@media (min-width: 900px) and (min-height: 600px) { .coach { position: sticky; top: 8px; z-index: 20; } }
.coach.nudge { background: #ffe9a8; }
.coach-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.coach-count { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: #5b6478; }
.coach-dots { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.coach-dots li { width: 22px; height: 22px; border-radius: 50%; display: grid; place-items: center; font-size: 12px; font-weight: 700; background: #fff; border: 1.5px solid #c9cfdb; color: #8a93a6; }
.coach-dots li.done { background: #2f9e6e; border-color: #2f9e6e; color: #fff; }
.coach-dots li.now { background: #f6c445; border-color: var(--ink, #1d2742); color: var(--ink, #1d2742); }
.coach-title { font-size: 18px; font-weight: 800; margin: 8px 0 2px; }
.coach-tip { margin: 0 0 8px; }
.coach-btns { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.coach-btns .mini[hidden] { display: none; }
.coach-target { outline: 3px solid #f6c445; outline-offset: 4px; border-radius: 10px; }
.coach-nudge { animation: coach-pulse 1.2s ease-in-out 3; }
@keyframes coach-pulse { 50% { outline-color: #e8590c; outline-offset: 8px; } }
@media (prefers-reduced-motion: reduce) { .coach-nudge { animation: none; } }
