/* =========================================================================
   PokeQuests Quest Builder — DARK MODE
   Aesthetic: deep navy / charcoal with a single Poké-Ball-red accent and
   warm amber for highlights. Reads as a "professional dev tool" rather
   than a toy. Subtle Pokémon DNA without being kitsch.
   ========================================================================= */

:root {
  /* Background system — layered dark surfaces */
  --bg-base:        #0f1419;     /* deepest — page background */
  --bg-surface:     #161c24;     /* main canvas surface */
  --bg-raised:      #1d2530;     /* cards, raised panels */
  --bg-input:       #0c1116;     /* recessed surfaces (inputs, code) */
  --bg-hover:       #243040;     /* hover state for interactive surfaces */

  /* Borders — subtle warm tints to separate dark surfaces */
  --border:         rgba(255, 255, 255, 0.06);
  --border-strong:  rgba(255, 255, 255, 0.12);
  --border-focus:   rgba(229, 90, 90, 0.55);  /* Poké-Ball red */

  /* Text — warm whites */
  --text-primary:   #e8eaed;
  --text-secondary: #9ba4b0;
  --text-muted:     #6b7684;
  --text-on-accent: #0f1419;

  /* Accents */
  --accent-primary:  #e55a5a;     /* Poké-Ball red — used sparingly for active state */
  --accent-primary-hover: #f06b6b;
  --accent-amber:    #f0a83a;     /* warm gold — section headers, highlights */
  --accent-electric: #fcd23f;     /* electric yellow — numbers, electric tint */
  --accent-moss:     #6cb557;     /* OK / success */
  --accent-mint:     #4ec5c5;     /* secondary action */
  --accent-rose:     #e8506e;     /* errors */

  /* Layout */
  --rail-w:    240px;
  --preview-w: 460px;
  --topbar-h:  64px;

  /* Fonts */
  --f-display: 'Cormorant Garamond', 'Iowan Old Style', Georgia, serif;
  --f-body:    'Inter', system-ui, -apple-system, sans-serif;
  --f-mono:    'JetBrains Mono', 'SF Mono', Menlo, monospace;

  /* Effects */
  --shadow-soft:   0 1px 0 rgba(255,255,255,.04) inset, 0 1px 2px rgba(0,0,0,.4);
  --shadow-deep:   0 24px 48px -16px rgba(0,0,0,.6), 0 4px 12px rgba(0,0,0,.3);
  --shadow-glow:   0 0 0 3px rgba(229, 90, 90, 0.18);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  font-family: var(--f-body);
  background: var(--bg-base);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.55;
  font-feature-settings: 'cv11', 'ss01';
}

/* Background texture: subtle diagonal stripes + a vignette
   inspired by Pokéball halves but extremely understated. */
.bg-grain {
  position: fixed; inset: 0;
  pointer-events: none; z-index: 0;
  background:
    radial-gradient(circle at 100% 0%, rgba(229, 90, 90, 0.06), transparent 50%),
    radial-gradient(circle at 0% 100%, rgba(76, 197, 197, 0.04), transparent 50%),
    repeating-linear-gradient(
      135deg,
      transparent 0,
      transparent 4px,
      rgba(255, 255, 255, 0.012) 4px,
      rgba(255, 255, 255, 0.012) 5px
    );
}

/* =====================================================================
   Top bar
   ===================================================================== */

.topbar {
  position: sticky; top: 0; z-index: 50;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  background: rgba(15, 20, 25, 0.85);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 38px; height: 38px;
  background: linear-gradient(180deg, var(--accent-primary) 0%, var(--accent-primary) 50%, #1a1f26 50%, #1a1f26 100%);
  color: white;
  border-radius: 50%;
  font-size: 0;
  border: 2px solid var(--bg-raised);
  position: relative;
  box-shadow: var(--shadow-soft);
}
/* Pokéball center button */
.brand-mark::after {
  content: '';
  position: absolute;
  width: 10px; height: 10px;
  border-radius: 50%;
  background: var(--bg-raised);
  border: 2px solid var(--text-primary);
}

.brand-text h1 {
  margin: 0;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 22px;
  line-height: 1;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.brand-text p {
  margin: 2px 0 0;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--text-muted);
}

.topbar-actions { display: flex; gap: 8px; }

.btn {
  appearance: none; border: none; cursor: pointer;
  font: 500 13px/1 var(--f-body);
  padding: 9px 16px;
  border-radius: 4px;
  display: inline-flex; align-items: center; gap: 8px;
  transition: transform .15s, box-shadow .15s, background .15s, border-color .15s;
}
.btn-primary {
  background: var(--accent-primary);
  color: white;
  box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 4px 12px rgba(229, 90, 90, .3);
}
.btn-primary:hover {
  background: var(--accent-primary-hover);
  transform: translateY(-1px);
  box-shadow: 0 1px 0 rgba(255,255,255,.2) inset, 0 6px 16px rgba(229, 90, 90, .4);
}
.btn-ghost {
  background: var(--bg-raised);
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}
.btn-ico { font-size: 14px; opacity: .8; }
.btn:disabled { opacity: .35; cursor: not-allowed; transform: none !important; }

.btn-mini {
  appearance: none; background: transparent;
  border: 1px solid var(--border-strong);
  font: 500 11px/1 var(--f-body);
  text-transform: uppercase; letter-spacing: .12em;
  padding: 6px 12px;
  border-radius: 3px;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all .15s;
}
.btn-mini:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent-primary);
}

