/* AppLab Digital LLP — Classic System UI */

/* ── Tokens ── */

:root {
  --ink: #000000;
  --paper: #ffffff;
  --chrome: #dcdcdc;
  --rule: #c8c8c8;
  --desk: #808080;
  --desk-lit: #d0d0d0;
  --icon-filter: url("#oneBit");

  /* Geneva is still installed on macOS and is literally the system's own body
     face from this era; Verdana is its closest widely-installed relative
     elsewhere. Deliberately NOT system-ui — that resolves to SF Pro, whose
     contemporary shapes are what made the earlier draft read as a modern site
     wearing a costume. */
  --font-chrome: "Silkscreen", "ChiKareGo2", "Chicago", monospace;
  --font-ui: Geneva, Verdana, "DejaVu Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;

  --menubar-h: 26px;
  --titlebar-h: 22px;
  --gutter: 16px;
  --shadow: 2px 2px 0 var(--ink);

  --pattern-size: 2px;
}

[data-theme="dark"] {
  --ink: #e8e8e8;
  --paper: #0a0a0a;
  --chrome: #1c1c1c;
  --rule: #333333;
  --desk: #2a2a2a;
  --desk-lit: #0e0e0e;
  --icon-filter: url("#oneBit") brightness(0.92);
}

/* ── 1-bit textures ── */
/* Every tile is an SVG mask drawn at its intrinsic size and never scaled, so it
   rasterises on integer device pixels at any DPR. Colour comes from a token
   underneath the mask — that is what makes the dark inversion free. */

:root {
  --tile-stripes: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1' height='2' shape-rendering='crispEdges'%3E%3Crect width='1' height='1' fill='%23000'/%3E%3C/svg%3E");
  --tile-checker: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='2' height='2' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h1v1H0zM1 1h1v1H1z' fill='%23000'/%3E%3C/svg%3E");

  --pattern-tile: var(--tile-checker);
}

