/*
 * discord.ozmium.org - the token layer, lifted verbatim from the root "Ozmium App UI Kit.html".
 *
 * WHAT CHANGED AND WHY. This surface used to be glass: translucent panes, backdrop-filter blur, a slow
 * gradient field behind everything. The kit says the opposite in as many words - "Cards are near-black,
 * separated by hairlines, never by shadow", "Depth comes from hairlines and near-black layering, not from
 * drop shadows". It is also the exact construction that black-screens WKWebView inside Base App. So the
 * blur is gone, the field is gone, and every colour, size, radius and duration below is a token from the
 * kit rather than a number chosen here.
 */

:root {
  color-scheme: dark;

  /* -- Base palette -- */
  --oz-bg: #0b0b0c;
  --oz-ink: #f4f2ec;
  --oz-muted: #9a968c;
  --oz-gold: #f5c400;
  --oz-gold-deep: #b8940a;
  --oz-up: #34d399;
  --oz-down: #fb7185;
  --oz-black: #000;

  /* -- Surfaces -- */
  --oz-surface-1: #121214;
  --oz-surface-2: #131315;
  --oz-surface-alpha-1: rgba(255, 255, 255, .02);
  --oz-surface-alpha-2: rgba(255, 255, 255, .03);
  --oz-surface-alpha-3: rgba(255, 255, 255, .04);
  --oz-surface-alpha-4: rgba(255, 255, 255, .05);
  --oz-surface-alpha-5: rgba(255, 255, 255, .06);
  --oz-surface-alpha-6: rgba(255, 255, 255, .08);
  --oz-surface-alpha-7: rgba(255, 255, 255, .10);
  --oz-scrim: rgba(0, 0, 0, .45);

  /* -- Hairlines -- */
  --oz-line-faint: rgba(255, 255, 255, .03);
  --oz-line: rgba(255, 255, 255, .06);
  --oz-line-strong: rgba(255, 255, 255, .12);
  --oz-line-gold: rgba(245, 196, 0, .30);
  --oz-line-up: rgba(52, 211, 153, .30);
  --oz-line-down: rgba(251, 113, 133, .30);

  /* -- Tints -- */
  --oz-tint-gold: rgba(245, 196, 0, .08);
  --oz-tint-gold-soft: rgba(245, 196, 0, .04);
  --oz-tint-up: rgba(52, 211, 153, .10);
  --oz-tint-down: rgba(251, 113, 133, .10);

  /* -- Semantic aliases: reach for these first -- */
  --text-primary: var(--oz-ink);
  --text-secondary: var(--oz-muted);
  --text-tertiary: rgba(154, 150, 140, .60);
  --text-accent: var(--oz-gold);
  --text-on-accent: var(--oz-black);
  --surface-page: var(--oz-bg);
  --surface-card: var(--oz-surface-alpha-2);
  --surface-card-solid: var(--oz-surface-1);
  --surface-sheet: var(--oz-surface-2);
  --surface-input: var(--oz-surface-alpha-3);
  --surface-hover: var(--oz-surface-alpha-5);
  --border-card: var(--oz-line);
  --border-input: var(--oz-line-strong);
  --accent: var(--oz-gold);

  /* -- Type -- */
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;
  --text-9: 9px; --text-10: 10px; --text-11: 11px; --text-12: 12px; --text-13: 13px;
  --text-14: 14px; --text-15: 15px; --text-16: 16px; --text-17: 17px; --text-18: 18px;
  --text-22: 22px; --text-26: 26px;
  --weight-normal: 400; --weight-medium: 500; --weight-semibold: 600; --weight-bold: 700;
  --tracking-tight: -.025em; --tracking-wide: .025em; --tracking-wider: .05em;
  --tracking-label: .18em; --tracking-wordmark: .22em;
  --leading-none: 1; --leading-tight: 1.25; --leading-snug: 1.375; --leading-normal: 1.5;
  --type-screen-title: var(--weight-semibold) var(--text-18)/var(--leading-tight) var(--font-sans);
  --type-body: var(--weight-normal) var(--text-14)/var(--leading-snug) var(--font-sans);
  --type-body-sm: var(--weight-normal) var(--text-13)/var(--leading-snug) var(--font-sans);
  --type-caption: var(--weight-normal) var(--text-11)/var(--leading-snug) var(--font-sans);
  --type-label: var(--weight-semibold) var(--text-10)/var(--leading-none) var(--font-sans);

  /* -- Space -- */
  --space-1: 4px; --space-1-5: 6px; --space-2: 8px; --space-2-5: 10px; --space-3: 12px;
  --space-4: 16px; --space-5: 20px; --space-6: 24px; --space-8: 32px;
  --layout-gutter: 16px;
  --layout-max: 72rem;
  --card-padding: 12px;
  --card-gap: 8px;
  --row-height: 44px;
  --header-height: 52px;

  /* -- Radius -- */
  --radius-sm: .25rem; --radius-md: .375rem; --radius-lg: .5rem; --radius-xl: .75rem;
  --radius-2xl: 1rem; --radius-full: 9999px;

  /* -- Depth. Shadows appear only where something floats over content. -- */
  --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, .25);
  --shadow-sheet: 0 -8px 40px rgba(0, 0, 0, .55);

  /* -- Motion -- */
  --duration-fast: .15s;
  --duration-med: .25s;
  --ease-standard: cubic-bezier(.4, 0, .2, 1);
  --transition-default: all var(--duration-fast) var(--ease-standard);
  --press-scale: .98;

  /* -- Discord's own scale. Partner colours, used only to draw Discord's chrome. -- */
  --dc-bg: #313338;
  --dc-embed: #2b2d31;
  --dc-text: #dbdee1;
  --dc-muted: #949ba4;
  --dc-link: #00a8fc;
  --dc-blurple: #5865f2;

  --safe-bottom: env(safe-area-inset-bottom, 0px);
  /* How much of the viewport the software keyboard is covering. Published by keyboard.ts. */
  --kb: 0px;
}

