/* Deliberately plain: browser-default buttons and inputs, Times, black on white. */

:root {
  color-scheme: light;
  --ink: #111;
  --muted: #6b6b6b;
  --faint: #b5b5b5;
  --bad: #a01818;
}

[hidden] { display: none !important; }
html { background: #fff; }
body {
  margin: 0;
  background: #fff;
  color: var(--ink);
  font-family: "Times New Roman", Times, serif;
  font-size: 19px;
  line-height: 1.45;
}
main {
  max-width: 40rem;
  margin: 0 auto;
  padding: 2.5rem 16px 5rem;
}

/* ── Top bar ───────────────────────────────────────────────── */
.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  border-bottom: 1px solid var(--ink); padding-bottom: 0.6rem; margin: 0 0 2rem;
}
.brand { font-size: 0.8rem; letter-spacing: 0.3em; text-transform: uppercase; color: var(--ink); text-decoration: none; }
a.brand:hover { text-decoration: underline; }
.tb-right { display: flex; align-items: center; gap: 0.9rem; }
button.help { width: 1.7em; height: 1.7em; padding: 0; border-radius: 50%; font-family: inherit; font-weight: bold; line-height: 1; }
legend button.help { font-size: 0.75rem; margin-left: 0.35rem; vertical-align: 1px; }

h2 { font-size: 1.15rem; font-weight: normal; font-style: italic; margin: 2rem 0 1rem; }
hr { border: 0; border-top: 1px solid var(--faint); margin: 2rem 0; }
p { margin: 0 0 1rem; }

.tbd { text-decoration: underline dotted var(--bad); text-underline-offset: 3px; }

/* ── H-10 speaking ─────────────────────────────────────────── */
.stage { display: flex; gap: 1.25rem; align-items: flex-start; margin-bottom: 1.5rem; }
.stage .h10 { margin: 0; flex: none; }
.stage .h10 img { width: 56px; height: auto; display: block; }
.stage.big { flex-direction: column; align-items: center; text-align: center; margin-top: 1rem; }
.stage.big .h10 img { width: auto; height: min(46vh, 380px); }
.speech { flex: 1; min-width: 0; }
.stage.big .speech { max-width: 32rem; width: 100%; min-height: 9em; display: flex; flex-direction: column; }
.stage.big .actions { margin-top: auto; }
.line { margin: 0 0 1rem; min-height: 1.45em; }
/* typewriter: every letter is laid out from the start, then revealed */
.ch { visibility: hidden; }
.ch.on { visibility: visible; }
.ch.cur { position: relative; }
.ch.cur::after { content: ""; position: absolute; left: 100%; top: 0.15em; width: 0.45em; height: 1.05em; margin-left: 1px; background: currentColor; animation: blink 0.7s steps(1) infinite; }
@keyframes blink { 50% { opacity: 0; } }
.actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }
.stage.big .actions { justify-content: center; }

.dots::after { content: ""; animation: dots 1.2s steps(4) infinite; }
@keyframes dots { 0% { content: ""; } 25% { content: "."; } 50% { content: ".."; } 75% { content: "..."; } }
.muted { color: var(--muted); }
.error { color: var(--bad); }

/* ── Hub dashboard ─────────────────────────────────────────── */
fieldset.panel { margin: 0 0 1.25rem; padding: 0.9rem 1.1rem 1.1rem; min-width: 0; }
fieldset.panel legend { padding: 0 0.4rem; font-style: italic; }
.panel-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.panel-row fieldset.panel { margin: 0; }
.hello { display: flex; gap: 1.25rem; align-items: flex-start; }
.hello img { width: 64px; flex: none; }
.greeting { min-height: 1.45em; }
.tally { display: flex; align-items: center; gap: 0.75rem; }
button.primary { font-size: 1rem; padding: 0.35em 1.1em; }
.preview { font-style: italic; }
.meta { font-size: 0.85rem; color: var(--muted); }
.rules { margin: 0 0 1rem; padding-left: 1.25rem; }
.boxes { display: inline-flex; gap: 6px; }
.boxes span { width: 18px; height: 18px; border: 1px solid var(--ink); display: inline-block; }
.boxes span.on { background: var(--ink); }
.boxes.mini { gap: 3px; }
.boxes.mini span { width: 9px; height: 9px; }

