.dp-calendar {
  --ink: #203b30;
  --ink-soft: #516054;
  --paper: #fffcf3;
  --accent: #9a3e34;
  --pine: #2c4e3e;
  --gold: #b89452;
  --cream: #f2e5c9;
  --rose: #9e433a;
  --pocket-bg: #f4eedc;
  --pocket-border: #cbbda0;
  color: var(--ink);
  width: min(100% - 2rem, 66rem);
  margin: 2.2rem auto 4rem;
  font-family: "DM Sans", "Avenir Next", -apple-system, sans-serif;
}

.dp-calendar[data-theme="cranberry"] {
  --pine: #6d3138;
  --rose: #a14b4a;
  --cream: #f7e1c9;
  --pocket-bg: #f7efe4;
  --pocket-border: #cfbca5;
}

.dp-calendar[data-theme="frost"] {
  --pine: #2d4c5e;
  --rose: #4c6f82;
  --cream: #e3eeef;
  --pocket-bg: #edf3f4;
  --pocket-border: #b3c5cb;
}

.dp-calendar[data-theme="gingerbread"] {
  --pine: #5e3b23;
  --rose: #9e5232;
  --cream: #f5e5c8;
  --pocket-bg: #f6eee0;
  --pocket-border: #cfb897;
}

.dp-calendar *,
.dp-calendar *::before,
.dp-calendar *::after {
  box-sizing: border-box;
}

.dp-calendar :is(h1, h2, h3, p) {
  margin: 0;
}

.dp-calendar :is(button, input, textarea) {
  font: inherit;
}

.dp-calendar button {
  cursor: pointer;
}

.dp-calendar button:disabled {
  opacity: 0.6;
  cursor: wait;
}

.dp-calendar :is(button, a, input, textarea):focus-visible {
  outline: 3px solid #b57c2a;
  outline-offset: 3px;
}

/* Loading & error state */
.dp-loading {
  text-align: center;
  padding: 4rem 1rem;
  font-family: "Baskervville", Georgia, serif;
  font-style: italic;
  font-size: 1.3rem;
  color: var(--ink-soft);
}

.dp-error-state {
  text-align: center;
  padding: 4rem 1rem;
  display: grid;
  justify-items: center;
  gap: 1rem;
}

/* Intro header */
.dp-intro {
  text-align: center;
  max-width: 46rem;
  margin: auto;
}

.dp-top-meta {
  display: inline-flex;
  align-items: center;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.6rem;
}

.dp-dateline,
.dp-progress,
.dp-stamp-label,
.dp-badge,
.dp-pill {
  font-family: "Courier Prime", "Courier New", monospace;
  font-size: 0.8rem;
}

.dp-dateline {
  text-transform: uppercase;
  color: var(--accent);
  letter-spacing: 0.13em;
  font-weight: 700;
}

.dp-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.22rem 0.65rem;
  border-radius: 999px;
  background: #f0e8d2;
  color: var(--ink);
  font-weight: 700;
  font-size: 0.74rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.dp-pill.is-live {
  background: #234735;
  color: #fff8e2;
}

.dp-calendar h1,
.dp-calendar h2,
.dp-calendar .dp-number,
.dp-calendar .dp-message {
  font-family: "Baskervville", Georgia, serif;
  font-weight: 400;
}

.dp-calendar h1 {
  font-size: clamp(2.4rem, 5.5vw, 4.3rem);
  margin: 0.5rem 0 0.6rem;
  line-height: 1.04;
  letter-spacing: -0.04em;
  overflow-wrap: anywhere;
}

.dp-description {
  max-width: 35rem;
  margin: auto;
  line-height: 1.56;
  color: var(--ink-soft);
  font-size: 1rem;
}

.dp-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.dp-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  border: 1px solid var(--ink);
  border-radius: 8px;
  color: #fffaea;
  background: var(--ink);
  font-weight: 600;
  padding: 0.7rem 1.2rem;
  min-height: 2.75rem;
  text-decoration: none;
  transition: background-color 0.15s ease, transform 0.12s ease;
}

.dp-action:hover {
  background: #173426;
  transform: translateY(-1px);
}

