/* TempleOS's 16-color palette and pixel grid; see docs/DESIGN.md.
   --u is 1px on phones, 2px on larger screens. Chrome stays LTR; content
   follows its language. Safe-area insets keep controls clear of notches.
   Font coverage and shaping: docs/LOCALIZATION.md and tools/fontgen/. */

@font-face {
  font-family: "TempleOS 8x8";
  src: url("/static/fonts/templeos-8x8.woff?v=77d33cc69114") format("woff");
  font-display: swap;
}

/* GNU Unifont, subset to the language menu's other scripts
   (tools/fontgen/build_unifont.py). Preloaded on /language; elsewhere it
   loads with the Brahmic fonts when the menu opens. block keeps names in
   their intended font rather than briefly drawing a fallback. */
@font-face {
  font-family: "Unifont";
  src: url("/static/fonts/unifont-lang.woff2?v=3fa90daecd0e") format("woff2"), url("/static/fonts/unifont-lang.woff?v=c021b05223a5") format("woff");
  font-display: block;
}

/* The Brahmic pixel fonts, one per script Unifont cannot shape: Noto Sans
   redrawn in pixels, shaping intact (tools/fontgen/build_brahmic.py). Not
   preloaded: each loads when the menu first shows a string in its script
   (38 KB in WOFF2 for all fourteen). Meanwhile block keeps those names blank rather
   than in another font, and .brahmic.<script> keeps each row its size. */
@font-face { font-family: "Pixel Brahmic Devanagari"; src: url("/static/fonts/pixel-brahmic-deva.woff2?v=1129ff67cd24") format("woff2"), url("/static/fonts/pixel-brahmic-deva.woff?v=17a126a02355") format("woff"); font-display: block; }
@font-face { font-family: "Pixel Brahmic Bengali"; src: url("/static/fonts/pixel-brahmic-beng.woff2?v=a65bd265688b") format("woff2"), url("/static/fonts/pixel-brahmic-beng.woff?v=574d66303c25") format("woff"); font-display: block; }
@font-face { font-family: "Pixel Brahmic Gurmukhi"; src: url("/static/fonts/pixel-brahmic-guru.woff2?v=04b1dd9c8b28") format("woff2"), url("/static/fonts/pixel-brahmic-guru.woff?v=264004d07fec") format("woff"); font-display: block; }
@font-face { font-family: "Pixel Brahmic Gujarati"; src: url("/static/fonts/pixel-brahmic-gujr.woff2?v=dae7d8ea5c9b") format("woff2"), url("/static/fonts/pixel-brahmic-gujr.woff?v=93a7bcdc72ad") format("woff"); font-display: block; }
@font-face { font-family: "Pixel Brahmic Oriya"; src: url("/static/fonts/pixel-brahmic-orya.woff2?v=221a8068114d") format("woff2"), url("/static/fonts/pixel-brahmic-orya.woff?v=403200322878") format("woff"); font-display: block; }
@font-face { font-family: "Pixel Brahmic Tamil"; src: url("/static/fonts/pixel-brahmic-taml.woff2?v=c54acba979ea") format("woff2"), url("/static/fonts/pixel-brahmic-taml.woff?v=9573c41ab6ec") format("woff"); font-display: block; }
@font-face { font-family: "Pixel Brahmic Telugu"; src: url("/static/fonts/pixel-brahmic-telu.woff2?v=d2dfc22b68c3") format("woff2"), url("/static/fonts/pixel-brahmic-telu.woff?v=da9dcb82bc0e") format("woff"); font-display: block; }
@font-face { font-family: "Pixel Brahmic Kannada"; src: url("/static/fonts/pixel-brahmic-knda.woff2?v=10f1d4498287") format("woff2"), url("/static/fonts/pixel-brahmic-knda.woff?v=1eaf0f0a13bb") format("woff"); font-display: block; }
@font-face { font-family: "Pixel Brahmic Malayalam"; src: url("/static/fonts/pixel-brahmic-mlym.woff2?v=cf16b85b7ab6") format("woff2"), url("/static/fonts/pixel-brahmic-mlym.woff?v=f876989ef1ae") format("woff"); font-display: block; }
@font-face { font-family: "Pixel Brahmic Sinhala"; src: url("/static/fonts/pixel-brahmic-sinh.woff2?v=3508d45bb190") format("woff2"), url("/static/fonts/pixel-brahmic-sinh.woff?v=7ce40a60f37c") format("woff"); font-display: block; }
@font-face { font-family: "Pixel Brahmic Thai"; src: url("/static/fonts/pixel-brahmic-thai.woff2?v=1b9fe22b2829") format("woff2"), url("/static/fonts/pixel-brahmic-thai.woff?v=7c6fecb9b204") format("woff"); font-display: block; }
@font-face { font-family: "Pixel Brahmic Lao"; src: url("/static/fonts/pixel-brahmic-laoo.woff2?v=f143c7e8da8b") format("woff2"), url("/static/fonts/pixel-brahmic-laoo.woff?v=55d42c676e84") format("woff"); font-display: block; }
@font-face { font-family: "Pixel Brahmic Myanmar"; src: url("/static/fonts/pixel-brahmic-mymr.woff2?v=ed2c77c93310") format("woff2"), url("/static/fonts/pixel-brahmic-mymr.woff?v=3acf305bdbb7") format("woff"); font-display: block; }
@font-face { font-family: "Pixel Brahmic Khmer"; src: url("/static/fonts/pixel-brahmic-khmr.woff2?v=6831da8149c7") format("woff2"), url("/static/fonts/pixel-brahmic-khmr.woff?v=6991a67e741a") format("woff"); font-display: block; }