/* Danger variant for destructive actions (delete role, drop section, etc.) */
.btn-mini.btn-danger {
  border-color: var(--accent-rose);
  color: var(--accent-rose);
}
.btn-mini.btn-danger:hover {
  background: rgba(232, 80, 110, 0.12);
  border-color: var(--accent-rose);
  color: var(--accent-rose);
}

/* Inline hint paragraph — used for explanatory text under section headers */
.hint {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.55;
  margin: 8px 0;
}
.hint code {
  font-family: var(--f-mono, monospace);
  font-size: 11px;
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 2px;
  color: var(--text-primary);
}
.hint.warn {
  color: var(--accent-amber);
}
.hint.warn code {
  color: var(--accent-amber);
  background: rgba(240, 168, 58, 0.08);
}

/* =====================================================================
   Layout
   ===================================================================== */

.layout {
  display: grid;
  grid-template-columns: var(--rail-w) 1fr var(--preview-w);
  gap: 0;
  min-height: calc(100vh - var(--topbar-h));
  position: relative; z-index: 1;
}

/* Rail (left navigation) */
.rail {
  border-right: 1px solid var(--border);
  background: var(--bg-surface);
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
}
.rail-inner { padding: 22px 16px; height: 100%; display: flex; flex-direction: column; }
.rail-header {
  font: 600 10px/1 var(--f-body);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--text-muted);
  margin-bottom: 14px;
  padding: 0 8px;
}
.rail-steps {
  list-style: none; padding: 0; margin: 0;
  display: flex; flex-direction: column; gap: 1px;
  flex: 1;
}
.rail-steps li {
  padding: 11px 12px;
  border-radius: 4px;
  cursor: pointer;
  font-family: var(--f-display);
  font-size: 17px;
  display: flex; align-items: center; gap: 12px;
  color: var(--text-secondary);
  transition: background .12s, color .12s;
  border-left: 3px solid transparent;
  position: relative;
}
.rail-steps li:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}
.rail-steps li.active {
  background: var(--bg-raised);
  color: var(--text-primary);
  border-left-color: var(--accent-primary);
  box-shadow: var(--shadow-soft);
}
.rail-steps li.active .rail-num {
  background: var(--accent-primary);
  color: white;
}

.rail-num {
  font-family: var(--f-mono);
  font-size: 11px;
  font-weight: 600;
  width: 22px; height: 22px;
  display: inline-grid; place-items: center;
  background: rgba(255,255,255,.05);
  border-radius: 50%;
  color: var(--text-muted);
  transition: all .12s;
}

.rail-footer {
  margin-top: 24px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}
.rail-footer a {
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 12px;
  display: block;
  padding: 8px 8px;
  border-radius: 3px;
  transition: all .12s;
}
.rail-footer a:hover {
  background: var(--bg-hover);
  color: var(--accent-amber);
}
.rail-meta {
  margin: 8px 0 0; padding: 0 8px;
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-muted);
}

/* Canvas (main form area) */
.canvas {
  padding: 36px 48px;
  max-width: 920px;
  width: 100%;
  background: var(--bg-base);
}

/* Each step is a "panel" */
.panel { display: none; animation: fadeIn .25s ease-out; }
.panel.active { display: block; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.panel-head { margin-bottom: 28px; }
.panel-head h2 {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 36px;
  line-height: 1.1;
  margin: 0 0 4px;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}
.panel-head .step-num {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--accent-primary);
  text-transform: uppercase;
  letter-spacing: 0.24em;
  margin-bottom: 6px;
  display: block;
  font-weight: 600;
}
.panel-head p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
  max-width: 60ch;
}

/* Form fields */
.field { margin-bottom: 20px; }
.field label {
  display: block;
  font: 600 11px/1 var(--f-body);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--text-secondary);
  margin-bottom: 7px;
}
.field label .required { color: var(--accent-primary); margin-left: 3px; }
.field-hint {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 5px;
  line-height: 1.45;
}
.field-hint code {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--accent-amber);
  background: var(--bg-input);
  padding: 1px 5px;
  border-radius: 2px;
}
.field input[type="text"],
.field input[type="number"],
.field textarea,
.field select {
  width: 100%;
  font: 500 14px/1.5 var(--f-body);
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  color: var(--text-primary);
  transition: border .15s, background .15s, box-shadow .15s;
}
.field input:focus,
.field textarea:focus,
.field select:focus {
  outline: none;
  border-color: var(--accent-primary);
  background: #0a0e13;
  box-shadow: var(--shadow-glow);
}
.field input::placeholder, .field textarea::placeholder {
  color: var(--text-muted);
  opacity: .55;
}
.field textarea {
  font-family: var(--f-mono);
  font-size: 13px;
  min-height: 90px;
  resize: vertical;
  line-height: 1.55;
}
.field code { font-family: var(--f-mono); }

