/* =============================================================================
 * typst-app.css — the one stylesheet both local services render with.
 *
 * Provenance
 * ----------
 * Section 2 ("Design tokens") is copied **verbatim** from typst.app's own
 * bundle, captured at app/assets/index-DJQ8URye.css (`:root,.forceLight{…}` and
 * `:root[data-theme=dark]{…}`). Section 6 mirrors the component rules from that
 * same file (`_button_10pgl_*`, `_primary_10pgl_*`, `_secondary_10pgl_*`), with
 * the hashed class names replaced by readable ones.
 *
 * Sections 4/5 reproduce typst.app's server-rendered /signin/ page (teal blur
 * canvas, 64px wordmark rail, white sheet, floating-label fields).
 *
 * Why one file
 * ------------
 * The editor (localhost:8060) and the auth service (localhost:8070) are two
 * processes that pretend to be one typst.app. Both serve this file from
 * shared/ at /assets/typst-app.css, so the two can never drift apart, and
 * `auth/test/theme.mjs` fails the build if typst.app's tokens change under us.
 *
 * Do not invent colours here. Use the tokens; if a token is missing, it means
 * typst.app does not have that concept yet.
 * ========================================================================== */

/* ---------- 1. Inter (typst.app's UI font, same files) ------------------- */
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/Inter-Regular.woff2") format("woff2");
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("/assets/fonts/Inter-Medium.woff2") format("woff2");
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("/assets/fonts/Inter-SemiBold.woff2") format("woff2");
}
@font-face {
  font-family: Inter;
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("/assets/fonts/Inter-Bold.woff2") format("woff2");
}
@font-face {
  font-family: Inter;
  font-style: italic;
  font-weight: 400;
  font-display: swap;
  src: url("/assets/fonts/Inter-Italic.woff2") format("woff2");
}

