/* ============================================================
   app.css — 黄历 Web App
   ============================================================ */

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

/* ============================================================
   DESIGN TOKENS
   ============================================================ */
:root {
  --red:        #C0392B;
  --red-dark:   #96281B;
  --red-light:  #F5B7B1;
  --gold:       #D4AC0D;
  --gold-light: #F9E79F;
  --ink:        #1A1A1A;
  --ink-soft:   #3D3D3D;
  --paper:      #FDF6E3;
  --paper-dark: #F5E6C8;
  --paper-mid:  #EDD9A3;
  --border:     #C4A35A;
  --green:      #1E8449;

  --font:       'Noto Serif SC', 'Songti SC', 'SimSun', serif;
  --card-w:     900px;
  --radius-lg:  14px;
}

/* ============================================================
   RESET & BASE
   ============================================================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; }

body {
  font-family: var(--font);
  color: var(--ink);
  min-height: 100%;
  /* Warm earthy background — frames the card on wide screens */
  background: linear-gradient(160deg, #B8935A 0%, #7A5020 100%);
  background-attachment: fixed;
  padding: 32px 16px 56px;
}

/* ============================================================
   APP CARD  — centered max-width container
   ============================================================ */
.app-card {
  max-width: var(--card-w);
  margin: 0 auto;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow:
    0 0 0 1px rgba(212,172,13,0.45),
    0 20px 60px rgba(50,15,0,0.38),
    0 4px 14px  rgba(50,15,0,0.22);
}

/* ============================================================
   HEADER  (sits at the top of the card)
   ============================================================ */
.topbar {
  background: var(--red);
  border-bottom: 3px solid var(--gold);
  display: flex;
  align-items: center;
  padding: 0 22px;
  height: 56px;
  gap: 12px;
}

.topbar-brand {
  margin-right: auto;
  display: flex;
  align-items: baseline;
  gap: 1px;
}
.brand-hl {
  font-size: 26px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: -1px;
  line-height: 1;
  text-shadow: 0 1px 4px rgba(0,0,0,0.3);
}
.brand-li {
  font-size: 18px;
  font-weight: 600;
  color: rgba(255,255,255,0.92);
  letter-spacing: 3px;
}

.topbar-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}

.today-btn {
  background: rgba(255,255,255,0.14);
  border: 1px solid rgba(255,255,255,0.32);
  color: #fff;
  padding: 5px 16px;
  border-radius: 20px;
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  letter-spacing: 0.5px;
  transition: background 0.2s, border-color 0.2s;
  white-space: nowrap;
}
.today-btn:hover  { background: rgba(255,255,255,0.26); border-color: rgba(255,255,255,0.5); }
.today-btn:active { background: rgba(255,255,255,0.18); }

/* ============================================================
   VIEW TOGGLE  (农历 ⟷ 西历)
   ============================================================ */
.view-toggle {
  display: flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  user-select: none;
}
.tgl-label {
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.45);
  letter-spacing: 0.5px;
  transition: color 0.2s;
  white-space: nowrap;
}
.tgl-label.active { color: #fff; }
.tgl-track {
  position: relative;
  width: 36px; height: 20px;
  background: rgba(255,255,255,0.18);
  border-radius: 10px;
  flex-shrink: 0;
  transition: background 0.2s;
}
.tgl-track.active { background: rgba(255,255,255,0.40); }
.tgl-thumb {
  position: absolute;
  top: 2px; left: 2px;
  width: 16px; height: 16px;
  background: #fff;
  border-radius: 50%;
  box-shadow: 0 1px 4px rgba(0,0,0,0.3);
  transition: transform 0.2s cubic-bezier(.4,0,.2,1);
}
.tgl-track.active .tgl-thumb { transform: translateX(16px); }

/* ============================================================
   LAYOUT  — single column: calendar on top, detail below
   ============================================================ */
.layout {
  display: flex;
  flex-direction: column;
  background: var(--paper);
}

/* ============================================================
   CALENDAR PANEL  (top)
   ============================================================ */
.cal-panel {
  padding: 18px 20px 16px;
  border-bottom: 2px solid var(--border);
  background: var(--paper);
}

.cal-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.cal-nav-center { flex: 1; text-align: center; }
.cal-month-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 2px;
}
.cal-month-sub {
  font-size: 13px;
  color: #888;
  margin-top: 3px;
}
.cal-nav-btn {
  flex-shrink: 0;
  width: 36px; height: 36px;
  background: var(--paper-dark);
  border: 1px solid var(--border);
  border-radius: 50%;
  font-size: 22px;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font);
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}
.cal-nav-btn:hover { background: var(--red); color: #fff; border-color: var(--red); }

.cal-jump {
  display: flex;
  gap: 8px;
  margin-bottom: 14px;
}
.cal-jump select {
  flex: 1;
  font-family: var(--font);
  font-size: 13px;
  padding: 5px 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--paper);
  color: var(--ink);
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}
.cal-jump select:focus,
.cal-jump select:hover { border-color: var(--red); }