.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.field-row.three { grid-template-columns: 1fr 1fr 1fr; }
.field-row.four  { grid-template-columns: repeat(4, 1fr); }

.checkbox-field {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 4px;
  margin-bottom: 14px;
}
.checkbox-field input {
  width: 18px; height: 18px;
  accent-color: var(--accent-primary);
  cursor: pointer;
}
.checkbox-field label {
  margin: 0; text-transform: none; letter-spacing: 0;
  font-weight: 500; font-size: 13px;
  color: var(--text-primary); cursor: pointer;
}

/* Cards (stages, objectives, rewards) */
.card {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-amber);
  border-radius: 4px;
  padding: 22px;
  margin-bottom: 16px;
  position: relative;
  box-shadow: var(--shadow-soft);
}
.card-head {
  display: flex; align-items: baseline; justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--border);
}
.card-title {
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 22px;
  margin: 0;
  letter-spacing: -0.01em;
  color: var(--text-primary);
}
.card-title small {
  font-family: var(--f-mono);
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.15em;
  margin-left: 10px;
  font-weight: 400;
}
.card-actions { display: flex; gap: 4px; }

.btn-icon {
  appearance: none; border: none; background: transparent;
  width: 28px; height: 28px;
  display: inline-grid; place-items: center;
  border-radius: 3px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 16px;
  transition: background .12s, color .12s;
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon.danger:hover { background: var(--accent-rose); color: white; }

.add-row {
  display: flex; gap: 10px;
  padding: 14px;
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
  background: rgba(255,255,255,.015);
  margin-top: 10px;
}
.add-row select {
  flex: 1;
  font: 500 14px/1.4 var(--f-body);
  background: var(--bg-input);
  color: var(--text-primary);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 8px 12px;
  cursor: pointer;
}
.add-row select:focus { outline: none; border-color: var(--accent-primary); }
.add-row .btn { white-space: nowrap; }

.empty-note {
  text-align: center;
  padding: 32px 18px;
  color: var(--text-muted);
  font-style: italic;
  font-family: var(--f-display);
  font-size: 17px;
  background: rgba(255,255,255,.015);
  border: 1px dashed var(--border);
  border-radius: 4px;
}

.card.objective { border-left-color: var(--accent-mint); }
.card.reward    { border-left-color: var(--accent-electric); }

/* Sub-card (a card inside a card) */
.subcard {
  background: rgba(0,0,0,.25);
  border-left: 3px solid var(--border-strong);
  padding: 16px 18px;
  margin: 10px 0;
  border-radius: 3px;
}
.subcard-head {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 12px;
}
.subcard-title {
  font: 600 12px/1 var(--f-body);
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--accent-amber);
}
.subcard.objective { border-left-color: var(--accent-mint); }
.subcard.reward    { border-left-color: var(--accent-electric); }

/* Tag chips for list-of-strings */
.chip-input {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 4px;
  transition: border .15s, box-shadow .15s;
}
.chip-input:focus-within {
  border-color: var(--accent-primary);
  box-shadow: var(--shadow-glow);
}
.chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 9px;
  background: var(--accent-primary);
  color: white;
  border-radius: 3px;
  font-family: var(--f-mono);
  font-size: 12px;
  font-weight: 500;
}
.chip button {
  appearance: none; border: none; background: transparent;
  color: white; opacity: .7;
  cursor: pointer;
  font-size: 14px;
  padding: 0; line-height: 1;
}
.chip button:hover { opacity: 1; }
.chip-input input {
  flex: 1; min-width: 120px;
  border: none; background: transparent;
  outline: none;
  font: 500 13px/1 var(--f-mono);
  color: var(--text-primary);
  padding: 4px;
}

/* =====================================================================
   YAML preview pane
   ===================================================================== */

.preview {
  border-left: 1px solid var(--border);
  background: #07090c;
  color: var(--text-primary);
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  display: flex;
  flex-direction: column;
}
.preview-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,.02);
}
.preview-header h3 {
  margin: 0;
  font: 600 11px/1 var(--f-body);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  color: var(--accent-amber);
}
.yaml-out {
  flex: 1;
  margin: 0;
  padding: 20px;
  overflow: auto;
  font: 500 12px/1.65 var(--f-mono);
  color: var(--text-primary);
  background: transparent;
  white-space: pre-wrap;
  word-break: break-word;
}
.yaml-out code { font: inherit; background: transparent; }

