/* MIT License © 2026 Binary Dice Games */
/* The nymph web app (spec/15_web_app/DESIGN.md section 3). */

:root {
  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #f0f2f5;
  --text: #1b2230;
  --muted: #5f6b7d;
  --border: #e1e5eb;
  --accent: #0f9f86;
  --accent-strong: #0b8571;
  --accent-text: #ffffff;
  --accent-soft: #e3f5f1;
  --danger: #c4352b;
  --danger-soft: #fdecea;
  --warning-soft: #fff6db;
  --shadow: 0 1px 2px rgba(16, 24, 40, 0.06), 0 8px 24px rgba(16, 24, 40, 0.08);
  --radius: 10px;
  --bar-h: 56px;
  color-scheme: light;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0f1217;
    --surface: #171b22;
    --surface-2: #1f242d;
    --text: #e6e9ef;
    --muted: #9aa4b5;
    --border: #2b313c;
    --accent: #2bc6a8;
    --accent-strong: #3fd8ba;
    --accent-text: #06231d;
    --accent-soft: #143a33;
    --danger: #f07167;
    --danger-soft: #3a1d1b;
    --warning-soft: #3a3217;
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
    color-scheme: dark;
  }
}

:root[data-theme="dark"] {
  --bg: #0f1217;
  --surface: #171b22;
  --surface-2: #1f242d;
  --text: #e6e9ef;
  --muted: #9aa4b5;
  --border: #2b313c;
  --accent: #2bc6a8;
  --accent-strong: #3fd8ba;
  --accent-text: #06231d;
  --accent-soft: #143a33;
  --danger: #f07167;
  --danger-soft: #3a1d1b;
  --warning-soft: #3a3217;
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 8px 24px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

/* The app fills the screen and only its panes scroll: the document never
   does. On phones and tablets (iOS Safari) a scrolled document could hide
   the top bar with no way to drag it back, since the chart keeps its
   touches. */
html {
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  position: fixed;
  inset: 0;
  height: auto;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  display: flex;
  flex-direction: column;
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--accent-strong);
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ── Top bar ──────────────────────────────────────────────────────────────── */

.bar {
  height: var(--bar-h);
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  padding-left: max(12px, env(safe-area-inset-left));
  padding-right: max(12px, env(safe-area-inset-right));
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  border: 0;
  background: none;
  color: var(--text);
  font: 600 17px/1 inherit;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}

.brand:hover {
  background: var(--surface-2);
}

.doc-title {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  flex: 0 1 420px;
  padding-left: 10px;
  border-left: 1px solid var(--border);
}

.origin {
  display: inline-flex;
  color: var(--muted);
}

.origin svg {
  width: 18px;
  height: 18px;
}

.doc-name {
  font: 500 15px/1.2 inherit;
  color: var(--text);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 5px 6px;
  min-width: 0;
  width: 100%;
  text-overflow: ellipsis;
}

.doc-name:hover,
.doc-name:focus {
  border-color: var(--border);
  background: var(--surface-2);
  outline: none;
}

.dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--accent);
  flex: none;
}

.spacer {
  flex: 1;
}

.actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── Buttons ──────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 14px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: 500 14px/1 inherit;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.12s, border-color 0.12s;
}

.btn:hover:not(:disabled) {
  background: var(--surface-2);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn.primary:hover:not(:disabled) {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
}

.btn.ghost {
  border-color: transparent;
  background: transparent;
}

.btn.ghost[aria-pressed="true"] {
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.btn.icon {
  width: 36px;
  padding: 0;
}

.btn svg {
  width: 18px;
  height: 18px;
}

.btn.large {
  height: 44px;
  padding: 0 20px;
  font-size: 15px;
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: #fff;
}

.split {
  display: inline-flex;
}

.split .btn:first-child {
  border-top-right-radius: 0;
  border-bottom-right-radius: 0;
}

.split .caret {
  width: 30px;
  padding: 0;
  border-top-left-radius: 0;
  border-bottom-left-radius: 0;
  border-left: 1px solid rgba(255, 255, 255, 0.35);
}

.segmented {
  display: inline-flex;
  background: var(--surface-2);
  border-radius: 9px;
  padding: 3px;
  border: 1px solid var(--border);
}

.segmented button {
  height: 28px;
  padding: 0 14px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--muted);
  font: 500 14px/1 inherit;
  cursor: pointer;
}

.segmented button[aria-pressed="true"] {
  background: var(--surface);
  color: var(--text);
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.12);
}

.segmented button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* Zoom: the chart's size on the page, not its image size. */
.segmented.zoom button {
  padding: 0 10px;
  color: var(--text);
}

