/* Soul — TADL shell (teal, PO-approved deviation) + light workspace + paper letters.
   Tokens follow the Thuy Automation design system; shell colours per PO decision 16-Nov-2026. */
:root {
  --ground: #F4F8F8; --surface: #FFFFFF; --surface-2: #EAF2F2; --line: #D5E3E3; --line-strong: #0B1F24;
  --ink: #0B1F24; --ink-muted: #4A5D63; --heading: #0B1F24;
  --brand: #0F766E; --on-brand: #FFFFFF; --brand-tint: #CCFBF1; --on-brand-tint: #134E4A; --focus: #0F766E;
  --shell: #134E4A; --shell-2: #1B625D; --on-shell: #ECF8F6; --on-shell-muted: #A9D6CF; --shell-accent: #5EEAD4;
  --critical-fg: #991B1B; --critical-bg: #FEE2E2; --major-fg: #9A3412; --major-bg: #FFEDD5;
  --minor-fg: #3730A3; --minor-bg: #E0E7FF; --closed-fg: #166534; --closed-bg: #DCFCE7;
  --paper: #FBF6EA; --paper-rule: #E3D8BF; --paper-margin: #E7B9B0; --env: #E9DCC0; --env-flap: #DDCCA9; --env-in: #C9B48C;
  --ink-navy: #1D3A6B; --ink-sepia: #5A3A1E; --seal: #8E2A2A; --seal-hi: #B4473F;
  --font-ui: "Be Vietnam Pro", Arial, sans-serif; --font-mono: "Roboto Mono", Consolas, monospace;
  --hand-bay: "Dancing Script", "Segoe Script", cursive; --hand-tron: "Patrick Hand", "Comic Sans MS", cursive; --hand-net: "Mali", "Segoe Print", cursive;
  --hand-but: "Sriracha", "Segoe Print", cursive; --hand-mem: "Itim", "Segoe Print", cursive; --hand-thanh: "Charm", "Segoe Script", cursive;
  --hand-hoa: "Ephesis", "Segoe Script", cursive; --hand-hoc: "Playpen Sans", "Comic Sans MS", cursive;
  --ink-blue: #1F5FBF; --ink-purple: #5B2A86;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px;
  color-scheme: light;
}
@media (prefers-color-scheme: dark) {
  :root {
    --ground: #0E1416; --surface: #162024; --surface-2: #1E2A2F; --line: #2A383D; --line-strong: #E6EDEF;
    --ink: #E6EDEF; --ink-muted: #9AA8AD; --heading: #E6EDEF;
    --brand: #2DD4BF; --on-brand: #0E1416; --brand-tint: #0F2F2B; --on-brand-tint: #5EEAD4; --focus: #5EEAD4;
    --shell: #12302D; --shell-2: #1A4440; --on-shell: #E6F2F0; --on-shell-muted: #9CC7C0;
    --critical-fg: #FCA5A5; --critical-bg: #3B1518; --major-fg: #FCD34D; --major-bg: #3A2A0B;
    --minor-fg: #A5B4FC; --minor-bg: #1E2440; --closed-fg: #86EFAC; --closed-bg: #12301F;
    --paper: #ECE3CF; --paper-rule: #CDBF9F; --paper-margin: #CF9C92; --env: #B9A47E; --env-flap: #A8936C; --env-in: #7E6B4C;
    --ink-navy: #1A3363; --ink-sepia: #4E3218; --ink-blue: #1B4FA0; --ink-purple: #4F2475; --seal: #9A3232; --seal-hi: #C25A50;
    color-scheme: dark;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--ground); color: var(--ink); font: 15px/24px var(--font-ui); }
