/*
 * [INPUT]: 使用 Worker 的页面结构与 calendar-ui 生成的门位。
 * [OUTPUT]: 提供导航、工具页、日历、评论徽标和交互面板样式。
 * [POS]: 站点通用样式。首页的专题布局由 home.css 提供。
 * [PROTOCOL]: 变更时更新此头部，然后检查 AGENTS.md
 */

:root {
  color-scheme: light;
  --paper: #fff9f1;
  --ink: #30234b;
  --muted: #5d5369;
  --accent: #a92352;
  --pine: #176b60;
  --serif: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  font-family: system-ui, sans-serif;
  background: var(--paper);
  color: var(--ink);
  line-height: 1.6;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 0; }
body > main { min-height: 66vh; }
a { color: var(--accent); }
button, input, select, textarea { font: inherit; }
button:not(:disabled) { cursor: pointer; }
button:disabled { opacity: .65; }
:focus-visible { outline: 2px solid var(--pine); outline-offset: 4px; }
h1, h2, h3 { font-family: var(--serif); line-height: 1.13; }
.skip-link { position: fixed; top: .7rem; left: .7rem; z-index: 6; transform: translateY(-200%); padding: .7rem; background: var(--paper); }
.skip-link:focus { transform: none; }

.site-header { background: #fff2e9; }
.site-bar, .footer-inner {
  width: min(100% - 2rem, 72rem); margin-inline: auto; display: flex;
  min-height: 4.5rem; align-items: center; justify-content: space-between; gap: .75rem 1.4rem;
}
.site-brand { display: inline-flex; align-items: center; gap: .65rem; color: var(--ink); font: bold clamp(1rem, 2.2vw, 1.2rem) var(--serif); text-decoration: none; white-space: nowrap; }
.brand-mark { display: inline-grid; place-items: center; inline-size: 2.25rem; block-size: 2.25rem; border-radius: 50%; background: #ffdfeb; color: var(--accent); font: 1.15rem var(--serif); }
.site-bar nav, .footer-inner nav { display: flex; align-items: center; gap: .5rem 1.35rem; flex-wrap: wrap; }
.site-bar nav a, .footer-inner nav a { color: #543178; text-decoration: none; font-size: .875rem; font-weight: 700; padding: .35rem .7rem; border-radius: 100vw; background: #f2e6ff; }
.site-bar nav a:nth-child(2) { background: #ffebbf; color: #684916; }
.site-bar nav a:nth-child(3) { background: #dcf3e4; color: #216051; }
.site-bar nav a:hover, .footer-inner nav a:hover { text-decoration: underline; }
.site-footer { padding-block: 1.4rem; background: #ffeae6; }

.utility-panel { width: min(100% - 2rem, 35rem); margin: clamp(2rem, 7vw, 5rem) auto; padding: clamp(1.35rem, 5vw, 3rem); border-radius: 1.9rem; background: #f8edff; box-shadow: 0 .6rem 1.8rem #56317110; }
.utility-panel.wide, .prose { max-width: 44rem; width: min(100% - 2rem, 44rem); }
.utility-panel h1 { font-size: clamp(2.1rem, 6vw, 3.6rem); margin: .25rem 0 .65rem; }
.utility-panel p, .prose li { color: var(--muted); }
.prose li + li { margin-top: .7rem; }
.eyebrow { color: var(--accent); letter-spacing: .13em; text-transform: uppercase; font-size: .75rem; font-weight: 750; }
.stack-form { display: flex; flex-direction: column; gap: .62rem; margin: 1rem 0; }
.stack-form label, .stack-form legend { color: var(--ink); font-weight: 650; }
.stack-form :is(input:not([type="checkbox"], [type="radio"]), select, textarea) {
  border: 0; border-radius: 1rem; padding: .65rem .8rem; min-width: 0;
  min-height: 2.75rem; background: #f0e8fb; color: var(--ink); width: 100%;
}
.utility-panel .stack-form :is(input:not([type="checkbox"], [type="radio"]), select, textarea) { background: #fffafd; }
.stack-form textarea { min-height: 6rem; resize: vertical; }
.stack-form fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.stack-form legend { padding: 0 0 .42rem; }
.stack-form p { margin: 0; }
.button, .text-link { font-weight: 700; }
.button {
  border: 0; padding: .65rem 1.1rem; border-radius: 100vw; line-height: 1.3;
  display: inline-flex; min-height: 2.75rem; align-items: center; justify-content: center; text-decoration: none; text-align: center;
}
.button.primary, .button.danger { background: var(--accent); color: white; }
.button.secondary { color: #543178; background: #f0e3ff; }
.button.primary:hover, .button.danger:hover { background: #742339; }
.button.secondary:hover { background: #e8d5fc; }
.text-link { color: var(--accent); background: none; border: 0; padding: 0; text-decoration: underline; text-underline-offset: .2em; }
.button-row, .comment-actions, .share-channels { display: flex; flex-wrap: wrap; gap: .6rem; align-items: center; }
.share-channels { gap: .45rem 1rem; margin-block: .9rem; font-size: .9rem; }
.empty-state { color: var(--muted); }
.comment-thread { padding: .95rem 0; border-bottom: 1px solid #e8d9c8; }
.public-comment { overflow-wrap: anywhere; }
.comment-meta { display: flex; flex-wrap: wrap; align-items: baseline; gap: .15rem .48rem; color: var(--muted); font-size: .9rem; }
.comment-meta strong { color: var(--ink); }
.comment-owner-badge, .comment-owner-status { color: var(--pine); font-weight: 700; }
.comment-owner-status { margin: 0; }
.public-comment p { margin: .3rem 0 .5rem; white-space: pre-wrap; }
.comment-replies { margin: .68rem 0 0 clamp(.55rem, 2.4vw, 1rem); padding-left: clamp(.7rem, 2.4vw, 1rem); border-left: 2px solid #e8d9c8; }
.comment-replies .public-comment { padding: .7rem 0; border-top: 1px solid #e8d9c8; }
.comment-parent { color: var(--muted); font-size: .79rem; }
.calendar-list { list-style: none; padding: 0; }
.calendar-list a { display: flex; align-items: center; gap: .75rem; padding: .5rem .7rem; margin-block: .3rem; border-radius: 1rem; background: #fffafd; color: var(--ink); text-decoration: none; }
.calendar-list a:hover { color: var(--accent); }
.calendar-list small { margin-left: auto; color: var(--muted); }
.list-stamp, .dashboard-summary { color: var(--accent); background: #f4e6d8; padding: .35rem .7rem; border-radius: .35rem; }
.dashboard-summary { width: fit-content; }
.recovery-form { padding-top: .75rem; }
#owner-sign-in[hidden] { display: none; }
.owner-device-list { list-style: none; padding: 0; }
.owner-device-list li { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: .6rem; padding-block: .65rem; border-bottom: 1px solid #e8d9c8; overflow-wrap: anywhere; }
.owner-device-list time { display: block; color: var(--muted); font-size: .85rem; }

.calendar-shell { --board: #782c3f; --board-dark: #591d31; --card: #f0dcc1; width: min(100% - 2rem, 49rem); margin: 1.5rem auto 3.5rem; }
.calendar-shell[data-theme="pine"] { --board: #38584b; --board-dark: #20382e; --card: #dddac1; }
.calendar-shell[data-theme="snow"] { --board: #495f75; --board-dark: #324458; --card: #e5e9ef; }
.calendar-shell[data-theme="gold"] { --board: #7b5432; --board-dark: #533b23; --card: #f5d893; }
.calendar-shell[data-theme="midnight"] { --board: #343654; --board-dark: #201f37; --card: #e1d7ec; }
.calendar-shell[data-theme="cocoa"] { --board: #704d43; --board-dark: #50352d; --card: #edd6c0; }
.calendar-shell[data-theme="plum"] { --board: #634266; --board-dark: #422c45; --card: #ead6e6; }
.calendar-shell[data-theme="holly"] { --board: #4b5635; --board-dark: #323c24; --card: #f0dfb3; }
.calendar-shell[data-theme="mint"] { --board: #356565; --board-dark: #284849; --card: #d0eadf; }
.calendar-shell[data-theme="slate"] { --board: #47536a; --board-dark: #323c4e; --card: #d5dfe8; }
.calendar-shell[data-theme="copper"] { --board: #815548; --board-dark: #5f392f; --card: #f5d1b7; }
.calendar-shell[data-theme="berry"] { --board: #7a3657; --board-dark: #57233f; --card: #eecad3; }
.calendar-shell[data-theme="frost-spires"] { --board: #516e8e; --board-dark: #273e5a; --card: #dfecf5; --roof: #a7bdd4; }
.calendar-shell[data-theme="woodland-hall"] { --board: #426859; --board-dark: #234335; --card: #e8e6c8; --roof: #90a288; }
.calendar-shell[data-theme="midnight-observatory"] { --board: #484573; --board-dark: #272444; --card: #e8ddf0; --roof: #a19ac9; }
.cal-top { display: flex; justify-content: space-between; align-items: center; color: var(--muted); font-size: .875rem; }
.cal-heading { text-align: center; padding: 1.6rem 0 1.25rem; overflow-wrap: anywhere; }
.cal-heading h1 { font-size: clamp(2.2rem, 6.7vw, 4.4rem); margin: .36rem 0; letter-spacing: -.04em; }
.cal-heading p { margin: .4rem 0; }
.cal-board { padding: clamp(.65rem, 2.7vw, 1.65rem); border-radius: 1rem; background: radial-gradient(ellipse at 35% 0, var(--board), var(--board-dark)); box-shadow: 0 14px 38px #3b25331c; }
.cal-board-bar { display: flex; align-items: center; justify-content: space-between; gap: .4rem; color: #f8e6ce; margin: .2rem .15rem .9rem; font-size: .8rem; letter-spacing: .035em; }
.cal-board-bar strong { font-size: .76rem; letter-spacing: .13em; }
.cal-board--scene { position: relative; margin-top: clamp(3rem, 10vw, 6rem); perspective: 1050px; }
.scene-roof { position: absolute; bottom: calc(100% - 1px); left: 8%; width: 84%; display: grid; grid-template-columns: repeat(3, 1fr); align-items: end; height: clamp(3rem, 10vw, 6rem); }
.scene-roof i { height: 75%; background: linear-gradient(100deg, var(--board-dark), var(--roof)); clip-path: polygon(0 100%, 18% 57%, 18% 44%, 50% 0, 82% 44%, 82% 57%, 100% 100%); }
.scene-roof i:nth-child(2) { height: 100%; }
[data-theme="woodland-hall"] .scene-roof i { clip-path: polygon(0 100%, 15% 100%, 15% 47%, 50% 0, 85% 47%, 85% 100%, 100% 100%); }
[data-theme="midnight-observatory"] .scene-roof i { clip-path: ellipse(49% 85% at 50% 100%); }
.cal-board--scene .cal-door { box-shadow: .18rem .3rem 0 var(--roof), .3rem .46rem .1rem var(--board-dark); }
.cal-board--scene .cal-door[data-state="opened"] { transform: perspective(500px) rotateY(-13deg); transform-origin: left center; }
.cal-grid { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); gap: clamp(.38rem, 1.5vw, .9rem); }
.cal-door { background: var(--card); border: 0; color: var(--board-dark); min-height: 3.5rem; aspect-ratio: 1.1; position: relative; border-radius: .9rem; font-family: var(--serif); box-shadow: 0 .3rem 0 #2816283b; transition: transform .18s ease, box-shadow .18s ease; }
.cal-door[data-state="empty"]:nth-child(5n + 1) { background: #ffdfed; }
.cal-door[data-state="empty"]:nth-child(5n + 2) { background: #d8f4e5; }
.cal-door[data-state="empty"]:nth-child(5n + 3) { background: #ffe8b5; }
.cal-door[data-state="empty"]:nth-child(5n + 4) { background: #e8dfff; }
.cal-door[data-state="empty"]:nth-child(5n + 5) { background: #d4ebfa; }
.cal-door span { font-size: clamp(.85rem, 3vw, 1.5rem); display: block; line-height: 1; }
.cal-door b { font-size: clamp(.85rem, 3.2vw, 1.35rem); }
.cal-door:is(:hover, :focus-visible) { transform: translateY(-.2rem); }
.cal-door:focus-visible { outline-color: white; }
.cal-door[data-state="reserved"] { opacity: .65; }
.cal-door[data-state="ready"] { background: #ffdf96; }
.cal-door[data-state="opened"] { background: #faf0df; }
.cal-door[data-wrap="gold"] { background: linear-gradient(135deg, #fae7a5, #dba95b, #f8dfa3); }
.cal-door[data-wrap="frosted"] { background: linear-gradient(135deg, #f5f7f8, #c2dce7); }
.cal-door[data-wrap="lights"] { background: linear-gradient(135deg, #f5d0e9, #cce0e5, #d3e3cc); }
.cal-actions { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: .65rem; margin: 1.4rem 0 .75rem; }
.cal-report { text-align: center; font-size: .82rem; }
#board-status, #calendar-loading { color: var(--accent); text-align: center; }

dialog {
  color: var(--ink); border: 0; border-radius: 1.65rem; padding: 0; width: min(calc(100% - 2rem), 32rem);
  max-height: min(84dvh, 46rem); background: #fffaf3; box-shadow: 0 1rem 4rem #2d1b3366;
}
dialog::backdrop { background: #2a1929a6; }
#dialog-panel { position: relative; padding: 1.5rem; }
#dialog-panel h2 { font-size: clamp(1.55rem, 5vw, 2.2rem); margin: .25rem 2rem .85rem 0; }
#dialog-panel p:last-child { margin-bottom: 0; }
.dialog-close { color: var(--ink); position: absolute; right: .65rem; top: .65rem; background: #f4e8dc; border: 0; border-radius: 50%; width: 2.5rem; height: 2.5rem; font-size: 1.4rem; line-height: 1; }
.private-link { border-radius: 1rem; background: #f6edff; padding: .55rem .75rem; margin-top: .8rem; }
.private-link summary { cursor: pointer; color: var(--accent); font-weight: 700; }
.private-link input { max-width: 100%; width: 100%; padding: .5rem; }
.share-code { background: #f4e6d8; color: var(--accent); text-align: center; font:bold 1.5rem ui-monospace, monospace; letter-spacing: .14em; padding: .7rem; border-radius: .35rem; }
.sticker-options { display: flex; gap: .4rem; flex-wrap: wrap; }
.sticker-options label { position: relative; }
.sticker-options input { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.sticker-options span { display: grid; place-items: center; min-width: 2.5rem; min-height: 2.5rem; border-radius: 50%; background: #eee3fc; font-size: 1.2rem; color: var(--accent); }
.sticker-options input:checked + span { background: #ffdcae; box-shadow: 0 2px 0 #bd6e2a; }
.sticker-options input:focus-visible + span { outline: 2px solid var(--pine); outline-offset: 2px; }
.check-label { display: flex; align-items: center; gap: .4rem; font-size: .9rem; }
.check-label input { accent-color: var(--accent); }
.hold-status, #note-count { color: var(--muted); font-size: .82rem; }
.door-note { padding: 1rem; margin-block: .8rem; border-radius: 1rem; background: #ffeccf; overflow-wrap: anywhere; }
.door-note p { white-space: pre-wrap; font: 1.27rem/1.4 var(--serif); margin: .42rem 0 .75rem; }
.door-note a { display: block; margin-top: .3rem; }
.decoration-edit { display: block; margin-block: .7rem; }
.note-stamp { color: var(--accent); font-size: 1.45rem; }

@media (max-width: 40rem) {
  .site-bar { min-height: 3.7rem; gap: .45rem .65rem; }
  .site-bar .site-brand { gap: .46rem; font-size: .94rem; }
  .site-bar .brand-mark { inline-size: 1.85rem; block-size: 1.85rem; }
  .site-bar nav { gap: .28rem; justify-content: flex-end; }
  .site-bar nav a { padding-inline: .44rem; font-size: .73rem; white-space: nowrap; }
  .site-bar .nav-how { display: none; }
  .footer-inner { align-items: flex-start; flex-direction: column; }
  .cal-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .cal-door { aspect-ratio: 1.28; }
  dialog { width: 100%; margin: auto 0 0; max-width: 100%; border-radius: .9rem .9rem 0 0; }
}

@media (min-width: 23rem) and (max-width: 40rem) {
  .site-bar nav { flex-wrap: nowrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