:root {
  --black: #000000;
  --blue: #0000AA;
  --red: #AA0000;
  --purple: #AA00AA;
  --brown: #AA5500;
  --ltgray: #AAAAAA;
  --dkgray: #555555;
  --ltgreen: #55FF55;
  --ltcyan: #55FFFF;
  --ltred: #FF5555;
  --yellow: #FFFF55;
  --white: #FFFFFF;

  --u: 1px;
  /* Pixel chrome uses multiples of the 8px cell; Unifont's 16px cell is
     doubled to match. Keep each font's line-height and reserved row spacing.
     Body text and unsupported menu strings use --mono. See docs/LOCALIZATION.md. */
  --pixel: "TempleOS 8x8", ui-monospace, Menlo, Consolas, monospace;
  --pixel-size: 16px;
  --unifont: "Unifont", ui-monospace, Menlo, Consolas, monospace;
  --unifont-size: 32px;
  --unifont-line: 40px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --bar: 40px; /* top bar height, without the top inset */
}

@media (min-width: 600px) {
  :root { --u: 2px; }
}

/* Arabic script has no monospace form. The monospace fonts' fallbacks draw
   it monospaced, its letters spread apart: Courier New in Chromium and
   Firefox on macOS and Windows, and WebKit's own cascade for ui-monospace
   and Menlo on macOS and iOS. So Arabic, Persian and Urdu pages take the
   Arabic letters, and only those (unicode-range), from the systems' Arabic
   text fonts first (macOS and iOS, Android, Windows); Latin text in those
   pages keeps the monospace fonts after it. These faces are installed
   fonts (local()), so nothing is downloaded. */
