:root {
  --bg: #f7f6f2;
  --surface: #ffffff;
  --ink: #1d2327;
  --muted: #5b6770;
  --line: #e2e0d8;
  --accent: #00878f;
  --accent-ink: #ffffff;
  --accent-soft: #e0f2f2;
  --warn-bg: #fff4e0;
  --warn-ink: #7a4b00;
  --see-bg: #eaf6ea;
  --see-line: #2e7d32;
  --code-bg: #f1f3f4;
  --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #141719;
    --surface: #1d2124;
    --ink: #e8eaeb;
    --muted: #a3adb4;
    --line: #2e3438;
    --accent: #2bb3ba;
    --accent-ink: #0b1213;
    --accent-soft: #163236;
    --warn-bg: #3a2b10;
    --warn-ink: #ffd591;
    --see-bg: #18301b;
    --see-line: #66bb6a;
    --code-bg: #121517;
    color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #141719; --surface: #1d2124; --ink: #e8eaeb; --muted: #a3adb4; --line: #2e3438;
  --accent: #2bb3ba; --accent-ink: #0b1213; --accent-soft: #163236; --warn-bg: #3a2b10;
  --warn-ink: #ffd591; --see-bg: #18301b; --see-line: #66bb6a; --code-bg: #121517;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 17px/1.55 "Segoe UI", system-ui, -apple-system, Roboto, Helvetica, Arial, sans-serif;
}
a { color: var(--accent); }
h1 { font-size: 1.9rem; line-height: 1.2; margin: .2rem 0 1rem; }
h2 { font-size: 1.2rem; margin: 0 0 .6rem; }
h3 { font-size: 1.05rem; margin: 1.2rem 0 .5rem; }
code { font-family: Consolas, "SFMono-Regular", Menlo, monospace; font-size: .92em; }
ul, ol { padding-left: 1.3rem; }
li { margin: .25rem 0; }