.dp-action-secondary {
  background: var(--paper);
  color: var(--ink);
  border: 1px solid #c2bda7;
}

.dp-action-secondary:hover {
  background: #f4eedd;
  border-color: var(--ink);
}

.dp-action-gold {
  background: #9f7939;
  border-color: #8b682e;
  color: #fffdf5;
}

.dp-action-gold:hover {
  background: #87652c;
}

.dp-link {
  border: 0;
  background: transparent;
  color: var(--ink);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 0.22em;
  padding: 0.5rem 0.25rem;
}

.dp-link:hover {
  color: var(--accent);
}

.dp-feedback {
  font-size: 0.92rem;
  margin: 0.75rem 0 0;
  color: #27533b;
  font-weight: 500;
}

.dp-feedback:empty,
.dp-error:empty {
  display: none;
}

/* Theme bar for owner */
.dp-theme-bar {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.4rem;
  border-radius: 999px;
  background: #f3ede0;
  border: 1px solid #d5cfb9;
}

.dp-theme-chip {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.dp-theme-chip:hover {
  transform: scale(1.12);
}

.dp-theme-chip[aria-pressed="true"] {
  border-color: #fffdf6;
  box-shadow: 0 0 0 2px var(--ink);
}

/* Board */
.dp-board {
  --board-pad: clamp(0.95rem, 3.2vw, 2rem);
  overflow: hidden;
  margin-top: 1.8rem;
  background: var(--paper);
  border: 1px solid #b5a382;
  border-radius: 14px;
  padding: var(--board-pad);
  box-shadow:
    0 5px 0 -2px #f6edd9,
    0 6px 0 -2px #b9aa8e,
    0 14px 30px rgba(48, 37, 22, 0.1);
}

.dp-art-wrap {
  position: relative;
  margin: calc(0px - var(--board-pad)) calc(0px - var(--board-pad)) 1.1rem;
}

.dp-village {
  display: block;
  width: 100%;
  height: clamp(6rem, 15vw, 9.8rem);
  object-fit: cover;
  object-position: center 62%;
  transition: filter 0.35s ease;
}

.dp-calendar[data-theme="frost"] .dp-village {
  filter: hue-rotate(109deg) saturate(0.66) brightness(1.04);
}

.dp-calendar[data-theme="gingerbread"] .dp-village {
  filter: sepia(0.32) saturate(1.08) brightness(0.96);
}

.dp-calendar[data-theme="cranberry"] .dp-village {
  filter: hue-rotate(-14deg) saturate(1.04);
}

.dp-board-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.75rem;
  border-bottom: 3px double #bcab8d;
  margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
}

.dp-board-head h2 {
  font-size: clamp(1.9rem, 4vw, 2.85rem);
  line-height: 1;
  font-style: italic;
}

.dp-progress-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}

.dp-progress {
  color: var(--ink-soft);
}

.dp-progress-track {
  width: 150px;
  height: 6px;
  border-radius: 999px;
  background: #e6dec8;
  overflow: hidden;
}

.dp-progress-fill {
  height: 100%;
  background: var(--pine);
  border-radius: 999px;
  transition: width 0.35s ease;
}

/* Doors Grid */
.dp-grid {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: clamp(0.45rem, 1.1vw, 0.9rem);
}

.dp-door {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 0.15rem;
  aspect-ratio: 1 / 1.1;
  min-width: 0;
  padding: 0.5rem 0.35rem;
  border-radius: 7px;
  border: 1px solid transparent;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.dp-door:hover {
  transform: translateY(-3px);
}

/* State 1: Empty pocket */
.dp-door[data-state="empty"] {
  background: var(--pocket-bg);
  color: var(--ink);
  border: 1.5px dashed var(--pocket-border);
  box-shadow: inset 0 2px 6px rgba(45, 38, 25, 0.06);
}

.dp-door[data-state="empty"]:hover {
  border-color: var(--pine);
  background: #fbf7eb;
  box-shadow: 0 6px 14px rgba(32, 59, 48, 0.1);
}

.dp-door[data-state="empty"] .dp-number {
  opacity: 0.58;
}

.dp-door[data-state="empty"] .dp-ornament {
  font-size: 0.95rem;
  opacity: 0.45;
}

.dp-door[data-state="empty"] .dp-stamp-label {
  color: var(--ink-soft);
  opacity: 0.85;
}

/* State 2: Sealed (Filled & Locked) */
.dp-door[data-state="sealed"],
.dp-door[data-state="ready"] {
  background-color: var(--pine);
  color: #fff4de;
  box-shadow: 0 3px 8px rgba(32, 42, 34, 0.18);
}

.dp-door[data-state="sealed"]::before,
.dp-door[data-state="ready"]::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: -1;
  border: 1px dashed rgba(255, 244, 222, 0.48);
  border-radius: 4px;
}

