/*
 * MELTER — visual system inherited from NOIR's STYLEGUIDE.md.
 *
 * Tokens, type stacks, easing, layering, and the hairline vocabulary are taken
 * from the guide unchanged. Three extensions are declared deliberately, all
 * documented in the README:
 *
 *   1. Syntax token opacities. Monochrome highlighting has no hue to work
 *      with, so it needs more steps than the four-level page ladder. They are
 *      namespaced under --t-* and used only inside editors.
 *   2. A second breakpoint at 60rem. A two-pane workbench cannot clamp into a
 *      single column; the guide's 30rem breakpoint is kept as well.
 *   3. --signal, the single accent (STYLEGUIDE §12). It means "the next action
 *      is here" and is spent on exactly one control at a time.
 */

:root {
  color-scheme: dark;

  /* --- guide tokens, verbatim --- */
  --bg: #000000;
  --fg: #ffffff;
  --fg-dim: rgba(255, 255, 255, 0.58);
  --fg-faint: rgba(255, 255, 255, 0.14);
  --fg-body: rgba(255, 255, 255, 0.72);

  --font-display: "Helvetica Neue", Helvetica, Arial, system-ui, sans-serif;
  --font-mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --ease: cubic-bezier(0.16, 1, 0.3, 1);

  --mx: 50%;
  --my: 30%;

  /* --- declared extension: signal (STYLEGUIDE §12) --- */
  /* The one accent. Means "the next action is here" and nothing else. */
  --signal: #a7e6ec;
  --signal-soft: rgba(167, 230, 236, 0.55);
  --signal-faint: rgba(167, 230, 236, 0.14);

  /* --- declared extension: syntax tokens (editors only) --- */
  --t-key: rgba(255, 255, 255, 1);
  --t-tag: rgba(255, 255, 255, 0.92);
  --t-number: rgba(255, 255, 255, 0.86);
  --t-string: rgba(255, 255, 255, 0.72);
  --t-attr: rgba(255, 255, 255, 0.66);
  --t-literal: rgba(255, 255, 255, 0.58);
  --t-punct: rgba(255, 255, 255, 0.38);
  --t-comment: rgba(255, 255, 255, 0.34);

  /* --- density --- */
  --rule: 1px solid var(--fg-faint);
  --pad: clamp(0.7rem, 1.4vw, 1.15rem);
  --gap: clamp(0.5rem, 1vw, 0.85rem);
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow: hidden; /* panes scroll internally; the shell never does */
}

/* ---------------------------------------------------------- atmosphere -- */

/*
 * The guide's three layers, with one change: the glow does not track the
 * pointer here. A light drifting behind a code editor is noise, so it sits
 * still. Grain and vignette are unchanged.
 */
.glow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background: radial-gradient(
    58vmax 58vmax at var(--mx) var(--my),
    rgba(255, 255, 255, 0.05),
    rgba(255, 255, 255, 0.018) 34%,
    transparent 68%
  );
  opacity: 0;
  animation: rise-in 2.4s var(--ease) 0.1s forwards;
}

.grain {
  position: fixed;
  inset: -150%;
  z-index: 3;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.82' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
  animation: grain-shift 700ms steps(1) infinite;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(130% 95% at 50% 40%, transparent 52%, rgba(0, 0, 0, 0.62) 100%);
}

@keyframes rise-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: none; }
}

@keyframes grain-shift {
  0%   { transform: translate(0, 0); }
  20%  { transform: translate(-6%, 3%); }
  40%  { transform: translate(4%, -5%); }
  60%  { transform: translate(-3%, -2%); }
  80%  { transform: translate(5%, 4%); }
  100% { transform: translate(0, 0); }
}

/* ------------------------------------------------------------- brand -- */

.bar {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: calc(var(--pad) * 0.8) var(--pad);
  border-bottom: var(--rule);
  flex: 0 0 auto;
}

/*
 * MELTER / by Noir. Display face for the name, mono for the attribution,
 * exactly as the guide's two-face rule requires. "by Noir" is always present,
 * always smaller, never substituted.
 */