.segmented.zoom #zoom-reset {
  min-width: 54px;
  padding: 0 6px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.link {
  border: 0;
  background: none;
  color: var(--accent-strong);
  font: inherit;
  cursor: pointer;
  padding: 2px 4px;
}

/* ── Menus ────────────────────────────────────────────────────────────────── */

.menu {
  position: fixed;
  z-index: 50;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 6px;
  margin: 0;
  list-style: none;
}

.menu button {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  border: 0;
  background: none;
  color: var(--text);
  font: 14px/1.2 inherit;
  text-align: left;
  padding: 9px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.menu button:hover,
.menu button:focus-visible {
  background: var(--surface-2);
  outline: none;
}

.menu button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.menu .note {
  margin-left: auto;
  color: var(--muted);
  font-size: 12px;
}

.menu hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 6px 4px;
}

.menu svg {
  width: 16px;
  height: 16px;
  color: var(--muted);
  flex: none;
}

/* ── Main ─────────────────────────────────────────────────────────────────── */

main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.start {
  overflow: auto;
  flex: 1;
}

.hero {
  padding: 40px 16px 8px;
  display: flex;
  justify-content: center;
}

.drop {
  width: min(880px, 100%);
  text-align: center;
  border: 2px dashed var(--border);
  border-radius: 18px;
  background: var(--surface);
  padding: 44px 24px 36px;
}

/* The logo: the dark variant lightens the tagline (web/tools/make_logo.py). */
.logo {
  margin: 0 auto 28px;
  max-width: 420px;
}

.logo img {
  display: block;
  width: 100%;
  height: auto;
}

.logo .logo-dark {
  display: none;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .logo .logo-light {
    display: none;
  }
  :root:not([data-theme="light"]) .logo .logo-dark {
    display: block;
  }
}

:root[data-theme="dark"] .logo .logo-light {
  display: none;
}

:root[data-theme="dark"] .logo .logo-dark {
  display: block;
}

.drop h1 {
  font-size: 28px;
  margin: 0 0 8px;
  letter-spacing: -0.01em;
}

.lead {
  color: var(--muted);
  margin: 0 0 24px;
}

.hint {
  color: var(--muted);
  font-size: 13px;
  margin: 18px 0 0;
}

.open-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.sections {
  width: min(1080px, 100%);
  margin: 0 auto;
  padding: 16px;
}

.sections section {
  margin-top: 22px;
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
}

.section-head h2 {
  font-size: 16px;
  margin: 0 0 10px;
}

.cards {
  list-style: none;
  padding: 0;
  margin: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 12px;
}

.cards.small {
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
}

.card {
  width: 100%;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  overflow: hidden;
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: box-shadow 0.12s, border-color 0.12s, transform 0.12s;
}

.card:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow);
}

.card:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}

.card .thumb {
  aspect-ratio: 16 / 10;
  background: var(--surface-2);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.card .thumb img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #fff;
}

.card .kind-icon {
  margin: 8px 8px 0;
}