/* ---------- 2. Design tokens (verbatim from typst.app) ------------------- */
:root,
.forceLight {
  --monospace: "Cascadia Mono", monospace;
  --text-light: #fdfdfd;
  --text-dark: #19181f;
  --action-primary: #007aff;
  --action-primary-selected: #007aff;
  --action-primary-hover: #004dc6;
  --action-primary-hover-transparent: #004dc61a;
  --action-primary-active: #00298c;
  --action-primary-active-transparent: #00298c59;
  --action-primary-disabled: #007aff80;
  --action-brand: #00afc6;
  --action-brand-hover: #239dad;
  --action-brand-active: #19798d;
  --action-brand-disabled: #00afc680;
  --action-secondary-plain: #fdfdfd;
  --action-secondary-shaded: #eff0f3;
  --action-secondary-hover: #e4e5ea;
  --action-secondary-active: #d7d9e0;
  --action-secondary-disabled: #eff0f380;
  --action-upsale: #145b49;
  --action-upsale-shaded: #d1ffe2;
  --action-upsale-hover: #a6fbc9;
  --action-upsale-active: #80f4b6;
  --action-critical: #ea3e47;
  --action-critical-hover: #b9312d;
  --action-critical-active: #85291d;
  --action-critical-disabled: #ea3e4780;
  --action-warning: #f88938;
  --selection-background: #bdd4dbb3;
  --selection-background-disabled: #d7d9e0;
  --selection-active-line: #b6ebff44;
  --selection-active-line-gutter: #e8f9ff;
  --selection-active-line-disabled: #e5ecf04d;
  --selection-active-line-gutter-disabled: #e5ecf0;
  --caret: #007bff52;
  --text-primary: #19181f;
  --text-nav: #3b3a48;
  --text-secondary-rgb: 86, 85, 101;
  --text-secondary: rgba(var(--text-secondary-rgb), 1);
  --text-brand-secondary: #0a3649;
  --text-brand: #11566c;
  --text-inverted: #fdfdfd;
  --text-disabled: #19181f80;
  --text-link: #007aff;
  --text-drop: #00298c;
  --text-critical: #b9312d;
  --text-warning: #b14c00;
  --text-gutter: #bdbfcc;
  --text-gutter-active: #b0b3c2;
  --text-c-comment: #74747c;
  --text-c-monospace: #6b6b6f;
  --text-c-math-delim: #198810;
  --text-c-math-op: #1d6c76;
  --text-c-list-marker: #8b41b1;
  --text-c-escape: #1d6c76;
  --text-c-keyword: #d73948;
  --text-c-null: #d73948;
  --text-c-atom: #d73948;
  --text-c-bool: #d73948;
  --text-c-number: #b60157;
  --text-c-string: #198810;
  --text-c-func: #4b69c6;
  --text-c-interpolated: #8b41b1;
  --text-success: #1e7c61;
  --layer-1: #fdfdfd;
  --layer-2: #eff0f3;
  --layer-3: #e4e5ea;
  --layer-1-80: #fdfdfdcc;
  --layer-2-80: #eff0f3cc;
  --layer-inverted-1: #111015e6;
  --layer-inverted-3: #4d4c5b;
  --layer-control: #fdfdfd4d;
  --layer-control-thumb: #fdfdfdcc;
  --layer-overlay: #0000001a;
  --layer-dropzone: #e8f9ff;
  --layer-comment: #f2ffa2;
  --layer-deletion: #f9d4cf;
  --layer-insertion: #a5f9c8;
  --border-primary-muted: #0065e9;
  --border-primary: #001666;
  --border-secondary-rgb: 189, 191, 204;
  --border-secondary: rgba(var(--border-secondary-rgb), 1);
  --border-panel: none;
  --border-toolbar-button: #d7d9e0;
  --border-critical: #611d14;
  --border-modal: #d7d9e0;
  --border-disabled: #0000001a;
  --border-input: #8b8fa2;
  --border-active-nav: none;
  --border-focus: #007aff80;
  --brand-primary: #239dad;
  --border-brand: #19798d;
  --border-success: #afd8c2;
  --border-warning: #f7c000;
  --effect-shadow-1: 0px 4px 12px #59556533;
  --effect-shadow-page: 0px 4px 12px #59556533;
  --effect-shadow-2: 0px 0px 12px #59556533, 0px 8px 48px #5955654d;
  --effect-shadow-modal: 0px 0px 12px #59556533, 0px 8px 48px #5955654d;
  --effect-shadow-menu: 0 0 0 1px #0000000d, 0 0 12px #5955651a, 0 2px 24px #59556533;
  --project-icon-gradient: linear-gradient(325.34deg, #007aff 0%, #7fc9ff 100%);
  --project-icon-border-thumb: linear-gradient(180deg, #c8f2ff 0%, #d7d9e000 66%);
  --project-icon-gradient-thumb: linear-gradient(347.95deg, #007aff 0%, #3dc5ff00 60%);
  --project-icon-corner-thumb: #c8f2ff;
  --toast-background: #3b3a48;
  --toast-background-shaded: #4d4c5b;
  --toast-border: #111015e6;
  --presentation-green: #2dab7d;
  --blend-mode-comment: multiply;
}

:root[data-theme=dark],
:root[data-theme=start23],
:root[data-theme=ubuntu],
:root[data-theme=christmas] {
  --action-secondary-plain: #19181f;
  --action-secondary-shaded: #2a2934;
  --action-secondary-hover: #33323e;
  --action-secondary-active: #444352;
  --action-secondary-disabled: #2a293480;
  --action-upsale: #d1ffe2;
  --action-upsale-shaded: #145b49;
  --action-upsale-hover: #1e7c61;
  --action-upsale-active: #2dab7d;
  --action-critical: #ea3e47;
  --action-critical-hover: #b9312d;
  --action-critical-active: #85291d;
  --action-critical-disabled: #ea3e4780;
  --selection-background: #3b4345b3;
  --selection-background-disabled: #4d4c5b;
  --selection-active-line: #44545a31;
  --selection-active-line-gutter: #475357;
  --selection-active-line-disabled: #3538394d;
  --selection-active-line-gutter-disabled: #353839;
  --text-primary: #fdfdfd;
  --text-nav: #eff0f3;
  --text-secondary-rgb: 163, 167, 183;
  --text-secondary: rgba(var(--text-secondary-rgb), 1);
  --text-brand-secondary: #afd1d1;
  --text-brand: #d9f8f4;
  --text-inverted: #111015;
  --text-disabled: #fdfdfd80;
  --text-link: #3da8ff;
  --text-drop: #e8f9ff;
  --text-critical: #f75a5b;
  --text-warning: #ff9554;
  --text-gutter: #3b3a48;
  --text-gutter-active: #b0b3c2;
  --text-c-comment: #b0b3c2;
  --text-c-monospace: #caccd6;
  --text-c-math-delim: #80f4b6;
  --text-c-math-op: #d9f8f4;
  --text-c-list-marker: #caa8ff;
  --text-c-escape: #d9f8f4;
  --text-c-keyword: #ffa49d;
  --text-c-null: #ffa49d;
  --text-c-atom: #ffa49d;
  --text-c-bool: #ffa49d;
  --text-c-number: #ff7d79;
  --text-c-string: #80f4b6;
  --text-c-func: #7cd5ff;
  --text-c-interpolated: #caa8ff;
  --text-success: #5de8a4;
  --layer-1: #19181f;
  --layer-2: #2a2934;
  --layer-3: #3b3a48;
  --layer-1-80: #19181fcc;
  --layer-2-80: #2a2934cc;
  --layer-inverted-1: #eff0f3e6;
  --layer-inverted-3: #e4e5ea;
  --layer-control: #19181f4d;
  --layer-control-thumb: #19181fcc;
  --layer-overlay: #b0b3c2b3;
  --layer-dropzone: #004e66;
  --layer-comment: #7e7336;
  --layer-deletion: #85291d;
  --layer-insertion: #1e7c61;
  --border-primary: #a6eaff;
  --border-secondary-rgb: 59, 58, 72;
  --border-panel: 1px solid #3b3a48;
  --border-toolbar-button: #4d4c5b;
  --border-critical: #ffcbc4;
  --border-modal: #2a2934;
  --border-disabled: #fdfdfd1a;
  --border-input: #565565;
  --border-active-nav: 1px solid #565565;
  --border-focus: #007aff80;
  --brand-primary: #00afc6;
  --border-success: #5de8a4;
  --border-warning: #f7c000;
  --effect-shadow-1: none;
  --effect-shadow-page: 0px 4px 12px #e9e7ef33;
  --effect-shadow-2: none;
  --effect-shadow-modal: 0px 0px 12px #59556533, 0px 8px 48px #5955654d;
  --effect-shadow-menu: none;
  --project-icon-gradient: linear-gradient(325.34deg, #004dc6 0%, #5cbeff 100%);
  --project-icon-gradient-thumb: linear-gradient(347.95deg, #004dc6 0%, #3dc5ff00 60%);
  --text-dark: #111015;
  --blend-mode-comment: lighten;
}

/* The app shell stores the user's choice in localStorage("global-settings")
   and sets data-theme on <html>; "system" defers to the OS. */
@media (prefers-color-scheme: dark) {
  :root[data-theme=system] {
    color-scheme: dark;
  }
  :root[data-theme=system] body {
    background-color: var(--action-secondary-shaded);
  }
}

/* ---------- 3. Base ------------------------------------------------------ */
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; }
body {
  margin: 0;
  color: var(--text-primary);
  background: var(--layer-2);
  font-family: Inter, sans-serif;
  font-size: 13px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
h1 { font-size: 32px; font-weight: 500; margin: 0; }
h2 { font-size: 20px; font-weight: 600; margin: 0; }
h3 { font-size: 13px; font-weight: 600; margin: 0; }
p { margin: 0; }
a { color: var(--text-link); text-decoration: none; }
a:hover { text-decoration: underline; }
small { font-size: 12px; color: var(--text-secondary); }
code, kbd, .mono, .font-mono { font-family: var(--monospace); font-size: 12px; }
/* an <a class="btn"> is just a wrapper for a <button> in old markup */
.btn { display: inline-block; }
:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--action-primary); }
::selection { background: var(--selection-background); }

/* ---------- 4. Sign-in sheet (typst.app's /signin/) ---------------------- */
/* body.signin paints the blurred teal canvas the real page uses */
body.signin {
  background: url("/assets/images/blur.webp") -50vw -80vw / 170vw 170vw no-repeat fixed #21b8cc;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Oxygen, sans-serif,
    "Apple Color Emoji", "Segoe UI Emoji";
}
#app {
  display: grid;
  grid-template: "sidebar infobar" 40px "sidebar sheet" minmax(min-content, 1fr) / auto minmax(0, 1fr);
  min-height: 100dvh;
}
#sidebar {
  grid-area: sidebar;
  width: 64px;
  padding: 16px 0;
  display: flex;
  flex-direction: column-reverse;
  align-items: center;
  color: var(--text-light);
}
#sidebar a { display: block; color: inherit; }
#sidebar svg { display: block; }
#sheet {
  grid-area: sheet;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 0 24px 32px;
  background: var(--layer-1);
  border-radius: 6px 0 0;
  box-shadow: var(--effect-shadow-1);
}
#top-bar {
  position: absolute;
  top: 24px;
  left: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
}
.back {
  display: flex;
  align-items: center;
  gap: 6px;
  padding-right: 4px;
  color: var(--text-secondary);
  text-decoration: none;
}
.back:hover { color: var(--text-primary); text-decoration: none; }
.back img { display: block; }
#target {
  display: flex;
  flex-direction: column;
  gap: 18px;
  width: 100%;
  max-width: 590px;
}
#target > p { color: var(--text-secondary); font-size: 14px; }
#target a:not(.button) { color: var(--text-secondary); font-weight: 500; text-decoration: none; }
#target a:not(.button):hover { text-decoration: underline; }