/* YAML syntax colors — matched to the dark palette */
.y-key   { color: #82c8ff; }
.y-str   { color: #d8e9c8; }
.y-num   { color: var(--accent-electric); }
.y-bool  { color: var(--accent-primary); font-weight: 600; }
.y-comm  { color: var(--text-muted); font-style: italic; }
.y-list  { color: var(--accent-amber); font-weight: 600; }

.validation {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  display: flex; align-items: center; gap: 8px;
  font-family: var(--f-mono);
  background: rgba(0,0,0,.4);
}
.validation.ok    { color: var(--accent-moss); }
.validation.warn  { color: var(--accent-amber); }
.validation.err   { color: var(--accent-primary); }
.validation::before { content: '◯'; font-size: 13px; }
.validation.ok::before  { content: '●'; }
.validation.warn::before { content: '▲'; }
.validation.err::before  { content: '✕'; }

/* =====================================================================
   Reference panel (slide-in from right)
   ===================================================================== */

.ref-panel {
  position: fixed; top: 0; right: 0;
  width: min(720px, 100vw);
  height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border-strong);
  box-shadow: var(--shadow-deep);
  z-index: 200;
  transform: translateX(100%);
  transition: transform .35s cubic-bezier(.45,.05,.15,1);
  display: flex; flex-direction: column;
}
.ref-panel.open { transform: translateX(0); }

.ref-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 26px;
  border-bottom: 1px solid var(--border);
  background: rgba(0,0,0,.2);
}
.ref-head h2 {
  margin: 0;
  font-family: var(--f-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

.ref-body {
  flex: 1; overflow-y: auto;
  padding: 28px 32px;
  font-size: 13.5px;
  line-height: 1.7;
  color: var(--text-secondary);
}
.ref-body h1, .ref-body h2, .ref-body h3 {
  font-family: var(--f-display);
  letter-spacing: -0.01em;
  margin-top: 1.6em;
  color: var(--text-primary);
}
.ref-body h1 { font-size: 28px; margin-top: 0; }
.ref-body h2 {
  font-size: 22px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
  color: var(--accent-amber);
}
.ref-body h3 {
  font-size: 17px;
  color: var(--text-primary);
}
.ref-body p { margin: .9em 0; }
.ref-body strong { color: var(--text-primary); }
.ref-body a { color: var(--accent-mint); text-decoration: none; border-bottom: 1px solid transparent; }
.ref-body a:hover { border-bottom-color: var(--accent-mint); }
.ref-body code {
  font-family: var(--f-mono);
  font-size: 12px;
  background: var(--bg-input);
  color: var(--accent-amber);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
}
.ref-body pre {
  background: #07090c;
  color: var(--text-primary);
  padding: 16px 20px;
  border-radius: 4px;
  overflow: auto;
  font: 500 12px/1.6 var(--f-mono);
  border: 1px solid var(--border);
  margin: 14px 0;
}
.ref-body pre code {
  background: transparent;
  padding: 0;
  color: inherit;
  border: none;
}
.ref-body table {
  border-collapse: collapse;
  margin: 14px 0;
  font-size: 13px;
  width: 100%;
}
.ref-body th, .ref-body td {
  border: 1px solid var(--border);
  padding: 7px 12px;
  text-align: left;
}
.ref-body th {
  background: var(--bg-raised);
  font-weight: 600;
  color: var(--text-primary);
}
.ref-body td { color: var(--text-secondary); }
.ref-body ul, .ref-body ol {
  padding-left: 22px;
  margin: .8em 0;
}
.ref-body li { margin: .35em 0; }
.ref-body hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 28px 0;
}

/* =====================================================================
   Toasts
   ===================================================================== */

.toasts {
  position: fixed; bottom: 24px; right: 24px;
  display: flex; flex-direction: column; gap: 10px;
  z-index: 300;
}
.toast {
  background: var(--bg-raised);
  color: var(--text-primary);
  padding: 12px 18px;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  box-shadow: var(--shadow-deep);
  animation: toast-in .25s ease-out, toast-out .25s ease-in 3.5s forwards;
  border-left: 3px solid var(--accent-amber);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent-amber);
  max-width: 360px;
}
.toast.ok    { border-left-color: var(--accent-moss); }
.toast.error { border-left-color: var(--accent-primary); }
.toast.info  { border-left-color: var(--accent-amber); }
@keyframes toast-in  { from { transform: translateY(100%); opacity: 0; } }
@keyframes toast-out { to   { transform: translateY(100%); opacity: 0; } }

/* =====================================================================
   Custom scrollbars (subtle, dark-mode appropriate)
   ===================================================================== */

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 5px;
  border: 2px solid transparent;
  background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.16);
  background-clip: content-box;
}

/* =====================================================================
   Responsive
   ===================================================================== */

@media (max-width: 1280px) {
  :root { --preview-w: 380px; --rail-w: 200px; }
  .canvas { padding: 32px 36px; }
}

@media (max-width: 1024px) {
  .layout { grid-template-columns: var(--rail-w) 1fr; }
  .preview { display: none; }
}

@media (max-width: 720px) {
  .layout { grid-template-columns: 1fr; }
  .rail {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .rail-steps { flex-direction: row; overflow-x: auto; gap: 6px; }
  .rail-steps li { white-space: nowrap; flex-shrink: 0; }
  .rail-footer { display: none; }
  .canvas { padding: 24px 18px; }
  .topbar { padding: 0 16px; }
  .brand-text h1 { font-size: 18px; }
  .topbar-actions { gap: 6px; }
  .btn { padding: 8px 12px; font-size: 12px; }
}

/* =====================================================================
   Step 6 — NPC Dialogue panel additions
   ===================================================================== */

.npc-state-section {
  border-top: 1px solid var(--border);
  margin-top: 24px;
  padding-top: 20px;
}
.npc-state-section:first-of-type { border-top: none; margin-top: 0; padding-top: 0; }

.npc-state-title {
  font-family: var(--f-display);
  font-size: 20px;
  margin: 0 0 12px;
  color: var(--text-primary);
  display: flex;
  align-items: baseline;
  gap: 12px;
}
.npc-state-title small {
  font-family: var(--f-body);
  font-weight: 400;
  font-size: 12px;
  color: var(--text-muted);
}

.npc-pages-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 12px;
}

