:root {
  color-scheme: light;
  --canvas: #e9e4da;
  --paper: #f8f4eb;
  --paper-deep: #f0eadf;
  --ink: #302d28;
  --muted: #756f65;
  --faint: #9a9387;
  --line: #d4ccbe;
  --line-dark: #bdb3a4;
  --rust: #8b5d3b;
  --rust-dark: #71482d;
  --olive: #667057;
  --red: #954f45;
  --input: #fffdf8;
  --header: rgba(248, 244, 235, 0.94);
  --canvas-wash: rgba(255, 255, 255, 0.14);
  --button-ink: #fffaf2;
  --focus: rgba(139, 93, 59, 0.45);
  --notice-border: #b99d60;
  --notice-bg: #fbf3dc;
  --error-border: #c08b82;
  --error-bg: #f9e9e5;
  --success-border: #a3ad91;
  --success-bg: #edf0e7;
  --shadow: 0 1px 2px rgba(50, 42, 33, 0.05), 0 8px 28px rgba(50, 42, 33, 0.04);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --canvas: #171816;
    --paper: #20211e;
    --paper-deep: #282923;
    --ink: #ece7db;
    --muted: #aaa397;
    --faint: #827c72;
    --line: #343630;
    --line-dark: #494a42;
    --rust: #bd8058;
    --rust-dark: #dda178;
    --olive: #a1ab86;
    --red: #db8478;
    --input: #191a18;
    --header: rgba(28, 29, 26, 0.94);
    --canvas-wash: rgba(255, 255, 255, 0.01);
    --button-ink: #fffaf2;
    --focus: rgba(221, 161, 120, 0.52);
    --notice-border: #66583b;
    --notice-bg: #29261c;
    --error-border: #744b46;
    --error-bg: #2e201e;
    --success-border: #566047;
    --success-bg: #22271d;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 8px 28px rgba(0, 0, 0, 0.14);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --canvas: #171816;
  --paper: #20211e;
  --paper-deep: #282923;
  --ink: #ece7db;
  --muted: #aaa397;
  --faint: #827c72;
  --line: #343630;
  --line-dark: #494a42;
  --rust: #bd8058;
  --rust-dark: #dda178;
  --olive: #a1ab86;
  --red: #db8478;
  --input: #191a18;
  --header: rgba(28, 29, 26, 0.94);
  --canvas-wash: rgba(255, 255, 255, 0.01);
  --button-ink: #fffaf2;
  --focus: rgba(221, 161, 120, 0.52);
  --notice-border: #66583b;
  --notice-bg: #29261c;
  --error-border: #744b46;
  --error-bg: #2e201e;
  --success-border: #566047;
  --success-bg: #22271d;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.22), 0 8px 28px rgba(0, 0, 0, 0.14);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(var(--canvas-wash), var(--canvas-wash)),
    var(--canvas);
  font-size: 15px;
}

a { color: inherit; }

.site-header {
  position: sticky;
  z-index: 10;
  top: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 2rem;
  min-height: 58px;
  padding: 0 2rem;
  border-bottom: 1px solid var(--line-dark);
  background: var(--header);
  backdrop-filter: blur(12px);
}

.wordmark {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 0.9rem;
  font-weight: 750;
  text-decoration: none;
}

.wordmark span { color: var(--rust); font-size: 1.1rem; }

nav { display: flex; align-items: stretch; gap: 0.25rem; height: 58px; }
.header-tools { display: flex; align-items: center; gap: 0.65rem; }
nav a, nav span {
  display: grid;
  place-items: center;
  padding: 0 0.7rem;
  color: var(--muted);
  border-bottom: 2px solid transparent;
  font-size: 0.82rem;
  text-decoration: none;
}
nav a:hover { color: var(--ink); }
nav a[aria-current="page"] { color: var(--rust-dark); border-color: var(--rust); }
nav span[aria-disabled="true"] { opacity: 0.48; }

main {
  width: min(1160px, calc(100% - 2.5rem));
  margin: 0 auto;
  padding: 2.4rem 0 5rem;
}

.workspace-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 3rem;
  margin-bottom: 1.5rem;
}
.workspace-heading h1, .page-heading h1, .etude-header h1 {
  margin: 0;
  font-family: Georgia, Cambria, serif;
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 500;
  letter-spacing: -0.035em;
  line-height: 1;
}
.workspace-heading > p { max-width: 540px; margin: 0; color: var(--muted); line-height: 1.55; }

.eyebrow {
  margin: 0 0 0.45rem;
  color: var(--rust);
  font: 750 0.68rem/1.2 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.lede { max-width: 720px; color: var(--muted); font-size: 1rem; line-height: 1.6; }
.muted { color: var(--muted); }

.workspace { display: grid; grid-template-columns: minmax(0, 1fr) 275px; gap: 1rem; align-items: start; }
.workspace-main, .workspace-sidebar { display: grid; gap: 1rem; }

.tool-card, .side-card, .card, .patch-sheet, .context-drawer, .provenance {
  border: 1px solid var(--line);
  border-radius: 0.65rem;
  background: var(--paper);
  box-shadow: var(--shadow);
}
.tool-card { padding: 1.25rem; }
.side-card { padding: 1.05rem; }

.card-heading, .side-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}
.card-heading > div { display: flex; align-items: center; gap: 0.65rem; }
.card-heading h2, .side-heading h2, .setting-row h2, .patch-sheet h2 {
  margin: 0;
  font-size: 1rem;
  letter-spacing: -0.01em;
}
.card-heading small { color: var(--faint); }
.step {
  display: grid;
  width: 1.5rem;
  height: 1.5rem;
  place-items: center;
  border-radius: 50%;
  color: var(--paper);
  background: var(--rust);
  font: 750 0.68rem ui-monospace, monospace;
}

.idea-card { display: grid; gap: 1rem; }
label {
  display: grid;
  gap: 0.4rem;
  color: var(--muted);
  font-size: 0.76rem;
  font-weight: 700;
  letter-spacing: 0.025em;
}
.label-note { color: var(--faint); font-weight: 500; }
input, select, textarea, button {
  width: 100%;
  border: 1px solid var(--line-dark);
  border-radius: 0.4rem;
  color: var(--ink);
  background: var(--input);
  font: inherit;
}
input, select, textarea { padding: 0.67rem 0.72rem; }
textarea { resize: vertical; line-height: 1.55; }
input::placeholder { color: var(--faint); }

.field-row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; }
.field-row.two { grid-template-columns: repeat(2, 1fr); }

button {
  width: auto;
  padding: 0.68rem 0.85rem;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 750;
}
.primary-action { width: 100%; margin-top: 1rem; color: var(--button-ink); border-color: var(--rust-dark); background: var(--rust); }
.primary-action:hover { background: var(--rust-dark); }
.primary-action:disabled { cursor: not-allowed; opacity: 0.5; }
.quiet-button { color: var(--ink); background: var(--paper-deep); }
.button-link { display: inline-block; padding: 0.58rem 0.75rem; border: 1px solid var(--line-dark); border-radius: 0.4rem; font-size: 0.78rem; font-weight: 750; text-decoration: none; }
.text-link { color: var(--rust-dark); font-size: 0.78rem; }
.fine-print, .empty-note { margin: 0.7rem 0 0; color: var(--faint); font-size: 0.72rem; line-height: 1.5; }

.connection { display: flex; align-items: center; gap: 0.45rem; margin: 0.85rem 0 0; color: var(--muted); font-size: 0.76rem; }
.connection span { width: 0.5rem; height: 0.5rem; border-radius: 50%; background: var(--faint); }
.connection.good { color: var(--olive); }
.connection.good span { background: var(--olive); box-shadow: 0 0 0 3px rgba(102, 112, 87, 0.12); }

.recent-card { padding-bottom: 0.55rem; }
.side-heading { margin-bottom: 0.35rem; }
.side-heading a { color: var(--rust); font-size: 0.72rem; }
.recent-item { display: grid; gap: 0.15rem; padding: 0.65rem 0; border-top: 1px solid var(--line); text-decoration: none; }
.recent-item span { font-size: 0.82rem; font-weight: 700; }
.recent-item small { color: var(--faint); font-size: 0.7rem; }

