:root {
  --bg: #f2f4f1;
  --surface: #ffffff;
  --surface-sunken: #eaeee9;
  --line: #e2e7e1;
  --line-strong: #d2d9d2;
  --ink: #17201c;
  --ink-2: #5d6b64;
  --ink-3: #8c988f;
  --accent: #1d6b52;
  --accent-ink: #14503d;
  --accent-soft: #e5efe9;
  --warn: #a9661b;
  --warn-soft: #fbf0e1;
  --danger: #a8483c;
  --danger-soft: #faebe8;
  --radius: 14px;
  --radius-sm: 10px;
  --shadow: 0 1px 2px rgba(23, 32, 28, 0.04), 0 6px 16px -12px rgba(23, 32, 28, 0.18);
  --font-ui: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-text: "Songti SC", "Noto Serif CJK SC", "Source Han Serif SC", "SimSun", serif;
  --tabbar: 58px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  padding: 0;
  background: #e6eae5;
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

body { overscroll-behavior-y: none; }

button { font: inherit; color: inherit; border: 0; background: none; cursor: pointer; }
input, textarea, select { font: inherit; color: inherit; }
a { color: var(--accent); text-decoration: none; }

.app {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 480px;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0 auto;
  background: var(--bg);
  box-shadow: 0 0 0 1px rgba(23, 32, 28, 0.06);
}

.view {
  flex: 1;
  padding-bottom: calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 12px);
  animation: fade 0.18s ease-out;
}
.view.no-tabbar { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 16px); }

@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

/* ---------- app bar ---------- */

.appbar {
  position: sticky;
  top: 0;
  z-index: 20;
  padding: calc(env(safe-area-inset-top, 0px) + 14px) 16px 12px;
  background: rgba(242, 244, 241, 0.92);
  backdrop-filter: saturate(1.6) blur(12px);
  border-bottom: 1px solid transparent;
}
.appbar.scrolled { border-bottom-color: var(--line); }
.appbar-row { display: flex; align-items: center; gap: 10px; }
.appbar h1 { margin: 0; font-size: 19px; font-weight: 600; letter-spacing: -0.01em; }
.appbar-title { flex: 1; font-size: 16px; font-weight: 600; }
.appbar-sub { margin: 2px 0 0; font-size: 12.5px; color: var(--ink-3); }

.icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  margin-left: -6px;
  border-radius: 10px;
  font-size: 17px;
  color: var(--ink);
}
.icon-btn:active { background: var(--surface-sunken); }
.icon-btn.plain { margin: 0; }
.icon-btn[aria-pressed="true"] { color: var(--accent); }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--warn-soft);
  color: var(--warn);
  font-size: 11px;
  font-weight: 500;
  vertical-align: 2px;
}
.pill.neutral { background: var(--surface-sunken); color: var(--ink-2); }

/* ---------- search ---------- */

.searchbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 10px 9px 12px;
  margin-top: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 12px;
  box-shadow: var(--shadow);
}
.searchbar:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.searchbar svg { flex: none; }
.searchbar input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  background: none;
  font-size: 15px;
}
.searchbar input::placeholder { color: var(--ink-3); }
.searchbar .go {
  flex: none;
  padding: 5px 12px;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
}
.searchbar.compact { margin-top: 0; padding: 6px 8px 6px 10px; box-shadow: none; }
.searchbar.compact input { font-size: 14px; }

/* ---------- sections & cards ---------- */

.section { padding: 22px 16px 0; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; margin-bottom: 10px; }
.section h2 { margin: 0; font-size: 14px; font-weight: 600; letter-spacing: 0.01em; }
.section h2 .hint { margin-left: 6px; font-size: 12px; font-weight: 400; color: var(--ink-3); }
.section-link { font-size: 12.5px; color: var(--accent); }

.card {
  padding: 14px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}
.card + .card { margin-top: 10px; }
.card.tappable:active { background: var(--surface-sunken); }

.grid { display: grid; gap: 8px; grid-template-columns: repeat(2, 1fr); }
.tile {
  padding: 11px 12px;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
}
.tile:active { background: var(--accent-soft); border-color: var(--accent); }
.tile strong { display: block; font-size: 13.5px; font-weight: 600; }
.tile span { display: block; margin-top: 3px; font-size: 11.5px; line-height: 1.45; color: var(--ink-3); }

