/*
 * Reusable pieces: buttons, form controls, tabs, chips, badges/pills,
 * small status/text treatments, and the LorenzoScript editor and rendered
 * text (.ls-editor, .ls-content; ADR 0106) - the generic subset curated from
 * apps/inventory-web's and apps/account-hub's own components.css.
 * Anything domain-specific (item cards, board columns, catalog rows,
 * tenant cards) stays local to the app that needs it, not here - see
 * ADR 0098 and docs/guides/adding-a-package.md's "don't generalize before
 * a second consumer needs it" rule.
 *
 * Uses the semantic tokens from tokens.css (identity.md §6.6) throughout -
 * never a --brand- or --utility- primitive directly.
 */

/* Sized relative to the surrounding text so an icon sits correctly next to
   a label at any font-size, and nudged to align with the text baseline
   (identity.md §17.3/§15.6 - see icons.svg/icons.manifest.yaml). */
.icon {
  width: 1em;
  height: 1em;
  display: inline-block;
  vertical-align: -0.125em;
}

/* A generic bordered, rounded surface - the base every more specific card
   (a tenant card, an item card, a preview swatch) is built from
   (identity.md §8.2's "clean information records"). Deliberately unpadded
   - some cards want edge-to-edge media (a swatch color, an image) with
   only a caption padded; add .card-body for a simple fully-padded card. */
.card {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  background: var(--surface-default);
  overflow: hidden;
}

.card-body {
  padding: var(--space-4);
}

/* .card used directly on an <a> (a whole card is the click target) - reset
   the base link color/decoration so it reads as a card first, not as blue
   underlined link text that happens to contain a heading. */
a.card {
  display: block;
  color: inherit;
  text-decoration: none;
}

/* A bare, unclassed <button> still gets a sensible default (identity.md
   §17's "buttons are their own layer" - never plain --action) - add
   .btn-secondary/.btn-danger explicitly to opt out of this default. */
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  background: var(--button-primary-bg);
  color: var(--button-primary-fg);
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
}

button:hover {
  background: var(--button-primary-hover);
}

button:disabled {
  opacity: 0.6;
  cursor: default;
}

/* .btn on an <a> gets the same visual language as a <button> - anchors
   don't inherit the `button` element rule above. */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-1);
  font-family: var(--font-ui);
  font-size: 14px;
  font-weight: 500;
  text-decoration: none;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
}

.btn-primary,
.btn.btn-primary {
  background: var(--button-primary-bg);
  color: var(--button-primary-fg);
}

.btn-primary:hover {
  background: var(--button-primary-hover);
}

.btn-secondary {
  background: var(--button-secondary-bg);
  color: var(--button-secondary-fg);
  border-color: var(--button-secondary-border);
}

.btn-secondary:hover {
  background: var(--fill-soft);
}

.btn-danger {
  background: var(--button-danger-bg);
  color: var(--button-danger-fg);
}

.btn-danger:hover {
  opacity: 0.9;
}

/* Form controls */
.text-input {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--surface-default);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  padding: var(--space-2) var(--space-3);
  width: 100%;
}

.text-input:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
}

.field-label {
  font-size: 13px;
  color: var(--text-secondary);
}

/* A single-line create/invite form (text input + submit + status). */
.inline-form {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
}

/* Tabs */
.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-subtle);
}

/* A row of tabs that does not fit a phone wraps onto a second line instead of running off the
   screen (identity.md 8.5). */
@media (max-width: 720px) {
  .tabs {
    flex-wrap: wrap;
  }
}

.tab {
  font-family: var(--font-ui);
  font-size: 14px;
  background: none;
  color: var(--text-secondary);
  border: none;
  border-radius: 0;
  border-bottom: 2px solid transparent;
  padding: var(--space-2) var(--space-3);
  cursor: pointer;
}

.tab:hover {
  color: var(--text-primary);
}

.tab[aria-selected="true"] {
  color: var(--text-primary);
  font-weight: 600;
  border-bottom-color: var(--action);
}

/* Chips - removable multi-select tags */
.chip {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  background: var(--fill-soft);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-pill);
  padding: var(--space-1) var(--space-2);
  font-size: 13px;
}

/* A chip reads the same whether or not it links somewhere: the link takes the chip's own
   colour and no underline, and only underlines once the pointer is on it. */
.chip a {
  color: inherit;
  text-decoration: none;
}

.chip a:hover {
  color: inherit;
  text-decoration: underline;
}

