:root {
  --bg: #0a0e14; --surface: #141b25; --surface2: #1c2634; --border: #2e3b4e;
  --text: #f4f7fb; --muted: #aab6c8; --accent: #4cc2ff; --accent-ink: #00131f;
  --red: #ff5964; --red-bg: #3a1218; --amber: #ffc247; --amber-bg: #3a2c08;
  --green: #3ddc84; --green-bg: #0f3321;
  --tap: 56px; --radius: 14px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}
[data-theme="light"] {
  --bg: #ffffff; --surface: #f2f5f9; --surface2: #e6ebf2; --border: #b9c4d3;
  --text: #0b0f15; --muted: #3d4a5c; --accent: #0058b8; --accent-ink: #ffffff;
  --red: #c4001a; --red-bg: #ffe3e6; --amber: #8a5300; --amber-bg: #fff0cc;
  --green: #00693a; --green-bg: #d8f5e5;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font: 18px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overscroll-behavior-y: none;
  padding-top: calc(56px + var(--safe-t));
  padding-bottom: calc(76px + var(--safe-b));
}
a { color: var(--accent); }
button { font: inherit; color: inherit; }
h1, h2, h3 { line-height: 1.2; margin: 0; }

/* top bar */
.topbar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  height: calc(56px + var(--safe-t)); padding: var(--safe-t) 10px 0 14px;
  display: flex; align-items: center; gap: 10px;
  background: var(--bg); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 800; font-size: 20px; color: var(--text); text-decoration: none; margin-right: auto; }
.logo { display: inline-grid; place-items: center; width: 32px; height: 32px; border-radius: 8px; background: var(--red); color: #fff; font-size: 26px; line-height: 1; font-weight: 900; }
.iconbtn { width: 48px; height: 48px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); font-size: 22px; cursor: pointer; }
.netdot { width: 12px; height: 12px; border-radius: 50%; background: var(--green); }
.netdot.off { background: var(--amber); }
.timerchip { font-variant-numeric: tabular-nums; font-weight: 800; background: var(--red); color: #fff; padding: 10px 12px; border-radius: 12px; text-decoration: none; }

main { max-width: 760px; width: 100%; overflow-x: clip; margin: 0 auto; padding: 12px 14px 24px; outline: none; }

/* tab bar */
.tabbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 20; display: flex;
  background: var(--bg); border-top: 1px solid var(--border); padding-bottom: var(--safe-b);
}
.tabbar a { flex: 1; min-height: 64px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; color: var(--muted); text-decoration: none; font-size: 14px; font-weight: 700; }
.tabbar a .ti { font-size: 24px; line-height: 1; }
.tabbar a.active { color: var(--accent); background: var(--surface); }
.actionbar {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 21; display: flex; gap: 8px;
  padding: 8px 10px calc(8px + var(--safe-b)); background: var(--bg); border-top: 1px solid var(--border);
}
.actionbar[hidden], .timerchip[hidden], .tabbar[hidden] { display: none; }
.abtn {
  flex: 1; min-height: var(--tap); border-radius: var(--radius); border: 2px solid var(--border);
  background: var(--surface); font-weight: 800; font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px; padding: 0 6px;
}
.abtn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.abtn.on { border-color: var(--amber); color: var(--amber); }
.abtn:active { transform: scale(.97); }

/* search + chips */
.search {
  width: 100%; min-height: 60px; font-size: 20px; padding: 0 16px; border-radius: var(--radius);
  background: var(--surface); color: var(--text); border: 2px solid var(--border); outline: none;
  -webkit-appearance: none; appearance: none;
}
.search:focus { border-color: var(--accent); }
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 4px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: 0 0 auto; min-height: 48px; padding: 0 16px; border-radius: 999px; border: 2px solid var(--border);
  background: var(--surface); font-weight: 700; font-size: 16px; cursor: pointer; white-space: nowrap;
}
.chip.active { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }

.sect-h { margin: 20px 0 8px; font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); font-weight: 800; }
.sect-h.em { color: var(--red); }