.brand {
  display: flex;
  flex-direction: column;
  gap: 0.14em;
  line-height: 1;
}

.brand__name {
  font-family: var(--font-display);
  font-size: clamp(1.05rem, 1.9vw, 1.42rem);
  font-weight: 900;
  letter-spacing: 0.17em;
  margin-right: -0.17em; /* cancel trailing letter-space */
  color: var(--fg);
}

.brand__by {
  font-family: var(--font-mono);
  font-size: clamp(0.56rem, 0.85vw, 0.68rem);
  font-weight: 400;
  letter-spacing: 0.19em;
  margin-right: -0.19em;
  color: var(--fg-dim);
}

/* ------------------------------------------------------- privacy badge -- */

.privacy {
  display: flex;
  align-items: center;
  gap: 0.5em;
  margin: 0 0 0 auto;
  padding: 0.4em 0.75em;
  border: var(--rule);
  font-size: clamp(0.56rem, 0.8vw, 0.66rem);
  letter-spacing: 0.2em;
  color: var(--fg-dim);
  white-space: nowrap;
}

.privacy__label { margin-right: -0.2em; }

.privacy__dot {
  width: 5px;
  height: 5px;
  background: var(--fg);
  border-radius: 50%;
  flex: 0 0 auto;
}

/* ------------------------------------------------------------ controls -- */

.bar__actions { display: flex; gap: 0.4rem; }

.btn {
  appearance: none;
  display: inline-flex;
  align-items: center;
  gap: 0.55em;
  padding: 0.5em 0.85em;
  border: var(--rule);
  background: transparent;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: clamp(0.58rem, 0.82vw, 0.68rem);
  font-weight: 500;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease);
}

.btn:hover,
.btn:focus-visible {
  color: var(--fg);
  border-color: var(--fg-dim);
  outline: none;
}

.btn:focus-visible { border-color: var(--fg); }

.btn:disabled { opacity: 0.35; cursor: not-allowed; }
.btn:disabled:hover { color: var(--fg-dim); border-color: var(--fg-faint); }

.btn--ghost { border-color: transparent; padding-inline: 0.6em; }
.btn--ghost:hover, .btn--ghost:focus-visible { border-color: var(--fg-faint); }

.btn.is-active { color: var(--fg); border-color: var(--fg-dim); }

/*
 * Beacon (STYLEGUIDE §14) — the only control allowed to wear signal, and only
 * while the user has not yet learned it. A slow 2.8s breath, never a blink.
 */
.btn--beacon {
  color: var(--signal);
  border-color: var(--signal-soft);
  animation: beacon 2.8s var(--ease) infinite;
}

.btn--beacon:hover,
.btn--beacon:focus-visible {
  color: var(--signal);
  border-color: var(--signal);
}

@keyframes beacon {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(167, 230, 236, 0);
    border-color: var(--signal-faint);
  }
  50% {
    box-shadow: 0 0 22px -2px rgba(167, 230, 236, 0.28);
    border-color: var(--signal-soft);
  }
}

/* The hint travels with the beacon and dies with it. */
.pipeline__hint {
  display: flex;
  align-items: center;
  gap: 0.45em;
  font-size: clamp(0.54rem, 0.78vw, 0.62rem);
  letter-spacing: 0.18em;
  color: var(--signal-soft);
  white-space: nowrap;
  flex: 0 0 auto;
  animation: rise-in 0.7s var(--ease) both;
}

.pipeline__hint[hidden] { display: none; }

.pipeline__hint kbd {
  font-family: inherit;
  letter-spacing: 0.1em;
  color: var(--t-punct);
}

.btn__key {
  font-family: inherit;
  font-size: 0.85em;
  letter-spacing: 0.1em;
  color: var(--t-punct);
}