/* ── Help dialog ───────────────────────────────────────────── */
dialog#help { max-width: 30rem; width: calc(100% - 32px); border: 1px solid var(--ink); padding: 1.25rem 1.5rem; font-size: 0.95rem; }
dialog#help::backdrop { background: rgba(255, 255, 255, 0.85); }
dialog#help h2 { margin-top: 0.5rem; }
dialog#help form { margin-top: 1.25rem; text-align: right; }

/* ── Writing ───────────────────────────────────────────────── */
#app.wide { max-width: 68rem; }
/* one column: painting directly above the haiku, H-10's note below */
.write-layout { display: grid; gap: 1.5rem; }
.painting { margin: 0; text-align: center; }
.painting img { max-width: 100%; max-height: min(52vh, 540px); display: block; margin: 0 auto; border: 1px solid #000; }
.painting figcaption { font-size: 0.85rem; color: var(--muted); margin-top: 0.5rem; }
.stage.compact { gap: 0.75rem; margin-bottom: 0.5rem; font-size: 0.9rem; line-height: 1.4; }
.stage.compact .h10 img { width: 34px; }
.stage.compact .line { margin-bottom: 0.5rem; }
.haiku-form { margin: 0 0 1.5rem; }
.haiku-form fieldset { margin: 0; padding: 0.75rem 1rem 1rem; min-width: 0; }
.haiku-form legend { padding: 0 0.4rem; font-style: italic; }
.haiku-line { display: flex; align-items: baseline; gap: 0.75rem; margin-bottom: 0.6rem; }
.haiku-line input {
  flex: 1; min-width: 0;
  font-family: inherit; font-size: 1.15rem; font-style: italic;
  padding: 0.3rem 0.4rem;
}
.haiku-line input[readonly] { border-color: transparent; background: transparent; outline: none; }
.counter { width: 3.2em; text-align: right; color: var(--faint); font-variant-numeric: tabular-nums; font-size: 0.9rem; }
.counter.ok { color: var(--ink); }
.counter.off { color: var(--bad); }
.form-actions { margin-top: 1rem; display: flex; gap: 0.5rem; align-items: center; }
.back { margin-top: 2.5rem; }

/* ── Sale ──────────────────────────────────────────────────── */
.customer { display: flex; align-items: flex-end; gap: 1rem; margin: 0 0 1rem 0.5rem; min-height: 150px; }
.customer .bot { animation: arrive 1.2s ease-out both; }
.customer .bot svg { display: block; animation: bob 3.2s ease-in-out 1.2s infinite; }
.customer .name { font-variant: small-caps; letter-spacing: 0.05em; }
@keyframes arrive { from { opacity: 0; transform: translateX(60px); } to { opacity: 1; transform: none; } }
@keyframes bob { 50% { transform: translateY(-3px); } }

.cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin: 1rem 0 1.5rem; }
.card {
  border: 1px solid var(--ink); padding: 0.9rem; font-style: italic; font-size: 0.95rem;
  background: #fff; transition: opacity 0.6s, outline-color 0.6s; outline: 3px double transparent; outline-offset: 3px;
}
.card p { margin: 0; }
.card .tag { font-style: normal; font-size: 0.7rem; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); margin-top: 0.75rem; min-height: 1em; }
.cards.decided .card { opacity: 0.4; }
.cards.decided .card.chosen { opacity: 1; outline-color: var(--ink); }
.thoughts { margin: 0 0 1.5rem; padding-left: 1rem; border-left: 2px solid var(--ink); }
.thoughts .who { margin-bottom: 0.4rem; font-size: 0.9rem; }
.sale-status { min-height: 1.5em; }
.cert-preview { max-width: 100%; border: 1px solid var(--faint); display: block; margin: 1rem 0; }

