:root {
  color-scheme: light;
  --ink: #4d3f39;
  --muted: #8c7970;
  --paper: #f8f1e5;
  --paper-deep: #efe2d0;
  --cream: #fffaf1;
  --terracotta: #bd755d;
  --terracotta-dark: #925744;
  --rose: #e9b8aa;
  --green: #9eb18d;
  --line: rgba(90, 67, 55, 0.17);
  --shadow: 0 18px 48px rgba(86, 62, 48, 0.13);
  font-family: "Comic Sans MS", "Microsoft YaHei", "PingFang SC", system-ui, sans-serif;
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  min-width: 320px;
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  background-image:
    linear-gradient(rgba(255,255,255,.42), rgba(255,255,255,.1)),
    repeating-linear-gradient(0deg, transparent 0 31px, rgba(113,86,69,.035) 31px 32px);
}

button { font: inherit; color: inherit; }

button:focus-visible {
  outline: 3px solid rgba(189,117,93,.42);
  outline-offset: 3px;
}

.paper-noise {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: .26;
  background-image: radial-gradient(rgba(62,44,35,.13) .45px, transparent .6px);
  background-size: 5px 5px;
  mix-blend-mode: multiply;
}

.activation-screen {
  position: relative;
  z-index: 1;
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  place-items: center;
  padding: max(32px, env(safe-area-inset-top)) 18px max(32px, env(safe-area-inset-bottom));
  transition: opacity .26s ease, transform .26s ease;
}

.activation-screen[hidden] { display: none; }
.has-saved-activation .activation-screen { display: none; }
.activation-screen.is-leaving { opacity: 0; transform: translateY(-8px); }

.activation-card {
  position: relative;
  width: min(100%, 430px);
  padding: 58px 34px 30px;
  border: 1px solid rgba(104,77,62,.16);
  border-radius: 28px 24px 32px 22px;
  background: rgba(255,250,241,.92);
  box-shadow: 0 22px 60px rgba(86,62,48,.16);
  transform: rotate(-.12deg);
}

.activation-card::after {
  content: "";
  position: absolute;
  inset: 12px;
  z-index: -1;
  border: 1px dashed rgba(146,87,68,.13);
  border-radius: 21px 19px 25px 17px;
  pointer-events: none;
}

.activation-tape {
  position: absolute;
  top: -13px;
  left: 50%;
  width: 104px;
  height: 31px;
  background: rgba(221,193,151,.62);
  box-shadow: 0 2px 4px rgba(84,62,44,.08);
  transform: translateX(-50%) rotate(-2deg);
}

.activation-brand { text-align: center; }
.activation-brand .eyebrow { margin-bottom: 8px; }
.activation-brand h1 {
  margin: 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(46px, 13vw, 62px);
  font-weight: 500;
  letter-spacing: .08em;
}

.activation-rule {
  display: block;
  width: 44px;
  height: 1px;
  margin: 18px auto 27px;
  background: var(--terracotta);
}

.activation-form label {
  display: block;
  margin-bottom: 12px;
  font-family: Georgia, "Songti SC", serif;
  font-size: 19px;
  text-align: center;
  letter-spacing: .05em;
}

.activation-input-wrap { position: relative; }

.activation-key {
  position: absolute;
  z-index: 1;
  top: 50%;
  left: 20px;
  width: 17px;
  height: 17px;
  border: 2px solid var(--terracotta-dark);
  border-radius: 50%;
  transform: translateY(-50%);
  pointer-events: none;
}

.activation-key::before {
  content: "";
  position: absolute;
  top: 6px;
  left: 14px;
  width: 14px;
  height: 3px;
  border-radius: 2px;
  background: var(--terracotta-dark);
}

.activation-key::after {
  content: "";
  position: absolute;
  top: 7px;
  left: 23px;
  width: 3px;
  height: 6px;
  border-left: 3px solid var(--terracotta-dark);
  border-right: 3px solid var(--terracotta-dark);
}

.activation-input {
  width: 100%;
  height: 62px;
  padding: 0 18px 0 61px;
  border: 1.5px solid rgba(146,87,68,.28);
  border-radius: 17px 14px 19px 15px;
  outline: none;
  background: rgba(255,255,255,.58);
  color: var(--ink);
  font: 600 20px/1 ui-monospace, "SFMono-Regular", Consolas, monospace;
  letter-spacing: .13em;
  text-transform: uppercase;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}

