.atlas-starter {
  margin: 16px 0;
  border: 2px solid var(--accent);
  background: var(--field);
}

.atlas-starter summary {
  padding: 14px 16px;
  cursor: pointer;
  color: var(--accent-dark);
  font: 700 20px/1.3 var(--display);
}

.atlas-starter[open] > summary {
  border-bottom: 1px solid var(--line);
}

.atlas-starter-body {
  padding: 16px;
}

.atlas-start-choices {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 13px;
}

.atlas-start-choices button {
  min-height: 88px;
  padding: 15px;
  text-align: left;
}

.atlas-start-choices strong,
.atlas-start-choices span {
  display: block;
}

.atlas-start-choices strong {
  margin-bottom: 6px;
  font: 700 19px var(--display);
}

.atlas-start-choices span {
  font-weight: 400;
  line-height: 1.4;
}

.atlas-vision {
  margin-top: 14px;
  padding: 14px;
  border-left: 5px solid var(--gold);
  background: var(--paper);
}

.atlas-vision textarea {
  min-height: 150px;
}

.atlas-framework {
  margin-top: 14px;
  border: 1px solid var(--line);
  background: var(--paper);
}

.atlas-framework > summary {
  cursor: pointer;
  padding: 12px 14px;
  color: var(--accent-dark);
  font-weight: 800;
}

.atlas-framework[open] > summary {
  border-bottom: 1px solid var(--line);
}

.atlas-framework-body {
  padding: 14px;
}

.atlas-framework-explanation,
.atlas-template-help {
  margin: 10px 0;
  padding: 10px 12px;
  border-left: 4px solid var(--gold);
  background: var(--field);
  white-space: pre-line;
}

#atlas-vision-status {
  min-height: 22px;
  margin-bottom: 0;
  font-weight: 700;
  color: var(--accent-dark);
}

.atlas-guide {
  margin: 16px 0;
  border: 2px solid var(--gold);
  background: var(--field);
}

.atlas-guide summary {
  padding: 14px 16px;
  cursor: pointer;
  color: var(--accent-dark);
  font: 700 18px/1.3 var(--display);
}

.atlas-guide summary:hover,
.atlas-guide summary:focus-visible {
  background: color-mix(in srgb, var(--gold) 14%, transparent);
}

.atlas-guide-body {
  padding: 0 18px 18px;
  border-top: 1px solid var(--line);
}

.atlas-guide-intro {
  margin-bottom: 8px;
}

.atlas-guide ol {
  display: grid;
  gap: 8px;
  margin: 10px 0 16px;
  padding-left: 24px;
}

.atlas-guide li {
  padding-left: 4px;
}

.atlas-guide .quick-row {
  align-items: center;
}

.atlas-guide .microcopy {
  margin: 0;
}

.required-note {
  color: var(--accent-dark);
  font-size: .82em;
}

.atlas-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: end;
  margin: 18px 0;
  padding: 14px;
  border: 1px solid var(--line);
  background: var(--field);
}

.atlas-toolbar label {
  flex: 1 1 220px;
  margin: 0;
}

.atlas-check {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
}

.atlas-check input {
  width: auto;
  margin: 0;
}

.atlas-tag-field {
  min-width: 0;
}

.atlas-tag-custom {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 7px;
  margin-top: 7px;
}

.atlas-tag-custom[hidden] {
  display: none;
}

.atlas-selected-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  min-height: 28px;
  margin-top: 8px;
}

.atlas-tag-chip {
  padding: 5px 8px;
  border-radius: 999px;
  border: 1px solid var(--accent);
  background: var(--paper);
  color: var(--accent-dark);
  font-size: 12px;
}

.atlas-tag-chip::after {
  content: " ×";
  font-weight: 900;
}

.atlas-layout {
  display: grid;
  grid-template-columns: minmax(250px, 320px) minmax(0, 1fr);
  gap: 16px;
}

.atlas-sidebar,
.atlas-directory,
.atlas-link-list,
.atlas-history-list,
.atlas-appearances {
  display: grid;
  gap: 9px;
}

.atlas-sidebar .play-card {
  padding: 14px;
}

.atlas-directory {
  max-height: 420px;
  overflow: auto;
}

.atlas-directory-button {
  width: 100%;
  padding: 10px 11px;
  text-align: left;
  border-left: 6px solid var(--atlas-color, var(--accent));
}

.atlas-directory-button strong,
.atlas-directory-button span {
  display: block;
}

.atlas-directory-button span {
  margin-top: 3px;
  color: var(--ink-soft);
  font-size: 12px;
}