@keyframes oz-spin { to { transform: rotate(360deg) } }
@keyframes oz-flash { from { background: var(--oz-tint-gold) } to { background: var(--surface-card) } }
@keyframes oz-rise { from { transform: translateY(100%) } to { transform: translateY(0) } }
@keyframes oz-fade { from { opacity: 0 } to { opacity: 1 } }

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

/*
 * A FIXED SCREEN, NOT A PAGE.
 *
 * The Director, on iPhone: "The whole website moves Y and X all over... Should be a fixed screen. Inner
 * containers can scroll though." So the document itself never scrolls in either axis - html and body are
 * exactly the viewport with overflow hidden, the header, tab row and dock are laid out in flow, and the
 * ONE scroller in the app is the content area between them. A sideways drag now has nothing to drag, and
 * the sticky-header rubber-band that made the chrome float away is structurally impossible.
 */
html {
  -webkit-text-size-adjust: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  height: 100dvh;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--surface-page);
  color: var(--text-primary);
  font: var(--type-body);
  -webkit-font-smoothing: antialiased;
}

::selection { background: var(--accent); color: var(--text-on-accent); }

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--oz-ink); }

.num { font-variant-numeric: tabular-nums; }
.grow { flex: 1 1 auto; min-width: 0; }
.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hide { display: none !important; }

/* --------------------------------------------------------------------------- shell */

/* 100dvh is the room the LAYOUT has; --kb is how much of it the keyboard is sitting on. */
.shell { display: flex; flex-direction: column; height: calc(100dvh - var(--kb)); overflow: hidden; }

.head {
  flex: 0 0 auto; z-index: 30;
  display: flex; align-items: center; gap: var(--space-2-5);
  height: var(--header-height); padding: 0 var(--space-2-5);
  /* Solid, never translucent: a blurred sticky bar drops tiles to black in Base App's WKWebView. */
  background: var(--surface-page);
  border-bottom: 1px solid var(--oz-line-gold);
}
.head .mark { width: 28px; height: 28px; border-radius: var(--radius-lg); flex: 0 0 auto; }
.head .wordmark {
  font: var(--weight-normal) var(--text-15)/1 var(--font-sans);
  letter-spacing: var(--tracking-wordmark); color: var(--text-primary);
}
.head .who { margin-left: auto; display: flex; align-items: center; gap: var(--space-1-5); }
.head .who img { width: 26px; height: 26px; border-radius: var(--radius-full); border: 1px solid var(--oz-line); }
.head .who .name {
  font: var(--weight-medium) var(--text-13)/1 var(--font-sans);
  color: var(--text-secondary); max-width: 11ch;
}

.tabs {
  flex: 0 0 auto; z-index: 29;
  display: grid; background: var(--surface-page);
  border-bottom: 1px solid var(--border-card);
}
.tab {
  min-height: var(--row-height); padding: 11px 4px 9px; background: transparent; border: 0; cursor: pointer;
  border-bottom: 2px solid transparent; margin-bottom: -1px;
  color: var(--text-secondary); font: var(--weight-semibold) var(--text-14)/1 var(--font-sans);
  letter-spacing: var(--tracking-wide); transition: var(--transition-default);
}
.tab[aria-selected="true"] { color: var(--accent); border-bottom-color: var(--accent); }

/* THE ONE SCROLLER. Everything else in the shell is fixed furniture. */
.body {
  flex: 1 1 auto; min-height: 0; width: 100%;
  overflow-y: auto; overflow-x: hidden; overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: var(--space-4) var(--layout-gutter);
}
.body > * { max-width: var(--layout-max); margin-inline: auto; }
/* A sheet is open: the screen behind it holds still. */
body.locked .body { overflow: hidden; }

.split { display: grid; gap: var(--space-6); align-items: start; }
/* Grid items default to min-width:auto, so a wide child (a Discord embed, an input row) pushes its own
   column past the viewport and the whole page scrolls sideways. It cost 20px at 320. */
.split > *, .grid-2 > * { min-width: 0; }
@media (min-width: 1000px) { .split { grid-template-columns: minmax(0, 1fr) 380px; } .side { position: sticky; top: 0; } }
/* The composer builds top-down, so on a phone the preview leads and the fields follow it. */
.split.pv-first > .side { order: -1; }
@media (min-width: 1000px) { .split.pv-first > .side { order: 1; } }

