/* Leo site — Apple UI (live) */
:root {
  --bg: #f5f5f7;
  --bg-elevated: rgba(255, 255, 255, 0.72);
  --bg-card: #ffffff;
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #8e8e93;
  --separator: rgba(60, 60, 67, 0.12);
  --fill: rgba(120, 120, 128, 0.12);
  --fill-strong: rgba(120, 120, 128, 0.2);
  --bar-track: rgba(120, 120, 128, 0.18);
  --blue: #0071e3;
  --blue-hover: #0077ed;
  --green: #34c759;
  --orange: #ff9f0a;
  --red: #ff3b30;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.04), 0 8px 24px rgba(0, 0, 0, 0.06);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
  --radius-pill: 999px;
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display",
    "Helvetica Neue", "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  --page-width: 720px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #000000;
    --bg-elevated: rgba(28, 28, 30, 0.72);
    --bg-card: #1c1c1e;
    --text: #f5f5f7;
    --text-secondary: #a1a1a6;
    --text-tertiary: #8e8e93;
    --separator: rgba(84, 84, 88, 0.65);
    /* neutral white fills — avoid cool gray/purple cast on OLED */
    --fill: rgba(255, 255, 255, 0.08);
    --fill-strong: rgba(255, 255, 255, 0.14);
    --bar-track: rgba(255, 255, 255, 0.14);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.35), 0 12px 32px rgba(0, 0, 0, 0.45);
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  font-family: var(--font);
  background:
    radial-gradient(1200px 600px at 50% -12%, rgba(0, 113, 227, 0.08), transparent 60%),
    var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  line-height: 1.5;
}

