:root {
  color-scheme: dark;
  --bg: #09111e;
  --bg-elevated: rgba(8, 17, 32, 0.82);
  --panel: rgba(12, 22, 41, 0.92);
  --panel-strong: #11203b;
  --panel-soft: rgba(18, 31, 58, 0.78);
  --text: #eef4ff;
  --text-muted: #9fb3d9;
  --text-soft: #7187af;
  --accent: #5fd0ff;
  --accent-strong: #3ba9ff;
  --accent-warm: #ffbd67;
  --success: #78e6b0;
  --danger: #ff8d8d;
  --line: rgba(111, 144, 199, 0.22);
  --shadow: 0 26px 80px rgba(0, 0, 0, 0.34);
  --radius-lg: 24px;
  --radius-md: 18px;
  --radius-sm: 12px;
  --sans: "Space Grotesk", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(56, 124, 255, 0.22), transparent 32%),
    radial-gradient(circle at top right, rgba(255, 189, 103, 0.18), transparent 28%),
    linear-gradient(180deg, #06101b 0%, #081425 50%, #09111e 100%);
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  width: min(1600px, calc(100vw - 32px));
  margin: 20px auto 40px;
}

.hero,
.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(22px);
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding: 28px;
  margin-bottom: 20px;
}

.eyebrow {
  margin: 0 0 10px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent);
  font-size: 0.8rem;
}

.hero h1,
.panel h2,
.panel h3,
.panel h4 {
  margin: 0;
}

.hero h1 {
  font-size: clamp(2rem, 3vw, 3.4rem);
}

.hero-copy,
.panel-subtitle,
.stage-note {
  color: var(--text-muted);
}

.hero-copy {
  max-width: 70ch;
  margin: 12px 0 0;
  line-height: 1.55;
}

.hero-actions,
.status-cluster,
.panel-header {
  display: flex;
  gap: 10px;
  align-items: center;
}

.hero-actions {
  flex-wrap: wrap;
  align-content: flex-start;
  justify-content: flex-end;
}

.button,
.text-button {
  border: 1px solid transparent;
  border-radius: 999px;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.button {
  padding: 11px 16px;
  font-weight: 700;
}

.button:hover,
.text-button:hover {
  transform: translateY(-1px);
}

.button.primary {
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #031421;
}

.button.secondary {
  background: rgba(95, 208, 255, 0.12);
  border-color: rgba(95, 208, 255, 0.26);
  color: var(--text);
}

.button.ghost,
.text-button {
  background: transparent;
  border-color: var(--line);
  color: var(--text-muted);
}

.button.danger,
.text-button.danger {
  color: var(--danger);
  border-color: rgba(255, 141, 141, 0.3);
}

.file-button {
  display: inline-flex;
  align-items: center;
}

.workspace {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel {
  padding: 20px;
}

.panel-header {
  justify-content: space-between;
  margin-bottom: 18px;
}

.unit-badge img,
.item-badge img {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

/* ── Bench panel ── */
.bench-panel {
  flex-shrink: 0;
  height: 290px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--line);
  background: rgba(7, 14, 28, 0.98);
}

.bench-toolbar {
  display: flex;
  align-items: center;
  padding: 8px 14px;
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
}

.bench-search-input {
  width: 100%;
  max-width: 380px;
  padding: 7px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(15, 28, 53, 0.7);
  color: var(--text);
  font-size: 0.88rem;
  outline: none;
  transition: border-color 160ms ease;
}

.bench-search-input::placeholder {
  color: var(--text-soft);
}

.bench-search-input:focus {
  border-color: rgba(95, 208, 255, 0.45);
}

.bench-columns {
  flex: 1;
  overflow: hidden;
  display: flex;
  min-height: 0;
}

.bench-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-right: 1px solid var(--line);
  min-width: 0;
}

.bench-col:last-child {
  border-right: none;
}

.bench-col-header {
  margin: 0;
  padding: 5px 12px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-soft);
  flex-shrink: 0;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.015);
}

.bench-col-body {
  flex: 1;
  overflow-y: auto;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.bench-cost-group {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.bench-unit {
  position: relative;
  width: 46px;
  height: 46px;
  cursor: grab;
  flex-shrink: 0;
}

.bench-unit-image {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  display: block;
}

.bench-icons-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.bench-item {
  position: relative;
  width: 46px;
  height: 46px;
  cursor: grab;
  flex-shrink: 0;
}

.bench-item-image {
  width: 46px;
  height: 46px;
  border-radius: 12px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  display: block;
}

.bench-unit::after,
.bench-item::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 8px);
  transform: translateX(-50%) translateY(4px);
  padding: 5px 9px;
  border-radius: 8px;
  background: rgba(3, 11, 23, 0.96);
  border: 1px solid rgba(95, 208, 255, 0.25);
  color: var(--text);
  font-size: 0.76rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 10;
}