.chip-remove {
  background: none;
  border: none;
  color: var(--text-tertiary);
  padding: 0;
  width: 16px;
  height: 16px;
  line-height: 1;
  border-radius: 50%;
  cursor: pointer;
}

.chip-remove:hover {
  background: var(--border-subtle);
}

/* Combobox - a text field with a list of suggestions under it. The list is an elevated surface
   like a dialog, so it gets the border and the shadow both. */
.combobox {
  position: relative;
}

.combobox-suggestions {
  position: absolute;
  inset-block-start: calc(100% + var(--space-1));
  inset-inline: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  max-height: 240px;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface-default);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  box-shadow: 0 8px 24px color-mix(in srgb, var(--brand-ink) 20%, transparent);
}

.combobox-suggestion button {
  display: block;
  width: 100%;
  background: none;
  color: var(--text-primary);
  text-align: left;
  font-size: 14px;
  border-radius: 0;
  padding: var(--space-2) var(--space-3);
}

.combobox-suggestion button:hover {
  background: var(--fill-soft);
}

/* A labeled color preview chip - e.g. showing what a design token or a
   user's chosen accent color actually looks like. Built on .card; the
   color itself is necessarily an inline style (there's no class for "some
   arbitrary token's current value"). */
.swatch-color {
  height: 56px;
}

.swatch-label {
  display: block;
  padding: var(--space-2);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* A small, uppercase role/kind tag next to a name - non-interactive. */
.badge {
  display: inline-block;
  font-family: var(--font-ui);
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.02em;
  color: var(--text-tertiary);
  background: var(--fill-soft);
  border-radius: var(--radius-pill);
  padding: 2px var(--space-2);
}

/* Status pills - success/warning/danger only (§6.6); canonical and
   restricted-visibility get their own, differently-shaped treatments
   below, since neither is a "status." */
.pill {
  display: inline-flex;
  align-items: center;
  font-size: 13px;
  font-weight: 500;
  padding: 4px var(--space-2);
  border-radius: var(--radius-pill);
}

.pill-success {
  background: var(--success-surface);
  color: var(--success);
}

.pill-warning {
  background: var(--warning-surface);
  color: var(--warning);
}

.pill-danger {
  background: var(--danger-surface);
  color: var(--danger);
}

/* Restricted visibility - one neutral treatment for every non-public
   tier (private, GM-only, a selected group); only the icon/label
   differs. Public gets no badge at all - see identity.md §6.6/§18. */
.badge-visibility {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  padding: 4px var(--space-2);
  border-radius: var(--radius-pill);
  background: var(--visibility-restricted-surface);
  color: var(--visibility-restricted-text);
  border: 1px solid var(--visibility-restricted-border);
}

/* An unread count or similar "needs attention" marker - gold, per
   identity.md §1.4's "gold is punctuation": marks significance, not a
   permanent surface treatment. */
.canonical-marker:not(h1, h2, h3, h4, h5) {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 600;
  color: var(--canonical);
}

h1.canonical-marker,
h2.canonical-marker,
h3.canonical-marker,
h4.canonical-marker,
h5.canonical-marker {
  color: var(--canonical);
}

/* A bordered list of records with inline actions (characters, beings,
   members) - identity.md §8.2's "clean information records." */
.list {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
}

.list > li {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  background: var(--surface-default);
}

/* Small, muted status/progress text next to a button or form -
   "Saving…", an inline error, or nothing at all. */
.status-text {
  font-size: 13px;
  color: var(--text-secondary);
}

.error-text {
  color: var(--danger);
}

/* A page or section's own intro paragraph - muted, and capped to a
   comfortable reading width regardless of its container. */
.lede {
  color: var(--text-secondary);
  max-width: 60ch;
}

pre {
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--fill-soft);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: var(--space-3);
  overflow-x: auto;
}

/* Dialogs - a bare <dialog> gets a sensible default with no class needed.
   Both a border and a shadow here, not just the shadow §8.2's binary
   policy would otherwise suggest for an elevated surface: a non-modal
   <dialog> (opened via show(), not showModal()) never gets a ::backdrop
   at all - that's a platform behavior, not something this stylesheet
   controls - so unlike a modal one, it has nothing else separating it
   from whatever happens to be behind it. */
dialog {
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-surface);
  padding: var(--space-4);
  background: var(--surface-default);
  color: var(--text-primary);
  max-width: min(480px, 92vw);
  box-shadow: 0 12px 32px color-mix(in srgb, var(--brand-ink) 28%, transparent);
}

