/* 800×600 mock CRT — VT323 */

@font-face {
  font-family: "VT323";
  src: url("../fonts/vt323.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

/*
 * CJK for LANG JP — DotGothic16, metric-matched to VT323.
 * VT323 "H" = 0.560em, DotGothic "漢" = 0.939em → size-adjust ≈ 59.6%.
 * Local face first so a fallback (if any) uses the same size-adjust and does
 * not flash full-size glyphs before the woff2 loads.
 */
@font-face {
  font-family: "DotGothic16";
  src: local("Hiragino Sans"), local("Hiragino Kaku Gothic ProN"),
    local("Yu Gothic"), local("YuGothic"), local("Noto Sans JP"),
    local("Noto Sans CJK JP"), local("Meiryo");
  font-weight: 400;
  font-style: normal;
  size-adjust: 59.6%;
  unicode-range: U+3000-303F, U+3040-309F, U+30A0-30FF, U+31F0-31FF,
    U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FF00-FFEF;
}

@font-face {
  font-family: "DotGothic16";
  src: url("../fonts/dotgothic16/dotgothic16-japanese-400-normal.woff2")
    format("woff2");
  font-weight: 400;
  font-style: normal;
  /* block: do not paint CJK at the wrong size, then shrink */
  font-display: block;
  size-adjust: 59.6%;
  unicode-range: U+3000-303F, U+3040-309F, U+30A0-30FF, U+31F0-31FF,
    U+3400-4DBF, U+4E00-9FFF, U+F900-FAFF, U+FF00-FFEF;
}

:root {
  /* only: stop Chrome/Edge auto-dark from inverting an already-themed page */
  color-scheme: only dark;
  --bg: #000;
  --fg: #6e9e66;
  --bright: #8fbf84;
  --dim: #4a7344;
  --inv: #6e9e66;
  --ink: #000;
  --glow: rgba(110, 158, 102, 0.55);
  /* Frame stroke + omnidirectional bloom (stage and nested share these). */
  --frame-border: var(--fg);
  --frame-glow:
    0 0 2px rgba(110, 158, 102, 0.35),
    0 0 5px rgba(110, 158, 102, 0.16),
    inset 0 0 2px rgba(110, 158, 102, 0.28),
    inset 0 0 5px rgba(110, 158, 102, 0.1);
  --scan: rgba(0, 0, 0, 0.22);
  --overlay: rgba(0, 0, 0, 0.82);
}

html.mode-light {
  color-scheme: only light;
  --bg: #cfcfc8;
  --fg: #1c2a1a;
  --bright: #0f180e;
  --dim: #4a5448;
  --inv: #1c2a1a;
  --ink: #cfcfc8;
  --glow: rgba(0, 0, 0, 0.38);
  --frame-border: var(--fg);
  --frame-glow:
    0 0 2px rgba(0, 0, 0, 0.18),
    0 0 5px rgba(0, 0, 0, 0.08),
    inset 0 0 2px rgba(0, 0, 0, 0.14),
    inset 0 0 5px rgba(0, 0, 0, 0.06);
  --scan: rgba(255, 255, 255, 0.14);
  --overlay: rgba(207, 207, 200, 0.92);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: "VT323", "DotGothic16", monospace;
  overflow: hidden;
}

html.lang-jp,
html.lang-jp body {
  font-family: "VT323", "DotGothic16", monospace;
}

html.lang-jp .ftr .stats {
  letter-spacing: 0;
}

body.is-mobile {
  overflow: auto;
}

#stage-wrap {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

body.is-mobile #stage-wrap {
  display: none;
}

/* Stage scale root (console only). */
#desk {
  flex: none;
  transform-origin: center center;
}

#stage {
  width: 800px;
  height: 600px;
  flex: none;
  background: var(--bg);
  border: 1px solid var(--frame-border);
  box-shadow: var(--frame-glow);
  position: relative;
  overflow: hidden;
  font-size: 20px;
  line-height: 24px;
  user-select: none;
  text-shadow: 0 0 2px var(--glow);
  outline: none;
}

