:root {
  color-scheme: light;
  --ink: #18201f;
  --muted: #62706d;
  --line: #d9e1dc;
  --paper: #fbfcf9;
  --panel: #ffffff;
  --mint: #16a085;
  --mint-dark: #0d6f61;
  --coral: #ff7b54;
  --yellow: #f5c542;
  --blue: #3f7cac;
  --shadow: 0 18px 50px rgba(25, 42, 39, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 72% 8%, rgba(245, 197, 66, 0.16), transparent 28%),
    linear-gradient(120deg, rgba(22, 160, 133, 0.09), rgba(255, 123, 84, 0.07)),
    var(--paper);
  color: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
textarea,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  display: grid;
  grid-template-columns: 292px minmax(0, 1fr);
  min-height: 100vh;
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 22px;
  border-right: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.72);
  backdrop-filter: blur(18px);
  display: flex;
  flex-direction: column;
  gap: 22px;
  min-width: 0;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-weight: 800;
}

.brand-name {
  font-weight: 800;
}

.brand-subtitle,
.eyebrow,
.meter-panel p,
.price-card p,
.run-grid span,
.quiz-top span {
  color: var(--muted);
}

.brand-subtitle {
  font-size: 13px;
}

.nav-list {
  display: grid;
  gap: 8px;
}

.nav-item {
  min-height: 42px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink);
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 0 12px;
  text-align: left;
}

.nav-item span {
  width: 22px;
  text-align: center;
  color: var(--mint-dark);
}

.nav-item.active,
.nav-item:hover {
  background: rgba(22, 160, 133, 0.12);
}

.meter-panel,
.run-card,
.account-panel,
.composer,
.visual-board,
.insight-panel,
.trust-panel,
.events-panel,
.price-card,
.library-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.92);
  box-shadow: 0 8px 28px rgba(25, 42, 39, 0.06);
}

.meter-panel,
.run-card,
.account-panel {
  padding: 16px;
}

.account-panel {
  display: grid;
  gap: 12px;
}

.account-label {
  display: block;
  margin-bottom: 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.member-badge {
  display: inline-flex;
  width: fit-content;
  padding: 5px 9px;
  border-radius: 999px;
  background: rgba(63, 124, 172, 0.1);
  color: var(--blue);
  font-size: 12px;
  font-weight: 800;
}

.member-badge.active {
  background: rgba(22, 160, 133, 0.12);
  color: var(--mint-dark);
}

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

.meter-top,
.quiz-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.meter-track {
  height: 8px;
  margin: 12px 0;
  overflow: hidden;
  border-radius: 999px;
  background: #e8eee9;
}

.meter-fill {
  height: 100%;
  width: 40%;
  background: linear-gradient(90deg, var(--mint), var(--coral));
}

.meter-panel p {
  margin: 0;
  font-size: 13px;
  line-height: 1.45;
}

.run-label {
  color: var(--coral);
  font-weight: 800;
  font-size: 12px;
  text-transform: uppercase;
}

.run-id {
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 13px;
}

.run-grid {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
}

.main-panel {
  padding: 28px;
  min-width: 0;
}

.hidden {
  display: none;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 20px;
}

.topbar > div {
  min-width: 0;
}

.topbar h1 {
  max-width: 760px;
  margin: 4px 0 0;
  font-size: clamp(30px, 4vw, 54px);
  line-height: 1.02;
  letter-spacing: 0;
}

.hero-copy {
  max-width: 680px;
  margin: 12px 0 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.55;
}

.eyebrow {
  margin: 0;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.icon-button {
  width: 46px;
  height: 46px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  color: var(--coral);
  font-size: 24px;
}

.icon-button.small {
  width: 36px;
  height: 36px;
  font-size: 20px;
}

.composer {
  padding: 16px;
  margin-bottom: 18px;
}

.mode-tabs {
  display: inline-flex;
  gap: 4px;
  padding: 4px;
  margin-bottom: 14px;
  border-radius: 8px;
  background: #edf3ef;
}

.mode {
  min-width: 88px;
  border: 0;
  border-radius: 6px;
  padding: 9px 12px;
  background: transparent;
  color: var(--muted);
  font-weight: 700;
}

.mode.active {
  background: white;
  color: var(--ink);
  box-shadow: 0 2px 8px rgba(25, 42, 39, 0.1);
}

.composer label {
  display: block;
  margin-bottom: 8px;
  font-weight: 800;
}

textarea {
  width: 100%;
  min-height: 142px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  color: var(--ink);
  background: #fbfdfb;
  line-height: 1.5;
}

textarea:focus,
input:focus,
button:focus-visible {
  outline: 3px solid rgba(22, 160, 133, 0.22);
  outline-offset: 2px;
}

input {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--ink);
  background: #fbfdfb;
}

.composer-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.primary-action,
.secondary-action {
  min-height: 42px;
  border-radius: 8px;
  padding: 0 16px;
  border: 1px solid transparent;
  font-weight: 800;
}

.primary-action {
  background: var(--ink);
  color: white;
}

.primary-action:hover {
  background: #26312f;
}

.secondary-action {
  background: white;
  color: var(--ink);
  border-color: var(--line);
}

.secondary-action:hover {
  border-color: var(--mint);
}

.compact {
  min-height: 34px;
  padding: 0 12px;
}

.workspace-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(310px, 0.75fr);
  gap: 18px;
  min-width: 0;
}