/* Only a modal dialog (showModal()) ever gets this - the blur is what
   actually reads as "everything else is out of focus," well beyond what
   the darkening tint alone communicates. */
dialog::backdrop {
  background: color-mix(in srgb, var(--brand-ink) 50%, transparent);
  backdrop-filter: blur(4px);
}

/* Tree view - nested <details>/<summary>, native disclosure semantics
   (keyboard-operable, no JS required for expand/collapse). */
.tree,
.tree ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  list-style: none;
  margin: 0;
  padding: 0;
}

.tree ul {
  padding-inline-start: var(--space-4);
  margin-top: var(--space-1);
}

.tree summary {
  cursor: pointer;
  border-radius: var(--radius-control);
}

.tree summary,
.tree li:not(:has(summary)) {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
}

.tree summary::-webkit-details-marker {
  display: none;
}

.tree summary::marker {
  content: "";
}

.tree summary:hover {
  background: var(--fill-soft);
}

/* Fades a scrolling element's top and bottom edges while there is more to
   scroll to on that side (pair with .vertical-window). Scroll-driven, so the
   animation sits behind @supports like motion.css's other scroll effects;
   without it the edges stay fully opaque. */
@property --scroll-fade-top {
  syntax: "<number>";
  inherits: false;
  initial-value: 1;
}

@property --scroll-fade-bottom {
  syntax: "<number>";
  inherits: false;
  initial-value: 1;
}

.vertical-mask {
  --fade-size: var(--space-6);
  --fade-distance: var(--space-3);
  --scroll-fade-top: 1;
  --scroll-fade-bottom: 1;

  mask-image: linear-gradient(
    to bottom,
    rgb(0 0 0 / var(--scroll-fade-top)) 0,
    #000 var(--fade-size),
    #000 calc(100% - var(--fade-size)),
    rgb(0 0 0 / var(--scroll-fade-bottom)) 100%
  );
}

@supports (animation-timeline: scroll()) {
  .vertical-mask {
    animation-name: scroll-fade-top, scroll-fade-bottom;
    animation-timing-function: linear, linear;
    animation-fill-mode: both, both;
    animation-timeline: scroll(self block), scroll(self block);
    animation-range:
      0 var(--fade-distance),
      calc(100% - var(--fade-distance)) 100%;
  }
}

@keyframes scroll-fade-top {
  from {
    --scroll-fade-top: 1;
  }
  to {
    --scroll-fade-top: 0;
  }
}

@keyframes scroll-fade-bottom {
  from {
    --scroll-fade-bottom: 0;
  }
  to {
    --scroll-fade-bottom: 1;
  }
}

/* A lineage: what something inherits from, nearest first. Each level indents under
   the one it comes from, a ↳ marking the step, and the first one is set apart. A DAG,
   not always a chain: something reachable through two parents (diamond inheritance)
   appears twice, once per real path, rather than being flattened into one misleading
   line. A <ul class="lineage"> of <li>s, each with its own nested <ul> of parents. */
.lineage {
  font-size: 13px;
  color: var(--text-tertiary);
}

.lineage > li {
  color: var(--text-secondary);
  font-weight: 600;
}

.lineage ul {
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  padding-inline-start: var(--space-4);
  margin-top: var(--space-1);
  color: var(--text-tertiary);
  font-weight: 400;
}

/* Likewise a name in a lineage looks the same linked or not. */
.lineage a {
  color: inherit;
  text-decoration: none;
}

.lineage a:hover {
  color: inherit;
  text-decoration: underline;
}

.lineage ul li::before {
  content: "↳ ";
  color: var(--text-tertiary);
}

/* Names and values in two aligned columns: a <dl class="key-values"> of <dt>/<dd>
   pairs, such as an item's stats. Values are monospaced. */
.key-values {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-1) var(--space-3);
  margin: 0;
}

.key-values dt {
  color: var(--text-tertiary);
  font-size: 13px;
}

.key-values dd {
  margin: 0;
  font-family: var(--font-mono);
  font-size: 13px;
}

/* One column on a phone: the name above its value, each pair set apart
   from the next (§8.5). */
@media (max-width: 720px) {
  .key-values {
    grid-template-columns: 1fr;
    gap: 0;
  }

  .key-values dd {
    margin-bottom: var(--space-2);
  }
}

/* A wrapping row of pictures, each at most 240px: a <div class="gallery"> of <figure>s. */
.gallery {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
}