.context-drawer { padding: 0.9rem 1rem; }
.context-drawer summary { cursor: pointer; color: var(--rust-dark); font-size: 0.82rem; font-weight: 700; }
.context-drawer > p { color: var(--muted); font-size: 0.78rem; }
.preview-frame { width: 100%; min-height: 42rem; margin-top: 0.75rem; border: 0; }
.fragment-body { margin: 0; padding: 0; background: transparent; }
.candidate-preview { padding: 0.3rem; }
.candidate-preview article { padding: 0.8rem 0; border-top: 1px solid var(--line); }
.candidate-preview article:first-of-type { border-top: 0; }
.candidate-preview code { display: block; margin-top: 0.2rem; color: var(--faint); font-size: 0.7rem; }
.candidate-preview p { margin-bottom: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }
.request-inspector { padding: 0.3rem; }
.inspector-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 0.5rem; }
.inspector-heading h1 { margin: 0; font-family: Georgia, Cambria, serif; font-size: 1.65rem; font-weight: 500; }
.inspector-heading > span { color: var(--faint); font: 700 0.68rem ui-monospace, monospace; }
.inspector-note { margin: 0 0 0.8rem; padding: 0.65rem 0.75rem; border-left: 3px solid var(--olive); color: var(--muted); background: var(--paper-deep); font-size: 0.75rem; line-height: 1.5; }
.inspector-drawer { border: 1px solid var(--line); border-bottom: 0; background: var(--paper); }
.inspector-drawer:first-of-type { border-radius: 0.5rem 0.5rem 0 0; }
.inspector-drawer:last-child { border-bottom: 1px solid var(--line); border-radius: 0 0 0.5rem 0.5rem; }
.inspector-drawer > summary { display: flex; align-items: center; justify-content: space-between; gap: 1rem; padding: 0.8rem; cursor: pointer; list-style-position: inside; color: var(--ink); font-size: 0.82rem; font-weight: 750; }
.inspector-drawer > summary small { color: var(--faint); font-size: 0.65rem; font-weight: 600; }
.inspector-drawer[open] > summary { border-bottom: 1px solid var(--line); background: var(--paper-deep); }
.inspector-content { padding: 0.9rem; color: var(--muted); font-size: 0.78rem; line-height: 1.55; }
.inspector-content > :first-child { margin-top: 0; }
.inspector-content > :last-child { margin-bottom: 0; }
.inspector-content h2 { margin: 1rem 0 0.35rem; color: var(--ink); font-size: 0.82rem; }
.inspector-content ul { margin: 0.35rem 0; padding-left: 1.15rem; }
.inspector-content li { margin: 0.25rem 0; }
.preserve-lines { white-space: pre-line; }
.inspector-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.inspector-facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(115px, 1fr)); margin: 0.8rem 0 0; border: 1px solid var(--line); }
.inspector-facts div { padding: 0.6rem; border-right: 1px solid var(--line); }
.inspector-facts div:last-child { border-right: 0; }
.nested-drawer, .raw-drawer { margin-top: 0.55rem; border: 1px solid var(--line); border-radius: 0.4rem; background: var(--paper-deep); }
.nested-drawer > summary, .raw-drawer > summary { padding: 0.65rem; cursor: pointer; color: var(--ink); font-size: 0.76rem; font-weight: 700; }
.nested-drawer > summary code { float: right; color: var(--faint); font-size: 0.65rem; font-weight: 500; }
.nested-drawer > div { padding: 0 0.7rem 0.7rem; }
.raw-drawer { background: var(--input); }
.raw-inspector pre, .raw-drawer pre { max-height: 32rem; overflow: auto; margin: 0; padding: 0.75rem; border: 1px solid var(--line); border-radius: 0.35rem; color: var(--ink); background: var(--input); font: 0.67rem/1.5 ui-monospace, SFMono-Regular, Menlo, monospace; white-space: pre-wrap; overflow-wrap: anywhere; }
.raw-drawer pre { max-height: 24rem; border: 0; border-top: 1px solid var(--line); border-radius: 0; }

.page-heading { margin-bottom: 1.5rem; }
.etudes-page-heading { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.etudes-page-heading h1 { margin-bottom: 0; }
.catalog-controls { display: flex; align-items: center; justify-content: flex-end; gap: 0.5rem; flex-wrap: wrap; }
.catalog-search input { width: min(15rem, 56vw); padding: 0.42rem 0.6rem; border: 1px solid var(--line); border-radius: 0.35rem; color: var(--ink); background: var(--input); font: inherit; font-size: 0.72rem; }
.catalog-search input::placeholder { color: var(--faint); }
.catalog-search input:focus-visible { outline: 2px solid var(--rust); outline-offset: 1px; }
.failed-toggle { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0.5rem; border: 1px solid var(--line); border-radius: 0.35rem; color: var(--muted); background: var(--paper); cursor: pointer; font-size: 0.7rem; }
.failed-toggle:hover { color: var(--ink); border-color: var(--line-dark); }
.failed-toggle input { width: 0.85rem; height: 0.85rem; margin: 0; accent-color: var(--rust); }
.failed-toggle small { color: var(--faint); font-size: 0.62rem; }
.catalog-result-count { min-width: 4.5rem; color: var(--faint); font-size: 0.62rem; text-align: right; }
.visually-hidden { position: absolute !important; width: 1px !important; height: 1px !important; padding: 0 !important; overflow: hidden !important; clip: rect(0, 0, 0, 0) !important; white-space: nowrap !important; border: 0 !important; }
.cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0.8rem; }
/* Etudes library: fixed 3-column rhythm so 1-2 cards keep the same width they
   have in a full row (auto-fit would stretch them across the whole grid). */