.select {
  appearance: none;
  padding: 0.45em 1.6em 0.45em 0.7em;
  border: var(--rule);
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: clamp(0.58rem, 0.82vw, 0.68rem);
  letter-spacing: 0.16em;
  text-transform: uppercase;
  cursor: pointer;
  background-image: linear-gradient(45deg, transparent 50%, var(--fg-dim) 50%),
                    linear-gradient(135deg, var(--fg-dim) 50%, transparent 50%);
  background-position: right 0.75em top 55%, right 0.5em top 55%;
  background-size: 4px 4px, 4px 4px;
  background-repeat: no-repeat;
}

.select:focus-visible { outline: none; border-color: var(--fg); }
.select option { background: var(--bg); color: var(--fg); }

/* ----------------------------------------------------------- pipeline -- */

.pipeline {
  position: relative;
  z-index: 4;
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: calc(var(--pad) * 0.6) var(--pad);
  border-bottom: var(--rule);
  overflow-x: auto;
  overflow-y: hidden;
  flex: 0 0 auto;
  scrollbar-width: thin;
}

.pipeline__source { display: flex; align-items: center; gap: 0.55rem; flex: 0 0 auto; }

.pipeline__sourceLabel {
  font-size: clamp(0.54rem, 0.78vw, 0.62rem);
  letter-spacing: 0.2em;
  color: var(--t-punct);
}

.pipeline__detected {
  font-size: clamp(0.54rem, 0.78vw, 0.62rem);
  letter-spacing: 0.14em;
  color: var(--t-punct);
  white-space: nowrap;
}

.pipeline__detected.is-ambiguous { color: var(--fg-dim); }

.pipeline__arrow { color: var(--t-punct); flex: 0 0 auto; }

.pipeline__steps {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  list-style: none;
  margin: 0;
  padding: 0;
  flex: 0 0 auto;
}

.pipeline__tools { display: flex; gap: 0.25rem; margin-left: auto; flex: 0 0 auto; }

.step {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.45em 0.5em 0.45em 0.75em;
  border: var(--rule);
  font-size: clamp(0.56rem, 0.8vw, 0.66rem);
  letter-spacing: 0.16em;
  color: var(--fg-dim);
  white-space: nowrap;
  cursor: grab;
  transition: color 0.25s var(--ease), border-color 0.25s var(--ease), opacity 0.2s var(--ease);
}

.step:hover { color: var(--fg); border-color: var(--fg-dim); }
.step.is-dragging { opacity: 0.35; cursor: grabbing; }
.step.is-drop-target { border-color: var(--fg); }
.step.is-failed { border-color: var(--fg); color: var(--fg); }
.step.is-failed .step__label { text-decoration: line-through; text-decoration-thickness: 1px; }

.step__label { margin-right: -0.16em; }

.step__opts,
.step__remove {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--t-punct);
  font-family: inherit;
  font-size: 1em;
  line-height: 1;
  padding: 0.15em 0.25em;
  cursor: pointer;
  transition: color 0.2s var(--ease);
}

.step__opts:hover, .step__remove:hover,
.step__opts:focus-visible, .step__remove:focus-visible { color: var(--fg); outline: none; }

.step__arrow { color: var(--t-punct); flex: 0 0 auto; }

/* step option popover */
.step-opts {
  position: absolute;
  z-index: 20;
  min-width: 15rem;
  padding: var(--pad);
  border: 1px solid var(--fg-dim);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
}

.step-opts__row { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }

.step-opts__label {
  font-size: clamp(0.56rem, 0.8vw, 0.66rem);
  letter-spacing: 0.14em;
  color: var(--fg-dim);
  text-transform: uppercase;
}

