:root {
  color-scheme:light;
  --ink:#202e28; --muted:#57665a; --forest:#205746; --forest-hover:#184936; --accent:#cfe695; --line:#d5dbce;
  --paper:#f5f4eb; --surface:#fffef8; --white:var(--surface); --soft:#eaf0e3;
  --amber:#fff0cb; --amber-border:#a67b38; --amber-ink:#765219; --danger:#a04635; --on-forest:#fff;
  --rail:#173e34; --rail-ink:#f3f3de; --shadow:0 4px 18px #243f2c09;
  font:15px/1.55 "Inter","PingFang SC","Microsoft YaHei",system-ui,sans-serif;
  background:var(--paper); color:var(--ink); -webkit-font-smoothing:antialiased;
}
:root[data-theme=dark] {
  color-scheme:dark; --ink:#edf2ea; --muted:#a8bab0; --forest:#7fd4a4; --forest-hover:#97dfb7; --accent:#d5e7a3;
  --line:#364b41; --paper:#121b17; --surface:#1b2822; --soft:#253830; --amber:#3d2f16;
  --amber-border:#8b692d; --amber-ink:#ffd996; --danger:#ffafa5; --on-forest:#0e261c; --rail:#0d211b;
}
@media(prefers-color-scheme:dark) {
  :root:not([data-theme=light]) {
    color-scheme:dark; --ink:#edf2ea; --muted:#a8bab0; --forest:#7fd4a4; --forest-hover:#97dfb7; --accent:#d5e7a3;
    --line:#364b41; --paper:#121b17; --surface:#1b2822; --soft:#253830; --amber:#3d2f16;
    --amber-border:#8b692d; --amber-ink:#ffd996; --danger:#ffafa5; --on-forest:#0e261c; --rail:#0d211b;
  }
}
* {box-sizing:border-box}
body {margin:0}
h1,h2,h3,h4,p {margin:0}
h1,h2,h3,h4 {line-height:1.35; text-wrap:pretty}
h2 {font-size:19px} h3 {font-size:15px}
a {color:inherit; text-decoration:none}
button,input,textarea,select {font:inherit}
:where(button,.button,input,textarea,select,.panel,.ib-list,.ib-letter,.ib-aside-card,.ib-thread-card,.ib-option,.pc-card) {
  transition:background-color 140ms ease,border-color 140ms ease,color 140ms ease,box-shadow 140ms ease;
}
button,.button {
  display:inline-flex; align-items:center; justify-content:center; gap:7px; white-space:nowrap;
  background:var(--surface); border:1px solid var(--line); color:var(--ink); font-size:13px;
  font-weight:600; min-height:38px; padding:7px 13px; border-radius:9px; cursor:pointer;
}
button:hover,.button:hover {border-color:var(--forest); background:var(--soft)}
button:disabled {opacity:.55; cursor:default}
button.primary,a.primary {background:var(--forest); color:var(--on-forest); border-color:var(--forest)}
button.primary:hover,a.primary:hover {background:var(--forest-hover); border-color:var(--forest-hover)}
:focus-visible {outline:3px solid var(--forest); outline-offset:3px}
[hidden] {display:none!important}
.skip {position:fixed; top:-100px; left:105px; z-index:30; background:var(--surface); padding:10px}
.skip:focus {top:5px}
.mast {
  position:fixed; inset:0 auto 0 0; width:96px; padding:24px 9px 17px;
  display:flex; flex-direction:column; align-items:stretch; gap:32px;
  background:var(--rail); color:var(--rail-ink); z-index:6;
}
.brand {display:grid; justify-items:center; gap:8px; font-size:12px; letter-spacing:.1em}
.stamp,.dialog-mark {
  display:grid; place-items:center; width:40px; height:43px; border-radius:6px;
  background:#d6e6b0; color:#274a35; outline:1px dashed #779264; outline-offset:-4px;
  transform:rotate(-4deg);
}
.stamp i,.dialog-mark i {width:19px; height:14px; border:1.6px solid currentColor; border-radius:2px; position:relative; overflow:hidden}
.stamp i::before,.dialog-mark i::before {content:""; position:absolute; width:12px; height:12px; border:solid currentColor; border-width:0 1.6px 1.6px 0; transform:rotate(45deg); top:-8px; left:2px}
.mast nav {display:grid; gap:7px}
.mast nav a {display:flex; flex-direction:column; align-items:center; justify-content:center; gap:5px; height:63px; border-radius:11px; font-size:12px; color:#d7e3d5; line-height:1.4}
.mast nav a[aria-current=page] {background:#d2e4b0; color:#234331; font-weight:700}
.mast nav a:hover:not([aria-current]) {background:#2a4e41}
.mast :focus-visible {outline-color:var(--accent)}
.glyph,.glyph-svg {display:inline-block; width:1.2em; height:1.2em; vertical-align:middle; flex:none}
.mast nav .glyph {width:22px; height:22px}
.rail-slot {margin-top:auto}
#device-menu {display:none}
.rail-bottom {display:grid; gap:12px; justify-items:center}
.rail-bottom button {color:#dbe7d5; border:0; background:transparent; min-width:0; padding:5px 2px; font-size:11px; gap:5px}
.rail-bottom button:hover {background:#2c4d42}
.rail-bottom .identity {background:#254d41; border:1px solid #587468; border-radius:10px; width:100%; white-space:nowrap; font:600 10px/1.5 ui-monospace,monospace}
.rail-bottom .identity[data-connected] {display:grid; gap:0; position:relative; justify-items:center}
.rail-bottom .identity[data-connected]::before {position:absolute; left:7px; top:9px; width:5px; height:5px}
.rail-bottom .device-id {font-variant-numeric:tabular-nums}
.identity::before,.boundary i {content:""; width:7px; height:7px; border-radius:50%; background:#96a499; flex-shrink:0}
.identity[data-connected]::before {background:#c5df90}
.page {margin-left:96px; min-width:0}
.topline {display:flex; align-items:center; justify-content:space-between; gap:8px; height:46px; padding:0 clamp(18px,2.3vw,40px); border-bottom:1px solid var(--line); background:var(--surface); font-size:12px}
.location,.top-meta,.boundary,.actions,.tabs,.fileline,.pairline {display:flex; align-items:center; gap:10px}
.location {color:var(--muted)} .location strong {color:var(--ink); font-weight:600} .mast-name {font-weight:620}
.top-meta {color:var(--muted); gap:16px}
.boundary {gap:6px; color:var(--forest); background:var(--soft); border:1px solid var(--line); padding:2px 9px; border-radius:20px; font-size:11px; font-weight:650}
.boundary i {width:6px; height:6px; background:var(--forest)}
main {max-width:1700px; margin:auto; padding:clamp(14px,1.55vw,24px) clamp(18px,2.05vw,36px) clamp(18px,2.05vw,36px); min-width:0}
.hero {display:flex; justify-content:space-between; align-items:center; gap:10px; margin:0 0 14px}
.hero>div {min-width:0}
h1 {font-size:clamp(24px,2vw,31px); letter-spacing:-.045em; font-weight:730}
.intro,.sub,.meta,.loading,.empty p,.welcome-copy p,dialog p {color:var(--muted)}
.intro {margin-top:4px; font-size:13px; max-width:75ch}
.panel,.letter,.empty {min-width:0; background:var(--surface); border:1px solid var(--line); border-radius:15px; box-shadow:var(--shadow); padding:clamp(15px,1.5vw,24px)}
.panel h2,.letter h2 {margin-bottom:10px}
.empty {display:grid; align-content:center; justify-items:start; gap:12px; min-height:185px; padding:24px}
.empty .glyph {background:var(--soft); color:var(--forest); width:39px; height:39px; padding:9px; border-radius:9px}
.empty p,.sub {font-size:13px}
.meta,small {font-size:12px; color:var(--muted); overflow-wrap:anywhere}
.actions,.tabs {flex-wrap:wrap; gap:8px}
.actions {margin-top:14px}
.actions .danger,.danger {color:var(--danger)}
.workspace {display:grid; grid-template-columns:minmax(0,1.7fr) minmax(230px,1fr); gap:18px; align-items:start}
label {display:grid; gap:6px; margin-top:13px; font-size:13px; font-weight:600; min-width:0}
input,textarea,select {min-width:0; max-width:100%; width:100%; background:var(--surface); color:var(--ink); border:1px solid var(--line); border-radius:8px; padding:9px 11px; font-size:14px; line-height:1.5}
input::placeholder,textarea::placeholder {color:var(--muted); opacity:1}
input:focus,textarea:focus,select:focus {border-color:var(--forest)}
input[type=checkbox] {width:17px; height:17px; accent-color:var(--forest); flex-shrink:0}
textarea {resize:vertical; min-height:115px}
.two {display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:16px}
.check {display:flex; align-items:center; gap:7px}
progress {width:100%; accent-color:var(--forest)}
mark {color:var(--amber-ink); background:var(--amber); padding:1px 2px; border-radius:3px}
code,.mono,pre {font:12px/1.6 ui-monospace,SFMono-Regular,monospace; overflow-wrap:anywhere; white-space:pre-wrap; min-width:0}
pre {margin:8px 0}
.notice {font-size:13px; background:var(--soft); border-left:3px solid var(--forest); border-radius:4px; padding:10px 13px; margin:12px 0; overflow-wrap:anywhere}
.error,#autherror {color:var(--danger)}
.badge,.revision,.count {display:inline-flex; align-items:center; padding:2px 7px; border-radius:5px; font-size:11px; font-weight:650; background:var(--soft); color:var(--forest)}
.revision {font-family:ui-monospace,monospace; color:var(--muted)}
.stack>*+* {margin-top:12px}
summary {cursor:pointer; font-weight:600}
button, a, input, textarea, select, summary {touch-action:manipulation}
dialog {border:1px solid var(--line); border-radius:16px; padding:24px; width:min(440px,92vw); max-height:88dvh; overflow:auto; background:var(--surface); color:var(--ink); box-shadow:0 20px 90px #001f153b}
dialog::backdrop {background:#10241db3}
dialog p {font-size:13px; margin:8px 0}
#device-sheet header {display:flex; align-items:center; justify-content:space-between; margin-bottom:18px}
#device-controls .rail-bottom {grid-template-columns:1fr 1fr; gap:12px; width:auto; border:0; padding:0}
#device-controls button {width:100%; font-size:13px; min-height:44px; border:1px solid var(--line); background:var(--soft); color:var(--ink)}
.dialog-mark {margin-bottom:15px}
#feedback {pointer-events:none; position:fixed; z-index:40; top:12px; left:50%; right:auto; bottom:auto; transform:translateX(-50%); margin:0; padding:0; width:max-content; max-width:min(420px,90vw); border:0; border-radius:999px; overflow-wrap:anywhere; text-align:center}
#feedback:not(:empty) {padding:8px 16px; background:var(--rail); color:var(--rail-ink); border:1px solid #64816c; box-shadow:0 4px 14px #0d211b26; font-size:13px}
.welcome {min-height:350px; padding:clamp(24px,5vw,72px); display:flex; align-items:center; justify-content:center; gap:clamp(24px,6vw,88px); border:1px solid var(--line); background:var(--surface); border-radius:18px}
.welcome-copy {min-width:0; max-width:400px}
.welcome-copy h2 {font-size:27px; letter-spacing:-.04em}
.welcome-copy p {margin:8px 0 14px; font-size:14px}
.welcome-badges {display:flex; flex-wrap:wrap; gap:6px; margin:0 0 22px; padding:0; list-style:none}
.welcome-badges li {display:inline-flex; align-items:center; gap:5px; padding:3px 8px; border:1px solid var(--line); border-radius:999px; background:var(--soft); color:var(--forest); font-size:12px}
.postal-print {position:relative; flex-shrink:0; width:185px; height:136px; color:var(--forest)}
.print-envelope {position:absolute; width:142px; height:93px; bottom:8px; left:0; border:2px solid; border-radius:6px; transform:rotate(-10deg); overflow:hidden; background:var(--soft)}
.print-envelope::before {content:""; position:absolute; width:98px; height:98px; border:2px solid; transform:rotate(45deg); left:18px; top:-59px; border-radius:6px}
.print-envelope::after {content:""; position:absolute; width:23px; height:3px; border-block:1px solid; left:11px; bottom:13px}
.postmark {position:absolute; width:72px; height:72px; right:2px; top:0; display:grid; align-content:center; justify-items:center; line-height:1.2; font-size:8px; font-weight:700; border:3px double; border-radius:50%; transform:rotate(12deg); background:var(--surface); outline:1px dashed; outline-offset:-7px}
.postmark .glyph {width:16px; height:16px; margin:3px}
@media(max-width:1100px) and (min-width:651px) {.mast {width:76px; padding-inline:6px} .page {margin-left:76px} main {padding-inline:18px}}
@media(max-width:650px) {
  .mast {inset:auto 9px calc(6px + env(safe-area-inset-bottom)); width:auto; padding:4px 8px; border-radius:18px; flex-direction:row; align-items:center; gap:6px; box-shadow:0 6px 24px #122b2360}
  .brand,.rail-slot {display:none} .mast nav {flex:4; display:grid; grid-template-columns:repeat(4,minmax(0,1fr)); gap:3px}
  .mast nav a {height:48px; gap:1px; font-size:11px; border-radius:12px}
  .mast nav .glyph {width:20px; height:20px}
  #device-menu {display:flex; flex:1; min-height:48px; flex-direction:column; gap:0; padding:0; border:0; background:transparent; color:var(--rail-ink); font-size:11px; font-weight:500}
  #device-menu .glyph {width:21px; height:21px}
  .page {margin:0} .topline {height:42px; padding-inline:15px} .top-meta time {display:none}
  main {padding:17px 13px calc(108px + env(safe-area-inset-bottom))}
  .hero {margin-bottom:15px} .hero .intro {font-size:12px} .hero>.button {font-size:12px; padding:6px 10px}
  .workspace,.two {grid-template-columns:minmax(0,1fr); gap:12px}
  .welcome {min-height:375px; flex-direction:column; align-items:flex-start; gap:20px}
  .postal-print {transform:scale(.8); transform-origin:left bottom; margin-top:-25px}
  .welcome-copy h2 {font-size:23px}
  #feedback {top:calc(10px + env(safe-area-inset-top)); bottom:auto; right:auto}
}
@media(prefers-reduced-motion:reduce) {*,*::before,*::after {scroll-behavior:auto!important; animation-duration:0s!important; transition-duration:0s!important}}