/* The primary action never leaves the thumb. In flow, not fixed - the shell is already the screen. */
.dock {
  flex: 0 0 auto; z-index: 28;
  padding: var(--space-2) var(--layout-gutter) calc(var(--space-2) + var(--safe-bottom));
  background: var(--surface-page); border-top: 1px solid var(--border-card);
}
.dock > * { max-width: var(--layout-max); margin: 0 auto; }
/* A gold bar the width of a desktop window is a banner, not a button. */
@media (min-width: 720px) { .dock > .btn { width: auto; min-width: 260px; display: flex; } }

/* --------------------------------------------------------------------------- type */

h1 { font: var(--type-screen-title); letter-spacing: var(--tracking-tight); margin: 0 0 var(--space-1); }
h2, .label {
  display: flex; align-items: center; gap: var(--space-2);
  font: var(--type-label); letter-spacing: var(--tracking-label); text-transform: uppercase;
  color: var(--text-secondary); margin: 0 0 var(--space-2);
}
h2 .count-of { margin-left: auto; letter-spacing: var(--tracking-wide); color: var(--text-tertiary); }
p { margin: 0 0 var(--space-3); color: var(--text-secondary); }
.sub { font: var(--type-body-sm); color: var(--text-secondary); }
.fine { font: var(--type-caption); line-height: var(--leading-normal); color: var(--text-tertiary); }
.err { color: var(--oz-down); font: var(--type-body-sm); }
.ok { color: var(--oz-up); font: var(--type-body-sm); }
code {
  font: var(--weight-normal) var(--text-12)/1.4 var(--font-mono);
  background: var(--oz-surface-alpha-5); padding: 2px 6px; border-radius: var(--radius-md);
}

.section { margin: 0 0 var(--space-6); }
.section:last-child { margin-bottom: 0; }

/* --------------------------------------------------------------------------- card */

.card {
  border-radius: var(--radius-2xl); border: 1px solid var(--border-card);
  background: var(--surface-card); padding: var(--card-padding); transition: var(--transition-default);
}
.card + .card { margin-top: var(--card-gap); }
.card.gold { border-color: var(--oz-line-gold); background: var(--oz-tint-gold-soft); }
.card.flat { padding: 0; overflow: hidden; }
.card.flash { animation: oz-flash 1.2s var(--ease-standard); }
.card.empty { text-align: center; padding: var(--space-6) var(--space-4); }
.card.empty h3 { font: var(--weight-semibold) var(--text-15)/1.3 var(--font-sans); margin: 0 0 var(--space-1-5); }

/* --------------------------------------------------------------------------- rows */

.list { display: grid; gap: var(--card-gap); }
/* The grid already spaces these; the adjacency margin would double it. */
.list > .card + .card { margin-top: 0; }

/* Swipe-to-delete: the row slides, the action underneath was always there. */
.swipe { position: relative; border-radius: var(--radius-2xl); overflow: hidden; }
.swipe .under {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: flex-end;
  padding: 0 var(--space-4); background: var(--oz-tint-down);
  color: var(--oz-down); font: var(--weight-semibold) var(--text-14)/1 var(--font-sans);
}
.swipe .over {
  position: relative; background: var(--surface-card-solid);
  transition: transform var(--duration-med) var(--ease-standard);
  /* The scroller keeps the vertical axis; only the horizontal one comes to us. */
  touch-action: pan-y;
}
.swipe.dragging .over { transition: none; }
.swipe .under .btn { -webkit-tap-highlight-color: transparent; }

.row {
  display: flex; align-items: center; gap: var(--space-3);
  min-height: var(--row-height); padding: var(--space-2-5) var(--space-3);
  border: 0; width: 100%; text-align: left; background: transparent; color: inherit;
  font: var(--type-body); cursor: pointer; -webkit-tap-highlight-color: transparent;
  /* A long press must reach our handler, not iOS's selection callout. */
  -webkit-touch-callout: none; user-select: none;
}
.row:active { background: var(--surface-hover); }
.row .gicon {
  width: 34px; height: 34px; flex: 0 0 34px; border-radius: var(--radius-lg);
  border: 1px solid var(--oz-line); background: var(--oz-surface-alpha-5); object-fit: cover;
  display: grid; place-items: center;
  font: var(--weight-semibold) var(--text-13)/1 var(--font-sans); color: var(--text-secondary);
}
.row .title { font: var(--weight-semibold) var(--text-15)/1.2 var(--font-sans); color: var(--text-primary); }
.row .meta { font: var(--type-caption); color: var(--text-secondary); margin-top: 2px; }

.dot { width: 6px; height: 6px; border-radius: var(--radius-full); display: inline-block; flex: 0 0 6px; }
.dot.on { background: var(--oz-up); }
.dot.off { background: var(--oz-down); }
.dot.warn { background: var(--oz-gold); }

/* --------------------------------------------------------------------------- chips */