/* ---------- chips ---------- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  padding: 6px 11px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--line);
  font-size: 12.5px;
  color: var(--ink-2);
  line-height: 1.5;
  text-align: left;
}
.chip:active { background: var(--surface-sunken); }
.chip.on { background: var(--accent-soft); border-color: rgba(29, 107, 82, 0.35); color: var(--accent-ink); font-weight: 500; }
.chip.ghost { background: transparent; }
.chip.tiny { padding: 4px 9px; font-size: 12px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; padding-bottom: 4px; scrollbar-width: none; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chips.scroll .chip { flex: none; }

.parsebar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin: 12px 16px 0;
  padding: 10px 12px;
  background: var(--accent-soft);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: var(--accent-ink);
}
.parsebar .label { color: var(--ink-2); }
.parsebar .clear { margin-left: auto; color: var(--accent); font-size: 12px; }

.filterbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px 0;
  font-size: 12.5px;
  color: var(--ink-3);
}
.filterbar .grow { flex: 1; }

/* ---------- result / list rows ---------- */

.status { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; font-weight: 500; white-space: nowrap; }
.status::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.status.valid { color: var(--accent); }
.status.not_yet_effective, .status.amended { color: var(--warn); }
.status.repealed, .status.expired, .status.superseded { color: var(--danger); }

.row-meta { display: flex; align-items: center; gap: 8px; font-size: 11.5px; color: var(--ink-3); flex-wrap: wrap; }
.dot-sep::before { content: "·"; margin-right: 8px; color: var(--line-strong); }

.item-title {
  margin: 7px 0 0;
  font-family: var(--font-text);
  font-size: 15.5px;
  font-weight: 600;
  line-height: 1.5;
  letter-spacing: 0.01em;
}
.item-sub { margin: 5px 0 0; font-size: 12.5px; color: var(--ink-2); }

mark { padding: 0 1px; background: var(--accent-soft); color: var(--accent-ink); border-radius: 3px; }

.clause-hit {
  position: relative;
  margin-top: 10px;
  padding: 9px 11px 9px 13px;
  background: var(--surface-sunken);
  border-radius: 0 8px 8px 0;
  font-family: var(--font-text);
  font-size: 13.5px;
  line-height: 1.75;
  color: var(--ink-2);
}
.clause-hit::before { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 3px; background: var(--accent); }
.clause-hit b { color: var(--ink); font-weight: 600; }
.clause-hit .more { display: block; margin-top: 6px; font-family: var(--font-ui); font-size: 12px; color: var(--accent); }

.source-line {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--line);
  font-size: 11.5px;
  color: var(--ink-3);
}
.source-line .host { color: var(--ink-2); }
.source-empty { display: flex; gap: 6px; align-items: flex-start; margin: 0; font-size: 12.5px; line-height: 1.7; color: var(--warn); }

/* ---------- detail ---------- */

.doc-title {
  margin: 6px 0 0;
  font-family: var(--font-text);
  font-size: 21px;
  font-weight: 600;
  line-height: 1.45;
  letter-spacing: 0.01em;
}
.badges { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 10px; }
.tag-badge { padding: 3px 8px; border-radius: 6px; background: var(--surface-sunken); color: var(--ink-2); font-size: 11.5px; }

.notice {
  display: flex;
  gap: 8px;
  margin: 16px 16px 0;
  padding: 10px 12px;
  background: var(--warn-soft);
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  line-height: 1.6;
  color: #7a4a12;
}
.notice.calm { background: var(--surface-sunken); color: var(--ink-2); }