.npc-page-card {
  background: var(--surface-soft);
  border-left-color: var(--accent-primary);
}
.npc-page-card .card-title {
  font-size: 14px;
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.npc-page-card .card-title small { color: var(--text-muted); font-weight: 400; }

.page-id, .page-flag {
  font-family: var(--f-mono);
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
  font-weight: 400;
}

.npc-options-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.npc-option-row {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  background: rgba(0, 0, 0, 0.18);
}

.npc-option-head {
  display: grid;
  grid-template-columns: 1fr 160px 28px;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}
.npc-option-head .npc-option-text { font-family: var(--f-mono); font-size: 12px; }
.npc-option-head .npc-option-action { font-family: var(--f-mono); font-size: 12px; }

.npc-option-advanced {
  margin-top: 8px;
  font-size: 12px;
}
.npc-option-advanced summary {
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px 0;
  font-size: 11px;
}
.npc-option-advanced[open] summary { color: var(--text-primary); }

.battle-option-config {
  border: 1px dashed var(--border);
  border-radius: 6px;
  padding: 14px;
  margin-top: 10px;
  background: rgba(0, 0, 0, 0.12);
}

.battle-team-block {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.02);
}

/* =====================================================================
   Right-pane tab switcher (Live YAML | Simulator)
   ===================================================================== */

.preview-tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  background: var(--surface);
}
.preview-tab {
  flex: 1;
  background: transparent;
  border: 0;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font: 600 12px/1 var(--f-body);
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 14px 8px;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.preview-tab:hover { color: var(--text-primary); }
.preview-tab.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent-primary);
}

.preview-pane {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: auto;
}

/* =====================================================================
   Simulator
   ===================================================================== */

.sim-host {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  font-family: var(--f-body);
  font-size: 13px;
}

/* ---- Empty state ---- */

.sim-empty {
  text-align: center;
  color: var(--text-muted);
  padding: 50px 24px;
  border: 1px dashed var(--border);
  border-radius: 12px;
}
.sim-empty-icon {
  font-size: 48px;
  margin-bottom: 12px;
  opacity: 0.5;
}
.sim-empty-title {
  font-family: var(--f-display);
  font-size: 20px;
  margin: 0 0 8px;
  color: var(--text-primary);
}
.sim-empty-body { margin: 0; font-size: 13px; }

.sim-empty-dialogue {
  text-align: center;
  color: var(--text-muted);
  padding: 32px 18px;
}
.sim-empty-dialogue .sim-empty-icon { font-size: 36px; margin-bottom: 10px; }
.sim-empty-prompt { margin: 0; font-size: 13px; line-height: 1.5; }
.sim-empty-prompt strong { color: var(--text-primary); }
.sim-empty-prompt code {
  font-family: var(--f-mono);
  background: rgba(255,255,255,0.06);
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
}

/* ---- Title bar (quest name + state pill) ---- */

.sim-titlebar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: space-between;
}
.sim-title-name {
  font-family: var(--f-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--text-primary);
}
.sim-state-pill {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  white-space: nowrap;
}
.sim-state-pill.state-offer         { background: rgba(255,170,0,0.18);   color: #ffd479; }
.sim-state-pill.state-in-progress   { background: rgba(85,255,255,0.18);  color: #9fe9ee; }
.sim-state-pill.state-complete      { background: rgba(85,255,85,0.18);   color: #9af09a; }
.sim-state-pill.state-post-complete { background: rgba(170,170,170,0.18); color: #cfcfcf; }

/* ---- "Currently talking to" card ---- */

.sim-npc-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: linear-gradient(135deg, rgba(255,170,0,0.10), rgba(85,170,170,0.06));
  border: 1px solid rgba(255,170,0,0.22);
  border-radius: 10px;
}
.sim-npc-avatar {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ffaa00, #ff7733);
  color: #1a1a1a;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 20px;
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(255,170,0,0.30);
}
.sim-npc-info { flex: 1; min-width: 0; }
.sim-npc-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-muted);
  margin-bottom: 2px;
}
.sim-npc-name {
  font-family: var(--f-display);
  font-size: 16px;
  color: var(--text-primary);
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Custom NPC dropdown ---- */

.sim-npc-dropdown {
  position: relative;
  display: inline-block;
  min-width: 0;
}
.sim-npc-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  color: var(--text-primary);
  font: 600 14px/1.2 var(--f-display);
  transition: background 0.12s, border-color 0.12s;
  width: 100%;
  text-align: left;
}
.sim-npc-toggle:hover {
  background: rgba(255,255,255,0.10);
  border-color: var(--accent-primary);
}
.sim-npc-toggle .sim-npc-name {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  flex: 1;
  text-align: left;
}
.sim-npc-chev {
  font-size: 11px;
  color: var(--text-muted);
  transition: transform 0.18s;
}
.sim-npc-dropdown[data-dropdown-open="true"] .sim-npc-chev {
  transform: rotate(180deg);
}

.sim-npc-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  min-width: 220px;
  max-width: 320px;
  background: #1a1a1f;
  border: 1px solid var(--border);
  border-radius: 8px;
  box-shadow: 0 10px 32px rgba(0,0,0,0.50), 0 0 0 1px rgba(255,255,255,0.04);
  display: none;
  flex-direction: column;
  padding: 4px;
  z-index: 50;
  overflow: hidden;
}
.sim-npc-dropdown[data-dropdown-open="true"] .sim-npc-menu {
  display: flex;
  animation: sim-dropdown-in 0.14s ease-out;
}
@keyframes sim-dropdown-in {
  from { opacity: 0; transform: translateY(-4px); }
  to   { opacity: 1; transform: translateY(0); }
}