.gallery figure {
  margin: 0;
}

.gallery img {
  display: block;
  max-width: 240px;
  max-height: 240px;
  border-radius: var(--radius-control);
}

/* Small print about where something comes from: "From Longsword". */
.caption {
  margin: 0;
  font-size: 12px;
  color: var(--text-tertiary);
}

/* A labelled row of choices, such as radios: the label gives every group the same width,
   so the choices line up down a list of groups. A <div class="option-group" role="group">
   of an .option-group-label and the choices. */
.option-group {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-3);
}

.option-group-label {
  min-width: 8rem;
  font-weight: 600;
}
/* .tree-toggle, not the generic .icon - a summary row often carries a
   second, semantic icon (a type marker) alongside the disclosure chevron,
   and only the chevron itself should rotate open. */
@media (prefers-reduced-motion: no-preference) {
  .tree summary .tree-toggle {
    transition: transform 150ms ease;
  }
}

.tree details[open] > summary .tree-toggle {
  transform: rotate(90deg);
}

/* Outline: a chain whose links say what they are, such as the repositories
   a repository is built on (identity.md §18). It is a plain nested list, so
   it reads in order with a screen reader and needs no script; a node that
   can be opened holds a link or a button.

   The rule down the left of a nested list is the edge. Solid is a direct
   relationship; .outline-derived is dashed for one that is derived or
   passes through another (§18.2). The line is never the only thing saying
   so: every node carries its state as words in .outline-state, so the
   outline reads the same in grayscale. The current selection is a fill,
   separate from meaning (§18.1). */
.outline,
.outline ul {
  list-style: none;
  margin: 0;
  padding: 0;
}

.outline ul {
  margin-inline-start: var(--space-3);
  padding-inline-start: var(--space-3);
  border-inline-start: 2px solid var(--border-strong);
}

.outline ul.outline-derived {
  border-inline-start-style: dashed;
}

.outline-node {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-1) var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-control);
}

.outline-node[aria-current="true"] {
  background: var(--surface-selected);
}

.outline-name {
  font-weight: 600;
}

/* Something that cannot be read (not invited, not published) stays in the
   outline, quieter: its state says why, so the fade is not the message. */
.outline-node--muted .outline-name {
  color: var(--text-tertiary);
  font-weight: 500;
}

.outline-state {
  font-size: 13px;
  color: var(--text-secondary);
}

/* What to do about a node, on a line of its own beneath it. */
.outline-hint {
  flex-basis: 100%;
  margin: 0;
  font-size: 13px;
  color: var(--text-secondary);
}

/* Form fields beyond .text-input */
textarea.text-input {
  min-height: 96px;
  resize: vertical;
}

/* A single-line <select> gets its own chevron (native ones look
   inconsistent across browsers/OSes) via two small gradients rather than
   an SVG data URI, since a data URI's own fill/stroke can't reference a
   design token - a plain gradient can. Excludes [multiple] and a sized
   listbox below, which render as a scrollable box, not a one-line
   dropdown, and shouldn't get a chevron at all. */
select.text-input:not([multiple]):not([size]) {
  cursor: pointer;
  appearance: none;
  padding-right: calc(var(--space-3) + 18px);
  background-repeat: no-repeat;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-secondary) 50%),
    linear-gradient(135deg, var(--text-secondary) 50%, transparent 50%);
  background-position:
    calc(100% - 20px) center,
    calc(100% - 15px) center;
  background-size: 5px 5px;
}

/* A multi-select listbox - still a .text-input for border/font
   consistency, but no chevron and no forced single line. */
select.text-input[multiple],
select.text-input[size] {
  cursor: pointer;
  padding: var(--space-2);
}

/* Browsers italicize an <optgroup> label by default - this design system
   has no italics anywhere else, so it gets the same treatment as any
   other secondary label instead. */
optgroup {
  font-style: normal;
  font-weight: 600;
  color: var(--text-secondary);
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  height: 16px;
  accent-color: var(--action);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--action);
}

/* A color swatch button - full .text-input width would stretch a small
   fixed-size native control absurdly wide, so it gets its own compact
   sizing instead. */
input[type="color"] {
  width: 48px;
  height: 36px;
  padding: 2px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-control);
  background: var(--surface-default);
  cursor: pointer;
}

/* A file input's native "choose file" button, restyled to match .btn-
   secondary rather than the browser's own default button chrome. */
input[type="file"] {
  font-family: var(--font-ui);
  font-size: 14px;
  color: var(--text-secondary);
}