/* Link tree switcher — top-left of the browser window. */
#link-tree-launch {
  position: fixed;
  top: 12px;
  left: 14px;
  z-index: 30;
  color: var(--fg);
  font-family: "VT323", "DotGothic16", monospace;
  font-size: 20px;
  line-height: 24px;
  text-decoration: none;
  text-shadow: 0 0 2px var(--glow);
  cursor: pointer;
}
#link-tree-launch:hover {
  color: var(--bright);
}
body.is-mobile #link-tree-launch {
  display: none;
}

/* Main panel vs link-tree panel (toggle). Flex so children keep CRT sizing. */
#view-main,
#view-tree {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
}
#view-main[hidden],
#view-tree[hidden] {
  display: none !important;
}
#view-main > .connect-body,
#view-main > .inner-win {
  flex: 1 1 auto;
  min-height: 0;
  height: auto;
}
/* Link tree: same type as the console, links only, no nested window chrome. */
#view-tree .tree-fill {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  padding: 4px 6px;
}
#view-tree .tree-fill.has-scroll {
  padding-right: 12px;
}
#view-tree .tree-fill .line {
  height: 24px;
  line-height: 24px;
  font-size: 20px;
  white-space: pre;
  overflow: hidden;
}
#view-tree .tree-fill a.row {
  display: block;
  color: var(--fg);
  text-decoration: none;
  padding: 0 4px;
  width: fit-content;
  min-width: 60%;
  cursor: default;
  font-size: 20px;
  line-height: 24px;
}
#view-tree .tree-fill a.row:hover,
#view-tree .tree-fill a.row.on {
  background: var(--inv);
  color: var(--ink);
  text-shadow: none;
}

/* Link tree: wipe header, prompt, and footer — tree only. */
html.tree-mode .hdr,
html.tree-mode .prompt-row,
html.tree-mode .ftr {
  display: none !important;
}
html.tree-mode .page-shell {
  padding: 10px 14px 8px;
  height: 100%;
}
html.tree-mode .viewport {
  margin: 0;
  flex: 1 1 auto;
  min-height: 0;
}
html.tree-mode #view-tree {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}
html.tree-mode #view-tree .tree-fill {
  flex: 1 1 auto;
  min-height: 0;
  height: 100%;
}

/* Console owns keyboard focus; suppress browser focus rings on chrome. */
#stage a:focus,
#stage button:focus,
#stage [tabindex]:focus,
#help a:focus,
#help button:focus {
  outline: none;
}

#stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 20;
  background: repeating-linear-gradient(
    to bottom,
    transparent 0,
    transparent 2px,
    var(--scan) 2px,
    var(--scan) 3px
  );
  opacity: 0.45;
}

/* ---- shared shell ---- */
.page-shell {
  height: 100%;
  padding: 10px 14px 8px;
  display: flex;
  flex-direction: column;
}

.hdr {
  flex: none;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  line-height: 24px;
  align-items: start;
}
.hdr .l {
  text-align: left;
}
.hdr .c {
  text-align: center;
  color: var(--bright);
  padding: 0 10px;
}
.hdr .c .copy {
  color: inherit;
}
.hdr .r {
  text-align: right;
}
.ftr a,
.prompt-row a {
  color: inherit;
  text-decoration: none;
  cursor: default;
}
.ftr a:hover,
.prompt-row a:hover {
  background: var(--inv);
  color: var(--ink);
  text-shadow: none;
}

.viewport {
  flex: 1 1 auto;
  min-height: 0;
  margin: 10px 0 8px;
  overflow: hidden;
  position: relative;
  display: flex;
  flex-direction: column;
}
.viewport.has-scroll {
  padding-right: 12px;
}

