@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Noto+Serif+SC:wght@500;600;700&display=swap');

:root {
  --ink: #18241f;
  --ink-soft: #526059;
  --paper: #f5f0e7;
  --paper-deep: #e9e1d3;
  --line: rgba(24, 36, 31, .14);
  --coral: #d9644d;
  --coral-deep: #b74735;
  --gold: #c29a56;
  --jade: #7e9c83;
  --white: #fffdf8;
  --shadow: 0 24px 60px rgba(24, 36, 31, .08);
  --sans: -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", "Microsoft YaHei", sans-serif;
  --serif: "Noto Serif SC", "Songti SC", STSong, serif;
  --mono: "DM Mono", "SFMono-Regular", Consolas, monospace;
}

* { box-sizing: border-box; }

html { background: var(--paper); }

body {
  margin: 0;
  min-width: 320px;
  color: var(--ink);
  background:
    radial-gradient(circle at 88% 6%, rgba(194, 154, 86, .12), transparent 24rem),
    radial-gradient(circle at 15% 88%, rgba(126, 156, 131, .10), transparent 24rem),
    var(--paper);
  font-family: var(--sans);
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; }
button { cursor: pointer; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 3px solid rgba(217, 100, 77, .35); outline-offset: 3px; }

.app-shell { display: grid; grid-template-columns: 248px minmax(0, 1fr); min-height: 100vh; }