input[type="file"]::file-selector-button {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  background: var(--button-secondary-bg);
  color: var(--button-secondary-fg);
  border: 1px solid var(--button-secondary-border);
  border-radius: var(--radius-control);
  padding: var(--space-1) var(--space-2);
  margin-right: var(--space-2);
  cursor: pointer;
}

input[type="file"]::file-selector-button:hover {
  background: var(--fill-soft);
}

/* An image-button submit control - not a text field, so no .text-input
   border/padding, just a focus ring and a pointer cursor to read as
   interactive. */
input[type="image"] {
  cursor: pointer;
  border-radius: var(--radius-control);
}

input[type="image"]:focus-visible {
  outline: 2px solid var(--focus-ring);
  outline-offset: 1px;
}

.field-row {
  display: flex;
  align-items: center;
  gap: var(--space-2);
}

/* A group of related controls under one question: a set of radios, a few checkboxes. A bare
   <fieldset> needs no class; its <legend> is the question, labelled like .field-label is for a
   single control. The controls stack, and min-width: 0 undoes the browser's own, which would
   otherwise let a long label push the box wider than its container. A class that sets its own
   layout (a .grid, say) wins over the stacking. */
fieldset {
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
  padding: var(--space-3) var(--space-4);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
}

legend {
  padding-inline: var(--space-2);
  font-size: 13px;
  color: var(--text-secondary);
}

fieldset:disabled {
  opacity: 0.6;
}

/* A toggle switch - not a native input type, built from a checkbox
   visually hidden under a track/thumb pair. */
.switch {
  position: relative;
  display: inline-block;
  width: 36px;
  height: 20px;
  flex-shrink: 0;
}

.switch input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.switch-track {
  position: absolute;
  inset: 0;
  background: var(--border-strong);
  border-radius: var(--radius-pill);
  transition: background-color 150ms ease;
  pointer-events: none;
}

.switch-track::before {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: var(--surface-default);
  border-radius: 50%;
  transition: transform 150ms ease;
}

.switch input:checked + .switch-track {
  background: var(--action);
}

.switch input:checked + .switch-track::before {
  transform: translateX(16px);
}

.switch input:focus-visible + .switch-track {
  outline: 2px solid var(--focus-ring);
  outline-offset: 2px;
}

/* A custom editor surface - compose with .card for the outer chrome
   (<div class="card"><div class="editor-toolbar">...<div class=
   "editor-content" contenteditable>). */
.editor-toolbar {
  display: flex;
  gap: var(--space-1);
  padding: var(--space-2);
  background: var(--surface-muted);
  border-bottom: 1px solid var(--border-subtle);
}

.editor-toolbar button {
  background: transparent;
  color: var(--text-secondary);
  width: 28px;
  height: 28px;
  padding: 0;
}

.editor-toolbar button:hover {
  background: var(--fill-soft);
  color: var(--text-primary);
}

.editor-toolbar .divider {
  width: 1px;
  align-self: stretch;
  background: var(--border-subtle);
  margin-inline: var(--space-1);
}

.editor-content {
  padding: var(--space-3);
  min-height: 160px;
  outline: none;
}

.editor-content:empty::before {
  content: attr(data-placeholder);
  color: var(--text-tertiary);
}

/* The LorenzoScript editor (RFC 0027, ADR 0106): packages/lorenzoscript-editor
   wraps a textarea and its preview in .card.ls-editor, after an .editor-toolbar.
   data-layout is "split" (side by side, stacked when the editor itself is
   narrow, whatever the viewport) or "tabs". */
.ls-editor {
  container-type: inline-size;
}

.ls-editor .editor-toolbar {
  flex-wrap: wrap;
  align-items: center;
}

.ls-editor .editor-toolbar button:disabled {
  opacity: 0.4;
  cursor: default;
}

.ls-editor .editor-toolbar .tabs {
  margin-inline-start: auto;
  border-bottom: none;
}

/* Tabs are buttons too, but not the toolbar's square icon ones. */
.ls-editor .editor-toolbar .tab {
  width: auto;
  height: auto;
  padding: var(--space-1) var(--space-2);
  border-radius: 0;
}

.ls-editor-panes {
  display: grid;
}

.ls-editor[data-layout="split"] .ls-editor-panes {
  grid-template-columns: 1fr 1fr;
}

.ls-editor[data-layout="split"] .ls-preview {
  border-inline-start: 1px solid var(--border-subtle);
}

