:root {
  --bg: #f4efe7;
  --bg-accent: #efe2d0;
  --panel: rgba(255, 250, 244, 0.88);
  --panel-border: rgba(91, 56, 37, 0.12);
  --text: #2a1f1a;
  --muted: #715f56;
  --primary: #a84f2d;
  --primary-strong: #7f3618;
  --secondary: #215e63;
  --node: #fff5e8;
  --node-active: #ffd7af;
  --line: rgba(65, 44, 32, 0.22);
  --shadow: 0 20px 50px rgba(84, 52, 33, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "IBM Plex Sans", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.8), transparent 28%),
    radial-gradient(circle at bottom right, rgba(198, 126, 83, 0.22), transparent 24%),
    linear-gradient(135deg, var(--bg) 0%, var(--bg-accent) 100%);
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
  border-radius: 999px;
  filter: blur(10px);
}

body::before {
  top: 72px;
  right: 10vw;
  width: 240px;
  height: 240px;
  background: rgba(33, 94, 99, 0.12);
}

body::after {
  left: -50px;
  bottom: 10vh;
  width: 260px;
  height: 260px;
  background: rgba(168, 79, 45, 0.11);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1240px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 40px 0 56px;
}

.hero {
  display: grid;
  grid-template-columns: 1.3fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.hero-copy,
.topic-form,
.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 28px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
}

.hero-copy {
  padding: 32px;
}

.eyebrow,
.panel-label {
  margin: 0 0 10px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  color: var(--secondary);
  font-weight: 600;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  line-height: 1.02;
}

h1 {
  font-size: clamp(2.7rem, 5vw, 4.6rem);
  max-width: 11ch;
}

.hero-text {
  margin: 18px 0 0;
  font-size: 1.05rem;
  line-height: 1.7;
  color: var(--muted);
  max-width: 58ch;
}

.topic-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 28px;
}

.input-label {
  font-weight: 600;
  margin-bottom: 12px;
}

.input-row {
  display: flex;
  gap: 12px;
}

.input-row input {
  flex: 1;
  border: 1px solid rgba(91, 56, 37, 0.18);
  border-radius: 18px;
  padding: 16px 18px;
  font-size: 1rem;
  font-family: inherit;
  background: rgba(255, 255, 255, 0.82);
}

.input-row input:focus,
.quick-topic:focus,
.node-button:focus {
  outline: 3px solid rgba(33, 94, 99, 0.22);
  outline-offset: 2px;
}

.input-row button,
.quick-topic {
  border: none;
  cursor: pointer;
  font-family: inherit;
  transition: transform 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.input-row button {
  padding: 0 22px;
  border-radius: 18px;
  font-weight: 700;
  color: #fff9f3;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-strong) 100%);
  box-shadow: 0 12px 24px rgba(127, 54, 24, 0.22);
}

.input-row button:hover,
.quick-topic:hover,
.node-button:hover {
  transform: translateY(-1px);
}

.input-row button:disabled,
.quick-topic:disabled,
.input-row input:disabled {
  cursor: wait;
  opacity: 0.72;
}

.quick-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.status-message {
  margin: 14px 0 0;
  min-height: 1.5em;
  color: var(--muted);
  line-height: 1.5;
}

.status-message[data-state="error"] {
  color: #9a2d1f;
}

.status-message[data-state="loading"] {
  color: var(--secondary);
  font-weight: 600;
}

.quick-topic {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(33, 94, 99, 0.09);
  color: var(--secondary);
  font-weight: 600;
}

.dashboard {
  display: grid;
  grid-template-columns: 1.7fr 0.9fr;
  gap: 24px;
}

.panel {
  padding: 24px;
}

.panel-heading {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

.panel-note {
  margin: 0;
  max-width: 24ch;
  color: var(--muted);
  font-size: 0.95rem;
}

.breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 18px;
}

.breadcrumb button,
.secondary-button,
.history-item button {
  border: 1px solid rgba(91, 56, 37, 0.15);
  background: rgba(255, 255, 255, 0.75);
  color: var(--text);
  cursor: pointer;
  transition: transform 180ms ease, background 180ms ease;
}

.breadcrumb button,
.secondary-button {
  padding: 9px 14px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 600;
}

.breadcrumb button:hover,
.secondary-button:hover,
.history-item button:hover {
  transform: translateY(-1px);
}

.breadcrumb button.active {
  background: rgba(33, 94, 99, 0.12);
  color: var(--secondary);
}

.map-surface {
  position: relative;
  margin-top: 20px;
  min-height: 680px;
  border-radius: 24px;
  overflow: hidden;
  background:
    linear-gradient(rgba(255, 255, 255, 0.5), rgba(255, 255, 255, 0.4)),
    radial-gradient(circle at 20% 20%, rgba(168, 79, 45, 0.08), transparent 32%),
    radial-gradient(circle at 80% 80%, rgba(33, 94, 99, 0.08), transparent 25%);
}

#concept-map {
  width: 100%;
  height: 100%;
  display: block;
}