@font-face {
  font-family: "Arabic Text";
  src: local("Geeza Pro"), local("Geeza Pro Regular"), local("GeezaPro"), local("Noto Naskh Arabic"), local("NotoNaskhArabic-Regular"),
       local("Noto Sans Arabic"), local("NotoSansArabic-Regular"), local("Segoe UI"), local("SegoeUI"), local("Tahoma");
  font-weight: normal;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
@font-face {
  font-family: "Arabic Text";
  src: local("Geeza Pro Bold"), local("GeezaPro-Bold"), local("Noto Naskh Arabic Bold"), local("NotoNaskhArabic-Bold"),
       local("Noto Sans Arabic Bold"), local("NotoSansArabic-Bold"), local("Segoe UI Bold"), local("SegoeUI-Bold"), local("Tahoma Bold"), local("Tahoma-Bold");
  font-weight: bold;
  unicode-range: U+0600-06FF, U+0750-077F, U+0870-08FF, U+FB50-FDFF, U+FE70-FEFF;
}
:lang(ar), :lang(fa), :lang(ur) {
  --mono: "Arabic Text", ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", "Geeza Pro", "Noto Naskh Arabic", "Noto Sans Arabic", "Segoe UI", Tahoma, monospace;
}

*, *::before, *::after { box-sizing: border-box; }

html {
  background: var(--dkgray);
  scroll-padding-top: calc(var(--bar) + 8px + var(--safe-top));
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  margin: 0;
  background: var(--dkgray);
  color: var(--blue);
  font: 14px/1.6 var(--mono);
}

@media (min-width: 600px) {
  body { font-size: 15px; }
}

a { color: var(--red); text-underline-offset: 2px; }

a:focus-visible,
button:focus-visible {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
  box-shadow: 0 0 0 2px var(--black);
}

.skip {
  position: absolute;
  top: -100px;
  left: max(8px, var(--safe-left));
  z-index: 10;
  padding: 12px 16px;
  background: var(--yellow);
  color: var(--blue);
  font: 16px/16px var(--pixel);
}
.skip:focus { top: calc(8px + var(--safe-top)); }

/* Top bar: BLACK, a BLUE/YELLOW MENU chip, one tab per page, and the
   language globe at the right end. The tabs give way (the current one is
   cut with an ellipsis) before anything overlaps the globe. */

.topbar {
  position: sticky;
  top: 0;
  z-index: 3;
  display: flex;
  gap: 8px;
  align-items: center;
  height: calc(var(--bar) + var(--safe-top));
  padding: var(--safe-top) var(--safe-right) 0 var(--safe-left);
  background: var(--black);
  font: 16px/16px var(--pixel);
  direction: ltr;
}

.topbar > .start { flex: none; }

.tabs { display: flex; flex: 0 1 auto; gap: 8px; min-width: 0; }

.tabs > * {
  min-width: 0;
  padding: 8px 12px;
  background: var(--dkgray);
  color: var(--white);
  text-decoration: none;
  white-space: nowrap;
  overflow-x: clip;
  text-overflow: ellipsis;
}
.tabs > [aria-current="page"] { background: var(--white); color: var(--blue); }

/* Like the apps' top bar, show only the current tab when the others do not fit. */
@media (max-width: 479px) {
  .tabs > :not([aria-current]) { display: none; }
}

/* The language globe: a BLUE chip like MENU, with the YELLOW pixel globe
   (templates/base.html) in a 44 x 40 target. It opens a popover (Escape
   and a tap outside close it, no script); browsers without popovers get a
   link to /language instead. While open, the chip is inverted. */

.lang { flex: none; margin-left: auto; }

.globe {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: var(--bar);
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: var(--blue);
  color: var(--yellow);
  font: inherit;
  cursor: pointer;
}
.globe-icon { display: block; width: 22px; height: 22px; }

.globe-button,
.lang-menu { display: none; }

@supports selector(:popover-open) {
  .globe-link { display: none; }
  .globe-button { display: flex; }
  .lang-menu:popover-open { display: block; }
  .lang:has(.lang-menu:popover-open) .globe-button { background: var(--yellow); color: var(--blue); }
}

/* One layout for the popover and the fallback page. The 48 rem cap gives
   pairs of names room on desktop without stretching across the monitor.
   A wrapped pair gets 8 px between its labels; the 10 px padding on each
   option leaves 20 px between options. Single-line targets stay 44 px. */
.lang-menu,
.lang-page {
  --language-width: 48rem;
  --option-padding: 10px;
  --option-min-height: 44px;
  --label-gap: 16px;
  --label-wrap-gap: 8px;
  --language-line: 24px;
}

/* The menu drops from the right end of the top bar, inside the safe area
   and dynamic viewport. One scroll container includes the naturally sized
   heading: even in a very short window no fixed header can cover a row. */
.lang-menu {
  position: fixed;
  inset: calc(var(--bar) + var(--safe-top)) max(8px, var(--safe-right)) auto auto;
  width: min(var(--language-width), calc(100vw - 16px - var(--safe-left) - var(--safe-right)));
  max-height: calc(100vh - var(--bar) - var(--safe-top) - var(--safe-bottom) - 16px);
  max-height: calc(100dvh - var(--bar) - var(--safe-top) - var(--safe-bottom) - 16px);
  margin: 0;
  padding: 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--blue);
  color: var(--yellow);
  border: max(1px, var(--u)) solid var(--yellow);
  box-shadow: calc(var(--u) * 4) calc(var(--u) * 4) 0 var(--black);
  font: var(--pixel-size)/var(--language-line) var(--pixel);
}

/* macOS font smoothing widens every glyph's edges, which rings each square
   of the pixel fonts with part-covered pixels; without it the squares are
   drawn exactly, in the text and background colors only (tools/browsercheck
   checks this). The platform windows' text too. */
.lang-menu,
.lang-page,
.uni,
.brahmic,
.platform { -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }

/* .doc .langs: the /language page is a document, whose lists otherwise get
   "* " bullets, which would read as the "not translated yet" mark. */
.langs, .doc .langs { margin: 0; padding: 4px 0; list-style: none; }
.langs > li, .doc .langs > li { margin: 0; break-inside: avoid; }

/* A row is the language's own name, then its English name at the row's end
   (on the next line when both do not fit). Each name is a block of whole
   lines (24 px, or --unifont-line in Unifont) placed from the row's edges,
   never after the other name's text: a .sys name has a fractional width
   and height, and pixel-font letters set after it would fall between
   device pixels and blur. The whole row is the link, however many lines
   its names take. Han and kana break only where a name has punctuation or
   a space (繁體中文 / （台灣）), unless a word is wider than the menu. */
