:root {
  --bg: #f3efe5;
  --panel: rgba(255, 252, 245, 0.9);
  --panel-strong: #fffdf8;
  --ink: #1e1c1a;
  --muted: #6b665f;
  --line: rgba(30, 28, 26, 0.12);
  --accent: #d65a31;
  --accent-2: #174c4f;
  --defined: #f3b341;
  --undefined: #fbf6ea;
  --channel-off: rgba(30, 28, 26, 0.12);
  --channel-on: #d65a31;
  --success: #1f7a53;
  --shadow: 0 20px 60px rgba(67, 43, 20, 0.12);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "IBM Plex Sans Thai", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(214, 90, 49, 0.18), transparent 28%),
    radial-gradient(circle at right center, rgba(23, 76, 79, 0.16), transparent 24%),
    linear-gradient(180deg, #f8f4eb 0%, var(--bg) 100%);
  min-height: 100vh;
}

a {
  color: inherit;
}

.shell {
  width: min(1320px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 48px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 18px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 14px;
  text-decoration: none;
}

.brand-mark {
  width: 56px;
  height: 56px;
  border-radius: 18px;
  background: linear-gradient(145deg, rgba(214, 90, 49, 0.14), rgba(23, 76, 79, 0.12));
  border: 1px solid rgba(30, 28, 26, 0.1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(67, 43, 20, 0.08);
}

.brand-mark svg {
  width: 36px;
  height: 36px;
  fill: none;
  stroke: var(--accent-2);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.brand-copy {
  display: grid;
  gap: 2px;
}

.brand-copy strong {
  font: 700 1.06rem/1.1 "Space Grotesk", sans-serif;
}

.brand-copy small {
  color: var(--muted);
  font-size: 0.8rem;
}

.top-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.top-nav a {
  text-decoration: none;
  color: var(--muted);
  padding: 10px 14px;
  border-radius: 999px;
  transition: background 160ms ease, color 160ms ease;
}

.top-nav a:hover {
  background: rgba(255, 255, 255, 0.66);
  color: var(--ink);
}

.language-switcher {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: 4px;
  padding-left: 8px;
  border-left: 1px solid rgba(30, 28, 26, 0.1);
}

.lang-button {
  width: auto;
  border-radius: 999px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.62);
  color: var(--muted);
  border: 1px solid rgba(30, 28, 26, 0.1);
  font: 600 0.84rem/1 "Space Grotesk", "IBM Plex Sans Thai", sans-serif;
  cursor: pointer;
  white-space: nowrap;
}

.lang-button.active {
  background: var(--accent-2);
  color: #fff;
  border-color: var(--accent-2);
  box-shadow: 0 10px 24px rgba(23, 76, 79, 0.18);
}

.hero {
  margin-bottom: 24px;
}

.hero-copy,
.card {
  background: var(--panel);
  backdrop-filter: blur(18px);
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.hero-copy {
  padding: 28px 30px;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.eyebrow,
.kicker {
  margin: 0 0 8px;
  font: 700 0.78rem/1 "Space Grotesk", sans-serif;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--accent-2);
}

h1,
h2,
h3,
strong,
button {
  font-family: "Space Grotesk", sans-serif;
}

h1 {
  margin: 0 0 12px;
  font-size: clamp(2rem, 5vw, 4.2rem);
  line-height: 0.95;
}

.lede,
.hint,
.status,
.empty-state p {
  color: var(--muted);
}

.grid {
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  gap: 24px;
  align-items: start;
}

.card {
  padding: 24px;
}

.section-head h2,
.empty-state h3,
.chips-section h3,
.tables h3 {
  margin: 0;
}

.form {
  display: grid;
  gap: 14px;
}

label span {
  display: block;
  font-weight: 600;
  margin-bottom: 8px;
}

.field-note {
  display: block;
  margin: -2px 0 8px;
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.45;
}

input,
select,
button {
  width: 100%;
  border-radius: 16px;
  border: 1px solid var(--line);
  padding: 14px 16px;
  font: inherit;
}

input,
select {
  background: var(--panel-strong);
}

input:focus,
select:focus,
button:focus {
  outline: 2px solid rgba(214, 90, 49, 0.25);
  outline-offset: 2px;
}

.row.two {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-top: 6px;
}

.btn {
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: var(--accent);
  color: white;
  box-shadow: 0 10px 30px rgba(214, 90, 49, 0.28);
}

.btn-secondary {
  background: #fff8eb;
  color: var(--ink);
}

.status {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.55);
}

.status.success {
  color: var(--success);
}

.status.error {
  color: #a22d2d;
}

.panel-note {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.55;
}

.empty-state {
  padding: 42px 24px;
  text-align: center;
  border: 1px dashed var(--line);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.35);
}

.hidden {
  display: none !important;
}

.summary-band {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 20px;
}

.summary-card,
.mini-card {
  padding: 16px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--line);
}