/* CRT-style scroll marker (line-rewrite views) — same soft bloom as frames */
.scroll-rail {
  display: none;
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: 8px;
  z-index: 5;
  border-left: 1px solid var(--frame-border);
  background: color-mix(in srgb, var(--bg) 65%, transparent);
  box-shadow: var(--frame-glow);
  pointer-events: none;
}
.scroll-rail.on {
  display: block;
}
.scroll-thumb {
  position: absolute;
  left: 1px;
  right: 1px;
  top: 0;
  min-height: 18px;
  background: var(--bright);
  box-shadow: var(--frame-glow);
}

.viewport .line {
  height: 24px;
  line-height: 24px;
  white-space: pre;
  overflow: hidden;
}
.viewport .line[hidden] {
  display: none !important;
}

/* bottom: prompt, then one status row */
.prompt-row {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--bright);
  min-height: 24px;
  gap: 12px;
}
.prompt-row .prompt {
  display: flex;
  align-items: center;
  min-width: 0;
}
.prompt-row .path {
  color: var(--bright);
}
.prompt-row .nav a {
  margin-left: 14px;
}

#cmdtext {
  color: var(--bright);
  white-space: pre;
}

.boxcur {
  display: inline-block;
  width: 0.55em;
  height: 1em;
  margin-left: 1px;
  background: var(--bright);
  vertical-align: text-bottom;
  animation: boxblink 1.05s step-end infinite;
}

@keyframes boxblink {
  50% {
    opacity: 0;
  }
}

.ftr {
  flex: none;
  color: var(--dim);
  padding-top: 2px;
}
.ftr .stats {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  gap: 2px;
  font-size: 20px;
  line-height: 24px;
  letter-spacing: 0;
}
.ftr .stats > * {
  flex: 1 1 0;
  text-align: center;
  white-space: nowrap;
  min-width: 0;
}
.ftr .stats > *:first-child {
  text-align: left;
}
.ftr .stats > *:last-child {
  text-align: right;
}

/* ---- connect body (nested in viewport) ---- */
.connect-body {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 4px 6px;
  position: relative;
  min-height: 0;
}