@media (max-width: 700px) {
  #app { grid-template-columns: 100%; grid-template-areas: "infobar" "sheet"; }
  #sidebar { display: none; }
  #sheet { border-radius: 0; padding: 72px 16px 0; }
  #top-bar { left: 12px; }
}

/* ---------- 5. Fields ---------------------------------------------------- */
/* the sign-in form stacks its fields with a 12px gap (as on typst.app) */
#target form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
}
/* 5a. Floating label — <div class="field"><input><label></label></div>
       Exactly typst.app's technique (the label scales up on focus/fill).
       Scoped to div.field on purpose: <label class="field"> (pattern 5b
       below) must not be pulled into this fixed-height clipping box — the
       unscoped selector used to eclipse the stacked labels on the setup
       wizard and admin console while typing. */
#target div.field {
  position: relative;
  width: 100%;
  height: 48px;
  margin: 0;
  padding: 0;
  background: var(--layer-2);
  border-radius: 4px;
  overflow: hidden;
}
#target div.field label {
  position: absolute;
  top: 16px;
  left: 12px;
  margin: 0;
  padding: 0;
  color: var(--text-secondary);
  white-space: nowrap;
  pointer-events: none;
  user-select: none;
  transform-origin: 0 0;
  transition: transform .25s ease-out;
}
#target div.field.has-text label,
#target div.field input:focus + label { transform: translateY(-6px) scale(.84615); }
#target div.field input {
  width: 100%;
  height: 100%;
  padding: 23px 12px 9px;
  font: inherit;
  font-size: 13px;
  color: var(--text-primary);
  background: transparent;
  border: 0;
  outline: none;
}
#target div.field:focus-within { box-shadow: inset 0 0 0 2px var(--border-focus); }
.inconspicuous { position: absolute; top: -9999px; left: -9999px; }

