:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0c1017;
  color: #edf0f5;
  --panel: #161c26;
  --line: #303a49;
  --muted: #a5afbf;
  --accent: #f0c86f;
}
* { box-sizing: border-box; }
body { margin: 0; padding: 24px; }
button, select, input { font: inherit; }
button, select, input { min-height: 44px; border: 1px solid var(--line); border-radius: 10px; background: #202836; color: inherit; }
button { cursor: pointer; touch-action: manipulation; }
button:hover:not(:disabled) { border-color: var(--accent); background: #2b3546; }
button:disabled, input:disabled { opacity: .45; cursor: not-allowed; }
button:focus-visible, select:focus-visible, input:focus-visible, summary:focus-visible, a:focus-visible { outline: 3px solid var(--accent); outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1 { font-size: clamp(1.35rem, 3vw, 1.75rem); letter-spacing: -.035em; }
h2 { font-size: 1rem; font-weight: 650; }
.page-header, .workspace, footer { max-width: 1060px; margin-inline: auto; }
.page-header { display: flex; gap: 14px; align-items: center; margin-bottom: 24px; }
.page-header p { margin-top: 4px; font-size: .85rem; color: var(--muted); }
.brand { flex-shrink: 0; }
.workspace { display: grid; grid-template-columns: 310px minmax(0, 1fr); gap: 18px; align-items: start; }
.preview-panel, .panel { border: 1px solid var(--line); border-radius: 16px; background: var(--panel); padding: 20px; }
.preview-panel { position: sticky; top: 20px; }
.panel-heading { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 16px; }
.panel-heading h2 { display: flex; align-items: center; gap: 9px; }
.badge { font-size: .65rem; color: var(--accent); border: 1px solid #5a4b2e; border-radius: 20px; padding: 4px 8px; white-space: nowrap; }
.preview-stage { display: grid; place-items: center; min-height: 203px; border: 1px solid #28303d; border-radius: 12px; background-color: #1d2531; background-image: linear-gradient(45deg, #242d3b 25%, transparent 25%), linear-gradient(-45deg, #242d3b 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #242d3b 75%), linear-gradient(-45deg, transparent 75%, #242d3b 75%); background-size: 24px 24px; background-position: 0 0, 0 12px, 12px -12px, -12px 0; overflow: hidden; }
#preview { width: 136.5px; height: 155.4px; max-width: 100%; object-fit: contain; grid-area: 1 / 1; }
#loading { grid-area: 1 / 1; padding: 10px; border-radius: 8px; background: #131820; color: var(--muted); font-size: .85rem; }
[hidden] { display: none !important; }
.code-controls { margin-top: 18px; display: grid; gap: 8px; min-width: 0; }
.code-controls label { font-size: .85rem; font-weight: 650; }
#banner-code { width: 100%; min-width: 0; padding: 8px 10px; font-family: ui-monospace, Consolas, monospace; font-size: 1.25rem; letter-spacing: .12em; text-align: center; }
#banner-code[aria-invalid="true"] { border-color: #ff9c9c; }
.field-help, .field-error { font-size: .7rem; line-height: 1.4; }
.field-help { color: var(--muted); }
.field-error { color: #ff9c9c; }
.export-controls { margin-top: 18px; min-width: 0; }
.export-controls summary { min-height: 44px; padding-block: 12px; cursor: pointer; font-size: .75rem; color: var(--muted); }
.export-options { display: grid; gap: 8px; }
.export-controls label { font-size: .75rem; color: var(--muted); }
.export-controls select { width: 100%; padding: 8px 12px; }
.primary { background: var(--accent); color: #201b10; border-color: var(--accent); font-weight: 700; width: 100%; }
.primary:hover:not(:disabled) { background: #ffdc91; color: #201b10; }
.quick-actions { display: flex; gap: 6px; margin-top: 10px; }
.quick-actions button { flex: 1; padding: 8px 5px; font-size: .75rem; white-space: nowrap; }
.status { min-height: 36px; margin-top: 14px; font-size: .75rem; color: var(--muted); line-height: 1.5; overflow-wrap: anywhere; }
.status a { color: var(--accent); }
.editor { display: grid; gap: 16px; min-width: 0; }
.step { display: inline-grid; place-items: center; width: 24px; height: 24px; border-radius: 7px; background: #293343; color: var(--accent); font-size: .75rem; }
.selection-summary, .optional { color: var(--muted); font-size: .75rem; font-weight: 400; }
.shape-grid, .icon-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(54px, 1fr)); gap: 8px; }
.art-choice { display: grid; place-items: center; height: 64px; padding: 5px; overflow: hidden; }
.art-choice img { width: 100%; height: 100%; object-fit: contain; }
.shape-grid .art-choice { height: 74px; }
.art-choice[aria-pressed="true"] { background: #353427; border: 2px solid var(--accent); box-shadow: 0 0 0 1px #f0c86f30; }
.none-icon { font-size: .72rem; color: var(--muted); }
.colour-field { border: 0; padding: 0; margin: 16px 0 0; min-inline-size: 0; }
.colour-field legend { margin-bottom: 10px; padding: 0; font-size: .85rem; font-weight: 550; }
.colour-field legend span { color: var(--muted); font-size: .7rem; font-weight: 400; margin-left: 8px; }
.palette { display: grid; grid-template-columns: repeat(10, minmax(0, 1fr)); gap: 8px; }
.swatch { position: relative; min-height: 44px; padding: 0; background: var(--swatch); border: 2px solid transparent; border-radius: 9px; }
.swatch:hover:not(:disabled) { background: var(--swatch); }
.swatch[aria-pressed="true"] { outline: 2px solid var(--accent); outline-offset: 2px; border-color: #161c26; }
.swatch[aria-pressed="true"]::after { content: "✓"; display: grid; place-items: center; color: #fff; text-shadow: 0 1px 3px #000, 0 0 3px #000; font-weight: 800; font-size: 1.2rem; }
.text-button { min-height: 44px; padding: 5px 10px; font-size: .75rem; color: var(--accent); background: transparent; }
#icon-colour-field:disabled { opacity: .45; }
footer { margin-top: 24px; text-align: center; font-size: .75rem; color: var(--muted); line-height: 1.6; }
noscript { display: block; margin: 20px auto; text-align: center; }
@media (max-width: 760px) {
  body { padding: 14px; }
  .page-header { margin-bottom: 16px; }
  .workspace { display: flex; flex-direction: column; gap: 14px; }
  .preview-panel, .editor { width: 100%; }
  .preview-panel { position: sticky; top: 8px; z-index: 2; display: grid; grid-template-columns: minmax(100px, 1fr) minmax(140px, 1fr); gap: 8px; padding: 12px; box-shadow: 0 8px 24px #0005; }
  .preview-panel .panel-heading { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
  .preview-stage { min-height: 103.6px; }
  #preview { width: 91px; height: 103.6px; }
  .code-controls { margin: 0; gap: 4px; }
  .export-controls { margin: 0; }
  .export-controls select { font-size: .75rem; padding: 8px; }
  .quick-actions { margin: 0; gap: 4px; align-self: start; }
  .quick-actions button { flex: 1 1 0; min-width: 44px; padding: 4px; font-size: .65rem; white-space: normal; }
  .status { grid-column: 1 / -1; margin: 0; min-height: 18px; }
  html { scroll-padding-top: var(--preview-clearance, 300px); }
  .panel { padding: 16px; }
  .palette { grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
  .shape-grid, .icon-grid { grid-template-columns: repeat(auto-fill, minmax(48px, 1fr)); gap: 7px; }
  .shape-grid .art-choice { height: 64px; }
  .art-choice { height: 54px; }
  .panel-heading { margin-bottom: 14px; }
  footer { font-size: .7rem; }
}
@media (max-width: 360px) {
  .palette { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: no-preference) {
  button { transition: background-color .12s, border-color .12s; }
}
.guild { max-width: 1060px; margin: 24px auto 0; min-width: 0; overflow-wrap: anywhere; }
.guild h2, .guild h3 { margin-bottom: 12px; }
.trust-warning { margin: 12px 0; padding: 12px; border-left: 3px solid var(--accent); background: #29251c; font-size: .8rem; line-height: 1.6; }
.guild-form { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 220px), 1fr)); gap: 10px; align-items: end; margin: 16px 0; }
.guild-form label { display: grid; gap: 6px; font-size: .8rem; min-width: 0; }
.guild input, .guild select { width: 100%; min-width: 0; padding: 8px; }
.guild button { padding: 8px 12px; font-size: .8rem; }
.guild-actions { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0; }
.guild-actions button { flex: 1 1 160px; }
.candidate-gallery { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 210px), 1fr)); gap: 14px; margin-top: 18px; }
.candidate-card { min-width: 0; padding: 14px; border: 1px solid var(--line); border-radius: 12px; background: #111720; display: grid; gap: 10px; }
.candidate-canvas { width: 78px; height: 88.8px; margin-inline: auto; }
.candidate-code { font-size: 1rem; font-family: ui-monospace, Consolas, monospace; color: var(--accent); }
.vote-choice { display: flex; align-items: center; gap: 8px; min-height: 44px; font-size: .85rem; }
.vote-choice input { width: 24px; min-height: 24px; height: 24px; flex-shrink: 0; }
.admin-panel { margin-top: 22px; border-top: 1px solid var(--line); padding-top: 12px; }
.admin-panel summary { min-height: 44px; padding-block: 12px; cursor: pointer; }
.candidate-history { list-style: none; padding: 0; display: grid; gap: 10px; }
.history-event { border: 1px solid var(--line); padding: 12px; border-radius: 10px; display: flex; flex-wrap: wrap; gap: 12px; align-items: center; }
.history-event .candidate-canvas { margin: 0; width: 52px; height: 59.2px; }
.history-description { flex: 1 1 190px; min-width: 0; font-size: .8rem; line-height: 1.6; }
#recovery-conflicts { color: #ff9c9c; font-size: .8rem; line-height: 1.6; }
.guild .field-help { font-size: .8rem; line-height: 1.6; }
@media (max-width: 760px) {
  .guild { padding: 14px; }
  .guild-form { grid-template-columns: 1fr; }
  .candidate-gallery { grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); }
}