.connect-body .connect-main {
  height: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.connect-body.booting .connect-main {
  visibility: hidden;
  pointer-events: none;
  position: absolute;
  inset: 0;
}

.connect-body .boot-log {
  display: none;
  flex: 1;
  margin: 0;
  padding: 4px 2px;
  overflow: hidden;
  white-space: pre-wrap;
  word-break: break-word;
  line-height: 24px;
  color: var(--dim);
  font-family: inherit;
  font-size: inherit;
}

.connect-body.booting .boot-log {
  display: block;
}

.connect-body .boot-log .boot-line {
  min-height: 24px;
}

.connect-body .boot-log .boot-ok {
  color: var(--bright);
}

.connect-body .boot-log .boot-hi {
  color: var(--fg);
}

/* Full-stage IMP / IPL log — chrome stays off until UI spell-out. */
html.connect-booting .hdr,
html.connect-booting .prompt-row,
html.connect-booting .ftr {
  display: none !important;
}

html.connect-booting .viewport {
  margin: 0;
  flex: 1 1 auto;
}

html.connect-booting .page-shell {
  padding: 8px 10px;
}

html.connect-booting .connect-body {
  padding: 2px 4px;
}

/* Chrome / landing blocks stay invisible until spelled. */
html.connect-spelling .hdr,
html.connect-spelling .prompt-row,
html.connect-spelling .ftr {
  opacity: 0;
}

html.connect-spelling.spell-chrome .hdr,
html.connect-spelling.spell-chrome .prompt-row,
html.connect-spelling.spell-chrome .ftr {
  opacity: 1;
  transition: opacity 0.35s step-end;
}

.connect-body .boot-reveal {
  opacity: 0;
}

.connect-body .boot-reveal.on {
  opacity: 1;
}

.connect-body .brand-art {
  opacity: 0;
}

.connect-body .brand-art.on {
  opacity: 1;
  transition: opacity 0.55s linear;
}

.connect-body.boot-done .boot-reveal,
.connect-body.boot-done .brand-art {
  opacity: 1;
  transition: none;
}

.connect-body .status {
  line-height: 24px;
  flex: none;
}
.connect-body .status .status-line {
  min-height: 24px;
}
.connect-body .status .ready {
  margin-top: 20px;
}
.connect-body .status .ready-dot {
  animation: none;
  opacity: 0;
}
.connect-body.boot-done .status .ready-dot {
  opacity: 1;
  animation: none;
}

/* Logo + word + tag as one centered unit */
.brand {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: default;
  min-height: 0;
  width: 100%;
}

.brand-lockup {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 6px;
  margin: 0 auto;
  width: max-content;
  max-width: 100%;
}

.brand-art {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.brand-lockup img.mark,
.brand-art img.mark {
  display: block;
  width: 160px;
  height: auto;
  margin: 0 auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.brand-lockup img.word,
.brand-art img.word {
  display: block;
  width: 280px;
  height: auto;
  margin: 0 auto;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

/* Baked green PNGs → dark ink in light mode */
html.mode-light .brand-lockup img.mark,
html.mode-light .brand-lockup img.word,
html.mode-light .brand-art img.mark,
html.mode-light .brand-art img.word,
html.mode-light #mobile img {
  filter: brightness(0);
  opacity: 0.88;
}

.brand-lockup .tag {
  color: var(--dim);
  letter-spacing: 0.02em;
  white-space: nowrap;
  text-align: center;
  width: 100%;
}

.connect-body .welcome {
  flex: none;
  line-height: 24px;
  margin-top: 8px;
}

/* Localized page bodies (product / company). */
.lang-pack[hidden] {
  display: none !important;
}

/* Shared nested window (menu, NC, records, company, …) */
.inner-win {
  height: calc(100% - 14px);
  margin-top: 14px;
  position: relative;
  border: 1px solid var(--frame-border);
  box-shadow: var(--frame-glow);
  padding: 18px 12px 8px;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.inner-win.nc-panel {
  padding: 18px 10px 8px;
}
.win-title {
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  background: var(--bg);
  padding: 0 12px;
  line-height: 24px;
  color: var(--bright);
  z-index: 2;
  white-space: nowrap;
  pointer-events: none;
}
.inner-win .file-list,
.inner-win .win-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  position: relative;
  margin-top: 2px;
}
.inner-win .file-list.has-scroll {
  padding-right: 10px;
}
/* product record: attrs | dot-raster mark (scrolls with body) */
.viewport .line.pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0 12px;
  white-space: nowrap;
}
.viewport .line.pair.node-mark {
  height: 192px;
  align-items: start;
  overflow: hidden;
  cursor: default;
}
.viewport .line.pair.node-mark:hover .pair-l {
  color: var(--bright);
}
.viewport .line.pair.node-mark:hover .mark-dots {
  opacity: 0.92;
}
.viewport .line.pair.node-mark .pair-l {
  margin: 0;
  font: inherit;
  font-size: inherit;
  line-height: 24px;
  color: var(--fg);
  white-space: pre;
  overflow: hidden;
  min-width: 0;
}
.viewport .line.pair .pair-l {
  overflow: hidden;
  white-space: pre;
  min-width: 0;
}
.viewport .line.pair .mark-dots {
  display: block;
  width: 100%;
  height: 100%;
  max-height: 192px;
  object-fit: contain;
  object-position: center center;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
  min-width: 0;
}
html.mode-light .mark-dots,
html.mode-light #mobile .mark-dots {
  filter: brightness(0);
  opacity: 0.88;
}
#mobile .mark-dots {
  width: min(100%, 320px);
  height: auto;
  image-rendering: pixelated;
  margin: 8px 0 16px;
}