/* 5b. Stacked label — <label class="field"><span>Label</span><input></label>
       Used by the setup wizard, the reset page and the admin console. */
label.field { display: block; margin-bottom: 14px; }
label.field > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 5px;
}
input[type=text],
input[type=email],
input[type=password],
input[type=number],
input[type=search],
input[type=url],
select,
textarea {
  width: 100%;
  padding: 10px 12px;
  font: inherit;
  color: var(--text-primary);
  background: var(--action-secondary-plain);
  border: 1px solid var(--border-input);
  border-radius: 6px;
  outline: none;
}
input::placeholder, textarea::placeholder { color: var(--text-secondary); }
input:focus, select:focus, textarea:focus {
  border-color: var(--action-primary);
  box-shadow: 0 0 0 2px var(--border-focus);
}
input:disabled, select:disabled { color: var(--text-disabled); border-color: var(--border-disabled); }

/* ---------- 6. Buttons (mirrors _button_10pgl_* from typst.app) ---------- */
button,
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 600;
  height: 48px;
  padding-inline: 24px;
  color: var(--text-primary);
  background: var(--action-secondary-shaded);
  border: 0;
  border-radius: 6px;
  cursor: default;
  text-decoration: none;
  user-select: none;
}
button:hover, .button:hover { background: var(--action-secondary-hover); text-decoration: none; }
button:active, .button:active { background: var(--action-secondary-active); }
button:focus-visible, .button:focus-visible { box-shadow: inset 0 0 0 2px var(--action-primary); }
button:disabled, .button[aria-disabled=true] {
  background: var(--action-secondary-disabled);
  color: var(--text-disabled);
}
button.primary, .button.primary {
  color: var(--text-light);
  background: var(--action-primary);
}
button.primary:hover, .button.primary:hover { background: var(--action-primary-hover); }
button.primary:active, .button.primary:active { background: var(--action-primary-active); }
button.primary:disabled, .button.primary[aria-disabled=true] {
  background: var(--action-primary-disabled);
  color: var(--text-light);
}
button.danger, .button.danger {
  color: var(--text-light);
  background: var(--action-critical);
}
button.danger:hover, .button.danger:hover { background: var(--action-critical-hover); }
button.compact, .button.compact,
button.small, .button.small { height: 32px; padding-inline: 12px; font-size: 12px; }
button.link {
  height: auto;
  padding: 0;
  background: none;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 13px;
  border-radius: 0;
}
button.link:hover { background: none; text-decoration: underline; }

