:root {
  --bg: #f2f4ef;
  --surface: #ffffff;
  --surface-soft: #e9efe9;
  --text: #17221d;
  --muted: #69736e;
  --line: #dbe1dc;
  --jade: #176f55;
  --jade-dark: #0f5943;
  --jade-soft: #dceee7;
  --gold: #d9a522;
  --red: #a13e31;
  --shadow: 0 8px 24px rgba(28, 52, 42, .08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: var(--bg);
  letter-spacing: 0;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--bg); }
body { min-width: 280px; font-size: 15px; -webkit-tap-highlight-color: transparent; }
button, input, textarea, select { font: inherit; letter-spacing: 0; }
button { color: inherit; }
button:focus-visible, input:focus-visible, textarea:focus-visible, select:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; }
[hidden] { display: none !important; }

.gate { min-height: 100vh; padding: max(38px, env(safe-area-inset-top)) 22px max(28px, env(safe-area-inset-bottom)); background: linear-gradient(180deg, #e5eee7 0, var(--bg) 42%); }
.gate-brand { display: flex; align-items: center; gap: 12px; width: min(100%, 430px); margin: 0 auto 34px; }
.gate-brand h1, .gate-brand p { margin: 0; }
.gate-brand h1 { font-family: "STKaiti", "KaiTi", serif; font-size: 28px; }
.gate-brand p { margin-top: 2px; color: var(--muted); }
.seal { display: grid; width: 48px; height: 48px; place-items: center; color: #fff; background: var(--jade); border: 2px solid var(--jade-dark); border-radius: 4px; font-family: "STKaiti", "KaiTi", serif; font-size: 27px; }
.gate-panel { width: min(100%, 430px); margin: auto; padding: 26px 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; box-shadow: var(--shadow); }
.gate-panel h2 { margin: 6px 0 24px; font-size: 25px; }
.eyebrow { color: var(--jade); font-size: 12px; font-weight: 700; }
.field { display: grid; gap: 7px; margin: 17px 0; color: var(--muted); font-size: 13px; }
.field textarea { width: 100%; resize: vertical; padding: 12px; color: var(--text); background: #fafbf9; border: 1px solid var(--line); border-radius: 6px; }
.copy-line { display: flex; min-height: 44px; align-items: center; padding-left: 12px; color: var(--text); background: #fafbf9; border: 1px solid var(--line); border-radius: 6px; }
.copy-line code { flex: 1; overflow-wrap: anywhere; font-family: ui-monospace, monospace; }
.icon-button { display: inline-grid; width: 42px; height: 42px; place-items: center; padding: 0; color: var(--jade); background: transparent; border: 0; border-radius: 6px; }
.icon-button svg { width: 20px; height: 20px; }
.primary-button { display: flex; width: 100%; min-height: 48px; align-items: center; justify-content: center; gap: 8px; margin-top: 18px; color: #fff; background: var(--jade); border: 0; border-radius: 7px; font-weight: 700; }
.primary-button:active { background: var(--jade-dark); }
.primary-button:disabled { opacity: .55; }
.text-button { padding: 6px 0; color: var(--jade); background: transparent; border: 0; }
.message { margin: 12px 0; padding: 10px 12px; color: var(--red); background: #f7e9e6; border-radius: 6px; }
.gate-foot { margin: 18px auto 0; color: var(--muted); text-align: center; font-size: 12px; }
.location-panel { text-align: center; }
.location-panel h2 { margin-bottom: 8px; }
.location-panel > p { color: var(--muted); }
.location-mark { display: grid; width: 64px; height: 64px; place-items: center; margin: -58px auto 18px; color: #fff; background: var(--jade); border: 6px solid var(--bg); border-radius: 50%; }
.location-mark svg { width: 28px; height: 28px; }
.status-row { display: flex; align-items: center; justify-content: space-between; padding: 13px 0; border-top: 1px solid var(--line); text-align: left; }
.status-row:first-of-type { margin-top: 24px; }
.status-row strong { display: flex; align-items: center; gap: 5px; color: var(--jade); }
.status-row svg { width: 17px; }

.app { min-height: 100vh; padding-bottom: calc(66px + env(safe-area-inset-bottom)); }
.screen { display: none; }
.screen.is-active { display: block; }
.topbar { display: flex; min-height: 78px; align-items: center; justify-content: space-between; padding: max(18px, env(safe-area-inset-top)) 18px 12px; background: var(--surface); border-bottom: 1px solid var(--line); }
.topbar h1 { margin: 2px 0 0; font-size: 25px; }
.home-band { padding: 18px; color: #fff; background: var(--jade); }
.date-field { display: grid; grid-template-columns: auto 1fr; align-items: center; gap: 14px; }
.date-field span { color: rgba(255,255,255,.72); font-size: 12px; }
.date-field input { width: 100%; min-width: 0; padding: 10px 0; color: #fff; color-scheme: dark; background: transparent; border: 0; border-bottom: 1px solid rgba(255,255,255,.35); }
.pillars { display: grid; grid-template-columns: repeat(4, 1fr); margin: 18px 0; background: rgba(255,255,255,.09); border: 1px solid rgba(255,255,255,.14); border-radius: 7px; }
.pillars span { display: grid; gap: 3px; padding: 10px 3px; text-align: center; border-right: 1px solid rgba(255,255,255,.13); }
.pillars span:last-child { border-right: 0; }
.pillars small { color: rgba(255,255,255,.62); }
.pillars b { font-family: "STKaiti", "KaiTi", serif; font-size: 18px; font-weight: 600; }
.location-time { display: grid; grid-template-columns: minmax(0, .9fr) minmax(0, 1.1fr); gap: 12px; }
.location-time > span { display: flex; min-width: 0; align-items: center; gap: 6px; }
.location-time > span:last-child { display: grid; gap: 2px; text-align: right; }
.location-time b { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.location-time small { color: rgba(255,255,255,.62); }
.location-time svg { width: 16px; flex: 0 0 auto; }
.section { padding: 18px; }
.methods-section { padding-top: 20px; }
.section-title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.section-title h2 { margin: 0; font-size: 18px; }
.section-title > span { color: var(--muted); font-size: 13px; }
.method-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.method-grid button { min-height: 42px; padding: 7px 5px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; white-space: normal; }
.method-grid button.is-selected { color: var(--jade-dark); background: var(--jade-soft); border-color: var(--jade); font-weight: 700; }
.result { margin-top: 18px; overflow: hidden; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.result-head { display: flex; align-items: center; justify-content: space-between; padding: 15px; color: #fff; background: var(--jade); }
.result-head > span { display: grid; gap: 3px; }
.result-head small { color: rgba(255,255,255,.7); }
.result-head strong { font-family: "STKaiti", "KaiTi", serif; font-size: 25px; }
.result-state { padding: 4px 8px; background: rgba(255,255,255,.13); border-radius: 999px; font-size: 12px; }
.result-lines { margin: 0; padding: 7px 15px 12px; }
.result-lines > div { display: grid; grid-template-columns: 92px minmax(0, 1fr); gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.result-lines > div:last-child { border-bottom: 0; }
.result-lines dt { color: var(--muted); }
.result-lines dd { margin: 0; overflow-wrap: anywhere; }
.point-list { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; padding: 0 15px 15px; }
.point-list span { display: flex; justify-content: space-between; gap: 8px; padding: 10px; background: var(--surface-soft); border-radius: 6px; }
.point-list small { color: var(--muted); }
.full-grid { grid-template-columns: repeat(3, 1fr); }

.search { display: flex; align-items: center; gap: 9px; padding: 11px 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.search svg { width: 18px; color: var(--muted); }
.search input { min-width: 0; flex: 1; background: transparent; border: 0; outline: 0; }
.feature-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; margin-top: 14px; }
.feature { position: relative; min-height: 145px; overflow: hidden; padding: 0; text-align: left; background: var(--surface); border: 1px solid var(--line); border-radius: 7px; }
.feature img { width: 100%; height: 104px; display: block; object-fit: cover; object-position: center 26%; filter: saturate(.78); }
.feature span { display: grid; gap: 1px; padding: 9px 11px; }
.feature small { color: var(--jade); }
.feature strong { font-size: 15px; }
.feature-wide, .feature-guide { grid-column: 1 / -1; min-height: 160px; }
.feature-wide img, .feature-guide img { height: 122px; }
.feature-wide span, .feature-guide span { position: absolute; left: 0; bottom: 0; width: 100%; color: #fff; background: linear-gradient(transparent, rgba(9,28,20,.83)); padding: 35px 14px 13px; }
.feature-wide small, .feature-guide small { color: rgba(255,255,255,.7); }
.feature-guide > svg { position: absolute; right: 14px; bottom: 16px; z-index: 2; color: #fff; }
.case-title { margin-top: 22px; }
.case-item { display: grid; grid-template-columns: 42px 1fr; gap: 12px; padding: 15px 0; border-top: 1px solid var(--line); }
.case-item h3, .case-item p { margin: 0; }
.case-item p { margin: 6px 0; color: var(--muted); line-height: 1.65; }
.case-item small { color: var(--jade); }
.case-index { display: grid; width: 40px; height: 40px; place-items: center; color: var(--red); background: #f5e5e1; border-radius: 6px; font-weight: 700; }
.empty { padding: 28px 0; color: var(--muted); text-align: center; }

.study-lead, .profile-license { display: flex; align-items: center; justify-content: space-between; min-height: 108px; margin-bottom: 22px; padding: 18px; color: #fff; background: var(--jade); border-radius: 8px; }
.study-lead span, .profile-license div { display: grid; gap: 5px; }
.study-lead small, .profile-license small, .profile-license span { color: rgba(255,255,255,.68); }
.study-lead strong { font-family: "STKaiti", "KaiTi", serif; font-size: 21px; }
.study-lead svg { width: 36px; height: 36px; color: var(--gold); }
.lesson-list, .settings-list, .source-list { margin-bottom: 22px; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
.lesson-list button { display: grid; width: 100%; grid-template-columns: 36px 1fr auto; align-items: center; gap: 10px; padding: 14px; text-align: left; background: transparent; border: 0; border-bottom: 1px solid var(--line); }
.lesson-list button:last-child { border-bottom: 0; }
.lesson-list button > span { color: var(--gold); font-weight: 700; }
.lesson-list button > div { display: grid; gap: 3px; }
.lesson-list small, .source-list span { color: var(--muted); }
.lesson-list svg { width: 17px; color: var(--muted); }
.source-list { padding: 4px 14px; }
.source-list p { display: grid; gap: 3px; margin: 0; padding: 13px 0; border-bottom: 1px solid var(--line); }
.source-list p:last-child { border-bottom: 0; }
.profile-license { justify-content: flex-start; gap: 16px; }
.profile-license > svg { width: 38px; height: 38px; color: var(--gold); }
.profile-license strong { font-size: 20px; }
.settings-list > button, .settings-list > label { display: flex; width: 100%; min-height: 52px; align-items: center; justify-content: space-between; gap: 12px; padding: 13px 14px; background: transparent; border: 0; border-bottom: 1px solid var(--line); }
.settings-list > :last-child { border-bottom: 0; }
.settings-list span { display: flex; align-items: center; gap: 9px; }
.settings-list svg { width: 18px; color: var(--jade); }
.settings-list strong { max-width: 55%; overflow: hidden; color: var(--muted); font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.settings-list select { min-width: 0; color: var(--jade); background: transparent; border: 0; }
.about { color: var(--muted); text-align: center; font-size: 12px; line-height: 1.6; }
.about strong { color: var(--text); }
.about p { max-width: 380px; margin: 7px auto; }

.bottom-nav { position: fixed; z-index: 20; right: 0; bottom: 0; left: 0; display: grid; grid-template-columns: repeat(4, 1fr); padding-bottom: env(safe-area-inset-bottom); background: rgba(255,255,255,.97); border-top: 1px solid var(--line); backdrop-filter: blur(16px); }
.bottom-nav button { display: grid; min-width: 0; height: 65px; place-items: center; align-content: center; gap: 3px; color: var(--muted); background: transparent; border: 0; font-size: 12px; }
.bottom-nav button.is-selected { color: var(--jade); }
.bottom-nav svg { width: 21px; height: 21px; }

@media (min-width: 700px) {
  .app { width: min(100%, 620px); margin: auto; background: var(--bg); box-shadow: 0 0 0 1px var(--line); }
  .bottom-nav { width: min(100%, 620px); margin: auto; }
}

@media (max-width: 350px) {
  .method-grid { grid-template-columns: repeat(2, 1fr); }
  .full-grid { grid-template-columns: repeat(2, 1fr); }
  .result-lines > div { grid-template-columns: 76px minmax(0, 1fr); }
}