/* ============================================================
   CALENDAR GRIDS
   ============================================================ */

/* Western (7-column) */
.cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

/* Lunar (xun rows) */
.cal-grid-lunar {
  display: flex !important;
  flex-direction: column;
  gap: 5px;
}

/* Weekday headers */
.cal-weekday {
  text-align: center;
  font-size: 12px;
  color: #999;
  padding: 4px 0 8px;
  font-weight: 700;
  letter-spacing: 0.3px;
}
.cal-weekday:first-child,
.cal-weekday:last-child { color: var(--red); }

/* Day cell */
.cal-day {
  background: #fff;
  border: 1px solid var(--paper-mid);
  border-radius: 6px;
  padding: 7px 4px 5px;
  min-height: 72px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s, box-shadow 0.15s;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
}
.cal-day:hover    { border-color: var(--red); background: var(--red-light); }
.cal-day:active   { background: #f0a09a; }
.cal-day.today    { background: var(--red); border-color: var(--red); }
.cal-day.selected { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold); }
.cal-day.other-month { opacity: 0.28; cursor: default; pointer-events: none; }

/* Western cell text */
.day-solar    { font-size: 19px; font-weight: 700; text-align: center; line-height: 1; margin-bottom: 3px; }
.day-lunar    { font-size: 12px; text-align: center; color: #777; }
.day-term     { font-size: 11px; text-align: center; color: var(--green); font-weight: 700; margin-top: 2px; }
.day-festival { font-size: 11px; text-align: center; color: var(--red);   font-weight: 700; margin-top: 2px; }

.cal-day.today .day-solar,
.cal-day.today .day-lunar    { color: #fff; }
.cal-day.today .day-term,
.cal-day.today .day-festival { color: var(--gold-light); }

/* Lunar xun layout */
.xun-row {
  display: grid;
  grid-template-columns: 26px repeat(10, 1fr);
  gap: 4px;
}
.xun-label {
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 700; color: var(--red);
  writing-mode: vertical-rl; letter-spacing: 2px;
}
.xun-day   { min-width: 0; }
.xun-blank { visibility: hidden; pointer-events: none; }

/* Quadrant wrappers for lunar cell layout */
.cell-q { display: block; }
.cell-q:empty { display: none; }

/* Lunar cell text */
.day-lunar-main { font-size: 15px; font-weight: 700; text-align: center; line-height: 1; margin-bottom: 3px; }
.day-solar-sub  { font-size: 11px; text-align: center; color: #777; }
.day-weekday    { color: #999; }
.day-weekday.weekend { color: var(--red); }

.cal-day.today .day-lunar-main,
.cal-day.today .day-solar-sub      { color: #fff; }
.cal-day.today .day-weekday        { color: rgba(255,255,255,0.7); }
.cal-day.today .day-weekday.weekend { color: var(--gold-light); }

/* ============================================================
   DETAIL PANEL  (below calendar)
   ============================================================ */
.detail-panel { background: var(--paper); }
#day-detail   { width: 100%; }

.cal-links {
  padding: 10px 16px;
  display: flex;
  gap: 8px;
  align-items: center;
  flex-wrap: wrap;
  border-top: 1px solid var(--paper-mid);
  background: var(--paper-dark);
}
.cal-links:empty { display: none; }
.cal-links-label { font-size: 12px; color: #888; margin-right: 2px; }
.cal-link-btn {
  display: inline-flex; align-items: center;
  padding: 5px 13px;
  border-radius: 4px;
  font-family: var(--font); font-size: 12px; font-weight: 600;
  text-decoration: none;
  border: 1px solid var(--border);
  color: var(--ink); background: var(--paper);
  transition: background 0.15s, border-color 0.15s;
}
.cal-link-btn:hover { background: var(--paper-dark); border-color: var(--red); }

/* ============================================================
   SHARED DAY DETAIL COMPONENTS  (rendered by calendar.js)
   ============================================================ */

.date-bar {
  display: flex;
  background: var(--red);
  border-bottom: 2px solid var(--gold);
}
.date-lunar {
  flex: 1;
  padding: 14px 16px;
  display: flex; flex-direction: column; justify-content: center;
}
.date-lunar-title { font-size: 21px; font-weight: 700; color: #fff; letter-spacing: 1.5px; }
.date-lunar-gz    { font-size: 12px; color: #FFE88A; margin-top: 4px; line-height: 1.5; }
.date-solar {
  display: flex; align-items: center; gap: 7px;
  padding: 14px 16px;
  background: rgba(0,0,0,0.12);
  min-width: 140px;
}
.date-solar-num  { font-size: 54px; font-weight: 700; color: #fff; line-height: 1; }
.date-solar-info { display: flex; flex-direction: column; }
.date-solar-ym   { font-size: 14px; color: rgba(255,255,255,0.92); font-weight: 600; }
.date-solar-wd   { font-size: 13px; color: rgba(255,255,255,0.82); margin-top: 3px; }

.tags-row { background: var(--red); padding: 2px 16px 8px; }
.tags-row:empty { padding: 0; }
.festival-tag {
  display: inline-block;
  background: var(--gold); color: #1A1A1A;
  font-size: 12px; font-weight: 700;
  padding: 2px 9px; border-radius: 10px;
  margin-right: 5px; letter-spacing: 0.5px; line-height: 1.8;
}
.term-tag {
  display: inline-block;
  background: rgba(255,255,255,0.18); color: #fff;
  font-size: 12px; padding: 2px 9px; border-radius: 10px;
  letter-spacing: 0.5px; line-height: 1.8;
}

.yiji-row { display: grid; grid-template-columns: 1fr 1fr; border-bottom: 1px solid var(--paper-mid); }
.yiji-cell { padding: 10px 16px; }
.yiji-cell:first-child { border-right: 1px solid var(--paper-mid); }
.yiji-label { display: flex; align-items: center; gap: 6px; font-size: 14px; font-weight: 700; margin-bottom: 5px; }
.yiji-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.yi-dot    { background: var(--green); }
.ji-dot    { background: var(--red); }
.yi-label  { color: var(--green); }
.ji-label  { color: var(--red); }
.yiji-items { font-size: 13px; color: var(--ink-soft); line-height: 1.9; }

.info-row { display: flex; border-bottom: 1px solid var(--paper-mid); }
.info-col {
  flex: 1; padding: 7px 4px; text-align: center;
  border-right: 1px solid var(--paper-mid); min-width: 0;
}
.info-col:last-child { border-right: none; }
.info-label { font-size: 11px; color: #888; letter-spacing: 0.3px; }
.info-value { font-size: 13px; font-weight: 600; color: var(--ink); word-break: keep-all; overflow-wrap: break-word; }
.info-sub   { font-size: 11px; white-space: nowrap; }
.luck-ji    { color: var(--red)   !important; }
.luck-good  { color: var(--green) !important; }

.hours-header { font-size: 12px; color: #888; font-weight: 700; padding: 7px 16px 3px; letter-spacing: 0.5px; }
.hours-grid {
  display: grid; grid-template-columns: repeat(13, 1fr);
  border-bottom: 1px solid var(--paper-mid);
}
.hour-cell {
  padding: 5px 1px; text-align: center;
  border-right: 1px solid var(--paper-mid);
}
.hour-cell:nth-child(13n) { border-right: none; }
.hour-cell.current { background: var(--red); }
.hour-cell.current .hour-gz,
.hour-cell.current .hour-luck { color: #fff !important; }
.hour-gz   { font-size: 12px; font-weight: 700; color: var(--ink); }
.hour-luck { font-size: 11px; font-weight: 600; }
.hour-good { color: var(--green); }
.hour-bad  { color: var(--red); }

.gods-section { display: flex; border-bottom: 1px solid var(--paper-mid); }
.gods-half { flex: 1; padding: 6px 12px; line-height: 1.7; }
.gods-half:first-child { border-right: 1px solid var(--paper-mid); }
.gods-label { font-size: 12px; color: #666; font-weight: 700; margin-bottom: 2px; }
.gods-items { font-size: 12px; }
.gods-items .g { margin-right: 4px; white-space: nowrap; }
.god-good  { color: var(--green); }
.god-ji    { color: var(--red); }

.pengzu {
  padding: 7px 16px 10px;
  font-size: 12px; color: var(--ink-soft); line-height: 2;
  background: var(--paper-dark);
  border-bottom: 1px solid var(--paper-mid);
}
.pengzu-title { font-size: 12px; font-weight: 700; color: #666; letter-spacing: 0.5px; margin-bottom: 2px; }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes detailIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.detail-anim { animation: detailIn 0.22s ease-out; }

@keyframes gridIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}
.grid-anim { animation: gridIn 0.18s ease-out; }

/* ============================================================
   PWA INSTALL BANNER
   ============================================================ */
.install-banner {
  position: fixed;
  bottom: max(16px, env(safe-area-inset-bottom, 16px));
  left: 50%;
  transform: translateX(-50%);
  background: var(--ink);
  color: #fff;
  padding: 11px 18px;
  border-radius: 12px;
  display: flex; align-items: center; gap: 10px;
  font-size: 13px; font-family: var(--font);
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  z-index: 500;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
}
.install-banner[hidden] { display: none; }
.install-yes {
  background: var(--red); border: none; color: #fff;
  padding: 6px 14px; border-radius: 7px;
  font-family: var(--font); font-size: 13px; cursor: pointer; flex-shrink: 0;
  transition: background 0.15s;
}
.install-yes:hover { background: var(--red-dark); }
.install-no {
  background: none; border: none; color: rgba(255,255,255,0.5);
  font-size: 16px; cursor: pointer; flex-shrink: 0; padding: 2px 4px;
  transition: color 0.15s;
}
.install-no:hover { color: #fff; }

/* ============================================================
   RESPONSIVE — mobile (≤ 599px)
   Full-width, no card frame, sticky header
   ============================================================ */
@media (max-width: 599px) {
  body {
    background: var(--paper);
    padding: 0;
  }
  .app-card {
    border-radius: 0;
    box-shadow: none;
    max-width: 100%;
  }
  .topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: 52px;
    padding: 0 14px;
  }
  .brand-hl { font-size: 22px; }
  .brand-li { font-size: 15px; letter-spacing: 2px; }
  .today-btn { padding: 4px 12px; font-size: 12px; }
  .tgl-label { font-size: 11px; }

  .cal-panel { padding: 12px 10px 10px; }
  .cal-month-title { font-size: 17px; }
  .cal-nav-btn { width: 32px; height: 32px; font-size: 19px; }

  /* Compact cells on small screens */
  .cal-day { min-height: 52px; padding: 5px 2px; }
  .day-solar { font-size: 15px; }
  .day-lunar, .day-term, .day-festival { font-size: 10px; }

  .xun-row { grid-template-columns: 18px repeat(10, 1fr); gap: 2px; }
  .xun-label { font-size: 9px; }
  .day-lunar-main { font-size: 12px; }
  .day-solar-sub  { font-size: 9px; }

  /* ── Lunar view: 4-quadrant vertical layout on mobile ── */
  /* Notice: writing-mode:vertical-rl swaps CSS Grid row/col meanings.
     In vertical-rl: row-axis = horizontal (right→left), col-axis = vertical (top→bottom).
     So grid-area: row/col maps as:
       1/1=right-top(右上), 1/2=right-bottom(右下), 2/1=left-top(左上), 2/2=left-bottom(左下) */
  .cal-grid-lunar .xun-day {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
    writing-mode: vertical-rl;
    text-orientation: mixed;
    height: auto;
    min-height: 75px;
    padding: 4px 2px;
    gap: 1px;
    overflow: hidden;
  }
  .cal-grid-lunar .cell-q {
    display: flex;
  }
  .cal-grid-lunar .cell-q:empty {
    display: flex;
  }
  /* quadrant positions — spread to four corners */
  .cal-grid-lunar .cell-q-festival { grid-area: 2 / 1; justify-content: flex-start; align-items: flex-end; }
  .cal-grid-lunar .cell-q-lunar    { grid-area: 1 / 1; justify-content: flex-start; align-items: flex-start; }
  .cal-grid-lunar .cell-q-term     { grid-area: 2 / 2; justify-content: flex-end;   align-items: flex-end; }
  .cal-grid-lunar .cell-q-solar    { grid-area: 1 / 2; justify-content: flex-end;   align-items: flex-start; }
  .cal-grid-lunar .day-lunar-main {
    font-size: 13px;
    font-weight: 700;
    margin: 0;
    line-height: 1.1;
  }
  .cal-grid-lunar .day-solar-sub {
    font-size: 9px;
  }
  .cal-grid-lunar .day-festival {
    font-size: 9px;
    color: var(--red);
  }
  .cal-grid-lunar .day-term {
    font-size: 9px;
    color: var(--green);
  }
  .cal-grid-lunar .day-num {
    -webkit-text-combine-upright: all;
    text-combine-upright: all;
  }

  .date-solar-num { font-size: 44px; }
  .date-lunar-title { font-size: 18px; }
  .yiji-cell { padding: 8px 12px; }
  .yiji-items { font-size: 12px; }
}

/* Safe area for notched phones in standalone PWA mode */
@supports (padding-top: env(safe-area-inset-top)) {
  @media (display-mode: standalone) and (max-width: 599px) {
    .topbar {
      padding-top: env(safe-area-inset-top);
      height: calc(52px + env(safe-area-inset-top));
    }
  }
}

/* ============================================================
   PRINT
   ============================================================ */
@media print {
  body { background: #fff; padding: 0; }
  .app-card { box-shadow: none; border-radius: 0; }
  .topbar, .cal-panel, .install-banner { display: none !important; }
}

/* ============================================================
   APPEND THIS BLOCK TO THE END OF app.css
   ============================================================ */

/* ============================================================
   DESCRIPTION CARDS  (solar term & festival in day detail)
   ============================================================ */
.desc-cards {
  border-bottom: 1px solid var(--paper-mid);
}

.desc-card {
  padding: 11px 16px 12px;
  border-left: 3px solid var(--green);
  background: linear-gradient(90deg, rgba(30, 132, 73, 0.07) 0%, transparent 55%);
  position: relative;
}
.desc-card + .desc-card {
  border-top: 1px solid var(--paper-mid);
}
.desc-card.desc-festival {
  border-left-color: var(--red);
  background: linear-gradient(90deg, rgba(192, 57, 43, 0.07) 0%, transparent 55%);
}

.desc-card-header {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 5px;
}
.desc-card-icon {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}
.desc-card-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.5px;
  flex: 1;
}
.desc-card-badge {
  font-size: 10px;
  padding: 1px 7px;
  border-radius: 8px;
  font-weight: 600;
  letter-spacing: 0.3px;
  flex-shrink: 0;
}
.desc-card-badge.badge-term     { background: rgba(30,132,73,0.13); color: var(--green); }
.desc-card-badge.badge-festival { background: rgba(192,57,43,0.12); color: var(--red); }

.desc-card-text {
  font-size: 12px;
  color: var(--ink-soft);
  line-height: 1.9;
  margin: 0 0 7px;
}

.desc-customs {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}
.desc-custom-tag {
  font-size: 11px;
  padding: 2px 9px;
  border-radius: 10px;
  background: rgba(0, 0, 0, 0.055);
  color: var(--ink-soft);
  border: 1px solid rgba(0, 0, 0, 0.07);
  white-space: nowrap;
}

/* No description available — subtle placeholder */
.desc-card-empty {
  font-size: 12px;
  color: #bbb;
  font-style: italic;
}

/* ============================================================
   ABOUT FOOTER  (bottom of app card, always visible)
   ============================================================ */
.about-footer {
  padding: 20px 24px 22px;
  background: linear-gradient(180deg, var(--paper-dark) 0%, #EDD08A 100%);
  border-top: 2px solid var(--border);
  text-align: center;
}

.about-footer-inner {
  max-width: 580px;
  margin: 0 auto;
}

.about-footer-wordmark {
  display: flex;
  align-items: baseline;
  justify-content: center;
  gap: 4px;
  margin-bottom: 8px;
}
.about-wm-hl {
  font-size: 22px;
  font-weight: 700;
  color: var(--red);
  letter-spacing: -1px;
}
.about-wm-li {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-soft);
  letter-spacing: 3px;
}
.about-wm-sep {
  font-size: 13px;
  color: var(--border);
  margin: 0 6px;
}
.about-wm-tagline {
  font-size: 13px;
  color: var(--ink-soft);
  letter-spacing: 0.5px;
}

.about-footer-desc {
  font-size: 12px;
  color: #6E5A38;
  line-height: 2;
  margin: 0 0 12px;
}

.about-features {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 5px;
  list-style: none;
  padding: 0;
  margin: 0;
}
.about-features li {
  font-size: 11px;
  padding: 3px 11px;
  border: 1px solid var(--border);
  border-radius: 12px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.5);
  letter-spacing: 0.3px;
}

@media (max-width: 599px) {
  .about-footer { padding: 16px 16px 18px; }
  .about-wm-hl  { font-size: 19px; }
  .about-wm-li  { font-size: 13px; }
  .about-footer-desc { font-size: 11px; }
  .desc-card { padding: 9px 12px 10px; }
  .desc-card-text { font-size: 11px; }
}

/* ============================================================
   APP BODY — flex row: sidebar + main layout
   ============================================================ */
.app-body {
  display: flex;
  align-items: stretch;
  background: var(--paper);
  position: relative;
}

/* ============================================================
   KNOWLEDGE NAV SIDEBAR (desktop only)
   ============================================================ */
.knowledge-nav {
  width: 172px;
  flex-shrink: 0;
  background: var(--paper-dark);
  border-right: 1px solid var(--border);
  padding: 18px 0 32px;
  position: sticky;
  top: 56px; /* height of topbar */
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--paper-mid) transparent;
}
.knowledge-nav::-webkit-scrollbar { width: 4px; }
.knowledge-nav::-webkit-scrollbar-track { background: transparent; }
.knowledge-nav::-webkit-scrollbar-thumb { background: var(--paper-mid); border-radius: 2px; }

.kn-header {
  font-size: 10px;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 4px;
  padding: 0 14px 14px;
  text-transform: uppercase;
  border-bottom: 1px solid var(--border);
  margin-bottom: 10px;
}

.kn-group-title {
  font-size: 10px;
  font-weight: 700;
  color: #aaa;
  letter-spacing: 1px;
  padding: 10px 14px 4px;
  text-transform: uppercase;
}

.kn-link {
  display: block;
  font-size: 12px;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 5px 14px 5px 20px;
  line-height: 1.4;
  border-left: 2px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  position: relative;
}
.kn-link:hover {
  color: var(--red);
  background: rgba(192, 57, 43, 0.07);
  border-left-color: var(--red);
}
.kn-link::before {
  content: '›';
  position: absolute;
  left: 10px;
  color: var(--border);
  font-size: 11px;
  transition: color 0.15s;
}
.kn-link:hover::before { color: var(--red); }

.kn-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 14px;
  opacity: 0.6;
}

/* The layout takes remaining space */
.app-body > .layout {
  flex: 1;
  min-width: 0;
}

/* ============================================================
   CLICKABLE TAG LINKS  (festival / term tags as anchors)
   ============================================================ */
a.festival-tag,
a.term-tag {
  text-decoration: none;
  cursor: pointer;
  transition: opacity 0.15s, box-shadow 0.15s;
}
a.festival-tag:hover {
  opacity: 0.82;
  box-shadow: 0 1px 6px rgba(192,57,43,0.25);
}
a.term-tag:hover {
  opacity: 0.82;
  box-shadow: 0 1px 6px rgba(0,0,0,0.15);
}

/* ============================================================
   MOBILE KNOWLEDGE SECTION  (in footer, hidden on desktop)
   ============================================================ */
.mobile-knowledge {
  display: none;
  margin-bottom: 20px;
}

.mobile-kn-title {
  font-size: 11px;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 3px;
  text-align: center;
  margin-bottom: 12px;
  text-transform: uppercase;
}

.mobile-kn-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: center;
}

.mobile-kn-grid a {
  display: inline-block;
  font-family: var(--font);
  font-size: 12px;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.6);
  transition: background 0.15s, border-color 0.15s, color 0.15s;
}
.mobile-kn-grid a:hover {
  border-color: var(--red);
  color: var(--red);
  background: rgba(192,57,43,0.06);
}

/* ============================================================
   RESPONSIVE — sidebar hidden on narrow screens
   ============================================================ */
@media (max-width: 900px) {
  .knowledge-nav { display: none; }
  .mobile-knowledge { display: block; }
  .about-footer-wordmark { border-top: 1px solid var(--border); padding-top: 16px; }
}

/* ============================================================
   ADJUST topbar sticky offset for standalone PWA on desktop
   ============================================================ */
@supports (padding-top: env(safe-area-inset-top)) {
  @media (display-mode: standalone) and (min-width: 600px) {
    .knowledge-nav { top: calc(56px + env(safe-area-inset-top)); }
  }
}

/* ============================================================
   INFO PAGE — knowledge base (info.html)
   ============================================================ */
.info-body {
  background: var(--paper);
  padding: 0;
  min-height: 100vh;
}

/* Info topbar */
.info-topbar {
  background: var(--red);
  border-bottom: 3px solid var(--gold);
  height: 56px;
  display: flex;
  align-items: center;
  padding: 0 24px;
  position: sticky;
  top: 0;
  z-index: 200;
  gap: 16px;
  max-width: 1100px;
  margin: 0 auto;
}

.info-back-link {
  color: rgba(255,255,255,0.82);
  text-decoration: none;
  font-family: var(--font);
  font-size: 13px;
  padding: 5px 14px;
  border: 1px solid rgba(255,255,255,0.3);
  border-radius: 18px;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  white-space: nowrap;
}
.info-back-link:hover {
  background: rgba(255,255,255,0.15);
  color: #fff;
}

.info-topbar-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 4px;
  flex: 1;
}

.info-topbar-home {
  color: rgba(255,255,255,0.7);
  text-decoration: none;
  font-family: var(--font);
  font-size: 12px;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}
.info-topbar-home:hover { color: #fff; }

/* Info layout: sidenav + main */
.info-layout {
  display: flex;
  max-width: 1100px;
  margin: 0 auto;
  min-height: calc(100vh - 56px);
}

/* Info side navigation */
.info-sidenav {
  width: 200px;
  flex-shrink: 0;
  padding: 24px 0 40px;
  position: sticky;
  top: 56px;
  height: calc(100vh - 56px);
  overflow-y: auto;
  border-right: 1px solid var(--border);
  background: var(--paper-dark);
  scrollbar-width: thin;
  scrollbar-color: var(--paper-mid) transparent;
}
.info-sidenav::-webkit-scrollbar { width: 4px; }
.info-sidenav::-webkit-scrollbar-thumb { background: var(--paper-mid); border-radius: 2px; }

.info-nav-section {
  margin-bottom: 6px;
}

.info-nav-section-title {
  font-size: 10px;
  font-weight: 700;
  color: #aaa;
  letter-spacing: 1.5px;
  padding: 10px 16px 5px;
  text-transform: uppercase;
}

.info-nav-link {
  display: block;
  font-family: var(--font);
  font-size: 12.5px;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 5px 16px 5px 24px;
  line-height: 1.4;
  border-left: 2px solid transparent;
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  position: relative;
}
.info-nav-link::before {
  content: '›';
  position: absolute;
  left: 13px;
  color: var(--border);
  transition: color 0.15s;
}
.info-nav-link:hover,
.info-nav-link.active {
  color: var(--red);
  background: rgba(192,57,43,0.07);
  border-left-color: var(--red);
}
.info-nav-link:hover::before,
.info-nav-link.active::before { color: var(--red); }

.info-nav-divider {
  height: 1px;
  background: var(--border);
  margin: 10px 16px;
  opacity: 0.6;
}

.info-nav-sub {
  font-size: 11.5px;
  padding-left: 32px;
  color: #999;
}
.info-nav-sub:hover { color: var(--red); }

/* Info main content */
.info-main {
  flex: 1;
  min-width: 0;
  padding: 0 0 80px;
}

/* Info section base */
.info-section {
  padding: 48px 40px 40px;
  border-bottom: 1px solid var(--paper-mid);
  scroll-margin-top: 72px;
}
.info-section:last-child { border-bottom: none; }

/* Section heading */
.info-section-title {
  font-size: 26px;
  font-weight: 700;
  color: var(--red);
  letter-spacing: 2px;
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.info-section-subtitle {
  font-size: 13px;
  color: #888;
  margin-bottom: 20px;
  line-height: 1.7;
}

.info-section-intro,
.info-section > .info-section-subtitle + p {
  font-size: 15px;
  color: var(--ink);
  line-height: 2;
  margin-bottom: 28px;
  max-width: 640px;
}

/* Individual item sections (term / festival) */
.info-item-section {
  padding: 36px 40px 32px;
  border-bottom: 1px solid var(--paper-mid);
  scroll-margin-top: 72px;
  /* background: #fff; */
}
/* .info-item-section:nth-child(even) { background: var(--paper); } */

.info-item-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.info-item-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 1px;
  margin: 0;
}

.info-item-badge {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 10px;
  letter-spacing: 0.5px;
}
.badge-term    { background: rgba(30,132,73,0.12); color: var(--green); }
.badge-festival { background: rgba(192,57,43,0.11); color: var(--red); }
.badge-solar   { background: rgba(212,172,13,0.15); color: #8a6d00; }

.info-item-date {
  font-size: 12px;
  color: #999;
  letter-spacing: 0.3px;
}

.info-item-desc {
  font-size: 14px;
  color: var(--ink-soft);
  line-height: 2;
  margin-bottom: 18px;
  max-width: 600px;
}

.info-customs-title {
  font-size: 12px;
  font-weight: 700;
  color: #666;
  letter-spacing: 1px;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.info-customs-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.info-custom-tag {
  font-size: 12px;
  padding: 3px 11px;
  border-radius: 12px;
  background: rgba(0,0,0,0.05);
  border: 1px solid rgba(0,0,0,0.08);
  color: var(--ink-soft);
}

/* Overview grid for term/festival index */
.info-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 10px;
  margin-top: 24px;
}

.info-overview-card {
  display: block;
  text-decoration: none;
  background: #fff;
  border: 1px solid var(--paper-mid);
  border-radius: 8px;
  padding: 14px 16px;
  transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}
.info-overview-card:hover {
  border-color: var(--red);
  box-shadow: 0 2px 12px rgba(192,57,43,0.1);
  background: var(--paper);
}
.info-oc-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  display: block;
  margin-bottom: 4px;
}
.info-oc-sub {
  font-size: 11px;
  color: #999;
  line-height: 1.4;
}
.info-oc-season {
  font-size: 11px;
  color: var(--green);
  font-weight: 600;
  margin-bottom: 2px;
}

/* Topic content block */
.info-topic-block {
  background: #fff;
  border: 1px solid var(--paper-mid);
  border-radius: 10px;
  padding: 24px;
  margin-bottom: 20px;
}

.info-topic-block h3 {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
  margin: 0 0 12px;
  border-left: 3px solid var(--red);
  padding-left: 10px;
}

.info-topic-block p {
  font-size: 13px;
  color: var(--ink-soft);
  line-height: 2;
  margin: 0 0 8px;
}

/* Placeholder content blocks */
.info-placeholder {
  background: var(--paper-dark);
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 24px;
  color: #aaa;
  font-size: 13px;
  line-height: 1.8;
  font-style: italic;
}

/* Info table */
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
  margin-top: 16px;
}
.info-table th {
  background: var(--red);
  color: #fff;
  padding: 8px 12px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  letter-spacing: 0.5px;
}
.info-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--paper-mid);
  color: var(--ink-soft);
  vertical-align: top;
  line-height: 1.6;
}
.info-table tr:nth-child(even) td { background: var(--paper); }
.info-table tr:hover td { background: rgba(192,57,43,0.04); }

/* Info page responsive */
@media (max-width: 800px) {
  .info-sidenav { display: none; }
  .info-section { padding: 28px 20px 24px; }
  .info-item-section { padding: 24px 20px 20px; }
  .info-section-title { font-size: 20px; }
  .info-item-title { font-size: 18px; }
  .info-overview-grid { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}

@media (max-width: 480px) {
  .info-topbar { padding: 0 14px; }
  .info-topbar-title { font-size: 15px; letter-spacing: 2px; }
  .info-section { padding: 20px 14px 18px; }
  .info-item-section { padding: 18px 14px 16px; }
}

/* Mobile nav for info page (replaces hidden sidenav) */
.info-mobile-nav {
  display: none;
  overflow-x: auto;
  background: var(--paper-dark);
  border-bottom: 1px solid var(--border);
  padding: 10px 14px;
  gap: 6px;
  white-space: nowrap;
  scrollbar-width: none;
  position: sticky;
  top: 56px;
  z-index: 100;
  -webkit-overflow-scrolling: touch;
}
.info-mobile-nav::-webkit-scrollbar { display: none; }

.info-mobile-nav a {
  display: inline-block;
  font-family: var(--font);
  font-size: 12px;
  color: var(--ink-soft);
  text-decoration: none;
  padding: 4px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--paper);
  margin-right: 4px;
  transition: border-color 0.15s, color 0.15s;
}
.info-mobile-nav a:hover { border-color: var(--red); color: var(--red); }

@media (max-width: 800px) {
  .info-mobile-nav { display: flex; }
}