[data-pattern="fifty"]   { --pattern-tile: var(--tile-checker); --pattern-size: 2px; }
[data-pattern="dots"]    { --pattern-size: 4px; --pattern-tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h1v1H0z' fill='%23000'/%3E%3C/svg%3E"); }
[data-pattern="sparse"]  { --pattern-size: 8px; --pattern-tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h1v1H0zM4 4h1v1H4z' fill='%23000'/%3E%3C/svg%3E"); }
[data-pattern="grid"]    { --pattern-size: 8px; --pattern-tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h8v1H0zM0 0h1v8H0z' fill='%23000'/%3E%3C/svg%3E"); }
[data-pattern="diagonal"]{ --pattern-size: 4px; --pattern-tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='4' height='4' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h1v1H0zM1 1h1v1H1zM2 2h1v1H2zM3 3h1v1H3z' fill='%23000'/%3E%3C/svg%3E"); }
[data-pattern="bricks"]  { --pattern-size: 8px; --pattern-tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h8v1H0zM0 4h8v1H0zM0 1h1v3H0zM4 5h1v3H4z' fill='%23000'/%3E%3C/svg%3E"); }
[data-pattern="weave"]   { --pattern-size: 8px; --pattern-tile: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='8' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h4v1H0zM4 1h4v1H4zM0 2h4v1H0zM4 3h4v1H4zM4 4h1v4H4zM0 4h1v4H0z' fill='%23000'/%3E%3C/svg%3E"); }

/* ── Reset ── */

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

html {
  -webkit-text-size-adjust: 100%;
}

body {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: 13.5px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

img {
  display: block;
  max-width: 100%;
}

button {
  font: inherit;
  color: inherit;
  background: none;
  border: 0;
  cursor: default;
}

a {
  color: inherit;
}

::selection {
  background: var(--ink);
  color: var(--paper);
}

/* ── Typography ── */
/* Silkscreen is drawn on an 8px grid: it is crisp at 16px and multiples of 8, and
   antialiased at everything else. It is therefore used ONLY for chrome, at 16px
   or larger. Every word a visitor actually reads is set in --font-ui. */

.chrome-type,
.menubar-title,
.menu button,
.menu a,
.window-title-text,
.menubar-clock,
.s7-btn,
.legal-doc-title {
  font-family: var(--font-chrome);
  font-weight: 400;
  letter-spacing: 0;
  /* Silkscreen has one weight; a synthesised bold would smear the pixel grid. */
  font-synthesis: none;
}

.doc-note {
  font-size: 12.5px;
  margin-top: 10px;
  opacity: 0.75;
}

.meta-label {
  font-size: 10.5px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

/* ── Utilities ── */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.skip-link {
  position: absolute;
  left: 4px;
  top: -60px;
  z-index: 400;
  background: var(--paper);
  border: 1px solid var(--ink);
  padding: 6px 10px;
  font-size: 13px;
  text-decoration: none;
}

.skip-link:focus {
  top: 4px;
}

.sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

/* Icons are pixel grids, not strokes: one path of paper cells under one path of
   ink cells, so both themes invert and nothing is ever half a pixel wide.
   The colours travel as custom properties because each <use> is a shadow tree
   that ordinary descendant selectors cannot reach into. */
.art {
  shape-rendering: crispEdges;
  --art-paper: var(--paper);
  --art-ink: var(--ink);
}

.is-selected .art {
  --art-paper: var(--ink);
  --art-ink: var(--paper);
}

:focus-visible {
  outline: 2px solid var(--ink);
  outline-offset: 2px;
}

/* ── Menu bar ── */

.menubar {
  position: sticky;
  top: 0;
  z-index: 200;
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 0;
  height: var(--menubar-h);
  padding: 0 6px;
  background: var(--paper);
  border-bottom: 1px solid var(--ink);
}

.menubar-title {
  display: flex;
  align-items: center;
  padding: 0 10px;
  font-size: 16px;
  line-height: 1;
  white-space: nowrap;
}

.menubar-title[aria-expanded="true"] {
  background: var(--ink);
  color: var(--paper);
}

/* A finger has no hover. On a touch screen :hover latches on tap and leaves the
   control inverted until something else is tapped, which reads as a stuck
   button — so every invert-on-hover rule is asked for a pointer first. */
@media (hover: hover) {
  .menubar-title:hover {
    background: var(--ink);
    color: var(--paper);
  }
}

.menubar-title--glyph {
  padding: 0 12px;
}

.glyph-mark {
  display: block;
  width: 13px;
  height: 13px;
  background: currentColor;
  clip-path: polygon(50% 0, 100% 38%, 81% 100%, 19% 100%, 0 38%);
}

.menubar-clock {
  margin-left: auto;
  display: flex;
  align-items: center;
  padding: 0 6px;
  font-family: var(--font-chrome);
  font-size: 16px;
}

/* ── Menus ── */

.menu {
  position: absolute;
  top: var(--menubar-h);
  z-index: 210;
  min-width: 210px;
  list-style: none;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: var(--shadow);
  padding: 3px 0;
}

.menu[hidden] {
  display: none;
}

.menu li {
  display: block;
}

.menu button,
.menu a {
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  padding: 3px 14px;
  font-size: 16px;
  line-height: 1.35;
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
}

.menu button::after,
.menu a::after {
  content: attr(data-key);
  margin-left: auto;
  opacity: 0.55;
}

.menu button:focus-visible,
.menu a:focus-visible {
  background: var(--ink);
  color: var(--paper);
  outline: none;
}

@media (hover: hover) {
  .menu button:hover:not([aria-disabled="true"]),
  .menu a:hover {
    background: var(--ink);
    color: var(--paper);
    outline: none;
  }
}

.menu [aria-disabled="true"] {
  opacity: 0.32;
}

.menu [role="menuitemradio"]::before {
  content: "";
  width: 10px;
  flex: 0 0 10px;
}

.menu [role="menuitemradio"][aria-checked="true"]::before {
  content: "\2713";
}

.menu-sep {
  height: 1px;
  margin: 3px 0;
  background: var(--rule);
}

/* ── Desktop ── */

.desk {
  position: relative;
  flex: 1 1 auto;
  overflow: hidden;
  background: var(--desk);
}

.desk::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--desk-lit);
  -webkit-mask-image: var(--pattern-tile);
  mask-image: var(--pattern-tile);
  -webkit-mask-size: var(--pattern-size) var(--pattern-size);
  mask-size: var(--pattern-size) var(--pattern-size);
  -webkit-mask-repeat: repeat;
  mask-repeat: repeat;
  pointer-events: none;
}

[data-pattern="solid"] .desk::before {
  display: none;
}

/* ── Desktop icons ── */

/* z-index 0 keeps the icons behind every window: a zoomed window must not leave
   a strip of desktop icons sitting on top of its content. */
.desk-icons {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
  list-style: none;
}

.desk-icon {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  width: 84px;
  padding: 4px 2px;
}

/* 32px against a 16-cell grid: every icon pixel is exactly two CSS pixels. */
.desk-icon-art {
  width: 32px;
  height: 32px;
}

.desk-icon-label {
  font-size: 11.5px;
  line-height: 1.25;
  text-align: center;
  background: var(--paper);
  color: var(--ink);
  padding: 1px 4px;
  border: 1px solid transparent;
}

.desk-icon.is-selected .desk-icon-label {
  background: var(--ink);
  color: var(--paper);
}

@media (hover: hover) {
  .desk-icon:hover .desk-icon-label {
    background: var(--ink);
    color: var(--paper);
  }
}

.desk-icon.is-selected .art {
  fill: var(--ink);
  stroke: var(--paper);
}

/* ── Window chrome ── */

.desk-layer {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

/* display:flex would otherwise defeat the hidden attribute, leaving stacked
   windows in the accessibility tree on mobile. */
.window[hidden],
.desk-icons[hidden] {
  display: none;
}

.window {
  position: absolute;
  display: flex;
  flex-direction: column;
  max-width: calc(100% - 16px);
  max-height: calc(100% - 16px);
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: var(--shadow);
  pointer-events: auto;
  animation: winOpen 0.09s steps(3) both;
}

@keyframes winOpen {
  from { clip-path: inset(46% 46% 46% 46%); }
  to   { clip-path: inset(0); }
}

.window.is-dragging {
  z-index: 1;
}

.window-titlebar {
  position: relative;
  flex: 0 0 var(--titlebar-h);
  height: var(--titlebar-h);
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 5px;
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
  touch-action: manipulation;
  cursor: default;
}

.window.is-active .window-titlebar::before {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--ink);
  -webkit-mask-image: var(--tile-stripes);
  mask-image: var(--tile-stripes);
  -webkit-mask-size: 1px 2px;
  mask-size: 1px 2px;
  -webkit-mask-repeat: repeat;
  mask-repeat: repeat;
  pointer-events: none;
}

.window-close,
.window-zoom {
  position: relative;
  z-index: 1;
  flex: 0 0 12px;
  width: 12px;
  height: 12px;
  background: var(--paper);
  border: 1px solid var(--ink);
  text-decoration: none;
}

.window-zoom {
  margin-left: auto;
}

.window-zoom::after {
  content: "";
  position: absolute;
  left: 1px;
  top: 1px;
  width: 6px;
  height: 6px;
  border: 1px solid var(--ink);
}

@media (hover: hover) {
  .window-close:hover,
  .window-zoom:hover {
    background: var(--ink);
  }

  .window-close:hover::after,
  .window-zoom:hover::after {
    border-color: var(--paper);
  }
}

.window-title {
  position: relative;
  z-index: 1;
  margin: 0 auto;
  font-size: 16px;
  font-weight: 400;
  line-height: 1;
}

.window-title-text {
  display: block;
  background: var(--paper);
  padding: 0 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 46vw;
}

.window:not(.is-active) .window-title-text {
  opacity: 0.55;
}

.window-body {
  flex: 1 1 auto;
  overflow: auto;
  padding: 14px var(--gutter);
  padding-bottom: calc(14px + env(safe-area-inset-bottom));
}

.window--info .window-body,
.window--dialog .window-body {
  padding: 14px var(--gutter) 16px;
}

.window--finder .window-body,
.window--legal .window-body {
  padding: 0;
}

.window--legal .legal-doc-header {
  padding: 18px var(--gutter) 14px;
}

.window--legal .legal-prose {
  padding: 18px var(--gutter) 26px;
}

.doc-loading {
  padding: 22px var(--gutter);
  font-size: 13px;
}

/* ── Window body & documents ── */

.doc-source {
  padding: 24px 16px 40px;
}

.js .doc-source {
  display: none;
}

.kv-list {
  margin-top: 14px;
  border-top: 1px solid var(--rule);
}

.kv {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  padding: 5px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 12.5px;
}

.kv dt {
  color: var(--ink);
  opacity: 0.6;
  white-space: nowrap;
}

.kv dd {
  text-align: right;
  font-weight: 600;
}

.doc-links {
  list-style: none;
  border-top: 1px solid var(--rule);
}

.doc-links li {
  border-bottom: 1px solid var(--rule);
}

.doc-links a {
  display: block;
  padding: 7px 2px;
  font-size: 13.5px;
}

@media (hover: hover) {
  .doc-links a:hover {
    background: var(--ink);
    color: var(--paper);
  }
}

.contact-email {
  font-size: 15px;
  word-break: break-all;
}

/* ── Finder: shared ── */

.finder-header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 10px;
  background: var(--chrome);
  border-bottom: 1px solid var(--ink);
  font-size: 11px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.finder {
  min-height: 60px;
}

/* The empty catalogue is a state the window is meant to hold, not an error
   message: it keeps the Finder's own measure and reads as a notice. */
.apps-empty {
  padding: 18px 16px 20px;
  font-size: 13px;
  line-height: 1.45;
  max-width: 46ch;
}

.apps-empty strong {
  display: block;
  margin-bottom: 3px;
  letter-spacing: 0.02em;
}

/* App artwork sits in a 1-bit room, so it is posterised to four greys by default
   and returns to full colour on hover — the same "desaturated until you point at
   it" move the sibling site uses, translated into this palette. */
.fl-icon,
.fi-icon,
.fs-icon,
.info-icon-img {
  filter: var(--icon-filter);
  border: 1px solid var(--rule);
  image-rendering: pixelated;
  transition: filter 0.08s;
}

.is-selected .fl-icon,
.is-selected .fi-icon,
.is-selected .fs-icon {
  filter: none;
}

@media (hover: hover) {
  .fl-row:hover .fl-icon,
  .fi-cell:hover .fi-icon,
  .fs-cell:hover .fs-icon {
    filter: none;
  }
}

.fl-icon-placeholder,
.fi-icon-placeholder,
.fs-icon-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--ink);
  background: var(--paper);
  font-size: 9px;
  letter-spacing: 0.02em;
}

/* ── Finder: list view ── */

.fl {
  list-style: none;
}

.fl-row {
  display: grid;
  grid-template-columns: 20px minmax(0, 1fr) 96px auto;
  align-items: center;
  gap: 10px;
  padding: 5px 10px;
  border-bottom: 1px solid var(--rule);
}

.fl-icon-cell,
.fi-icon-cell,
.fs-icon-cell {
  display: flex;
  align-items: center;
  justify-content: center;
}

.fl-icon,
.fl-icon-placeholder {
  width: 18px;
  height: 18px;
}

.fl-name {
  display: block;
  text-align: left;
  font-size: 13px;
  line-height: 1.3;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.fl-kind {
  font-size: 11.5px;
  opacity: 0.7;
  white-space: nowrap;
}

.fl-links {
  display: flex;
  gap: 10px;
  font-size: 11px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.fl-links a {
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

/* ── Finder: icon views ── */

.fi {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(112px, 1fr));
  gap: 6px;
  padding: 14px 10px;
}

.fi-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 4px;
  text-align: center;
}

.fi-icon,
.fi-icon-placeholder {
  width: 48px;
  height: 48px;
}

.fi-icon-placeholder {
  font-size: 14px;
}

.fi-name {
  font-size: 12px;
  line-height: 1.25;
  background: var(--paper);
  padding: 1px 4px;
}

.fi-links {
  display: flex;
  gap: 8px;
  font-size: 10.5px;
  text-transform: uppercase;
}

.fs {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 2px 10px;
  padding: 10px;
}

.fs-cell {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 3px 4px;
}

.fs-icon,
.fs-icon-placeholder {
  width: 16px;
  height: 16px;
  flex: 0 0 16px;
}

.fs-name {
  font-size: 12.5px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ── Selection & focus ── */
/* Selection is a full inversion, focus is an outline: the two must never be
   confusable, and System 7's own 1px dotted focus ring vanishes at DPR 1. */

.fl-row.is-selected,
.fi-cell.is-selected,
.fs-cell.is-selected {
  background: var(--ink);
  color: var(--paper);
}

.fi-cell.is-selected .fi-name,
.fs-cell.is-selected .fs-name {
  background: var(--ink);
  color: var(--paper);
}

.is-selected .fl-icon,
.is-selected .fi-icon,
.is-selected .fs-icon {
  border-color: var(--paper);
}

@media (hover: hover) {
  .fl-name:hover,
  .fi-name:hover,
  .fs-name:hover {
    text-decoration: underline;
  }
}

/* ── Buttons & controls ── */

.s7-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 84px;
  padding: 3px 16px;
  font-size: 16px;
  line-height: 1.4;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--ink);
  border-radius: 6px;
  text-decoration: none;
  cursor: default;
}

@media (hover: hover) {
  .s7-btn:hover {
    background: var(--ink);
    color: var(--paper);
  }
}

/* The rings must be concentric, which means the button itself needs the radius —
   a square ring around a rounded button is the classic tell of a fake dialog. */
.s7-btn--default {
  margin: 3px;
  box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink);
}

.s7-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  margin-top: 16px;
}

.s7-field {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  padding: 3px 0;
}

.s7-radio {
  width: 13px;
  height: 13px;
  flex: 0 0 13px;
  border: 1px solid var(--ink);
  border-radius: 50%;
  background: var(--paper);
  position: relative;
}

[aria-checked="true"] > .s7-radio::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  background: var(--ink);
}

/* ── Scrollbars ── */
/* Native scrollbars, restyled. A hand-drawn scrollbar looks marginally better and
   breaks wheel, keyboard and touch scrolling — not a trade worth making. */

.window-body {
  scrollbar-width: auto;
  scrollbar-color: var(--paper) var(--chrome);
}

.window-body::-webkit-scrollbar {
  width: 15px;
  height: 15px;
}

.window-body::-webkit-scrollbar-track {
  background-color: var(--chrome);
  border-left: 1px solid var(--ink);
}

.window-body::-webkit-scrollbar-thumb {
  background-color: var(--paper);
  border: 1px solid var(--ink);
}

.window-body::-webkit-scrollbar-button:single-button {
  height: 15px;
  background-color: var(--paper);
  border: 1px solid var(--ink);
}

.window-body::-webkit-scrollbar-corner {
  background-color: var(--chrome);
}

/* ── Get Info ── */

.info-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--ink);
}