.step-opts input[type="text"] {
  width: 7rem;
  padding: 0.35em 0.5em;
  border: var(--rule);
  background: transparent;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.step-opts input[type="text"]:focus-visible { outline: none; border-color: var(--fg); }

.step-opts input[type="checkbox"] { accent-color: #fff; width: 0.9rem; height: 0.9rem; }

/* --------------------------------------------------------- workspace -- */

.workspace {
  position: relative;
  z-index: 4;
  flex: 1 1 auto;
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.workspace[data-mode="diff"] {
  grid-template-columns: 1fr 1fr;
  grid-template-rows: minmax(6rem, 0.75fr) minmax(0, 1.25fr);
}

.pane {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-right: var(--rule);
}

.pane:last-of-type { border-right: 0; }

.pane--diffout { grid-column: 1 / -1; border-right: 0; border-top: var(--rule); }

.pane__head {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem var(--pad);
  border-bottom: var(--rule);
  flex: 0 0 auto;
  min-height: 2.6rem;
}

.pane__title {
  margin: 0;
  font-size: clamp(0.58rem, 0.82vw, 0.68rem);
  font-weight: 500;
  letter-spacing: 0.24em;
  color: var(--fg);
}

.pane__meta {
  font-size: clamp(0.54rem, 0.76vw, 0.62rem);
  letter-spacing: 0.12em;
  color: var(--t-punct);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.pane__actions { display: flex; gap: 0.15rem; margin-left: auto; flex: 0 0 auto; }

.pane__body { position: relative; flex: 1 1 auto; min-height: 0; }

.pane__foot {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.4rem var(--pad);
  border-top: var(--rule);
  flex: 0 0 auto;
  font-size: clamp(0.52rem, 0.74vw, 0.6rem);
  letter-spacing: 0.14em;
  color: var(--t-punct);
  min-height: 1.9rem;
}

.pane__cursor, .pane__timing { margin-left: auto; }

.status.is-error { color: var(--fg); }
.status.is-ok { color: var(--fg-dim); }

/* ------------------------------------------------------------- editor -- */

/*
 * EDITOR METRICS CONTRACT
 * The textarea and the <pre> beneath it must resolve to identical font,
 * line-height, letter-spacing, padding, and white-space. Change one, change
 * both, or the caret will drift away from the glyphs.
 */
.editor {
  position: absolute;
  inset: 0;
  display: flex;
  overflow: hidden;
  --editor-font-size: clamp(0.7rem, 0.85vw, 0.8rem);
  --editor-line-height: 1.65;
  --editor-pad-y: 0.75rem;
  --editor-pad-x: 0.8rem;
}

.editor__gutter {
  flex: 0 0 auto;
  overflow: hidden;
  padding: var(--editor-pad-y) 0.6rem var(--editor-pad-y) var(--pad);
  border-right: var(--rule);
  user-select: none;
  background: var(--bg);
}

.editor__gutter.is-hidden { display: none; }
.editor.is-wrapped .editor__gutter { display: none; }

.editor__lines {
  font-family: var(--font-mono);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  letter-spacing: 0;
  text-align: right;
  color: var(--t-punct);
  white-space: pre;
  will-change: transform;
}

.editor__body { position: relative; flex: 1 1 auto; min-width: 0; }

.editor__highlight,
.editor__input {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: var(--editor-pad-y) var(--editor-pad-x);
  border: 0;
  font-family: var(--font-mono);
  font-size: var(--editor-font-size);
  line-height: var(--editor-line-height);
  letter-spacing: 0;
  tab-size: 2;
  white-space: pre;
  word-break: normal;
  overflow-wrap: normal;
}

.editor__highlight {
  overflow: hidden;
  pointer-events: none;
  color: var(--fg-body);
  background: transparent;
}

.editor__highlight code { font: inherit; letter-spacing: inherit; }

.editor__input {
  overflow: auto;
  resize: none;
  background: transparent;
  color: transparent;
  caret-color: var(--fg);
  scrollbar-width: thin;
  scrollbar-color: var(--fg-faint) transparent;
}

.editor__input::selection { background: rgba(255, 255, 255, 0.22); color: transparent; }
.editor__input:focus-visible { outline: none; }

.editor.is-wrapped .editor__highlight,
.editor.is-wrapped .editor__input { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Oversized payloads drop highlighting; keep the text readable. */
.editor.is-plain .editor__highlight { color: var(--fg-body); }

.editor__input::-webkit-scrollbar { width: 10px; height: 10px; }
.editor__input::-webkit-scrollbar-thumb { background: var(--fg-faint); }
.editor__input::-webkit-scrollbar-thumb:hover { background: var(--fg-dim); }
.editor__input::-webkit-scrollbar-corner { background: transparent; }

/* ------------------------------------------------------ syntax tokens -- */

.t-key    { color: var(--t-key); font-weight: 500; }
.t-tag    { color: var(--t-tag); font-weight: 500; }
.t-attr   { color: var(--t-attr); }
.t-string { color: var(--t-string); }
.t-number { color: var(--t-number); }
.t-literal { color: var(--t-literal); font-style: italic; }
.t-punct  { color: var(--t-punct); }
.t-comment { color: var(--t-comment); font-style: italic; }
.t-boolean { color: var(--t-literal); font-style: italic; }
.t-null, .t-undefined { color: var(--t-literal); font-style: italic; }

/* -------------------------------------------------------- empty state -- */

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.9rem;
  padding: var(--pad);
  text-align: center;
  pointer-events: none;
}

.empty.is-hidden { display: none; }

.empty__lead {
  margin: 0;
  font-size: clamp(0.68rem, 1vw, 0.8rem);
  letter-spacing: 0.14em;
  color: var(--fg-dim);
}

.empty__hint,
.empty__drop {
  margin: 0;
  font-size: clamp(0.54rem, 0.78vw, 0.62rem);
  letter-spacing: 0.12em;
  color: var(--t-punct);
}

.empty__samples {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  pointer-events: auto;
  max-width: 30rem;
}

.pane__body.is-dropping { outline: 1px solid var(--fg); outline-offset: -1px; }

/* --------------------------------------------------------------- find -- */

.find {
  position: absolute;
  top: 0.5rem;
  right: 0.9rem;
  z-index: 6;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.4rem;
  border: 1px solid var(--fg-dim);
  background: var(--bg);
}

.find__input {
  width: 10rem;
  padding: 0.3em 0.5em;
  border: 0;
  background: transparent;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.72rem;
}

.find__input:focus-visible { outline: none; }

.find__count {
  font-size: 0.62rem;
  letter-spacing: 0.1em;
  color: var(--t-punct);
  min-width: 4rem;
  text-align: right;
}

/* --------------------------------------------------------------- tree -- */

.tree-host {
  position: absolute;
  inset: 0;
  overflow: auto;
  padding: var(--editor-pad-y, 0.75rem) var(--pad);
  scrollbar-width: thin;
}

.tree {
  font-family: var(--font-mono);
  font-size: clamp(0.7rem, 0.85vw, 0.8rem);
  line-height: 1.75;
}

.tree__node { position: relative; }
.tree__node:focus-visible { outline: 1px solid var(--fg); outline-offset: 1px; }

.tree__row { display: flex; align-items: baseline; gap: 0.35em; }

.tree__children { padding-left: 1.1rem; border-left: var(--rule); margin-left: 0.35rem; }

.tree__toggle,
.tree__spacer {
  width: 1.1em;
  flex: 0 0 auto;
  text-align: center;
}

.tree__toggle {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--t-punct);
  font: inherit;
  cursor: pointer;
  padding: 0;
}

.tree__toggle:hover { color: var(--fg); }

.tree__key { color: var(--t-key); font-weight: 500; }
.tree__count { color: var(--t-punct); }

.tree__more {
  appearance: none;
  margin: 0.3rem 0;
  padding: 0.35em 0.7em;
  border: var(--rule);
  background: transparent;
  color: var(--fg-dim);
  font-family: var(--font-mono);
  font-size: 0.6rem;
  letter-spacing: 0.16em;
  cursor: pointer;
}

.tree__more:hover { color: var(--fg); border-color: var(--fg-dim); }

/* --------------------------------------------------------------- diff -- */

.diff {
  position: absolute;
  inset: 0;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: clamp(0.68rem, 0.82vw, 0.78rem);
  line-height: 1.7;
  scrollbar-width: thin;
}

.diff__table { width: 100%; border-collapse: collapse; }

.diff__row > * { padding: 0 0.6rem; vertical-align: top; white-space: pre-wrap; overflow-wrap: anywhere; }

.diff__no {
  width: 3.2rem;
  text-align: right;
  color: var(--t-punct);
  user-select: none;
  white-space: nowrap;
  border-right: var(--rule);
}

.diff__sign {
  width: 1.4rem;
  text-align: center;
  color: var(--t-punct);
  user-select: none;
}

.diff__cell { color: var(--fg-body); }

/* Monochrome diff: presence is brightness, absence is dimness, plus a rule. */
.diff__row--insert .diff__cell { color: var(--fg); background: rgba(255, 255, 255, 0.055); }
.diff__row--insert .diff__sign { color: var(--fg); }

.diff__row--delete .diff__cell { color: rgba(255, 255, 255, 0.42); background: rgba(255, 255, 255, 0.015); }
.diff__row--delete .diff__sign { color: var(--fg-dim); }

.diff__row--replace .diff__cell--left { color: rgba(255, 255, 255, 0.42); background: rgba(255, 255, 255, 0.015); }
.diff__row--replace .diff__cell--right { color: var(--fg); background: rgba(255, 255, 255, 0.055); }

.diff__row--gap td {
  color: var(--t-punct);
  text-align: center;
  padding: 0.4rem;
  border-block: var(--rule);
  letter-spacing: 0.2em;
  font-size: 0.85em;
}

.diff__empty { padding: var(--pad); color: var(--t-punct); letter-spacing: 0.16em; }

.diff__split .diff__cell { width: 50%; }
.diff__split .diff__cell--left { border-right: var(--rule); }

/* ------------------------------------------------------------ palette -- */

.palette { position: fixed; inset: 0; z-index: 30; }

.palette__scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.72); }

.palette__panel {
  position: relative;
  width: min(38rem, calc(100vw - 2rem));
  margin: 12vh auto 0;
  border: 1px solid var(--fg-dim);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  max-height: 70vh;
  animation: rise-in 0.28s var(--ease) both;
}

.palette__field { display: flex; align-items: center; gap: 0.6rem; padding: 0.85rem var(--pad); border-bottom: var(--rule); }

.palette__prompt { color: var(--t-punct); }

.palette__input {
  flex: 1;
  border: 0;
  background: transparent;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  letter-spacing: 0.06em;
}

.palette__input:focus-visible { outline: none; }
.palette__input::placeholder { color: var(--t-punct); }

.palette__list { list-style: none; margin: 0; padding: 0.3rem 0; overflow-y: auto; scrollbar-width: thin; }

.palette__item {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas: "label group shortcut" "hint hint hint";
  gap: 0 0.8rem;
  padding: 0.5rem var(--pad);
  cursor: pointer;
  border-left: 2px solid transparent;
}

.palette__item.is-active { background: rgba(255, 255, 255, 0.045); border-left-color: var(--fg); }

.palette__label {
  grid-area: label;
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  color: var(--fg-dim);
}

.palette__item.is-active .palette__label { color: var(--fg); }
.palette__label em { font-style: normal; color: var(--fg); text-decoration: underline; text-underline-offset: 3px; }

.palette__group, .palette__shortcut {
  font-size: 0.6rem;
  letter-spacing: 0.14em;
  color: var(--t-punct);
}

.palette__group { grid-area: group; }
.palette__shortcut { grid-area: shortcut; }

.palette__hint {
  grid-area: hint;
  font-size: 0.62rem;
  letter-spacing: 0.06em;
  color: var(--t-punct);
  margin-top: 0.15rem;
}

.palette__empty { padding: var(--pad); margin: 0; color: var(--t-punct); font-size: 0.7rem; letter-spacing: 0.14em; }

/* ----------------------------------------------------------- overlays -- */

.sheet-overlay { position: fixed; inset: 0; z-index: 28; }
.sheet-overlay__scrim { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.72); }