.langs a {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  gap: var(--label-wrap-gap) var(--label-gap);
  min-height: var(--option-min-height);
  padding-block: var(--option-padding);
  padding-inline: 40px 16px;
  color: var(--yellow);
  text-decoration: none;
  word-break: keep-all;
  overflow-wrap: anywhere; /* a word wider than a narrow phone's menu */
}
/* Prefer each label's natural width. Wrap the pair before compressing it
   into two columns; only a label wider than the whole row wraps internally.
   Isolate each script without changing the interface's row direction. */
.langs .native,
.langs .english {
  flex: 0 0 auto;
  min-width: 0;
  max-width: 100%;
  unicode-bidi: isolate;
}
.langs a:focus-visible { outline-offset: -4px; box-shadow: none; }
.langs a[aria-current]::before {
  content: "\221A";
  content: "\221A" / ""; /* aria-current says it; not read out as "square root" */
  position: absolute;
  inset-inline-start: 16px;
  color: var(--ltgreen);
  font: var(--pixel-size)/24px var(--pixel); /* also in a .uni or .sys row */
}
/* In a row with Unifont or Brahmic text the names share their first
   baseline: 32 px down a Unifont line, 14 px lower than in a TempleOS
   line, and 42 px down a Brahmic line, 24 px lower; the TempleOS text and
   the √ move down by those whole pixels. (A .sys name's baseline is
   fractional, so .sys rows keep their names top-aligned.) */
.langs a:is(.uni, .brahmic, :has(> .uni, > .brahmic)) { align-items: baseline; }
.langs a:is(.uni, :has(> .uni))[aria-current]::before { top: calc(var(--option-padding) + 14px); }
.langs a:is(.brahmic, :has(> .brahmic))[aria-current]::before { top: calc(var(--option-padding) + 24px); }
/* Names, like every string of the menu, are in the menu's pixel font when
   it has all their characters, and otherwise .uni or .sys. The English
   name is dir="ltr" even in a right-to-left menu, so its margin toward the
   row's start is set by the row's direction, not by logical properties. */
.langs .english { margin-left: auto; color: var(--ltcyan); text-align: right; }
.langs a:dir(rtl) .english { margin-left: 0; margin-right: auto; text-align: left; }
/* The lines of a wrapped name start at the row's start too, whatever the
   name's own direction, so a right-to-left name in a left-to-right menu
   stays in line with the names above it (Firefox and Chromium otherwise
   disagree on which side its lines take). */
.langs .native { text-align: left; }
.langs a:dir(rtl) .native { text-align: right; }
.langs .pending { color: var(--ltgray); }
.langs .english .pending { margin-inline-start: 1ch; }

.lang-menu .legend,
.lang-page .legend {
  margin: 0;
  padding: 10px 16px 12px;
  border-top: max(1px, var(--u)) solid var(--yellow);
  color: var(--ltgray);
  overflow-wrap: anywhere; /* a word wider than the menu (Tamil's are long) */
}

.lang-menu .menu-title,
.lang-page .menu-title { padding-block: var(--option-padding); overflow-wrap: anywhere; }

/* /language: the same list in a BLUE dialog, in columns where there is room. */
.lang-page {
  margin: 12px 0;
  background: var(--blue);
  color: var(--yellow);
  border: max(1px, var(--u)) solid var(--yellow);
  font: var(--pixel-size)/var(--language-line) var(--pixel);
}
.lang-page .langs { columns: 17rem; column-gap: 0; }

/* "Not translated yet": the apps' toast, small, at the top of the document. */
.l10n-notice {
  margin: 0 0 16px;
  padding: 8px 12px;
  background: var(--black);
  color: var(--yellow);
  border: max(1px, var(--u)) solid var(--yellow);
  font-size: 13px;
}
.l10n-notice a { color: var(--yellow); }

/* Strings the pixel font cannot draw: a character outside ASCII and code
   page 437 (l10n.PixelSafe), such as Č, ’ or any other script. The whole
   string is set in another font, never mixed within a word. The language
   menu decides string by string (pageData.Face, internal/web/fonts.go):
   Unifont (.uni) when it has every character, else the Brahmic pixel font
   of the string's script (.brahmic), else .sys. The chrome and the page
   headings decide by group, with .sys only (internal/web/views.go).

   .uni: GNU Unifont at --unifont-size on --unifont-line lines (:root), at
   every screen width, the /language title included: names wrap or rows
   grow instead. Its strings appear only in the language menu and on
   /language (TestUnifontScope). Its baseline is 7/8 of the em down, like
   the TempleOS font's, and its lines are whole pixels tall, so its squares
   stay whole. It inherits the 24 px lines of the lists it is in, so this
   one rule sets its own. */
