/* ============================================================
   声学标准速查 PWA — 移动优先样式
   主题：深色为默认（对齐 IDE dark），支持浅色跟随系统
   ============================================================ */

:root {
  --bg:            #0d1117;
  --bg-elev:       #161b22;
  --bg-elev-2:     #1c2129;
  --bg-input:      #010409;
  --border:        #262c36;
  --border-strong: #3d444d;

  --text:          #e6edf3;
  --text-dim:      #9aa4b1;
  --text-faint:    #6e7681;

  --accent:        #2f81f7;
  --accent-soft:   rgba(47, 129, 247, .14);
  --green:         #3fb950;
  --amber:         #d29922;
  --red:           #f85149;
  --purple:        #a371f7;

  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-full: 999px;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 58px;

  --shadow: 0 8px 28px rgba(0, 0, 0, .45);
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #f6f8fa; --bg-elev: #ffffff; --bg-elev-2: #f0f3f6;
    --bg-input: #ffffff;
    --border: #d8dee4; --border-strong: #b8c0c9;
    --text: #1f2328; --text-dim: #5a6572; --text-faint: #818b98;
    --accent: #0969da; --accent-soft: rgba(9, 105, 218, .10);
    --shadow: 0 8px 28px rgba(31, 35, 40, .14);
  }
}

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

/* hidden 属性必须始终生效。
   下方的 .filters / .iconbtn / .tab__dot 均设置了 display，
   优先级高于浏览器默认的 [hidden]{display:none}，需显式覆盖。 */
[hidden] { display: none !important; }

html, body {
  margin: 0; padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
               "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  overscroll-behavior-y: none;
}

body { min-height: 100dvh; }

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

.app {
  display: flex; flex-direction: column;
  min-height: 100dvh;
  max-width: 760px; margin: 0 auto;
  background: var(--bg);
}

/* ── 顶栏 ─────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  padding: calc(var(--safe-top) + 10px) 14px 0;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.6) blur(14px);
  -webkit-backdrop-filter: saturate(1.6) blur(14px);
  border-bottom: 1px solid var(--border);
}
.topbar__row { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.brand__icon { width: 26px; height: 26px; color: var(--accent); flex: none; }
.brand__text { min-width: 0; }
.brand h1 { margin: 0; font-size: 16px; font-weight: 650; letter-spacing: .2px; }
.brand__sub { display: block; font-size: 11.5px; color: var(--text-faint); margin-top: 1px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.iconbtn {
  width: 36px; height: 36px; flex: none;
  display: grid; place-items: center;
  border-radius: var(--r-md);
  background: var(--bg-elev); border: 1px solid var(--border);
  color: var(--text-dim);
  transition: background .15s, color .15s;
}
.iconbtn:active { background: var(--bg-elev-2); color: var(--text); }
.iconbtn svg { width: 19px; height: 19px; }

/* ── 搜索框 ───────────────────────────────────────── */
.searchbar {
  position: relative; display: flex; align-items: center;
  margin: 11px 0 10px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  transition: border-color .15s, box-shadow .15s;
}
.searchbar:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.searchbar__icon { position: absolute; left: 11px; width: 17px; height: 17px; color: var(--text-faint); pointer-events: none; }
.searchbar input {
  flex: 1; min-width: 0;
  padding: 10px 36px 10px 36px;
  background: none; border: none; outline: none;
  font-size: 15px;
}
.searchbar input::placeholder { color: var(--text-faint); }
.searchbar input::-webkit-search-cancel-button { display: none; }
.searchbar__clear {
  position: absolute; right: 7px;
  width: 26px; height: 26px; display: grid; place-items: center;
  border-radius: var(--r-full); background: var(--bg-elev-2); color: var(--text-dim);
}
.searchbar__clear svg { width: 14px; height: 14px; }

/* ── 筛选 chips ───────────────────────────────────── */
.chips {
  display: flex; gap: 7px;
  overflow-x: auto; padding-bottom: 10px;
  scrollbar-width: none; -ms-overflow-style: none;
}
.chips::-webkit-scrollbar { display: none; }
.chips--wrap { flex-wrap: wrap; overflow: visible; }
.chip {
  flex: none;
  padding: 5px 11px;
  border-radius: var(--r-full);
  background: var(--bg-elev);
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-size: 12.5px; white-space: nowrap;
  transition: background .15s, color .15s, border-color .15s;
}
.chip.is-active { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); font-weight: 600; }
.chip--btn { display: inline-flex; align-items: center; gap: 5px; }
.chip--btn svg { width: 14px; height: 14px; }
.chip__n { opacity: .65; margin-left: 4px; font-variant-numeric: tabular-nums; }