.chip {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-1-5);
  height: 22px; padding: 0 var(--space-2); border-radius: var(--radius-md);
  font: var(--weight-semibold) var(--text-11)/1 var(--font-sans);
  letter-spacing: var(--tracking-wide); white-space: nowrap;
  background: var(--oz-surface-alpha-6); color: var(--text-secondary);
  border: 1px solid var(--oz-line); cursor: pointer; user-select: none;
  transition: var(--transition-default);
  /* A guild can be called anything; a chip carrying its name must not widen the page. */
  max-width: 100%; overflow: hidden;
}
.chip.sm { height: 16px; padding: 0 5px; font-size: var(--text-9); letter-spacing: var(--tracking-wider); }
.chip.static { cursor: default; }
.chip.up { background: var(--oz-tint-up); color: var(--oz-up); border-color: var(--oz-line-up); }
.chip.down { background: var(--oz-tint-down); color: var(--oz-down); border-color: var(--oz-line-down); }
.chip[aria-pressed="true"] { background: var(--oz-tint-gold); color: var(--accent); border-color: var(--oz-line-gold); }
.chip .x { opacity: .6; font-size: var(--text-12); }
.chips { display: flex; flex-wrap: wrap; gap: var(--space-1-5); }

/* --------------------------------------------------------------------------- controls */

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: var(--space-2);
  height: 38px; padding: 0 14px; border-radius: var(--radius-xl);
  font: var(--weight-medium) var(--text-14)/1 var(--font-sans);
  background: var(--oz-surface-alpha-3); color: var(--text-primary);
  border: 1px solid var(--oz-line); cursor: pointer; white-space: nowrap;
  transition: var(--transition-default); -webkit-tap-highlight-color: transparent;
}
.btn:active { transform: scale(var(--press-scale)); }
.btn.primary { background: var(--accent); color: var(--text-on-accent); border-color: transparent; font-weight: var(--weight-semibold); }
.btn.gold { background: var(--oz-tint-gold); color: var(--accent); border-color: var(--oz-line-gold); font-weight: var(--weight-semibold); }
.btn.ghost { background: transparent; color: var(--text-secondary); border-color: transparent; }
.btn.danger { background: transparent; color: var(--oz-down); border-color: var(--oz-line-down); }
.btn.lg { height: 48px; padding: 0 18px; font-size: var(--text-16); }
.btn.sm { height: 28px; padding: 0 10px; font-size: var(--text-12); border-radius: var(--radius-lg); }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .4; cursor: not-allowed; }

/* Every bare affordance clears 44px even when its glyph is 16. */
.icon-btn {
  display: inline-grid; place-items: center; width: var(--row-height); height: var(--row-height);
  flex: 0 0 var(--row-height); border-radius: var(--radius-lg);
  background: transparent; border: 1px solid transparent; color: var(--text-secondary);
  cursor: pointer; transition: var(--transition-default); -webkit-tap-highlight-color: transparent;
}
.icon-btn:active { background: var(--surface-hover); }
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; fill: none; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

/* A real switch, in a 44px hit box. */
.sw {
  position: relative; width: 42px; height: var(--row-height); flex: 0 0 42px;
  background: transparent; border: 0; padding: 0; cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.sw::before {
  content: ''; position: absolute; top: 10px; left: 0; width: 42px; height: 24px;
  border-radius: var(--radius-full); border: 1px solid var(--oz-line-strong);
  background: var(--oz-surface-alpha-3); transition: var(--transition-default);
}
.sw::after {
  content: ''; position: absolute; top: 13px; left: 3px; width: 18px; height: 18px;
  border-radius: var(--radius-full); background: var(--text-secondary);
  transition: transform var(--duration-med) var(--ease-standard), background var(--duration-fast) var(--ease-standard);
}
.sw[aria-checked="true"]::before { background: var(--oz-tint-up); border-color: var(--oz-line-up); }
.sw[aria-checked="true"]::after { transform: translateX(17px); background: var(--oz-up); }

.field { display: block; margin: 0 0 var(--space-4); }
/* The container ends the rhythm, not the field - a field that happens to be last inside a two-up grid
   used to drop its margin and collide with whatever followed the grid. */
.card > :last-child, .sheet-body > :last-child, .grid-2 > .field { margin-bottom: 0; }
.field > .label { margin-bottom: var(--space-1-5); }
/*
 * SIXTEEN PIXELS, EVERYWHERE A CARET CAN LAND.
 *
 * The Director: "It keeps zooming in on fields and stuff annoyingly." That is iOS Safari's focus zoom,
 * and its trigger is exact - a focused editable whose computed font-size is UNDER 16px gets the viewport
 * scaled up to it. This field was 15px and the file rows were 13px, so every tap jumped the page.
 *
 * The fix is the size, not `user-scalable=no` / `maximum-scale=1`. Those do stop the auto-zoom, and they
 * stop a person pinching to read as well, which is not a trade this site gets to make on anyone's behalf.
 */
.input, textarea.input {
  width: 100%; min-height: var(--row-height); padding: 11px var(--space-3);
  border-radius: var(--radius-xl); background: var(--surface-input);
  border: 1px solid var(--oz-line); color: var(--text-primary);
  font: var(--weight-normal) var(--text-16)/1.35 var(--font-sans); outline: none;
  transition: border-color var(--duration-fast) var(--ease-standard);
  -webkit-appearance: none; appearance: none;
}
.input:focus, textarea.input:focus { border-color: var(--border-input); }
.input::placeholder { color: var(--text-tertiary); }
.input[aria-invalid="true"] { border-color: var(--oz-line-down); }
textarea.input { min-height: 84px; resize: vertical; }
input[type="color"].input { padding: 3px; height: var(--row-height); cursor: pointer; }
input[type="file"].input { padding: 10px var(--space-3); font-size: var(--text-16); color: var(--text-secondary); }

.with-btn { display: flex; gap: var(--space-2); align-items: stretch; }
.with-btn .input { flex: 1 1 auto; }

.hint { display: block; margin-top: var(--space-1-5); font: var(--type-caption); color: var(--text-tertiary); }
.hint.bad { color: var(--oz-down); }
.hint.good { color: var(--oz-up); }

/* The grid carries the rhythm its children gave up (see the :last-child rule above). */
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--space-3); margin: 0 0 var(--space-4); }
@media (max-width: 420px) { .grid-2 { grid-template-columns: 1fr; } }