.label {
  display: block;
  margin-bottom: 8px;
  font-size: 0.82rem;
  color: var(--muted);
}

.label-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.info-button {
  width: 18px;
  height: 18px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(30, 28, 26, 0.18);
  background: rgba(255, 255, 255, 0.7);
  color: var(--accent-2);
  font: 700 11px/1 "Space Grotesk", sans-serif;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}

.info-button:hover {
  background: rgba(23, 76, 79, 0.08);
}

.detail-text {
  margin: 8px 0 0;
  font-size: 0.82rem;
  line-height: 1.45;
  color: var(--muted);
}

.visual-layout {
  display: grid;
  grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.35fr) minmax(220px, 0.9fr);
  gap: 18px;
  margin-bottom: 22px;
  align-items: start;
}

.visual-center {
  display: grid;
  gap: 16px;
}

.graph-panel {
  padding: 12px;
  border-radius: 22px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.82), rgba(250, 242, 228, 0.9));
  border: 1px solid var(--line);
  display: flex;
  justify-content: center;
}

#bodygraph-svg {
  width: 100%;
  height: auto;
  display: block;
  max-width: 420px;
}

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

.activation-sidebar {
  padding: 16px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.48);
}

.activation-sidebar-head {
  margin-bottom: 10px;
}

.activation-label {
  display: inline-block;
  font: 700 0.82rem/1 "Space Grotesk", sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.activation-label.design {
  color: #d71920;
}

.activation-label.personality {
  color: #3d3d3d;
}

.chips-section {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 18px;
  margin-bottom: 18px;
  align-items: start;
}

.chips-section > div {
  padding: 18px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.48);
  min-height: 100%;
}

.chips-section h3 {
  margin-bottom: 4px;
}

.gates-section {
  padding: 20px 22px;
  border-radius: 22px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.48);
  margin-bottom: 22px;
}

.gates-section h3 {
  margin: 0 0 6px;
}

.mechanics-section {
  margin-bottom: 22px;
}

.mechanics-section h3 {
  margin: 0 0 10px;
}

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

.mechanics-grid .mini-card {
  min-height: 110px;
}

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

#gate-chips {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.chip {
  padding: 8px 12px;
  border-radius: 999px;
  background: #fff7e9;
  border: 1px solid rgba(214, 90, 49, 0.18);
  font-size: 0.92rem;
}

.chip.active {
  background: rgba(214, 90, 49, 0.12);
}

.gate-item {
  width: 100%;
  text-align: left;
  padding: 13px 14px;
  border-radius: 18px;
  border: 1px solid rgba(30, 28, 26, 0.12);
  background: rgba(255, 255, 255, 0.72);
  color: var(--ink);
  font: 500 0.96rem/1.35 "Space Grotesk", sans-serif;
  cursor: default;
  display: grid;
  gap: 4px;
  align-content: start;
  min-height: 92px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

.gate-item.gate-state-conscious {
  border-left: 5px solid #4a4a4a;
}

.gate-item.gate-state-unconscious {
  border-left: 5px solid #d71920;
}

.gate-item.gate-state-mixed {
  border-left: 5px solid #d65a31;
}

.gate-item-title {
  display: block;
  font-weight: 700;
  line-height: 1.28;
  text-wrap: pretty;
}

.gate-item-subtitle {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.32;
  text-wrap: balance;
}

.gate-tooltip {
  position: fixed;
  z-index: 1000;
  max-width: min(360px, calc(100vw - 24px));
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(30, 28, 26, 0.12);
  background: rgba(255, 253, 248, 0.97);
  box-shadow: 0 18px 40px rgba(67, 43, 20, 0.18);
  pointer-events: none;
}

.gate-tooltip-hex {
  font: 700 0.95rem/1.2 "Space Grotesk", sans-serif;
  color: var(--accent-2);
  margin-bottom: 6px;
}

.gate-tooltip-title {
  font: 700 1.05rem/1.25 "Space Grotesk", sans-serif;
  margin-bottom: 6px;
}

.gate-tooltip-subtitle,
.gate-tooltip-copy {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.45;
}

.gate-tooltip-copy {
  margin-top: 8px;
}

.info-popover {
  position: fixed;
  z-index: 1001;
  max-width: min(380px, calc(100vw - 24px));
  padding: 14px 16px;
  border-radius: 16px;
  border: 1px solid rgba(30, 28, 26, 0.12);
  background: rgba(255, 253, 248, 0.99);
  box-shadow: 0 18px 40px rgba(67, 43, 20, 0.18);
}

.info-popover-title {
  font: 700 1rem/1.2 "Space Grotesk", sans-serif;
  margin-bottom: 6px;
}

.info-popover-copy {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.5;
}

.help-value {
  cursor: pointer;
  text-decoration: underline dotted rgba(215, 25, 32, 0.42);
  text-underline-offset: 0.18em;
  transition: color 160ms ease, text-decoration-color 160ms ease;
}

.help-value:hover,
.help-value:focus-visible {
  color: var(--accent-2);
  text-decoration-color: rgba(215, 25, 32, 0.9);
  outline: none;
}

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

.activation-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 11px 12px;
  border-radius: 14px;
  color: white;
}

