/* Legacy layout and paint share one cascade layer. Theme recipes own opt-in appearance. */
@layer legacy {
  :root {
    color-scheme: dark;
    --ink: #dce9e1;
    --muted: #9aaea5;
    --paper: #101d1b;
    --line: #3f5750;
    --accent: #d8ef92;
  }
  * {
    box-sizing: border-box;
  }
  body {
    margin: 0;
    background: var(--paper);
    color: var(--ink);
    font-family: 'Field Kit UI', sans-serif;
    font-size: 15px;
    line-height: 1.5;
  }
  header {
    display: flex;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 3vw;
    border-bottom: 1px solid var(--line);
    font:
      12px 'Field Kit Mono',
      monospace;
  }
  a {
    color: var(--accent);
    text-underline-offset: 4px;
  }
  main {
    max-width: 1800px;
    margin: auto;
    padding: 28px 3vw;
  }
  .title-row,
  .section-heading {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 18px;
  }
  h1 {
    font:
      600 clamp(36px, 4vw, 64px) / 1 'Field Kit Display',
      monospace;
    margin: 6px 0 24px;
    letter-spacing: -0.02em;
  }
  h2 {
    font-size: 18px;
    margin: 0;
  }
  .eyebrow,
  .edition {
    color: var(--accent);
    font:
      11px/1.6 'Field Kit Mono',
      monospace;
    letter-spacing: 0.08em;
  }
  .edition {
    text-align: right;
    color: var(--muted);
  }
  #status {
    padding: 12px 16px;
    border-left: 3px solid var(--accent);
    background: #1c302b;
  }
  #status[data-error='true'] {
    border-color: #ffb395;
    background: #382924;
  }
  .toolbar,
  .pair,
  .preview-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
  }
  .preview-remains-options {
    flex-basis: 100%;
  }
  .preview-remains-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
    margin: 0;
  }
  .preview-remains-toggle input {
    flex: 0 0 20px;
    width: 20px;
    height: 20px;
    margin: 0;
    padding: 0;
  }
  .toolbar {
    padding: 8px 0 24px;
  }
  .workbench-jump {
    margin-left: auto;
    padding: 12px 0;
  }
  .candidate-library,
  .difficulty-edition {
    margin: 0 0 12px;
    padding: 0;
  }
  .candidate-library > summary,
  .difficulty-edition > summary {
    font-size: 15px;
  }
  .library-summary-note {
    color: var(--muted);
    margin-left: 16px;
    font-size: 12px;
  }
  .library-filters {
    display: grid;
    grid-template-columns: minmax(0, 2fr) minmax(0, 1fr) auto;
    gap: 16px;
    align-items: end;
  }
  .library-filters label {
    min-width: 0;
    margin: 0;
  }
  .candidate-group {
    margin: 24px 0;
  }
  .candidate-group h2 {
    margin-bottom: 12px;
  }
  .candidate-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
  }
  .candidate-entry {
    min-width: 0;
    padding: 16px;
    border: 1px solid var(--line);
    background: #15251f;
    overflow-wrap: anywhere;
  }
  .candidate-entry button {
    width: 100%;
    text-align: left;
  }
  .candidate-entry button + button {
    margin-top: 8px;
  }
  .candidate-entry a {
    display: inline-block;
    padding-block: 10px;
  }
  .candidate-library [hidden] {
    display: none;
  }
  .library-inspection {
    position: sticky;
    top: 8px;
    z-index: 2;
    border-left: 3px solid var(--accent);
    padding: 12px 16px;
    background: #1c302b;
  }
  .library-inspection p {
    margin-top: 0;
  }
  @media (max-width: 650px) {
    .candidate-grid,
    .library-filters {
      grid-template-columns: minmax(0, 1fr);
    }
    .library-summary-note {
      display: block;
      margin: 4px 0 0 18px;
    }
    .workbench-jump {
      margin-left: 0;
    }
  }
  .workspace {
    display: grid;
    grid-template-columns: minmax(180px, 0.7fr) minmax(440px, 2.2fr) minmax(260px, 1fr);
    border-block: 1px solid var(--line);
  }
  #actor-tools,
  #objective-tools,
  #bonus-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0 16px;
  }
  #actor-tools > .note,
  #objective-tools > .note,
  #bonus-tools > .note {
    grid-column: 1 / -1;
  }
  #actor-tools label,
  #objective-tools label,
  #bonus-tools label {
    min-width: 0;
  }
  #actor-tools > .pair,
  #objective-tools > .pair,
  #bonus-tools > .pair {
    align-items: start;
  }
  #actor-tools > .pair > label,
  #objective-tools > .pair > label,
  #bonus-tools > .pair > label {
    flex: 1;
  }
  @media (max-width: 560px) {
    #actor-tools,
    #objective-tools,
    #bonus-tools {
      grid-template-columns: minmax(0, 1fr);
    }
  }
  aside,
  .board-panel,
  .source-panel {
    min-width: 0;
    padding: 22px 20px;
  }
  aside {
    padding-left: 0;
    border-right: 1px solid var(--line);
  }
  .source-panel {
    padding-right: 0;
    border-left: 1px solid var(--line);
  }
  label {
    display: block;
    font-size: 12px;
    color: var(--muted);
    margin: 9px 0;
  }
  label[hidden] {
    display: none;
  }
  input,
  select,
  textarea,
  button,
  .file-button {
    font: inherit;
    color: var(--ink);
    background: #182a25;
    border: 1px solid var(--line);
    border-radius: 2px;
  }
  input,
  select,
  textarea {
    width: 100%;
    padding: 10px;
    display: block;
    margin-top: 5px;
  }
  input:not([type='checkbox']),
  select {
    min-height: 44px;
  }
  button,
  .file-button {
    padding: 10px 12px;
    min-height: 44px;
    cursor: pointer;
    font-size: 12px;
  }
  button:hover:not(:disabled),
  .file-button:hover {
    background: #30443a;
    border-color: var(--accent);
  }
  button:disabled {
    opacity: 0.45;
    cursor: default;
  }
  .primary {
    background: var(--accent);
    color: #152117;
    border-color: var(--accent);
    font-weight: 600;
  }
  button.primary:hover:not(:disabled) {
    color: var(--ink);
  }
  :focus-visible {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
  }
  .file-button {
    position: relative;
    overflow: hidden;
    margin: 0;
  }
  .file-button input {
    position: absolute;
    inset: 0;
    opacity: 0;
    width: 100%;
    cursor: pointer;
  }
  .file-button:focus-within {
    outline: 3px solid var(--accent);
    outline-offset: 3px;
  }
  canvas {
    display: block;
    width: 100%;
    height: auto;
    margin-top: 18px;
    border: 1px solid #71877a;
    background: #071311;
    image-rendering: pixelated;
  }
  canvas[hidden] {
    display: none;
  }
  #empty-board {
    margin-block: 18px;
    padding: 24px;
    border: 1px dashed var(--line);
  }
  .legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font:
      11px 'Field Kit Mono',
      monospace;
    color: var(--accent);
  }
  .legend[hidden] {
    display: none;
  }
  .toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 44px;
  }
  .toggle input {
    width: 20px;
    height: 20px;
    margin: 0;
    accent-color: var(--accent);
  }
  .note,
  .preview-actions span,
  footer {
    color: var(--muted);
    font-size: 12px;
  }
  fieldset {
    padding: 10px 14px 16px;
    border: 1px solid var(--line);
  }
  legend {
    color: var(--accent);
    font-size: 12px;
  }
  .coordinates {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
  }
  details {
    border-block: 1px solid var(--line);
    margin: 20px 0;
    padding: 12px 0;
  }
  summary {
    cursor: pointer;
    font-size: 12px;
    min-height: 44px;
    padding-block: 12px;
  }
  .community-guide-copy {
    max-width: 72ch;
  }
  .community-guide-copy h2 {
    margin-top: 24px;
  }
  pre,
  textarea {
    font:
      11px/1.6 'Field Kit Mono',
      monospace;
  }
  pre {
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    max-height: 350px;
    overflow: auto;
  }
  textarea {
    min-height: 430px;
    resize: vertical;
  }
  #diagnostics {
    padding-left: 18px;
    font-size: 12px;
  }
  #preview-panel {
    margin-top: 32px;
  }
  iframe {
    width: 100%;
    height: min(720px, calc(100vh - 4px));
    height: min(720px, calc(100dvh - 4px));
    border: 1px solid var(--line);
  }
  footer {
    border-top: 1px solid var(--line);
    margin-top: 24px;
    padding-top: 16px;
  }
  @media (max-width: 1180px) {
    .workspace {
      grid-template-columns: 200px 1fr;
    }
    .source-panel {
      grid-column: 1 / -1;
      border-top: 1px solid var(--line);
      border-left: none;
      padding-inline: 0;
    }
    textarea {
      min-height: 250px;
    }
  }
  @media (max-width: 650px) {
    header {
      flex-wrap: wrap;
    }
    header span {
      display: none;
    }
    .edition {
      display: none;
    }
    .workspace {
      display: block;
    }
    aside,
    .board-panel {
      border: 0;
      padding-inline: 0;
    }
    aside {
      border-bottom: 1px solid var(--line);
    }
    .coordinates {
      gap: 6px;
    }
    iframe {
      height: 620px;
    }
  }

  /* Native validation selects the control; nearest reveal also includes its label. */
  #timed-bonus-form label,
  #timed-bonus-form input,
  #timed-bonus-form select,
  #timed-bonus-form textarea {
    scroll-margin: 8px;
  }
  /* The same data remains an ordered, keyboard-readable list in every exhibit. */
  .discovery-exhibit {
    padding-left: 1.5rem;
  }
  .discovery-exhibit li {
    padding: 0.8rem;
    border: 1px solid currentColor;
    border-radius: 0.6rem;
    margin-bottom: 0.7rem;
  }
  .discovery-exhibit small {
    display: block;
    margin-top: 0.35rem;
  }
  .discovery-exhibit-gallery,
  .discovery-exhibit-mosaic {
    display: grid;
    gap: 0.7rem;
    grid-template-columns: repeat(auto-fit, minmax(min(100%, 14rem), 1fr));
  }
  .discovery-exhibit-mosaic li:nth-child(3n) {
    border-width: 3px;
  }
  #discovery-tools {
    display: grid;
    gap: 0.75rem;
  }
  #discovery-tools label {
    display: grid;
    gap: 0.3rem;
  }

  .studio-source-discard {
    max-width: min(36rem, calc(100vw - 32px));
    color: var(--ink);
    background: var(--paper);
    border: 2px solid currentColor;
    padding: 24px;
  }
  .studio-source-discard::backdrop {
    background: #000b;
  }
  .studio-source-discard h2 {
    margin: 0 0 20px;
    font-size: 1.1rem;
  }
  .studio-source-discard button + button {
    margin-inline-start: 12px;
  }
}