.atlas-directory-button.selected {
  outline: 3px solid var(--gold);
  outline-offset: 1px;
}

.atlas-canvas-panel {
  position: relative;
  min-width: 0;
}

.atlas-breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
  margin-bottom: 8px;
  padding: 7px 9px;
  border: 1px solid var(--line);
  background: var(--field);
}

.atlas-breadcrumbs button {
  padding: 5px 8px;
  border: 0;
  background: transparent;
  color: var(--accent-dark);
  font-weight: 800;
  text-decoration: underline;
}

.atlas-breadcrumbs button:disabled {
  color: var(--ink);
  text-decoration: none;
  opacity: 1;
}

.atlas-map-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 8px 10px;
  border-left: 5px solid var(--gold);
  background: var(--paper-deep, var(--field));
}

.atlas-map-heading strong,
.atlas-map-heading span { display: block; }
.atlas-map-heading strong { font: 700 20px/1.2 var(--display); }
.atlas-map-heading span { margin-top: 2px; color: var(--ink-soft); font-size: 12px; }

.atlas-canvas-panel:fullscreen,
.atlas-canvas-panel.atlas-fullscreen-fallback {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  padding: 12px;
  overflow: hidden;
  background: var(--paper);
}

.atlas-canvas-panel.atlas-fullscreen-fallback {
  position: fixed;
  z-index: 190;
  inset: 0;
}

.atlas-canvas-panel:fullscreen .atlas-canvas-scroll,
.atlas-canvas-panel.atlas-fullscreen-fallback .atlas-canvas-scroll {
  flex: 1 1 auto;
  height: auto;
  min-height: 0;
}

.atlas-canvas-panel:fullscreen > .microcopy,
.atlas-canvas-panel.atlas-fullscreen-fallback > .microcopy,
.atlas-canvas-panel:fullscreen .atlas-map-heading,
.atlas-canvas-panel.atlas-fullscreen-fallback .atlas-map-heading {
  display: none;
}

.atlas-canvas-panel:fullscreen .atlas-breadcrumbs,
.atlas-canvas-panel.atlas-fullscreen-fallback .atlas-breadcrumbs {
  margin-bottom: 4px;
  padding: 3px 7px;
}

.atlas-canvas-panel:fullscreen .atlas-viewbar,
.atlas-canvas-panel.atlas-fullscreen-fallback .atlas-viewbar {
  margin: 3px 0;
  padding: 4px 6px;
}

.atlas-canvas-panel:fullscreen .atlas-create-palette,
.atlas-canvas-panel.atlas-fullscreen-fallback .atlas-create-palette {
  margin-bottom: 4px;
  padding: 5px 8px;
}

.atlas-canvas-panel:fullscreen .atlas-create-palette > .microcopy,
.atlas-canvas-panel.atlas-fullscreen-fallback .atlas-create-palette > .microcopy {
  display: none;
}

.atlas-viewbar {
  position: sticky;
  top: 0;
  z-index: 12;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 7px;
  margin: 8px 0;
  padding: 7px 9px;
  border: 1px solid var(--line);
  background: var(--field);
}

.atlas-viewbar button {
  min-width: 40px;
  padding: 7px 10px;
}

.atlas-viewbar output {
  min-width: 58px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--paper);
  color: var(--accent-dark);
  font: 800 13px system-ui, sans-serif;
  text-align: center;
}

.atlas-create-palette {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin: 0 0 9px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--field);
}

.atlas-create-palette > div:first-child strong,
.atlas-create-palette > div:first-child span {
  display: block;
}

.atlas-create-palette > div:first-child span {
  color: var(--ink-soft);
  font: 600 11px system-ui, sans-serif;
}

.atlas-palette-tools {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.atlas-palette-tools button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--paper);
  color: var(--ink);
  font: 700 11px system-ui, sans-serif;
}

.atlas-palette-tools button.selected {
  outline: 3px solid var(--gold);
  outline-offset: 1px;
  background: var(--paper-deep, var(--field));
}

.atlas-palette-tools i {
  display: inline-block;
  width: 25px;
  height: 15px;
  border: 2px solid var(--accent);
  background: var(--paper);
}

.atlas-create-palette > .microcopy {
  flex: 1 0 100%;
  margin: 0;
}

.atlas-legend-character { border-radius: 10px 2px 10px 2px; }
.atlas-legend-faction { clip-path: polygon(5px 0, calc(100% - 5px) 0, 100% 50%, calc(100% - 5px) 100%, 5px 100%, 0 50%); }
.atlas-legend-place { clip-path: polygon(5px 0, 100% 0, 100% calc(100% - 5px), calc(100% - 5px) 100%, 0 100%, 0 5px); }
.atlas-legend-story { border-radius: 1px 9px 1px 9px; }
.atlas-legend-object { clip-path: polygon(0 0, calc(100% - 7px) 0, 100% 50%, calc(100% - 7px) 100%, 0 100%); }