.sidebar { display: flex; flex-direction: column; position: sticky; top: 0; height: 100vh; padding: 34px 22px 22px; color: #f4eee2; background: var(--ink); }
.brand-lockup { display: flex; align-items: center; gap: 12px; padding: 0 8px; }
.brand-mark { display: grid; place-items: center; width: 38px; height: 38px; color: var(--ink); background: var(--gold); font: 600 21px/1 var(--serif); border-radius: 50% 50% 46% 54%; transform: rotate(-8deg); }
.brand-name { margin: 0; font: 600 20px/1.2 var(--serif); letter-spacing: .08em; }
.brand-caption { margin: 4px 0 0; color: rgba(244, 238, 226, .52); font: 10px/1.2 var(--mono); letter-spacing: .04em; }

.main-nav { display: grid; gap: 7px; margin-top: 72px; }
.nav-item { display: flex; align-items: center; gap: 12px; width: 100%; padding: 12px 11px; border: 0; border-radius: 3px; color: rgba(244, 238, 226, .61); background: transparent; text-align: left; transition: background .2s ease, color .2s ease; }
.nav-item:hover, .nav-item.is-active { color: #fffaf0; background: rgba(255, 255, 255, .10); }
.nav-item.is-active { box-shadow: inset 3px 0 var(--coral); }
.nav-glyph { width: 17px; color: var(--gold); font-size: 18px; text-align: center; }

.sidebar-note { display: grid; gap: 6px; margin: auto 8px 28px; padding: 18px 15px; border-top: 1px solid rgba(244, 238, 226, .21); border-bottom: 1px solid rgba(244, 238, 226, .21); }
.sidebar-note strong { color: #fffaf0; font: 600 22px/1.2 var(--serif); }
.sidebar-note span:last-child { color: rgba(244, 238, 226, .58); font-size: 12px; }
.eyebrow { margin: 0; color: var(--coral-deep); font: 500 10px/1.4 var(--mono); letter-spacing: .12em; text-transform: uppercase; }
.sidebar .eyebrow { color: var(--gold); }

.account-chip { display: flex; align-items: center; gap: 10px; padding: 12px 8px 0; border-top: 1px solid rgba(244, 238, 226, .14); }
.avatar { display: grid; place-items: center; flex: 0 0 auto; width: 30px; height: 30px; color: var(--ink); background: var(--paper); border-radius: 50%; font: 600 13px/1 var(--serif); }
.account-copy { display: grid; gap: 2px; min-width: 0; flex: 1; }
.account-copy strong { color: #fffaf0; font-size: 12px; font-weight: 500; }
.account-copy span { color: rgba(244, 238, 226, .46); font-size: 10px; }
.icon-button { display: inline-grid; place-items: center; width: 34px; height: 34px; padding: 0; color: currentColor; border: 1px solid var(--line); border-radius: 50%; background: transparent; transition: background .2s ease, border-color .2s ease; }
.icon-button:hover { background: rgba(24, 36, 31, .07); border-color: rgba(24, 36, 31, .28); }
.sidebar .icon-button { border-color: rgba(244, 238, 226, .15); color: rgba(244, 238, 226, .55); }

.main-content { min-width: 0; max-width: 1500px; width: 100%; padding: 0 5.2vw 72px; }
.topbar { display: flex; align-items: center; justify-content: space-between; min-height: 92px; border-bottom: 1px solid var(--line); }
.breadcrumb { display: flex; align-items: center; gap: 10px; color: var(--ink-soft); font-size: 12px; }
.breadcrumb strong { color: var(--ink); font-weight: 600; }
.breadcrumb-slash { color: var(--gold); font: 16px/1 var(--serif); }
.topbar-actions { display: flex; align-items: center; gap: 22px; }
.sync-status { display: flex; align-items: center; gap: 6px; color: var(--ink-soft); font: 10px/1 var(--mono); }
.status-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--jade); box-shadow: 0 0 0 4px rgba(126, 156, 131, .16); }

.primary-button, .secondary-button, .danger-button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 42px; padding: 0 18px; border-radius: 2px; font-size: 12px; font-weight: 600; transition: transform .2s ease, background .2s ease, color .2s ease; }
.primary-button { border: 1px solid var(--ink); color: var(--paper); background: var(--ink); }
.primary-button:hover { background: #2d4037; transform: translateY(-1px); }
.primary-button.compact { min-height: 38px; padding-inline: 14px; }
.secondary-button { border: 1px solid var(--line); color: var(--ink); background: transparent; }
.secondary-button:hover { border-color: var(--ink); background: rgba(24, 36, 31, .05); }
.danger-button { margin-top: 22px; border: 1px solid rgba(183, 71, 53, .33); color: var(--coral-deep); background: transparent; }

.view { padding-top: 62px; animation: appear .35s ease both; }
.view[hidden] { display: none; }
@keyframes appear { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.hero-row { display: flex; align-items: flex-end; justify-content: space-between; gap: 48px; max-width: 1080px; }
h1, h2, p { margin-top: 0; }
h1, h2 { font-family: var(--serif); font-weight: 600; }
.hero-row h1 { max-width: 690px; margin: 13px 0 18px; font-size: clamp(36px, 4.6vw, 66px); line-height: 1.15; letter-spacing: -.055em; }
.hero-row h1 em { color: var(--coral-deep); font-style: normal; }
.hero-copy { margin-bottom: 0; color: var(--ink-soft); font-size: 14px; line-height: 1.8; }
.hero-day { display: grid; align-items: center; justify-items: center; flex: 0 0 150px; width: 150px; height: 164px; padding: 17px 10px; border: 1px solid var(--gold); color: var(--ink); background: rgba(255, 253, 248, .54); transform: rotate(2deg); }
.hero-day::before { content: ""; position: absolute; }
.hero-day-label { color: var(--coral-deep); font: 500 10px/1 var(--mono); letter-spacing: .12em; }
.hero-day strong { font: 600 70px/.86 var(--serif); letter-spacing: -.08em; }
.hero-day > span:not(.hero-day-label):not(.hero-lunar) { color: var(--ink-soft); font-size: 10px; }
.hero-lunar { color: var(--gold); font: 10px/1 var(--mono); }

.content-grid { display: grid; grid-template-columns: minmax(0, 1.34fr) minmax(260px, .66fr); gap: 46px; margin-top: 64px; }
.calendar-panel, .inspector-panel { min-width: 0; }
.panel-heading { display: flex; align-items: flex-end; justify-content: space-between; padding-bottom: 17px; border-bottom: 1px solid var(--line); }
.panel-heading h2 { margin: 8px 0 0; font-size: 26px; letter-spacing: -.04em; }
.panel-heading h2 span { color: var(--ink-soft); font: 400 12px/1 var(--mono); letter-spacing: .02em; }
.month-controls { display: flex; gap: 8px; }
.calendar-weekdays, .calendar-grid { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); }
.calendar-weekdays { padding: 16px 0 11px; color: var(--ink-soft); font: 10px/1 var(--mono); text-align: center; }
.calendar-grid { border-top: 1px solid var(--line); border-left: 1px solid var(--line); }
.calendar-cell { position: relative; min-height: 98px; padding: 10px; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); background: rgba(255, 253, 248, .24); }
.calendar-cell.is-muted { color: rgba(82, 96, 89, .4); background: rgba(233, 225, 211, .18); }
.calendar-cell.is-today { background: var(--ink); color: #fffaf0; }
.calendar-cell.is-today .lunar-label { color: rgba(255, 250, 240, .62); }
.date-number { display: block; font: 500 17px/1 var(--serif); }
.lunar-label { display: block; margin-top: 7px; color: var(--ink-soft); font: 9px/1 var(--mono); }
.day-events { display: grid; gap: 3px; margin-top: 12px; }
.day-event { display: block; overflow: hidden; color: var(--coral-deep); font-size: 10px; font-weight: 600; text-overflow: ellipsis; white-space: nowrap; }
.is-today .day-event { color: #f3c1a6; }
.day-event.holiday { color: var(--jade); }
.day-event.workday { color: var(--gold); }
.calendar-legend { display: flex; flex-wrap: wrap; gap: 18px; padding-top: 15px; color: var(--ink-soft); font-size: 10px; }
.calendar-legend span { display: inline-flex; align-items: center; gap: 6px; }
.legend-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--coral); }
.legend-dot.holiday { background: var(--jade); }
.legend-dot.workday { background: var(--gold); }

.inspector-panel { padding-left: 2px; }
.inspector-heading { align-items: center; }
.event-count { color: var(--ink-soft); font: 10px/1 var(--mono); }
.upcoming-list { display: grid; gap: 0; }
.upcoming-item { display: grid; grid-template-columns: 50px 1fr; gap: 14px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.upcoming-date { display: grid; align-content: start; justify-items: center; gap: 4px; padding-top: 3px; color: var(--coral-deep); }
.upcoming-date strong { font: 600 26px/.9 var(--serif); }
.upcoming-date span { color: var(--ink-soft); font: 9px/1 var(--mono); }
.upcoming-copy { min-width: 0; }
.upcoming-copy strong { display: block; overflow: hidden; margin-bottom: 6px; font: 600 15px/1.25 var(--serif); text-overflow: ellipsis; white-space: nowrap; }
.upcoming-copy p { margin: 0; color: var(--ink-soft); font-size: 11px; line-height: 1.5; }
.event-tag { display: inline-block; margin-top: 9px; padding: 3px 6px; color: var(--coral-deep); background: rgba(217, 100, 77, .10); font: 9px/1 var(--mono); }
.event-tag.green { color: #577b5f; background: rgba(126, 156, 131, .15); }
.text-button { display: inline-flex; gap: 7px; margin-top: 20px; padding: 0; border: 0; color: var(--ink); background: transparent; font-size: 11px; font-weight: 600; }
.text-button:hover { color: var(--coral-deep); }

.subscription-strip { display: flex; align-items: center; justify-content: space-between; gap: 28px; margin-top: 56px; padding: 23px 24px; color: #f7efe2; background: var(--ink); }
.subscription-copy { display: flex; align-items: center; gap: 15px; }
.subscription-icon { display: grid; place-items: center; width: 35px; height: 35px; color: var(--ink); background: var(--gold); border-radius: 50%; font: 25px/1 var(--serif); transform: rotate(-22deg); }
.subscription-strip .eyebrow { color: var(--gold); }
.subscription-strip h2 { margin: 6px 0 6px; color: #fffaf0; font-size: 18px; }
.subscription-strip p:last-child { margin: 0; color: rgba(247, 239, 226, .62); font-size: 11px; }
.subscription-action { display: flex; align-items: center; gap: 12px; flex: 0 0 auto; }
.subscription-action code { color: rgba(247, 239, 226, .67); font: 10px/1 var(--mono); }
.subscription-action .secondary-button { color: #fffaf0; border-color: rgba(247, 239, 226, .3); }
.subscription-action .secondary-button:hover { background: rgba(247, 239, 226, .1); }

.section-intro { max-width: 620px; }
.section-intro h1 { margin: 13px 0 14px; font-size: clamp(34px, 4vw, 54px); line-height: 1.16; letter-spacing: -.05em; }
.section-intro > p:last-child { color: var(--ink-soft); font-size: 14px; line-height: 1.8; }
.event-list-page { max-width: 760px; margin: 48px 0 28px; }
.event-group { margin-top: 34px; border-top: 1px solid var(--line); }
.event-group:first-child { margin-top: 0; }
.event-group-heading { display: flex; align-items: center; justify-content: space-between; padding: 16px 0 4px; }
.event-group-heading .eyebrow { margin: 0; color: var(--coral-deep); }
.event-group-heading > span { color: var(--ink-soft); font: 10px/1 var(--mono); }
.event-list-row { display: grid; grid-template-columns: 145px minmax(0, 1fr) auto; align-items: center; gap: 20px; padding: 20px 0; border-bottom: 1px solid var(--line); }
.event-list-date { color: var(--coral-deep); font: 11px/1.5 var(--mono); }
.event-list-row strong { display: block; margin-bottom: 5px; font: 600 17px/1.2 var(--serif); }
.event-list-row small { color: var(--ink-soft); font-size: 11px; }
.delete-event { border: 0; color: var(--ink-soft); background: transparent; font-size: 12px; }
.delete-event:hover { color: var(--coral-deep); }
.settings-layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 70px; max-width: 840px; margin-top: 60px; }
.settings-group { border-top: 1px solid var(--line); }
.settings-group > .eyebrow { padding-top: 16px; margin-bottom: 10px; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 20px; padding: 18px 0; border-bottom: 1px solid var(--line); }
.setting-row span { display: grid; gap: 5px; }
.setting-row strong { font-size: 13px; font-weight: 600; }
.setting-row small { color: var(--ink-soft); font-size: 11px; }
.setting-row input { position: relative; width: 36px; height: 20px; appearance: none; border-radius: 20px; background: var(--paper-deep); transition: background .2s ease; }
.setting-row input::after { content: ""; position: absolute; top: 3px; left: 3px; width: 14px; height: 14px; border-radius: 50%; background: var(--white); box-shadow: 0 1px 2px rgba(24, 36, 31, .15); transition: transform .2s ease; }
.setting-row input:checked { background: var(--jade); }
.setting-row input:checked::after { transform: translateX(16px); }

.modal-backdrop { position: fixed; z-index: 10; inset: 0; display: grid; place-items: center; padding: 20px; background: rgba(24, 36, 31, .58); }
.modal-backdrop[hidden] { display: none; }
.modal { position: relative; width: min(100%, 480px); max-height: calc(100vh - 40px); overflow: auto; padding: 34px; color: var(--ink); background: var(--paper); box-shadow: var(--shadow); animation: modal-in .25s ease both; }
@keyframes modal-in { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
.modal-close { position: absolute; top: 18px; right: 18px; }
.modal h2 { margin: 12px 0 8px; font-size: 32px; letter-spacing: -.05em; }
.modal-intro { margin-bottom: 28px; color: var(--ink-soft); font-size: 12px; }
.field-label { display: block; margin: 17px 0 8px; color: var(--ink-soft); font-size: 11px; font-weight: 600; }
.field-label span { color: rgba(82, 96, 89, .6); font-weight: 400; }
.field-label-row { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; }
.field-label-row .field-label { margin: 0; }
.text-input { width: 100%; min-height: 43px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 2px; color: var(--ink); outline: 0; background: rgba(255, 253, 248, .5); font-size: 13px; }
.text-input::placeholder { color: rgba(82, 96, 89, .46); }
.text-input:focus { border-color: var(--ink); }
.textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.segmented-control { display: flex; padding: 3px; border: 1px solid var(--line); background: rgba(255, 253, 248, .5); }
.segment { min-width: 58px; padding: 6px 10px; border: 0; color: var(--ink-soft); background: transparent; font-size: 11px; }
.segment.is-active { color: var(--paper); background: var(--ink); }
.modal-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 28px; padding-top: 19px; border-top: 1px solid var(--line); }

.toast { position: fixed; z-index: 20; right: 24px; bottom: 24px; max-width: min(360px, calc(100vw - 48px)); padding: 12px 15px; color: #fffaf0; background: var(--ink); box-shadow: var(--shadow); font-size: 12px; opacity: 0; pointer-events: none; transform: translateY(8px); transition: opacity .2s ease, transform .2s ease; }
.toast.is-visible { opacity: 1; transform: translateY(0); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 205px minmax(0, 1fr); }
  .main-content { padding-inline: 32px; }
  .content-grid { gap: 28px; }
  .subscription-strip { align-items: flex-start; flex-direction: column; }
  .subscription-action { width: 100%; }
  .subscription-action code { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

@media (max-width: 720px) {
  .app-shell { display: block; }
  .sidebar { position: static; height: auto; padding: 18px 18px 14px; }
  .brand-lockup { padding: 0; }
  .main-nav { grid-template-columns: repeat(3, 1fr); gap: 4px; margin-top: 22px; }
  .nav-item { justify-content: center; gap: 6px; padding: 9px 4px; font-size: 11px; }
  .nav-glyph { width: auto; font-size: 15px; }
  .sidebar-note { display: none; }
  .account-chip { position: absolute; top: 17px; right: 14px; padding: 0; border: 0; }
  .account-copy, .account-chip .icon-button { display: none; }
  .main-content { padding: 0 18px 48px; }
  .topbar { min-height: 65px; }
  .topbar-actions { gap: 0; }
  .sync-status { display: none; }
  .view { padding-top: 40px; }
  .hero-row { align-items: flex-start; flex-direction: column; gap: 28px; }
  .hero-row h1 { margin-top: 10px; font-size: clamp(38px, 11vw, 55px); }
  .desktop-break { display: none; }
  .hero-day { align-self: flex-end; width: 130px; height: 143px; flex-basis: 143px; }
  .hero-day strong { font-size: 61px; }
  .content-grid { display: block; margin-top: 48px; }
  .calendar-cell { min-height: 72px; padding: 7px 5px; }
  .date-number { font-size: 14px; }
  .lunar-label { margin-top: 5px; font-size: 8px; }
  .day-events { margin-top: 8px; }
  .day-event { font-size: 8px; }
  .inspector-panel { margin-top: 46px; }
  .subscription-strip { margin-top: 44px; padding: 20px 18px; }
  .subscription-copy { align-items: flex-start; }
  .subscription-copy h2 { font-size: 16px; }
  .subscription-action { align-items: stretch; flex-direction: column; }
  .subscription-action code { width: 100%; padding-bottom: 4px; }
  .subscription-action .secondary-button { width: 100%; }
  .settings-layout { display: block; margin-top: 42px; }
  .settings-group + .settings-group { margin-top: 45px; }
  .event-list-row { grid-template-columns: 90px minmax(0, 1fr) auto; gap: 10px; }
  .event-list-date { font-size: 9px; }
  .event-list-row strong { font-size: 15px; }
  .modal { padding: 28px 20px 22px; }
}

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