.sim-npc-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: #f0f0f0;
  cursor: pointer;
  font: 500 13px/1.2 var(--f-body);
  text-align: left;
  transition: background 0.10s;
  width: 100%;
}
.sim-npc-item:hover {
  background: rgba(255,170,0,0.16);
  color: #ffe9b6;
}
.sim-npc-item.active {
  background: rgba(85,170,170,0.18);
  color: #c1eaee;
}
.sim-npc-item-avatar {
  width: 24px;
  height: 24px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,170,0,0.30);
  color: #ffe9b6;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 11px;
  border-radius: 50%;
}
.sim-npc-item.active .sim-npc-item-avatar {
  background: rgba(85,170,170,0.40);
  color: #ffffff;
}
.sim-npc-item-name {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sim-npc-item-check {
  color: #9af09a;
  font-weight: 700;
  width: 14px;
  text-align: right;
}

/* Stage info row */

.sim-stage-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 8px;
  font-size: 12px;
  padding: 8px 10px;
  background: rgba(255,255,255,0.03);
  border-radius: 6px;
}
.sim-stage-row strong { color: var(--text-primary); }
.sim-stage-id {
  font-family: var(--f-mono);
  color: var(--text-muted);
  font-size: 11px;
}
.sim-stage-desc { flex: 1; min-width: 120px; }

/* Objective list */