/* Company: lockup at half panel width, motto, TOC, then body. */
.viewport .line.company-hero {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 72px;
  overflow: hidden;
}
.viewport .line.company-hero .company-lockup {
  display: block;
  width: 50%;
  max-width: 50%;
  height: 72px;
  object-fit: contain;
  object-position: center center;
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}
.viewport .line.company-motto-row {
  text-align: center;
}
.viewport .company-motto {
  color: var(--bright);
}
html.mode-light .company-lockup,
html.mode-light #mobile .company-lockup {
  filter: brightness(0);
  opacity: 0.88;
}
#mobile .company-lockup {
  width: 50%;
  max-width: 280px;
  height: auto;
  image-rendering: pixelated;
  margin: 8px 0 8px;
}
#mobile .company-motto {
  margin: 0 0 16px;
  color: var(--bright);
}

.win-foot {
  flex: none;
  margin-top: 6px;
  padding-top: 4px;
  border-top: 1px solid var(--dim);
  color: var(--dim);
}
.win-foot a {
  color: var(--bright);
  text-decoration: none;
  cursor: default;
  padding: 0 2px;
}
.win-foot a:hover {
  background: var(--inv);
  color: var(--ink);
  text-shadow: none;
}

.menu-box {
  padding: 18px 22px 10px;
}
.menu-box nav {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  flex: 1;
  min-height: 0;
  margin-top: 2px;
  padding-top: 4px;
}
.menu-box nav a {
  color: var(--fg);
  text-decoration: none;
  padding: 0 8px;
  min-width: 50%;
  cursor: default;
}
.menu-box nav a:hover,
.menu-box nav a.on {
  background: var(--inv);
  color: var(--ink);
  text-shadow: none;
}

/* Norton Commander columns: Name | Type | Status | Model */
.nc-head {
  flex: none;
  display: grid;
  grid-template-columns: minmax(12ch, 1fr) 6ch 9ch 8ch;
  column-gap: 0;
  color: var(--bright);
  border-bottom: 1px solid var(--fg);
  margin: 6px 0 2px;
  padding: 0 10px 0 4px;
}
.nc-head a {
  padding: 0 4px;
  border-right: 1px solid var(--fg);
  color: inherit;
  text-decoration: none;
  cursor: default;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
}
.nc-head a:last-child {
  border-right: 0;
}
.nc-head a:hover,
.nc-head a.sort-on {
  background: var(--inv);
  color: var(--ink);
  text-shadow: none;
}
.nc-panel .file-list .line {
  height: 24px;
  line-height: 24px;
}
.nc-panel a.row.nc-row {
  display: grid;
  grid-template-columns: minmax(12ch, 1fr) 6ch 9ch 8ch;
  width: 100%;
  min-width: 0;
  padding: 0 4px;
  white-space: pre;
}
html.lang-jp .nc-head,
html.lang-jp .nc-panel a.row.nc-row {
  grid-template-columns: minmax(16ch, 1.35fr) 5ch 7ch 7ch;
}
.nc-panel a.row.nc-row span {
  overflow: hidden;
  text-overflow: clip;
  padding: 0 4px;
  border-right: 1px solid transparent;
}
.nc-panel a.row.nc-row .c-type,
.nc-panel a.row.nc-row .c-status,
.nc-panel a.row.nc-row .c-model {
  color: var(--dim);
}
.nc-panel a.row.nc-row.on,
.nc-panel a.row.nc-row:hover {
  background: var(--inv);
  color: var(--ink);
  text-shadow: none;
}
.nc-panel a.row.nc-row.on span,
.nc-panel a.row.nc-row:hover span {
  color: var(--ink);
}

a.row {
  display: block;
  color: var(--fg);
  text-decoration: none;
  padding: 0 4px;
  width: fit-content;
  min-width: 60%;
  cursor: default;
}
a.row:hover,
a.row.on {
  background: var(--inv);
  color: var(--ink);
  text-shadow: none;
}