a { color: var(--blue); text-decoration: none; }
a:visited { color: var(--blue); }
a:hover { text-decoration: underline; }
button, input { font: inherit; }
button { cursor: pointer; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

.page, .wrap {
  width: min(var(--page-width), calc(100% - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 3.5rem;
}

/* Top nav */
.topnav, .topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  margin: 0 0 1.35rem;
  padding: 0.7rem 0.85rem;
  border: 1px solid var(--separator);
  border-radius: 18px;
  background: var(--bg-elevated);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  box-shadow: var(--shadow);
  flex-wrap: nowrap;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: inherit !important;
  text-decoration: none !important;
  min-width: 0;
  flex: 0 1 auto;
  max-width: 42%;
  font-weight: 650;
  letter-spacing: -0.01em;
  overflow: hidden;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  font-size: 1.25rem;
  line-height: 1;
  background: transparent;
  box-shadow: none;
}

.brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
}
.brand-text strong {
  font-size: 0.95rem;
  font-weight: 650;
  letter-spacing: -0.01em;
}
.brand-text span {
  color: var(--text-tertiary);
  font-size: 0.72rem;
  font-weight: 500;
}

.nav, .nav-links {
  display: flex;
  gap: 0.08rem;
  flex-wrap: nowrap;
  justify-content: flex-end;
  align-items: center;
  flex: 0 0 auto;
  min-width: 0;
}
.nav a, .nav-links a,
.nav a:link, .nav-links a:link,
.nav a:visited, .nav-links a:visited,
.nav a:active, .nav-links a:active,
.nav a:focus, .nav-links a:focus {
  color: var(--text-secondary) !important;
  background: transparent !important;
  text-decoration: none !important;
  font-size: 0.84rem;
  font-weight: 500;
  padding: 0.45rem 0.7rem;
  border-radius: var(--radius-pill);
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
  flex: 0 0 auto;
  -webkit-tap-highlight-color: transparent;
}
.nav a:hover, .nav-links a:hover,
.nav a:focus-visible, .nav-links a:focus-visible {
  background: var(--fill) !important;
  color: var(--text) !important;
}
.nav a.active, .nav-links a.active,
.nav a.active:link, .nav-links a.active:link,
.nav a.active:visited, .nav-links a.active:visited,
.nav a.active:hover, .nav-links a.active:hover,
.nav a.active:focus, .nav-links a.active:focus,
.nav a.active:focus-visible, .nav-links a.active:focus-visible,
.nav a.active:active, .nav-links a.active:active {
  background: var(--fill-strong) !important;
  color: var(--text) !important;
  font-weight: 600;
}

/* Hero */
.hero {
  text-align: center;
  padding: 0.7rem 0.4rem 1.35rem;
}
.eyebrow, .kicker {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-secondary);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-bottom: 0.75rem;
}
.eyebrow .live, .kicker .live {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #30d158;
  box-shadow: 0 0 0 4px rgba(48, 209, 88, 0.28);
}
@media (prefers-color-scheme: light) {
  .live, .kicker .live {
    background: var(--green);
    box-shadow: 0 0 0 4px rgba(52, 199, 89, 0.18);
  }
}
.hero h1 {
  margin: 0;
  font-size: clamp(2rem, 6vw, 2.85rem);
  line-height: 1.08;
  letter-spacing: -0.035em;
  font-weight: 700;
  color: var(--text);
}
.hero h1 span {
  background: none;
  color: inherit;
  -webkit-text-fill-color: currentColor;
}
.hero-sub, .tagline, .hero .tagline {
  margin: 0.8rem auto 0;
  max-width: 36rem;
  color: var(--text-secondary);
  font-size: 1.02rem;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

/* Sections / cards */
.section { margin-top: 1.2rem; }
.section-label {
  margin: 0 0 0.55rem 1.05rem;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}

.card, .group {
  background: var(--bg-card);
  border: 1px solid var(--separator);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
}
.card { padding: 1.15rem 1.2rem; }
.group { overflow: hidden; }

.card-title, .card h2, .panel-head h2 {
  margin: 0 0 0.25rem;
  font-size: 1.05rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--text);
  text-transform: none;
}
.card-meta, .panel-meta {
  color: var(--text-secondary);
  font-size: 0.86rem;
}
.panel-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin-bottom: 0.85rem;
}
.panel-status, .pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.28rem 0.65rem;
  border-radius: var(--radius-pill);
  background: var(--fill);
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}
.panel-status.is-fail, .pill.bad { color: var(--red); background: rgba(255, 59, 48, 0.14); }
.pill.ok, .panel-status:not(.is-fail) { }
.panel-error, .msg.err, .status-error {
  color: var(--red);
  font-size: 0.9rem;
  margin-top: 0.55rem;
}
.msg { margin-top: 0.7rem; font-size: 0.9rem; color: var(--text-secondary); }
.msg.ok { color: var(--green); }
.hint, .note, .s60-tip {
  color: var(--text-tertiary);
  font-size: 0.84rem;
  line-height: 1.45;
}
.s60-tip {
  margin-top: 0.75rem;
  padding: 0.75rem 0.85rem;
  border-radius: 12px;
  background: var(--fill);
  color: var(--text-secondary);
}
.s60-tip strong {
  display: inline-block;
  margin-right: 0.4rem;
  color: var(--text);
}

.stack { display: grid; gap: 0.9rem; }
.pair, .card-pair, .grid-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem;
  align-items: stretch;
}

/* Home pair: row height follows lunar only; history matches + scrolls */
.card-pair {
  /* keep stretch; lunar content defines row size */
  align-items: stretch;
}
.card-pair > .card {
  display: flex;
  flex-direction: column;
  min-height: 0;
  box-sizing: border-box;
}
.card-pair #lunar-card {
  /* intrinsic height drives the grid row */
  height: max-content;
}
.card-pair #history-card {
  /*
    Classic grid trick: do not contribute intrinsic height.
    Stretch to the row height established by #lunar-card.
  */
  height: 0;
  min-height: 100%;
  overflow: hidden;
}
.card-pair #history-card .panel-head,
.card-pair #lunar-card .panel-head,
.card-pair #history-card .panel-error,
.card-pair #lunar-card .panel-error,
.card-pair #lunar-card #lunar-body {
  flex: 0 0 auto;
}
.card-pair #history-card .history-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  -ms-overflow-style: none;
}
.card-pair #history-card .history-list::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
  background: transparent;
}
.card-pair #history-card .panel-actions,
.card-pair #lunar-card .panel-actions {
  margin-top: auto;
  padding-top: 0.9rem;
  flex: 0 0 auto;
}