/* Order type / rate limit: a segmented row, not a native select nobody can style. */
.seg { display: grid; gap: var(--space-1); padding: var(--space-1); border-radius: var(--radius-xl);
  background: var(--oz-surface-alpha-3); border: 1px solid var(--oz-line); grid-auto-flow: column; }
.seg button {
  height: 36px; padding: 0 var(--space-2); border: 0; border-radius: var(--radius-lg); cursor: pointer;
  background: transparent; color: var(--text-secondary);
  font: var(--weight-medium) var(--text-13)/1 var(--font-sans); transition: var(--transition-default);
}
.seg button[aria-pressed="true"] { background: var(--text-primary); color: var(--text-on-accent); font-weight: var(--weight-semibold); }

/* --------------------------------------------------------------------------- dropdown (portal) */

/*
 * THE MENU IS NOT A CHILD OF THE CARD.
 *
 * It used to be absolutely positioned inside .pane, so any ancestor with overflow or a transform sheared
 * it - the Director's screenshot had AAPL and AAVE cut in half. It now mounts on <body>, is positioned
 * fixed from the anchor's own rect, flips above when the space below is short, and clamps to the visual
 * viewport so the last row is always reachable.
 */
.menu {
  position: fixed; z-index: 60; overflow-y: auto; overscroll-behavior: contain;
  background: var(--surface-sheet); border: 1px solid var(--oz-line-strong);
  border-radius: var(--radius-xl); padding: var(--space-1);
  box-shadow: var(--shadow-2xl); animation: oz-fade var(--duration-fast) var(--ease-standard);
  -webkit-overflow-scrolling: touch;
}
.menu .opt {
  display: flex; align-items: center; gap: var(--space-2); width: 100%;
  min-height: var(--row-height); padding: var(--space-2) var(--space-2-5);
  border: 0; border-radius: var(--radius-lg); background: transparent; color: var(--text-primary);
  font: var(--type-body); text-align: left; cursor: pointer;
}
.menu .opt:active, .menu .opt:hover { background: var(--surface-hover); }
.menu .opt .sym { color: var(--text-secondary); font-size: var(--text-12); }
.menu .opt .tick { margin-left: auto; color: var(--accent); }
.menu .opt.danger { color: var(--oz-down); }
.menu .grp {
  position: sticky; top: 0; z-index: 1; display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2) var(--space-2-5) var(--space-1);
  background: var(--surface-sheet); color: var(--text-secondary);
  font: var(--type-label); letter-spacing: var(--tracking-wider); text-transform: uppercase;
}
.menu .grp .pick {
  margin-left: auto; padding: var(--space-1) var(--space-2); border: 0; border-radius: var(--radius-md);
  background: transparent; color: var(--accent); cursor: pointer;
  font: var(--weight-semibold) var(--text-11)/1 var(--font-sans); text-transform: none;
  letter-spacing: var(--tracking-wide);
}
.menu .none { padding: var(--space-3); color: var(--text-secondary); font: var(--type-body-sm); }

/* --------------------------------------------------------------------------- sheet */