.activation-input::placeholder { color: rgba(77,63,57,.32); }
.activation-input:focus {
  border-color: var(--terracotta);
  background: rgba(255,255,255,.82);
  box-shadow: 0 0 0 4px rgba(189,117,93,.11);
}

.activation-button {
  display: flex;
  width: 100%;
  min-height: 55px;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-top: 14px;
  border: 0;
  border-radius: 17px 14px 18px 13px;
  background: var(--terracotta-dark);
  box-shadow: 0 9px 20px rgba(146,87,68,.22);
  color: #fffaf1;
  cursor: pointer;
  font-weight: 700;
  letter-spacing: .08em;
  transition: opacity .2s ease, transform .18s ease, background .2s ease;
}

.activation-button:not(:disabled):active { transform: translateY(1px) scale(.995); }
.activation-button:disabled { opacity: .34; box-shadow: none; cursor: not-allowed; }
.activation-button.is-success { background: #7f9871; opacity: 1; }

.activation-status {
  min-height: 20px;
  margin: 10px 4px 0;
  color: #a34f45;
  font-size: 12px;
  text-align: center;
}

.activation-form.has-error .activation-input {
  border-color: #bd675c;
  animation: activationShake .28s ease;
}

.activation-help {
  margin: 2px 0 26px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.65;
  text-align: center;
}

.activation-signature {
  margin: 0;
  padding-top: 19px;
  border-top: 1px dashed rgba(90,67,55,.2);
  color: var(--muted);
  font-family: Georgia, "Songti SC", serif;
  font-size: 13px;
  text-align: center;
  letter-spacing: .08em;
}

@keyframes activationShake {
  0%, 100% { transform: translateX(0); }
  35% { transform: translateX(-5px); }
  70% { transform: translateX(5px); }
}

.app-shell {
  width: min(100%, 820px);
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 18px calc(72px + env(safe-area-inset-bottom));
}

.screen { animation: pageIn .28s ease both; }

.topbar,
.day-topbar,
.calendar-heading,
.drawer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.topbar h1 {
  margin: 2px 0 0;
  font-family: Georgia, "Songti SC", serif;
  font-size: clamp(34px, 8vw, 50px);
  font-weight: 500;
  letter-spacing: .06em;
}

.topbar-actions { display: flex; align-items: center; gap: 9px; }

.eyebrow {
  margin: 0;
  color: var(--terracotta-dark);
  font: 700 10px/1.2 ui-monospace, monospace;
  letter-spacing: .22em;
}

.icon-button,
.month-button {
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  background: rgba(255,250,241,.7);
  box-shadow: 0 5px 14px rgba(86,62,48,.08);
  cursor: pointer;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  font-size: 25px;
}

.install-button { padding: 0; }
.install-arrow { position: relative; display: block; width: 20px; height: 22px; }
.install-arrow::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 2px;
  width: 4px;
  height: 15px;
  border-radius: 3px;
  background: currentColor;
  transform: translateX(-50%);
}
.install-arrow::after {
  content: "";
  position: absolute;
  left: 2px;
  top: 0;
  width: 16px;
  height: 11px;
  background: currentColor;
  clip-path: polygon(50% 0, 100% 70%, 76% 70%, 50% 35%, 24% 70%, 0 70%);
}
.settings-button { padding: 0; }
.menu-dots { display: flex; align-items: center; justify-content: center; gap: 4px; }
.menu-dots i { width: 5px; height: 5px; border-radius: 50%; background: currentColor; }

.intro {
  width: min(500px, 92%);
  margin: 15px 0 25px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.8;
}

.calendar-card {
  position: relative;
  padding: 22px 16px 16px;
  border: 1px solid rgba(104,77,62,.14);
  border-radius: 25px 25px 30px 22px;
  background: rgba(255,250,241,.86);
  box-shadow: var(--shadow);
  transform: rotate(-.15deg);
}

.calendar-card::before {
  content: "";
  position: absolute;
  width: 74px;
  height: 22px;
  left: 50%;
  top: -12px;
  transform: translateX(-50%) rotate(-2deg);
  background: rgba(221,193,151,.55);
  box-shadow: 0 1px 2px rgba(84,62,44,.08);
}

.month-label { text-align: center; }

.month-label strong {
  display: block;
  font-family: Georgia, "Songti SC", serif;
  font-size: 24px;
  font-weight: 500;
}

.month-label span { color: var(--muted); font-size: 11px; letter-spacing: .13em; }

.month-button {
  width: 42px;
  height: 42px;
  border-radius: 15px 13px 16px 12px;
  font: 30px/1 Georgia, serif;
}