/* Mobile: stack normally, history can show more without the equal-height lock */
@media (max-width: 640px) {
  .card-pair #lunar-card {
    height: auto;
  }
  .card-pair #history-card {
    height: auto;
    min-height: 0;
    overflow: visible;
  }
  .card-pair #history-card .history-list {
    flex: 0 1 auto;
    max-height: 22rem;
    overflow-y: auto;
  }
}

/* Site favicon tiles */
.row-icon.row-icon-img {
  background: #fff !important;
  border: 1px solid var(--separator);
  box-shadow: none;
  overflow: hidden;
  padding: 0;
}
.row-icon.row-icon-img img {
  width: 18px;
  height: 18px;
  display: block;
  object-fit: contain;
}
@media (prefers-color-scheme: dark) {
  .row-icon.row-icon-img {
    background: #2c2c2e !important;
  }
}
.grid { display: grid; gap: 0.9rem; }
.full { grid-column: 1 / -1; }

/* Buttons */
.btn, button.btn,
.panel-actions button,
.quote-refresh,
#enterBtn,
#uploadBtn,
#lockBtn,
#refreshBtn {
  appearance: none;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--fill-strong);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  padding: 0.62rem 0.95rem;
  letter-spacing: -0.01em;
  text-decoration: none !important;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  transition: background 0.15s ease, transform 0.05s ease;
}
.btn.primary, #enterBtn, #uploadBtn {
  background: var(--blue) !important;
  color: #fff !important;
  border: 0 !important;
  box-shadow: none !important;
}
.btn.primary:hover, #enterBtn:hover, #uploadBtn:hover {
  background: var(--blue-hover) !important;
  color: #fff !important;
}
.btn:hover, .panel-actions button:hover, .quote-refresh:hover,
#lockBtn:hover, #refreshBtn:hover {
  background: var(--fill);
}
.btn.primary:hover, #enterBtn:hover, #uploadBtn:hover {
  background: var(--blue-hover) !important;
  color: #fff !important;
}
.btn:active, .panel-actions button:active,
#enterBtn:active, #uploadBtn:active, #lockBtn:active, #refreshBtn:active {
  transform: scale(0.98);
}
.btn.danger, button.danger {
  background: rgba(255, 59, 48, 0.12);
  color: var(--red);
}
button:disabled { opacity: 0.5; cursor: not-allowed; }
.btn-row, .panel-actions, .row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  align-items: center;
}
.panel-actions { margin-top: 0.9rem; }

.field, input[type="password"], input[type="file"], input[type="text"] {
  width: 100%;
  border: 1px solid var(--separator);
  border-radius: 12px;
  background: var(--fill);
  color: var(--text);
  padding: 0.8rem 0.95rem;
  outline: none;
}
.field:focus, input[type="password"]:focus, input[type="text"]:focus {
  border-color: rgba(0, 113, 227, 0.55);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.15);
  background: var(--bg-card);
}

/* Search — single shell, no outer card */
.search-card {
  position: relative;
  z-index: 20;
  padding: 0 !important;
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}
.search-card.is-menu-open { z-index: 80; }
.search-form, .search-shell {
  display: flex;
  align-items: stretch;
  width: 100%;
  min-height: 52px;
  border: 1px solid var(--separator);
  border-radius: 16px;
  background: var(--bg-card);
  box-shadow: var(--shadow);
  overflow: visible;
  position: relative;
}
.search-form:focus-within, .search-shell:focus-within {
  border-color: rgba(0, 113, 227, 0.45);
  box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.12), var(--shadow);
}
.engine-switch { position: relative; flex: 0 0 auto; }
.engine-btn {
  appearance: none;
  height: 100%;
  min-width: 5.2rem;
  border: 0;
  border-right: 1px solid var(--separator);
  background: transparent;
  color: var(--text);
  font-weight: 600;
  padding: 0 0.9rem;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  border-radius: 16px 0 0 16px;
}
.engine-btn .caret {
  width: 0; height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid var(--text-tertiary);
}
.engine-menu {
  display: none;
  position: absolute;
  top: calc(100% + 8px);
  left: 0;
  min-width: 8.5rem;
  padding: 0.35rem;
  border-radius: 14px;
  border: 1px solid var(--separator);
  background: var(--bg-card);
  box-shadow: var(--shadow);
  z-index: 40;
}
.engine-switch.is-open .engine-menu { display: grid; gap: 0.15rem; }
.engine-option {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: left;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  color: var(--text);
  font-weight: 550;
}
.engine-option:hover,
.engine-option.is-active { background: var(--fill); }
.search-input {
  flex: 1;
  min-width: 0;
  border: 0 !important;
  outline: none !important;
  box-shadow: none !important;
  background: transparent !important;
  color: var(--text);
  padding: 0 0.85rem;
  font-size: 1rem;
  border-radius: 0;
}
.search-submit {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--text-secondary);
  width: 3rem;
  display: grid;
  place-items: center;
  border-radius: 0 16px 16px 0;
}
.search-submit svg { width: 18px; height: 18px; }