.uni,
.doc .uni { font-family: var(--unifont); font-weight: normal; font-size: var(--unifont-size); line-height: var(--unifont-line); }
/* .brahmic: the Brahmic pixel font of the string's script (the second
   class: .deva, .beng, ... ISO 15924), with Unifont's spaces and
   punctuation. Its em is 16 pixels like Unifont's, so it is drawn at
   --unifont-size, in the same 2 x 2 CSS-pixel squares. Each script's line
   is its font's own height: the ascent all fourteen share (20 pixels, so
   every baseline is 42 px down its line), its deepest ink, and 2 pixels
   between wrapped lines (TestBrahmicFonts checks these against the
   files). Its strings appear only in the language menu and on /language. */
.brahmic,
.doc .brahmic { font-family: var(--brahmic-face), var(--unifont); font-weight: normal; font-size: var(--unifont-size); }
.brahmic.deva { --brahmic-face: "Pixel Brahmic Devanagari"; line-height: 58px; }
.brahmic.beng { --brahmic-face: "Pixel Brahmic Bengali"; line-height: 54px; }
.brahmic.guru { --brahmic-face: "Pixel Brahmic Gurmukhi"; line-height: 52px; }
.brahmic.gujr { --brahmic-face: "Pixel Brahmic Gujarati"; line-height: 56px; }
.brahmic.orya { --brahmic-face: "Pixel Brahmic Oriya"; line-height: 54px; }
.brahmic.taml { --brahmic-face: "Pixel Brahmic Tamil"; line-height: 56px; }
.brahmic.telu { --brahmic-face: "Pixel Brahmic Telugu"; line-height: 58px; }
.brahmic.knda { --brahmic-face: "Pixel Brahmic Kannada"; line-height: 58px; }
.brahmic.mlym { --brahmic-face: "Pixel Brahmic Malayalam"; line-height: 56px; }
.brahmic.sinh { --brahmic-face: "Pixel Brahmic Sinhala"; line-height: 54px; }
.brahmic.thai { --brahmic-face: "Pixel Brahmic Thai"; line-height: 52px; }
.brahmic.laoo { --brahmic-face: "Pixel Brahmic Lao"; line-height: 50px; }
.brahmic.mymr { --brahmic-face: "Pixel Brahmic Myanmar"; line-height: 62px; }
.brahmic.khmr { --brahmic-face: "Pixel Brahmic Khmer"; line-height: 56px; }
/* .sys: the system monospace, bold like the TempleOS font's two-pixel
   strokes (the apps use the bold system font), and an eighth larger than
   the TempleOS text it stands in for (--pixel-size), so its x-height
   matches the font's (5 of 8 rows). In the language menu, only for a
   script no pixel font covers (none at present; TestMenuFaces). */
.sys,
.doc .sys,
.chrome-sys .topbar,
.chrome-sys .chrome,
.chrome-sys .menu > nav,
.chrome-sys .keys,
.chrome-sys .skip,
.content-sys .doc h1,
.content-sys .doc h2,
.content-sys .store-os,
.content-sys .soon,
.content-sys .button,
.platform-text .sys { font-family: var(--mono); font-weight: bold; font-size: calc(var(--pixel-size) * 1.125); }
.chrome-sys .tabs > * { padding-block: 4px; line-height: 24px; }

/* Menus: TempleOS BLUE with YELLOW text and border. MENU and the
   window's ≡ MENU are buttons that open their menu as a popover
   (templates/base.html), without script; while it is open the chip is
   inverted, like the globe. Their labels are controls, not text to
   select. Browsers without popovers get neither button. */

.menu-button {
  display: none;
  margin: 0;
  border: 0;
  border-radius: 0;
  font: inherit;
  white-space: nowrap;
  cursor: pointer;
  -webkit-user-select: none;
  user-select: none;
}

@supports selector(:popover-open) {
  .menu-button { display: block; }
  .menu > nav:popover-open { display: block; }
}

.start > .menu-button {
  padding: 12px 16px;
  background: var(--blue);
  color: var(--yellow);
}
.start:has(> nav:popover-open) > .menu-button { background: var(--yellow); color: var(--blue); }

