/* Warm parchment-on-wood palette, close to the game's own Pro mode window. */
:root {
  --bg: #2a1d12;
  --panel: #3a2818;
  --panel-2: #24180f;
  --line: #5a4026;
  --text: #f1e4cc;
  --muted: #bda98a;
  --gold: #f0c860;
  --gold-dim: #b8913c;
  --ok: #8fcf7a;
  --warn: #f0b04a;
  --err: #ff7f6e;
  --info: #8fbbe8;
  --code-bg: #1a110a;
  --radius: 6px;
  --font: "Segoe UI", system-ui, -apple-system, sans-serif;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, monospace;
}

* { box-sizing: border-box; }

html { scrollbar-color: var(--line) var(--panel-2); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 14px/1.45 var(--font);
}

button, input, select, textarea { font: inherit; color: inherit; }

code, pre, textarea.code { font-family: var(--mono); }

code {
  background: var(--code-bg);
  border-radius: 3px;
  padding: 0 4px;
  color: var(--gold);
}

pre {
  background: var(--code-bg);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px 10px;
  margin: 6px 0;
  overflow-x: auto;
  white-space: pre;
}

/* ---- Header ---- */
.top {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  padding: 10px 16px;
  background: var(--panel-2);
  border-bottom: 2px solid var(--line);
}
.top h1 { margin: 0; font-size: 20px; color: var(--gold); }
.top .sub { font-size: 13px; color: var(--muted); font-weight: normal; }
.top .sub a, .linklike { color: var(--gold); }
.linklike {
  background: none;
  border: none;
  padding: 0;
  font: inherit;
  text-decoration: underline dotted;
  cursor: pointer;
}

/* ---- Not-affiliated notice ---- */
dialog.about {
  max-width: min(520px, calc(100vw - 32px));
  background: var(--panel);
  color: var(--text);
  border: 2px solid var(--gold-dim);
  border-radius: var(--radius);
  padding: 18px 20px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .6);
}
dialog.about::backdrop { background: rgba(20, 12, 6, .75); }
dialog.about h2 { margin: 0 0 10px; color: var(--gold); font-size: 18px; }
dialog.about p { margin: 0 0 10px; }
dialog.about a { color: var(--gold); }
dialog.about .about-note { color: var(--muted); font-size: 13px; }
.about-actions { display: flex; justify-content: flex-end; margin-top: 14px; }

.tabs { display: flex; gap: 4px; }
.tabs button {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 14px;
  cursor: pointer;
}
.tabs button[aria-selected="true"] { border-color: var(--gold); color: var(--gold); }

/* ---- Workspace: palette | blocks | output ---- */
.workspace {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 380px;
  gap: 12px;
  padding: 12px 16px;
  align-items: start;
}
.workspace[hidden], .reference[hidden] { display: none; }

.palette, .output {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 10px;
}

.palette h3, .output h3 {
  margin: 12px 0 6px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--gold-dim);
}
.palette h3:first-child, .output h3:first-child { margin-top: 0; }

.palette .pal-list { display: flex; flex-wrap: wrap; gap: 4px; }
.pal-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 3px 7px;
  cursor: pointer;
  font-family: var(--mono);
  font-size: 12.5px;
}
.pal-btn:hover { border-color: var(--gold); color: var(--gold); }
.pal-btn.recipe { font-family: var(--font); width: 100%; text-align: left; }
.pal-filter { width: 100%; margin-bottom: 8px; }

/* ---- Blocks ---- */
.blocks { display: flex; flex-direction: column; gap: 10px; min-width: 0; }