.sim-objectives { display: flex; flex-direction: column; gap: 8px; }
.sim-obj {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px;
  background: rgba(0,0,0,0.18);
  font-size: 12px;
}
.sim-obj.done { opacity: 0.6; }
.sim-obj-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}
.sim-obj-check { font-weight: 700; color: #9af09a; min-width: 14px; }
.sim-obj.done .sim-obj-check { color: #9af09a; }
.sim-obj:not(.done) .sim-obj-check { color: var(--text-muted); }
.sim-obj-id { font-family: var(--f-mono); font-size: 11px; color: var(--text-primary); }
.sim-obj-type {
  font-family: var(--f-mono);
  font-size: 10px;
  color: var(--text-muted);
  background: rgba(255,255,255,0.04);
  padding: 1px 6px;
  border-radius: 3px;
}
.sim-obj-progress { font-family: var(--f-mono); font-size: 11px; color: var(--text-muted); margin-left: auto; }
.sim-tick-btn { padding: 2px 8px; font-size: 11px; }
.sim-obj-bar {
  height: 6px;
  background: rgba(255,255,255,0.05);
  border-radius: 3px;
  margin-top: 6px;
  overflow: hidden;
}
.sim-obj-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #ffaa00, #55ff55);
  transition: width 0.3s;
}

/* Dialogue screen (NPC mode) */

.sim-screen {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px;
  background: rgba(0,0,0,0.30);
  min-height: 140px;
}

.sim-dialogue, .sim-battle {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sim-speaker {
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 10px;
}
.sim-speaker-avatar {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #ffaa00, #ff7733);
  color: #1a1a1a;
  font-family: var(--f-display);
  font-weight: 700;
  font-size: 14px;
  border-radius: 50%;
}
.sim-speaker-name {
  font-family: var(--f-display);
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}
.sim-lines {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  line-height: 1.55;
  color: #e3e3e3;
  min-height: 40px;
}
.sim-line { word-break: break-word; }

.sim-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 6px;
}
.sim-options.vertical {
  flex-direction: column;
  align-items: stretch;
}
.sim-opt-btn, .sim-battle-btn {
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  color: var(--text-primary);
  padding: 10px 14px;
  font: 500 13px/1.3 var(--f-body);
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  transition: background 0.12s, border-color 0.12s, transform 0.08s;
}
.sim-opt-btn:hover, .sim-battle-btn:hover {
  background: rgba(255,255,255,0.12);
  border-color: var(--accent-primary);
}
.sim-opt-btn:active, .sim-battle-btn:active {
  transform: translateY(1px);
}
.sim-battle-btn {
  flex: 1;
  text-align: center;
  padding: 10px;
}
.sim-battle-btn.alt {
  background: rgba(255, 80, 80, 0.10);
  border-color: rgba(255, 80, 80, 0.30);
}
.sim-battle-btn.alt:hover {
  background: rgba(255, 80, 80, 0.16);
  border-color: rgba(255, 80, 80, 0.50);
}

.sim-page-meta {
  color: var(--text-muted);
  font-size: 10px;
  font-family: var(--f-mono);
  margin-top: 4px;
}

/* Minecraft chat fallback */

.sim-screen.mode-chat {
  background: rgba(0,0,0,0.55);
  font-family: var(--f-mono), monospace;
  font-size: 12px;
  padding: 8px 10px;
}
.mc-chat-scroll {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 280px;
  overflow-y: auto;
  padding: 4px;
}
.mc-line {
  color: #f0f0f0;
  text-shadow: 1px 1px 0 rgba(0,0,0,0.55);
  line-height: 1.45;
  word-break: break-word;
}
.mc-line.mc-system { color: #aaaaaa; }
.mc-line.mc-faint { color: #666666; font-style: italic; }
.mc-sender { color: #ffffff; }

/* Bottom action row */

.sim-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding-top: 6px;
  border-top: 1px solid var(--border);
}
.sim-action-btn {
  font-size: 13px;
  padding: 10px 16px;
}
.sim-action-btn.btn-primary {
  font-weight: 600;
}

.sim-stage-suggest {
  background: rgba(255, 170, 0, 0.10);
  border: 1px solid rgba(255, 170, 0, 0.32);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 12px;
  color: #ffd479;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
}
.sim-stage-suggest strong { color: #ffe9b6; }

.sim-role-switch-btn {
  background: rgba(255, 170, 0, 0.20);
  border: 1px solid rgba(255, 170, 0, 0.50);
  color: #ffe9b6;
  padding: 4px 10px;
  font: 600 11px/1.3 var(--f-body);
  border-radius: 4px;
  cursor: pointer;
  transition: background 0.12s, border-color 0.12s;
}
.sim-role-switch-btn:hover {
  background: rgba(255, 170, 0, 0.32);
  border-color: rgba(255, 170, 0, 0.72);
}

/* Primary "Continue" button (auto-advance pages) — slightly stronger
   visual weight so the user knows where to click when there's nothing
   else to choose. */
.sim-opt-btn.primary {
  background: linear-gradient(135deg, rgba(255,170,0,0.20), rgba(255,170,0,0.12));
  border-color: rgba(255,170,0,0.40);
  color: #ffe9b6;
  font-weight: 600;
}
.sim-opt-btn.primary:hover {
  background: linear-gradient(135deg, rgba(255,170,0,0.32), rgba(255,170,0,0.18));
  border-color: rgba(255,170,0,0.66);
}

/* =====================================================================
   Quest template picker (modal)
   ===================================================================== */

.template-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 24px;
  animation: tpl-overlay-in 0.18s ease-out;
}
@keyframes tpl-overlay-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.template-modal {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.04);
  width: 100%;
  max-width: 720px;
  max-height: 88vh;
  overflow: auto;
  padding: 24px 26px 26px;
  animation: tpl-modal-in 0.22s cubic-bezier(.2,.7,.2,1);
}
@keyframes tpl-modal-in {
  from { opacity: 0; transform: translateY(12px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.template-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
}
.template-head h2 {
  font-family: var(--f-display);
  font-size: 24px;
  margin: 0;
  color: var(--text-primary);
}
.template-subtitle {
  color: var(--text-muted);
  font-size: 13px;
  margin: 0 0 20px;
  line-height: 1.5;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}
.template-card {
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 18px 16px;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 8px;
  color: var(--text-primary);
  font-family: var(--f-body);
  transition: background 0.14s, border-color 0.14s, transform 0.10s;
}
.template-card:hover {
  background: rgba(255,170,0,0.08);
  border-color: rgba(255,170,0,0.50);
  transform: translateY(-2px);
}
.template-card:active { transform: translateY(0); }

.template-icon {
  font-size: 28px;
  line-height: 1;
  margin-bottom: 4px;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.40));
}
.template-title {
  font-family: var(--f-display);
  font-size: 16px;
  font-weight: 600;
}
.template-blurb {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.5;
}

@media (max-width: 600px) {
  .template-modal { padding: 18px; max-height: 92vh; }
  .template-grid { grid-template-columns: 1fr; }
}

/* =====================================================================
   Rail step-completion indicators
   ===================================================================== */

#rail-steps li {
  position: relative;
  padding-right: 28px;
}
#rail-steps li.step-ok::after,
#rail-steps li.step-warn::after {
  content: '';
  position: absolute;
  top: 50%;
  right: 8px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  transform: translateY(-50%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 700;
  line-height: 14px;
  text-align: center;
}
#rail-steps li.step-ok::after {
  content: '✓';
  background: rgba(85, 255, 85, 0.20);
  color: #9af09a;
}
#rail-steps li.step-warn::after {
  content: '!';
  background: rgba(255, 170, 0, 0.20);
  color: #ffd479;
}

/* =====================================================================
   Icon quick-picks (Step 1)
   ===================================================================== */