h1, h2, h3 { color: var(--heading); margin: 0; text-wrap: balance; }
h1 { font-size: 26px; line-height: 34px; }
h2 { font-size: 20px; line-height: 28px; font-weight: 600; }
h3 { font-size: 16px; line-height: 24px; font-weight: 600; }
p { margin: 0; }
button, input, select, textarea { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
a { color: var(--brand); }
.muted { color: var(--ink-muted); }
.small { font-size: 13px; line-height: 20px; }
.mono { font-family: var(--font-mono); font-size: 13px; }
.label { font-size: 11px; line-height: 16px; font-weight: 600; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted); }
#root { min-height: 100vh; min-height: 100dvh; display: flex; flex-direction: column; }
#root > * { flex: 1 0 auto; }
.boot { align-items: center; justify-content: center; color: var(--ink-muted); }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Buttons, chips */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: var(--r-md); padding: 8px 16px; font-weight: 600; cursor: pointer; border: 1px solid var(--line); background: var(--surface); color: var(--ink); white-space: nowrap; }
.btn:disabled { opacity: .55; cursor: progress; }
.btn.primary { background: var(--brand); border-color: var(--brand); color: var(--on-brand); }
.btn.ghost { background: transparent; }
.btn.sm { padding: 4px 10px; font-size: 13px; border-radius: 8px; }
.btn.danger { color: var(--critical-fg); }
.linkbtn { border: 0; background: none; color: var(--brand); cursor: pointer; padding: 0; font-weight: 600; }
.chip { display: inline-flex; align-items: center; padding: 1px 10px; border-radius: 999px; font-size: 12px; line-height: 20px; font-weight: 600; white-space: nowrap; }
.chip.pending { background: var(--major-bg); color: var(--major-fg); }
.chip.active { background: var(--closed-bg); color: var(--closed-fg); }
.chip.locked, .chip.sealed { background: var(--critical-bg); color: var(--critical-fg); }
.chip.info, .chip.disabled { background: var(--minor-bg); color: var(--minor-fg); }