.card .label {
  padding: 9px 11px 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.card .label strong {
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card .label span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.foot {
  width: min(1080px, 100%);
  margin: 26px auto 0;
  padding: 18px 16px 32px;
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 13px;
}

.foot p {
  margin: 4px 0;
}

/* ── Document ─────────────────────────────────────────────────────────────── */

.doc {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.workarea {
  flex: 1;
  min-height: 0;
  display: flex;
}

.stage {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: auto;
  overscroll-behavior: contain;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.stage.viewing {
  padding: 24px;
}

.stage.viewing > .viewer-box {
  width: 100%;
  max-width: 100%;
  display: flex;
  /* A zoomed chart wider than the stage scrolls from its left edge. */
  justify-content: safe center;
}

.stage.viewing.dragging,
.stage.viewing.dragging canvas {
  cursor: grabbing;
}

.stage.editing {
  overflow: hidden;
  padding: 0;
}

.stage.editing > .editor-box {
  position: absolute;
  inset: 0;
}

.stage .message {
  max-width: 560px;
  margin: 60px auto;
  text-align: center;
  color: var(--muted);
}

.dock {
  flex: none;
  width: 360px;
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  padding: 12px 16px 24px;
}

/* ── Agents panel forms (spec/17_agent_connectors) ──────────────────────── */

.agents-section input[type="text"],
.agents-section input[type="password"],
.agents-section textarea {
  width: 100%;
  box-sizing: border-box;
  font: inherit;
  font-size: 13px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
}

.agents-section summary {
  cursor: pointer;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

details.agents-section[open] > *:not(summary) {
  margin-top: 8px;
}

.agents-section label.check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
}

/* ── Agents panel (spec/17_agent_connectors) ─────────────────────────────── */

.agents-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.agents-head h2 {
  margin: 0;
  font-size: 16px;
}

.agents-status {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 10px 0 0;
  padding: 8px 10px;
  border-radius: var(--radius);
  background: var(--accent-soft);
  font-size: 13px;
}

.agents-status .text {
  flex: 1;
  min-width: 0;
}

.agents-status .pulse {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  animation: agents-pulse 1.4s ease-in-out infinite;
}

@keyframes agents-pulse {
  50% {
    opacity: 0.3;
  }
}

@media (prefers-reduced-motion: reduce) {
  .agents-status .pulse {
    animation: none;
  }
}

.agents-section {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: flex-start;
  font-size: 14px;
}

.agents-section h3 {
  margin: 0;
  font-size: 13px;
  color: var(--muted);
  font-weight: 600;
}

.agents-section .muted {
  margin: 0;
  color: var(--muted);
}

.agents-list,
.activity-list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: 100%;
}

.agents-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0;
}

.agents-list .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

.agents-list .name {
  font-weight: 600;
}

.agents-list .route {
  flex: 1;
  color: var(--muted);
  font-size: 13px;
}

.activity-list .entry {
  padding: 8px 0;
  border-top: 1px solid var(--border);
}

.activity-list .entry.undone .label {
  text-decoration: line-through;
  color: var(--muted);
}

.activity-list .line {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.activity-list .line + .line {
  margin-top: 4px;
  align-items: center;
}

.activity-list .who {
  font-weight: 600;
  white-space: nowrap;
}

.activity-list .label {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.activity-list time,
.activity-list .state,
.activity-list summary {
  color: var(--muted);
  font-size: 12px;
}

.activity-list details {
  flex: 1;
}

.activity-list .tools {
  margin: 4px 0 0;
  padding-left: 16px;
  font-size: 12px;
}

.activity-list .tools .failed {
  color: var(--danger);
}

label.check {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
}

.btn.small {
  padding: 3px 10px;
  font-size: 13px;
}

.banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  background: var(--warning-soft);
  font-size: 14px;
}

.banner.error {
  background: var(--danger-soft);
}

.banner.info {
  background: var(--accent-soft);
}

.banner .text {
  flex: 1;
  min-width: 0;
  overflow-wrap: anywhere;
}

.banner .where {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
  color: var(--muted);
  margin-right: 6px;
}

.banner .btn {
  height: 30px;
  padding: 0 12px;
}

/* ── Progress, overlay, toasts ────────────────────────────────────────────── */

.progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  z-index: 100;
  overflow: hidden;
}

.progress div {
  height: 100%;
  width: 40%;
  background: var(--accent);
  animation: slide 1.1s ease-in-out infinite;
}

@keyframes slide {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(260%);
  }
}

.drop-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  background: color-mix(in srgb, var(--accent) 18%, transparent);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-overlay div {
  background: var(--surface);
  border: 2px dashed var(--accent);
  border-radius: 16px;
  padding: 28px 40px;
  font-size: 20px;
  font-weight: 600;
}

.toasts {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 70;
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  pointer-events: none;
}

.toast {
  background: var(--text);
  color: var(--bg);
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow);
  max-width: min(560px, 90vw);
}

/* ── Dialogs ──────────────────────────────────────────────────────────────── */

dialog.dlg {
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 0;
  background: var(--surface);
  color: var(--text);
  box-shadow: var(--shadow);
  width: min(520px, calc(100vw - 32px));
}

dialog.dlg::backdrop {
  background: rgba(10, 14, 20, 0.45);
}

.dlg form,
.dlg .body {
  padding: 20px 22px 18px;
}

.dlg h2 {
  font-size: 18px;
  margin: 0 0 8px;
}

.dlg p {
  margin: 0 0 12px;
  color: var(--muted);
}

.dlg input[type="url"],
.dlg input[type="text"],
.dlg textarea {
  width: 100%;
  font: 14px/1.4 inherit;
  padding: 9px 11px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
}

.dlg textarea {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  min-height: 110px;
  resize: vertical;
}

/* Connect an agent (spec/17_agent_connectors/DESIGN.md section 5.1). */
dialog.dlg.connect-agent {
  width: min(600px, calc(100vw - 32px));
  max-height: calc(100vh - 32px);
  overflow-y: auto;
}

.connect-agent .pair-row {
  display: flex;
  gap: 8px;
  padding: 0;
  margin-bottom: 12px;
}

.connect-agent .pair-row input {
  flex: 1;
  min-width: 0;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 16px;
  letter-spacing: 0.04em;
}