.bench-unit:hover::after,
.bench-item:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.bench-empty {
  margin: 4px 0 0;
  color: var(--text-soft);
  font-size: 0.82rem;
  font-style: italic;
}


.pill {
  display: inline-flex;
  align-items: center;
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(95, 208, 255, 0.22);
  background: rgba(95, 208, 255, 0.1);
  color: var(--text);
  font-size: 0.82rem;
}

.pill.muted {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

.flowchart-canvas {
  min-height: 720px;
  border-radius: 20px;
  border: 1px dashed rgba(111, 144, 199, 0.24);
  background:
    linear-gradient(rgba(11, 24, 46, 0.84), rgba(11, 24, 46, 0.84)),
    radial-gradient(circle at 20% 20%, rgba(59, 169, 255, 0.12), transparent 35%);
  overflow: auto;
}

.flowchart-canvas.empty-state {
  display: grid;
  place-items: center;
  color: var(--text-soft);
}

.flowchart-layout {
  position: relative;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 24px;
  padding: 28px;
}

.flowchart-lines {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.flow-stage {
  position: relative;
  display: grid;
  gap: 12px;
  z-index: 1;
}

.flow-stage.items-only {
  align-self: start;
}

.stage-heading-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.stage-heading-input,
.flow-note-textarea {
  width: 100%;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(111, 144, 199, 0.2);
  background: rgba(8, 15, 30, 0.78);
  color: var(--text);
  resize: vertical;
}

.stage-heading-input {
  color: var(--accent-warm);
  font-size: 0.86rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.icon-button,
.compact-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.icon-button {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
  cursor: pointer;
}

.icon-button.danger {
  color: var(--danger);
  border-color: rgba(255, 141, 141, 0.3);
}

.compact-button {
  padding: 8px 12px;
  font-size: 0.82rem;
}

.flow-node {
  padding: 14px;
  border-radius: 20px;
  border: 1px solid rgba(111, 144, 199, 0.18);
  background: linear-gradient(180deg, rgba(20, 35, 66, 0.92), rgba(14, 25, 49, 0.96));
  display: grid;
  gap: 10px;
}

.flow-node-body {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 170px;
  gap: 16px;
  align-items: start;
}

.flow-node-body.flow-node-body-items-only {
  grid-template-columns: 1fr;
}

.flow-node-body.flow-node-body-items-only .portrait-row {
  justify-content: center;
}

.flow-node-main {
  display: grid;
  gap: 14px;
}

.flow-node p {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.portrait-row {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
}

.portrait-row-items {
  gap: 12px;
}

.unit-badge,
.item-badge {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  min-width: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  font-size: 0.9rem;
}

.unit-badge img,
.item-badge img {
  width: 28px;
  height: 28px;
  border-radius: 8px;
}

.unit-portrait,
.item-portrait {
  position: relative;
  display: inline-flex;
  border-radius: 16px;
  transition: transform 160ms ease, box-shadow 160ms ease;
}

.unit-portrait:hover,
.item-portrait:hover {
  transform: translateY(-2px) scale(1.03);
}

.unit-portrait::after,
.item-portrait::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(4px);
  padding: 7px 10px;
  border-radius: 10px;
  background: rgba(3, 11, 23, 0.96);
  border: 1px solid rgba(95, 208, 255, 0.25);
  color: var(--text);
  font-size: 0.78rem;
  line-height: 1;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease, transform 140ms ease;
  z-index: 4;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.28);
}

.unit-portrait:hover::after,
.item-portrait:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.unit-portrait-image,
.item-portrait-image {
  width: 60px;
  height: 60px;
  border-radius: 16px;
  object-fit: cover;
  display: block;
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
}

.item-portrait-image {
  width: 45px;
  height: 45px;
  border-radius: 12px;
}

.flow-node .unit-portrait-image,
.flow-node .item-portrait-image {
  display: block;
}

.portrait-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 999px;
  background: rgba(3, 11, 23, 0.9);
  color: var(--text);
  cursor: pointer;
  opacity: 0;
  transition: opacity 140ms ease;
}

.unit-portrait:hover .portrait-remove,
.item-portrait:hover .portrait-remove {
  opacity: 1;
}

.empty-portrait-state {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px dashed rgba(111, 144, 199, 0.3);
  color: var(--text-soft);
  background: rgba(255, 255, 255, 0.03);
  font-size: 0.88rem;
}

.dropzone-active {
  border-color: rgba(95, 208, 255, 0.5);
  background: rgba(95, 208, 255, 0.08);
}

.trait-sidebar {
  display: grid;
  gap: 10px;
  padding: 12px;
  border-radius: 16px;
  border: 1px solid rgba(111, 144, 199, 0.18);
  background: rgba(7, 16, 32, 0.56);
}

.trait-list {
  display: grid;
  gap: 10px;
}

.trait-row {
  display: grid;
  gap: 7px;
}

.trait-row-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.trait-name {
  font-size: 0.88rem;
  font-weight: 700;
}

.trait-breakpoints {
  display: flex;
  gap: 6px;
  align-items: center;
}

.trait-breakpoint {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  height: 24px;
  padding: 0 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-soft);
  font-size: 0.76rem;
  font-weight: 700;
}

