/* 主题只换颜色变量，结构样式共用一套。 */
:root,
[data-theme="pine"] {
  --bg: #12332a;
  --bg-deep: #0c2620;
  --ink: #f4ecdc;
  --ink-soft: rgba(244, 236, 220, 0.72);
  --card: #f8f1e3;
  --card-ink: #20302a;
  --card-soft: #5d6b63;
  --line: rgba(32, 48, 42, 0.16);
  --accent: #c9503a;
  --accent-ink: #fff8ef;
  --gold: #e3b55b;
  --door: #f8f1e3;
  --door-ink: #1d3b31;
  --door-empty: rgba(244, 236, 220, 0.1);
  --door-empty-line: rgba(244, 236, 220, 0.45);
}
[data-theme="midnight"] {
  --bg: #141b3a;
  --bg-deep: #0c1128;
  --ink: #eef0ff;
  --ink-soft: rgba(238, 240, 255, 0.72);
  --card: #f4f1ea;
  --card-ink: #1a2148;
  --card-soft: #5b6184;
  --line: rgba(26, 33, 72, 0.16);
  --accent: #e0624f;
  --accent-ink: #fff8ef;
  --gold: #f0c869;
  --door: #f4f1ea;
  --door-ink: #1a2250;
  --door-empty: rgba(238, 240, 255, 0.08);
  --door-empty-line: rgba(238, 240, 255, 0.42);
}
[data-theme="cocoa"] {
  --bg: #f3e7d3;
  --bg-deep: #e9d9bf;
  --ink: #3a2a20;
  --ink-soft: rgba(58, 42, 32, 0.72);
  --card: #fffaf0;
  --card-ink: #3a2a20;
  --card-soft: #7a6555;
  --line: rgba(58, 42, 32, 0.16);
  --accent: #b8442f;
  --accent-ink: #fff8ef;
  --gold: #b9852c;
  --door: #fffaf0;
  --door-ink: #5a3a28;
  --door-empty: rgba(58, 42, 32, 0.05);
  --door-empty-line: rgba(58, 42, 32, 0.38);
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  background-image: radial-gradient(120% 60% at 50% 0%, transparent 40%, var(--bg-deep) 100%);
  background-attachment: fixed;
  color: var(--ink);
  font: 16px/1.55 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  transition: background-color 0.25s, color 0.25s;
}
h1, h2, h3 { font-family: "Fraunces", ui-serif, Georgia, serif; font-weight: 700; line-height: 1.12; margin: 0; text-wrap: balance; }
h1 { font-size: clamp(2rem, 6.2vw, 3.3rem); letter-spacing: -0.02em; }
h2 { font-size: clamp(1.45rem, 4vw, 2rem); letter-spacing: -0.01em; }
h3 { font-size: 1.1rem; }
p { margin: 0; }
a { color: inherit; }
button, input, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

.wrap { width: 100%; max-width: 980px; margin: 0 auto; padding: 8px 16px 48px; }
.stack > * + * { margin-top: 14px; }
.center { text-align: center; }
.lede { font-size: 1.08rem; color: var(--ink-soft); max-width: 34em; }
.eyebrow { font-size: 0.78rem; letter-spacing: 0.14em; text-transform: uppercase; color: var(--gold); font-weight: 700; }
.notice { padding: 12px 14px; border-radius: 12px; background: var(--door-empty); border: 1px solid var(--door-empty-line); }

.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; max-width: 980px; margin: 0 auto; padding: 14px 16px; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-family: "Fraunces", ui-serif, Georgia, serif; font-weight: 700; font-size: 1.05rem; text-decoration: none; }
.brand-mark { width: 22px; height: 22px; border-radius: 6px; background: var(--accent); box-shadow: inset 0 0 0 2px var(--gold), inset 0 0 0 5px var(--accent), inset -9px 0 0 -6px var(--gold); }
.topbar-link { font-size: 0.92rem; color: var(--ink-soft); }

.card { background: var(--card); color: var(--card-ink); border-radius: 18px; padding: 20px; box-shadow: 0 14px 40px rgba(0, 0, 0, 0.22); }
.card p.small, .small { font-size: 0.86rem; }
.card .muted { color: var(--card-soft); }
.muted { color: var(--ink-soft); }