.scrim {
  position: fixed; inset: 0; z-index: 40; background: var(--oz-scrim);
  animation: oz-fade var(--duration-fast) var(--ease-standard);
}
.sheet {
  position: fixed; left: 0; right: 0; bottom: var(--kb); z-index: 41;
  display: flex; flex-direction: column; max-height: calc(92dvh - var(--kb));
  background: var(--surface-sheet); border-top: 1px solid var(--oz-line-strong);
  border-radius: var(--radius-2xl) var(--radius-2xl) 0 0; box-shadow: var(--shadow-sheet);
  animation: oz-rise var(--duration-med) var(--ease-standard);
}
@media (min-width: 720px) {
  .sheet {
    left: 50%; right: auto; bottom: auto; top: 50%; width: 560px;
    transform: translate(-50%, -50%); border-radius: var(--radius-2xl);
    border: 1px solid var(--oz-line-strong); animation: oz-fade var(--duration-fast) var(--ease-standard);
  }
}
.sheet .handle { padding: var(--space-2) 0 0; display: grid; place-items: center; flex: 0 0 auto; }
.sheet .handle span { width: 36px; height: 4px; border-radius: var(--radius-full); background: var(--oz-surface-alpha-7); }
@media (min-width: 720px) { .sheet .handle { display: none; } }
.sheet .sheet-head {
  display: flex; align-items: center; gap: var(--space-2); flex: 0 0 auto;
  padding: var(--space-3) var(--space-4) var(--space-2);
}
.sheet .sheet-head h3 { font: var(--type-screen-title); }
.sheet .sheet-body { flex: 1 1 auto; overflow-y: auto; padding: var(--space-2) var(--space-4) var(--space-4); -webkit-overflow-scrolling: touch; }
.sheet .sheet-foot {
  flex: 0 0 auto; display: flex; gap: var(--space-2); align-items: center;
  padding: var(--space-3) var(--space-4) calc(var(--space-3) + var(--safe-bottom));
  border-top: 1px solid var(--border-card); background: var(--surface-sheet);
}
.sheet .sheet-foot .btn.primary { flex: 1 1 auto; }

/* --------------------------------------------------------------------------- toast */

.toasts {
  position: fixed; left: 0; right: 0; z-index: 70; display: grid; justify-items: center; gap: var(--space-2);
  bottom: calc(var(--space-5) + var(--safe-bottom) + 56px); pointer-events: none;
}
.toast {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-2-5) var(--space-4); border-radius: var(--radius-full);
  background: var(--surface-card-solid); border: 1px solid var(--oz-line-strong);
  color: var(--text-primary); font: var(--weight-medium) var(--text-13)/1 var(--font-sans);
  box-shadow: var(--shadow-2xl); animation: oz-fade var(--duration-fast) var(--ease-standard);
  transition: opacity var(--duration-fast) var(--ease-standard);
}
.toast.bad { border-color: var(--oz-line-down); color: var(--oz-down); }
.toast.going { opacity: 0; }

.spinner {
  width: 16px; height: 16px; border-radius: var(--radius-full);
  border: 2px solid var(--oz-line-strong); border-top-color: var(--accent);
  animation: oz-spin 1s linear infinite;
}

/* --------------------------------------------------------------------------- discord embed */