.map-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: rgba(255, 248, 240, 0.72);
  backdrop-filter: blur(6px);
}

.map-loading[hidden] {
  display: none;
}

.map-loading p {
  margin: 0;
  max-width: 28ch;
  color: var(--muted);
  line-height: 1.5;
  font-weight: 600;
}

.loading-spinner {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 4px solid rgba(33, 94, 99, 0.14);
  border-top-color: var(--secondary);
  animation: spin 0.9s linear infinite;
}

.sidebar {
  display: grid;
  gap: 24px;
}

.detail-panel,
.roadmap-panel,
.history-panel {
  min-height: 0;
}

.detail-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
}

#detail-description {
  margin: 14px 0 0;
  line-height: 1.65;
  color: var(--muted);
}

.detail-points,
.roadmap-list {
  margin: 18px 0 0;
  padding-left: 20px;
  color: var(--text);
}

.detail-points li,
.roadmap-list li {
  margin-bottom: 12px;
  line-height: 1.5;
}

.roadmap-list strong {
  display: block;
  margin-bottom: 4px;
  font-family: "Space Grotesk", sans-serif;
}

.history-list {
  display: grid;
  gap: 12px;
  margin-top: 18px;
}

.history-empty {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

.history-item {
  display: grid;
  gap: 8px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(91, 56, 37, 0.12);
  background: rgba(255, 255, 255, 0.52);
}

.history-item button {
  justify-self: start;
  padding: 8px 12px;
  border-radius: 999px;
  font-family: inherit;
  font-weight: 600;
}

.history-topic {
  margin: 0;
  font-family: "Space Grotesk", sans-serif;
  font-size: 1.05rem;
}

.history-meta {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.map-line {
  stroke: var(--line);
  stroke-width: 3;
  stroke-linecap: round;
}

.node-circle {
  fill: var(--node);
  stroke: rgba(91, 56, 37, 0.16);
  stroke-width: 2;
  transition: fill 180ms ease, transform 180ms ease;
}

.node-circle.active {
  fill: var(--node-active);
}

.node-circle.context {
  fill: rgba(33, 94, 99, 0.08);
}

.node-circle.expandable {
  stroke-dasharray: 6 5;
}

.node-label {
  fill: var(--text);
  font-size: 17px;
  font-weight: 600;
  text-anchor: middle;
  dominant-baseline: middle;
  pointer-events: none;
}

.node-button {
  cursor: pointer;
}

.center-node .node-circle {
  fill: rgba(33, 94, 99, 0.12);
  stroke: rgba(33, 94, 99, 0.32);
}

.center-node .node-label {
  font-size: 20px;
  font-family: "Space Grotesk", sans-serif;
}

.context-node .node-label {
  font-size: 15px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 1040px) {
  .hero,
  .dashboard {
    grid-template-columns: 1fr;
  }

  .map-surface {
    min-height: 600px;
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 18px, 100%);
    padding-top: 18px;
  }

  .hero-copy,
  .topic-form,
  .panel {
    border-radius: 22px;
    padding: 20px;
  }

  h1 {
    font-size: 2.6rem;
  }

  .input-row {
    flex-direction: column;
  }

  .detail-header,
  .panel-heading {
    flex-direction: column;
  }

  .input-row button {
    padding: 14px 18px;
  }

  .map-surface {
    min-height: 520px;
  }
}