.atlas-canvas-scroll {
  max-width: 100%;
  height: 650px;
  overflow: auto;
  border: 2px solid var(--line);
  background: var(--field);
  cursor: grab;
  overscroll-behavior: contain;
  touch-action: none;
}

.atlas-canvas-scroll.panning { cursor: grabbing; }

.atlas-canvas-scroll.drop-ready {
  outline: 4px solid var(--gold);
  outline-offset: -4px;
  background: color-mix(in srgb, var(--gold) 12%, var(--field));
}

.atlas-canvas-scroll.connecting {
  outline: 4px dashed var(--accent);
  outline-offset: -4px;
  cursor: crosshair;
}

.atlas-map-connect {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(180px, 1.4fr) auto auto;
  gap: 8px;
  align-items: end;
  margin: 12px 0;
  padding: 10px;
  border: 1px solid var(--gold);
  background: var(--field);
}

.atlas-map-connect label { margin: 0; }
.atlas-map-connect .atlas-check { align-self: center; }

.atlas-canvas-viewport {
  position: relative;
  width: 1400px;
  height: 850px;
  margin: 0;
}

.atlas-canvas {
  position: absolute;
  inset: 0;
  width: 1400px;
  height: 850px;
  transform-origin: left top;
  background-color: var(--paper);
  background-image: linear-gradient(#806a4715 1px, transparent 1px), linear-gradient(90deg, #806a4715 1px, transparent 1px);
  background-size: 28px 28px;
}

.atlas-minimap {
  position: absolute;
  z-index: 11;
  right: 18px;
  bottom: 38px;
  width: 210px;
  height: 126px;
  overflow: hidden;
  border: 2px solid var(--accent-dark);
  border-radius: 5px;
  background: var(--paper);
  background: color-mix(in srgb, var(--paper) 92%, transparent);
  box-shadow: 2px 4px 12px var(--shadow);
  cursor: crosshair;
}

#atlas-minimap-nodes {
  position: absolute;
  inset: 0;
}

#atlas-minimap-viewport {
  position: absolute;
  left: 0;
  top: 0;
}

.atlas-minimap-dot {
  position: absolute;
  min-width: 4px;
  min-height: 4px;
  border-radius: 2px;
  background: var(--atlas-color, var(--accent));
}

#atlas-minimap-viewport {
  width: 40%;
  height: 40%;
  border: 2px solid var(--gold);
  background: color-mix(in srgb, var(--gold) 15%, transparent);
  pointer-events: none;
}

.atlas-quick-create {
  position: fixed;
  z-index: 260;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: #1b1510a8;
}

.atlas-quick-create[hidden] { display: none; }

.atlas-quick-create form {
  width: min(520px, 100%);
  padding: 20px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  box-shadow: 0 18px 50px #0008;
}

.atlas-quick-create form > label {
  display: grid;
  gap: 5px;
  margin: 12px 0;
  font-weight: 800;
}