/* Line cursor on product / company records (plain text lines). */
.file-list .line.on {
  background: var(--inv);
  color: var(--ink);
  text-shadow: none;
}
.file-list .line.on a.row {
  background: transparent;
  color: inherit;
}
.file-list .line.on .pair-l,
.file-list .line.on [data-i18n] {
  color: inherit;
}

/* mobile */
#mobile {
  display: none;
  padding: 20px 16px 40px;
  background: var(--bg);
  color: var(--fg);
  font-family: "VT323", "DotGothic16", monospace;
  font-size: 20px;
  line-height: 24px;
  min-height: 100%;
}
body.is-mobile #mobile {
  display: block;
}
#mobile a {
  display: block;
  color: var(--fg);
  text-decoration: none;
  padding: 10px 0;
  border-bottom: 1px solid var(--dim);
}
#mobile img {
  width: 120px;
  image-rendering: pixelated;
  margin-bottom: 8px;
}
#mobile pre {
  font-family: "VT323", "DotGothic16", monospace;
  font-size: 20px;
  line-height: 24px;
  color: var(--bright);
  white-space: pre;
  overflow-x: auto;
  margin: 8px 0 16px;
}

/* help overlay */
#help {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 45;
  background: var(--overlay);
  align-items: center;
  justify-content: center;
  font-family: "VT323", "DotGothic16", monospace;
  font-size: 20px;
  line-height: 24px;
  color: var(--fg);
  text-shadow: 0 0 2px var(--glow);
}
#help.on {
  display: flex;
}
#help .panel {
  width: min(520px, 92vw);
  border: 1px solid var(--fg);
  outline: 1px solid var(--fg);
  outline-offset: -3px;
  background: var(--bg);
  padding: 18px 22px 14px;
}
#help .title {
  color: var(--bright);
  margin-bottom: 10px;
}
#help .body {
  line-height: 24px;
  white-space: pre;
  margin-bottom: 14px;
}
#help .row {
  display: flex;
  gap: 16px;
}
#help .cmd {
  flex: 0 0 11em;
  color: var(--bright);
}
#help .desc {
  flex: 1;
  color: var(--dim);
  white-space: normal;
}
#help .actions {
  display: flex;
  align-items: center;
  gap: 14px;
  border-top: 1px solid var(--dim);
  padding-top: 10px;
}
#help .actions a {
  color: var(--bright);
  text-decoration: none;
  padding: 0 8px;
  cursor: default;
}
#help .actions a:hover {
  background: var(--inv);
  color: var(--ink);
  text-shadow: none;
}
#help .esc {
  color: var(--dim);
}

/* brochure: full-viewport slide-up, no blur */
#fax {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 40;
  background: var(--overlay);
  align-items: center;
  justify-content: center;
  font-family: "VT323", "DotGothic16", monospace;
  font-size: 20px;
  line-height: 24px;
  color: var(--fg);
}
html.lang-jp #fax {
  letter-spacing: 0;
}
#fax.on {
  display: flex;
}
#fax .box {
  border: 1px solid var(--fg);
  padding: 14px 18px;
  width: min(400px, 90vw);
  background: var(--bg);
}
#fax .bar {
  margin-top: 10px;
  height: 10px;
  border: 1px solid var(--dim);
}
#fax .fill {
  height: 100%;
  width: 0;
  background: var(--fg);
}
#paper {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 50;
  transform: translateY(100%);
  transition: transform 0.4s ease;
  background: var(--bg);
  display: flex;
  flex-direction: column;
}
#paper.on {
  transform: translateY(0);
}
#paper .paper-bar {
  flex: none;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  padding: 8px 12px;
  background: var(--bg);
  border-bottom: 1px solid var(--fg);
  z-index: 2;
}
#paper button {
  border: 1px solid var(--fg);
  background: var(--bg);
  color: var(--fg);
  font-family: "VT323", "DotGothic16", monospace;
  font-size: 20px;
  line-height: 24px;
  padding: 2px 12px;
  cursor: default;
}
html.lang-jp #paper button {
  letter-spacing: 0;
}
#paper button:hover {
  background: var(--inv);
  color: var(--ink);
}
#paper iframe {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border: 0;
  margin: 0;
  background: #fff;
}
#preload {
  position: absolute;
  width: 0;
  height: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
}

