* { box-sizing: border-box; }
:root {
  --bg: #0e1116;
  --panel: #161b22;
  --panel-2: #1c232c;
  --border: #30363d;
  --text: #e6edf3;
  --muted: #9aa4b2;
  --gold: #c9a227;
  --gold-2: #e0c36a;
  --accent: #4aa3a2;
  --danger: #e35d6a;
  --ok: #3cb371;
  --shadow: 0 10px 40px rgba(0,0,0,.35);
  --radius: 14px;
}
html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(1200px 500px at 10% -10%, rgba(201,162,39,.12), transparent 50%),
    radial-gradient(900px 400px at 100% 0%, rgba(74,163,162,.10), transparent 45%),
    var(--bg);
  color: var(--text);
  font-family: "Source Sans 3", "Segoe UI", sans-serif;
}
body.embed .top,
body.embed .form-panel,
body.embed .log-panel,
body.embed .stub-note,
body.embed .legend { display: none !important; }
body.embed { background: #0b0e13; }
body.embed .layout { display: block; padding: 0; }
body.embed .preview-panel {
  margin: 0;
  border: 0;
  border-radius: 0;
  min-height: 100vh;
  box-shadow: none;
}
body.embed .viewport { height: 100vh; min-height: 100vh; }
body.embed .preview-toolbar { display: none; }

.top {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  padding: 22px 28px 10px;
}
.brand { display: flex; gap: 14px; align-items: center; }
.mark {
  width: 42px; height: 42px; border-radius: 10px;
  background:
    linear-gradient(135deg, var(--gold) 0%, #7a5a12 55%, var(--accent) 130%);
  box-shadow: 0 0 0 1px rgba(201,162,39,.4), var(--shadow);
}
h1 {
  font-family: Cinzel, Georgia, serif;
  font-weight: 700;
  letter-spacing: .04em;
  margin: 0;
  font-size: 1.55rem;
}
.tag { margin: 2px 0 0; color: var(--muted); font-size: .92rem; }
.stub-note {
  max-width: 560px;
  margin: 0;
  color: var(--muted);
  font-size: .8rem;
  line-height: 1.45;
}
.layout {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  padding: 10px 28px 18px;
}
@media (max-width: 960px) {
  .layout { grid-template-columns: 1fr; }
  .top { flex-direction: column; }
}
.panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px 18px 16px;
}
h2 { margin: 0 0 12px; font-size: 1.05rem; font-weight: 600; }
label { display: block; margin-bottom: 12px; }
label > span { display: block; color: var(--muted); font-size: .82rem; margin-bottom: 4px; }
input[type="file"], select, textarea, button {
  font: inherit;
}
textarea, select, input[type="file"] {
  width: 100%;
  background: var(--panel-2);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
}
textarea { resize: vertical; }
button, .download {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  background: linear-gradient(180deg, var(--gold-2), var(--gold));
  color: #1a1406;
  font-weight: 700;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  cursor: pointer;
  text-decoration: none;
}
button:disabled { opacity: .55; cursor: default; }
button.ghost, .ghost {
  width: auto;
  background: transparent;
  color: var(--text);
  border: 1px solid var(--border);
  font-weight: 500;
  padding: 5px 10px;
  border-radius: 8px;
  cursor: pointer;
}
.image-preview { margin: -4px 0 12px; }
.image-preview img { max-width: 100%; max-height: 90px; border-radius: 8px; border: 1px solid var(--border); }
.hidden { display: none !important; }
.progress {
  list-style: none;
  padding: 8px 0 0;
  margin: 8px 0 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.progress li {
  font-size: .75rem;
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px 9px;
}
.progress li.active { color: var(--gold-2); border-color: var(--gold); }
.progress li.done { color: var(--ok); border-color: #2e8b57; }
.progress li.failed { color: var(--danger); border-color: var(--danger); }
.error {
  margin-top: 12px;
  background: rgba(227,93,106,.12);
  border: 1px solid var(--danger);
  color: #ffd5d8;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: .9rem;
}
.result-meta { margin-top: 12px; color: var(--muted); font-size: .85rem; line-height: 1.45; }
.download { margin-top: 10px; }
.preview-panel { display: flex; flex-direction: column; min-height: 560px; }
.preview-toolbar { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.tools { display: flex; gap: 10px; align-items: center; }
.inline { display: flex; gap: 6px; align-items: center; font-size: .85rem; color: var(--muted); margin: 0; }
.viewport {
  position: relative;
  flex: 1;
  min-height: 480px;
  margin-top: 8px;
  background: #0b0e13;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid var(--border);
}
.viewport canvas { display: block; width: 100%; height: 100%; }
.empty-hint {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
  padding: 24px;
  text-align: center;
}
.legend {
  list-style: none;
  display: flex;
  gap: 16px;
  padding: 8px 0 0;
  margin: 0;
  color: var(--muted);
  font-size: .85rem;
}
.swatch { display: inline-block; width: 10px; height: 10px; border-radius: 2px; margin-right: 6px; }
.swatch.entry { background: #3cb371; }
.swatch.station { background: #e08a2c; }
.swatch.npc { background: #4aa3e0; }
.log-panel { margin: 0 28px 28px; }
.log-head { display: flex; justify-content: space-between; align-items: center; }
.job-log {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .8rem;
  background: #0b0e13;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
  min-height: 4.5rem;
  white-space: pre-wrap;
  color: #c6d0db;
  margin-bottom: 12px;
}
.table-wrap { overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: .82rem; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid var(--border); }
th { color: var(--muted); font-weight: 600; }
td.pass { color: var(--ok); }
td.fail { color: var(--danger); }

.field-hint {
  margin: 0 0 1rem;
  font-size: 0.85rem;
  line-height: 1.4;
  opacity: 0.8;
}


.prefab-lib { margin: 1.25rem 0 0; padding-top: 1rem; border-top: 1px solid var(--border); }
.prefab-lib h3 { margin: 0 0 .5rem; font-size: 1rem; }
.prefab-search { display: flex; gap: .5rem; margin-bottom: .5rem; }
.prefab-search input, .prefab-search select { flex: 1; }
.prefab-results { list-style: none; margin: 0; padding: 0; max-height: 16rem; overflow: auto; }
.prefab-results li {
  display: flex; justify-content: space-between; gap: .75rem; align-items: flex-start;
  padding: .45rem 0; border-bottom: 1px solid var(--border);
}
.prefab-results .meta { color: var(--muted); font-size: .8rem; }
.prefab-results button { flex: 0 0 auto; }
.prefab-hint { margin: .35rem 0 0; font-size: .8rem; color: var(--muted); }