.dp-door[data-state="sealed"]:nth-child(6n + 2),
.dp-door[data-state="sealed"]:nth-child(6n + 6),
.dp-door[data-state="ready"]:nth-child(6n + 2),
.dp-door[data-state="ready"]:nth-child(6n + 6) {
  background-color: var(--cream);
  color: var(--ink);
}

.dp-door[data-state="sealed"]:nth-child(6n + 2)::before,
.dp-door[data-state="sealed"]:nth-child(6n + 6)::before,
.dp-door[data-state="ready"]:nth-child(6n + 2)::before,
.dp-door[data-state="ready"]:nth-child(6n + 6)::before {
  border-color: rgba(32, 59, 48, 0.32);
}

.dp-door[data-state="sealed"]:nth-child(6n + 3),
.dp-door[data-state="sealed"]:nth-child(6n + 5),
.dp-door[data-state="ready"]:nth-child(6n + 3),
.dp-door[data-state="ready"]:nth-child(6n + 5) {
  background-color: var(--rose);
  color: #fff4de;
}

.dp-door[data-state="sealed"]:nth-child(4n + 1),
.dp-door[data-state="ready"]:nth-child(4n + 1) {
  background-image: repeating-linear-gradient(45deg, transparent 0 7px, rgba(255, 240, 200, 0.08) 7px 9px);
}

.dp-door[data-state="sealed"]:nth-child(4n + 2),
.dp-door[data-state="ready"]:nth-child(4n + 2) {
  background-image: radial-gradient(rgba(115, 99, 76, 0.16) 1px, transparent 1.5px);
  background-size: 9px 9px;
}

/* State 3: Ready to unwrap (Unlocked + Unread for owner) */
.dp-door[data-state="ready"] {
  border: 2px solid #e5be6c;
  box-shadow:
    0 0 0 2px rgba(229, 190, 108, 0.35),
    0 6px 16px rgba(184, 148, 82, 0.32);
  animation: readyGlow 2.4s ease-in-out infinite;
}

@keyframes readyGlow {
  0%, 100% { box-shadow: 0 0 0 2px rgba(229, 190, 108, 0.3), 0 6px 14px rgba(184, 148, 82, 0.25); }
  50% { box-shadow: 0 0 0 4px rgba(229, 190, 108, 0.6), 0 8px 20px rgba(184, 148, 82, 0.45); }
}

/* State 4: Opened (Read by owner) */
.dp-door[data-state="opened"] {
  background: #fffdf7;
  color: var(--ink);
  border: 1.5px solid #cab894;
  box-shadow: inset 0 3px 10px rgba(73, 56, 30, 0.12);
}

.dp-door[data-state="opened"]::before {
  content: "";
  position: absolute;
  inset: 5px;
  z-index: -1;
  border: 1px solid #e4d8bd;
  border-radius: 4px;
}