/* The site menu drops from the top bar's left end, under MENU. */
.menu > nav {
  display: none;
  position: fixed;
  inset: calc(var(--bar) + var(--safe-top)) auto auto var(--safe-left);
  width: max-content;
  min-width: 240px;
  max-width: calc(100vw - 16px - var(--safe-left) - var(--safe-right));
  max-height: calc(100dvh - var(--bar) - var(--safe-top) - var(--safe-bottom) - 16px);
  margin: 0;
  padding: 4px 0;
  overflow: auto;
  overscroll-behavior: contain;
  background: var(--blue);
  color: var(--yellow);
  border: max(1px, var(--u)) solid var(--yellow);
  box-shadow: calc(var(--u) * 4) calc(var(--u) * 4) 0 var(--black);
  font: 16px/16px var(--pixel);
}

.menu-title { margin: 0; padding: 14px 16px; color: var(--white); }

.menu nav a {
  display: block;
  padding-block: 10px;
  padding-inline: 40px 16px;
  line-height: 24px;
  color: var(--yellow);
  text-decoration: none;
}
.menu nav a[aria-current="page"]::before {
  content: "\221A";
  float: inline-start;
  margin-inline-start: -24px;
  color: var(--ltgreen);
}

/* Desktop and window: double-line BLUE border with the title drawn into it. */

/* Phones: the window fills the width, as in the apps' portrait window deck. */
.desktop {
  flex: 1 0 auto;
  padding: 10px max(2px, var(--safe-right)) 2px max(2px, var(--safe-left));
}

@media (min-width: 600px) {
  .desktop { padding: 28px max(20px, var(--safe-right)) 28px max(20px, var(--safe-left)); }
}

/* Two screens side by side (a dual-screen phone, or a foldable folded like a
   book): the window keeps to the first screen, so no line of text crosses
   the hinge. Progressive: other browsers ignore it. */
@media (horizontal-viewport-segments: 2) {
  .desktop { padding-inline-end: calc(100vw - env(viewport-segment-right 0 0, 100vw) + 20px); }
  .window { margin-inline: 0; }
}

.window {
  position: relative;
  max-width: 880px;
  margin: 0 auto;
  padding: 12px 4px 4px;
  background: var(--white);
  border: solid var(--blue);
  border-width: var(--u) calc(var(--u) * 2);
  box-shadow: 0 0 0 calc(var(--u) * 2) var(--white);
}

@media (min-width: 600px) {
  .window { padding: calc(var(--u) * 5) calc(var(--u) * 4) calc(var(--u) * 4); }
}

.window::before,
.platform-window::before {
  content: "";
  position: absolute;
  inset: var(--u);
  border: solid var(--blue);
  border-width: var(--u) calc(var(--u) * 2);
  pointer-events: none;
}

.window-title {
  position: absolute;
  top: calc(var(--u) - 8px);
  left: calc(var(--u) * 12);
  z-index: 1;
  max-width: calc(100% - var(--u) * 24);
  margin: 0;
  overflow: hidden;
  background: var(--white);
  color: var(--blue);
  font: 16px/16px var(--pixel);
  white-space: pre;
  text-overflow: ellipsis;
}

.chrome {
  direction: ltr;
  display: flex;
  justify-content: space-between;
  background: var(--blue);
  font: 16px/16px var(--pixel);
}

.window-menu > .menu-button { padding: 8px; background: none; color: var(--yellow); }
.window-menu .glyph { color: var(--white); }
.window-menu:has(> nav:popover-open) > .menu-button,
.window-menu:has(> nav:popover-open) .glyph { background: var(--yellow); color: var(--blue); }
/* The sections menu drops from ≡ MENU and scrolls with the window where
   anchor positioning exists, at its full length (the page scrolls to the
   rest); elsewhere it opens under the top bar, like the site menu. */
@supports (anchor-name: --a) {
  .window-menu > .menu-button { anchor-name: --page-menu; }
  .window-menu > nav {
    position: absolute;
    position-anchor: --page-menu;
    inset: anchor(bottom) auto auto anchor(left);
    max-height: none;
    overflow: visible;
  }
}

.close {
  padding: 8px 12px;
  color: var(--ltred);
  text-decoration: none;
}

/* Document: DolDoc colors. BLUE text on WHITE, PURPLE titles, RED links. */

.doc {
  max-width: calc(70ch + 56px);
  margin: 0 auto;
  padding: 16px 12px 20px;
  overflow-wrap: break-word;
}

@media (min-width: 600px) {
  .doc { padding: 24px 28px 28px; }
}

.doc p, .doc ul, .doc dl { margin: 0 0 12px; }
.doc ul { padding-inline-start: 2ch; list-style-type: "* "; }
.doc li { margin-bottom: 6px; }

.doc h1, .doc h2 {
  color: var(--purple);
  font-family: var(--pixel);
  font-weight: normal;
}

.doc h1 { margin: 8px 0; font-size: var(--pixel-size); line-height: 1.5; }
.doc h2 { margin: 28px 0 8px; font-size: 16px; line-height: 1.5; }