@container (max-width: 760px) {
  .ls-editor[data-layout="split"] .ls-editor-panes {
    grid-template-columns: 1fr;
  }

  .ls-editor[data-layout="split"] .ls-preview {
    border-inline-start: none;
    border-top: 1px solid var(--border-subtle);
  }
}

.ls-editor textarea.editor-content {
  width: 100%;
  min-height: 320px;
  border: none;
  border-radius: 0;
  resize: vertical;
  background: transparent;
  color: var(--text-primary);
  font-family: var(--font-mono);
  font-size: 13px;
  line-height: 1.6;
}

/* A wide table scrolls the preview sideways instead of squeezing its words. */
.ls-editor .ls-preview {
  min-width: 0;
  overflow-x: auto;
}

/* Rendered LorenzoScript, wherever it's shown: wrap the renderer's output
   in .ls-content. Its own classes all start with ls-. Table cells keep the
   renderer's align attribute, so nothing here sets their text-align. */
.ls-content {
  overflow-wrap: break-word;
}

.ls-content > :first-child {
  margin-top: 0;
}

/* normalize.css strips every list's markers; written lists need theirs. */
.ls-content ul,
.ls-content ol {
  margin-block: var(--space-2);
  padding-inline-start: var(--space-5);
}

.ls-content ul {
  list-style: disc;
}

.ls-content ol {
  list-style: decimal;
}

.ls-content ul ul {
  list-style: circle;
}

.ls-content blockquote {
  margin-inline: 0;
  padding-inline-start: var(--space-3);
  border-inline-start: 3px solid var(--border-subtle);
  color: var(--text-secondary);
}

.ls-content hr {
  border: none;
  border-top: 1px solid var(--border-subtle);
  margin-block: var(--space-4);
}

.ls-content table {
  border-collapse: collapse;
  margin-block: var(--space-3);
}

.ls-content th,
.ls-content td {
  border: 1px solid var(--border-subtle);
  padding: var(--space-1) var(--space-2);
}

.ls-content th {
  background: var(--surface-muted);
}

.ls-content img {
  max-width: 100%;
  height: auto;
}

.ls-content abbr[title] {
  text-decoration: underline dotted;
  cursor: help;
}

.ls-content .ls-task {
  list-style: none;
}

.ls-content .ls-task input {
  margin-inline-end: var(--space-1);
}

.ls-content .ls-entity {
  text-decoration-style: dotted;
}

.ls-content .ls-cal {
  font-style: italic;
}

.ls-content math[display="block"] {
  margin-block: var(--space-3);
}

.ls-content .ls-math {
  color: var(--text-secondary);
}

.ls-content .ls-toc {
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-card);
  padding: var(--space-2) var(--space-3);
}

.ls-content .ls-toc ul {
  margin: 0;
  padding-inline-start: var(--space-4);
  list-style: none;
}

.ls-content .ls-toc > ul {
  padding-inline-start: 0;
  list-style: none;
}

.ls-content .ls-footnotes {
  margin-top: var(--space-5);
  padding-top: var(--space-2);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.875em;
  color: var(--text-secondary);
}

.ls-content .ls-fnref a,
.ls-content .ls-backref {
  text-decoration: none;
}

/* Touch targets (identity.md §8.5): at phone widths and for a coarse
   pointer, anything pressed is at least --target-min tall. The same rule
   serves a narrowed desktop window and a tablet in landscape, which is why
   it is two conditions and not a guess about the device. It only raises a
   minimum: a control already taller is untouched, and desktop sizes with a
   fine pointer are exactly what they were. Placed last so nothing above it
   can set a smaller height after it. */
@media (max-width: 720px), (pointer: coarse) {
  button,
  .btn,
  .text-input,
  .tab,
  .sidebar a,
  .tree summary,
  .tree li:not(:has(summary)),
  .outline-node {
    min-height: var(--target-min);
  }

  /* An inline link in a header is not a block, so min-height would be
     ignored; make it one that centres its text. */
  .site-header nav a {
    display: inline-flex;
    align-items: center;
    min-height: var(--target-min);
  }

  /* A chip's remove mark is 16px and sits inside a 25px chip; making the
     mark 44px would change the chip. Its pressable area grows instead,
     past its edges and under neighbouring text, not its look. */
  .chip-remove {
    position: relative;
  }

  .chip-remove::after {
    content: "";
    position: absolute;
    inset: calc((var(--target-min) - 16px) / -2);
  }
}
