:root {
  --navy: #0B1F3A;
  --ink: #111827;
  --muted: #4B5563;
  --line: #D1D5DB;
  --bg: #F3F4F6;
  --card: #FFFFFF;
  --accent: #1D4ED8;
  --warn-bg: #FEF3C7;
  --warn-ink: #78350F;
  --err-bg: #FEE2E2;
  --err-ink: #7F1D1D;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { height: 100%; margin: 0; }
body {
  display: flex; flex-direction: column;
  font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--ink); background: var(--bg);
}
button { font: inherit; cursor: pointer; }

.bar {
  display: flex; align-items: center; gap: 8px; flex: none;
  min-height: 56px; padding: 6px 8px; padding-top: calc(6px + env(safe-area-inset-top));
  background: var(--navy); color: #fff;
}
.bar h1 { flex: 1; margin: 0; font-size: 1.25rem; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn {
  width: 48px; height: 48px; border: 0; border-radius: 12px;
  background: rgba(255,255,255,.14); color: #fff; font-size: 1.6rem; line-height: 1;
}
.icon-btn[hidden] { display: block; visibility: hidden; }
.icon-btn:active { background: rgba(255,255,255,.3); }

.demo { flex: none; padding: 6px 12px; background: var(--warn-bg); color: var(--warn-ink); font-size: .85rem; text-align: center; }
.banner { flex: none; padding: 10px 14px; font-size: .95rem; font-weight: 600; }
.banner.warn { background: var(--warn-bg); color: var(--warn-ink); }
.banner[hidden] { display: none; }

#view { flex: 1; min-height: 0; overflow: hidden; display: flex; flex-direction: column; }
.page { flex: 1; overflow-y: auto; padding: 16px; padding-bottom: calc(16px + env(safe-area-inset-bottom)); }

/* ---- bottom nav ---- */
.nav { flex: none; display: flex; background: var(--card); border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); }
.nav[hidden] { display: none; }
.tab {
  flex: 1; min-width: 0; min-height: 58px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  padding: 6px 4px; color: var(--muted); text-decoration: none; font-size: .82rem; font-weight: 700; border-top: 3px solid transparent;
}
.tab span { max-width: 100%; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tab i { width: 22px; height: 6px; border-radius: 3px; background: var(--c); opacity: .55; }
.tab.on { color: var(--c); border-top-color: var(--c); font-weight: 800; }
.tab.on i { opacity: 1; }
.tab:active { background: #E5E7EB; }

/* ---- home ---- */
.tiles { display: flex; flex-direction: column; gap: 14px; flex: 1; }
.tile {
  flex: 1; min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px;
  border-radius: 20px; color: #fff; text-decoration: none; text-align: center;
  font-size: 2rem; font-weight: 800; letter-spacing: .01em; box-shadow: 0 2px 0 rgba(0,0,0,.18);
}
.tile:active { transform: scale(.985); filter: brightness(.92); }
.tile small { font-size: .95rem; font-weight: 600; opacity: .92; }
.tile.skel { background: #E5E7EB; box-shadow: none; }
.home-foot { flex: none; margin-top: 14px; font-size: .85rem; color: var(--muted); text-align: center; }
.linkbtn { background: none; border: 0; color: var(--accent); font-weight: 700; padding: 10px; min-height: 44px; }
.home-page { display: flex; flex-direction: column; }

/* ---- list ---- */
.list-screen { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.toolbar { flex: none; padding: 10px 12px 6px; background: var(--card); border-bottom: 1px solid var(--line); }
.search {
  width: 100%; min-height: 48px; padding: 0 14px; font: inherit; font-size: 1.05rem;
  border: 2px solid #9CA3AF; border-radius: 12px; background: #fff; color: var(--ink);
}
.search:focus { outline: none; border-color: var(--accent); }
.chip-row { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.chip-row::-webkit-scrollbar { display: none; }
.fchip {
  flex: none; min-height: 44px; padding: 0 14px; border: 2px solid #9CA3AF; border-radius: 22px;
  background: #fff; color: var(--ink); font-weight: 600; white-space: nowrap;
}
.fchip.on { background: var(--navy); border-color: var(--navy); color: #fff; }
.fchip.lbl { border: 0; background: none; padding: 0 4px; color: var(--muted); font-weight: 700; }
.meta-row { display: flex; align-items: center; justify-content: space-between; padding-top: 4px; font-size: .85rem; color: var(--muted); }
.refresh { min-height: 44px; padding: 0 12px; border: 0; background: none; color: var(--accent); font-weight: 700; }
.refresh.spin::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; border: 2px solid var(--accent); border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }
@keyframes spin { to { transform: rotate(360deg); } }

.scroller { position: relative; flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior-y: contain; background: var(--card); }
.ptr { height: 0; overflow: hidden; display: flex; align-items: center; justify-content: center; font-size: .85rem; font-weight: 700; color: var(--muted); background: var(--bg); }
.spacer { position: relative; }
.win { position: absolute; left: 0; right: 0; top: 0; }
.pill { display: inline-block; padding: 4px 10px; border-radius: 10px; border: 1px solid rgba(0,0,0,.15); }
.row {
  display: flex; align-items: center; gap: 10px; padding: 0 14px 0 8px; border-left: 6px solid transparent;
  border-bottom: 1px solid #E5E7EB; color: inherit; text-decoration: none; background: var(--card);
}
.row:active { background: #E0E7FF; }
.row .txt { flex: 1; min-width: 0; }
.row .p { font-weight: 700; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .s { color: var(--muted); font-size: .95rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row .go { color: #6B7280; font-size: 1.6rem; }
.chip { flex: none; max-width: 38%; padding: 3px 10px; border-radius: 12px; font-size: .8rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 40px 20px; text-align: center; color: var(--muted); }
.skelrow { height: 76px; padding: 14px; border-bottom: 1px solid #E5E7EB; }
.skelrow i { display: block; height: 14px; border-radius: 7px; background: #E5E7EB; margin-bottom: 10px; animation: pulse 1.2s ease-in-out infinite; }
.skelrow i:first-child { width: 55%; }
.skelrow i:last-child { width: 35%; margin: 0; }
@keyframes pulse { 50% { opacity: .45; } }

.errbox { margin: 16px; padding: 16px; border-radius: 12px; background: var(--err-bg); color: var(--err-ink); font-weight: 600; }
.btn { display: inline-block; min-height: 48px; padding: 0 20px; margin-top: 12px; border: 0; border-radius: 12px; background: var(--navy); color: #fff; font-weight: 700; }

/* ---- detail ---- */
.detail h2 { margin: 0 0 4px; font-size: 1.6rem; line-height: 1.2; overflow-wrap: anywhere; }
.detail .sub { margin: 0 0 16px; color: var(--muted); font-size: 1.05rem; overflow-wrap: anywhere; }
.sect { margin: 20px 0 6px; font-size: .85rem; font-weight: 800; letter-spacing: .08em; text-transform: uppercase; color: var(--accent); }
.field { padding: 12px 0; border-bottom: 1px solid var(--line); }
.field dt { font-weight: 800; font-size: 1.1rem; margin-bottom: 4px; }
.field dd { margin: 0; font-size: 1.05rem; white-space: pre-wrap; overflow-wrap: anywhere; }
.field dd.blank { color: #6B7280; }
.cardbox { background: var(--card); border-radius: 16px; padding: 4px 16px 8px; }
.detail dl { margin: 0; }

/* ---- search row, filters, active chips ---- */
.searchrow { display: flex; gap: 8px; }
.searchrow .search { flex: 1; min-width: 0; }
.fbtn { flex: none; min-height: 48px; padding: 0 14px; border: 2px solid #9CA3AF; border-radius: 12px; background: #fff; color: var(--ink); font-weight: 700; }
.fbtn.on { border-color: var(--accent); color: var(--accent); }
.badge { display: inline-block; min-width: 22px; margin-left: 6px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: #fff; font-size: .8rem; line-height: 22px; text-align: center; }
.badge[hidden] { display: none; }
.active { display: flex; gap: 6px; overflow-x: auto; padding: 8px 0 2px; scrollbar-width: none; }
.active::-webkit-scrollbar { display: none; }
.active[hidden], .chip-row[hidden] { display: none; }
.achip { flex: none; min-height: 40px; padding: 0 12px; border: 1px solid #A5B4FC; border-radius: 20px; background: #EEF2FF; color: #1E1B4B; font-weight: 600; white-space: nowrap; }
.achip.clear { background: #fff; border-color: var(--line); color: var(--muted); }
.banner.info { background: #DBEAFE; color: #1E3A8A; }
.tile small.busy::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 8px; border: 2px solid #fff; border-right-color: transparent; border-radius: 50%; animation: spin .8s linear infinite; vertical-align: -1px; }

/* ---- filter & sort panel ---- */
.list-screen { position: relative; }
.sheet-wrap { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; justify-content: flex-end; background: rgba(0,0,0,.45); }
.sheet-wrap[hidden] { display: none; }
.sheet { display: flex; flex-direction: column; max-height: 94%; background: #fff; border-radius: 18px 18px 0 0; }
.sheet-head { flex: none; display: flex; align-items: center; gap: 8px; padding: 10px 12px 10px 18px; border-bottom: 1px solid var(--line); }
.sheet-head b { flex: 1; font-size: 1.2rem; }
.icon-btn.dark { background: #E5E7EB; color: var(--ink); }
.sheet-body { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 16px 12px; }
.sheet-foot { flex: none; padding: 10px 16px calc(10px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.btn.wide { display: block; width: 100%; margin: 0; }
.sheet details { border-bottom: 1px solid var(--line); }
.sheet summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; min-height: 52px; font-weight: 600; font-size: 1.05rem; cursor: pointer; }
.sheet summary .cnt { flex: none; max-width: 55%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--accent); font-size: .85rem; font-weight: 600; }
.opts { padding: 0 0 12px; }
.opt { display: flex; align-items: center; gap: 12px; min-height: 44px; }
.opt input { width: 22px; height: 22px; flex: none; }
.opt .vt { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.opt .vn { flex: none; color: var(--muted); font-size: .85rem; }
.vals { max-height: 240px; overflow-y: auto; margin-top: 6px; border-top: 1px solid #E5E7EB; }
.seg { display: flex; gap: 6px; margin-bottom: 8px; }
.segopt { flex: 1; }
.segopt input { position: absolute; opacity: 0; pointer-events: none; }
.segopt span { display: flex; align-items: center; justify-content: center; min-height: 44px; border: 2px solid #9CA3AF; border-radius: 10px; font-weight: 600; text-align: center; padding: 0 4px; }
.segopt input:checked + span { background: var(--navy); border-color: var(--navy); color: #fff; }
.ftext, .sheet select { width: 100%; min-height: 46px; padding: 0 12px; margin-bottom: 8px; font: inherit; border: 2px solid #9CA3AF; border-radius: 10px; background: #fff; color: var(--ink); }
.hint { margin: 6px 0 0; color: var(--muted); font-size: .88rem; }
.hint.tips { padding: 12px 0 4px; }

/* ---- install card (home screen, browser only) ---- */
.install { flex: none; display: flex; align-items: center; gap: 10px; margin-bottom: 14px; padding: 10px 4px 10px 14px; background: #EEF2FF; border: 1px solid #A5B4FC; border-radius: 14px; }
.install[hidden] { display: none; }
.install .itext { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.install .itext b { font-size: 1.05rem; }
.install .itext span { color: var(--muted); font-size: .9rem; }
.install .btn { flex: none; margin: 0; min-height: 44px; }
.install .ix { flex: none; width: 44px; height: 44px; border: 0; background: none; color: var(--muted); font-size: 1.7rem; line-height: 1; }
.fbody[hidden] { display: none; }