/* Print: black terminal ink on plain paper. No CRT fill, glow, or scan.
 * When a brochure sheet is open (#paper.on / body.print-brochure), print
 * that document only — hide the CRT chrome behind it. */
@media print {
  :root,
  html.mode-light {
    color-scheme: only light;
    --bg: transparent;
    --fg: #000;
    --bright: #000;
    --dim: #000;
    --inv: #000;
    --ink: #000;
    --glow: transparent;
    --frame-border: #000;
    --frame-glow: none;
    --scan: transparent;
    --overlay: transparent;
  }

  html,
  body {
    background: transparent !important;
    color: #000 !important;
    overflow: visible !important;
    height: auto !important;
  }

  body:not(.print-brochure):not(:has(#paper.on)) *,
  body:not(.print-brochure):not(:has(#paper.on)) *::before,
  body:not(.print-brochure):not(:has(#paper.on)) *::after {
    background: transparent !important;
    background-image: none !important;
    box-shadow: none !important;
    text-shadow: none !important;
    color: #000 !important;
    border-color: #000 !important;
    outline-color: #000 !important;
    -webkit-print-color-adjust: economy;
    print-color-adjust: economy;
  }

  #fax,
  #help,
  #preload,
  #link-tree-launch,
  #mobile,
  #stage::after,
  .scroll-rail,
  .scroll-thumb {
    display: none !important;
  }

  /* CRT console print (brochure closed) */
  body:not(.print-brochure):not(:has(#paper.on)) #paper {
    display: none !important;
  }

  body:not(.print-brochure):not(:has(#paper.on)) #stage-wrap {
    position: static !important;
    inset: auto !important;
    display: block !important;
    background: transparent !important;
  }

  body:not(.print-brochure):not(:has(#paper.on)) #desk {
    transform: none !important;
  }

  body:not(.print-brochure):not(:has(#paper.on)) #stage {
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    overflow: visible !important;
    border: 1px solid #000 !important;
    background: transparent !important;
  }

  #view-main[hidden],
  #view-tree[hidden] {
    display: none !important;
  }

  body:not(.print-brochure):not(:has(#paper.on)) img,
  body:not(.print-brochure):not(:has(#paper.on)) .mark-dots,
  body:not(.print-brochure):not(:has(#paper.on)) .brand-lockup img,
  body:not(.print-brochure):not(:has(#paper.on)) .brand-art img,
  body:not(.print-brochure):not(:has(#paper.on)) .company-lockup {
    filter: grayscale(1) brightness(0);
  }

  /* Brochure open: print the sheet only */
  body.print-brochure #stage-wrap,
  body:has(#paper.on) #stage-wrap,
  body.print-brochure #link-tree-launch,
  body:has(#paper.on) #link-tree-launch,
  body.print-brochure #mobile,
  body:has(#paper.on) #mobile {
    display: none !important;
  }

  body.print-brochure #paper,
  body:has(#paper.on) #paper {
    display: flex !important;
    position: static !important;
    inset: auto !important;
    transform: none !important;
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    background: #fff !important;
    z-index: auto !important;
  }

  body.print-brochure #paper .paper-bar,
  body:has(#paper.on) #paper .paper-bar {
    display: none !important;
  }

  body.print-brochure #paper iframe,
  body:has(#paper.on) #paper iframe {
    display: block !important;
    width: 100% !important;
    height: auto !important;
    min-height: 100vh !important;
    border: 0 !important;
    background: #fff !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }
}