.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px; padding: 12px 20px; border: 0; border-radius: 12px; background: var(--accent); color: var(--accent-ink); font-weight: 700; text-decoration: none; cursor: pointer; transition: transform 0.1s, filter 0.15s; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(1px); }
.btn[disabled] { opacity: 0.6; cursor: default; }
.btn.block { width: 100%; }
.btn.ghost { background: transparent; color: inherit; box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.quiet { min-height: 40px; padding: 8px 14px; font-weight: 600; background: transparent; color: inherit; box-shadow: inset 0 0 0 1.5px var(--line); }
.btn.danger { background: transparent; color: var(--accent); box-shadow: inset 0 0 0 1.5px var(--accent); }
.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

label.field { display: block; font-weight: 700; font-size: 0.92rem; }
.field input, .field textarea, input.readonly {
  display: block; width: 100%; margin-top: 6px; padding: 12px 14px; border-radius: 12px;
  border: 1.5px solid var(--line); background: #fff; color: #1d2a25; font-size: 1rem;
}
.field textarea { min-height: 120px; resize: vertical; }
.field-hint { display: flex; justify-content: space-between; gap: 10px; margin-top: 6px; font-size: 0.82rem; color: var(--card-soft); font-weight: 400; }
.error { color: var(--accent); font-weight: 600; font-size: 0.92rem; min-height: 1.3em; }

/* 主题选择 */
.swatches { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 6px; }
.swatch { position: relative; }
.swatch input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.swatch span { display: flex; align-items: center; gap: 8px; padding: 10px; border-radius: 12px; border: 1.5px solid var(--line); font-size: 0.9rem; font-weight: 600; }
.swatch span::before { content: ""; width: 20px; height: 20px; border-radius: 6px; flex: none; }
.swatch.pine span::before { background: #12332a; box-shadow: inset 0 0 0 3px #e3b55b; }
.swatch.midnight span::before { background: #141b3a; box-shadow: inset 0 0 0 3px #f0c869; }
.swatch.cocoa span::before { background: #f3e7d3; box-shadow: inset 0 0 0 3px #b8442f; }
.swatch input:checked + span { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.swatch input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }

/* 首页 */
.hero { display: grid; gap: 24px; padding: 18px 0 8px; align-items: start; }
.hero-copy > * + * { margin-top: 14px; }
.ticks { list-style: none; margin: 14px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 16px; color: var(--ink-soft); font-size: 0.92rem; }
.ticks li::before { content: "✓ "; color: var(--gold); font-weight: 700; }
.section { margin-top: 56px; }
.section > h2 + * { margin-top: 16px; }
.steps { list-style: none; counter-reset: step; margin: 0; padding: 0; display: grid; gap: 12px; }
.steps li { counter-increment: step; position: relative; padding: 16px 16px 16px 62px; border-radius: 14px; background: var(--door-empty); border: 1px solid var(--door-empty-line); }
.steps li::before { content: counter(step); position: absolute; left: 16px; top: 16px; width: 32px; height: 32px; display: grid; place-items: center; border-radius: 50%; background: var(--gold); color: #1d2a25; font-family: "Fraunces", ui-serif, Georgia, serif; font-weight: 700; }
.steps h3 + p { margin-top: 4px; color: var(--ink-soft); }
.notes { display: grid; gap: 10px; margin: 0; padding: 0; list-style: none; }
.notes li { background: var(--card); color: var(--card-ink); border-radius: 14px; padding: 14px 16px; }
.notes li span { display: block; margin-top: 4px; font-size: 0.84rem; color: var(--card-soft); }
.faq details { border-bottom: 1px solid var(--door-empty-line); padding: 14px 0; }
.faq summary { cursor: pointer; font-weight: 700; font-size: 1.02rem; }
.faq details p { margin-top: 8px; color: var(--ink-soft); max-width: 44em; }
.prose { max-width: 44em; }
.prose > * + * { margin-top: 14px; }
.prose h2 { margin-top: 36px; }
.prose ul { margin: 10px 0 0; padding-left: 1.2em; }
.prose li + li { margin-top: 6px; }
.mine { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.mine a { display: block; padding: 10px 12px; border-radius: 10px; background: var(--door-empty); border: 1px solid var(--door-empty-line); text-decoration: none; font-weight: 600; }

/* 日历格子 */
.grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.door {
  position: relative; aspect-ratio: 1; width: 100%; padding: 0; border: 0; border-radius: 14px;
  background: var(--door); color: var(--door-ink); cursor: pointer;
  display: grid; place-items: center; overflow: hidden;
  box-shadow: 0 3px 0 rgba(0, 0, 0, 0.18), 0 8px 18px rgba(0, 0, 0, 0.14);
  transition: transform 0.12s;
}
.door:hover { transform: translateY(-2px); }
.door[disabled] { cursor: default; }
.door[disabled]:hover { transform: none; }
.door .num { font-family: "Fraunces", ui-serif, Georgia, serif; font-weight: 700; font-size: clamp(1.4rem, 6vw, 2rem); }
.door .sticker { font-size: clamp(1.7rem, 8vw, 2.5rem); line-height: 1; }
.door .tag { position: absolute; left: 0; right: 0; bottom: 6px; font-size: 0.66rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; text-align: center; }
.door.has-sticker .num { position: absolute; top: 6px; left: 9px; font-size: 0.86rem; opacity: 0.7; }
.door.empty { background: var(--door-empty); color: var(--ink); box-shadow: inset 0 0 0 2px var(--door-empty-line); }
.door.empty.fillable { box-shadow: none; outline: 2px dashed var(--door-empty-line); outline-offset: -2px; }
.door.empty.fillable .tag { color: var(--gold); }
.door.locked .sticker { filter: grayscale(0.5); opacity: 0.6; }
.door.ready { box-shadow: 0 0 0 3px var(--gold), 0 8px 22px rgba(0, 0, 0, 0.25); animation: glow 1.8s ease-in-out infinite; }
.door.ready .tag { color: var(--accent); }
.door.opened { opacity: 0.86; }
.door.today:not(.ready) { box-shadow: 0 0 0 3px var(--gold), 0 3px 0 rgba(0, 0, 0, 0.18); }
@keyframes glow { 50% { box-shadow: 0 0 0 6px var(--gold), 0 8px 22px rgba(0, 0, 0, 0.25); } }
@media (prefers-reduced-motion: reduce) { .door.ready { animation: none; } .door, .btn, body { transition: none; } }

.cal-head > * + * { margin-top: 10px; }
.cal-head { padding: 10px 0 18px; }
.count { display: inline-block; padding: 5px 12px; border-radius: 999px; background: var(--door-empty); border: 1px solid var(--door-empty-line); font-size: 0.88rem; font-weight: 600; }
.cal-layout { display: grid; gap: 20px; align-items: start; }
.share-card h2 { font-size: 1.25rem; }
.share-card > * + * { margin-top: 12px; }
.divider { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }

/* 弹层：手机上从底部升起 */
dialog.sheet { border: 0; padding: 0; width: 100%; max-width: 480px; border-radius: 20px 20px 0 0; background: var(--card); color: var(--card-ink); margin: auto auto 0; max-height: 92vh; }
dialog.sheet::backdrop { background: rgba(0, 0, 0, 0.55); }
.sheet-body { padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); }
.sheet-body > * + * { margin-top: 14px; }
.sheet-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; }
.sheet-close { background: none; border: 0; font-size: 1.5rem; line-height: 1; padding: 4px 8px; cursor: pointer; color: var(--card-soft); }
.stickers { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.stickers label { position: relative; }
.stickers input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.stickers span { display: grid; place-items: center; aspect-ratio: 1; border-radius: 10px; font-size: 1.5rem; border: 1.5px solid var(--line); background: #fff; }
.stickers input:checked + span { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.stickers input:focus-visible + span { outline: 3px solid var(--gold); outline-offset: 2px; }
.note-sticker { font-size: 3.4rem; line-height: 1; text-align: center; }
.note-body { font-family: "Fraunces", ui-serif, Georgia, serif; font-size: 1.3rem; line-height: 1.4; white-space: pre-wrap; overflow-wrap: anywhere; text-align: center; }
.note-from { text-align: center; color: var(--card-soft); }

.toast { position: fixed; left: 50%; bottom: calc(20px + env(safe-area-inset-bottom)); transform: translateX(-50%); max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 999px; background: #1b1b1b; color: #fff; font-size: 0.94rem; font-weight: 600; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.35); z-index: 50; }

.footer { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px 20px; padding: 28px 16px 40px; font-size: 0.88rem; color: var(--ink-soft); }

@media (min-width: 640px) {
  .grid { grid-template-columns: repeat(6, 1fr); gap: 12px; }
  dialog.sheet { border-radius: 20px; margin: auto; }
  .steps { grid-template-columns: repeat(2, 1fr); }
  .notes { grid-template-columns: repeat(2, 1fr); }
}
@media (min-width: 900px) {
  .hero { grid-template-columns: 1.15fr 0.85fr; gap: 40px; padding-top: 36px; }
  .cal-layout.owner { grid-template-columns: 1fr 320px; }
}
.demo .door { cursor: default; }
.demo .door:hover { transform: none; }
/* 弹层是浅色底，沿用页面上的浅色次要文字会看不见。 */
dialog.sheet .muted { color: var(--card-soft); }
.section > * + * { margin-top: 16px; }
dialog.sheet:focus-visible { outline: none; }
.cal-layout.share-first .share-card { order: -1; }
@media (min-width: 900px) { .cal-layout.share-first .share-card { order: 0; } }