.submit-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: flex-end;
  gap: 32px;
}
.submit-row > * { flex-shrink: 0; }
@media (max-width: 640px) { .submit-row { gap: 8px; } }

/* ---------- 7. Status messages ------------------------------------------ */
/* typst.app's status palette: error/success/info use the -critical /
   -success / -primary pairs rather than bespoke colours. */
.status, .msg {
  padding: 8px 12px;
  border-radius: 4px;
  font-size: 13px;
  border: 1px solid transparent;
}
.status.error, .msg.error {
  background: var(--action-critical-transparent, #ea3e4714);
  border-color: var(--action-critical);
  color: var(--text-critical);
}
.status.success, .msg.ok, .msg.success {
  background: var(--action-upsale-hover-transparent, #3ed9931a);
  border-color: var(--border-success);
  color: var(--text-success);
}
.status.info, .msg.info {
  background: var(--action-primary-hover-transparent);
  border-color: var(--action-primary);
  color: var(--text-primary);
}
.status a, .msg a { color: var(--text-link); }

/* ---------- 8. Cards & the admin shell ---------------------------------- */
.center {
  min-height: 100%;
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.card {
  background: var(--layer-1);
  border: 1px solid var(--border-secondary);
  border-radius: 6px;
  box-shadow: var(--effect-shadow-1);
  padding: 28px;
  width: 100%;
  max-width: 420px;
}
.card.wide { max-width: 980px; }
.card h1 { font-size: 24px; margin-bottom: 6px; }
.muted { color: var(--text-secondary); }
.row { display: flex; gap: 10px; align-items: center; }
.row.end { justify-content: flex-end; }
.grow { flex: 1; }
hr { border: 0; border-top: 1px solid var(--border-secondary); margin: 20px 0; }

/* topbar: the editor's 40px bar (grid-template "… infobar" 40px) */
.topbar {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 40px;
  padding: 0 16px;
  background: var(--layer-1);
  border-bottom: 1px solid var(--border-secondary);
  position: sticky;
  top: 0;
  z-index: 20;
}
.topbar .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}
.topbar .spacer { flex: 1; }
.wrap { max-width: 1360px; margin: 0 auto; padding: 20px 24px 60px; }

.panel {
  background: var(--layer-1);
  border: 1px solid var(--border-secondary);
  border-radius: 6px;
  padding: 18px;
  margin-top: 14px;
}
.kpi-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  padding: 10px 16px;
  background: var(--layer-1);
  border: 1px solid var(--border-secondary);
  border-radius: 6px;
  margin-bottom: 18px;
  font-size: 13px;
}
.kpi-bar .kpi-item { display: flex; align-items: center; gap: 6px; }
.kpi-bar .kpi-item b { font-size: 14px; font-weight: 700; }
.kpi-bar .kpi-sep { color: var(--border-secondary); user-select: none; }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.tabs { display: flex; gap: 4px; margin: 0; flex-wrap: wrap; }
.tabs button {
  height: 32px;
  padding-inline: 12px;
  font-size: 13px;
  font-weight: 500;
  background: transparent;
  color: var(--text-secondary);
  border-radius: 6px;
}
.tabs button:hover { background: var(--action-secondary-hover); }
.tabs button[aria-selected=true] {
  background: var(--action-secondary-shaded);
  color: var(--text-primary);
  font-weight: 600;
}
.search { max-width: 280px; }

/* tables — typst.app's list view uses layer-1 rows on a layer-2 canvas */
table { width: 100%; border-collapse: collapse; font-size: 13px; }
th, td {
  text-align: left;
  padding: 9px 10px;
  border-bottom: 1px solid var(--border-secondary);
  vertical-align: middle;
}
th {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-secondary);
  font-weight: 600;
}
tbody tr:hover { background: var(--layer-2); }
td.actions { text-align: right; white-space: nowrap; overflow: visible !important; }