.trait-breakpoint.active {
  background: rgba(255, 189, 103, 0.16);
  border-color: rgba(255, 189, 103, 0.3);
  color: #ffd9a1;
}

.trait-tier-base {
  background: rgba(95, 208, 255, 0.12);
  border-color: rgba(95, 208, 255, 0.2);
  color: #c9f2ff;
}

.trait-tier-bronze {
  background: rgba(198, 133, 89, 0.18);
  border-color: rgba(198, 133, 89, 0.36);
  color: #ffd7b5;
}

.trait-tier-silver {
  background: rgba(176, 196, 222, 0.18);
  border-color: rgba(176, 196, 222, 0.34);
  color: #eff6ff;
}

.trait-tier-gold {
  background: rgba(255, 189, 103, 0.18);
  border-color: rgba(255, 189, 103, 0.36);
  color: #ffe1a9;
}

.trait-tier-prismatic {
  background: rgba(120, 124, 255, 0.2);
  border-color: rgba(144, 160, 255, 0.4);
  color: #eef0ff;
}

.trait-breakpoint-separator {
  color: var(--text-soft);
  font-size: 0.8rem;
  font-weight: 700;
}

.empty-trait-state {
  color: var(--text-soft);
  font-size: 0.86rem;
  line-height: 1.4;
}

.flow-notes-panel {
  margin: 0 28px 28px;
  padding: 18px;
  border-radius: 18px;
  border: 1px solid rgba(111, 144, 199, 0.18);
  background: rgba(9, 18, 35, 0.72);
}

.flow-notes-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.flow-notes-header h3 {
  margin: 0;
  font-size: 0.96rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-warm);
}

.flow-notes-grid {
  display: grid;
  gap: 10px;
}

.flow-note-entry {
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
}

.flow-note-entry-overview {
  background: rgba(95, 208, 255, 0.06);
  border-color: rgba(95, 208, 255, 0.16);
}

.flow-note-label {
  display: inline-block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-soft);
}

.flow-note-entry p,
.flow-notes-empty {
  margin: 0;
  color: var(--text-muted);
  line-height: 1.5;
}

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

/* ──────────────────────────────────────────────
   Gallery View
   ────────────────────────────────────────────── */
.gallery-view {
  margin-top: 20px;
  padding-bottom: 40px;
}

.gallery-toolbar {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
}

.search-input {
  flex: 1;
  padding: 12px 20px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(15, 28, 53, 0.7);
  color: var(--text);
  font-size: 0.96rem;
  outline: none;
  transition: border-color 160ms ease;
}

.search-input::placeholder {
  color: var(--text-soft);
}

.search-input:focus {
  border-color: rgba(95, 208, 255, 0.45);
}

.lines-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.gallery-empty {
  text-align: center;
  color: var(--text-soft);
  padding: 48px 0;
  margin: 0;
}

.line-row {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 14px 18px;
  border-radius: var(--radius-md);
  border: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
  cursor: pointer;
  text-align: left;
  transition: transform 120ms ease, border-color 160ms ease;
}

.line-row:hover {
  transform: translateY(-1px);
  border-color: rgba(95, 208, 255, 0.3);
}

.line-row-info {
  width: 200px;
  flex-shrink: 0;
}

.line-row-name {
  margin: 0 0 5px;
  font-weight: 700;
  font-size: 0.96rem;
}

.line-row-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.path-tag {
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-soft);
  font-size: 0.74rem;
  font-weight: 600;
  letter-spacing: 0.05em;
}