.connect-agent .agent-warning {
  border: 1px solid var(--danger);
  background: var(--danger-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 8px 12px;
}

.agent-setup summary {
  cursor: pointer;
  font-weight: 600;
  margin-bottom: 8px;
}

.agent-setup .steps {
  margin: 0 0 12px;
  padding-left: 22px;
}

.agent-setup .steps > li {
  margin: 10px 0;
}

.agent-setup .steps p {
  margin: 0 0 6px;
}

.agent-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 6px;
}

.agent-picker .btn[aria-pressed="true"] {
  background: var(--accent-soft);
  border-color: var(--accent);
  color: var(--accent-strong);
}

.agent-system {
  float: right;
  color: var(--muted);
  font-size: 13px;
}

.agent-system select {
  font: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 2px 4px;
}

.agent-step .btn.primary {
  margin-bottom: 8px;
  text-decoration: none;
}

.copy-block {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  margin-bottom: 6px;
}

.copy-block pre {
  flex: 1;
  min-width: 0;
  margin: 0;
  padding: 8px 10px;
  overflow-x: auto;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  font: 12px/1.45 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.dlg .row {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  margin-top: 16px;
  flex-wrap: wrap;
}

.dlg kbd {
  font: 12px ui-monospace, monospace;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 5px;
}

.dlg table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.dlg td {
  padding: 5px 4px;
  border-bottom: 1px solid var(--border);
}

.dlg .err {
  color: var(--danger);
  font-size: 13px;
  margin-top: 8px;
  min-height: 1em;
}

.dlg code.args {
  display: block;
  white-space: pre-wrap;
  font-size: 12px;
  background: var(--surface-2);
  padding: 8px;
  border-radius: 6px;
  max-height: 160px;
  overflow: auto;
}

/* ── Narrow screens ───────────────────────────────────────────────────────── */

@media (max-width: 720px) {
  :root {
    --bar-h: 52px;
  }
  .brand span {
    display: none;
  }
  .actions .collapsible {
    display: none;
  }
  .doc-title {
    flex: 1 1 auto;
    border-left: 0;
    padding-left: 0;
  }
  .hero {
    padding-top: 18px;
  }
  .drop {
    padding: 28px 16px;
    border-style: solid;
  }
  .drop h1 {
    font-size: 22px;
  }
  .logo {
    margin-bottom: 18px;
  }
  .stage.viewing {
    padding: 8px;
  }
  .cards {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  /* A bottom sheet over the chart: phones keep the chart visible. */
  .dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: auto;
    max-height: 50vh;
    border-left: 0;
    border-top: 1px solid var(--border);
    border-radius: 14px 14px 0 0;
    box-shadow: var(--shadow);
    z-index: 20;
  }
}

/* ── Theme picker ─────────────────────────────────────────────────────────── */

dialog.dlg:has(.theme-grid) {
  width: min(720px, calc(100vw - 32px));
}

.theme-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
  max-height: min(60vh, 520px);
  overflow-y: auto;
  padding: 2px;
}

.theme-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font: inherit;
}

.theme-card:hover {
  border-color: var(--accent);
}

.theme-card.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.theme-card .swatch {
  position: relative;
  height: 72px;
  border-radius: 8px;
  border: 1px solid var(--border);
  display: block;
}

.theme-card .swatch.own {
  display: flex;
  align-items: center;
  justify-content: center;
  background: repeating-linear-gradient(45deg, var(--surface-2), var(--surface-2) 8px, var(--bg) 8px, var(--bg) 16px);
  color: var(--muted);
  font-size: 20px;
}

.swatch-title {
  position: absolute;
  left: 10px;
  top: 8px;
  font-size: 18px;
  font-weight: 600;
}

.swatch-dots {
  position: absolute;
  left: 10px;
  bottom: 9px;
  display: flex;
  gap: 5px;
}

.swatch-dots i {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: block;
}

.theme-name {
  font-weight: 600;
  font-size: 14px;
}

.theme-desc {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ── Import wizard ────────────────────────────────────────────────────────── */

@font-face {
  font-family: "nymph PT Serif";
  src: url("fonts/PT_Serif-Web-Bold.ttf");
  font-weight: 700;
}

@font-face {
  font-family: "nymph Fira Sans";
  src: url("fonts/FiraSans-Bold.ttf");
  font-weight: 700;
}

@font-face {
  font-family: "nymph Fira Mono";
  src: url("fonts/FiraMono-Bold.ttf");
  font-weight: 700;
}

dialog.dlg.wizard-dlg {
  width: min(1120px, calc(100vw - 32px));
}

.dlg .body.wizard {
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 48px);
}