@media (min-width: 480px) {
  .doc h1 { --pixel-size: 24px; }
}

@media (min-width: 720px) {
  .doc h1 { --pixel-size: 32px; }
}

.doc-header { margin-bottom: 20px; text-align: center; }
.doc-header > p { margin: 0; }
/* The TempleOS logo spans 70% of the header. The width and height attributes
   reserve its space before it loads. */
.logo { display: block; width: 70%; height: auto; margin: 4px auto 8px; }
/* The standalone download window shares the site's chrome and palette. */
.download-page .window { max-width: 720px; }
.download-page .doc-header > p { margin-bottom: 8px; }
.download-page .stores { grid-template-columns: repeat(auto-fit, minmax(min(13rem, 100%), 1fr)); }
.download-page .store h2 { margin: 0; }
.download-page .button { max-width: 100%; line-height: 1.5; }
.date, .fine { color: var(--dkgray); }
.fine { font-size: 13px; }
/* Names and code are Latin, left to right, in every language. Each is
   isolated, so that inside right-to-left text it is drawn as written: C:
   keeps its colon after the C, and the punctuation around it stays the
   sentence's. */
.name { color: var(--red); unicode-bidi: isolate; direction: ltr; }

/* The contact address is an image of RED body text (tools/contactpng), so
   that it is not in the page as text; never replace it with text, an email
   link or an encoded form. The image spans 1.0em above the baseline to 0.2em
   below it, so it lines up and scales with the text around it. Its RED has
   no underline because it is not a link. */
.contact-email {
  width: auto;
  height: 1.2em;
  max-width: 100%;
  vertical-align: -0.2em;
  object-fit: contain;
  object-position: left center;
}
.nowrap { white-space: nowrap; }
code { font-family: var(--mono); font-size: 1em; unicode-bidi: isolate; direction: ltr; }

.sources dt { color: var(--black); font-weight: bold; }
.sources dd { margin: 0 0 14px; padding-inline-start: 2ch; }

.statement .signature { margin-top: 4px; }

/* Store availability on /download: small dialog-style panels under the
   page's name. The header is centered; the panels read from their start. */

.doc .stores {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(13rem, 1fr));
  gap: 12px;
  margin: 12px 0 16px;
  padding: 0;
  list-style: none;
  text-align: start;
}

.store {
  margin: 0;
  padding: 12px 14px 14px;
  border: max(1px, var(--u)) solid var(--blue);
}
.store p { margin: 0; }
.store-os { font: 16px/1.5 var(--pixel); }

.soon { margin-top: 10px; color: var(--brown); font: 16px/1.5 var(--pixel); }
.soon .where { display: block; color: var(--dkgray); font: 13px/1.6 var(--mono); }

/* Platform windows (templates/base.html, "platform"): the home page's App
   Store and Google Play windows under its name, and the GitHub window in
   "Source code". Each is a small window of the apps' portrait deck: .window's
   double-line BLUE frame and WHITE gaps, the BLUE title strip with WHITE ≡,
   the apps' name and LTRED X (drawWindow), then the platform's mark and its
   phrase, the dialog's BLACK text with the name large in its BLUE title
   color. One column, at most 400 px wide. The window's own width decides
   the layout (container queries): the mark above the phrase, beside it from
   336 px, with more room from 360 px. The name wraps only on the narrowest
   phones.
   No motion. Hover and keyboard focus invert the strip, like an open MENU
   chip; a press gives the body the apps' pressed button face (DrawCtrlBttn:
   BLUE, YELLOW label) and a WHITE mark. Only colors change, so nothing moves.
   (Mobile Safari applies :active only for pages with touch handlers, and the
   site runs no script; there its own tap highlight is the press feedback.) */

.doc .platforms {
  display: grid;
  grid-template-columns: min(100%, 400px);
  gap: 12px;
  margin: 12px 0 16px;
  padding: 0;
  list-style: none;
}
.doc-header .platforms { justify-content: center; margin: 16px 0 20px; }
.doc .platforms > li { margin: 0; }

.platform {
  display: block;
  width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: 0;
  background: none;
  color: var(--black);
  font: inherit;
  text-align: start;
  text-decoration: none;
  cursor: pointer;
}

.platform-window {
  position: relative;
  display: block;
  padding: calc(var(--u) * 5) calc(var(--u) * 4) calc(var(--u) * 4);
  background: var(--white);
  border: solid var(--blue);
  border-width: var(--u) calc(var(--u) * 2);
  container-type: inline-size;
}