.sheet-overlay__panel {
  position: relative;
  width: min(46rem, calc(100vw - 2rem));
  max-height: 78vh;
  margin: 9vh auto 0;
  border: 1px solid var(--fg-dim);
  background: var(--bg);
  display: flex;
  flex-direction: column;
  animation: rise-in 0.28s var(--ease) both;
}

.sheet-overlay__panel--narrow { width: min(34rem, calc(100vw - 2rem)); }

.sheet-overlay__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem var(--pad);
  border-bottom: var(--rule);
}

.sheet-overlay__head h2 {
  margin: 0;
  font-size: clamp(0.6rem, 0.85vw, 0.7rem);
  font-weight: 500;
  letter-spacing: 0.24em;
  color: var(--fg);
}

.sheet-overlay__body { padding: var(--pad); overflow-y: auto; scrollbar-width: thin; }

.keys { display: grid; grid-template-columns: repeat(auto-fit, minmax(15rem, 1fr)); gap: 0 2rem; }

.keys__group { margin-bottom: 1.2rem; }

.keys__title {
  margin: 0 0 0.5rem;
  font-size: 0.6rem;
  letter-spacing: 0.22em;
  color: var(--t-punct);
}

.keys__row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.28rem 0;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  color: var(--fg-body);
}

.keys__row kbd {
  font-family: var(--font-mono);
  font-size: 0.92em;
  letter-spacing: 0.1em;
  color: var(--fg-dim);
  white-space: nowrap;
}