.activation-item.design {
  background: #d71920;
}

.activation-item.personality {
  background: #4a4a4a;
}

.activation-main {
  display: grid;
  gap: 2px;
}

.activation-value {
  font: 700 1rem/1.15 "Space Grotesk", sans-serif;
}

.activation-meta {
  font-size: 0.78rem;
  line-height: 1.3;
  opacity: 0.88;
}

.activation-planet {
  font: 700 1.2rem/1 "Space Grotesk", sans-serif;
}

.center-shape {
  stroke: #1f1b18;
  stroke-width: 4;
  fill: var(--undefined);
}

.center-shape.defined {
  fill: var(--defined);
}

.channel {
  stroke: var(--channel-off);
  stroke-width: 7;
  stroke-linecap: round;
}

.channel.active {
  stroke: var(--channel-on);
}

.bodygraph-border {
  fill: none;
  stroke: #1f1b18;
  stroke-width: 1;
  stroke-miterlimit: 10;
}

.bodygraph-segment {
  transition: fill 180ms ease;
}

.gate-marker {
  fill: #f3cd49;
  stroke: #1f1b18;
  stroke-width: 1.25;
}

.center-label {
  font: 700 13px/1 "Space Grotesk", sans-serif;
  text-anchor: middle;
  fill: #1f1b18;
}

.gate-label {
  font: 600 11px/1 "Space Grotesk", sans-serif;
  text-anchor: middle;
  fill: rgba(30, 28, 26, 0.72);
}

.info-strip {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  margin-top: 24px;
}

.info-card {
  min-height: 100%;
}

.info-card h2 {
  margin: 0 0 8px;
  font-size: 1.35rem;
}

.info-card p:last-child {
  margin: 0;
  color: var(--muted);
  line-height: 1.6;
}

@media (max-width: 1080px) {
  .grid,
  .tables,
  .summary-band,
  .info-strip {
    grid-template-columns: 1fr;
  }

  .visual-layout {
    grid-template-columns: 1fr;
  }

  .chips-section {
    grid-template-columns: 1fr;
  }

  .site-header {
    flex-direction: column;
    align-items: flex-start;
  }

  #gate-chips {
    grid-template-columns: 1fr 1fr;
  }

  .mechanics-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 720px) {
  .shell {
    width: min(100% - 20px, 1320px);
    padding-top: 20px;
  }

  .card,
  .hero-copy {
    padding: 18px;
  }

  .brand {
    align-items: flex-start;
  }

  .brand-mark {
    width: 50px;
    height: 50px;
  }

  .top-nav {
    width: 100%;
    gap: 6px;
  }

  .language-switcher {
    margin-left: 0;
    padding-left: 0;
    border-left: 0;
    width: 100%;
  }

  .top-nav a {
    padding: 9px 12px;
  }

  .actions,
  .row.two {
    grid-template-columns: 1fr;
  }

  .chips-section > div {
    padding: 16px;
  }

  .gates-section {
    padding: 16px;
  }

  #gate-chips {
    grid-template-columns: 1fr;
  }

  .gate-item {
    min-height: auto;
  }

  .mechanics-grid {
    grid-template-columns: 1fr;
  }
}