/* Discord's own geometry, so a preview is a preview rather than an impression. */
.dc { background: var(--dc-bg); border-radius: var(--radius-lg); padding: var(--space-3); color: var(--dc-text); }
.dc-msg { display: flex; gap: var(--space-3); }
.dc-av { width: 36px; height: 36px; flex: 0 0 36px; border-radius: var(--radius-full); background: var(--dc-blurple); object-fit: cover; }
.dc-name { font: var(--weight-semibold) var(--text-14)/1.2 var(--font-sans); color: #fff; }
.dc-bot {
  background: var(--dc-blurple); color: #fff; border-radius: var(--radius-sm);
  font: var(--weight-bold) var(--text-9)/1.4 var(--font-sans); padding: 1px 4px; margin-left: 5px;
  text-transform: uppercase; vertical-align: middle;
}
.dc-time { color: var(--dc-muted); font-size: var(--text-11); margin-left: 6px; }
.dc-content { white-space: pre-wrap; font-size: var(--text-14); margin: 2px 0 6px; }
.dc-embed {
  border-left: 4px solid var(--accent); background: var(--dc-embed); border-radius: var(--radius-sm);
  padding: 10px 14px 12px; max-width: 520px;
  display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 0 var(--space-3);
}
.dc-embed .dc-body { min-width: 0; }
.dc-author { display: flex; align-items: center; gap: var(--space-2); font: var(--weight-semibold) var(--text-13)/1.2 var(--font-sans); margin: 0 0 6px; }
.dc-author img { width: 20px; height: 20px; border-radius: var(--radius-full); }
/* Discord colours a title blue only when it carries a link. Unlinked, it is white. */
.dc-title { color: #fff; font: var(--weight-semibold) var(--text-15)/1.3 var(--font-sans); margin: 0 0 6px; }
.dc-title.linked, .dc-title a { color: var(--dc-link); }
.dc-desc { font-size: var(--text-13); line-height: var(--leading-normal); white-space: pre-wrap; margin: 0 0 var(--space-2); overflow-wrap: anywhere; }
.dc-desc.placeholder { color: var(--dc-muted); font-style: italic; }
.dc-fields { display: grid; gap: var(--space-2); margin: 0 0 var(--space-2); }
.dc-fields.has-inline { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.dc-field.block { grid-column: 1 / -1; }
.dc-fname { font: var(--weight-semibold) var(--text-13)/1.3 var(--font-sans); margin: 0 0 2px; }
.dc-fval { font-size: var(--text-13); line-height: var(--leading-normal); white-space: pre-wrap; overflow-wrap: anywhere; }
.dc-thumb { width: 72px; height: 72px; object-fit: cover; border-radius: var(--radius-sm); }
.dc-img { width: 100%; border-radius: var(--radius-sm); margin: var(--space-2) 0 0; grid-column: 1 / -1; display: block; }
.dc-foot { display: flex; align-items: center; gap: var(--space-2); font-size: var(--text-11); color: var(--dc-muted); margin: var(--space-2) 0 0; grid-column: 1 / -1; }
.dc-foot img { width: 18px; height: 18px; border-radius: var(--radius-full); }
.dc a { color: var(--dc-link); }
.dc code { background: rgba(0, 0, 0, .3); color: var(--dc-text); }

/* --------------------------------------------------------------------------- discord markdown */

.md-tok { opacity: .38; font-weight: var(--weight-normal); }
.md-spoiler { background: rgba(0, 0, 0, .45); border-radius: var(--radius-sm); }
.md-em { font-style: italic; }
.md-line { display: block; }
.md-h1 { font: var(--weight-bold) var(--text-18)/1.3 var(--font-sans); }
.md-h2 { font: var(--weight-bold) var(--text-16)/1.3 var(--font-sans); }
.md-h3 { font: var(--weight-semibold) var(--text-15)/1.3 var(--font-sans); }
.md-subtext { font-size: var(--text-11); color: var(--dc-muted); }
.md-quote { border-left: 4px solid var(--oz-surface-alpha-7); padding-left: var(--space-2); color: var(--dc-text); }
.md-li { padding-left: var(--space-3); }
.md-bullet { margin-right: var(--space-1-5); opacity: .7; }
.md-mention, .md-obj { background: rgba(88, 101, 242, .28); color: #dee0fc; border-radius: var(--radius-sm); padding: 0 3px; }
.md-emoji { width: 20px; height: 20px; vertical-align: -4px; }
.md-block { display: block; white-space: pre-wrap; background: rgba(0, 0, 0, .3); border-radius: var(--radius-sm); padding: var(--space-2); margin: var(--space-1) 0; }

/* --------------------------------------------------------------------------- the message IS the editor */

/*
 * Every piece of text on the message is a contenteditable. The affordance has to read as "you can type
 * here" without turning the drawing into a wireframe, so it is a hairline that appears under a finger and
 * a gold ring when the caret is actually in it.
 */
.md-edit {
  outline: none; border-radius: var(--radius-sm);
  padding: 1px 3px; margin: -1px -3px;
  box-shadow: inset 0 0 0 1px transparent;
  transition: box-shadow var(--duration-fast) var(--ease-standard), background var(--duration-fast) var(--ease-standard);
  -webkit-tap-highlight-color: transparent; cursor: text;
  /* Newlines are literal characters while typing - see decorate() in discordmd.ts. */
  white-space: pre-wrap; overflow-wrap: anywhere;
}
@media (hover: hover) { .md-edit:hover { box-shadow: inset 0 0 0 1px var(--oz-line-strong); } }
/*
 * The composer's regions are Discord's DESKTOP geometry - 13 to 15px - and iOS zooms into any focused
 * editable under 16. So on a touch screen the editable message is drawn at Discord's MOBILE size instead,
 * which is 16px for message and embed body text in Discord's own iPhone client. The Latest Signal card is
 * NOT an editor, is never focused, and keeps the tighter scale.
 */
@media (pointer: coarse) {
  .dc-editing .md-edit { font-size: var(--text-16); }
  .dc-editing .dc-foot { font-size: var(--text-13); }
  .dc-editing .dc-name { font-size: var(--text-16); }
}
.md-edit:focus {
  box-shadow: inset 0 0 0 1px var(--oz-line-gold);
  background: var(--oz-tint-gold-soft);
}
.md-edit.is-empty::before {
  content: attr(data-ph);
  color: var(--dc-muted); font-style: italic; opacity: .8; pointer-events: none;
}
.md-edit.is-empty:focus::before { opacity: .45; }
/* Links in the message are content being edited, not navigation. */
.dc-editing a { pointer-events: none; }
.dc-editing .dc-desc, .dc-editing .dc-content, .dc-editing .dc-fval { min-height: 1.4em; }

/* The floating format bar, over the selection. */
.md-bar {
  position: fixed; z-index: 65; display: flex; gap: 2px; padding: 3px;
  border-radius: var(--radius-lg); background: var(--surface-sheet);
  border: 1px solid var(--oz-line-strong); box-shadow: var(--shadow-2xl);
}
.md-bar button {
  min-width: 34px; height: 34px; padding: 0 var(--space-2); border: 0; border-radius: var(--radius-md);
  background: transparent; color: var(--text-primary); cursor: pointer;
  font: var(--weight-bold) var(--text-13)/1 var(--font-mono);
}
.md-bar button:hover { background: var(--surface-hover); color: var(--accent); }

/* The knobs: the few properties that are not text, each sitting on the thing it changes. */
.dc-knob {
  display: inline-grid; place-items: center; width: 26px; height: 26px; flex: 0 0 26px;
  border-radius: var(--radius-full); border: 1px dashed rgba(255, 255, 255, .22);
  background: transparent; color: var(--dc-muted); cursor: pointer;
  transition: var(--transition-default);
}
.dc-knob:hover, .dc-knob:focus-visible { border-style: solid; border-color: var(--oz-line-gold); color: var(--accent); }
.dc-knob.on { border-style: solid; border-color: var(--oz-line-gold); color: var(--accent); }
.dc-title-row { display: flex; align-items: flex-start; gap: var(--space-2); margin: 0 0 6px; }
.dc-title-row .dc-title { flex: 1 1 auto; margin: 0; }

.dc-author-name { font: var(--weight-semibold) var(--text-13)/1.3 var(--font-sans); }
.dc-author-icon { width: 20px; height: 20px; flex: 0 0 20px; border-radius: var(--radius-full); }
.dc-author-icon.ghost, .dc-foot-icon.ghost { border: 1px dashed rgba(255, 255, 255, .22); cursor: pointer; }
.dc-foot-icon { width: 18px; height: 18px; flex: 0 0 18px; border-radius: var(--radius-full); }
.dc-foot-text { flex: 0 1 auto; }
.dc-av.ghost { display: grid; place-items: center; border: 1px dashed rgba(255, 255, 255, .22); background: transparent; color: var(--dc-muted); cursor: pointer; }

.dc-ts {
  display: inline-flex; align-items: center; gap: 4px; padding: 2px var(--space-2);
  border-radius: var(--radius-full); border: 1px dashed rgba(255, 255, 255, .22);
  background: transparent; color: var(--dc-muted); cursor: pointer;
  font: var(--weight-medium) var(--text-11)/1.4 var(--font-sans); white-space: nowrap;
}
.dc-ts svg { opacity: 0; width: 12px; height: 12px; }
.dc-ts.on { border-style: solid; border-color: var(--oz-line-gold); color: var(--accent); }
.dc-ts.on svg { opacity: 1; }

/* The two field knobs sit UNDER the field, not over it. Absolutely positioning them at the top right laid
   them across the field name, and on a touch screen - where they are always visible - permanently. */
.dc-field-tools { display: flex; justify-content: flex-end; gap: 2px; margin-top: var(--space-1); }
.dc-field-tools .dc-knob { width: 22px; height: 22px; flex: 0 0 22px; }

.dc-add {
  display: inline-flex; align-items: center; gap: var(--space-1-5); min-height: 32px;
  padding: var(--space-1) var(--space-2-5); border-radius: var(--radius-md);
  border: 1px dashed rgba(255, 255, 255, .22); background: transparent;
  color: var(--dc-muted); cursor: pointer; font: var(--type-body-sm);
}
.dc-add:hover { border-color: var(--oz-line-gold); color: var(--accent); }

.dc-thumb.ghost, .dc-img.ghost {
  display: grid; place-items: center; gap: 4px;
  border: 1px dashed rgba(255, 255, 255, .22); background: transparent;
  color: var(--dc-muted); cursor: pointer; font: var(--type-caption);
}
.dc-img.ghost { height: 56px; grid-auto-flow: column; }
.dc-thumb.ghost { width: 48px; height: 48px; }

/* The accent bar is the one property with no text of its own, so it gets a hit area over the border. */
.dc-embed { position: relative; }
.dc-bar {
  position: absolute; top: 0; bottom: 0; left: -4px; width: 4px; padding: 0;
  border: 0; background: transparent; cursor: pointer;
  border-radius: var(--radius-sm) 0 0 var(--radius-sm);
}
.dc-bar:hover { background: rgba(255, 255, 255, .25); }
.dc-head-line { display: block; }

/* --------------------------------------------------------------------------- popover panes */

.pop { padding: var(--space-2); min-width: 0; }
.pop-row { display: flex; gap: var(--space-2); align-items: center; margin-top: var(--space-2); }
.pop-row > .input[type="color"] { flex: 1 1 auto; }

/* --------------------------------------------------------------------------- banner */

.banner {
  display: flex; gap: var(--space-2-5); align-items: flex-start;
  padding: var(--space-3); margin: 0 0 var(--space-4);
  border-radius: var(--radius-2xl); border: 1px solid var(--oz-line-gold);
  background: var(--oz-tint-gold-soft);
  font: var(--type-body-sm); color: var(--text-secondary);
}
.banner svg { flex: 0 0 auto; color: var(--accent); margin-top: 1px; }
.banner strong { color: var(--text-primary); font-weight: var(--weight-semibold); }

@media (max-width: 430px) {
  .dc { padding: var(--space-2-5); }
  .dc-msg { gap: var(--space-2); }
  .dc-fields.has-inline { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  /* Discord's thumbnail is 80px against a much wider embed; at this width it eats the description. */
  .dc-thumb { width: 48px; height: 48px; }
}

/*
 * THUMBS, NOT CURSORS. The kit sizes buttons 28 / 38 / 48, which is right under a mouse; a finger needs
 * 44 in both directions. Rather than fork every call site, anything a coarse pointer can hit grows to the
 * kit's own --row-height. Desktop keeps the kit's geometry exactly.
 */
@media (pointer: coarse) {
  .btn, .btn.sm { min-height: var(--row-height); }
  .btn.sm { padding: 0 var(--space-3); }
  input[type="checkbox"] { width: 20px; height: 20px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