.note { margin: 0 0 0.9rem; font-size: 0.7rem; line-height: 1.9; letter-spacing: 0.04em; color: var(--fg-body); }
.note--dim { color: var(--t-punct); font-size: 0.62rem; margin-top: 0.9rem; margin-bottom: 0; }
.note strong { color: var(--fg); font-weight: 500; }

.share__url {
  width: 100%;
  padding: 0.6em 0.7em;
  border: var(--rule);
  background: transparent;
  color: var(--fg-body);
  font-family: var(--font-mono);
  font-size: 0.68rem;
}

.share__url:focus-visible { outline: none; border-color: var(--fg); }
.share__actions { display: flex; gap: 0.4rem; margin-top: 0.7rem; }

/* -------------------------------------------------------------- toast -- */

.toast {
  position: fixed;
  bottom: 1.4rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  padding: 0.6em 1.1em;
  border: 1px solid var(--fg-dim);
  background: var(--bg);
  color: var(--fg);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
  animation: rise-in 0.3s var(--ease) both;
}

/* ---------------------------------------------------------- utilities -- */

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 50;
  padding: 0.6em 1em;
  background: var(--bg);
  border: 1px solid var(--fg);
  color: var(--fg);
  font-size: 0.66rem;
  letter-spacing: 0.18em;
}