.empty {
  border: 2px dashed var(--line);
  border-radius: var(--radius);
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.block {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 4px solid var(--gold-dim);
  border-radius: var(--radius);
  padding: 10px 12px;
}
.block.disabled { opacity: .55; border-left-color: var(--line); }
.block.has-error { border-left-color: var(--err); }
.block.has-warn { border-left-color: var(--warn); }

.block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.block-head .kw { font-family: var(--mono); font-weight: bold; color: var(--gold); font-size: 15px; }
.block-head .summary { color: var(--muted); font-size: 12.5px; flex: 1 1 200px; }
.block-head .actions { display: flex; gap: 4px; margin-left: auto; }
.icon-btn {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  min-width: 28px;
  height: 26px;
  cursor: pointer;
  padding: 0 6px;
}
.icon-btn:hover { border-color: var(--gold); }
.icon-btn.danger:hover { border-color: var(--err); color: var(--err); }

.block-line {
  margin-top: 8px;
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 4px 8px;
  white-space: pre-wrap;
  word-break: break-all;
  color: var(--ok);
}
.block-line.incomplete { color: var(--muted); font-style: italic; }

.issues { margin: 6px 0 0; padding: 0; list-style: none; font-size: 12.5px; }
.issues li { padding: 2px 0 2px 18px; position: relative; }
.issues li::before { position: absolute; left: 0; }
.issues .error { color: var(--err); }
.issues .error::before { content: "✖"; }
.issues .warn { color: var(--warn); }
.issues .warn::before { content: "▲"; }
.issues .info { color: var(--info); }
.issues .info::before { content: "ℹ"; }

/* ---- Forms ---- */
.fields { display: flex; flex-wrap: wrap; gap: 8px 14px; margin-top: 8px; align-items: flex-end; }
.field { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.field.wide { flex: 1 1 100%; }
.field > label, .field > .lbl { font-size: 12px; color: var(--muted); }
.field .hint { font-size: 11.5px; color: var(--muted); }

input[type="text"], input[type="number"], input[type="search"], select, textarea {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 4px 6px;
  min-width: 0;
}
input:focus, select:focus, textarea:focus { outline: 1px solid var(--gold); border-color: var(--gold); }
input[type="number"] { width: 78px; }
input.bad { border-color: var(--err); }
textarea { width: 100%; resize: vertical; }

.rows { display: flex; flex-direction: column; gap: 4px; }
.row { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.row .drag { color: var(--muted); font-size: 11px; width: 18px; text-align: right; }
.add-row {
  align-self: flex-start;
  background: none;
  border: 1px dashed var(--line);
  border-radius: 4px;
  padding: 2px 8px;
  cursor: pointer;
  color: var(--muted);
}
.add-row:hover { color: var(--gold); border-color: var(--gold); }

.checks { display: flex; flex-wrap: wrap; gap: 4px; }
.check-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 2px 9px;
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
}
.check-pill input { margin: 0; accent-color: var(--gold); }
.check-pill:has(input:checked) { border-color: var(--gold); color: var(--gold); }

.chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 3px; }
.chip {
  background: none;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0 8px;
  font-size: 11.5px;
  cursor: pointer;
  color: var(--muted);
  font-family: var(--mono);
}
.chip:hover { color: var(--gold); border-color: var(--gold); }

.switch { display: inline-flex; gap: 6px; align-items: center; cursor: pointer; }
.switch input { accent-color: var(--gold); width: 16px; height: 16px; }
.switch input[type="number"] { width: 60px; height: auto; flex-shrink: 0; }
.palette, .output { scrollbar-color: var(--line) var(--panel); }

/* ---- Guide drawer inside a block ---- */
details.guide { margin-top: 8px; font-size: 13px; }
details.guide summary { cursor: pointer; color: var(--gold-dim); font-size: 12.5px; }
details.guide[open] summary { margin-bottom: 4px; }
details.guide dl { margin: 4px 0; }
details.guide dt { font-family: var(--mono); color: var(--gold); }
details.guide dd { margin: 0 0 4px 14px; }
details.guide ul { margin: 4px 0; padding-left: 18px; }
.ex { display: flex; gap: 6px; align-items: flex-start; }
.ex pre { flex: 1; margin: 3px 0; }
.ex-note { color: var(--muted); font-size: 12.5px; margin: 0 0 6px; }

/* ---- Output panel ---- */
.output textarea.code {
  min-height: 260px;
  font-size: 12.5px;
  background: var(--code-bg);
  color: var(--ok);
  white-space: pre;
}
.out-actions { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0; }
.btn {
  background: var(--panel-2);
  border: 1px solid var(--gold-dim);
  border-radius: 4px;
  padding: 5px 12px;
  cursor: pointer;
}
.btn.primary { background: var(--gold-dim); color: #20140a; font-weight: 600; border-color: var(--gold); }
.btn:hover { border-color: var(--gold); }
.btn.danger:hover { border-color: var(--err); color: var(--err); }
.stat { color: var(--muted); font-size: 12px; }
.toast { color: var(--ok); font-size: 12.5px; min-height: 1.2em; }

.settings { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.preset-box {
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  margin-top: 6px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.preset-box .fields { margin-top: 0; }
.preset-box input[type="number"] { width: 60px; }

/* ---- Reference ---- */
.reference { padding: 12px 16px; }
.ref-bar input { width: 100%; max-width: 560px; padding: 7px 10px; }
.ref-layout { display: grid; grid-template-columns: 220px minmax(0, 1fr); gap: 16px; margin-top: 12px; }
.ref-nav {
  position: sticky;
  top: 12px;
  max-height: calc(100vh - 24px);
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 8px;
  font-size: 13px;
}
.ref-nav a { display: block; color: var(--text); text-decoration: none; padding: 1px 4px; border-radius: 3px; }
.ref-nav a:hover { background: var(--panel-2); color: var(--gold); }
.ref-nav h4 { margin: 10px 0 4px; font-size: 12px; color: var(--gold-dim); text-transform: uppercase; }
.ref-body { min-width: 0; }
.ref-page {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 12px 16px;
  margin-bottom: 12px;
}
.ref-page h2 { margin: 0 0 4px; color: var(--gold); font-family: var(--mono); }
.ref-page h4 { margin: 12px 0 4px; color: var(--gold-dim); }
.ref-page dt { font-family: var(--mono); color: var(--gold); }
.ref-page dd { margin: 0 0 6px 16px; }
.ref-page ul { padding-left: 20px; }
.shortname-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 10px; }
.shortname-grid table { width: 100%; border-collapse: collapse; font-size: 13px; }
.shortname-grid td { border-bottom: 1px solid var(--line); padding: 2px 4px; }
.shortname-grid td:last-child { font-family: var(--mono); color: var(--gold); text-align: right; }

/* ---- Narrow screens ---- */
@media (max-width: 1100px) {
  .workspace { grid-template-columns: 220px minmax(0, 1fr); }
  .output { grid-column: 1 / -1; position: static; max-height: none; }
}
@media (max-width: 720px) {
  .workspace, .ref-layout { grid-template-columns: minmax(0, 1fr); padding: 10px 16px; }
  .palette, .ref-nav { position: static; max-height: 320px; }
  .top { padding: 10px 16px; }
}