.line-row-nodes {
  display: flex;
  gap: 10px;
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.line-node-preview {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(111, 144, 199, 0.18);
  background: rgba(14, 25, 48, 0.7);
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.line-node-preview-label {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--accent-warm);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.line-node-preview-portraits {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.preview-unit-wrap {
  display: inline-flex;
  border-radius: 10px;
}

.line-node-preview-portraits .preview-unit-image {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.08);
}

.line-node-preview-items {
  display: flex;
  flex-wrap: wrap;
  gap: 3px;
}

.line-node-preview-items .preview-item-image {
  width: 22px;
  height: 22px;
  border-radius: 6px;
  object-fit: cover;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.06);
}

.line-node-preview-empty {
  font-size: 0.78rem;
  color: var(--text-soft);
}

.line-row-actions {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
}

/* ──────────────────────────────────────────────
   Editor Overlay (bottom-sheet)
   ────────────────────────────────────────────── */
.editor-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-end;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.editor-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.editor-sheet {
  max-height: 92vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border: 1px solid var(--line);
  border-bottom: none;
  background: #09111e;
  transform: translateY(32px);
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

.editor-overlay.open .editor-sheet {
  transform: translateY(0);
}

.editor-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(22px);
  flex-shrink: 0;
}

.editor-header-title {
  flex: 1;
  min-width: 0;
}

.editor-header-title h2 {
  font-size: 1.05rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.path-name-input {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 8px;
  color: var(--text);
  font-size: 1.05rem;
  font-weight: 700;
  font-family: inherit;
  padding: 3px 7px;
  margin-left: -7px;
  transition: border-color 160ms ease, background 160ms ease;
}

.path-name-input:hover {
  border-color: var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.path-name-input:focus {
  outline: none;
  border-color: rgba(95, 208, 255, 0.45);
  background: rgba(95, 208, 255, 0.06);
}

.editor-header-title .panel-subtitle {
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 2px 0 0;
}

.editor-header-status {
  flex-shrink: 0;
}

.editor-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.editor-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ──────────────────────────────────────────────
   Viewer Overlay (centered modal)
   ────────────────────────────────────────────── */
.viewer-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(6px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 220ms ease;
}

.viewer-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.viewer-sheet {
  width: min(1400px, calc(100vw - 48px));
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: #09111e;
  transform: scale(0.97);
  transition: transform 260ms cubic-bezier(0.22, 1, 0.36, 1);
  overflow: hidden;
}

.viewer-overlay.open .viewer-sheet {
  transform: scale(1);
}

.viewer-header {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  backdrop-filter: blur(22px);
  flex-shrink: 0;
}

.viewer-header-title {
  flex: 1;
  min-width: 0;
}

.viewer-path-name {
  font-size: 1.05rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 0;
}

.viewer-header-title .panel-subtitle {
  font-size: 0.82rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin: 2px 0 0;
}

.viewer-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
}

.viewer-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.stage-heading-text {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  padding: 3px 7px;
}

/* ── Cost-tier outline colours ── */
[data-cost="1"] .unit-portrait-image,
.preview-unit-wrap[data-cost="1"] .preview-unit-image,
.bench-unit[data-cost="1"] .bench-unit-image {
  border: 2px solid rgba(160, 160, 160, 0.8);
}

[data-cost="2"] .unit-portrait-image,
.preview-unit-wrap[data-cost="2"] .preview-unit-image,
.bench-unit[data-cost="2"] .bench-unit-image {
  border: 2px solid rgba(28, 180, 84, 0.9);
}

[data-cost="3"] .unit-portrait-image,
.preview-unit-wrap[data-cost="3"] .preview-unit-image,
.bench-unit[data-cost="3"] .bench-unit-image {
  border: 2px solid rgba(47, 125, 219, 0.95);
}

[data-cost="4"] .unit-portrait-image,
.preview-unit-wrap[data-cost="4"] .preview-unit-image,
.bench-unit[data-cost="4"] .bench-unit-image {
  border: 2px solid rgba(196, 75, 227, 0.95);
}

[data-cost="5"] .unit-portrait-image,
.preview-unit-wrap[data-cost="5"] .preview-unit-image,
.bench-unit[data-cost="5"] .bench-unit-image {
  border: 2px solid rgba(240, 180, 41, 1);
  box-shadow: 0 0 8px rgba(240, 180, 41, 0.35);
}

.hidden {
  display: none;
}


@media (max-width: 740px) {
  .app-shell {
    width: min(100vw - 16px, 1600px);
    margin: 8px auto 24px;
  }

  .hero,
  .panel {
    padding: 16px;
    border-radius: 20px;
  }

  .hero {
    flex-direction: column;
  }

  .hero-actions {
    justify-content: flex-start;
  }

  .flowchart-layout {
    grid-template-columns: 1fr;
    padding: 18px;
  }

  .flow-node-body {
    grid-template-columns: 1fr;
  }

  .flow-notes-panel {
    margin: 0 18px 18px;
  }

  .flowchart-lines {
    display: none;
  }
}

.legal {
  text-align: center;
  padding: 1.5rem;
  font-size: 0.75rem;
  color: #666;
}
