/* 首页、制作器与主题陈列页共享主题色、日期造型和开信动画。 */
.nd-theme-palette {
  --theme-scene-color: #0d1827;
  --theme-ink: #fff5df;
  --theme-muted-ink: #e4dcca;
  --theme-accent: #ffd697;
  --theme-panel: #131d2be6;
  --theme-paper: #f8ebd2;
  --theme-paper-ink: #3e2b22;
}
.nd-theme-palette[data-theme="birthday"] {
  --theme-scene-color: #5c253a;
  --theme-accent: #ffc9b1;
  --theme-panel: #4a2231e8;
  --theme-paper: #ffeddb;
  --theme-paper-ink: #592337;
}
.nd-theme-palette[data-theme="christmas"] {
  --theme-scene-color: #102d24;
  --theme-accent: #f6d593;
  --theme-panel: #102e25e8;
  --theme-paper: #f9ebd0;
  --theme-paper-ink: #3e2b22;
}
.nd-theme-palette[data-theme="garden"] {
  --theme-scene-color: #24372a;
  --theme-accent: #d9e7a5;
  --theme-panel: #27382aee;
  --theme-paper: #f5efd7;
  --theme-paper-ink: #303a26;
}

.nd-theme-day {
  --door-edge: #b17b42;
  --door-ink: #fff0ce;
  --door-cover: linear-gradient(135deg,#a17140,#573219 50%,#794b28);
  display: grid;
  place-items: center;
  position: relative;
  isolation: isolate;
  min-width: 0;
  height: clamp(49px, 7vw, 66px);
  padding: 0;
  color: var(--door-ink);
  border: 0;
  border-radius: 7px;
  background: none;
  font: 700 clamp(.97rem, 2vw, 1.42rem)/1 var(--serif, Georgia, serif);
}
.nd-theme-day::before, .nd-theme-day::after { content: ""; position: absolute; pointer-events: none; }
.nd-theme-day::before { inset: 0; z-index: -1; border: 1px solid var(--door-edge); border-radius: inherit; background: var(--door-cover); box-shadow: inset 0 0 7px #0005; }
.nd-theme-day::after { inset: 4px; z-index: -1; border: 1px solid color-mix(in srgb, var(--door-edge) 58%, transparent); border-radius: inherit; }
.nd-theme-day[disabled] { color: var(--door-ink); opacity: .79; }
.nd-theme-day.nd-has-note { cursor: pointer; }
.nd-theme-day.nd-has-note::before { border-color: var(--theme-accent); box-shadow: 0 0 0 1px var(--theme-accent), 0 0 12px color-mix(in srgb, var(--theme-accent) 40%, transparent); }
.nd-theme-day.nd-has-note:hover::before { filter: brightness(1.23); }
.nd-theme-day.nd-has-note:hover > span:first-child { transform: translateY(-1px); }
.nd-theme-day .nd-theme-count {
  position: absolute;
  display: grid;
  place-items: center;
  top: 2px;
  right: 2px;
  min-width: 15px;
  height: 15px;
  padding: 0 3px;
  border-radius: 10px;
  font: 750 .64rem/1 var(--sans, sans-serif);
  background: var(--theme-accent);
  color: #2b2018;
}
.nd-theme-day [data-door-handle] {
  position: absolute;
  bottom: 8px;
  width: 25%;
  height: 2px;
  background: color-mix(in srgb, var(--door-edge) 65%, var(--door-ink));
  border-radius: 3px;
}

/* 同一套日期按钮以不同的轮廓、印刷图案和材质表达主题。 */
[data-theme="birthday"] .nd-theme-day {
  --gift-paper: #e8a5a2;
  --gift-ribbon: #fce1a2;
  --door-edge: #a7575f;
  --door-ink: #462339;
  --door-cover: linear-gradient(90deg, var(--gift-paper) 40%, var(--gift-ribbon) 40% 60%, var(--gift-paper) 60%);
  border-radius: 4px;
}
[data-theme="birthday"] .nd-theme-day:nth-child(3n) { --gift-paper: #bdb9e8; --door-edge: #726a9d; }
[data-theme="birthday"] .nd-theme-day:nth-child(5n) { --gift-paper: #f2c477; --gift-ribbon: #fff2d3; }
[data-theme="birthday"] .nd-theme-day::before { inset: 27% 10% 4%; }
[data-theme="birthday"] .nd-theme-day::after { inset: 21% 6% 61%; background: var(--door-cover); border-color: var(--door-edge); box-shadow: 0 2px 3px #241a1260; }
[data-theme="birthday"] .nd-theme-day > span:first-child {
  position: absolute;
  top: 48%;
  min-width: 1.62em;
  padding: .13em .14em;
  background: #fff5dd;
  border-radius: 5px;
  font-size: .9em;
}
[data-theme="birthday"] .nd-theme-day [data-door-handle] { top: 12%; bottom: auto; width: 9%; height: 12%; background: var(--gift-ribbon); z-index: 1; }
[data-theme="birthday"] .nd-theme-day [data-door-handle]::before,
[data-theme="birthday"] .nd-theme-day [data-door-handle]::after {
  content: "";
  position: absolute;
  top: -50%;
  width: 185%;
  height: 115%;
  border: 2px solid var(--gift-ribbon);
  border-radius: 65% 55% 35% 55%;
}
[data-theme="birthday"] .nd-theme-day [data-door-handle]::before { right: 55%; transform: rotate(24deg); }
[data-theme="birthday"] .nd-theme-day [data-door-handle]::after { left: 55%; transform: scaleX(-1) rotate(24deg); }

/* 轮廓有袜筒、圆袜头与卷边，切换颜色时仍保持可读的日期位置。 */
[data-theme="christmas"] {
  --stock-cut: polygon(33% 3%, 86% 3%, 86% 62%, 83% 78%, 76% 89%, 64% 96%, 31% 96%, 18% 92%, 10% 84%, 7% 73%, 10% 61%, 17% 54%, 25% 52%, 36% 56%, 38% 53%);
}
[data-theme="christmas"] .nd-theme-day { --door-cover: repeating-linear-gradient(113deg,#9b3b50 0 2px,#8b3045 2px 4px); --door-edge: #e3a698; }
[data-theme="christmas"] .nd-theme-day:nth-child(3n) { --door-cover: repeating-linear-gradient(113deg,#386457 0 2px,#30584b 2px 4px); --door-edge: #b8caa1; }
[data-theme="christmas"] .nd-theme-day::before { inset: 2% 5% 0; clip-path: var(--stock-cut); border: 0; }
[data-theme="christmas"] .nd-theme-day::after { inset: auto 21% 9% 20%; height: 8%; border: 0; background: #fff1ce68; border-radius: 50%; }
[data-theme="christmas"] .nd-theme-day [data-door-handle] {
  top: 2%;
  left: 34%;
  bottom: auto;
  width: 51%;
  height: 21%;
  background: repeating-linear-gradient(90deg,#e5d4ae 0 2px,#f9ebd0 2px 4px);
  box-shadow: 0 2px 3px #241a1260;
  z-index: 1;
}
[data-theme="christmas"] .nd-theme-day > span:first-child { position: absolute; top: 40%; left: 55%; translate: -50% 0; }
[data-theme="christmas"] .nd-theme-day.nd-has-note { filter: drop-shadow(0 0 4px #ffd99baf); }
[data-theme="christmas"] .nd-theme-day.nd-has-note::before { filter: brightness(1.24); }
[data-theme="christmas"] .nd-theme-day .nd-theme-count { z-index: 2; }
[data-theme="garden"] .nd-theme-day { --door-cover: linear-gradient(145deg,#e6e5bd,#c2cb99); --door-edge: #a3ae6d; --door-ink: #344527; border-radius: 2px 2px 7px 7px; }
[data-theme="garden"] .nd-theme-day:nth-child(3n) { --door-cover: linear-gradient(145deg,#ecd8a5,#d9bb80); }
[data-theme="garden"] .nd-theme-day::before { inset-inline: 7%; box-shadow: inset 0 -6px #55664026, inset 0 6px #55664026; }
[data-theme="garden"] .nd-theme-day::after { inset: 9px 17% 8px; border-style: dashed; }
[data-theme="garden"] .nd-theme-day [data-door-handle] { width: 8px; height: 5px; border-radius: 70% 0; background: #71864c; transform: rotate(-17deg); }
.nd-theme-reveal {
  display: grid;
  height: 192px;
  place-items: center;
  margin: 16px 0 8px;
  overflow: hidden;
  border-radius: 10px;
  border: 1px solid #fff2ce30;
  background: radial-gradient(ellipse at center,#fff3c32a,transparent 63%),#0d100e42;
}
.nd-theme-parcel { position: relative; width: 158px; height: 114px; perspective: 390px; }
.nd-theme-parcel > span { position: absolute; }
.nd-theme-reveal-note {
  inset: 12px 28px;
  border: 1px solid #ad8a5a;
  border-radius: 4px;
  background: repeating-linear-gradient(#fff0c9 0 13px,#e9cb98 14px 15px);
  box-shadow: 0 3px 14px #1e13084c;
  opacity: 0;
}
.nd-theme-dialog[data-playing] .nd-theme-reveal-note { animation: nd-paper-rise .58s .27s both; }
.nd-theme-piece-a { inset: 0; border-radius: 7px; }
.nd-theme-piece-b { inset: 0; }
.nd-theme-sparks { inset: 0; }
.nd-theme-sparks i { position: absolute; left: 50%; top: 45%; width: 8px; height: 8px; border-radius: 50%; background: var(--theme-accent); opacity: 0; }
.nd-theme-sparks i:nth-child(1) { --x: -88px; --y: -48px; }
.nd-theme-sparks i:nth-child(2) { --x: -51px; --y: -64px; }
.nd-theme-sparks i:nth-child(3) { --x: 14px; --y: -78px; }
.nd-theme-sparks i:nth-child(4) { --x: 60px; --y: -73px; }
.nd-theme-sparks i:nth-child(5) { --x: 91px; --y: -44px; }
.nd-theme-dialog[data-playing] .nd-theme-sparks i { animation: nd-spark .52s .22s both; }
[data-theme="midnight"] .nd-theme-parcel { background: #1d100b; border-radius: 8px; border: 3px ridge #cb995b; box-shadow: inset 0 0 28px #ee9b41bb; }
[data-theme="midnight"] .nd-theme-piece-a { transform-origin: left center; background: linear-gradient(140deg,#c18d51,#673c25 56%,#94582f); border: 4px double #e8b877; }
[data-theme="midnight"] .nd-theme-piece-a::after { content: ""; position: absolute; right: 15px; top: 41%; width: 13px; height: 13px; border-radius: 50%; background: #ffdfa1; box-shadow: 1px 2px 4px #5e260b; }
[data-theme="midnight"] .nd-theme-piece-b { background: linear-gradient(122deg,transparent,#ffe49a91,transparent); opacity: 0; }
[data-theme="midnight"] .nd-theme-dialog[data-playing] .nd-theme-piece-a { animation: nd-cabinet .66s ease-out both; }
[data-theme="midnight"] .nd-theme-dialog[data-playing] .nd-theme-piece-b { animation: nd-light .65s .15s both; }
[data-theme="birthday"] .nd-theme-parcel { width: 137px; height: 104px; }
[data-theme="birthday"] .nd-theme-piece-a, [data-theme="birthday"] .nd-theme-piece-b {
  background: linear-gradient(90deg,#e8a5a2 41%,#fce1a2 41% 59%,#e8a5a2 59%);
  border: 1px solid #a7575f;
  border-radius: 5px;
}
[data-theme="birthday"] .nd-theme-piece-a { inset: 21px 8px 0; box-shadow: inset 0 -10px #671c332f, 0 6px 12px #2f0a1d67; }
[data-theme="birthday"] .nd-theme-piece-b { inset: 10px 0 auto; height: 24px; border-color: #ffe0be; box-shadow: 0 3px 5px #2f0a1d45; }
[data-theme="birthday"] .nd-theme-piece-b::before, [data-theme="birthday"] .nd-theme-piece-b::after {
  content: "";
  position: absolute;
  bottom: 95%;
  width: 31px;
  height: 19px;
  border: 5px solid #fce1a2;
  border-radius: 66% 64% 40% 52%;
}
[data-theme="birthday"] .nd-theme-piece-b::before { right: 50%; transform: rotate(19deg); }
[data-theme="birthday"] .nd-theme-piece-b::after { left: 50%; transform: scaleX(-1) rotate(19deg); }
[data-theme="birthday"] .nd-theme-sparks i { width: 13px; height: 11px; border-radius: 0; clip-path: polygon(0 0,100% 0,50% 100%); }
[data-theme="birthday"] .nd-theme-dialog[data-playing] .nd-theme-piece-a { animation: nd-gift-box .78s ease-out both; }
[data-theme="birthday"] .nd-theme-dialog[data-playing] .nd-theme-piece-b { animation: nd-gift-lid .70s ease-out both; }
[data-theme="christmas"] .nd-theme-parcel { width: 123px; height: 119px; }
[data-theme="christmas"] .nd-theme-piece-a { clip-path: var(--stock-cut); background: repeating-linear-gradient(113deg,#9b3b50 0 3px,#8b3045 3px 6px); transform-origin: 62% 7%; }
[data-theme="christmas"] .nd-theme-piece-b { inset: 0 12% auto 32%; height: 22px; border-radius: 5px; background: repeating-linear-gradient(90deg,#e5d4ae 0 3px,#f9ebd0 3px 5px); transform-origin: 55% 10%; box-shadow: 0 3px 6px #241a1260; }
[data-theme="christmas"] .nd-theme-reveal-note { inset: 10px 10px 40px 52px; }
[data-theme="christmas"] .nd-theme-sparks i { width: 14px; height: 14px; clip-path: polygon(50% 0,62% 37%,100% 50%,63% 62%,50% 100%,37% 64%,0 50%,37% 37%); }
[data-theme="christmas"] .nd-theme-dialog[data-playing] .nd-theme-piece-a,
[data-theme="christmas"] .nd-theme-dialog[data-playing] .nd-theme-piece-b { animation: nd-stocking .80s ease-in-out both; }
[data-theme="garden"] .nd-theme-parcel { width: 125px; }
[data-theme="garden"] .nd-theme-piece-a { border-radius: 4px 4px 11px 11px; background: linear-gradient(145deg,#eeebbd,#a4ad72); border: 5px double #757e49; }
[data-theme="garden"] .nd-theme-piece-a::after { content: ""; position: absolute; width: 28px; height: 17px; left: 42%; top: 49%; border-radius: 90% 0; background: #788553; transform: rotate(-24deg); }
[data-theme="garden"] .nd-theme-piece-b { inset: 0 0 auto; height: 38px; transform-origin: top; background: #c2c899; clip-path: polygon(0 0,100% 0,50% 100%); }
[data-theme="garden"] .nd-theme-sparks i { width: 13px; height: 8px; border-radius: 90% 0; background: #e4e7aa; }
[data-theme="garden"] .nd-theme-dialog[data-playing] .nd-theme-piece-a { animation: nd-seed-packet .65s ease both; }
[data-theme="garden"] .nd-theme-dialog[data-playing] .nd-theme-piece-b { animation: nd-seed-flap .56s ease both; }
@keyframes nd-cabinet { to { transform: rotateY(-112deg); opacity: .65; } }
@keyframes nd-light { 30% { opacity: 1; } to { opacity: 0; transform: translateX(82px); } }
@keyframes nd-paper-rise { from { opacity: 0; transform: translateY(24px) scale(.83); } 55% { opacity: 1; } to { opacity: 1; transform: translateY(-42px) rotate(-5deg); } }
@keyframes nd-gift-lid { 22% { transform: translate(-3px,-8px) rotate(-6deg); } 70% { opacity: 1; } to { transform: translate(-38px,-43px) rotate(-21deg); opacity: 0; } }
@keyframes nd-gift-box { 24% { transform: scale(1.02,.94); } 62% { opacity: 1; } to { transform: translateY(17px); opacity: .65; } }
@keyframes nd-stocking { 25% { transform: rotate(-13deg); } 48% { transform: rotate(8deg); } 72% { opacity: 1; } to { transform: translateY(20px) rotate(-6deg); opacity: .55; } }
@keyframes nd-seed-packet { 45% { transform: rotate(-6deg); } to { transform: translateY(35px) rotate(8deg); opacity: 0; } }
@keyframes nd-seed-flap { 54% { transform: rotateX(120deg) translateY(-8px); } to { transform: translateY(37px) rotateX(140deg); opacity: 0; } }
@keyframes nd-spark { 26% { opacity: 1; } to { transform: translate(var(--x),var(--y)) rotate(72deg) scale(.8); opacity: 0; } }
.nd-theme-letter { padding: 14px 16px; border-radius: 4px; background: var(--theme-paper); color: var(--theme-paper-ink); border: 1px solid #c2a474; box-shadow: 0 3px 9px #0002; }
.nd-theme-letter p { margin: 0; font: 500 1.07rem/1.5 var(--serif, Georgia, serif); }
.nd-theme-letter .nd-theme-author { margin: 7px 0 0; font: 720 .76rem/1.35 var(--sans, sans-serif); }
@media (prefers-reduced-motion: reduce) {
  .nd-theme-reveal * { animation: none !important; }
}