.icon-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.icon-chip {
  background: rgba(255,255,255,0.05);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 10px;
  font: 500 11px/1.4 var(--f-mono);
  color: var(--text-primary);
  cursor: pointer;
  transition: background 0.10s, border-color 0.10s;
}
.icon-chip:hover {
  background: rgba(255,170,0,0.14);
  border-color: rgba(255,170,0,0.50);
}

/* =====================================================================
   Step Next/Previous navigation (bottom of every panel)
   ===================================================================== */

.step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  margin-top: 32px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
}
.step-nav > span:empty { width: 1px; }  /* placeholder for missing prev */

.step-nav-btn {
  font-size: 13px;
  font-weight: 500;
  padding: 10px 18px;
}
.step-nav-btn[data-step-nav="DOWNLOAD"] {
  background: linear-gradient(135deg, #ffaa00, #ff7733);
  color: #1a1a1a;
  font-weight: 700;
}
.step-nav-btn[data-step-nav="DOWNLOAD"]:hover {
  filter: brightness(1.08);
}

/* =====================================================================
   Output target (Cobblemon / Pixelmon)
   ===================================================================== */

.target-switch {
  display: inline-flex; align-items: center;
  background: var(--bg-input);
  border: 1px solid var(--border-strong);
  border-radius: 4px;
  padding: 3px;
  margin-right: 6px;
}
.target-switch-label {
  font: 500 10px/1 var(--f-body);
  text-transform: uppercase; letter-spacing: .16em;
  color: var(--text-muted);
  padding: 0 8px 0 6px;
}
.target-opt {
  appearance: none; border: none; cursor: pointer;
  background: transparent;
  color: var(--text-secondary);
  font: 500 12px/1 var(--f-body);
  padding: 7px 12px;
  border-radius: 3px;
  transition: background .15s, color .15s;
}
.target-opt:hover { color: var(--text-primary); background: var(--bg-hover); }
.target-opt.active {
  background: var(--accent-primary);
  color: white;
}
.target-opt:focus-visible { outline: none; box-shadow: var(--shadow-glow); }

.target-notes {
  margin: 0 0 10px;
  padding: 10px 12px;
  background: rgba(240, 168, 58, 0.08);
  border: 1px solid rgba(240, 168, 58, 0.35);
  border-left: 3px solid var(--accent-amber);
  border-radius: 4px;
  font-size: 12px;
  color: var(--text-primary);
}
.target-notes[hidden] { display: none; }
.target-notes-head {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  margin-bottom: 6px;
}
.target-notes ul { margin: 0; padding-left: 18px; }
.target-notes li { margin: 2px 0; overflow-wrap: anywhere; }

.opt-subhead {
  margin: 14px 0 8px;
  font-size: 11px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--text-secondary);
}
.opt-subhead small { text-transform: none; letter-spacing: 0; color: var(--text-muted); }

.stage-extras {
  margin: 4px 0 8px;
  padding: 8px 12px;
  border: 1px dashed var(--border-strong);
  border-radius: 4px;
}
.stage-extras summary {
  cursor: pointer;
  font-size: 12px; text-transform: uppercase; letter-spacing: .12em;
  color: var(--text-secondary);
}
.stage-extras[open] summary { color: var(--text-primary); margin-bottom: 10px; }

@media (max-width: 720px) {
  .topbar { height: auto; min-height: var(--topbar-h); flex-wrap: wrap; gap: 8px; padding: 8px 16px; }
  .topbar-actions { flex-wrap: wrap; }
  .target-switch-label { display: none; }
}

/* ---------------------------------------------------------------
   Server mode — the mod itself serves this page (Open / Save to server)
   --------------------------------------------------------------- */
.topbar-actions .btn[hidden], .target-switch[hidden] { display: none; }
.server-session { font-size: 12px; color: var(--text-secondary); }
.server-session.signed-in { color: var(--accent-moss); border-color: rgba(108, 181, 87, 0.35); }
.server-modal .field { margin-bottom: 14px; }
.server-modal .server-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 6px; }
.server-modal .server-error { color: var(--accent-rose); font-size: 13px; margin: 0 0 12px; overflow-wrap: anywhere; }
.server-modal .server-error:empty { display: none; }
.server-files { display: flex; flex-direction: column; gap: 4px; max-height: 56vh; overflow: auto; }
.server-file {
  appearance: none; cursor: pointer; text-align: left;
  display: grid; grid-template-columns: 1fr auto; gap: 2px 12px;
  padding: 9px 12px; border-radius: 4px;
  background: var(--bg-raised); border: 1px solid var(--border);
  color: var(--text-primary); font: 500 13px/1.4 var(--f-body);
}
.server-file:hover { background: var(--bg-hover); border-color: var(--border-strong); }
.server-file.current { border-color: var(--accent-amber); }
.server-file-path { font-family: var(--f-mono); font-size: 12px; overflow-wrap: anywhere; }
.server-file-id { font-family: var(--f-mono); font-size: 11px; color: var(--text-muted); }
.server-file-name { grid-column: 1 / -1; font-size: 12px; color: var(--text-secondary); }
.server-empty { color: var(--text-muted); font-size: 13px; padding: 12px 0; }