/* Shell (TADL) */
.app { min-height: 100%; display: grid; grid-template-columns: 240px minmax(0, 1fr); grid-template-rows: 56px 1fr auto; }
.side { grid-row: 1 / 3; background: var(--shell); color: var(--on-shell); display: flex; flex-direction: column; padding: 16px 12px; gap: 20px; padding-left: max(12px, env(safe-area-inset-left, 0px)); }
.ident { display: flex; gap: 10px; align-items: center; padding: 4px 6px; }
.ident .name { font-weight: 700; letter-spacing: .06em; font-size: 17px; }
.slogan { font-family: var(--hand-bay); font-weight: 500; font-size: 19px; line-height: 22px; color: var(--on-shell); }
.slogan.on-light { color: var(--ink-navy); font-size: 26px; line-height: 30px; }
.nav { display: flex; flex-direction: column; gap: 2px; }
.nav .grp { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--on-shell-muted); padding: 10px 10px 4px; }
.nav a { display: flex; align-items: center; gap: 10px; color: var(--on-shell); padding: 8px 10px; border-radius: 8px; font-weight: 500; text-decoration: none; }
.nav a:hover { background: var(--shell-2); }
.nav a[aria-current="page"] { background: var(--shell-2); box-shadow: inset 3px 0 0 var(--shell-accent); color: #fff; }
.nav .count { margin-left: auto; font-size: 12px; background: var(--seal); color: #fff; border-radius: 999px; padding: 0 7px; line-height: 18px; }
.me { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 10px; border-top: 1px solid var(--shell-2); }
.me .n { font-size: 13px; line-height: 18px; font-weight: 600; }
.me .r { font-size: 12px; line-height: 16px; color: var(--on-shell-muted); }
.avatar { width: 30px; height: 30px; border-radius: 50%; display: grid; place-items: center; font-weight: 700; font-size: 12px; background: var(--shell-2); color: var(--on-shell); flex: none; }
.head { grid-column: 2; display: flex; align-items: center; gap: 12px; padding: 0 24px; border-bottom: 1px solid var(--line); background: var(--surface); min-width: 0; position: sticky; top: 0; z-index: 5; }
.head .crumb { font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.head .crumb span { color: var(--ink-muted); font-weight: 500; }
.head .sp { margin-left: auto; }
.work { grid-column: 2; padding: 24px; min-width: 0; position: relative; padding-right: max(24px, env(safe-area-inset-right, 0px)); }
.work-inner { max-width: 1040px; margin: 0 auto; }
.foot { grid-column: 1 / 3; background: var(--shell); color: var(--on-shell-muted); font-size: 12px; line-height: 18px; display: flex; flex-wrap: wrap; gap: 6px 24px; align-items: center; padding: 10px 16px calc(10px + env(safe-area-inset-bottom, 0px)); }
.foot b { color: var(--on-shell); font-weight: 600; }
.foot .fid { display: flex; align-items: center; gap: 8px; }

/* Auth surface */
.authpage { min-height: 100%; display: grid; grid-template-rows: 1fr auto; background: var(--shell); }
.authpage main { display: grid; place-items: center; padding: 32px max(16px, env(safe-area-inset-right, 0px)) 32px max(16px, env(safe-area-inset-left, 0px)); }
.authpage .foot { grid-column: auto; border-top: 1px solid var(--shell-2); }
.auth { width: min(410px, 100%); background: var(--surface); border-radius: var(--r-lg); padding: 32px; display: flex; flex-direction: column; gap: 16px; box-shadow: 0 20px 50px rgba(0,0,0,.3); }
.auth .brand { display: flex; flex-direction: column; align-items: center; gap: 4px; text-align: center; padding-bottom: 12px; border-bottom: 1px solid var(--line); }
.auth .brand .pn { font-size: 22px; font-weight: 700; letter-spacing: .08em; }
.auth form { display: flex; flex-direction: column; gap: 12px; }
.msg { font-size: 13px; line-height: 20px; padding: 10px 12px; border-radius: var(--r-sm); }
.msg.err { background: var(--critical-bg); color: var(--critical-fg); }
.msg.wait { background: var(--major-bg); color: var(--major-fg); }
.msg.ok { background: var(--closed-bg); color: var(--closed-fg); }
.alt { font-size: 13px; text-align: center; color: var(--ink-muted); }
.qr { width: 200px; height: 200px; align-self: center; border-radius: var(--r-sm); border: 1px solid var(--line); image-rendering: pixelated; }
.secret { font-family: var(--font-mono); font-size: 15px; letter-spacing: .08em; background: var(--surface-2); border-radius: var(--r-sm); padding: 10px 12px; word-break: break-all; user-select: all; }

/* Forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field label, .field .lb { font-size: 13px; font-weight: 600; }
.help { font-size: 12px; line-height: 18px; color: var(--ink-muted); }
.ferr { font-size: 13px; color: var(--critical-fg); }
input[type=text], input[type=email], input[type=password], select, textarea { width: 100%; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-sm); padding: 9px 12px; }
textarea { min-height: 220px; resize: vertical; line-height: 22px; }
.opts { display: flex; flex-wrap: wrap; gap: 8px; }
.opts label { display: inline-flex; align-items: center; gap: 6px; border: 1px solid var(--line); border-radius: 999px; padding: 4px 12px; cursor: pointer; font-size: 13px; background: var(--surface); }
.opts input { accent-color: var(--brand); }
.opts label:has(input:checked) { background: var(--brand-tint); color: var(--on-brand-tint); border-color: transparent; font-weight: 600; }
.row-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Page title */
.ptitle { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.ptitle .t { display: flex; flex-direction: column; gap: 2px; min-width: 0; }

/* Letter list */
.list { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); overflow: hidden; }
.lrow { display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 14px; align-items: center; padding: 14px 16px; border: 0; border-bottom: 1px solid var(--line); cursor: pointer; background: var(--surface); width: 100%; text-align: left; }
.lrow:last-child { border-bottom: 0; }
.lrow:hover { background: var(--surface-2); }
.lrow .who { font-weight: 600; }
.lrow .sub { font-size: 13px; line-height: 20px; color: var(--ink-muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lrow .meta { display: flex; flex-direction: column; align-items: flex-end; gap: 4px; font-size: 12px; color: var(--ink-muted); }
.lrow .txt { min-width: 0; display: flex; flex-direction: column; }
.mini-env { width: 40px; height: 28px; position: relative; border-radius: 3px; background: var(--env); }
.mini-env::before { content: ""; position: absolute; inset: 0; background: var(--env-flap); clip-path: polygon(0 0, 100% 0, 50% 60%); border-radius: 3px; }
.mini-env.sealed::after { content: ""; position: absolute; width: 11px; height: 11px; border-radius: 50%; background: var(--seal); left: 50%; top: 60%; transform: translate(-50%, -50%); }
.mini-env.open::before { clip-path: polygon(0 0, 100% 0, 50% 0); }
.mini-env.recalled { opacity: .4; }
.empty { padding: 48px 16px; text-align: center; color: var(--ink-muted); display: flex; flex-direction: column; gap: 12px; align-items: center; }

/* Envelope stage */
.stage { position: fixed; inset: 0; background: color-mix(in srgb, var(--shell) 94%, black); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 28px; padding: 24px; z-index: 50; }
.stage .from { color: var(--on-shell); text-align: center; display: flex; flex-direction: column; gap: 4px; }
.stage .from h2 { color: var(--on-shell); }
.stage .from small, .stage .from .label { color: var(--on-shell-muted); }
.env { position: relative; width: min(380px, 82vw); aspect-ratio: 1.62; margin-top: 100px; perspective: 1000px; }
.env-back { position: absolute; inset: 0; background: var(--env-in); border-radius: 6px; }
.sheet-peek { position: absolute; left: 6%; right: 6%; top: 6%; height: 88%; background: var(--paper); border-radius: 3px; z-index: 2; transition: transform .9s cubic-bezier(.2,.8,.2,1) .55s; background-image: repeating-linear-gradient(to bottom, transparent 0 17px, var(--paper-rule) 17px 18px); background-position: 0 26px; }
.env-front { position: absolute; inset: 0; z-index: 3; background: var(--env); clip-path: polygon(0 0, 50% 56%, 100% 0, 100% 100%, 0 100%); border-radius: 6px; }
.env-front .addr { position: absolute; left: 0; right: 0; bottom: 16%; text-align: center; font-family: var(--hand-bay); font-size: 23px; color: var(--ink-navy); padding: 0 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.env-flap { position: absolute; left: 0; right: 0; top: 0; height: 58%; z-index: 4; background: var(--env-flap); clip-path: polygon(0 0, 100% 0, 50% 100%); transform-origin: 50% 0; transition: transform .6s ease, z-index 0s linear .3s; }
.seal { position: absolute; left: 50%; top: 58%; width: 64px; height: 64px; transform: translate(-50%, -50%); z-index: 5; border: 0; border-radius: 50%; cursor: pointer; background: radial-gradient(circle at 35% 30%, var(--seal-hi), var(--seal) 60%); box-shadow: 0 2px 0 rgba(0,0,0,.25), inset 0 0 0 5px rgba(0,0,0,.12); display: grid; place-items: center; transition: transform .45s ease, opacity .45s ease; }
.seal:hover { transform: translate(-50%, -50%) scale(1.06); }
.env.open .seal { transform: translate(-50%, -50%) scale(1.35) rotate(-12deg); opacity: 0; pointer-events: none; }
.env.open .env-flap { transform: rotateX(180deg); z-index: 1; }
.env.open .sheet-peek { transform: translateY(-58%); }
.stage .hint { color: var(--on-shell-muted); font-size: 13px; min-height: 20px; }
.stage .close { position: absolute; top: calc(14px + env(safe-area-inset-top, 0px)); right: max(14px, env(safe-area-inset-right, 0px)); background: transparent; border-color: var(--shell-2); color: var(--on-shell); }

/* Reader & paper */
.reader { display: flex; flex-direction: column; align-items: center; gap: 16px; }
.reader .bar { width: min(780px, 100%); display: flex; flex-wrap: wrap; gap: 8px; align-items: center; justify-content: space-between; }
.sheet { --lh: 38px; width: min(780px, 100%); background: var(--paper); color: var(--ink-navy); border-radius: 4px; box-shadow: 0 1px 0 var(--paper-rule), 0 14px 34px rgba(11,31,36,.16); padding: 40px 44px 48px 64px; position: relative;
  background-image: linear-gradient(to right, transparent 46px, var(--paper-margin) 46px 47px, transparent 47px), repeating-linear-gradient(to bottom, transparent 0 calc(var(--lh) - 1px), var(--paper-rule) calc(var(--lh) - 1px) var(--lh)); background-position: 0 0, 0 39px; }
.sheet .date { font-family: var(--hand-tron); font-size: 20px; line-height: var(--lh); text-align: right; opacity: .85; }
.sheet .body { white-space: pre-wrap; overflow-wrap: anywhere; line-height: var(--lh); min-height: calc(var(--lh) * 6); }
.sheet .sign { line-height: var(--lh); text-align: right; margin-top: var(--lh); display: flex; flex-direction: column; align-items: flex-end; }
.sheet .sign img { max-width: 260px; height: auto; }
.hand-bay { font-family: var(--hand-bay); font-size: 27px; font-weight: 500; }
.hand-tron { font-family: var(--hand-tron); font-size: 24px; }
.hand-net { font-family: var(--hand-net); font-size: 20px; }
.hand-but { font-family: var(--hand-but); font-size: 22px; }
.hand-mem { font-family: var(--hand-mem); font-size: 22px; }
.hand-thanh { font-family: var(--hand-thanh); font-size: 25px; }
.hand-hoa { font-family: var(--hand-hoa); font-size: 34px; }
.hand-hoc { font-family: var(--hand-hoc); font-size: 19px; }
.ink-sepia { color: var(--ink-sepia); }
.ink-navy { color: var(--ink-navy); }
.ink-blue { color: var(--ink-blue); }
.ink-purple { color: var(--ink-purple); }

/* Paper types: each sets the paper tokens; .sheet draws margin + rules from them. */
.paper-trang { --paper: #FFFFFF; --paper-rule: transparent; --paper-margin: transparent; }
.paper-kraft { --paper: #D8C19C; --paper-rule: #C7AD83; --paper-margin: transparent; }
.paper-hong { --paper: #FBE9EC; --paper-rule: #F0CDD4; --paper-margin: #E39AA8; }
.paper-airmail { --paper: #F6F8FC; --paper-rule: #DCE3EF; --paper-margin: transparent; }
.sheet.paper-oly { --paper: #FDFDF7; --paper-margin: #E7A9A0;
  background-image: linear-gradient(to right, transparent 46px, var(--paper-margin) 46px 47px, transparent 47px),
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--lh) - 1px), #B9C3E6 calc(var(--lh) - 1px) var(--lh)),
    repeating-linear-gradient(to bottom, transparent 0 calc(var(--lh) / 4 - 1px), #E2E7F6 calc(var(--lh) / 4 - 1px) calc(var(--lh) / 4)),
    repeating-linear-gradient(to right, transparent 0 calc(var(--lh) / 4 - 1px), #E2E7F6 calc(var(--lh) / 4 - 1px) calc(var(--lh) / 4)); }
.sheet.paper-kraft { background-image: linear-gradient(to right, transparent 46px, var(--paper-margin) 46px 47px, transparent 47px), repeating-linear-gradient(to bottom, transparent 0 calc(var(--lh) - 1px), var(--paper-rule) calc(var(--lh) - 1px) var(--lh)), radial-gradient(circle at 20% 30%, rgba(120,90,50,.08), transparent 60%); }
.sheet.paper-airmail { border: 10px solid transparent; border-image: repeating-linear-gradient(-45deg, #C8323C 0 12px, #F6F8FC 12px 22px, #2A4FA0 22px 34px, #F6F8FC 34px 44px) 10; border-radius: 0; }
@media (prefers-color-scheme: dark) {
  .paper-trang { --paper: #E9E7E1; }
  .paper-kraft { --paper: #B9A27D; --paper-rule: #A68E68; }
  .paper-hong { --paper: #E8D3D7; --paper-rule: #D7B5BC; }
  .paper-airmail { --paper: #E1E5EC; --paper-rule: #C6CEDC; }
  .sheet.paper-oly { --paper: #E8E8E0; }
}
.sw { display: inline-block; width: 14px; height: 14px; border-radius: 50%; border: 1px solid var(--line); flex: none; }
.sw.ink-navy { background: var(--ink-navy); } .sw.ink-blue { background: var(--ink-blue); }
.sw.ink-purple { background: var(--ink-purple); } .sw.ink-sepia { background: var(--ink-sepia); }
.sw.paper { border-radius: 3px; background: var(--paper); }
.opts .hs { font-size: 17px; line-height: 22px; }
.opts .hs.hand-hoa { font-size: 24px; }
.final-note { font-size: 12px; line-height: 18px; color: var(--ink-muted); }
.c { opacity: 0; animation: ink .38s ease-out forwards; }
@keyframes ink { from { opacity: 0; transform: translateY(1px); } to { opacity: 1; transform: none; } }
.thread { width: min(780px, 100%); display: flex; flex-direction: column; gap: 8px; }
.thread details { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 14px; }
.thread summary { cursor: pointer; font-weight: 600; font-size: 14px; }
.thread .prev { white-space: pre-wrap; margin-top: 8px; font-size: 19px; line-height: 30px; overflow-wrap: anywhere; }
.thread .prev.hand-net { font-size: 16px; }
.banner { width: min(780px, 100%); }

/* Compose */
.compose { display: grid; grid-template-columns: minmax(0, 360px) minmax(0, 1fr); gap: 20px; align-items: start; }
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.compose .sheet { --lh: 34px; padding: 28px 28px 32px 56px; width: 100%; }
.compose .sheet .body { min-height: calc(var(--lh) * 7); }
.placeholder { opacity: .45; }
.reply-to { font-size: 13px; background: var(--brand-tint); color: var(--on-brand-tint); border-radius: var(--r-sm); padding: 8px 12px; }
.sigpad { width: 100%; height: 130px; background: var(--paper); border: 1px dashed var(--paper-rule); border-radius: var(--r-sm); touch-action: none; cursor: crosshair; display: block; }

/* Admin / account */
.tablewrap { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: middle; }
th { font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-muted); background: var(--surface-2); font-weight: 600; border-bottom: 2px solid var(--line-strong); white-space: nowrap; }
tr:last-child td { border-bottom: 0; }
.audit { list-style: none; padding: 0; margin: 8px 0 0; }
.audit li { display: grid; grid-template-columns: 160px minmax(0, 1fr); gap: 12px; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.section + .section { margin-top: 28px; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 16px; }

/* Toast */
.toast { position: fixed; left: 50%; bottom: calc(64px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); background: var(--ink); color: var(--surface); padding: 10px 16px; border-radius: var(--r-md); font-size: 14px; z-index: 60; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(0,0,0,.25); }

@media (max-width: 900px) { .compose { grid-template-columns: 1fr; } }
@media (max-width: 760px) {
  .app { grid-template-columns: 1fr; grid-template-rows: auto auto 1fr auto; }
  .side { grid-row: auto; padding: 12px max(12px, env(safe-area-inset-right, 0px)) 12px max(12px, env(safe-area-inset-left, 0px)); gap: 10px; }
  .nav { flex-direction: row; flex-wrap: wrap; }
  .nav .grp, .me { display: none; }
  .head, .work, .foot { grid-column: 1; }
  .head { padding: 10px 16px; min-height: 52px; position: static; }
  .work { padding: 16px max(16px, env(safe-area-inset-right, 0px)) 24px max(16px, env(safe-area-inset-left, 0px)); }
  .sheet { padding: 28px 18px 32px 40px; background-image: linear-gradient(to right, transparent 28px, var(--paper-margin) 28px 29px, transparent 29px), repeating-linear-gradient(to bottom, transparent 0 calc(var(--lh) - 1px), var(--paper-rule) calc(var(--lh) - 1px) var(--lh)); }
  .hand-bay { font-size: 23px; } .hand-tron { font-size: 21px; } .hand-net { font-size: 17px; }
  .hand-but, .hand-mem { font-size: 19px; } .hand-thanh { font-size: 22px; } .hand-hoa { font-size: 29px; } .hand-hoc { font-size: 17px; }
  .sheet.paper-oly { background-image: linear-gradient(to right, transparent 28px, var(--paper-margin) 28px 29px, transparent 29px), repeating-linear-gradient(to bottom, transparent 0 calc(var(--lh) - 1px), #B9C3E6 calc(var(--lh) - 1px) var(--lh)), repeating-linear-gradient(to bottom, transparent 0 calc(var(--lh) / 4 - 1px), #E2E7F6 calc(var(--lh) / 4 - 1px) calc(var(--lh) / 4)); }
  .audit li { grid-template-columns: 1fr; gap: 2px; }
  .auth { padding: 24px; }
}
@media (prefers-reduced-motion: reduce) {
  .c { animation: none; opacity: 1; }
  .env-flap, .sheet-peek, .seal { transition: none; }
}

.filters { display: flex; flex-wrap: wrap; gap: 12px; margin: 12px 0 4px; }
.filters .field { min-width: 220px; flex: 1 1 220px; max-width: 360px; }
