/* Little Doors. One paper board per calendar; each calendar picks a theme that sets every token below. */
:root {
  --bg: #e9efec; --paper: #fbfaf6; --ink: #1b2a24; --muted: #5d6c66; --line: #d3dcd7;
  --door-a: #1f4a3c; --door-b: #962436; --door-c: #2b5d4c; --door-ink: #e7c46f; --door-tag: rgba(255,255,255,.75);
  --accent: #962436; --accent-ink: #ffffff; --gold: #b3862a; --gold-soft: #f3e7c9; --inside: #fffdf6;
  --danger: #a3242f;
  --font-display: "Yeseva One", Georgia, "Times New Roman", serif;
  --font-body: "Figtree", system-ui, -apple-system, "Segoe UI", sans-serif;
  --radius: 10px;
  color-scheme: light;
}
/* The landing page (no calendar theme) follows the device's dark mode. */
@media (prefers-color-scheme: dark) {
  :root:not([data-cal]) {
    --bg: #0d1714; --paper: #15221d; --ink: #e9eee9; --muted: #98a8a0; --line: #2a3a33;
    --door-a: #24594a; --door-b: #b43a4a; --door-c: #2f6c5a; --accent: #c94a59; --gold: #e2bb5e; --gold-soft: #3a3220;
    --inside: #1d2b25; --danger: #e0606b; color-scheme: dark;
  }
}
:root[data-cal="snow"] {
  --bg: #edf2f7; --paper: #ffffff; --ink: #1c2733; --muted: #5a6878; --line: #d6dee8;
  --door-a: #2f4b6e; --door-b: #c94f4f; --door-c: #6f8db3; --door-ink: #ffffff; --door-tag: rgba(255,255,255,.8);
  --accent: #c94f4f; --gold: #9a7b2e; --gold-soft: #e7eef7; --inside: #f8fbff;
}
:root[data-cal="midnight"] {
  --bg: #0c1020; --paper: #151a2d; --ink: #eef0f7; --muted: #a2a8c0; --line: #2a3150;
  --door-a: #1f2747; --door-b: #3a2d5c; --door-c: #2b3561; --door-ink: #e8c46c; --door-tag: rgba(232,196,108,.75);
  --accent: #e8c46c; --accent-ink: #151a2d; --gold: #e8c46c; --gold-soft: #2c2a2a; --inside: #1b2138;
  --danger: #ef7a84; color-scheme: dark;
}
:root[data-cal="candy"] {
  --bg: #fcefef; --paper: #fffafa; --ink: #2c1a1d; --muted: #7a5d61; --line: #f0d3d5;
  --door-a: #d23a4b; --door-b: #2f7d5b; --door-c: #b52a3b; --door-ink: #ffffff; --door-tag: rgba(255,255,255,.85);
  --accent: #d23a4b; --gold: #b8862b; --gold-soft: #fde3e6; --inside: #ffffff;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--ink); font-family: var(--font-body); font-size: 16px; line-height: 1.5;
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: calc(24px + env(safe-area-inset-top, 0px)) calc(48px + env(safe-area-inset-bottom, 0px));
}
[hidden] { display: none !important; }
main { max-width: 880px; margin: 0 auto; display: flex; flex-direction: column; gap: 24px; }
a { color: inherit; }
.brand { font-family: var(--font-display); font-size: 18px; text-decoration: none; color: var(--ink); }
header.page { display: flex; flex-direction: column; gap: 6px; }
.eyebrow { font-size: 12px; letter-spacing: .12em; text-transform: uppercase; font-weight: 600; color: var(--gold); margin: 0; }
h1 { font-family: var(--font-display); font-weight: 400; font-size: clamp(34px, 7vw, 56px); line-height: 1.05; margin: 0; text-wrap: balance; }
h2 { font-family: var(--font-display); font-weight: 400; font-size: 24px; line-height: 1.2; margin: 0; text-wrap: balance; }
h3 { font-size: 16px; margin: 0; }
p { margin: 0; }
.sub { color: var(--muted); max-width: 62ch; }
.small { font-size: 14px; }
.panel { background: var(--paper); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; display: flex; flex-direction: column; gap: 14px; min-width: 0; }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.stack { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

button, .btn {
  font: inherit; font-weight: 600; font-size: 15px; border-radius: 999px; border: 1px solid var(--line);
  background: var(--paper); color: var(--ink); padding: 10px 18px; cursor: pointer; min-height: 44px; text-decoration: none;
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
button:hover, .btn:hover { border-color: var(--muted); }
button:focus-visible, .btn:focus-visible, textarea:focus-visible, input:focus-visible, select:focus-visible, .door:focus-visible, .inside:focus-visible, .theme-option input:focus-visible + span {
  outline: 3px solid var(--gold); outline-offset: 2px;
}
button.primary, .btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.quiet { border-color: transparent; background: transparent; color: var(--muted); padding-inline: 10px; }
button.danger { color: var(--danger); border-color: var(--danger); background: transparent; }
button.danger.solid { background: var(--danger); color: #fff; }
button:disabled { opacity: .5; cursor: not-allowed; }

label.field { display: flex; flex-direction: column; gap: 6px; font-weight: 600; font-size: 14px; min-width: 0; }
label.field .hint { font-weight: 400; color: var(--muted); }
input[type=text], input[type=password], textarea, select {
  font: inherit; font-size: 16px; color: var(--ink); background: var(--inside); border: 1px solid var(--line); border-radius: 8px;
  padding: 10px 12px; width: 100%; min-width: 0;
}
textarea { min-height: 110px; resize: vertical; }
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
@media (max-width: 560px) { .grid-2 { grid-template-columns: 1fr; } }

.progress { height: 8px; border-radius: 99px; background: var(--line); overflow: hidden; }
.progress > span { display: block; height: 100%; width: 0; background: var(--gold); transition: width .4s; }
.stat { font-variant-numeric: tabular-nums; }

.linkbox { display: flex; gap: 8px; align-items: stretch; min-width: 0; }
.linkbox input { font-size: 14px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.note { display: flex; flex-direction: column; gap: 6px; background: var(--gold-soft); border-radius: 8px; padding: 12px 14px; font-size: 14px; }
.confirm { border: 1px solid var(--danger); border-radius: 8px; padding: 14px; display: flex; flex-direction: column; gap: 10px; }

fieldset.plain { border: 0; padding: 0; margin: 0; min-width: 0; }
.legend { font-weight: 600; font-size: 14px; margin-bottom: 6px; padding: 0; }
.bullets { padding-left: 18px; margin: 0; }

/* Theme picker */
.themes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
@media (max-width: 560px) { .themes { grid-template-columns: repeat(2, 1fr); } }
.theme-option { position: relative; cursor: pointer; }
.theme-option input { position: absolute; opacity: 0; pointer-events: none; }
.theme-option > span { display: flex; flex-direction: column; gap: 8px; border: 2px solid var(--line); border-radius: 10px; padding: 10px; font-weight: 600; font-size: 14px; }
.theme-option input:checked + span { border-color: var(--accent); }
.swatch { display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; height: 36px; border-radius: 6px; padding: 4px; }
.swatch i { border-radius: 3px; }
.sw-spruce { background: #e9efec; } .sw-spruce i:nth-child(1) { background: #1f4a3c; } .sw-spruce i:nth-child(2) { background: #962436; } .sw-spruce i:nth-child(3) { background: #b3862a; }
.sw-snow { background: #edf2f7; } .sw-snow i:nth-child(1) { background: #2f4b6e; } .sw-snow i:nth-child(2) { background: #c94f4f; } .sw-snow i:nth-child(3) { background: #6f8db3; }
.sw-midnight { background: #0c1020; } .sw-midnight i:nth-child(1) { background: #1f2747; } .sw-midnight i:nth-child(2) { background: #3a2d5c; } .sw-midnight i:nth-child(3) { background: #e8c46c; }
.sw-candy { background: #fcefef; } .sw-candy i:nth-child(1) { background: #d23a4b; } .sw-candy i:nth-child(2) { background: #2f7d5b; } .sw-candy i:nth-child(3) { background: repeating-linear-gradient(45deg, #d23a4b 0 5px, #fff 5px 10px); }

/* The board */
.board { background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 12px; }
.grid { display: grid; grid-template-columns: repeat(6, 1fr); grid-auto-rows: minmax(92px, auto); grid-auto-flow: dense; gap: 10px; }
@media (max-width: 560px) { .grid { grid-template-columns: repeat(5, 1fr); grid-auto-rows: minmax(66px, auto); gap: 7px; } .board { padding: 8px; } }
.cell { position: relative; perspective: 900px; min-width: 0; }
.cell.wide { grid-column: span 2; }
.cell.big { grid-column: span 2; grid-row: span 2; }
.inside {
  position: absolute; inset: 0; border-radius: 8px; background: var(--inside); border: 1px dashed var(--line);
  display: flex; align-items: center; justify-content: center; text-align: center; padding: 8px;
  font-size: 13px; line-height: 1.3; color: var(--ink); overflow: hidden;
}
.inside span { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.door {
  position: absolute; inset: 0; border-radius: 8px; border: 0; padding: 8px; cursor: pointer; color: var(--door-ink);
  background-color: var(--door-a);
  background-image: radial-gradient(circle at 20% 30%, rgba(255,255,255,.12) 0 1.5px, transparent 2px),
                    radial-gradient(circle at 70% 70%, rgba(255,255,255,.08) 0 1px, transparent 1.5px);
  background-size: 22px 22px, 17px 17px;
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between; text-align: left;
  transform-origin: left center; transition: transform .7s cubic-bezier(.3,.7,.2,1), box-shadow .3s;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.06), 0 1px 2px rgba(0,0,0,.2); min-height: 0; font-weight: 400;
}
.door.c1 { background-color: var(--door-b); }
.door.c2 { background-color: var(--door-c); }
:root[data-cal="candy"] .door.c2 { background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.22) 0 8px, transparent 8px 16px); }
.door .num { font-family: var(--font-display); font-size: clamp(22px, 5vw, 34px); line-height: 1; }
.cell.big .door .num { font-size: clamp(40px, 10vw, 68px); }
.door .tag { font-size: 11px; letter-spacing: .08em; text-transform: uppercase; color: var(--door-tag); font-weight: 600; }
.door.locked { cursor: default; }
.door.ready { animation: glow 2.4s ease-in-out infinite; }
@keyframes glow { 0%,100% { box-shadow: inset 0 0 0 2px var(--gold), 0 0 0 0 transparent; } 50% { box-shadow: inset 0 0 0 2px var(--gold), 0 0 14px 2px var(--gold); } }
.cell.open .door { transform: rotateY(-105deg); box-shadow: none; pointer-events: none; }
.cell.open .inside { cursor: pointer; }
.shake { animation: shake .4s; }
@keyframes shake { 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }
@media (max-width: 560px) { .door .tag { font-size: 9px; letter-spacing: .04em; } }

/* Filler tiles */
.slot {
  position: absolute; inset: 0; border-radius: 8px; border: 1px solid var(--line); background: var(--inside); color: var(--ink);
  padding: 8px; text-align: left; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; gap: 4px;
  cursor: pointer; font-weight: 400; min-height: 0; overflow: hidden;
}
.slot .num { font-family: var(--font-display); font-size: 20px; line-height: 1; color: var(--gold); }
.slot .txt { font-size: 12.5px; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
.slot.empty { border-style: dashed; }
.slot.empty .txt { color: var(--muted); }
.slot.filled { background: var(--gold-soft); border-color: var(--gold); }
.slot .flag { font-size: 10px; text-transform: uppercase; letter-spacing: .08em; font-weight: 700; color: var(--gold); margin-top: auto; }
@media (max-width: 560px) { .slot .txt { font-size: 11px; -webkit-line-clamp: 2; } .slot .num { font-size: 16px; } .slot { padding: 6px; } }

/* Suggestions */
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { font-weight: 500; font-size: 14px; padding: 8px 14px; min-height: 38px; text-align: left; }
.chip.used { opacity: .5; text-decoration: line-through; }
.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.list li { display: flex; gap: 8px; align-items: center; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--line); }
.list li span { min-width: 0; overflow-wrap: anywhere; }
.list li:last-child { border-bottom: 0; }
details.panel > summary { cursor: pointer; font-weight: 600; list-style: none; display: flex; justify-content: space-between; align-items: center; min-height: 28px; }
details.panel > summary::-webkit-details-marker { display: none; }
details.panel > summary::after { content: "+"; font-size: 22px; color: var(--muted); }
details.panel[open] > summary::after { content: "–"; }

/* Sheet */
.scrim { position: fixed; inset: 0; background: rgba(5,10,14,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
@media (min-width: 640px) { .scrim { align-items: center; padding: 16px; } }
.sheet {
  background: var(--paper); color: var(--ink); width: 100%; max-width: 560px; max-height: 88vh; overflow: auto;
  border-radius: 16px 16px 0 0;
  padding: 22px max(20px, env(safe-area-inset-right, 0px)) calc(22px + env(safe-area-inset-bottom, 0px)) max(20px, env(safe-area-inset-left, 0px));
  display: flex; flex-direction: column; gap: 14px;
}
@media (min-width: 640px) { .sheet { border-radius: 16px; } }
.bignum { font-family: var(--font-display); font-size: 56px; line-height: 1; color: var(--gold); }
.reveal-text { font-size: 22px; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; }
.toast {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--ink); color: var(--paper); padding: 10px 18px; border-radius: 999px; font-weight: 600; font-size: 14px;
  z-index: 30; max-width: calc(100% - 32px); text-align: center;
}

/* Landing */
.hero { display: grid; grid-template-columns: 1.1fr 1fr; gap: 28px; align-items: center; }
@media (max-width: 720px) { .hero { grid-template-columns: 1fr; } }
.hero .lede { font-size: 19px; color: var(--muted); max-width: 46ch; }
.mini-board { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; background: var(--paper); border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.mini-board .cell { min-height: 58px; }
.steps { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; counter-reset: step; }
@media (max-width: 720px) { .steps { grid-template-columns: 1fr; } }
.steps li { counter-increment: step; display: flex; flex-direction: column; gap: 6px; }
.steps li::before { content: counter(step); font-family: var(--font-display); font-size: 30px; color: var(--gold); line-height: 1; }
footer { color: var(--muted); font-size: 13px; text-align: center; }

@media (prefers-reduced-motion: reduce) {
  .door, .progress > span { transition: none; }
  .door.ready, .shake { animation: none; }
}
.divider { border: 0; border-top: 1px solid var(--line); margin: 6px 0; width: 100%; }
.linkbox input:not([readonly]) { font-family: var(--font-body); font-size: 16px; }
details.panel:not([open]) { gap: 0; }