/* cards */
.grid2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.card .txt { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.card {
  display: flex; flex-direction: column; justify-content: center; gap: 4px; min-height: var(--tap);
  padding: 12px 14px; border-radius: var(--radius); background: var(--surface); border: 2px solid var(--border);
  color: var(--text); text-decoration: none; font-weight: 700;
}
.card:active { background: var(--surface2); }
.card small { color: var(--muted); font-weight: 600; font-size: 14px; }
.card.em { border-color: var(--red); background: var(--red-bg); }
.card.em .name { color: var(--text); }
.grid2 .card { min-height: 84px; }
.list { display: flex; flex-direction: column; gap: 8px; }
.list .card { flex-direction: row; align-items: center; justify-content: space-between; }
.badge { display: inline-block; font-size: 12px; font-weight: 800; padding: 3px 8px; border-radius: 999px; letter-spacing: .04em; text-transform: uppercase; background: var(--surface2); color: var(--muted); }
.badge.em { background: var(--red); color: #fff; }
.badge.warn { background: var(--amber); color: #1a1200; }
.empty { padding: 28px 8px; text-align: center; color: var(--muted); }
.tip { margin-top: 14px; padding: 12px 14px; border: 2px dashed var(--border); border-radius: var(--radius); color: var(--muted); font-size: 15px; display: flex; gap: 10px; align-items: center; }
.tip button { min-width: 48px; min-height: 48px; border-radius: 10px; border: 1px solid var(--border); background: var(--surface); }
.foot { margin: 22px 0 8px; font-size: 13px; color: var(--muted); border-top: 1px solid var(--border); padding-top: 12px; }

/* condition */
.chead h1 { font-size: 26px; margin-bottom: 8px; }
.tags { display: flex; gap: 6px; flex-wrap: wrap; }
.glance { margin: 14px 0; padding: 14px; border-radius: var(--radius); border: 3px solid var(--amber); background: var(--amber-bg); }
.glance h2 { font-size: 14px; letter-spacing: .08em; text-transform: uppercase; color: var(--amber); margin-bottom: 8px; }
.glance ol { margin: 0; padding-left: 26px; font-weight: 800; font-size: 19px; }
.glance li { margin: 8px 0; }
.secnav { position: sticky; top: calc(56px + var(--safe-t)); z-index: 10; display: flex; gap: 6px; overflow-x: auto; padding: 8px 0; background: var(--bg); scrollbar-width: none; }
.secnav::-webkit-scrollbar { display: none; }
.secnav button { flex: 0 0 auto; min-height: 44px; padding: 0 14px; border-radius: 10px; border: 2px solid var(--border); background: var(--surface); font-weight: 700; font-size: 15px; cursor: pointer; }
details.sec { margin: 12px 0; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); scroll-margin-top: 120px; }
details.sec > summary { list-style: none; cursor: pointer; display: flex; align-items: center; justify-content: space-between; gap: 8px; min-height: var(--tap); padding: 8px 14px; font-weight: 800; font-size: 19px; }
details.sec > summary::-webkit-details-marker { display: none; }
details.sec > summary::after { content: "▾"; color: var(--muted); }
details.sec:not([open]) > summary::after { content: "▸"; }
details.sec .body { padding: 0 10px 12px; }
details.sec.s-actions { border-color: var(--accent); }
details.sec.s-escalate { border-color: var(--red); }
details.sec.s-escalate > summary { color: var(--red); }
.prog { font-size: 14px; font-weight: 800; color: var(--muted); margin-left: auto; margin-right: 8px; }
.bar { height: 6px; border-radius: 3px; background: var(--surface2); margin: 0 4px 8px; overflow: hidden; }
.bar > i { display: block; height: 100%; width: 0; background: var(--green); transition: width .15s; }

ul.bul { list-style: none; margin: 0; padding: 0; }
ul.bul li { padding: 10px 6px 10px 22px; position: relative; border-top: 1px solid var(--border); }
ul.bul li:first-child { border-top: 0; }
ul.bul li::before { content: "•"; position: absolute; left: 6px; color: var(--muted); font-weight: 900; }
ul.bul li.call, .step.call .t { font-weight: 800; }
ul.bul li.call { color: var(--red); }
ul.bul li.call::before { content: "!"; color: var(--red); left: 7px; }

.steps { display: flex; flex-direction: column; gap: 8px; margin: 0; padding: 0; list-style: none; }
.step {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; text-align: left; min-height: var(--tap);
  padding: 12px; border-radius: 12px; border: 2px solid var(--border); background: var(--bg); cursor: pointer;
}
.step .n { flex: 0 0 34px; height: 34px; border-radius: 50%; border: 3px solid var(--muted); display: grid; place-items: center; font-weight: 900; font-size: 15px; color: var(--muted); }
.step .t { flex: 1; }
.step.call { border-color: var(--red); }
.step.call .n { border-color: var(--red); color: var(--red); }
.step .callpill { display: inline-block; background: var(--red); color: #fff; font-size: 12px; font-weight: 900; padding: 2px 8px; border-radius: 999px; margin-right: 6px; vertical-align: 1px; }
.step.done { background: var(--green-bg); border-color: var(--green); }
.step.done .n { background: var(--green); border-color: var(--green); color: #00150a; }
.step.done .n::after { content: "✓"; }
.step.done .n span { display: none; }
.step.done .t { opacity: .72; text-decoration: line-through; text-decoration-thickness: 1.5px; }
.verify { margin: 0 4px 10px; padding: 10px 12px; border-radius: 10px; background: var(--amber-bg); border: 2px solid var(--amber); color: var(--text); font-weight: 700; font-size: 15px; }

/* tools */
.tcard { margin: 12px 0; border: 2px solid var(--border); border-radius: var(--radius); background: var(--surface); padding: 12px; }
.tcard h2 { font-size: 19px; margin-bottom: 10px; }
table.kv { width: 100%; border-collapse: collapse; font-size: 16px; }
table.kv td { padding: 10px 6px; border-top: 1px solid var(--border); vertical-align: top; }
table.kv td:first-child { font-weight: 800; white-space: nowrap; padding-right: 12px; }
.note { font-size: 14px; color: var(--muted); margin-top: 8px; }
.timer-big { font-size: 56px; font-weight: 900; text-align: center; font-variant-numeric: tabular-nums; }
.timer-sub { text-align: center; font-weight: 800; font-size: 20px; margin: 4px 0; }
.timer-sub.alert { color: #fff; background: var(--red); border-radius: 10px; padding: 6px; animation: blink 0.6s steps(2) infinite; }
@keyframes blink { 50% { opacity: .45; } }
.tbtns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 10px; }
.tbtns .abtn { min-height: 64px; font-size: 18px; }
.tlog { margin-top: 10px; font-size: 15px; color: var(--muted); font-variant-numeric: tabular-nums; max-height: 150px; overflow: auto; }
.seg { margin-bottom: 12px; }
.seg h3 { font-size: 15px; color: var(--muted); margin-bottom: 6px; }
.seg .opts { display: flex; flex-direction: column; gap: 6px; }
.opt { min-height: 48px; border-radius: 10px; border: 2px solid var(--border); background: var(--bg); text-align: left; padding: 6px 12px; font-weight: 600; cursor: pointer; display: flex; gap: 10px; }
.opt b { min-width: 20px; }
.opt.sel { border-color: var(--accent); background: var(--accent); color: var(--accent-ink); }
.gcs-total { font-size: 34px; font-weight: 900; text-align: center; }
.rass-row td:first-child { font-size: 20px; }
.lines p { margin: 8px 0; }

.toast { position: fixed; left: 50%; bottom: calc(92px + var(--safe-b)); transform: translateX(-50%) translateY(20px); background: var(--text); color: var(--bg); padding: 12px 18px; border-radius: 12px; font-weight: 700; opacity: 0; pointer-events: none; transition: .2s; z-index: 50; max-width: 90%; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

.about h2 { margin: 18px 0 6px; font-size: 20px; }
.about p, .about li { font-size: 16px; }
.discl { border: 3px solid var(--red); background: var(--red-bg); border-radius: var(--radius); padding: 14px; font-weight: 700; }
.btnrow { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 8px; }
.btnrow .abtn { flex: 1 1 200px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (min-width: 700px) { body { font-size: 19px; } .grid2 { grid-template-columns: repeat(4, minmax(0, 1fr)); } }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
@media print { .topbar, .tabbar, .actionbar { display: none; } body { padding: 0; } }