.visual-board,
.insight-panel,
.trust-panel,
.events-panel {
  padding: 18px;
  min-width: 0;
}

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

.section-heading h2 {
  margin: 2px 0 0;
  font-size: 22px;
}

.section-heading.tight h2 {
  font-size: 18px;
}

.status-pill {
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(22, 160, 133, 0.12);
  color: var(--mint-dark);
  font-weight: 800;
  font-size: 12px;
}

.map {
  position: relative;
  min-height: 430px;
  border-radius: 8px;
  overflow: hidden;
  background:
    linear-gradient(90deg, rgba(24, 32, 31, 0.05) 1px, transparent 1px),
    linear-gradient(rgba(24, 32, 31, 0.05) 1px, transparent 1px),
    #f8fbf7;
  background-size: 42px 42px;
}

.map-svg {
  display: block;
  width: 100%;
  min-height: 430px;
  height: clamp(430px, 46vw, 540px);
}

.map-link {
  fill: none;
  stroke: rgba(24, 32, 31, 0.28);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.map-link.active-link {
  stroke: rgba(22, 160, 133, 0.62);
  stroke-width: 2.6;
}

.map-node rect {
  fill: #ffffff;
  stroke: rgba(24, 32, 31, 0.14);
  stroke-width: 1.2;
  filter: drop-shadow(0 10px 18px rgba(25, 42, 39, 0.12));
}

.map-node text {
  fill: var(--ink);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

.map-node .node-title {
  font-size: 16px;
  font-weight: 800;
}

.map-node .node-body {
  fill: var(--muted);
  font-size: 11px;
}

.map-node .node-accent {
  stroke-width: 5;
  stroke-linecap: round;
}

.map-node.center-node rect {
  fill: var(--ink);
  stroke: var(--ink);
}

.map-node.center-node text {
  fill: #ffffff;
}

.map-node.center-node .node-body {
  fill: rgba(255, 255, 255, 0.78);
}

.map-node.center-node .node-accent {
  stroke: var(--mint);
}

.map-badge {
  fill: rgba(22, 160, 133, 0.1);
  stroke: rgba(22, 160, 133, 0.28);
}

.map-badge-text {
  fill: var(--mint-dark);
  font-size: 11px;
  font-weight: 800;
}

.node {
  position: absolute;
  width: min(190px, 38%);
  min-height: 74px;
  border: 1px solid rgba(24, 32, 31, 0.14);
  border-radius: 8px;
  padding: 12px;
  background: white;
  box-shadow: var(--shadow);
}

.node strong {
  display: block;
  margin-bottom: 6px;
}

.node span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.node.center {
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: var(--ink);
  color: white;
}

.node.center span {
  color: rgba(255, 255, 255, 0.78);
}

.node.n1 {
  left: 6%;
  top: 11%;
  border-top: 5px solid var(--mint);
}

.node.n2 {
  right: 7%;
  top: 12%;
  border-top: 5px solid var(--coral);
}

.node.n3 {
  left: 8%;
  bottom: 12%;
  border-top: 5px solid var(--blue);
}

.node.n4 {
  right: 9%;
  bottom: 10%;
  border-top: 5px solid var(--yellow);
}

.connector {
  position: absolute;
  height: 2px;
  background: rgba(24, 32, 31, 0.22);
  transform-origin: left center;
}

.action-list,
.trust-list,
#quizList {
  display: grid;
  gap: 10px;
}

.action-card,
.trust-card,
.quiz-item,
.library-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  padding: 12px;
}