.cards[data-etude-catalog] { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.card { display: block; padding: 1rem; color: var(--muted); text-decoration: none; }
.card h2 { margin: 0.45rem 0 0; color: color-mix(in srgb, var(--ink) 76%, var(--muted)); font-size: 0.91rem; font-weight: 700; line-height: 1.25; }
.card p { line-height: 1.5; }
.etude-card { position: relative; display: flex; min-height: 350px; flex-direction: column; border: 1px solid transparent; transition: border-color 120ms ease, box-shadow 120ms ease; }
.etude-card[hidden] { display: none; }
.etude-card.starred { border-color: var(--line); }
.etude-card:hover { border-color: color-mix(in srgb, var(--rust) 38%, var(--line)); box-shadow: 0 3px 12px rgb(0 0 0 / 10%); }
.etude-card:hover h2 { color: var(--ink); }
.etude-card-link { display: flex; min-width: 0; flex: 1; flex-direction: column; color: inherit; text-decoration: none; }
.etude-card-link:focus-visible { outline: 2px solid var(--rust); outline-offset: 0.45rem; border-radius: 0.2rem; }
.etude-card-identity { display: grid; min-width: 0; min-height: 3.65rem; grid-template-columns: 44px minmax(0, 1fr); gap: 0.7rem; margin-bottom: 0.65rem; }
.etude-card-heading-copy { min-width: 0; }
.etude-card-topline { display: flex; align-items: center; justify-content: space-between; gap: 1rem; }
.etude-card-star { position: absolute; z-index: 3; top: 1rem; right: 1rem; margin: 0; }
.etude-card h2 { display: -webkit-box; height: 2.3em; overflow: hidden; -webkit-box-orient: vertical; -webkit-line-clamp: 2; }
.folio-mark { --folio-base: #65425c; --folio-mid: #a86f90; --folio-paper: #eadde3; --folio-dark: #2c2029; position: relative; width: 44px; height: 58px; overflow: hidden; border: 1px solid color-mix(in srgb, var(--folio-paper) 22%, var(--folio-dark)); border-radius: 0.24rem; background: var(--folio-base); box-shadow: inset 0 0 0 1px rgb(255 255 255 / 5%), 0 1px 3px rgb(0 0 0 / 18%); }
.folio-mark::before { position: absolute; inset: 0 0 52% 44%; background: var(--folio-mid); content: ""; opacity: 0.34; }
.folio-mark::after { position: absolute; z-index: 3; top: var(--folio-dot-y); left: var(--folio-dot-x); width: 3px; height: 3px; border: 1px solid color-mix(in srgb, var(--folio-paper) 72%, transparent); border-radius: 50%; content: ""; opacity: 0.58; }
.variant-northwest { --folio-dot-x: 4px; --folio-dot-y: 4px; }
.variant-northeast { --folio-dot-x: 35px; --folio-dot-y: 4px; }
.variant-southeast { --folio-dot-x: 35px; --folio-dot-y: 49px; }
.variant-southwest { --folio-dot-x: 4px; --folio-dot-y: 49px; }
.folio-shape, .folio-texture { position: absolute; display: block; }
.folio-shape { z-index: 1; }
.folio-texture { z-index: 2; inset: 0; pointer-events: none; opacity: 0.32; }
.palette-fuchsia { --folio-base: #713c5e; --folio-mid: #bc739b; --folio-paper: #ead8e1; --folio-dark: #2f202b; }
.palette-cobalt { --folio-base: #35576f; --folio-mid: #6e95ad; --folio-paper: #d9e3e8; --folio-dark: #1f2b33; }
.palette-moss { --folio-base: #506044; --folio-mid: #91a576; --folio-paper: #e2e5d5; --folio-dark: #252b21; }
.palette-rust { --folio-base: #7b4937; --folio-mid: #bf7d59; --folio-paper: #eaded3; --folio-dark: #33241e; }
.palette-ochre { --folio-base: #76612f; --folio-mid: #b69b55; --folio-paper: #e9e2cd; --folio-dark: #302b1c; }
.palette-violet { --folio-base: #55496f; --folio-mid: #8b7cad; --folio-paper: #e0ddec; --folio-dark: #282432; }
.palette-teal { --folio-base: #315e5d; --folio-mid: #6e9f98; --folio-paper: #d8e6e2; --folio-dark: #1e2d2d; }
.motif-orbit .folio-shape-a { top: 9px; left: 7px; width: 27px; height: 27px; border: 1.5px solid var(--folio-paper); border-radius: 50%; opacity: 0.8; }
.motif-orbit .folio-shape-b { right: 6px; bottom: 7px; width: 9px; height: 9px; border-radius: 50%; background: var(--folio-mid); box-shadow: -20px 5px 0 -3px var(--folio-paper); }
.motif-horizon .folio-shape-a { right: 0; bottom: 11px; left: 0; height: 13px; border-top: 1px solid var(--folio-paper); background: color-mix(in srgb, var(--folio-dark) 42%, transparent); }
.motif-horizon .folio-shape-b { top: 11px; left: 9px; width: 14px; height: 14px; border-radius: 50%; background: var(--folio-paper); opacity: 0.72; }
.motif-arches .folio-shape-a, .motif-arches .folio-shape-b { bottom: 6px; border: 1.5px solid var(--folio-paper); border-bottom: 0; border-radius: 50% 50% 0 0; }
.motif-arches .folio-shape-a { left: 3px; width: 34px; height: 35px; opacity: 0.72; }
.motif-arches .folio-shape-b { left: 12px; width: 25px; height: 25px; border-color: var(--folio-mid); }
.motif-blocks .folio-shape-a { top: 9px; left: 7px; width: 16px; height: 16px; background: var(--folio-paper); opacity: 0.68; transform: rotate(-7deg); }
.motif-blocks .folio-shape-b { right: 6px; bottom: 8px; width: 14px; height: 14px; border: 1px solid var(--folio-paper); opacity: 0.78; }
.motif-diagonal .folio-shape-a { top: 21px; left: -7px; width: 57px; height: 9px; background: var(--folio-paper); opacity: 0.7; transform: rotate(-28deg); }
.motif-diagonal .folio-shape-b { right: 7px; bottom: 8px; width: 8px; height: 8px; border: 1px solid var(--folio-paper); border-radius: 50%; }
.folio-wave-art { display: none; position: absolute; z-index: 1; inset: 0; width: 100%; height: 100%; }
.motif-wave .folio-wave-art { display: block; }
.motif-wave .folio-wave-art path { fill: none; stroke: var(--folio-paper); stroke-width: 1.5; stroke-linecap: round; stroke-linejoin: round; opacity: 0.8; vector-effect: non-scaling-stroke; }
.motif-wave .folio-wave-art circle { fill: var(--folio-paper); opacity: 0.72; }
.motif-wave .folio-shape-a, .motif-wave .folio-shape-b { display: none; }
.texture-scratches .folio-texture { background: repeating-linear-gradient(108deg, transparent 0 6px, rgb(255 255 255 / 20%) 6px 7px, transparent 7px 11px); }
.texture-grid .folio-texture { background-image: linear-gradient(rgb(255 255 255 / 19%) 1px, transparent 1px), linear-gradient(90deg, rgb(255 255 255 / 19%) 1px, transparent 1px); background-size: 7px 7px; }
.texture-paper .folio-texture { background-image: radial-gradient(circle at 22% 17%, rgb(255 255 255 / 33%) 0 0.7px, transparent 1px), radial-gradient(circle at 76% 68%, rgb(0 0 0 / 28%) 0 0.6px, transparent 1px), radial-gradient(circle at 48% 42%, rgb(255 255 255 / 22%) 0 0.55px, transparent 0.9px); background-size: 7px 9px, 9px 8px, 5px 6px; }
.texture-linen .folio-texture { background-image: repeating-linear-gradient(0deg, transparent 0 3px, rgb(255 255 255 / 14%) 3px 4px), repeating-linear-gradient(90deg, transparent 0 5px, rgb(0 0 0 / 13%) 5px 6px); }
.texture-speckle .folio-texture { background-image: radial-gradient(circle, rgb(255 255 255 / 32%) 0 0.7px, transparent 0.9px), radial-gradient(circle, rgb(0 0 0 / 24%) 0 0.6px, transparent 0.85px); background-position: 0 0, 4px 5px; background-size: 8px 9px, 9px 8px; }
.star-button { padding: 0.15rem 0.3rem; border: 0; color: var(--faint); background: transparent; font-size: 1.08rem; font-weight: 400; line-height: 1; opacity: 0.42; }
.star-button:hover { color: var(--muted); opacity: 0.8; }
.star-button.active { color: var(--olive); opacity: 0.82; }
.star-detail.active { border-color: var(--line-dark); color: var(--olive); background: var(--paper-deep); }
.etude-card-facts { display: flex; height: 3.35rem; align-content: flex-start; flex-wrap: wrap; gap: 0.3rem; overflow: hidden; }
.etude-card-facts span { max-width: 100%; height: 1.4rem; padding: 0.25rem 0.4rem; overflow: hidden; border-radius: 0.3rem; color: var(--ink); background: var(--paper-deep); font-size: 0.7rem; line-height: 0.9rem; text-overflow: ellipsis; white-space: nowrap; }
.etude-card-preview { margin-top: auto; padding-top: 0.75rem; }
.etude-summary { position: relative; z-index: 2; display: -webkit-box; height: 3.18rem; overflow: hidden; margin: 0; color: var(--muted); font-size: 0.72rem; line-height: 1.48; -webkit-box-orient: vertical; -webkit-line-clamp: 3; }
.etude-summary.empty { visibility: hidden; }
.etude-card-tools { display: grid; position: relative; z-index: 2; height: 5.1rem; align-content: start; grid-template-columns: minmax(0, 1fr); grid-template-rows: repeat(3, 1.5rem); gap: 0.3rem; margin-top: 0.55rem; }
.tool-patch-pill { display: grid; min-width: 0; grid-template-columns: 94px minmax(0, 1fr); overflow: hidden; border: 1px solid var(--line); border-radius: 0.4rem; background: var(--paper); font-size: 0.62rem; line-height: 1.2; }
.tool-instrument, .tool-patch-name { min-width: 0; padding: 0.3rem 0.4rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-instrument { --tool-accent: var(--faint); border-right: 1px solid color-mix(in srgb, var(--tool-accent) 32%, var(--line)); color: color-mix(in srgb, var(--tool-accent) 72%, var(--ink)); background: color-mix(in srgb, var(--tool-accent) 14%, transparent); font-weight: 750; }
.tool-instrument.tone-green { --tool-accent: #73a66d; }
.tool-instrument.tone-orange { --tool-accent: #c98552; }
.tool-instrument.tone-blue { --tool-accent: #6498c8; }
.tool-instrument.tone-yellow { --tool-accent: #c4ad4f; }
.tool-instrument.tone-purple { --tool-accent: #916bc4; }
.tool-patch-name { color: var(--muted); }
.tool-patch-more { position: absolute; right: -0.25rem; bottom: -0.25rem; padding: 0.12rem 0.24rem; border-radius: 999px; color: var(--faint); background: var(--paper-deep); font-size: 0.58rem; }
.etude-card-footer { padding-top: 0.8rem; }
.etude-provider { display: flex; min-height: 2.8em; align-items: flex-end; margin: 0 0 0.35rem; color: color-mix(in srgb, var(--muted) 72%, var(--faint)); font-size: 0.76rem; opacity: 0.82; overflow-wrap: anywhere; }
.etude-secondary-meta { position: relative; z-index: 2; color: var(--faint); font-size: 0.64rem; opacity: 0.58; transition: opacity 120ms ease; }
.etude-secondary-meta:hover { opacity: 0.95; }
.status { color: var(--olive); font: 750 0.66rem ui-monospace, monospace; text-transform: uppercase; }
.status.failed, .status.invalid { color: var(--red); }
.attempt-status-card { display: grid; gap: 1rem; }
.attempt-status-card p { max-width: 760px; margin: 0; color: var(--muted); line-height: 1.55; }
.attempt-status-heading { display: flex; align-items: start; justify-content: space-between; gap: 1rem; }
.attempt-status-heading h2 { margin: 0.35rem 0 0; font-size: 1.15rem; }
.activity-dot {
  width: 0.7rem;
  height: 0.7rem;
  flex: 0 0 auto;
  margin: 0.3rem;
  border-radius: 50%;
  background: var(--faint);
}
.activity-dot.active {
  background: var(--olive);
  box-shadow: 0 0 0 0 color-mix(in srgb, var(--olive) 45%, transparent);
  animation: activity-pulse 1.8s ease-out infinite;
}
.attempt-status-facts { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); margin: 0; border: 1px solid var(--line); border-radius: 0.5rem; }
.attempt-status-facts div { min-width: 0; padding: 0.75rem; border-right: 1px solid var(--line); }
.attempt-status-facts div:last-child { border-right: 0; }
.attempt-status-facts dt { color: var(--faint); font: 700 0.61rem ui-monospace, monospace; letter-spacing: 0.06em; text-transform: uppercase; }
.attempt-status-facts dd { margin: 0.25rem 0 0; overflow: hidden; font-size: 0.78rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.attempt-progress { height: 0.28rem; overflow: hidden; border-radius: 999px; background: var(--paper-deep); }
.attempt-progress span { display: block; width: 32%; height: 100%; border-radius: inherit; background: var(--rust); animation: attempt-progress 1.7s ease-in-out infinite; }
.attempt-status-actions { display: flex; align-items: center; gap: 1rem; }

@keyframes activity-pulse {
  70% { box-shadow: 0 0 0 0.45rem transparent; }
  100% { box-shadow: 0 0 0 0 transparent; }
}

@keyframes attempt-progress {
  from { transform: translateX(-110%); }
  to { transform: translateX(315%); }
}
.candidate-meta { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.68rem; }
.candidate-meta span { color: var(--rust); text-transform: uppercase; }
.candidate-meta code { color: var(--faint); }

.theme-toggle { display: flex; align-items: center; gap: 0.35rem; padding: 0.4rem 0.55rem; color: var(--muted); background: var(--paper-deep); white-space: nowrap; }
.theme-toggle span:last-child { font-size: 0.7rem; }

.guidance-workspace { display: grid; grid-template-columns: minmax(0, 1fr) 290px; gap: 1rem; align-items: start; }
.guidance-sidebar { position: sticky; top: 74px; }
.draft-panel h2 { margin: 0 0 0.55rem; font-size: 1rem; }
.draft-panel form, .candidate-editor { display: grid; gap: 0.9rem; }
.candidate-family { margin-top: 1.4rem; }
.candidate-family > h2 { margin: 0 0 0.45rem; color: var(--rust); font: 750 0.68rem ui-monospace, monospace; letter-spacing: 0.08em; text-transform: uppercase; }
.candidate-list { border-top: 1px solid var(--line); }
.candidate-row { display: grid; grid-template-columns: minmax(0, 1fr) 135px; gap: 1.2rem; padding: 1rem 0; border-bottom: 1px solid var(--line); }
.candidate-row.disabled { opacity: 0.58; }
.candidate-copy h3 { margin: 0.4rem 0; font-size: 0.95rem; }
.candidate-copy p { margin: 0 0 0.45rem; color: var(--muted); line-height: 1.55; }
.candidate-copy small { color: var(--faint); }
.candidate-actions { display: grid; align-content: start; gap: 0.55rem; }
.candidate-actions form { margin: 0; }
.candidate-actions button { width: 100%; }
.version-history summary { cursor: pointer; color: var(--faint); font-size: 0.72rem; }
.version-history small { display: block; margin-top: 0.3rem; color: var(--faint); }
.draft-results { margin-top: 2.8rem; }
.draft-results .page-heading h2 { margin: 0; font-family: Georgia, Cambria, serif; font-size: 2rem; font-weight: 500; }
.draft-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(390px, 1fr)); gap: 1rem; }
.candidate-editor { max-width: 860px; margin: 0 auto; padding: 1.25rem; }
.candidate-editor.compact { max-width: none; margin: 0; }
.draft-rationale { margin: 0; padding: 0.65rem 0.75rem; border-left: 3px solid var(--olive); color: var(--muted); background: var(--paper-deep); font-size: 0.8rem; line-height: 1.5; }
.draft-save-status { min-height: 1.2em; margin: 0; color: var(--olive); font-size: 0.78rem; line-height: 1.5; }
.draft-save-status:empty { display: none; }
.draft-save-status.error-text { color: var(--red); }
.saved-draft { border-color: var(--success-border); }
.saved-draft input, .saved-draft select, .saved-draft textarea { opacity: 0.68; }
.check-row { display: flex; flex-wrap: wrap; gap: 1.2rem; }
.check-row label { display: flex; align-items: center; gap: 0.45rem; }
.check-row input { width: auto; }
.form-actions { display: flex; align-items: center; gap: 1rem; }
.form-actions .primary-action { width: auto; margin: 0; }

/* Sign-in */
.auth-panel { max-width: 460px; margin: 3.5rem auto 0; }
.auth-panel .workspace-heading { display: block; margin-bottom: 1.25rem; }
.auth-panel .workspace-heading > p { margin-top: 0.6rem; max-width: none; }
.auth-panel h1 { font-size: 1.65rem; letter-spacing: -0.02em; }
.auth-panel .workspace-heading > p { font-size: 0.9rem; }
.auth-form label { display: grid; gap: 0.45rem; color: var(--muted); font-size: 0.85rem; }
.auth-form input { width: 100%; font-size: 1rem; }
.auth-form .primary-action { width: 100%; margin-top: 1rem; }
.auth-error { margin: 0 0 1rem; padding: 0.6rem 0.75rem; border-left: 3px solid var(--red); color: var(--red); background: var(--paper-deep); font-size: 0.85rem; }
.auth-hint { color: var(--muted); font-size: 0.85rem; }
.signout-form { display: flex; align-items: center; gap: 0.55rem; margin: 0; }
.user-email { max-width: 200px; overflow: hidden; color: var(--muted); font-size: 0.75rem; text-overflow: ellipsis; white-space: nowrap; }
.signout-button { padding: 0.3rem 0.6rem; font-size: 0.75rem; }

.etude-header { display: grid; grid-template-columns: minmax(0, 1fr) 350px; gap: 2rem; align-items: start; }
.facts { display: grid; grid-template-columns: 1fr 1fr; margin: 0; border: 1px solid var(--line); border-radius: 0.55rem; background: var(--paper); }
.facts div { padding: 0.8rem; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line); }
.facts div:nth-child(even) { border-right: 0; }
.facts div:nth-last-child(-n + 2) { border-bottom: 0; }
dt { color: var(--faint); font-size: 0.65rem; text-transform: uppercase; }
dd { margin: 0.25rem 0 0; font-size: 0.85rem; font-weight: 700; }

.validation, .notice { margin: 1rem 0; padding: 0.8rem 1rem; border: 1px solid var(--notice-border); border-radius: 0.5rem; background: var(--notice-bg); }
.validation.invalid, .notice.error { border-color: var(--error-border); background: var(--error-bg); }
.notice.success { border-color: var(--success-border); background: var(--success-bg); }
.validation h2 { font-size: 0.9rem; }
.validation p, .notice { font-size: 0.8rem; }
.etude-section { margin-top: 2.8rem; }
.listen { color: var(--olive); }

.patch-sheet { padding: 1.25rem; }
.patch-sheet ol { line-height: 1.7; }
.parameter-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(125px, 1fr)); margin: 1.3rem 0; }
.parameter-grid div { padding: 0.65rem; border: 1px solid var(--line); margin: -1px 0 0 -1px; }

.arrangement-strip { display: flex; gap: 0.4rem; overflow-x: auto; }
.arrangement-strip article { flex: var(--bars) 0 175px; display: grid; gap: 0.4rem; padding: 0.8rem; border: 1px solid var(--line); border-radius: 0.45rem; background: var(--paper); }
.arrangement-strip span, .arrangement-strip small { color: var(--muted); }

.chart-table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: 0.55rem; background: var(--paper); }
table { width: 100%; border-collapse: collapse; min-width: 820px; }
th, td { padding: 0.75rem; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { color: var(--faint); font-size: 0.65rem; text-transform: uppercase; }
tr:last-child td { border-bottom: 0; }
.chord { color: var(--rust-dark); font-size: 1rem; font-weight: 800; }
.notes { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; white-space: nowrap; }
.provenance { margin-top: 2.8rem; padding: 1rem; }
.provenance summary { cursor: pointer; font-size: 0.82rem; font-weight: 750; }
.provenance h2 { margin-top: 1.5rem; font-size: 0.9rem; }
.reference-image { display: block; max-width: 22rem; max-height: 22rem; margin-top: 0.8rem; border-radius: 0.5rem; }
.etude-actions { display: flex; justify-content: flex-start; align-items: center; flex-wrap: wrap; gap: 0.55rem; margin-top: 1rem; }
.etude-actions form { margin: 0; }
.button-link.accent { border-color: var(--rust-dark); background: var(--rust); color: var(--button-ink); }
.button-link.accent:hover { background: var(--rust-dark); }
.copy-suno-button { display: inline-flex; align-items: center; gap: 0.42rem; }
.copy-suno-button svg { width: 0.9rem; height: 0.9rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.35; }
.copy-suno-button.copied { color: var(--olive); border-color: var(--success-border); background: var(--success-bg); }
.transfer-panel, .revision-panel, .lineage-panel { margin: 1rem 0; padding: 1rem; border: 1px solid var(--line); border-radius: 0.55rem; background: var(--paper); }
.transfer-panel { display: flex; align-items: center; flex-wrap: wrap; gap: 0.8rem 1rem; }
.transfer-panel > div:first-child { flex: 1 1 360px; }
.transfer-panel p { margin: 0.25rem 0; color: var(--muted); }
.transfer-panel details { flex: 0 1 auto; }
.compose-drafts { margin: 1.4rem 0 1.8rem; }
.compose-drafts .section-heading p { max-width: 440px; margin: 0; color: var(--muted); font-size: 0.78rem; line-height: 1.5; }
.draft-shelf-actions { display: flex; align-items: center; justify-content: flex-end; flex-wrap: wrap; gap: 0.65rem; }
.draft-clear { position: relative; color: var(--faint); font-size: 0.7rem; }
.draft-clear summary { cursor: pointer; }
.draft-clear form { position: absolute; z-index: 3; right: 0; min-width: 145px; margin-top: 0.35rem; padding: 0.5rem; border: 1px solid var(--line); border-radius: 0.4rem; background: var(--paper); box-shadow: var(--shadow); }
.draft-shelf { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 0.65rem; }
.draft-card { position: relative; min-height: 105px; border: 1px solid var(--line); border-radius: 0.5rem; color: var(--ink); background: var(--paper); }
.draft-card:hover, .draft-card.selected { border-color: var(--rust); background: var(--paper-deep); }
.draft-card-main { display: grid; gap: 0.45rem; min-height: 103px; padding: 0.85rem 3.8rem 0.85rem 0.85rem; color: inherit; text-decoration: none; }
.draft-card-main span, .draft-card-main small { color: var(--faint); font-size: 0.7rem; }
.draft-card-main small { align-self: end; color: var(--rust-dark); font-weight: 700; }
.draft-delete-form { position: absolute; z-index: 2; top: 0.55rem; right: 0.55rem; margin: 0; }
.draft-delete-button { padding: 0.22rem 0.34rem; border: 0; color: var(--faint); background: transparent; font-size: 0.64rem; }
.draft-delete-button:hover { color: var(--red); background: transparent; }
.draft-delete-button.danger { width: 100%; color: var(--red); }
.import-form { display: grid; min-width: min(680px, 75vw); grid-template-columns: 1fr 1fr; gap: 0.7rem; padding-top: 0.8rem; }
.import-form .quiet-button { align-self: end; }
.draft-links { display: grid; gap: 0.4rem; min-width: 240px; padding-top: 0.7rem; }
.revision-panel form { display: grid; gap: 0.8rem; padding-top: 0.8rem; }
.revision-panel .primary-action { width: fit-content; }
.lineage-panel blockquote { margin-left: 0; padding-left: 1rem; border-left: 3px solid var(--rust); color: var(--muted); }

.settings-list { display: grid; gap: 0.8rem; }
.setting-row { display: grid; grid-template-columns: 1fr auto; gap: 2rem; align-items: center; }
.setting-status { min-width: 170px; }
.setting-status .connection { margin: 0 0 0.65rem; }
.setup-note pre { overflow-x: auto; padding: 0.85rem; border: 1px solid var(--line); border-radius: 0.4rem; background: var(--paper-deep); }

.context-section { margin-top: 2.4rem; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 1rem; margin-bottom: 0.8rem; }
.section-heading h2 { margin: 0; font-family: Georgia, Cambria, serif; font-size: 1.55rem; font-weight: 500; }
.admin-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0.8rem; }
.admin-card { display: grid; align-content: start; gap: 0.7rem; }
.admin-card.disabled { opacity: 0.6; }
.admin-card h3 { margin: 0; font-size: 1rem; }
.admin-card p { margin: 0; color: var(--muted); line-height: 1.5; }
.admin-card small { color: var(--faint); line-height: 1.45; }
.profile-summary { display: flex; align-items: center; justify-content: space-between; gap: 2rem; }
.profile-summary > div { display: grid; gap: 0.3rem; }
.profile-summary > div span { color: var(--muted); font-size: 0.78rem; }
.profile-summary dl { display: flex; margin: 0; }
.profile-summary dl div { min-width: 145px; padding-left: 1rem; border-left: 1px solid var(--line); }
.admin-editor { display: grid; max-width: 900px; margin: 0 auto; gap: 1rem; }
.admin-editor.wide { max-width: 1050px; }
.admin-editor input[readonly] { color: var(--muted); background: var(--paper-deep); }
.instrument-picker { display: grid; gap: 0.55rem; margin: 0; padding: 1rem; border: 1px solid var(--line); border-radius: 0.45rem; }
.instrument-picker legend { padding: 0 0.35rem; color: var(--muted); font-size: 0.76rem; font-weight: 750; }
.instrument-picker label { display: flex; align-items: center; gap: 0.6rem; }
.instrument-picker input { width: auto; }
.instrument-picker span { display: grid; gap: 0.15rem; color: var(--ink); }
.instrument-picker small { color: var(--faint); font-weight: 500; }
.form-help { margin: 0; padding: 0.75rem; border-left: 3px solid var(--olive); color: var(--muted); background: var(--paper-deep); font-size: 0.8rem; line-height: 1.5; }
.code-input { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.78rem; tab-size: 2; }

.practice-sheet-page { background: #e7e5df; color: #171717; }
.print-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 1rem; width: min(1100px, calc(100% - 2rem)); margin: 1rem auto; }
.print-toolbar .primary-action { width: auto; margin: 0; }
.print-toolbar > p { margin: 0; color: #555; font-size: 0.78rem; }
.practice-packet { display: grid; width: min(1100px, calc(100% - 2rem)); margin: 0 auto 2rem; gap: 1.5rem; }
.practice-sheet { min-width: 0; padding: 2.2rem; color: #171717; background: #fff; box-shadow: 0 2px 20px rgba(0, 0, 0, 0.12); }
.practice-sheet h1 { margin: 0; font-family: Georgia, Cambria, serif; font-size: 2.2rem; font-weight: 500; }
.practice-sheet section { margin-top: 1.8rem; break-inside: avoid; }
.practice-header { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 2rem; padding-bottom: 1rem; border-bottom: 2px solid #222; }
.practice-header p { max-width: 680px; line-height: 1.45; }
.practice-header dl { display: grid; grid-template-columns: 1fr 1fr; margin: 0; border: 1px solid #aaa; }
.practice-header dl div { padding: 0.6rem; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa; }
.practice-header dl div:nth-child(even) { border-right: 0; }
.practice-header dl div:nth-last-child(-n + 2) { border-bottom: 0; }
.practice-sheet table { min-width: 0; color: #171717; font-size: 0.78rem; }
.practice-sheet th, .practice-sheet td { padding: 0.5rem; border-color: #aaa; }
.practice-sheet th { color: #444; }
.practice-sheet .chord { color: #171717; }
.print-voicing-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border-top: 1px solid #aaa; border-left: 1px solid #aaa; }
.print-voicing-grid article { min-width: 0; padding: 0.45rem; border-right: 1px solid #aaa; border-bottom: 1px solid #aaa; }
.print-voicing-grid article > div { display: flex; align-items: baseline; justify-content: space-between; gap: 0.4rem; }
.print-voicing-grid article span { color: #555; font-size: 0.66rem; }
.print-voicing-grid article p { margin: 0.3rem 0 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.72rem; line-height: 1.35; }
.print-voicing-grid article b { color: #555; font-size: 0.6rem; }
.print-voicing-grid article small { display: block; margin-top: 0.25rem; color: #555; line-height: 1.35; }
.print-practice { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem 2rem; padding-left: 1.25rem; }
.print-practice li { padding-left: 0.25rem; break-inside: avoid; }
.print-practice p { margin: 0.25rem 0; line-height: 1.45; }
.print-practice small { color: #444; }
.practice-sheet footer { margin-top: 1.5rem; padding-top: 0.6rem; border-top: 1px solid #aaa; color: #555; font-size: 0.65rem; }
.print-performance-header { display: flex; align-items: end; justify-content: space-between; gap: 1rem; padding-bottom: 0.7rem; border-bottom: 2px solid #222; }
.print-performance-header h1 { font-size: 1.8rem; }
.print-performance-header > p { margin: 0 0 0.15rem; font-size: 0.78rem; }
.print-performance-score { display: grid; grid-template-columns: repeat(var(--section-count), minmax(0, 1fr)); margin-top: 0.8rem; border-top: 1px solid #999; border-left: 1px solid #999; }
.print-performance-lane { display: grid; min-width: 0; grid-template-rows: auto minmax(0, 1fr); margin: 0 !important; border-right: 1px solid #999; border-bottom: 1px solid #999; }
.print-performance-lane > header { min-width: 0; padding: 0.45rem; border-bottom: 1px solid #aaa; background: #f1f0ec; }
.print-performance-lane > header p { display: flex; align-items: baseline; justify-content: space-between; gap: 0.35rem; margin: 0; }
.print-performance-lane > header span { color: #555; font-size: 0.62rem; text-transform: uppercase; }
.print-performance-lane > header strong { font-size: 0.88rem; text-align: right; }
.print-performance-lane > header small { display: block; margin-top: 0.3rem; color: #555; font-size: 0.64rem; line-height: 1.3; }
.print-performance-lane > header div { margin-top: 0.3rem; font-size: 0.7rem; line-height: 1.3; }
.print-performance-lane ol { display: grid; min-height: 0; grid-template-rows: repeat(var(--event-count), minmax(0, 1fr)); margin: 0; padding: 0; list-style: none; }
.print-performance-lane li { min-width: 0; padding: 0.4rem; overflow: hidden; border-bottom: 1px solid #bbb; }
.print-performance-lane li:last-child { border-bottom: 0; }
.print-performance-event-heading { display: flex; align-items: baseline; justify-content: space-between; gap: 0.3rem; }
.print-performance-event-heading span { color: #555; font-size: 0.62rem; }
.print-performance-event-heading strong { font-size: 0.92rem; }
.print-performance-lane li p { margin: 0.2rem 0 0; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.7rem; line-height: 1.25; }
.print-performance-lane li p b { color: #555; font-size: 0.58rem; }
.print-performance-lane li p i { padding-left: 0.2rem; border-left: 1px solid #aaa; color: #555; font-size: 0.62rem; font-style: normal; }
.print-performance-lane li > small { display: block; margin-top: 0.25rem; color: #444; font-size: 0.66rem; line-height: 1.3; }

.performance-page { --performance-toolbar-height: 5.2rem; height: 100dvh; margin: 0; overflow: hidden; color: var(--ink); background: var(--canvas); }
.performance-toolbar { display: grid; grid-template-columns: minmax(10rem, 1fr) minmax(17rem, 30rem) auto auto; align-items: center; gap: 0.75rem; min-height: 5.2rem; padding: 0.75rem 1.2rem; border-bottom: 1px solid var(--line); background: var(--paper); }
.performance-toolbar h1 { margin: 0; overflow: hidden; font-family: Georgia, Cambria, serif; font-size: clamp(1.25rem, 2vw, 2rem); font-weight: 500; text-overflow: ellipsis; white-space: nowrap; }
.performance-toolbar .eyebrow { margin-bottom: 0.15rem; }
.performance-toolbar dl { display: flex; margin: 0; }
.performance-toolbar dl div { min-width: 0; flex: 1 1 6.5rem; padding: 0 0.8rem; border-left: 1px solid var(--line); }
.performance-toolbar dl div:last-child { flex-grow: 2; }
.performance-toolbar dt { color: var(--faint); font-size: 0.6rem; font-weight: 750; letter-spacing: 0.08em; text-transform: uppercase; }
.performance-toolbar dd { margin: 0.15rem 0 0; overflow: hidden; color: var(--ink); font-size: 0.83rem; font-weight: 700; text-overflow: ellipsis; white-space: nowrap; }
.performance-session-tools { display: flex; align-items: center; gap: 0.45rem; }
.performance-metronome { display: flex; align-items: center; gap: 0.35rem; padding: 0.3rem; border: 1px solid var(--line); border-radius: 0.45rem; background: var(--paper-deep); }
.performance-metronome button { width: auto; min-height: 2.2rem; padding: 0.35rem 0.45rem; cursor: pointer; color: var(--muted); background: var(--paper); font-size: 0.64rem; font-weight: 750; }
.performance-metronome > button { min-width: 4.8rem; }
.performance-metronome > div { display: flex; gap: 0.2rem; }
.performance-metronome [data-tempo-percent] { min-width: 2.3rem; }
.performance-metronome [aria-pressed="true"] { color: var(--button-ink); border-color: var(--rust-dark); background: var(--rust); }
.performance-metronome output { min-width: 3.5rem; color: var(--ink); font-size: 0.68rem; font-weight: 800; text-align: center; }
.performance-volume { display: grid; width: 5.2rem; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0.25rem; color: var(--faint); font-size: 0.58rem; font-weight: 750; }
.performance-range { --volume-position: 50%; box-sizing: border-box; width: 100%; height: 1.15rem; margin: 0; padding: 0; appearance: none; border: 0; cursor: pointer; background: linear-gradient(to right, var(--rust) 0 var(--volume-position), var(--line-dark) var(--volume-position) 100%) center / calc(100% - 0.66rem) 0.22rem no-repeat; }
.performance-range::-webkit-slider-runnable-track { height: 0.22rem; background: transparent; }
.performance-range::-webkit-slider-thumb { width: 1rem; height: 1rem; margin-top: -0.39rem; appearance: none; border: 0; border-radius: 50%; background: var(--rust); box-shadow: 0 0 0 1px color-mix(in srgb, var(--rust-dark) 55%, transparent); }
.performance-range::-moz-range-track { height: 0.22rem; background: transparent; }
.performance-range::-moz-range-progress { height: 0.22rem; background: transparent; }
.performance-range::-moz-range-thumb { width: 1rem; height: 1rem; border: 0; border-radius: 50%; background: var(--rust); box-shadow: 0 0 0 1px color-mix(in srgb, var(--rust-dark) 55%, transparent); }
.performance-range:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; border-radius: 0.4rem; }
.performance-tone-toggle { display: grid; width: 3.8rem; min-height: 2.8rem; margin: 0; padding: 0.25rem 0.45rem; grid-template-columns: 1rem auto; place-content: center; align-items: center; gap: 0.3rem; border: 1px solid var(--line-dark); border-radius: 0.4rem; color: var(--muted); background: var(--paper-deep); cursor: pointer; font-size: 0.64rem; font-weight: 750; }
.performance-tone-toggle svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-linecap: round; stroke-linejoin: round; stroke-width: 1.5; }
.performance-tone-toggle:hover { color: var(--ink); border-color: var(--faint); }
.performance-tone-toggle[aria-pressed="true"] { color: var(--button-ink); border-color: var(--rust-dark); background: var(--rust); }
.performance-tone-toggle:focus-visible { outline: 2px solid var(--rust); outline-offset: 2px; }
.performance-layer-menu, .performance-midi-monitor { position: relative; }
.performance-layer-menu summary, .performance-midi-monitor summary { display: grid; min-height: 2.8rem; padding: 0 0.6rem; place-items: center; border: 1px solid var(--line-dark); border-radius: 0.4rem; color: var(--muted); background: var(--paper-deep); cursor: pointer; font-size: 0.68rem; font-weight: 750; list-style: none; }
.performance-layer-menu summary::-webkit-details-marker, .performance-midi-monitor summary::-webkit-details-marker { display: none; }
.performance-midi-monitor summary { width: 6.8rem; grid-template-columns: auto 2.6rem; gap: 0.45rem; }
.performance-midi-monitor summary output { width: 2.6rem; overflow: hidden; color: var(--ink); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.74rem; text-align: center; text-overflow: ellipsis; white-space: nowrap; }
.performance-midi-monitor.active summary { border-color: var(--rust-dark); }
.performance-midi-monitor > div { position: absolute; z-index: 6; top: calc(100% + 0.4rem); right: 0; display: grid; width: 18rem; gap: 0.5rem; padding: 0.75rem; border: 1px solid var(--line-dark); border-radius: 0.45rem; background: var(--paper); box-shadow: var(--shadow); }
.performance-midi-monitor p, .performance-midi-monitor small { margin: 0; color: var(--muted); font-size: 0.7rem; line-height: 1.4; }
.performance-midi-monitor button { width: auto; justify-self: start; padding: 0.45rem 0.65rem; font-size: 0.7rem; }
.performance-practice-sound { display: grid; grid-template-columns: auto minmax(7rem, 1fr); align-items: center; gap: 0.65rem; padding-top: 0.55rem; border-top: 1px solid var(--line); }
.performance-practice-sound > strong { font-size: 0.7rem; }
.performance-practice-sound label { display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; gap: 0.4rem; color: var(--muted); font-size: 0.68rem; font-weight: 700; }
.performance-layer-menu fieldset { position: absolute; z-index: 5; top: calc(100% + 0.4rem); right: 0; display: grid; width: 10rem; gap: 0.45rem; margin: 0; padding: 0.65rem; border: 1px solid var(--line-dark); border-radius: 0.45rem; background: var(--paper); box-shadow: var(--shadow); }
.performance-layer-menu label { display: flex; align-items: center; gap: 0.45rem; color: var(--muted); font-size: 0.68rem; white-space: nowrap; }
.performance-layer-menu input { width: 0.85rem; height: 0.85rem; margin: 0; accent-color: var(--rust); }
.performance-toolbar nav { display: flex; align-items: stretch; gap: 0.5rem; height: auto; }
.performance-toolbar nav > button, .performance-toolbar nav > .button-link { display: inline-grid; width: auto; min-height: 3rem; margin: 0; padding: 0.45rem 0.65rem; place-items: center; font-size: 0.72rem; line-height: 1.1; text-align: center; }
.performance-score { display: grid; grid-template-columns: repeat(var(--section-count), minmax(0, 1fr)); grid-template-rows: max-content minmax(0, 1fr); width: 100%; height: calc(100dvh - var(--performance-toolbar-height)); padding: 0; }
.performance-lane { display: contents; }
.performance-lane > header { container-type: inline-size; grid-column: var(--lane-index); grid-row: 1; min-width: 0; min-height: 0; padding: 0.7rem; overflow: hidden; border-right: 1px solid var(--line); border-bottom: 1px solid var(--line-dark); background: var(--paper-deep); }
.performance-lane:last-child > header, .performance-lane:last-child > ol { border-right: 0; }
.performance-lane > header > p:first-child { display: flex; justify-content: space-between; gap: 0.4rem; margin: 0; color: var(--faint); font-size: 0.64rem; text-transform: uppercase; }
.performance-lane > header > p:first-child small { max-width: 62%; line-height: 1.3; overflow-wrap: anywhere; text-align: right; text-transform: none; }
.performance-section-title { display: flex; min-width: 0; align-items: baseline; gap: 0.4rem; margin: 0.45rem 0 0.35rem; }
.performance-lane h2 { min-width: 0; margin: 0; overflow: hidden; color: var(--ink); font-size: clamp(0.95rem, 5cqi, 1.35rem); text-overflow: ellipsis; white-space: nowrap; }
.performance-section-title > span { flex: 0 0 auto; color: var(--faint); font-size: 0.55rem; font-weight: 750; letter-spacing: 0.04em; text-transform: uppercase; }
.performance-progression { margin: 0; color: var(--muted); font-size: clamp(0.72rem, 3.8cqi, 0.9rem); line-height: 1.35; overflow-wrap: anywhere; }
.performance-lane ol { container-type: inline-size; display: grid; grid-column: var(--lane-index); grid-row: 2; width: 100%; min-width: 0; grid-template-rows: repeat(var(--event-count), minmax(0, 1fr)); min-height: 0; gap: 0; margin: 0; padding: 0; overflow: hidden; border-right: 1px solid var(--line); background: var(--paper); list-style: none; }
.performance-lane li { width: 100%; min-width: 0; min-height: 0; padding: clamp(0.28rem, 0.65vh, 0.48rem) 0.65rem; overflow: hidden; border-bottom: 1px solid var(--line); }
.performance-event-heading { display: flex; width: 100%; min-width: 0; align-items: baseline; justify-content: space-between; gap: 0.5rem; }
.performance-event-heading span { flex: 0 0 auto; color: var(--faint); font-size: 0.64rem; }
.performance-event-heading strong { min-width: 0; max-width: 72%; overflow: hidden; color: var(--ink); font-size: clamp(1rem, 5cqi, 1.45rem); line-height: 1.08; text-align: right; text-overflow: ellipsis; white-space: nowrap; }
.performance-lane li dl { display: grid; min-width: 0; gap: 0.08rem; margin: 0.22rem 0 0; }
.performance-lane li dl div { display: grid; min-width: 0; grid-template-columns: 1.5rem minmax(0, 1fr); gap: 0.3rem; }
.performance-lane li dt { color: var(--faint); font-size: clamp(0.62rem, 2.8cqi, 0.72rem); font-weight: 800; }
.performance-lane li dd { display: flex; min-width: 0; align-items: baseline; flex-wrap: wrap; gap: 0.12rem 0.42rem; margin: 0; overflow: visible; color: var(--muted); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: clamp(0.75rem, 4.3cqi, 1rem); line-height: 1.3; white-space: normal; }
.performance-notes { min-width: 0; overflow: visible; overflow-wrap: anywhere; }
.performance-fingering { flex: 0 0 auto; padding-left: 0.38rem; border-left: 1px solid var(--line-dark); color: var(--faint); font-size: clamp(0.66rem, 3.4cqi, 0.82rem); letter-spacing: 0.02em; white-space: nowrap; }
.performance-lane li > small { display: -webkit-box; min-height: 1.7rem; margin-top: 0.22rem; overflow: hidden; color: var(--faint); font-size: clamp(0.68rem, 4cqi, 0.9rem); line-height: 1.3; overflow-wrap: anywhere; -webkit-box-orient: vertical; -webkit-line-clamp: 4; }
.hide-hands .performance-lane li dl, .hide-fingering .performance-fingering, .hide-cues .performance-lane li > small { display: none; }
.performance-lane.compact li > small { -webkit-line-clamp: 3; }
.performance-lane.dense li { padding-block: 0.15rem; }
.performance-lane.dense li dl { margin-top: 0.08rem; }
.performance-lane.dense li > small { margin-top: 0.12rem; -webkit-line-clamp: 2; }

@media (max-height: 800px) and (min-width: 801px) {
  .performance-lane > header { padding: 0.55rem 0.65rem; }
  .performance-lane li { padding: 0.2rem 0.65rem; }
  .performance-lane li dl { gap: 0; margin-top: 0.12rem; }
  .performance-lane li > small { min-height: 1.5rem; }
}

:fullscreen .performance-page { --performance-toolbar-height: 6rem; }
:fullscreen .performance-toolbar { min-height: 6rem; padding-inline: 1.6rem; }
:fullscreen .performance-lane > header { padding: 0.9rem; }
:fullscreen .performance-lane li { padding: clamp(0.45rem, 0.8vh, 0.7rem) 0.85rem; }
:fullscreen .performance-event-heading strong { font-size: clamp(1.05rem, 5cqi, 1.55rem); }

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

@media (max-width: 800px) {
  .site-header { position: static; align-items: flex-start; flex-direction: column; gap: 0.3rem; padding: 0.8rem 1.2rem 0; }
  .header-tools { width: 100%; flex-wrap: wrap; justify-content: space-between; row-gap: 0.2rem; }
  nav { width: 100%; flex-wrap: wrap; height: auto; }
  nav a, nav span { flex: 0 0 auto; padding: 0.5rem 0.7rem 0.55rem; }
  main { width: min(100% - 1.5rem, 1160px); padding-top: 1.5rem; }
  .workspace-heading { align-items: flex-start; flex-direction: column; gap: 0.8rem; }
  .attempt-status-facts { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .attempt-status-facts div:nth-child(2) { border-right: 0; }
  .attempt-status-facts div:nth-child(-n + 2) { border-bottom: 1px solid var(--line); }
  .workspace, .etude-header, .guidance-workspace { grid-template-columns: 1fr; }
  .cards[data-etude-catalog] { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .guidance-sidebar { position: static; }
  .workspace-sidebar { grid-template-columns: 1fr 1fr; }
  .profile-summary { align-items: flex-start; flex-direction: column; }
  .profile-summary dl { width: 100%; }
  .practice-header { grid-template-columns: 1fr; }
  .performance-page { height: auto; overflow: auto; }
  .performance-toolbar { grid-template-columns: 1fr; }
  .performance-toolbar dl { display: none; }
  .performance-session-tools { flex-wrap: wrap; }
  .performance-score { grid-template-columns: 1fr; grid-template-rows: none; height: auto; }
  .performance-lane { display: block; grid-row: auto; overflow: visible; border-right: 0; }
  .performance-lane > header, .performance-lane ol { border-right: 0; }
  .performance-lane ol { display: grid; grid-template-rows: none; overflow: visible; }
}

@media (max-width: 560px) {
  .field-row, .field-row.two, .workspace-sidebar, .setting-row, .candidate-row, .draft-grid, .inspector-columns, .import-form { grid-template-columns: 1fr; }
  .cards[data-etude-catalog] { grid-template-columns: 1fr; }
  .attempt-status-facts { grid-template-columns: 1fr; }
  .attempt-status-facts div { border-right: 0; border-bottom: 1px solid var(--line); }
  .attempt-status-facts div:last-child { border-bottom: 0; }
  .attempt-status-actions { align-items: flex-start; flex-direction: column; }
  /* Uniform two-column button grid: every action the same size, wrapping in
     reading order (the hidden scaffold textarea is absolutely positioned and
     takes no cell). */
  .etude-actions { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); align-items: stretch; }
  .etude-actions > * { margin: 0; }
  .etude-actions .button-link,
  .etude-actions .quiet-button { display: inline-flex; width: 100%; justify-content: center; padding: 0.68rem 0.5rem; text-align: center; }
  .theme-toggle span:last-child { display: none; }
  .profile-summary dl, .print-practice { display: grid; grid-template-columns: 1fr; }
  .profile-summary dl div { padding: 0.5rem 0; border: 0; }
}

@media print {
  @page { size: Letter landscape; margin: 0.22in; }
  .practice-sheet-page { min-height: 0; background: #fff; print-color-adjust: exact; }
  .print-toolbar { display: none; }
  .practice-packet { display: block; width: auto; min-height: 0; margin: 0; padding: 0; }
  .practice-sheet {
    width: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    box-shadow: none;
  }
  .practice-overview-sheet { break-after: page; }
  .practice-sheet h1 { font-size: 18pt; }
  .practice-header { grid-template-columns: minmax(0, 1fr) 2.6in; gap: 0.25in; padding-bottom: 0.1in; }
  .practice-header p { margin: 0.04in 0 0; font-size: 8.2pt; line-height: 1.25; }
  .practice-header dl div { padding: 0.06in; }
  .practice-header dt { font-size: 6.5pt; }
  .practice-header dd { margin-top: 0.02in; font-size: 8.5pt; }
  .practice-sheet section { margin-top: 0.09in; }
  .practice-sheet .print-chart { break-inside: avoid; }
  .practice-sheet table { font-size: 7.8pt; line-height: 1.18; }
  .practice-sheet thead { display: table-header-group; }
  .practice-sheet th, .practice-sheet td { padding: 0.032in 0.05in; }
  .practice-sheet tr { break-inside: avoid; }
  .print-arrangement th:nth-child(1) { width: 0.55in; }
  .print-arrangement th:nth-child(2) { width: 0.85in; }
  .print-voicing-grid article { padding: 0.032in 0.04in; }
  .print-voicing-grid article > div strong { font-size: 8.5pt; }
  .print-voicing-grid article span { font-size: 6.8pt; }
  .print-voicing-grid article p { margin-top: 0.018in; font-size: 7.5pt; line-height: 1.15; }
  .print-voicing-grid article small { margin-top: 0.015in; font-size: 6.8pt; line-height: 1.15; }
  .print-practice { grid-template-columns: repeat(3, 1fr); gap: 0.04in 0.22in; margin: 0.025in 0 0; font-size: 7.8pt; line-height: 1.2; }
  .print-practice p { margin: 0.018in 0; line-height: 1.2; }
  .print-practice small { font-size: 7.3pt; }
  .practice-sheet footer { margin-top: 0.06in; padding-top: 0.035in; }
  .practice-performance-sheet { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
  .practice-performance-sheet section { break-inside: auto; }
  .print-performance-header { padding-bottom: 0.05in; }
  .print-performance-header h1 { font-size: 15pt; }
  .print-performance-header > p { font-size: 8pt; }
  .print-performance-score { min-height: 0; margin-top: 0.05in; }
  .print-performance-lane > header { padding: 0.04in 0.05in; }
  .print-performance-lane > header span { font-size: 6pt; }
  .print-performance-lane > header strong { font-size: 8.5pt; }
  .print-performance-lane > header small { margin-top: 0.02in; font-size: 6.3pt; line-height: 1.16; }
  .print-performance-lane > header div { margin-top: 0.022in; font-size: 7pt; line-height: 1.16; }
  .print-performance-lane li { padding: 0.03in 0.05in; }
  .print-performance-event-heading span { font-size: 6.2pt; }
  .print-performance-event-heading strong { font-size: 9pt; }
  .print-performance-lane li p { margin-top: 0.012in; font-size: 7.4pt; line-height: 1.16; }
  .print-performance-lane li p b { font-size: 6pt; }
  .print-performance-lane li p i { font-size: 6.5pt; }
  .print-performance-lane li > small { margin-top: 0.015in; font-size: 7pt; line-height: 1.18; }
  .eyebrow { color: #333; }
}