.platform-bar {
  direction: ltr;
  display: flex;
  gap: 8px;
  padding: 4px 8px;
  background: var(--blue);
  color: var(--white);
  font: 16px/16px var(--pixel);
  white-space: nowrap;
}
.platform-title { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.platform-x { color: var(--ltred); }

.platform-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 12px 0 8px; /* centered: the phrase's own margins, so it fits 320 px phones */
  text-align: center;
}
.platform-icon { display: block; flex: none; width: 48px; height: 48px; }
.platform-text { display: block; min-width: 0; overflow-wrap: anywhere; }
/* A phrase the pixel font cannot draw is .sys, sized from --pixel-size. */
.platform-intro { --pixel-size: 16px; display: block; font: var(--pixel-size)/24px var(--pixel); }
.platform-brand { --pixel-size: 24px; display: block; color: var(--blue); font: var(--pixel-size)/32px var(--pixel); }

@container (min-width: 336px) {
  .platform-body { flex-direction: row; gap: 8px; padding: 12px 8px; text-align: start; }
}
@container (min-width: 360px) {
  .platform-body { gap: 16px; padding: 16px; }
}
/* Too narrow for the strip's glyphs (200% zoom on a small phone): only the
   title stays. */
@container (max-width: 255px) {
  .platform-bar > .platform-glyph { display: none; }
}

@media (hover: hover) {
  .platform:hover .platform-bar { background: var(--yellow); color: var(--blue); }
  .platform:hover .platform-x { color: var(--red); }
}
.platform:focus-visible .platform-bar { background: var(--yellow); color: var(--blue); }
.platform:focus-visible .platform-x { color: var(--red); }
.platform:active .platform-body { background: var(--blue); color: var(--yellow); }
.platform:active .platform-brand { color: var(--yellow); }
.platform:active .platform-icon { filter: brightness(0) invert(1); }

/* TEMPORARY-APP-STORE-SOON: remove this block when the App Store launches;
   see docs/LOCALIZATION.md, "Temporary App Store overlay". */
.platform:disabled { position: relative; cursor: default; opacity: 1; }
.platform:disabled .platform-window { filter: grayscale(1); }
.platform:disabled .platform-body { background: var(--ltgray); color: var(--dkgray); }
.platform:disabled .platform-bar { background: var(--dkgray); color: var(--white); }
.platform:disabled .platform-brand,
.platform:disabled .platform-x { color: var(--dkgray); }
.platform-soon {
  --pixel-size: 24px;
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  color: var(--yellow);
  font: var(--pixel-size)/32px var(--pixel);
  text-align: center;
  overflow-wrap: anywhere;
  text-shadow: 2px 2px var(--black), -1px -1px var(--black), 1px -1px var(--black), -1px 1px var(--black);
  pointer-events: none;
}

/* Notice: the apps' toast, BLACK with a YELLOW frame. */

.notice {
  margin: 28px 0 4px;
  padding: 12px 14px;
  background: var(--black);
  color: var(--yellow);
  border: max(1px, var(--u)) solid var(--yellow);
}
.notice p { margin: 0; }

/* Footer: the apps' key row of TempleOS buttons (DrawCtrlBttn: BLACK frame,
   LTCYAN face, label in face XOR WHITE = RED). .button is the same button
   on its own, such as "View on GitHub". */

.site-footer {
  padding: 0 var(--safe-right) max(16px, var(--safe-bottom)) var(--safe-left);
  background: var(--black);
  color: var(--ltgray);
  font-size: 13px;
}

.keys {
  direction: ltr;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  font: 16px/16px var(--pixel);
}

/* Wider screens: one row, the keys sharing the full width equally. */
@media (min-width: 560px) {
  .keys { grid-template-columns: none; grid-auto-flow: column; grid-auto-columns: 1fr; }
}

/* A label longer than its key (German Datenschutz on a 320 px phone) is
   hyphenated in the page's language, or else broken, inside the key, never
   wider than it. */
.keys a { min-width: 0; overflow-wrap: anywhere; -webkit-hyphens: auto; hyphens: auto; }

.keys a,
.button {
  padding: 14px 4px;
  background: var(--ltcyan);
  color: var(--red);
  text-align: center;
  text-decoration: none;
  box-shadow: inset 0 0 0 calc(var(--u) * 2) var(--black);
}
.keys a:focus-visible,
.button:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: -8px;
  box-shadow: inset 0 0 0 calc(var(--u) * 2) var(--black);
}

.button { display: inline-block; margin-top: 10px; padding: 14px 8px; font: 16px/16px var(--pixel); }

.site-footer p { max-width: 880px; margin: 12px auto 0; padding: 0 16px; }
.site-footer p a { color: var(--yellow); }