/* ── 筛选面板 ─────────────────────────────────────── */
.filters {
  padding: 14px;
  background: var(--bg-elev);
  border-bottom: 1px solid var(--border);
  display: grid; gap: 16px;
}
.filters__group h3 {
  margin: 0 0 8px; font-size: 12px; font-weight: 600;
  color: var(--text-faint); text-transform: uppercase; letter-spacing: .6px;
}

/* ── 工具条 ───────────────────────────────────────── */
.main { flex: 1; padding: 0 14px calc(var(--tabbar-h) + var(--safe-bottom) + 18px); }
.toolbar {
  position: sticky; top: calc(var(--safe-top) + 118px); z-index: 20;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 10px 0;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.toolbar__count { font-size: 12.5px; color: var(--text-dim); font-variant-numeric: tabular-nums; }
.toolbar__actions { display: flex; align-items: center; gap: 8px; }
.select {
  padding: 6px 26px 6px 10px;
  background: var(--bg-elev) no-repeat right 8px center/9px 6px;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 10 6'><path d='M1 1l4 4 4-4' stroke='%239aa4b1' stroke-width='1.4' fill='none' stroke-linecap='round'/></svg>");
  border: 1px solid var(--border); border-radius: var(--r-sm);
  font-size: 12.5px; color: var(--text-dim);
  appearance: none; -webkit-appearance: none;
}

/* ── 列表 ─────────────────────────────────────────── */
.list { display: grid; gap: 9px; }

.card {
  padding: 12px 13px;
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--r-lg);
  text-align: left; width: 100%;
  display: block;
  transition: transform .12s, border-color .15s, background .15s;
}
.card:active { transform: scale(.985); border-color: var(--border-strong); }
.card__top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-bottom: 6px; }
.card__no {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
  font-size: 13px; font-weight: 650; color: var(--accent);
  letter-spacing: .2px;
}
.card__title { margin: 0; font-size: 14px; font-weight: 500; line-height: 1.42; }
.card__title-en {
  margin: 3px 0 0; font-size: 11.5px; color: var(--text-faint);
  line-height: 1.4;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.card__foot {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 9px; padding-top: 9px; border-top: 1px solid var(--border);
  font-size: 11.5px; color: var(--text-faint);
}
.card__foot span { display: inline-flex; align-items: center; gap: 4px; }
.card__ics { font-family: ui-monospace, Menlo, Consolas, monospace; }

.badge {
  padding: 2px 7px; border-radius: var(--r-full);
  font-size: 10.5px; font-weight: 600; letter-spacing: .2px;
  white-space: nowrap; border: 1px solid transparent;
}
.badge--current   { background: rgba(63,185,80,.13);  color: var(--green);  border-color: rgba(63,185,80,.3); }
.badge--upcoming  { background: rgba(210,153,34,.14); color: var(--amber);  border-color: rgba(210,153,34,.32); }
.badge--withdrawn { background: rgba(248,81,73,.12);  color: var(--red);    border-color: rgba(248,81,73,.28); }
.badge--draft     { background: rgba(163,113,247,.14);color: var(--purple); border-color: rgba(163,113,247,.3); }
.badge--free      { background: rgba(47,129,247,.13); color: var(--accent); border-color: rgba(47,129,247,.28); }
.badge--org       { background: var(--bg-elev-2); color: var(--text-dim); border-color: var(--border); }
.badge--new       { background: linear-gradient(135deg, var(--accent), var(--purple));
                     color: #fff; border-color: transparent; }

.card__watch { margin-left: auto; color: var(--text-faint); display: inline-flex; }
.card__watch svg { width: 15px; height: 15px; }
.card__watch.is-on { color: var(--amber); }

/* ── 空状态 ───────────────────────────────────────── */
.empty { text-align: center; padding: 56px 20px; color: var(--text-faint); }
.empty svg { width: 40px; height: 40px; opacity: .4; margin-bottom: 10px; }
.empty p { margin: 0 0 4px; font-size: 14px; color: var(--text-dim); }
.empty span { font-size: 12.5px; }

/* ── 底部标签栏 ───────────────────────────────────── */
.tabbar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 760px; z-index: 45;
  display: grid; grid-template-columns: repeat(4, 1fr);
  background: color-mix(in srgb, var(--bg-elev) 94%, transparent);
  backdrop-filter: saturate(1.6) blur(16px);
  -webkit-backdrop-filter: saturate(1.6) blur(16px);
  border-top: 1px solid var(--border);
  padding-bottom: var(--safe-bottom);
}
.tab {
  position: relative;
  height: var(--tabbar-h);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--text-faint);
  font-size: 10.5px;
  transition: color .15s;
}
.tab svg { width: 21px; height: 21px; }
.tab.is-active { color: var(--accent); }
.tab__dot {
  position: absolute; top: 7px; left: 50%; margin-left: 4px;
  min-width: 16px; height: 16px; padding: 0 4px;
  display: grid; place-items: center;
  background: var(--text-faint); color: var(--bg);
  border-radius: var(--r-full);
  font-size: 10px; font-weight: 700; font-style: normal;
}
.tab__dot--accent { background: var(--accent); color: #fff; }

/* ── 详情抽屉 ─────────────────────────────────────── */
.sheet { position: fixed; inset: 0; z-index: 90; }
.sheet__scrim {
  position: absolute; inset: 0;
  background: rgba(0, 0, 0, .55);
  animation: fade .2s ease;
}
.sheet__body {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  width: 100%; max-width: 760px;
  max-height: 92dvh; overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-elev);
  border-top: 1px solid var(--border);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 8px 18px calc(22px + var(--safe-bottom));
  box-shadow: var(--shadow);
  animation: slideUp .26s cubic-bezier(.2, .8, .3, 1);
}
.sheet__grab { width: 36px; height: 4px; border-radius: 2px; background: var(--border-strong); margin: 0 auto 12px; }
.sheet__head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.sheet__badges { display: flex; flex-wrap: wrap; gap: 6px; }
.sheet__title {
  margin: 12px 0 0; font-size: 18px; font-weight: 650; line-height: 1.38;
}
.sheet__title-en { margin: 6px 0 0; font-size: 12.5px; color: var(--text-faint); line-height: 1.5; }