.info-icon-img,
.info-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
}

.info-name {
  display: block;
  font-size: 14px;
  font-weight: 600;
  line-height: 1.25;
}

.info-sub {
  display: block;
  font-size: 11.5px;
  opacity: 0.7;
  margin-top: 2px;
}

.info-blurb {
  margin-top: 12px;
  font-size: 12.5px;
  line-height: 1.55;
}

.info-note {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--rule);
  font-size: 11px;
  opacity: 0.7;
}


/* ── Control panel: Appearance ── */

.cp-section {
  padding: 4px 0 12px;
}

.cp-legend {
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.6;
  padding-bottom: 8px;
}

.cp-patterns {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.cp-swatch {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  font-size: 10.5px;
  padding: 4px 2px;
  border: 1px solid transparent;
}

.cp-swatch[aria-checked="true"] {
  border-color: var(--ink);
}

.cp-swatch-art {
  width: 100%;
  height: 34px;
  border: 1px solid var(--ink);
  background-color: var(--desk);
  position: relative;
  overflow: hidden;
}

/* The swatch carries its own data-pattern, so the same [data-pattern] rules that
   theme the desktop also theme the preview — no second set of tiles. */
.cp-swatch-art::after {
  content: "";
  position: absolute;
  inset: 0;
  background-color: var(--desk-lit);
  -webkit-mask-image: var(--pattern-tile);
  mask-image: var(--pattern-tile);
  -webkit-mask-size: var(--pattern-size) var(--pattern-size);
  mask-size: var(--pattern-size) var(--pattern-size);
}

.cp-swatch[data-pattern="solid"] .cp-swatch-art::after {
  display: none;
}

.cp-divider {
  height: 1px;
  background: var(--rule);
  margin: 4px 0 12px;
}

/* ── Dialogs ── */

.window--dialog {
  min-width: 300px;
}

.dialog-body {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.dialog-text {
  font-size: 13px;
  line-height: 1.55;
}

.dialog-icon {
  width: 32px;
  height: 32px;
  flex: 0 0 32px;
}

/* ── Legal pages ── */

.desk--static {
  overflow: auto;
  padding: 22px 16px 34px;
}

.window--static {
  position: relative;
  margin: 0 auto;
  max-width: 78ch;
  width: 100%;
  max-height: none;
  animation: none;
}

.window--static.is-wide {
  max-width: 118ch;
}

.window--static .window-body {
  overflow: visible;
  padding: 0;
}

.legal-doc-header {
  padding: 26px var(--gutter) 18px;
  border-bottom: 1px solid var(--ink);
}

.back-link {
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

.legal-doc-header .label {
  margin-top: 16px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.6;
}

.legal-doc-title {
  margin-top: 6px;
  font-size: 24px;
  line-height: 1.25;
}

.legal-doc-meta {
  margin-top: 10px;
  font-size: 11.5px;
  opacity: 0.7;
}

.legal-prose {
  padding: 22px var(--gutter) 34px;
  max-width: 72ch;
  font-size: 14.5px;
  line-height: 1.62;
}

.legal-prose h2 {
  margin: 30px 0 10px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
  font-size: 15px;
  line-height: 1.3;
}

.legal-prose h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: 0;
}

.legal-prose h3 {
  margin: 20px 0 6px;
  font-size: 13.5px;
}

.legal-prose p,
.legal-prose li {
  margin-bottom: 12px;
}

.legal-prose ul,
.legal-prose ol {
  margin: 0 0 12px 22px;
}

.legal-prose li {
  margin-bottom: 6px;
}

.legal-prose a {
  text-decoration: underline;
}

.legal-prose strong {
  font-weight: 600;
}

/* ── Desk footer ── */

.desk-footer {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 6px 12px calc(6px + env(safe-area-inset-bottom));
  background: var(--paper);
  border-top: 1px solid var(--ink);
  font-size: 11px;
  letter-spacing: 0.03em;
}

.desk-footer-links {
  display: flex;
  gap: 14px;
}

.desk-footer a {
  text-decoration: none;
  border-bottom: 1px solid currentColor;
}

/* ── No-JS fallback ── */
/* With scripting off the desktop simply renders every document as a paper sheet,
   which reads as "all the windows are already open and tiled". */

.no-js .desk-icons,
.no-js .menu,
.no-js .menubar-clock {
  display: none;
}

.no-js .desk {
  overflow: visible;
}

.no-js .doc {
  position: relative;
  max-width: 720px;
  margin: 0 auto 22px;
  background: var(--paper);
  border: 1px solid var(--ink);
  box-shadow: var(--shadow);
  padding: 40px var(--gutter) 16px;
}

.no-js .doc::before {
  content: attr(data-window-title);
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  height: var(--titlebar-h);
  display: flex;
  align-items: center;
  justify-content: center;
  border-bottom: 1px solid var(--ink);
  background: var(--paper);
  font-family: var(--font-chrome);
  font-size: 16px;
}

.no-js .window--finder .window-body,
.no-js .finder {
  padding: 0;
}

/* ── Reduced motion ── */

@media (prefers-reduced-motion: reduce) {
  .window {
    animation: none;
  }

  * {
    transition: none !important;
  }
}

/* ── Mobile ── */
/* The breakpoint below MUST stay identical to the matchMedia query in site.js:
   a mismatch is the classic cause of windows keeping stale coordinates. */

/* With hover gone the press has to carry the feedback: the same invert the
   desktop gets on hover, for exactly as long as the finger is down. */
@media (hover: none) {
  .menubar-title:active,
  .menu button:active:not([aria-disabled="true"]),
  .menu a:active,
  .doc-links a:active,
  .window-close:active,
  .s7-btn:active,
  .desk-icon:active .desk-icon-label {
    background: var(--ink);
    color: var(--paper);
  }
}

@media (max-width: 767px) {
  /* 26px of menu bar and 22px of title bar are mouse measurements. On a phone
     that chrome is the entire navigation, so it grows to something a thumb can
     land on without the desktop losing its proportions. */
  :root {
    --menubar-h: 34px;
    --titlebar-h: 42px;
  }

  a,
  button {
    touch-action: manipulation;
  }

  .menubar {
    padding-left: max(2px, env(safe-area-inset-left));
    padding-right: max(2px, env(safe-area-inset-right));
  }

  .menubar-title {
    padding: 0 9px;
  }

  .menu button,
  .menu a {
    padding: 9px 14px;
  }

  .doc-links a {
    padding: 11px 2px;
  }

  /* The support address is the point of the Contact window and the one thing a
     visitor taps there, so it gets a target rather than a line of text. */
  .contact-email {
    display: inline-block;
    padding: 7px 0;
  }

  .menu {
    left: 0;
    right: 0;
    min-width: 0;
    max-height: 60dvh;
    overflow: auto;
    box-shadow: none;
    border-left: 0;
    border-right: 0;
  }

  /* Windows become a stack of full-width sheets in normal flow rather than a
     canvas: the page scrolls natively, the footer stays reachable, and there is
     no 100dvh arithmetic to get wrong when the address bar collapses. */
  .desk {
    overflow: visible;
  }

  /* relative + z-index keeps in-flow windows above the desk pattern layer,
     which is absolutely positioned and would otherwise paint over them. */
  .desk-layer {
    position: relative;
    z-index: 1;
    pointer-events: auto;
  }

  /* With every window closed these four are the home screen, so they lay out as
     a grid of real targets rather than a column of 84px mouse icons. */
  .desk-icons {
    position: relative;
    z-index: 1;
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
    padding: 14px 12px;
  }

  /* 100%, not auto: a button sizes to its content even as a flex container, so
     auto would leave the icon and its label huddled at the left of the cell. */
  .desk-icon {
    width: 100%;
    gap: 7px;
    padding: 13px 6px;
  }

  /* A short document used to be padded out to the full screen, so Contact was a
     line of text above half a screen of nothing and the footer was always one
     scroll away. The window ends where its content does; the desk fills the
     rest, which is what a desk is for. */
  .window {
    position: static;
    width: 100%;
    max-width: none;
    height: auto !important;
    max-height: none !important;
    min-height: 0;
    border-left: 0;
    border-right: 0;
    border-top: 0;
    box-shadow: none;
    animation: none;
  }

  .window-body {
    overflow: visible;
  }

  .window-titlebar {
    position: sticky;
    top: var(--menubar-h);
    z-index: 5;
  }

  .window-zoom {
    display: none;
  }

  /* The close box becomes a labelled back control: on a phone the stack is the
     navigation, so an unlabelled 12px square is both the only way out and the
     hardest thing on the screen to hit. */
  .window-close.is-back,
  .window--static .window-close {
    flex: 0 0 auto;
    width: auto;
    min-width: 62px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 9px;
  }

  .window-close.is-back::before,
  .window--static .window-close::before {
    font-family: var(--font-chrome);
    font-size: 13px;
    line-height: 1;
  }

  .window-close.is-back::before {
    content: "\2039\00a0" attr(data-label);
  }

  /* One step down in the title, one step up in the room it gets: the long
     window names read whole instead of ending in an ellipsis. */
  .window-title {
    font-size: 14px;
  }

  .window-title-text {
    max-width: 62vw;
  }

  .fl-row {
    grid-template-columns: 20px minmax(0, 1fr);
    grid-template-areas:
      "icon name"
      "kind kind"
      "links links";
    gap: 4px 10px;
    padding: 8px 10px;
  }

  .fl-icon-cell { grid-area: icon; }
  .fl-name { grid-area: name; white-space: normal; }
  .fl-kind { grid-area: kind; }
  .fl-links { grid-area: links; margin-top: 2px; }

  .fi {
    grid-template-columns: repeat(3, 1fr);
  }

  .fs {
    grid-template-columns: repeat(2, 1fr);
  }

  .cp-patterns {
    grid-template-columns: repeat(2, 1fr);
  }

  .desk--static {
    padding: 0;
  }

  /* Positioned, not static: .desk::before is an absolutely positioned overlay,
     so a static document is painted underneath it and the desk pattern shows
     straight through the text. Same reason .desk-layer is raised above. */
  .window--static {
    position: relative;
    z-index: 1;
    max-width: none;
    border: 0;
    border-bottom: 1px solid var(--ink);
    box-shadow: none;
  }

  /* A policy read from a store listing is the one page some visitors ever see,
     so its way back is the same labelled control the windows carry. */
  .window--static .window-close::before {
    /* The space terminates the escape: without it "\00a0D" reads as one six-digit
       code point and the D disappears into it. */
    content: "\2039\00a0 Desktop";
  }

  .window--static .window-titlebar {
    position: sticky;
    top: var(--menubar-h);
    z-index: 5;
  }

  /* The sticky title bar already carries the way back, and it never scrolls
     away — a second Desktop link under it is only clutter on a phone. */
  .window--static .back-link {
    display: none;
  }
}

/* ── Print ── */

@media print {
  .menubar,
  .desk-icons,
  .desk-footer,
  .window-titlebar,
  .back-link,
  .skip-link {
    display: none !important;
  }

  /* The only literal colours outside the token blocks: print is always ink on
     paper, whichever desktop theme the reader happened to be using. */
  body,
  .desk,
  .desk--static,
  .window {
    background: #ffffff;
    color: #000000;
    border: 0;
    box-shadow: none;
    padding: 0;
    margin: 0;
  }

  .desk::before {
    display: none;
  }

  .legal-prose {
    max-width: none;
    font-size: 11pt;
  }
}