/* ── Lists ─────────────────────────────────────────────────── */
.entry { display: flex; gap: 1rem; padding: 1.25rem 0; border-top: 1px solid var(--faint); }
.entry img { width: 90px; height: 90px; object-fit: cover; border: 1px solid #000; flex: none; }
.entry .lines { font-style: italic; margin: 0 0 0.4rem; }
.entry .meta { font-size: 0.85rem; color: var(--muted); margin: 0 0 0.5rem; }
.entry .actions { margin-top: 0.4rem; }

/* ── (de)materialization ───────────────────────────────────── */
.veil { position: fixed; inset: 0; z-index: 10; pointer-events: none; }
.veil.block { pointer-events: auto; }
#app.fading { animation: unravel 2.4s ease-in forwards; }
@keyframes unravel { 60% { filter: blur(1px); } 100% { filter: blur(4px); opacity: 0; } }

@media (max-width: 560px) {
  body { font-size: 18px; }
  .cards { grid-template-columns: 1fr; }
  .panel-row { grid-template-columns: 1fr; }
  .hello img { width: 48px; }
  .stage .h10 img { width: 44px; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.001s !important; animation-iteration-count: 1 !important; }
}

/* ── Page-by-page flow ─────────────────────────────────────── */
#app > * { animation: page-in 0.35s ease-out both; }
@keyframes page-in { from { opacity: 0; } to { opacity: 1; } }

.review { display: flex; gap: 1.25rem; align-items: flex-start; margin: 0 0 2rem; }
.review .thumb { width: 120px; height: 120px; object-fit: cover; border: 1px solid #000; flex: none; }
.haiku-card { flex: 1; margin: 0; padding: 0.6rem 1.1rem 0.9rem; min-width: 0; }
.haiku-card legend { padding: 0 0.4rem; font-style: italic; }
.haiku-card p { margin: 0; font-style: italic; font-size: 1.15rem; line-height: 1.6; }

.form-status { font-size: 0.9rem; }
.caption { min-height: 1.45em; margin-bottom: 1.25rem; }
.sale-next { margin-top: 0.5rem; }
.cert-loading { min-height: 1.5em; }

@media (max-width: 560px) {
  .review { flex-direction: column; }
  .review .thumb { width: 100%; height: 160px; }
}

/* ── Customer page: robot with their words beside it, haikus below ── */
.customer-row { display: flex; gap: 1.25rem; align-items: flex-end; margin: 0 0 1.25rem; min-height: 140px; }
.customer-row .customer { margin: 0; min-height: 0; flex: none; flex-direction: column; align-items: center; gap: 0.25rem; }
.customer-says { flex: 1; min-width: 0; align-self: center; }
.customer-says .thoughts { margin: 0; }
.customer-says .thoughts .line { margin: 0; }
.caption { margin-bottom: 0.75rem; }
.cards { margin-top: 0; }
@media (max-width: 560px) {
  .customer-row { align-items: center; }
  .customer-says { font-size: 0.95rem; }
}

/* ── Customer page on phones: everything on one screen ── */
@media (max-width: 560px) {
  .caption { margin-bottom: 0.5rem; font-size: 0.95rem; }
  .customer-row { gap: 0.9rem; min-height: 0; margin-bottom: 0.9rem; align-items: center; }
  .customer-row .customer .bot svg { width: auto; height: 104px; }
  .customer-row .customer .name { font-size: 0.85rem; }
  .customer-says { font-size: 0.92rem; line-height: 1.38; }
  .customer-says .thoughts { padding-left: 0.7rem; }
  .customer-says .thoughts .who { margin-bottom: 0.2rem; font-size: 0.8rem; }
  .cards { gap: 0.5rem; margin-bottom: 0.9rem; }
  .card { padding: 0.55rem 0.8rem; font-size: 0.86rem; line-height: 1.35; }
  .card .tag { margin-top: 0.35rem; font-size: 0.62rem; }
}

/* ── Customer's one-line reaction to each haiku they passed over ── */
.cards.decided .card { opacity: 1; }
.cards.decided .card:not(.chosen) { border-color: var(--faint); }
.cards.decided .card:not(.chosen) > p:first-child { opacity: 0.45; transition: opacity 0.6s; }
.card-comment {
  font-style: normal; font-size: 0.85rem; line-height: 1.35; color: var(--ink);
  margin: 0.6rem 0 0 !important; padding-top: 0.5rem; border-top: 1px dotted var(--faint);
  animation: page-in 0.6s ease-out both;
}
@media (max-width: 560px) { .card-comment { font-size: 0.8rem; margin-top: 0.4rem !important; padding-top: 0.35rem; } }

/* Chosen card: a double border (more reliable than the animated outline) */
.card { outline: none !important; }
.cards.decided .card.chosen { border: 4px double var(--ink); padding: calc(0.9rem - 3px); }
@media (max-width: 560px) { .cards.decided .card.chosen { padding: calc(0.55rem - 3px) calc(0.8rem - 3px); } }

/* Customer's job, under their name */
.customer .role { font-size: 0.72rem; color: var(--muted); text-align: center; max-width: 7.5rem; line-height: 1.25; animation: page-in 0.6s ease-out both; }

/* Name prompt in the intro */
.name-form { display: flex; flex-wrap: wrap; gap: 0.5rem; justify-content: center; align-items: center; }
.name-form input { font-family: inherit; font-size: 1.05rem; padding: 0.25rem 0.45rem; width: 14rem; max-width: 70vw; }
.name-note { flex-basis: 100%; margin: 0.4rem 0 0; font-size: 0.78rem; font-style: italic; color: var(--muted); }

/* H-10's Special Helpers leaderboard */
ol.helpers { margin: 0 0 1rem; padding-left: 1.6rem; }
ol.helpers li { margin-bottom: 0.25rem; }
ol.helpers .who { font-style: italic; }
ol.helpers .count { color: var(--muted); font-size: 0.85rem; margin-left: 0.3rem; }
fieldset.mine-panel { margin-top: 1.25rem; }

/* After the ending: the only thing left on the blank page */
.endless-hint {
  position: fixed; inset: 0; z-index: 11; margin: 0; padding: 0 16px;
  display: flex; align-items: center; justify-content: center; text-align: center;
  font-style: italic; color: var(--muted); animation: page-in 1.6s ease-out both;
}

/* ── Shop page doorways ── */
.doors { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; margin-top: 1.25rem; }
.door {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.3rem;
  padding: 1rem 0.6rem 0.9rem; border: 1px solid var(--ink); border-radius: 0; background: #fff; color: var(--ink);
  font: inherit; text-align: center; cursor: pointer; transition: background 0.15s, color 0.15s, transform 0.15s;
}
.door .t { font-style: italic; font-size: 1rem; line-height: 1.2; }
.door .s { font-size: 0.72rem; color: var(--muted); letter-spacing: 0.02em; }
.door .t::after { content: " →"; font-style: normal; opacity: 0; transition: opacity 0.15s; }
.door:hover, .door:focus-visible { background: var(--ink); color: #fff; outline: none; }
.door:hover .s, .door:focus-visible .s { color: #cfcfcf; }
.door:hover .t::after, .door:focus-visible .t::after { opacity: 1; }
.door:active { transform: translateY(1px); }
.aside { font-style: italic; font-size: 0.88rem; color: var(--muted); margin: -0.4rem 0 0.9rem; min-height: 1.2em; }
@media (max-width: 560px) {
  .doors { grid-template-columns: 1fr; gap: 0.5rem; }
  .door { flex-direction: row; justify-content: flex-start; gap: 0.75rem; padding: 0.7rem 0.9rem; text-align: left; }
  .door .s { margin-left: auto; text-align: right; }
}