.dp-door[data-today="true"] {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

.dp-door-badge {
  position: absolute;
  top: 5px;
  right: 5px;
  font-family: "Courier Prime", monospace;
  font-size: 0.65rem;
  font-weight: 700;
  padding: 2px 5px;
  border-radius: 999px;
  background: rgba(25, 42, 34, 0.82);
  color: #fff8e6;
  line-height: 1.1;
}

.dp-door-badge.is-gold {
  background: #d3a349;
  color: #1f2e25;
}

.dp-door-badge.is-mine {
  left: 5px;
  right: auto;
  background: var(--accent);
  color: #fff9ee;
}

.dp-ornament {
  line-height: 1;
  font-size: clamp(1rem, 1.8vw, 1.45rem);
}

.dp-number {
  line-height: 1;
  letter-spacing: -0.04em;
  font-size: clamp(1.7rem, 3.2vw, 2.7rem);
}

.dp-stamp-label {
  max-width: 94%;
  font-size: 0.72rem;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  opacity: 0.92;
}

/* Dialog & Modals */
.dp-dialog {
  box-sizing: border-box;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid #9e9176;
  border-radius: 14px;
  width: min(30rem, calc(100% - 1.75rem));
  max-height: 88dvh;
  padding: 1.85rem;
  margin: auto;
  box-shadow: 0 1.25rem 4rem rgba(24, 42, 35, 0.36);
}

.dp-dialog::backdrop {
  background: rgba(20, 38, 31, 0.64);
  backdrop-filter: blur(3px);
}

.dp-close {
  position: absolute;
  top: 0.45rem;
  right: 0.55rem;
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: inherit;
  font-size: 1.65rem;
  line-height: 1;
}

.dp-close:hover {
  background: rgba(32, 59, 48, 0.08);
}

.dp-dialog-content {
  display: grid;
  gap: 0.95rem;
}

.dp-dialog h2 {
  font-size: 2rem;
  line-height: 1.08;
  letter-spacing: -0.03em;
  overflow-wrap: anywhere;
  padding-right: 1.6rem;
}

.dp-dialog p {
  line-height: 1.54;
  overflow-wrap: anywhere;
}

/* Postcard stack inside modal */
.dp-postcard-list {
  display: grid;
  gap: 0.9rem;
}

.dp-postcard {
  position: relative;
  border: 1px solid #d5cab0;
  border-radius: 10px;
  background: #ffffff;
  padding: 1.15rem 1.2rem;
  box-shadow: 0 3px 10px rgba(48, 37, 22, 0.06);
  display: grid;
  gap: 0.65rem;
}

.dp-postcard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.dp-large-sticker {
  font-size: 2.2rem;
  line-height: 1;
}

.dp-wax-seal {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  color: #fffaf0;
  font-family: "Courier Prime", monospace;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.dp-wax-seal[data-seal="crimson"] { background: #9a3e34; }
.dp-wax-seal[data-seal="forest"] { background: #2b523e; }
.dp-wax-seal[data-seal="gold"] { background: #a87f35; }
.dp-wax-seal[data-seal="midnight"] { background: #2c4a5e; }
.dp-wax-seal[data-seal="rose"] { background: #9e4b5b; }

.dp-message {
  white-space: pre-wrap;
  font-size: 1.42rem;
  line-height: 1.45;
  color: var(--ink);
}

.dp-postcard-foot {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-top: 0.5rem;
  border-top: 1px dashed #dfd6bf;
  font-family: "Courier Prime", monospace;
  font-size: 0.78rem;
  color: var(--ink-soft);
}

.dp-remove-btn {
  border: 0;
  background: transparent;
  color: #9a3e34;
  font-size: 0.78rem;
  font-family: "DM Sans", sans-serif;
  font-weight: 600;
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
}

.dp-remove-btn:hover {
  background: rgba(154, 62, 52, 0.1);
}

/* Write Note Form */
.dp-form {
  display: grid;
  gap: 0.85rem;
}

.dp-label,
.dp-stickers legend,
.dp-seals legend {
  display: block;
  font-size: 0.9rem;
  font-weight: 600;
}

.dp-input {
  display: block;
  width: 100%;
  border: 1px solid #b6b8a5;
  border-radius: 7px;
  background: #ffffff;
  color: var(--ink);
  padding: 0.65rem 0.75rem;
  line-height: 1.4;
}

.dp-input:focus {
  border-color: var(--pine);
  outline: none;
  box-shadow: 0 0 0 3px rgba(44, 78, 62, 0.14);
}

.dp-calendar label .dp-input {
  margin-top: 0.35rem;
}

.dp-calendar textarea {
  resize: vertical;
  min-height: 5.5rem;
}

.dp-check {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.88rem;
  color: var(--ink-soft);
}

.dp-calendar input[type="checkbox"] {
  accent-color: var(--ink);
  width: 1rem;
  height: 1rem;
}

.dp-counter {
  text-align: right;
  font-size: 0.78rem;
  font-family: "Courier Prime", monospace;
  margin-top: -0.55rem;
  color: var(--ink-soft);
}

.dp-stickers,
.dp-seals {
  border: 0;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.dp-stickers div {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.35rem;
  margin-top: 0.4rem;
}

.dp-stickers label,
.dp-seals label {
  position: relative;
  cursor: pointer;
}

.dp-stickers input,
.dp-seals input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.dp-stickers span {
  display: grid;
  place-items: center;
  padding: 0.35rem;
  min-height: 2.55rem;
  border: 1px solid #cac6b3;
  border-radius: 7px;
  background: #ffffff;
  font-size: 1.25rem;
  transition: transform 0.12s ease, border-color 0.12s ease, background-color 0.12s ease;
}

.dp-stickers span:hover {
  border-color: var(--pine);
  transform: scale(1.05);
}

.dp-stickers input:checked + span {
  border: 2px solid var(--pine);
  background: #ecf2e4;
}

.dp-stickers input:focus-visible + span,
.dp-seals input:focus-visible + span {
  outline: 3px solid #b57c2a;
  outline-offset: 2px;
}

.dp-seals div {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-top: 0.4rem;
}

.dp-seals span {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  border: 1px solid #cac6b3;
  background: #ffffff;
  font-size: 0.8rem;
  font-weight: 600;
}

.dp-seals i {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--seal-color);
}

.dp-seals input:checked + span {
  border-color: var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
  background: #f2f4ea;
}

/* Writing prompt chips */
.dp-prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.dp-prompt-chip {
  border: 1px solid #d4ceb9;
  border-radius: 999px;
  background: #faf6ea;
  color: var(--ink-soft);
  font-size: 0.76rem;
  padding: 0.25rem 0.6rem;
  transition: background-color 0.15s ease, color 0.15s ease;
}

.dp-prompt-chip:hover {
  background: #ede6d1;
  color: var(--ink);
}

.dp-error {
  font-size: 0.9rem;
  color: #9a332e;
}

/* Share Modal tools */
.dp-share-row {
  display: flex;
  gap: 0.5rem;
}

.dp-share-row .dp-input {
  flex: 1;
  min-width: 0;
}

.dp-share-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.55rem;
}

.dp-recovery {
  border-top: 1px dashed #d4ccb6;
  padding-top: 0.85rem;
  font-size: 0.86rem;
  color: var(--ink-soft);
}

.dp-recovery summary {
  cursor: pointer;
  font-weight: 600;
  color: var(--ink);
}

.dp-recovery-body {
  display: grid;
  gap: 0.6rem;
  margin-top: 0.6rem;
}

/* Confetti celebration layer */
.dp-confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 100;
  overflow: hidden;
}

.dp-confetti {
  position: absolute;
  font-size: 18px;
  opacity: 0;
  animation: confettiPop 1.15s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes confettiPop {
  0% {
    opacity: 0;
    transform: translate(0, 0) scale(0.5) rotate(0deg);
  }
  15% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(var(--dx), var(--dy)) scale(1.15) rotate(var(--rot));
  }
}

@media (max-width: 680px) {
  .dp-calendar {
    margin-top: 1.5rem;
  }
  .dp-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
  .dp-dialog {
    padding: 1.45rem;
  }
  .dp-share-grid {
    grid-template-columns: 1fr;
  }
  .dp-progress-wrap {
    align-items: flex-start;
  }
}

@media (max-width: 390px) {
  .dp-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
  .dp-stickers div {
    grid-template-columns: repeat(4, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dp-door,
  .dp-door[data-state="ready"] {
    transition: none;
    animation: none;
  }
  .dp-confetti-layer {
    display: none;
  }
}