.action-card strong,
.trust-card strong,
.quiz-item strong {
  display: block;
  margin-bottom: 4px;
}

.action-card p,
.trust-card p,
.quiz-item p {
  margin: 0;
  color: var(--muted);
  line-height: 1.4;
  font-size: 14px;
}

.quiz-box {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}

.quiz-top {
  margin-bottom: 10px;
}

.bottom-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 0.75fr);
  gap: 18px;
  margin-top: 18px;
}

.event-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  max-height: 250px;
  overflow: auto;
}

.event-list li {
  padding: 10px;
  border-radius: 8px;
  background: #f2f6f2;
  color: var(--muted);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 12px;
}

.export-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.export-option {
  min-height: 52px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
  color: var(--ink);
  font-weight: 800;
}

.export-option:hover {
  border-color: var(--mint);
  background: rgba(22, 160, 133, 0.08);
}

.export-note {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: 14px;
}

.payment-state {
  margin-top: 14px;
  color: var(--muted);
  line-height: 1.45;
  font-size: 14px;
}

.payment-result {
  margin-top: 14px;
  display: grid;
  gap: 10px;
}

.payment-result img {
  width: 188px;
  max-width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  background: white;
}

.payment-order {
  display: grid;
  gap: 4px;
  color: var(--muted);
  font-size: 13px;
}

.hidden-events {
  display: none;
}

.pricing-grid,
.library-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.pricing-grid.single-plan {
  grid-template-columns: minmax(280px, 520px);
}

.price-card,
.library-item {
  padding: 18px;
}

.price-card h2 {
  margin: 4px 0;
  font-size: 34px;
}

.price-card.featured {
  border-color: var(--mint);
  box-shadow: var(--shadow);
}

.price-card .primary-action,
.price-card .secondary-action {
  margin-top: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(24, 32, 31, 0.38);
}

.modal-backdrop.hidden {
  display: none;
}

.auth-dialog {
  width: min(860px, 100%);
  max-height: min(760px, calc(100vh - 40px));
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 20px;
  box-shadow: var(--shadow);
}

.auth-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.auth-section {
  display: grid;
  gap: 9px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfdfb;
}

.auth-section h3 {
  margin: 0 0 4px;
}

.auth-section label {
  font-size: 13px;
  font-weight: 800;
}

.inline-fields {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.auth-message {
  min-height: 20px;
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.45;
}

.auth-message.error {
  color: #b42318;
}

.auth-message.success {
  color: var(--mint-dark);
}

.library-item h3 {
  margin: 0 0 8px;
}

.library-item p {
  margin: 0;
  color: var(--muted);
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace-grid,
  .bottom-grid,
  .pricing-grid,
  .library-grid,
  .auth-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px) {
  .main-panel,
  .sidebar {
    padding: 16px;
  }

  .topbar {
    align-items: stretch;
    flex-wrap: wrap;
    gap: 12px;
  }

  .topbar h1 {
    max-width: 100%;
    font-size: 32px;
  }

  .icon-button {
    flex: 0 0 auto;
  }

  .map {
    min-height: 640px;
  }

  .map-svg {
    min-height: 640px;
    height: 640px;
  }

  .map-node .node-title {
    font-size: 17px;
  }

  .map-node .node-body {
    font-size: 11px;
  }

  .export-actions {
    grid-template-columns: 1fr;
  }
}