/* Poem */
.poem-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 0 0 0.85rem;
  padding: 0 0 0.85rem;
  border-bottom: 1px solid var(--separator);
}
.poem-author { color: var(--text-secondary); font-size: 0.86rem; margin-top: 0.15rem; }
.poem-mark, .pill {
  flex: 0 0 auto;
}
.poem-text, .poem {
  white-space: pre-line;
  color: var(--text);
  font-size: 1.02rem;
  line-height: 1.85;
  letter-spacing: 0.01em;
  margin: 0;
}

/* Shared card header rhythm: title meta, then hairline, then body */
.card > .panel-head {
  margin: 0 0 0.85rem;
  padding: 0 0 0.85rem;
  border-bottom: 1px solid var(--separator);
}
.card > .panel-head + .s60-list,
.card > .panel-head + .history-list,
.card > .panel-head + .lunar-body,
.card > .panel-head + .panel-error {
  margin-top: 0;
}

/* 60s / history lists */
.s60-list, .history-list, .plain-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.s60-list li {
  display: grid;
  grid-template-columns: 1.7rem 1fr;
  gap: 0.55rem;
  padding: 0.72rem 0;
  border-top: 1px solid var(--separator);
  font-size: 0.95rem;
  line-height: 1.45;
}
.s60-list li:first-child { border-top: 0; padding-top: 0.1rem; }
.s60-list .n {
  color: var(--text-tertiary);
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  font-size: 0.86rem;
}
.history-list li {
  padding: 0.75rem 0;
  border-top: 1px solid var(--separator);
}
.history-list li:first-child { border-top: 0; padding-top: 0.1rem; }
.history-list .year {
  color: var(--text-tertiary);
  font-size: 0.8rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  margin-bottom: 0.15rem;
}
.history-list .title {
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.history-list a.title:hover { color: var(--blue); text-decoration: underline; }
.history-list .desc {
  margin-top: 0.2rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.45;
}

/* Lunar */
.lunar-hero {
  font-size: 1.15rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  margin-bottom: 0.85rem;
}
.lunar-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
}
.lunar-item {
  padding: 0.8rem 0.85rem;
  border-radius: 14px;
  background: var(--fill);
}
.lunar-item .k {
  color: var(--text-tertiary);
  font-size: 0.72rem;
  font-weight: 650;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
.lunar-item .v {
  margin-top: 0.2rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  font-size: 0.95rem;
}
.lunar-taboo { margin-top: 0.85rem; display: grid; gap: 0.45rem; }
.lunar-taboo .row {
  align-items: flex-start;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.45;
}
.lunar-taboo .yi, .lunar-taboo .ji {
  display: inline-flex;
  min-width: 1.5rem;
  font-weight: 750;
  margin-right: 0.35rem;
}
.lunar-taboo .yi { color: var(--green); }
.lunar-taboo .ji { color: var(--red); }

/* Resources rows */
.links { display: grid; }
.links.dense { gap: 0; }
.link-btn, .row-item {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.95rem 1.15rem;
  color: inherit !important;
  text-decoration: none !important;
  min-height: auto;
  border: 0;
  background: transparent;
  border-radius: 0;
}
.link-btn + .link-btn, .row-item + .row-item { border-top: 1px solid var(--separator); }
.link-btn:hover, .row-item:hover { background: var(--fill); }
.link-btn .title, .row-copy strong {
  display: block;
  font-size: 0.98rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
}
.link-btn small, .row-copy span {
  color: var(--text-secondary);
  font-size: 0.84rem;
}
.link-btn .go, .row-chevron {
  margin-left: auto;
  color: var(--text-tertiary);
  font-size: 1.1rem;
}
.row-icon {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 0.82rem;
  font-weight: 700;
  flex: 0 0 auto;
}
.icon-a { background: linear-gradient(180deg, #ff6482, #ff375f); }
.icon-b { background: linear-gradient(180deg, #ffd60a, #ff9f0a); }
.icon-c { background: linear-gradient(180deg, #64d2ff, #0a84ff); }
.icon-d { background: linear-gradient(180deg, #bf5af2, #5e5ce6); }
.icon-e { background: linear-gradient(180deg, #30d158, #28a745); }

/* Status */
.status-hero-head {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.9rem;
}
.state, .status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.55rem 0.95rem 0.55rem 0.7rem;
  border-radius: var(--radius-pill);
  background: var(--bg-card);
  border: 1px solid var(--separator);
  box-shadow: var(--shadow);
  font-size: 0.95rem;
  font-weight: 650;
}
.state .dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-tertiary);
  box-shadow: 0 0 0 5px rgba(142, 142, 147, 0.18);
}
.state.ok .dot { background: #34c759; box-shadow: 0 0 0 5px rgba(52, 199, 89, 0.18); }
.state.warn .dot { background: #ff9f0a; box-shadow: 0 0 0 5px rgba(255, 159, 10, 0.18); }
.state.bad .dot { background: #ff3b30; box-shadow: 0 0 0 5px rgba(255, 59, 48, 0.18); }
.state.ok { color: #248a3d; }
.state.warn { color: #9a6700; }
.state.bad { color: #d70015; }
@media (prefers-color-scheme: dark) {
  .state.ok { color: #30d158; }
  .state.warn { color: #ffd60a; }
  .state.bad { color: #ff453a; }
  .state .dot { box-shadow: 0 0 0 5px rgba(255, 255, 255, 0.10); }
  .state.ok .dot { background: #30d158; box-shadow: 0 0 0 5px rgba(48, 209, 88, 0.32); }
  .state.warn .dot { background: #ffd60a; box-shadow: 0 0 0 5px rgba(255, 214, 10, 0.28); }
  .state.bad .dot { background: #ff453a; box-shadow: 0 0 0 5px rgba(255, 69, 58, 0.30); }
  .live, .kicker .live {
    background: #30d158;
    box-shadow: 0 0 0 4px rgba(48, 209, 88, 0.34);
  }
}
.meta, .meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  margin-top: 1.1rem;
  text-align: left;
}
.meta-item, .meta-card {
  background: var(--bg-card);
  border: 1px solid var(--separator);
  border-radius: var(--radius-lg);
  padding: 1rem 1.05rem;
  box-shadow: var(--shadow);
  display: block;
}
.meta-item span, .meta-card .label {
  display: block;
  color: var(--text-tertiary);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.meta-item strong, .meta-card .value {
  display: block;
  margin-top: 0.3rem;
  font-size: 1.25rem;
  font-weight: 650;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.resource-grid, #resources {
  display: grid;
  gap: 0;
  background: var(--bg-card);
  border: 1px solid var(--separator);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow);
  overflow: hidden;
}
.resource-card {
  border: 0 !important;
  border-radius: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
  padding: 1.05rem 1.15rem 1rem !important;
  margin: 0;
}
.resource-card + .resource-card { border-top: 1px solid var(--separator) !important; }
.resource-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 1rem;
}
.resource-name {
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.resource-value {
  color: var(--text);
  font-size: 1.15rem;
  font-weight: 650;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.02em;
}
.resource-sub {
  margin-top: 0.28rem;
  color: var(--text-secondary);
  font-size: 0.88rem;
  line-height: 1.45;
}
.resource-card .bar {
  position: relative;
  height: 6px;
  margin-top: 0.7rem;
  overflow: hidden;
  border-radius: 999px;
  background: var(--bar-track, var(--fill));
}
.resource-card .bar::after {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: var(--pct, 0%);
  max-width: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, #64d2ff, #0a84ff);
  transition: width 0.35s ease;
}
.resource-card .bar.warn::after { background: linear-gradient(90deg, #ffd60a, #ff9f0a); }
.resource-card .bar.bad::after { background: linear-gradient(90deg, #ff6482, #ff453a); }
.section-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 0 0 0.55rem;
  padding: 0 1.05rem;
}
.section-title {
  margin: 0;
  color: var(--text-secondary);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  text-transform: uppercase;
}
.section-note { color: var(--text-tertiary); font-size: 0.8rem; }

/* Share */
#gate label {
  display: block;
  font-size: 0.84rem;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 0.45rem;
}
#gate .row input[type="password"] { flex: 1 1 220px; min-width: 0; width: auto; }
.badge {
  display: inline-flex;
  margin-top: 0.75rem;
  padding: 0.28rem 0.65rem;
  border-radius: 999px;
  background: rgba(52, 199, 89, 0.14);
  color: var(--green);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
/* Custom Apple-like file picker */
.sr-only-file {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}
.upload-row {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  flex-wrap: wrap;
}
.file-picker {
  flex: 1 1 220px;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 0.65rem;
  min-height: 44px;
  padding: 0.35rem 0.4rem 0.35rem 0.35rem;
  border: 1px solid var(--separator);
  border-radius: 12px;
  background: var(--fill);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.file-picker:hover { background: var(--fill-strong); }
.file-picker-btn {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 0 0.75rem;
  border-radius: 9px;
  background: var(--bg-card);
  border: 1px solid var(--separator);
  color: var(--text);
  font-size: 0.84rem;
  font-weight: 600;
  white-space: nowrap;
  box-shadow: 0 1px 1px rgba(0,0,0,0.04);
}
.file-picker-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
  font-size: 0.88rem;
  font-weight: 500;
}
#uploadBtn {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 0.7rem 1.05rem;
  white-space: nowrap;
}

.files { display: grid; }
.file {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) minmax(9.5rem, 0.9fr) auto;
  align-items: center;
  column-gap: 0.9rem;
  row-gap: 0.45rem;
  padding: 0.95rem 0;
  border-top: 1px solid var(--separator);
}
.file:first-child { border-top: 0; padding-top: 0.15rem; }
.file .name {
  min-width: 0;
  font-weight: 600;
  letter-spacing: -0.01em;
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: normal;
  line-height: 1.35;
}
.file .sub {
  min-width: 0;
  color: var(--text-tertiary);
  font-size: 0.82rem;
  line-height: 1.3;
  white-space: nowrap;
  text-align: right;
  justify-self: end;
  align-self: center;
}
.file .actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  align-self: center;
  flex: 0 0 auto;
}
.file .actions .file-action,
.file .actions button {
  appearance: none;
  border: 0;
  border-radius: var(--radius-pill);
  background: var(--fill-strong);
  color: var(--text);
  font-weight: 600;
  font-size: 0.82rem;
  line-height: 1;
  min-width: 3.6rem;
  height: 32px;
  min-height: 32px;
  padding: 0 0.75rem;
  white-space: nowrap;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.file .actions .file-action.danger,
.file .actions button.danger {
  background: rgba(255, 59, 48, 0.12);
  color: var(--red);
}

@media (max-width: 720px) {
  .file {
    grid-template-columns: minmax(0, 1fr) auto;
    grid-template-areas:
      "name actions"
      "sub actions";
  }
  .file .name { grid-area: name; }
  .file .sub {
    grid-area: sub;
    text-align: left;
    justify-self: start;
    white-space: normal;
  }
  .file .actions {
    grid-area: actions;
    align-self: center;
  }
}

@media (max-width: 560px) {
  .upload-row { align-items: stretch; }
  #uploadBtn { width: 100%; }
  .file {
    grid-template-columns: 1fr;
    grid-template-areas:
      "name"
      "sub"
      "actions";
    gap: 0.45rem;
  }
  .file .actions {
    justify-content: flex-start;
  }
}
progress {
  width: 100%;
  margin-top: 0.85rem;
  height: 8px;
  border: 0;
  border-radius: 999px;
  overflow: hidden;
  background: var(--fill);
}
progress::-webkit-progress-bar { background: var(--fill); border-radius: 999px; }
progress::-webkit-progress-value { background: linear-gradient(90deg, #64d2ff, #0071e3); border-radius: 999px; }
progress::-moz-progress-bar { background: linear-gradient(90deg, #64d2ff, #0071e3); border-radius: 999px; }

.quote-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8rem;
  margin: 0.95rem auto 0;
  max-width: 36rem;
  text-align: left;
}
.quote-row .tagline { margin: 0; text-align: left; }

.footer, .glow-line + .footer {
  margin-top: 2rem;
  text-align: center;
  color: var(--text-tertiary);
  font-size: 0.8rem;
  line-height: 1.6;
  display: grid;
  gap: 0.2rem;
  justify-items: center;
}
.glow-line { display: none; }

@media (max-width: 640px) {
  .page, .wrap { width: min(100% - 1rem, var(--page-width)); }
  .topnav, .topbar {
    gap: 0.4rem;
    min-height: 52px;
    padding: 0.62rem 0.7rem;
    border-radius: 16px;
    margin-bottom: 1rem;
  }
  .brand {
    gap: 0.4rem;
    max-width: none;
    flex: 0 0 auto;
  }
  .brand-mark {
    width: 28px;
    height: 28px;
    font-size: 1.2rem;
  }
  /* Keep one-line nav: hide subtitle like Resources/Private/Home */
  .brand-text span { display: none; }
  .brand-text strong {
    font-size: 0.92rem;
    line-height: 1.1;
  }
  .nav, .nav-links {
    gap: 0.05rem;
    flex-wrap: nowrap;
    overflow: visible;
  }
  .nav a, .nav-links a {
    padding: 0.48rem 0.5rem;
    font-size: 0.78rem;
    letter-spacing: -0.01em;
    line-height: 1.1;
  }
  .pair, .card-pair, .lunar-grid, .meta, .meta-row { grid-template-columns: 1fr; }
  .hero h1 { font-size: 2.05rem; }
  .quote-row { flex-direction: column; align-items: stretch; }
}

/* Extra-narrow phones: still single-line, slightly tighter width only */
@media (max-width: 380px) {
  .brand-text { display: none; }
  .topnav, .topbar {
    min-height: 50px;
    padding: 0.58rem 0.55rem;
  }
  .nav a, .nav-links a {
    padding: 0.46rem 0.4rem;
    font-size: 0.74rem;
  }
}


/* Quiet Apple-style text actions (no pill buttons) */
.panel-actions.panel-actions-links {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.7rem;
  padding-top: 0.65rem;
  border-top: 1px solid var(--separator);
}
.panel-actions.panel-actions-links a,
.panel-actions.panel-actions-links .text-link,
.panel-actions.panel-actions-links a.text-link {
  appearance: none !important;
  display: inline !important;
  border: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
  color: var(--blue) !important;
  font-weight: 500 !important;
  font-size: 0.82rem !important;
  line-height: 1.3 !important;
  padding: 0 !important;
  min-height: 0 !important;
  letter-spacing: -0.01em;
  text-decoration: none !important;
  transform: none !important;
}
.panel-actions.panel-actions-links a:hover,
.panel-actions.panel-actions-links .text-link:hover {
  background: transparent !important;
  color: var(--blue-hover) !important;
  text-decoration: underline !important;
}
.panel-actions.panel-actions-links a:active,
.panel-actions.panel-actions-links .text-link:active {
  transform: none !important;
  opacity: 0.75;
}
.panel-actions.panel-actions-links .action-dot {
  color: var(--text-tertiary);
  font-size: 0.78rem;
  line-height: 1;
  user-select: none;
  transform: translateY(-0.5px);
}


/* Resource sections: title outside, one list card only (no card-in-card) */
.resource-block {
  display: grid;
  gap: 0.55rem;
}
.resource-block > h2 {
  margin: 0;
  padding: 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 650;
  letter-spacing: -0.01em;
  color: var(--text-secondary);
}
.resource-block .group.links,
.resource-block .group.links.dense {
  margin: 0;
}
/* If legacy markup still has .card > .group, flatten outer card */
.card.full:has(> .group.links) {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}
.card.full:has(> .group.links) > h2 {
  margin: 0 0 0.55rem;
  padding: 0 0.35rem;
  font-size: 0.92rem;
  font-weight: 650;
  color: var(--text-secondary);
}