.spreadsheet-wrap {
  border: 1px solid var(--border-secondary);
  border-radius: 6px;
  background: var(--layer-1);
  overflow: auto;
  max-height: calc(100vh - 260px);
}
.spreadsheet {
  width: 100%;
  table-layout: fixed;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 12.5px;
}
.spreadsheet thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  text-align: left;
  background: var(--layer-2);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border-secondary);
  border-right: 1px solid var(--border-secondary);
  user-select: none;
}
.spreadsheet thead th:last-child { border-right: none; }
.spreadsheet tbody td {
  padding: 6px 12px;
  height: 38px;
  border-bottom: 1px solid var(--border-secondary);
  border-right: 1px solid var(--border-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}
.spreadsheet tbody td:last-child { border-right: none; }
.spreadsheet tbody tr:hover { background: var(--layer-2); }
.spreadsheet tbody .num-cell { text-align: right; font-variant-numeric: tabular-nums; }
.spreadsheet .mono-cell { font-family: var(--monospace); font-size: 11.5px; }

.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  padding: 2px 6px;
  border-radius: 4px;
  background: var(--layer-3);
  color: var(--text-secondary);
}
.badge.ok { color: var(--text-success); }
.badge.warn { color: var(--text-warning); }
.badge.danger { color: var(--text-critical); }
.badge.brand { color: var(--text-light); background: var(--brand-primary); }

/* modal — typst.app's dialogs sit on layer-1 with the modal shadow */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--layer-overlay);
  backdrop-filter: blur(3px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.modal-dialog {
  background: var(--layer-1);
  border: 1px solid var(--border-modal);
  border-radius: 6px;
  box-shadow: var(--effect-shadow-modal);
  width: 100%;
  max-width: 540px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 24px;
  position: relative;
}
.modal-dialog h2 { margin-top: 0; font-size: 20px; margin-bottom: 8px; }
.modal-close {
  position: absolute;
  top: 18px;
  right: 18px;
  height: auto;
  padding: 4px;
  background: transparent;
  border: none;
  font-size: 18px;
  line-height: 1;
  color: var(--text-secondary);
  cursor: default;
}
.modal-close:hover { background: var(--action-secondary-hover); border-radius: 4px; }

/* avatars (typst.app: 32px circles, initials on the brand gradient) */
.avatar-circle {
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  display: inline-block;
  vertical-align: middle;
  background: var(--layer-3);
}
.avatar-cell { display: flex; align-items: center; gap: 10px; }
.avatar-preview-wrap {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 12px;
  background: var(--layer-2);
  border-radius: 6px;
  margin-bottom: 16px;
}
.avatar-preview-wrap .avatar-circle { width: 56px; height: 56px; }

/* ---------- 9. Aliases -------------------------------------------------- */
/* Older markup used generic names; map them onto typst.app's tokens so a
   single token change updates every page. */
:root {
  --bg: var(--layer-2);
  --card: var(--layer-1);
  --text: var(--text-primary);
  --border: var(--border-secondary);
  --layer: var(--layer-2);
  --brand: var(--action-primary);
  --brand-hover: var(--action-primary-hover);
  --danger: var(--text-critical);
  --danger-bg: #ea3e4714;
  --ok: var(--text-success);
  --warn: var(--text-warning);
  --radius: 6px;
  --shadow: var(--effect-shadow-1);
  /* typst.app only ships the -hover-transparent pair for the primary action;
     mirror the same 8% alpha for the status colours it has no token for */
  --action-critical-transparent: #ea3e4714;
  --action-upsale-hover-transparent: #3ed9931a;
}