/* header + progress */
.top { position: sticky; top: env(safe-area-inset-top, 0px); z-index: 5; background: var(--surface); border-bottom: 1px solid var(--line); }
.topin { max-width: 820px; margin: 0 auto; padding: .55rem 16px; display: flex; justify-content: space-between; align-items: center; gap: 1rem; }
.brand { font-weight: 700; color: var(--ink); text-decoration: none; font-size: .95rem; }
.toplink { font-size: .9rem; white-space: nowrap; }
.progress { height: 4px; background: var(--line); }
.progress .bar { height: 100%; background: var(--accent); }
.dots { max-width: 820px; margin: 0 auto; padding: .45rem 16px; display: flex; gap: 6px; flex-wrap: wrap; }
.dot {
  min-width: 30px; height: 30px; border-radius: 15px; display: inline-grid; place-items: center;
  font-size: .85rem; font-weight: 700; text-decoration: none; color: var(--muted);
  border: 2px solid var(--line); background: var(--surface);
}
.dot.done { background: var(--accent-soft); border-color: var(--accent); color: var(--accent); }
.dot.here { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

main { max-width: 820px; margin: 0 auto; padding: 1.2rem 16px 3rem; }
.kicker { color: var(--muted); font-weight: 600; margin: 0; display: flex; gap: .8rem; flex-wrap: wrap; align-items: center; }
.time { background: var(--accent-soft); color: var(--accent); border-radius: 99px; padding: .05rem .6rem; font-size: .85rem; font-weight: 700; white-space: nowrap; }
.lead { font-size: 1.12rem; }
.small { font-size: .9rem; color: var(--muted); }

.card, .adding, .see, .trouble, .callout {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem 1.1rem; margin: 1rem 0;
}
.adding { border-left: 5px solid var(--accent); }
.callout.android { border-left: 5px solid #5c6bc0; }
.callout.safety { background: var(--warn-bg); color: var(--warn-ink); border-color: transparent; }
.callout.safety h2 { color: inherit; }
.warn { background: var(--warn-bg); color: var(--warn-ink); border-radius: var(--radius); padding: .7rem 1rem; font-weight: 600; }
.note { background: var(--accent-soft); border-radius: var(--radius); padding: .75rem 1rem; margin: 1rem 0; }
.see { background: var(--see-bg); border-color: transparent; border-left: 5px solid var(--see-line); }
.trouble details { border-top: 1px solid var(--line); padding: .55rem 0; }
.trouble details:first-of-type { border-top: 0; }
.trouble summary { cursor: pointer; font-weight: 600; }
.trouble details p { margin: .5rem 0 .2rem; }

/* diagram */
.diagram { margin: 1rem 0; }
.diagram .scroll { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); background: #fbfaf7; -webkit-overflow-scrolling: touch; }
.diagram img { display: block; width: 100%; min-width: 640px; height: auto; }
.diagram figcaption { font-size: .88rem; color: var(--muted); margin-top: .4rem; }

/* checklist */
.checklist { list-style: none; padding: 0; margin: 0; }
.checklist li { margin: 0; border-top: 1px solid var(--line); }
.checklist li:first-child { border-top: 0; }
.checklist label { display: flex; gap: .75rem; align-items: flex-start; padding: .6rem .1rem; cursor: pointer; }
.checklist input { width: 22px; height: 22px; margin: .15rem 0 0; flex: none; accent-color: var(--accent); }
.checklist input:checked + span { color: var(--muted); text-decoration: line-through; text-decoration-color: var(--accent); }
.allset { color: var(--see-line); font-weight: 700; margin: .6rem 0 0; }
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; margin-right: .45rem; vertical-align: -2px; border: 1px solid rgba(0,0,0,.15); }

/* buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  background: var(--accent); color: var(--accent-ink); border: 2px solid var(--accent);
  border-radius: 10px; padding: .6rem 1rem; font: inherit; font-weight: 700; text-decoration: none;
  cursor: pointer; min-height: 44px;
}
.btn.ghost { background: transparent; color: var(--accent); }
.btn.big { font-size: 1.1rem; padding: .75rem 1.3rem; }
.download, .actions { display: flex; flex-wrap: wrap; gap: .6rem; margin: .8rem 0; }
.pager { display: flex; justify-content: space-between; gap: .6rem; margin-top: 2rem; flex-wrap: wrap; }

/* code */
.upload { margin: .3rem 0 .6rem; }
details.code summary { cursor: pointer; color: var(--accent); font-weight: 600; }
pre { background: var(--code-bg); border: 1px solid var(--line); border-radius: 10px; padding: .8rem; overflow-x: auto; font-size: .85rem; line-height: 1.45; }

/* index */
.flow { display: flex; flex-wrap: wrap; align-items: center; gap: .4rem; font-weight: 700; color: var(--muted); }
.flow span { background: var(--accent-soft); color: var(--ink); border-radius: 8px; padding: .3rem .6rem; }
.steplist { list-style: none; padding: 0; margin: 0; }
.steplist li { display: flex; justify-content: space-between; align-items: center; gap: .8rem; border-top: 1px solid var(--line); padding: .5rem 0; margin: 0; }
.steplist li:first-child { border-top: 0; }
.steplist a { display: flex; align-items: center; gap: .7rem; text-decoration: none; color: var(--ink); font-weight: 600; }
.steplist .n { width: 28px; height: 28px; border-radius: 14px; background: var(--accent); color: var(--accent-ink); display: grid; place-items: center; font-size: .9rem; flex: none; }

/* tables */
.tbl { border-collapse: collapse; width: 100%; font-size: .93rem; }
.tbl th, .tbl td { text-align: left; padding: .4rem .5rem; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { color: var(--muted); font-weight: 600; }
.tbl td.cmd { font-family: Consolas, Menlo, monospace; font-weight: 700; font-size: 1.05rem; }
.twocol { display: grid; grid-template-columns: 1fr; gap: 0 1.5rem; }
@media (min-width: 760px) { .twocol { grid-template-columns: 1fr 1fr; } }

/* phone mock */
.macros { margin: .4rem 0 1rem; }
.phone { max-width: 320px; margin: 0 auto; background: #11181c; border-radius: 26px; padding: 14px; box-shadow: 0 6px 18px rgba(0,0,0,.18); }
.phonebar { color: #9ee6a0; font: 600 .8rem/1 system-ui, sans-serif; padding: .3rem .4rem .6rem; }
.phonelog { background: #1d262b; color: #cfd8dc; font: .85rem/1.4 Consolas, monospace; border-radius: 10px; padding: .5rem .7rem; min-height: 64px; margin-bottom: 10px; }
.mgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.mbtn { border-radius: 10px; padding: .45rem .5rem; text-align: center; color: #fff; line-height: 1.2; }
.mbtn b { display: block; font-size: .88rem; }
.mbtn small { font-size: .75rem; opacity: .85; }
.mbtn.on { background: #2e7d32; }
.mbtn.off { background: #546e7a; }

.party { text-align: center; padding: 1rem 0; }
.party .actions { justify-content: center; }
.sheethead { display: flex; justify-content: space-between; align-items: center; gap: 1rem; }

@media print {
  @page { size: A4 landscape; margin: 10mm; }
  body { background: #fff; color: #000; font-size: 11px; }
  .top, .pager, .noprint, .party .actions, .party .lead, .party .kicker, [data-print] { display: none !important; }
  .party { padding: 0; text-align: left; }
  .party h1 { font-size: 18px; margin: 0 0 4px; }
  main { max-width: none; padding: 0; }
  .sheet h2 { display: none; }
  .sheetgrid { display: grid; grid-template-columns: 58% 1fr; gap: 0 2%; }
  .diagram { margin: 0; }
  .diagram .scroll { overflow: visible; border: 0; }
  .diagram img { min-width: 0; }
  .twocol { grid-template-columns: 1fr !important; }
  .twocol h3:first-child { margin-top: 0; }
  .tbl { font-size: 10px; }
  .tbl td.cmd { font-size: 12px; }
  .small { font-size: 10px; margin: 4px 0 0; }
  .sheet, .card, .party { margin: 0; padding: 0; border: 0; }
  .tbl th, .tbl td { padding: 1px 4px; line-height: 1.3; }
  h3 { margin: 4px 0 2px; font-size: 12px; }
  .sheethead h1 { font-size: 18px; margin: 0 0 4px; }
}