.stepper {
  list-style: none;
  display: flex;
  gap: 6px;
  padding: 0;
  margin: 4px 0 14px;
}

.stepper li {
  flex: 1;
  border-top: 3px solid var(--border);
}

.stepper li.on,
.stepper li.done {
  border-color: var(--accent);
}

.stepper button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 2px 0;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
  text-align: left;
}

.stepper li.on button {
  color: var(--text);
  font-weight: 600;
}

.stepper button:disabled {
  cursor: default;
}

.stepper b {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: var(--surface-2);
  font-size: 12px;
}

.stepper li.on b,
.stepper li.done b {
  background: var(--accent);
  color: var(--accent-text);
}

.wizard-main {
  display: grid;
  grid-template-columns: minmax(300px, 400px) 1fr;
  gap: 18px;
  min-height: 0;
  flex: 1 1 auto;
}

.wizard-panel {
  overflow-y: auto;
  max-height: min(64vh, 620px);
  padding: 2px 6px 2px 2px;
}

.wizard-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.preview-canvas {
  height: min(56vh, 520px);
  border: 1px solid var(--border);
  border-radius: 10px;
  background: repeating-conic-gradient(var(--surface-2) 0 25%, var(--bg) 0 50%) 0 0 / 16px 16px;
  overflow: hidden;
}

.preview-note {
  font-size: 12px;
  color: var(--muted);
  min-height: 1.3em;
}

.preview-note.err {
  color: var(--danger);
}

.dlg .row .spacer {
  flex: 1;
}

.wizard .stack {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.wizard .field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wizard .field-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.wizard .hint {
  font-size: 12px;
  color: var(--muted);
  margin: 0;
}

.wizard .two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.wizard select,
.wizard .series-row input[type="text"] {
  font: inherit;
  font-size: 14px;
  padding: 7px 9px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  min-width: 0;
}

.kind-grid,
.type-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.type-grid {
  grid-template-columns: repeat(3, 1fr);
}

.kind-card,
.type-card,
.theme-chip,
.chip {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font: inherit;
  cursor: pointer;
  text-align: left;
  transition: border-color 0.12s, box-shadow 0.12s;
}

.kind-card,
.type-card {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 10px 12px;
  border-radius: 12px;
}

.kind-card span:not(.kind-icon),
.type-card span:not(.type-sample) {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.3;
}

.kind-icon {
  display: flex;
  height: 54px;
  align-items: center;
  margin-bottom: 4px;
  border-radius: 8px;
  background: var(--surface-2);
  justify-content: center;
}

.type-sample {
  font-size: 28px;
  font-weight: 700;
  line-height: 1.1;
}

.kind-card:hover,
.type-card:hover,
.theme-chip:hover,
.chip:hover {
  border-color: var(--accent);
}

.kind-card.on,
.type-card.on,
.theme-chip.on,
.chip.on {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent-soft);
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.chip {
  padding: 6px 11px;
  border-radius: 999px;
  font-size: 13px;
}

.chip.on {
  background: var(--accent-soft);
}

.theme-strip {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(84px, 1fr));
  gap: 8px;
}

.theme-chip {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 5px;
  border-radius: 10px;
  font-size: 12px;
}

.theme-swatch {
  position: relative;
  display: block;
  height: 42px;
  border-radius: 7px;
  border: 1px solid var(--border);
}

.theme-swatch b {
  position: absolute;
  left: 7px;
  top: 4px;
  font-size: 14px;
}

.theme-swatch .swatch-dots {
  left: 7px;
  bottom: 6px;
  gap: 3px;
}

.theme-swatch .swatch-dots i {
  width: 9px;
  height: 9px;
}

.series-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.series-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  align-items: center;
}

.series-name,
.wizard .check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  min-width: 0;
}

.series-name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.series-row:not(.on) .series-name span {
  color: var(--muted);
}

.table-peek {
  overflow-x: auto;
}

.dlg .table-peek table {
  font-size: 12px;
}

.table-peek th {
  text-align: left;
  padding: 4px 6px;
  border-bottom: 2px solid var(--border);
  white-space: nowrap;
}

.table-peek th small {
  display: block;
  font-weight: 400;
  color: var(--muted);
}

.table-peek th.used {
  border-color: var(--accent);
}

.table-peek th.axis {
  border-color: var(--muted);
}

.table-peek td {
  white-space: nowrap;
  max-width: 140px;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 760px) {
  .wizard-main {
    grid-template-columns: 1fr;
  }
  .preview-canvas {
    height: 34vh;
  }
  .wizard-panel {
    max-height: none;
  }
  .type-grid {
    grid-template-columns: 1fr;
  }
}