.atlas-links {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.atlas-link-line {
  stroke: #7a6041;
  stroke-width: 2.5;
  marker-end: url(#atlas-arrow);
}

.atlas-link-line.private {
  stroke-dasharray: 8 5;
}

.atlas-link-label {
  fill: var(--ink);
  paint-order: stroke;
  stroke: var(--paper);
  stroke-width: 5px;
  stroke-linejoin: round;
  font: 700 13px system-ui, sans-serif;
  text-anchor: middle;
}

.atlas-node {
  position: absolute;
  z-index: 2;
  width: var(--atlas-node-width, 190px);
  min-height: var(--atlas-node-height, 92px);
  padding: 11px 12px;
  text-align: left;
  cursor: grab;
  user-select: none;
  touch-action: none;
  border: 2px solid var(--atlas-color, var(--accent));
  border-top-width: 7px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 3px 5px 12px var(--shadow);
  transition: width .18s ease, min-height .18s ease, box-shadow .18s ease, opacity .18s ease;
}

.atlas-node.atlas-shape-character { border-radius: 30px 9px 30px 9px; }
.atlas-node.atlas-shape-faction { clip-path: polygon(12px 0, calc(100% - 12px) 0, 100% 50%, calc(100% - 12px) 100%, 12px 100%, 0 50%); padding-left: 18px; padding-right: 18px; }
.atlas-node.atlas-shape-place { clip-path: polygon(13px 0, 100% 0, 100% calc(100% - 13px), calc(100% - 13px) 100%, 0 100%, 0 13px); }
.atlas-node.atlas-shape-story { border-radius: 3px 24px 3px 24px; }
.atlas-node.atlas-shape-object { clip-path: polygon(0 0, calc(100% - 18px) 0, 100% 50%, calc(100% - 18px) 100%, 0 100%); padding-right: 22px; }
.atlas-node.atlas-depth-0 { box-shadow: 4px 7px 16px var(--shadow); }
.atlas-node.atlas-depth-1 strong { font-size: 16px; }
.atlas-node.atlas-depth-2 { padding: 9px 10px; border-top-width: 6px; }
.atlas-node.atlas-depth-2 strong { font-size: 14px; }
.atlas-node.atlas-depth-2 span,.atlas-node.atlas-depth-2 small { font-size: 11px; }
.atlas-node.atlas-depth-3 { padding: 8px 9px; border-top-width: 5px; }
.atlas-node.atlas-depth-3 strong { font-size: 13px; }
.atlas-node.atlas-depth-3 span { font-size: 10px; }
.atlas-node.atlas-depth-3 small { display: none; }

.atlas-node.has-submap::after {
  content: "↳ MAP";
  position: absolute;
  right: 7px;
  top: 7px;
  padding: 2px 5px;
  border-radius: 999px;
  background: var(--accent-dark);
  color: var(--paper);
  font: 800 9px system-ui, sans-serif;
  letter-spacing: .05em;
}

.atlas-node:active {
  cursor: grabbing;
}

.atlas-node.selected {
  outline: 4px solid var(--gold);
  outline-offset: 2px;
}

.atlas-node.dimmed {
  opacity: .16;
}

.atlas-node strong,
.atlas-node span,
.atlas-node small {
  display: block;
}

.atlas-node strong {
  font: 700 17px/1.15 var(--display);
}

.atlas-node span {
  margin-top: 5px;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 700;
}

.atlas-node small {
  margin-top: 4px;
  color: var(--ink-soft);
}

.atlas-edit-grid {
  display: grid;
  grid-template-columns: 1.1fr .9fr;
  gap: 16px;
  margin-top: 16px;
}

.atlas-link-record,
.atlas-history-record,
.atlas-appearance-record {
  padding: 10px 11px;
  border-left: 5px solid var(--accent);
  background: var(--field);
}

.atlas-link-record header,
.atlas-history-record header {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.atlas-link-record p,
.atlas-history-record p,
.atlas-appearance-record p {
  margin: 5px 0 0;
  white-space: pre-line;
}

.atlas-history {
  margin-top: 16px;
}

.atlas-time-distance {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.atlas-timeline {
  position: relative;
  padding-left: 24px;
}

.atlas-timeline::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 6px;
  bottom: 6px;
  width: 3px;
  background: var(--gold);
}

.atlas-timeline .atlas-history-record {
  position: relative;
}

.atlas-timeline .atlas-history-record::before {
  content: "";
  position: absolute;
  left: -22px;
  top: 16px;
  width: 11px;
  height: 11px;
  border: 2px solid var(--gold);
  border-radius: 50%;
  background: var(--paper);
}

.atlas-timeline-badge {
  display: inline-block;
  margin: 4px 6px 0 0;
  padding: 2px 7px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.atlas-card-detail {
  position: fixed;
  z-index: 140;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 14px;
  margin: 0;
  background: #0009;
}

.atlas-card-detail[hidden] {
  display: none;
}

.atlas-card-detail-panel {
  width: min(720px, 100%);
  max-height: min(780px, 92vh);
  overflow: auto;
  padding: 18px;
  border: 3px solid var(--gold);
  border-radius: 10px;
  background: var(--paper);
  box-shadow: 0 20px 60px #0009;
}

.atlas-card-detail-panel > header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--line);
}

.atlas-card-detail-panel h2 {
  margin: 3px 0 0;
}

#atlas-card-detail-type {
  color: var(--accent-dark);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: .05em;
}

.atlas-card-detail-section {
  margin-top: 14px;
  padding: 12px;
  border-left: 5px solid var(--accent);
  background: var(--field);
  white-space: pre-line;
}

.atlas-card-detail-section h3 {
  margin: 0 0 7px;
}

.atlas-card-prompts li {
  margin-bottom: 5px;
}

.atlas-book-module {
  margin-top: 16px;
  border: 2px solid var(--accent);
  background: var(--field);
}

.atlas-book-module > summary {
  cursor: pointer;
  padding: 14px 16px;
  color: var(--accent-dark);
  font: 700 20px/1.3 var(--display);
}

.atlas-book-module[open] > summary {
  border-bottom: 1px solid var(--line);
}

.atlas-book-controls {
  padding: 16px;
}

.binding-instructions {
  margin: 4px 15px 14px;
  padding: 10px 12px;
  border-left: 5px solid var(--gold);
  background: var(--paper);
}

.atlas-book-output {
  color: #1d1a17;
  background: #fff;
  font: 11pt/1.45 Georgia, serif;
}

.atlas-book-title-page,
.atlas-book-notes-page {
  display: grid;
  min-height: 9in;
  align-content: center;
  text-align: center;
  break-after: page;
}

.atlas-book-title-page h1 {
  font-size: 34pt;
}

.atlas-book-chapter {
  break-before: page;
}

.atlas-book-output.chapter-front .atlas-book-chapter {
  break-before: right;
}

.atlas-book-record {
  margin: 0 0 16pt;
  padding: 10pt;
  border: 1px solid #777;
  break-inside: avoid;
}

.atlas-book-record h3 {
  margin: 0 0 3pt;
  font-size: 17pt;
}

.atlas-book-meta {
  margin: 0 0 8pt;
  color: #555;
  font-weight: 700;
}

.atlas-book-secret {
  padding: 7pt;
  border-left: 4px solid #791f1f;
  background: #f3eeee;
}

.atlas-book-notes-lines {
  min-height: 7in;
  margin-top: 20pt;
  background: repeating-linear-gradient(to bottom, transparent 0, transparent 25px, #999 26px);
}

.atlas-private-mark {
  color: #8b3c2f;
  font-weight: 700;
}

html[data-theme="scifi"] .atlas-canvas,
html[data-theme="scifi"] .atlas-node {
  background-color: var(--paper);
}

html[data-theme="ink"] .atlas-node {
  box-shadow: none;
}

@media (max-width: 900px) {
  .atlas-layout,
  .atlas-edit-grid {
    grid-template-columns: 1fr;
  }

  .atlas-sidebar {
    grid-template-columns: 1fr 1fr;
  }

  .atlas-canvas-scroll {
    height: 520px;
  }
}

@media (max-width: 620px) {
  .atlas-map-connect {
    grid-template-columns: 1fr;
  }

  .atlas-start-choices {
    grid-template-columns: 1fr;
  }

  .atlas-sidebar {
    grid-template-columns: 1fr;
  }

  .atlas-toolbar > button {
    flex: 1 1 145px;
  }

  .atlas-canvas-scroll {
    height: 460px;
  }

  .atlas-create-palette {
    align-items: stretch;
  }

  .atlas-palette-tools {
    width: 100%;
  }

  .atlas-palette-tools button {
    flex: 1 1 105px;
    justify-content: center;
  }

  .atlas-minimap {
    right: 8px;
    bottom: 34px;
    width: 145px;
    height: 88px;
  }
}

@media print {
  .campaign-atlas {
    display: none !important;
  }

  html.print-atlas-book body > header,
  html.print-atlas-book main > :not(#app-workspace),
  html.print-atlas-book #app-workspace > :not(#campaign-atlas),
  html.print-atlas-book #campaign-atlas > :not(#atlas-book-output) {
    display: none !important;
  }

  html.print-atlas-book #app-workspace,
  html.print-atlas-book #campaign-atlas,
  html.print-atlas-book #atlas-book-output {
    display: block !important;
  }

  html.print-atlas-book #campaign-atlas {
    margin: 0 !important;
    padding: 0 !important;
    border: 0 !important;
    box-shadow: none !important;
  }

}

@page atlasbook-left {
  size: letter;
  margin: .65in .65in .7in .95in;
}

@page atlasbook-left:left {
  margin-left: .65in;
  margin-right: .95in;
}

@page atlasbook-left:right {
  margin-left: .95in;
  margin-right: .65in;
}

@page atlasbook-right {
  size: letter;
  margin: .65in .95in .7in .65in;
}

@page atlasbook-right:left {
  margin-left: .95in;
  margin-right: .65in;
}

@page atlasbook-right:right {
  margin-left: .65in;
  margin-right: .95in;
}

@page atlasbook-single {
  size: letter;
  margin: .65in .7in .7in .9in;
}

.atlas-book-output.binding-left { page: atlasbook-left; }
.atlas-book-output.binding-right { page: atlasbook-right; }
.atlas-book-output.binding-single { page: atlasbook-single; }