.skip-link:focus { left: 0.5rem; top: 0.5rem; }

[hidden] { display: none !important; }

/* --------------------------------------------------------- responsive -- */

/*
 * Declared extension: a second breakpoint. Two editor panes cannot clamp into
 * one column, so below 60rem the workspace stacks and each pane keeps a usable
 * minimum height.
 */
@media (max-width: 60rem) {
  body { overflow: auto; }

  .workspace,
  .workspace[data-mode="diff"] {
    grid-template-columns: 1fr;
    grid-template-rows: none;
  }

  .pane { border-right: 0; border-bottom: var(--rule); min-height: 22rem; }
  .pane--diffout { grid-column: auto; }

  .bar { flex-wrap: wrap; }
  .privacy { order: 3; margin-left: 0; }
}

@media (max-width: 30rem) {
  .bar__actions { width: 100%; justify-content: space-between; }
  .pane__actions { gap: 0; }
  .btn { padding: 0.5em 0.6em; letter-spacing: 0.12em; }
}

/* ------------------------------------------------------ reduced motion -- */

@media (prefers-reduced-motion: reduce) {
  .grain { animation: none; }

  /* Hold the signal border; stop breathing. Still findable. */
  .btn--beacon {
    animation: none;
    border-color: var(--signal-soft);
  }

  .glow,
  .palette__panel,
  .sheet-overlay__panel,
  .toast {
    animation-duration: 0.01ms;
    animation-delay: 0s;
  }

  * { transition-duration: 0.01ms !important; }
}