.meta { margin: 18px 0 0; display: grid; grid-template-columns: 86px 1fr; gap: 9px 12px; }
.meta dt { font-size: 12.5px; color: var(--text-faint); }
.meta dd { margin: 0; font-size: 13.5px; word-break: break-word; }
.meta dd .mono { font-family: ui-monospace, Menlo, Consolas, monospace; }

.sheet__rel { margin-top: 18px; display: grid; gap: 9px; }
.relbox {
  padding: 11px 12px; border-radius: var(--r-md);
  background: var(--bg-elev-2); border: 1px solid var(--border);
}
.relbox h4 { margin: 0 0 7px; font-size: 12px; color: var(--text-faint); font-weight: 600; }
.relbox ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 5px; }
.relbox li { display: flex; gap: 8px; font-size: 12.5px; align-items: baseline; }
.relbox code { font-family: ui-monospace, Menlo, Consolas, monospace; color: var(--accent); font-size: 12px; flex: none; }
.relbox span { color: var(--text-dim); }

.sheet__actions { display: flex; gap: 9px; margin-top: 20px; }
.btn {
  flex: 1; padding: 11px 14px;
  border-radius: var(--r-md);
  font-size: 13.5px; font-weight: 600; text-align: center;
  display: inline-flex; align-items: center; justify-content: center;
  transition: filter .15s, background .15s;
}
.btn--primary { background: var(--accent); color: #fff; }
.btn--primary:active { filter: brightness(.9); }
.btn--ghost { background: var(--bg-elev-2); border: 1px solid var(--border); color: var(--text); }
.btn--ghost:active { background: var(--bg); }
.sheet__note { margin: 14px 0 0; font-size: 11.5px; color: var(--text-faint); line-height: 1.6; }

/* ── Toast ────────────────────────────────────────── */
.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--safe-bottom) + 16px);
  transform: translateX(-50%);
  z-index: 100;
  padding: 9px 16px; border-radius: var(--r-full);
  background: var(--text); color: var(--bg);
  font-size: 13px; font-weight: 500;
  box-shadow: var(--shadow);
  animation: fade .2s ease;
}

@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes slideUp { from { transform: translate(-50%, 100%) } to { transform: translate(-50%, 0) } }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

/* 桌面端微调 */
@media (min-width: 700px) {
  .main { padding-left: 22px; padding-right: 22px; }
  .list { grid-template-columns: repeat(2, 1fr); }
  .sheet__body { border-radius: var(--r-lg) var(--r-lg) 0 0; }
}