.month-button:disabled { opacity: .25; cursor: not-allowed; }

.weekdays,
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
}

.weekdays {
  margin-top: 18px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.weekdays span { padding: 7px 0; }

.calendar-grid { gap: 4px 2px; }

.day-cell {
  position: relative;
  min-width: 0;
  aspect-ratio: .82;
  border: 0;
  border-radius: 15px 13px 16px 12px;
  background: transparent;
  cursor: pointer;
  transition: transform .16s ease, background .16s ease;
}

.day-cell:hover:not(:disabled) { transform: translateY(-2px); background: rgba(233,184,170,.18); }
.day-cell:active:not(:disabled) { transform: scale(.95); }
.day-cell--blank { pointer-events: none; }
.day-cell:disabled { cursor: default; color: #cbbeb5; }
.day-cell--selected { background: #ead0c4 !important; box-shadow: inset 0 0 0 1px rgba(155,91,69,.15); }
.day-cell--today .day-number-small { color: var(--terracotta-dark); }
.day-cell--today::after {
  content: "今天";
  position: absolute;
  right: 3px;
  top: 3px;
  color: var(--terracotta-dark);
  font-size: 7px;
  transform: rotate(5deg);
}

.day-number-small {
  position: absolute;
  left: 7px;
  top: 5px;
  font-family: Georgia, serif;
  font-size: clamp(17px, 4.8vw, 25px);
  line-height: 1;
}

.cell-stickers {
  position: absolute;
  inset: 45% 3px 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  align-content: center;
  gap: 0;
  overflow: hidden;
}

.cell-stickers img {
  width: clamp(16px, 4.2vw, 25px);
  height: clamp(16px, 4.2vw, 25px);
  margin: -1px;
  object-fit: contain;
}

.calendar-hint {
  margin: 14px 0 0;
  color: var(--muted);
  text-align: center;
  font-size: 11px;
}

.tiny-star { color: var(--terracotta); }

.sticker-section { padding-top: 34px; }

.sticker-box {
  position: relative;
  display: block;
  width: min(300px, 76vw);
  height: 156px;
  margin: 0 auto;
  border: 0;
  background: transparent;
  cursor: pointer;
  filter: drop-shadow(0 18px 16px rgba(80,55,38,.17));
  transition: transform .2s ease;
}

.sticker-box:hover { transform: translateY(-4px) rotate(.4deg); }
.sticker-box:active { transform: translateY(2px) scale(.98); }

.box-lid {
  position: absolute;
  z-index: 2;
  top: 16px;
  left: 12px;
  width: calc(100% - 24px);
  height: 40px;
  border: 2px solid #9b6849;
  border-radius: 8px 6px 4px 7px;
  background: #c99568;
  transform: rotate(-2deg);
}

.box-lid::before,
.box-lid::after {
  content: "";
  position: absolute;
  top: -20px;
  width: 49%;
  height: 30px;
  border: 2px solid #9b6849;
  background: #d4a576;
}

.box-lid::before { left: -2px; transform: skewY(8deg); border-radius: 10px 2px 0; }
.box-lid::after { right: -2px; transform: skewY(-8deg); border-radius: 2px 10px 0 0; }

.box-lid i {
  position: absolute;
  left: 50%;
  top: -18px;
  width: 45px;
  height: 55px;
  transform: translateX(-50%);
  background: rgba(244,218,167,.6);
}

.box-body {
  position: absolute;
  left: 22px;
  right: 14px;
  top: 46px;
  bottom: 10px;
  display: grid;
  place-items: center;
  border: 2px solid #956344;
  border-radius: 5px 7px 17px 10px;
  background: #c68c5d;
  overflow: hidden;
  transform: rotate(.8deg);
}

.box-body::after {
  content: "";
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(90deg, transparent 0 32px, rgba(107,69,43,.055) 33px 35px);
}

.box-label {
  z-index: 1;
  display: grid;
  min-width: 142px;
  padding: 10px 20px 12px;
  border: 1px solid #96755e;
  background: #fbf2dc;
  text-align: center;
  transform: rotate(-2deg);
  box-shadow: 0 3px 5px rgba(79,53,34,.11);
}

.box-label small { font: 700 8px/1.4 ui-monospace, monospace; letter-spacing: .2em; color: var(--muted); }
.box-label strong { font-family: Georgia, "Songti SC", serif; font-size: 24px; letter-spacing: .16em; }
.box-tape { position: absolute; width: 35px; height: 120%; background: rgba(242,203,145,.3); }

.sticker-drawer {
  margin-top: 15px;
  padding: 25px 18px 22px;
  border: 1px dashed rgba(104,77,62,.3);
  border-radius: 28px 19px 26px 21px;
  background: rgba(255,250,241,.58);
  animation: drawerIn .35s cubic-bezier(.2,.8,.2,1) both;
}

.drawer-heading h2 { margin: 5px 0 0; font: 500 20px/1.4 Georgia, "Songti SC", serif; }

.date-ticket {
  flex: 0 0 auto;
  padding: 8px 10px;
  background: #e6cf9f;
  color: #755744;
  font-size: 11px;
  transform: rotate(3deg);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 15px 13px;
  margin-top: 24px;
}

.category-button {
  position: relative;
  display: grid;
  place-items: center;
  aspect-ratio: 1.45;
  min-height: 112px;
  border: 0;
  border-radius: 18px;
  background: transparent;
  cursor: pointer;
  transform: rotate(var(--tilt));
  transition: transform .18s ease, filter .18s ease;
}

.category-button:hover { transform: rotate(0) translateY(-3px); filter: saturate(1.08); }
.category-button:active { transform: scale(.95); }
.category-button.is-used::after { content: "✓"; position: absolute; right: 22%; top: 8%; color: var(--terracotta-dark); font-size: 15px; }
.category-icon {
  width: clamp(68px, 18vw, 94px);
  height: clamp(68px, 18vw, 94px);
  object-fit: contain;
  filter: drop-shadow(0 7px 7px rgba(86,62,48,.12));
  user-select: none;
}
.category-name { margin-top: 10px; font-family: Georgia, "Songti SC", serif; font-size: 16px; }
.drawer-note { margin: 18px 0 0; color: var(--muted); text-align: center; font-size: 11px; }

.day-topbar { margin-bottom: 28px; }
.back-button { border: 0; padding: 9px 0; background: transparent; color: var(--terracotta-dark); cursor: pointer; }
.day-topbar-note { color: var(--muted); font-size: 11px; }

.day-page {
  position: relative;
  min-height: 620px;
  padding: 40px 26px 36px;
  border: 1px solid var(--line);
  border-radius: 8px 14px 10px 6px;
  background: #fffaf0;
  box-shadow: var(--shadow);
  transform: rotate(.2deg);
}

.day-page::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(transparent 0 42px, rgba(130,104,85,.08) 43px 44px);
  mask-image: linear-gradient(to bottom, transparent 0 175px, #000 230px);
}

.tape { position: absolute; z-index: 2; top: -15px; width: 74px; height: 26px; background: rgba(219,184,136,.55); }
.tape--left { left: 8%; transform: rotate(-6deg); }
.tape--right { right: 8%; transform: rotate(5deg); }

.day-date-block { display: flex; align-items: flex-end; gap: 15px; }
.day-year { position: absolute; right: 25px; top: 23px; margin: 0; color: var(--muted); font: 11px ui-monospace, monospace; letter-spacing: .18em; }
.day-number { font: 500 clamp(82px, 23vw, 124px)/.78 Georgia, serif; color: var(--terracotta); }
.day-date-block h2 { margin: 0 0 3px; font: 500 25px Georgia, "Songti SC", serif; }
.day-date-block div p { margin: 0 0 1px; color: var(--muted); font-size: 13px; }
.dashed-line { margin: 29px 0 25px; border-top: 1px dashed rgba(95,72,59,.34); }
.day-note {
  position: relative;
  z-index: 1;
  min-height: 184px;
}

.day-note-input {
  display: block;
  width: 100%;
  height: 176px;
  margin: 0;
  padding: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--ink);
  caret-color: var(--terracotta-dark);
  font-family: Georgia, "Songti SC", serif;
  font-size: 18px;
  line-height: 44px;
  text-align: left;
  overflow-wrap: anywhere;
}

.day-note-input::placeholder {
  color: var(--ink);
  opacity: 1;
}

.day-note-status {
  position: absolute;
  right: 2px;
  bottom: 0;
  color: var(--muted);
  font-size: 11px;
  pointer-events: none;
}
.day-note-caret {
  display: none;
  position: absolute;
  z-index: 3;
  width: 2px;
  border-radius: 2px;
  background: var(--terracotta-dark);
  pointer-events: none;
}
.day-stickers { position: relative; z-index: 1; display: flex; flex-wrap: wrap; gap: 15px; margin-top: 25px; }
.day-sticker {
  display: grid;
  place-items: center;
  width: 112px;
  min-height: 118px;
  padding: 4px 6px 10px;
  border: 0;
  background: transparent;
  cursor: pointer;
  transform: rotate(var(--tilt));
}
.day-sticker img { width: 84px; height: 84px; object-fit: contain; user-select: none; }
.day-sticker span:last-child { font-size: 12px; }
.remove-button { position: relative; z-index: 1; display: block; margin: 42px auto 0; border: 0; border-bottom: 1px dashed currentColor; background: transparent; color: #a57060; cursor: pointer; font-size: 12px; }
.remove-button[hidden] { display: none; }

.settings-page {
  position: relative;
  padding: 36px 22px 30px;
  border: 1px solid var(--line);
  border-radius: 10px 18px 12px 8px;
  background: rgba(255,250,240,.96);
  box-shadow: var(--shadow);
  transform: rotate(-.1deg);
}

.settings-page > h2 {
  margin: 7px 0 8px;
  font: 500 clamp(30px, 8vw, 42px)/1.2 Georgia, "Songti SC", serif;
  letter-spacing: .05em;
}

.settings-lead {
  max-width: 560px;
  margin: 0 0 25px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.85;
}

.settings-card {
  margin-top: 16px;
  padding: 19px 17px;
  border: 1px solid rgba(104,77,62,.13);
  border-radius: 16px 13px 18px 12px;
  background: rgba(255,255,255,.44);
  box-shadow: 0 7px 18px rgba(86,62,48,.055);
}

.settings-card-heading { display: flex; align-items: center; gap: 13px; }
.settings-card-heading h3 { margin: 0 0 3px; font: 500 20px/1.25 Georgia, "Songti SC", serif; }
.settings-card-heading p { margin: 0; color: var(--muted); font-size: 12px; }
.settings-mark {
  display: grid;
  flex: 0 0 43px;
  height: 38px;
  place-items: center;
  background: #e8cdbf;
  color: var(--terracotta-dark);
  font: 700 11px/1 ui-monospace, monospace;
  transform: rotate(-3deg);
}

.settings-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 18px; }
.paper-button {
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid rgba(114,78,59,.2);
  border-radius: 12px 9px 13px 10px;
  background: var(--cream);
  cursor: pointer;
  font-size: 14px;
}
.paper-button--primary { border-color: transparent; background: var(--terracotta); color: #fffaf1; }
.paper-button:active { transform: translateY(1px); }
.settings-tip,
.privacy-copy { margin: 14px 0 0; color: var(--muted); font-size: 13px; line-height: 1.75; }
.guide-list { margin: 17px 0 0; padding-left: 24px; color: var(--ink); font-size: 14px; line-height: 1.85; }
.guide-list li + li { margin-top: 5px; }
.guide-list li::marker { color: var(--terracotta); font-family: Georgia, serif; }
.danger-button {
  display: block;
  margin: 28px auto 2px;
  padding: 9px 4px;
  border: 0;
  border-bottom: 1px dashed currentColor;
  background: transparent;
  color: #a57060;
  cursor: pointer;
  font-size: 12px;
}

.toast {
  position: fixed;
  z-index: 20;
  left: 50%;
  bottom: calc(24px + env(safe-area-inset-bottom));
  max-width: calc(100vw - 36px);
  padding: 11px 18px;
  border-radius: 999px;
  background: rgba(73,57,49,.92);
  color: #fffaf1;
  font-size: 13px;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 16px);
  transition: opacity .22s ease, transform .22s ease;
}
.toast.is-visible { opacity: 1; transform: translate(-50%, 0); }

@keyframes drawerIn { from { opacity: 0; transform: translateY(-16px) scale(.98); } }
@keyframes pageIn { from { opacity: 0; transform: translateY(7px); } }
@keyframes caretBlink { 0%, 48% { opacity: 1; } 49%, 100% { opacity: 0; } }

@media (max-width: 679px) {
  .activation-card { padding: 50px 24px 27px; }
  .activation-help { margin-bottom: 22px; }
  .day-note-input { padding-top: 25px; caret-color: transparent; }
  .day-note-caret.is-visible { display: block; animation: caretBlink 1s steps(1, end) infinite; }
}

@media (min-width: 680px) {
  .app-shell { padding-inline: 32px; }
  .calendar-card { padding: 28px 30px 20px; }
  .day-cell { aspect-ratio: 1; }
  .settings-page { padding: 45px 40px 38px; }
}

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