.metagrid { margin: 16px 16px 0; padding: 4px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.metagrid dl { display: grid; grid-template-columns: 76px 1fr; gap: 0; margin: 0; }
.metagrid dt { padding: 9px 0; font-size: 12.5px; color: var(--ink-3); }
.metagrid dd { margin: 0; padding: 9px 0; font-size: 13px; border-bottom: 1px solid var(--line); word-break: break-word; }
.metagrid dl > dt:last-of-type, .metagrid dl > dd:last-of-type { border-bottom: 0; }

.tabs { display: flex; gap: 2px; margin: 20px 16px 0; padding: 3px; background: var(--surface-sunken); border-radius: 10px; }
.tabs button { flex: 1; padding: 7px 0; border-radius: 8px; font-size: 13px; color: var(--ink-2); }
.tabs button.on { background: var(--surface); color: var(--ink); font-weight: 500; box-shadow: var(--shadow); }

.body-text { margin: 14px 16px 0; font-family: var(--font-text); font-size: 15px; line-height: 1.95; letter-spacing: 0.01em; }
.body-text p { margin: 0 0 0.9em; }
.body-text p:last-child { margin-bottom: 0; }

.clauses { margin: 12px 16px 0; }
.clause {
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.clause:last-child { border-bottom: 0; }
.clause-no { display: block; margin-bottom: 4px; font-size: 12.5px; font-weight: 600; color: var(--accent); }
.clause-body { margin: 0; font-family: var(--font-text); font-size: 15px; line-height: 1.9; }
.clause.flash { animation: flash 2.4s ease-out; }
@keyframes flash {
  0%, 22% { background: var(--accent-soft); box-shadow: 0 0 0 23px var(--accent-soft); }
  100% { background: transparent; box-shadow: 0 0 0 23px transparent; }
}
.clause.focus { border-radius: 10px; background: var(--accent-soft); padding: 12px; margin: 0 -12px; }

.rel { margin: 16px 16px 0; }
.rel-item { padding: 12px 14px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.rel-item + .rel-item { margin-top: 8px; }
.rel-type { display: inline-flex; padding: 3px 8px; border-radius: 6px; background: var(--accent-soft); color: var(--accent-ink); font-size: 11.5px; font-weight: 500; }
.rel-item.is-incoming .rel-type { background: var(--surface-sunken); color: var(--ink-2); }
.rel-title { margin: 8px 0 0; font-size: 14px; font-weight: 500; line-height: 1.5; }
.rel-note { margin: 5px 0 0; font-size: 12.5px; color: var(--ink-3); }
.rel-direction { display: block; margin-top: 6px; font-size: 11.5px; color: var(--ink-3); }

.disclaimer { margin: 22px 16px 0; padding: 12px 14px; border: 1px dashed var(--line-strong); border-radius: var(--radius-sm); font-size: 12px; line-height: 1.7; color: var(--ink-3); }

/* ---------- forms ---------- */

.field { margin-top: 16px; }
.field > label { display: block; margin-bottom: 8px; font-size: 13px; font-weight: 600; }
.field .help { margin: 8px 0 0; font-size: 12px; color: var(--ink-3); }
.field select, .field input[type="text"] {
  width: 100%;
  padding: 10px 12px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  outline: 0;
  font-size: 14px;
}
.field select:focus, .field input[type="text"]:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

.btn {
  display: block;
  width: 100%;
  padding: 12px;
  border-radius: 12px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
}
.btn:active { background: var(--accent-ink); }
.btn.secondary { background: var(--surface); color: var(--accent); border: 1px solid rgba(29, 107, 82, 0.3); }
.btn.quiet { background: var(--surface-sunken); color: var(--ink-2); }
.btn[disabled] { opacity: 0.5; }
.btn-row { display: flex; gap: 10px; }

/* ---------- states ---------- */

.state { padding: 44px 24px; text-align: center; }
.state .glyph { font-size: 26px; color: var(--ink-3); }
.state h3 { margin: 12px 0 0; font-size: 15px; font-weight: 600; }
.state p { margin: 8px 0 0; font-size: 13px; line-height: 1.7; color: var(--ink-2); }
.state .actions { display: flex; flex-direction: column; gap: 8px; margin-top: 18px; }
.state code {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 5px;
  background: var(--surface-sunken);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
}

.skeleton { padding: 16px; }
.sk-line, .sk-card { background: linear-gradient(90deg, #e7ebe6 25%, #eff2ee 37%, #e7ebe6 63%); background-size: 400% 100%; animation: shimmer 1.4s ease infinite; border-radius: 8px; }
.sk-card { height: 116px; margin-bottom: 10px; border-radius: var(--radius); }
.sk-line { height: 12px; margin-bottom: 9px; }
.sk-line.w60 { width: 60%; }
.sk-line.w40 { width: 40%; }
@keyframes shimmer { from { background-position: 100% 0; } to { background-position: 0 0; } }

/* ---------- tabbar ---------- */

.tabbar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  width: 100%;
  max-width: 480px;
  padding-bottom: env(safe-area-inset-bottom, 0px);
  background: rgba(252, 253, 252, 0.94);
  backdrop-filter: saturate(1.8) blur(14px);
  border-top: 1px solid var(--line);
}
.tabbar button {
  flex: 1;
  height: var(--tabbar);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 11px;
  color: var(--ink-3);
}
.tabbar button.on { color: var(--accent); }
.tabbar .glyph { font-size: 17px; line-height: 1; }

/* ---------- sheet & toast ---------- */

.layer { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; }
.layer[hidden] { display: none; }
.layer .scrim { position: absolute; inset: 0; background: rgba(23, 32, 28, 0.35); animation: fade 0.16s ease-out; }
.sheet-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 82vh;
  overflow-y: auto;
  padding: 8px 16px calc(20px + env(safe-area-inset-bottom, 0px));
  background: var(--bg);
  border-radius: 18px 18px 0 0;
  animation: rise 0.22s cubic-bezier(0.32, 0.72, 0.3, 1);
}
@keyframes rise { from { transform: translateY(14%); } to { transform: none; } }
.sheet-head { position: sticky; top: 0; display: flex; align-items: center; justify-content: space-between; padding: 12px 0; background: var(--bg); }
.sheet-head h2 { margin: 0; font-size: 16px; font-weight: 600; }
.sheet-group { margin-bottom: 18px; }
.sheet-group h3 { margin: 0 0 9px; font-size: 12.5px; font-weight: 600; color: var(--ink-2); }
.grabber { width: 36px; height: 4px; margin: 6px auto 2px; border-radius: 2px; background: var(--line-strong); }

.toast-layer {
  position: fixed;
  bottom: calc(var(--tabbar) + 26px);
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  justify-content: center;
  pointer-events: none;
}
.toast {
  max-width: 320px;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(23, 32, 28, 0.9);
  color: #fff;
  font-size: 13px;
  animation: fade 0.18s ease-out;
}
.toast[hidden] { display: none; }

/* ---------- misc ---------- */

.switch {
  position: relative;
  flex: none;
  width: 46px;
  height: 28px;
  border-radius: 999px;
  background: var(--line-strong);
  transition: background 0.16s ease;
}
.switch::after {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 1px 3px rgba(23, 32, 28, 0.28);
  transition: transform 0.16s ease;
}
.switch[aria-checked="true"] { background: var(--accent); }
.switch[aria-checked="true"]::after { transform: translateX(18px); }

.list-row { display: flex; align-items: center; gap: 12px; padding: 13px 14px; background: var(--surface); border-bottom: 1px solid var(--line); }
.list-row:first-of-type { border-radius: var(--radius) var(--radius) 0 0; }
.list-row:last-of-type { border-bottom: 0; border-radius: 0 0 var(--radius) var(--radius); }
.list-row:only-of-type { border-radius: var(--radius); }
.list-stack { border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); box-shadow: var(--shadow); }
.list-row .grow { flex: 1; min-width: 0; }
.list-row .primary { font-size: 14px; font-weight: 500; line-height: 1.5; }
.list-row .secondary { margin-top: 3px; font-size: 12px; color: var(--ink-3); }
.row-action { flex: none; padding: 6px 10px; border-radius: 8px; background: var(--surface-sunken); font-size: 12.5px; color: var(--ink-2); }
.row-action.danger { color: var(--danger); }

.profile { padding: 24px 16px 0; }
.profile .avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 52px;
  height: 52px;
  border-radius: 16px;
  background: var(--accent-soft);
  color: var(--accent-ink);
  font-family: var(--font-text);
  font-size: 20px;
  font-weight: 600;
}
.profile .name { margin: 12px 0 0; font-size: 17px; font-weight: 600; }
.profile .sub { margin: 4px 0 0; font-size: 12.5px; color: var(--ink-3); }

@media (min-width: 520px) {
  .app { border-left: 1px solid var(--line); border-right: 1px solid var(--line); }
}

/* ---------- 备案信息（工信部要求网站底部展示） ---------- */
.filing {
  padding: 4px 16px calc(var(--tabbar) + env(safe-area-inset-bottom, 0px) + 4px);
  text-align: center;
  font-size: 11px;
  line-height: 1.7;
  color: var(--ink-3);
}
.filing a { color: inherit; }
.filing .sep { margin: 0 6px; }
.filing .police { display: inline-flex; align-items: center; gap: 3px; vertical-align: middle; }
.filing .police img { display: block; width: 14px; height: 14px; }
.view.no-tabbar + .filing { padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 8px); }

