/* Generative Experiments — shared interface styles */

/* 1. Design tokens and base elements */
:root {
  color-scheme: light;
  --left: #e9eae8;
  --right: #fcfcfa;
  --ink: #272b2a;
  --muted: #656b67;
  --faint: #8a908c;
  --rule: #c7cbc7;
  --orange: #e76532;
  --green: #508d62;
  --grey: #898d89;
  --red: #c85c52;
  --bar-track: #e1e3df;
  --bar-fill: #9ca39d;
  font-family: 'DM Sans', Arial, sans-serif;
  font-synthesis: none;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; background: var(--right); color: var(--ink); }
h1, h2, h3, p { margin-top: 0; }
button, select { font: inherit; }
button { cursor: pointer; }
button:disabled { opacity: .38; cursor: not-allowed; }
a { color: var(--orange); text-underline-offset: 4px; }
a:hover, button:hover:not(:disabled) { color: #b9471c; }
:focus-visible { outline: 3px solid var(--orange); outline-offset: 3px; }
[hidden] { display: none !important; }
.orange, .head-accent { color: var(--orange); }

/* 2. Two-panel page layout */
.diptych {
  display: grid;
  grid-template-columns: 40% minmax(0, 60%);
  height: 100dvh;
  min-height: 500px;
  overflow: hidden;
}
.context {
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: clamp(30px, 6vh, 66px);
  min-width: 0;
  padding: clamp(18px, 2.2vw, 34px);
  overflow-y: auto;
  background: var(--left);
}
.workspace { min-width: 0; overflow-y: auto; background: var(--right); }
.workspace-inner { width: 100%; max-width: none; margin: 0 auto; padding: 0; }
.section-content {
  padding-right: clamp(22px, 4vw, 64px);
  padding-left: clamp(22px, 4vw, 64px);
}

/* 3. Left panel: branding, selector, grammar and footer */
.microline {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 15px;
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .085em;
}
.orange-square { display: block; flex: none; width: 12px; height: 12px; background: var(--orange); }
.context h1 {
  margin: 22px 0 18px;
  padding-bottom: .13em;
  font: 400 clamp(36px, 4vw, 68px)/1.17 'Manrope', Arial, sans-serif;
  letter-spacing: -.065em;
  overflow-wrap: anywhere;
}
.tracery-mark {
  color: var(--orange);
  font: 800 24px/1 'Manrope', Arial, sans-serif;
  letter-spacing: .075em;
  white-space: nowrap;
}
.title-dot { display: inline-block; margin-left: .035em; font-size: 1.7em; line-height: 0; vertical-align: -.085em; }
.tagline {
  max-width: 410px;
  color: #515653;
  font: 400 clamp(13px, 1.05vw, 15px)/1.8 'DM Sans', sans-serif;
}
.aside-rule { height: 1px; margin: 34px 0; background: #b7bbb7; }
.micro { color: var(--muted); font-size: 11px; font-weight: 700; letter-spacing: .1em; }
.grammar-system { margin-top: 38px; }
.rule-name { margin: 20px 0 4px; font: 500 23px/1.4 'Manrope', sans-serif; }
.rule-expansion {
  color: #505752;
  font: 500 17px/1.55 'DM Sans', sans-serif;
  overflow-wrap: anywhere;
}
.system-note { max-width: 340px; color: var(--muted); font-size: 13px; line-height: 1.6; }
.context-bottom { margin-top: auto; padding-top: 32px; color: #555b56; font-size: 13px; }
.context-bottom .aside-rule { margin-bottom: 20px; }
.context-bottom p { margin: 0 0 9px; }

/* Experiment selector (in the left panel) */
.context-selector { margin: 24px 0 20px; }
.selector-row { display: flex; align-items: center; gap: 18px; margin: 0 0 29px; }
.context-selector .selector-row { max-width: 340px; margin: 0; }
.selector-row label, .actions label {
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  white-space: nowrap;
}
.selector-row select {
  flex: 1;
  min-width: 0;
  max-width: 460px;
  padding: 11px 27px 11px 2px;
  border: 0;
  border-bottom: 1px solid var(--ink);
  border-radius: 0;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
  font-weight: 700;
}

/* 4. Right panel: experiment introduction */
.experiment-head { padding: 0; border-bottom: 1px solid var(--rule); }
.experiment-head > .section-content {
  padding-top: clamp(22px, 3vw, 48px);
  padding-bottom: 28px;
}
.experiment-head .microline { margin-bottom: 14px; }
.experiment-head h2 {
  margin: 0 0 14px;
  font: 600 clamp(20px, 2vw, 28px)/1.14 'Manrope', sans-serif;
  letter-spacing: -.04em;
}
.description, .method-description {
  width: 100%;
  max-width: none;
  color: var(--muted);
  font-size: 15px;
  font-weight: 400;
  line-height: 1.7;
}
.experiment-head .description { margin-bottom: 12px; }
.method-description { margin-bottom: 0; }
.status { color: #9b4025; font-size: 13px; line-height: 1.5; }
.status:empty { display: none; }

/* 5. Output controls, score chips and legend */
.output-section { padding: 19px 0 36px; border-top: 1px solid var(--rule); }
.batch-section { padding: 0; border: 0; }
.batch-section > .section-content { padding-top: 24px; padding-bottom: 30px; }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: 16px; }
.section-head h3 { margin: 0; color: #666c67; font-size: 11px; font-weight: 700; letter-spacing: .09em; }
.actions { display: flex; align-items: center; flex-wrap: wrap; gap: 18px; }
.actions button, .collection-footer button {
  padding: 5px 0;
  border: 0;
  background: transparent;
  color: var(--orange);
  font-size: 15px;
  font-weight: 400;
  text-decoration: underline;
  text-underline-offset: 4px;
  white-space: nowrap;
}
.actions select {
  padding: 4px 16px 4px 4px;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
  font-size: 13px;
}
.single-result {
  margin: 52px 0 25px;
  font: 700 clamp(27px, 3.1vw, 47px)/1.4 'Manrope', sans-serif;
  letter-spacing: -.055em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.single-analysis { display: flex; align-items: center; gap: 14px; margin: 0 0 5px; }
.score-description { color: var(--muted); font-size: 12px; }
.score-chip {
  display: grid;
  flex: none;
  place-items: center;
  width: 66px;
  height: 38px;
  border: 1px solid var(--score);
  background: repeating-linear-gradient(45deg, transparent 0 4px,
    color-mix(in srgb, var(--score) 28%, transparent) 4px 6px), var(--chip-bg);
}
.score-chip span {
  display: block;
  padding: 2px 5px;
  background: var(--chip-bg);
  color: var(--score);
  font: 800 13px/1.3 'Manrope', sans-serif;
}
.score-chip.small { width: 54px; height: 31px; }
.score-chip.small span { font-size: 11px; }
.score-close { --score: var(--green); --chip-bg: #e5eee7; }
.score-mid { --score: var(--grey); --chip-bg: #ebedeb; }
.score-far { --score: var(--red); --chip-bg: #f5e7e5; }
.analysis-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 9px 18px;
  margin: 27px 0 8px;
  color: var(--muted);
  font-size: 11px;
}
.legend-item { display: inline-flex; align-items: center; gap: 7px; }
.legend-swatch {
  width: 15px;
  height: 12px;
  border: 1px solid var(--score);
  background: repeating-linear-gradient(45deg, var(--chip-bg) 0 4px, var(--score) 4px 5px);
}

/* 6. Generated result rows and shared disclosures */
.results-list { margin: 20px 0 0; padding: 0; list-style: none; counter-reset: item; }
.results-list > li {
  position: relative;
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) auto;
  align-items: center;
  gap: 0 12px;
  padding: 15px 0;
  border-bottom: 1px solid var(--bar-track);
  counter-increment: item;
}
.results-list > li::before {
  content: counter(item, decimal-leading-zero);
  font-size: 11px;
  color: #929993;
}
.results-list > li > .result-name-wrap {
  display: flex;
  grid-column: 2;
  grid-row: 1;
  align-items: center;
  gap: 7px;
  min-width: 0;
}
.result-text {
  font: 600 clamp(15px, 1.3vw, 19px)/1.6 'Manrope', sans-serif;
  letter-spacing: -.02em;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.result-name-wrap .result-text {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--ink);
  text-align: left;
  cursor: pointer;
}
.result-name-wrap .result-text:hover,
.result-name-wrap .result-text:focus-visible { color: var(--ink); }
.result-name-wrap .result-text.plain-output { color: var(--ink); opacity: 1; cursor: pointer; }
.results-list > li > .score-group { grid-column: 3; grid-row: 1; align-self: center; }
.score-group { display: flex; justify-content: flex-end; align-items: center; gap: 7px; min-width: 0; }
.percentile-flag {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  height: 31px;
  padding: 0 8px;
  border: 1px solid var(--rule);
  background: transparent;
  color: var(--ink);
  font: 600 10px/1.2 'DM Sans', sans-serif;
  letter-spacing: .025em;
  white-space: nowrap;
}
.exact-match-flag {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 31px;
  padding: 6px 10px;
  border: 1px dashed var(--orange);
  border-radius: 0;
  background: #fff1e8;
  color: #a9471c;
  font: 700 11px/1.2 'DM Sans', sans-serif;
  white-space: nowrap;
}
.result-name-wrap .score-expand {
  display: inline-grid;
  flex: none;
  place-items: center;
  width: 14px;
  height: 18px;
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--orange);
  font: 400 17px/1 'Manrope', sans-serif;
  cursor: pointer;
}
.score-expand:hover { color: #b9471c; }
.results-list > li > .score-breakdown {
  grid-column: 2 / -1;
  grid-row: 2;
  min-width: 0;
  margin: 0;
  padding: 15px 0 4px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
}
.score-breakdown p { margin: 0 0 7px; }
.collection-footer { display: flex; justify-content: flex-end; align-items: center; gap: 22px; padding: 17px 0; }
.workspace-footer {
  display: flex;
  justify-content: space-between;
  gap: 15px;
  margin-top: 0;
  padding-top: 22px;
  padding-bottom: 32px;
  border-top: 1px solid var(--rule);
  color: var(--faint);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .065em;
}
.workspace-footer a { text-decoration: none; }

/* 7. Cumberbot9000 — Jaro–Winkler calculation disclosure */
.breakdown-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 22px;
  margin: 0 0 12px;
}
.breakdown-word { min-width: 0; }
.breakdown-word h4 {
  margin: 0 0 9px;
  color: var(--ink);
  font: 600 12px/1.4 'Manrope', sans-serif;
  letter-spacing: 0;
  overflow-wrap: anywhere;
}
.breakdown-word strong { color: var(--ink); }
.breakdown-comparison {
  margin-bottom: 4px;
  color: var(--ink);
  font: 600 13px/1.5 'Manrope', sans-serif;
  overflow-wrap: anywhere;
}
.breakdown-word-score { color: var(--ink); font: 600 15px/1.4 'Manrope', sans-serif; }
.breakdown-formula { min-width: 0; overflow-wrap: anywhere; font-weight: 400; }
.breakdown-number { color: var(--muted); font-variant-numeric: tabular-nums; }
.breakdown-steps { display: flex; flex-direction: column; gap: 6px; margin: 0; padding: 0; list-style: none; counter-reset: none; }
.breakdown-steps .breakdown-step {
  display: grid;
  grid-template-columns: minmax(30px, 22%) minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
  font-size: 11px;
  line-height: 1.5;
  counter-increment: none;
}
.breakdown-step::before { content: none !important; display: none !important; }
.breakdown-step .mini-track {
  display: block;
  width: 100%;
  height: 5px;
  background: var(--bar-track);
}
.breakdown-step .mini-fill { display: block; height: 100%; background: var(--bar-fill); }
.breakdown-step .breakdown-formula {
  min-width: 0;
  color: var(--muted);
  font-weight: 400;
  overflow-wrap: normal;
  word-break: normal;
}
.breakdown-column-result { display: block; margin: 10px 0 0; padding: 0; color: var(--ink); font-size: 11px; }
.breakdown-column-result .comparison-track { display: block; width: 100%; height: 6px; background: var(--bar-track); }
.breakdown-column-result .comparison-fill { display: block; height: 100%; background: var(--bar-fill); }
.breakdown-column-result strong { font-variant-numeric: tabular-nums; }
.breakdown-total { margin: 0 0 8px; padding: 9px 0 0; border: 0; color: var(--ink); font-weight: 700; }
.breakdown-score-bars { display: grid; gap: 5px; max-width: 260px; margin: 0 0 9px; }
.comparison-bar { display: grid; grid-template-columns: 31px 1fr 43px; align-items: center; gap: 7px; font-size: 10px; }
.comparison-track { display: block; height: 5px; background: var(--bar-track); }
.comparison-fill { display: block; height: 100%; background: var(--orange); }
.breakdown-mini { display: flex; gap: 5px; max-width: 140px; margin: 10px 0 0; }
.mini-track { display: block; flex: 1; height: 5px; background: var(--bar-track); }
.mini-fill { display: block; height: 100%; background: var(--orange); }
.breakdown-note { margin: 0 !important; color: var(--muted); font-size: 10px; }

/* 8. Ghost Echoes — edition provenance and word-rarity disclosure */
.ghost-rule { font-size: 14px; line-height: 1.7; overflow-wrap: anywhere; }
.ghost-breakdown p { margin: 0 0 5px; font-size: 12px; line-height: 1.5; }
.ghost-breakdown .ghost-heading {
  margin: 0 0 8px;
  color: var(--ink);
  font: 700 12px/1.5 'DM Sans', sans-serif;
}
.ghost-breakdown .ghost-stat-row {
  display: grid;
  grid-template-columns: minmax(28px, 11%) minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  min-width: 0;
  margin: 0 0 6px;
}
.ghost-breakdown .ghost-mini-track { display: block; width: 100%; height: 5px; background: var(--bar-track); }
.ghost-breakdown .ghost-mini-fill { display: block; height: 100%; background: var(--bar-fill); }
.ghost-breakdown .ghost-edition-blocks {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 5px;
  width: 100%;
  height: 5px;
}
.ghost-breakdown .ghost-edition-block { min-width: 0; height: 5px; background: var(--bar-track); }
.ghost-breakdown .ghost-edition-block.is-present { background: var(--bar-fill); }
.ghost-breakdown .ghost-stat-label { color: var(--muted); font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.ghost-breakdown .ghost-subhead { margin: 10px 0 5px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.ghost-breakdown .ghost-mean { margin: 5px 0 0; color: var(--muted); font-size: 11px; line-height: 1.5; }

/* 9. Responsive adjustments */
@media (max-width: 800px) {
  .diptych { display: block; height: auto; min-height: 100vh; overflow: visible; }
  .context { min-height: 0; padding: 24px; gap: 24px; overflow: visible; }
  .context h1 { margin: 20px 0 14px; font-size: clamp(36px, 7vw, 58px); }
  .tagline { font-size: 14px; }
  .aside-rule { margin: 20px 0; }
  .grammar-system { margin-top: 25px; }
  .context-bottom { padding-top: 12px; }
  .context-bottom .aside-rule { margin: 0 0 14px; }
  .workspace { overflow: visible; }
  .experiment-head > .section-content { padding-top: 30px; padding-bottom: 26px; }
  .section-content { padding-right: 24px; padding-left: 24px; }
  .selector-row { margin: 0 0 25px; }
  .single-result { margin: 32px 0 22px; }
}

@media (max-width: 650px) {
  .breakdown-grid { grid-template-columns: 1fr; gap: 17px; }
  .breakdown-steps .breakdown-step { grid-template-columns: minmax(28px, 20%) minmax(0, 1fr); }
}

@media (max-width: 480px) {
  .section-head { flex-direction: column; align-items: flex-start; gap: 10px; }
  .selector-row { flex-direction: column; align-items: flex-start; gap: 8px; }
  .selector-row select { width: 100%; max-width: none; }
  .results-list > li { grid-template-columns: 22px minmax(0, 1fr) auto; column-gap: 8px; }
  .score-chip.small { width: 47px; }
  .score-group { flex-wrap: wrap; justify-content: flex-end; gap: 4px; }
  .percentile-flag { padding: 0 5px; font-size: 9px; }
  .exact-match-flag { padding: 5px 7px; font-size: 9px; }
  .workspace-footer { flex-direction: column; }
  .head-accent { display: none; }
}

@media (prefers-reduced-motion: no-preference) {
  button, a { transition: color .15s ease; }
}
