*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
html { color-scheme: dark; }
body {
  font-family: var(--font-ui);
  background:
    radial-gradient(1200px 700px at 10% -10%, rgba(201, 162, 39, 0.08), transparent 55%),
    radial-gradient(900px 500px at 110% 10%, rgba(143, 45, 31, 0.08), transparent 50%),
    var(--ink-0);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.65;
  font-size: 16px;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
img, svg { max-width: 100%; }
code { font-family: var(--font-mono); font-size: 0.9em; }

.site-bg {
  position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background-image:
    linear-gradient(rgba(201,162,39,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(201,162,39,0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 40%, transparent 85%);
}

.app { position: relative; z-index: 1; max-width: 1120px; margin: 0 auto; padding: 20px 16px 80px; }

.topbar {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; margin-bottom: 28px; flex-wrap: wrap;
}
.brand { display: flex; align-items: center; gap: 12px; min-width: 0; }
.brand-mark {
  width: 40px; height: 40px; border-radius: 50%;
  border: 1px solid var(--gold-1);
  display: grid; place-items: center;
  color: var(--gold-2);
  background: radial-gradient(circle at 40% 30%, var(--ink-3), var(--ink-0));
}
.brand h1 {
  font-family: var(--font-display);
  font-weight: 600; font-size: 1.45rem;
  margin: 0; letter-spacing: 0.12em;
  color: var(--gold-2);
}
.brand p { margin: 0; color: var(--text-muted); font-size: 0.82rem; letter-spacing: 0.08em; }

.top-actions { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.lang-toggle, .icon-btn, .ghost-btn, .text-btn {
  background: var(--ink-2);
  border: 1px solid var(--ink-line);
  color: var(--text);
  border-radius: 999px;
  padding: 6px 12px;
  display: inline-flex; align-items: center; gap: 6px;
}
.lang-toggle button {
  background: transparent; border: 0; padding: 2px 8px;
  border-radius: 999px; color: var(--text-muted);
}
.lang-toggle button.is-on { background: var(--gold-1); color: var(--ink-0); }
.icon-btn svg, .ghost-btn svg, .pay-btn svg, .field-icon svg { display: block; }

.privacy-banner {
  display: flex; gap: 10px; align-items: flex-start;
  padding: 12px 16px; margin-bottom: 22px;
  border: 1px solid rgba(201,162,39,0.25);
  background: rgba(20,22,17,0.8);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 0.92rem;
}
.privacy-banner svg { color: var(--gold-2); flex: none; margin-top: 2px; }

.card {
  background: linear-gradient(180deg, var(--ink-2), var(--ink-1));
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: 20px 20px 22px;
  margin-bottom: 20px;
}
.card h2, .card h3 {
  font-family: var(--font-display);
  letter-spacing: 0.08em;
  margin: 0 0 14px;
  color: var(--gold-2);
  font-weight: 600;
}
.card h2 { font-size: 1.2rem; }
.card h3 { font-size: 1.05rem; }

.form-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px 18px;
}
.field { position: relative; }
.field > label {
  display: block; margin-bottom: 6px;
  color: var(--text-muted); font-size: 0.82rem; letter-spacing: 0.08em;
}
.field-btn, .cs-input {
  width: 100%;
  background: var(--ink-0);
  border: 1px solid var(--ink-line);
  border-radius: var(--radius-md);
  padding: 12px 12px 12px 42px;
  text-align: left;
  min-height: 48px;
}
.field-btn:hover, .cs-input:focus { border-color: var(--gold-1); outline: none; }
.field-icon {
  position: absolute; left: 12px; top: 38px;
  color: var(--gold-1); pointer-events: none;
}
.cs-wrap { position: relative; }
.cs-wrap .field-icon { top: 12px; }
.cs-wrap .cs-input { padding-left: 42px; }
.cs-tz, .hint { margin-top: 6px; font-size: 0.8rem; color: var(--text-muted); }
.form-actions {
  display: flex; flex-wrap: wrap; gap: 10px;
  margin-top: 20px; align-items: center;
}
.primary-btn, .pay-btn {
  border: 0; border-radius: 999px;
  padding: 12px 22px;
  font-weight: 600;
  letter-spacing: 0.08em;
  background: linear-gradient(135deg, var(--gold-2), var(--gold-1) 45%, var(--amber));
  color: var(--ink-0);
  display: inline-flex; align-items: center; gap: 8px;
  box-shadow: 0 0 0 1px rgba(243, 226, 160, 0.2), 0 8px 24px rgba(201,162,39,0.2);
}
.primary-btn:hover, .pay-btn:hover { filter: brightness(1.06); }
.demo-btn {
  background: transparent;
  border: 1px dashed var(--gold-0);
  color: var(--gold-2);
  border-radius: 999px;
  padding: 10px 16px;
}

/* calendar / time wheel */
.cal-pop, .tw-pop, .cs-pop {
  position: absolute; z-index: 20; left: 0; right: 0; top: calc(100% + 6px);
  background: var(--ink-2);
  border: 1px solid var(--gold-0);
  border-radius: var(--radius-md);
  padding: 12px;
  box-shadow: var(--shadow-card);
}
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.cal-nav button {
  width: 32px; height: 32px; border-radius: 50%;
  border: 1px solid var(--ink-line); background: var(--ink-0); color: var(--gold-2);
}
.cal-week, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; text-align: center; }
.cal-week { color: var(--text-muted); font-size: 0.75rem; margin-bottom: 4px; }
.cal-day {
  background: transparent; border: 0; color: var(--text);
  aspect-ratio: 1; border-radius: 8px; padding: 0;
}
.cal-day.is-out { color: var(--ink-line); }
.cal-day.is-sel, .cal-day:hover { background: var(--gold-1); color: var(--ink-0); }
.tw-unknown { display: flex; gap: 8px; align-items: center; margin-bottom: 8px; }
.tw-wheels { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.tw-wheels.is-disabled { opacity: 0.4; pointer-events: none; }
.tw-caption { grid-column: 1 / -1; display: grid; grid-template-columns: 1fr 1fr; text-align: center; color: var(--text-muted); font-size: 0.8rem; }
.tw-col {
  max-height: 180px; overflow: auto;
  border: 1px solid var(--ink-line); border-radius: 8px;
  scroll-snap-type: y mandatory;
}
.tw-item {
  display: block; width: 100%; background: transparent; border: 0;
  padding: 8px 0; scroll-snap-align: center; color: var(--text);
}
.tw-item.is-sel { background: var(--gold-1); color: var(--ink-0); }
.cs-pop { max-height: 260px; overflow: auto; }
.cs-item {
  display: flex; flex-direction: column; align-items: flex-start;
  width: 100%; background: transparent; border: 0; padding: 8px 6px;
  border-bottom: 1px solid var(--ink-3);
}
.cs-item span { color: var(--text-muted); font-size: 0.8rem; }
.cs-item.is-sel, .cs-item:hover { background: var(--ink-3); }
.cs-empty { padding: 10px; color: var(--text-muted); }

/* bodygraph */
.hd-graph {
  display: grid;
  grid-template-columns: minmax(110px, 160px) minmax(0, 1fr) minmax(110px, 160px);
  gap: 8px;
  align-items: stretch;
}
.hd-planets {
  font-size: 0.8rem;
  padding: 8px 4px;
}
.hd-planets-title {
  font-family: var(--font-display);
  letter-spacing: 0.1em;
  margin-bottom: 8px;
  font-size: 0.85rem;
}
.hd-planets.is-design .hd-planets-title, .hd-planets.is-design .hd-planet-gl { color: var(--design-bright); }
.hd-planets.is-personality .hd-planets-title, .hd-planets.is-personality .hd-planet-gl { color: var(--bone); }
.hd-planet {
  display: flex; justify-content: space-between; gap: 6px;
  padding: 3px 4px; border-radius: 6px; cursor: pointer;
}
.hd-planet:hover { background: var(--ink-3); }
.hd-svg-wrap { position: relative; min-width: 0; }
.hd-svg { width: 100%; height: auto; display: block; }
.hd-silhouette { stroke: rgba(138, 109, 31, 0.45); stroke-width: 1.4; }
.hd-ch { stroke: rgba(90, 86, 72, 0.45); stroke-width: 3.2; stroke-linecap: round; }
.hd-ch.is-defined.is-personality { stroke: var(--channel-personality); stroke-width: 4.2; }
.hd-ch.is-defined.is-design { stroke: var(--channel-design); stroke-width: 4.2; }
.hd-ch.is-defined.is-both { stroke-width: 4.4; }
.hd-ch.is-hanging { stroke-dasharray: 5 6; stroke-width: 2.4; opacity: 0.85; }
.hd-ch.is-hanging.is-personality { stroke: var(--channel-personality); }
.hd-ch.is-hanging.is-design { stroke: var(--channel-design); }
.hd-ch.is-comp.is-electromagnetic { stroke-width: 5; }
.hd-ch.is-comp.is-companionship { stroke: var(--companionship); stroke-width: 4.6; }
.hd-ch.is-comp.is-dominance { stroke: var(--dominance); stroke-width: 4.4; }
.hd-ch.is-comp.is-compromise { stroke: var(--compromise); stroke-width: 4; stroke-dasharray: 6 5; }
.hd-ch.is-comp.is-idle { stroke: rgba(90,86,72,0.28); stroke-width: 2; }
.hd-ch.is-hot, .hd-gate.is-hot .hd-gate-ring, .hd-center.is-hot .hd-center-shape {
  filter: drop-shadow(0 0 5px var(--gold-2));
}
.hd-center-shape { cursor: pointer; stroke-width: 2.2; stroke-linejoin: round; }
.hd-center.is-defined .hd-center-shape { fill: var(--center-defined-fill); stroke: var(--center-defined-stroke); }
.hd-center.is-open .hd-center-shape { fill: var(--center-open-fill); stroke: var(--center-open-stroke); }
.hd-center-inner { fill: none; stroke: rgba(246,240,224,0.28); stroke-width: 1; pointer-events: none; transform-origin: center; }
.hd-gate { cursor: pointer; }
.hd-gate-disk { fill: var(--bone); stroke: none; }
.hd-gate-ring { fill: none; stroke: var(--ink-4); stroke-width: 1.4; }
.hd-gate.is-personality .hd-gate-ring { stroke: var(--personality-on-paper); stroke-width: 2.2; }
.hd-gate.is-personality .hd-gate-disk { fill: #2a271f; }
.hd-gate.is-personality .hd-gate-num { fill: var(--bone); }
.hd-gate.is-design .hd-gate-ring { stroke: var(--design); stroke-width: 2.2; }
.hd-gate.is-design .hd-gate-disk { fill: #f3e8df; }
.hd-gate.is-design .hd-gate-num { fill: var(--design-deep); }
.hd-gate.is-both .hd-gate-disk { fill: #2a271f; }
.hd-gate.is-both .hd-gate-ring { stroke: var(--design); stroke-width: 2.6; }
.hd-gate.is-both .hd-gate-num { fill: var(--gold-2); }
.hd-gate.is-hanging .hd-gate-ring { stroke-dasharray: 3 2; }
.hd-gate-num { font-size: 10px; font-weight: 700; fill: var(--text-on-paper); pointer-events: none; font-family: var(--font-ui); }
.hd-tip {
  position: absolute; left: 12px; right: 12px; bottom: 12px;
  background: rgba(11,12,10,0.88); color: var(--bone);
  border: 1px solid var(--gold-0); border-radius: 10px;
  padding: 8px 12px; font-size: 0.88rem;
}

@media (prefers-reduced-motion: no-preference) {
  .hd-center.is-defined .hd-center-shape {
    animation: hdLight 0.8s var(--ease) both;
  }
  .hd-ch.is-defined {
    stroke-dasharray: 10 14;
    animation: hdFlow 7s linear infinite;
  }
  .hd-ch.is-comp.is-electromagnetic {
    stroke-dasharray: 10 12;
    animation: hdFlow 5s linear infinite;
  }
}
@keyframes hdLight {
  from { filter: brightness(0.6); opacity: 0.4; }
  to { filter: brightness(1); opacity: 1; }
}
@keyframes hdFlow { to { stroke-dashoffset: -240; } }

.table-3 {
  width: 100%; border-collapse: collapse; font-size: 0.92rem;
}
.table-3 th, .table-3 td {
  border-bottom: 1px solid var(--ink-line);
  text-align: left; vertical-align: top; padding: 10px 8px;
}
.table-3 th { color: var(--gold-2); font-weight: 600; font-size: 0.8rem; letter-spacing: 0.08em; }
.kv { display: grid; gap: 10px; }
.badge {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid var(--gold-0); color: var(--gold-2);
  border-radius: 999px; padding: 2px 10px; font-size: 0.8rem;
  letter-spacing: 0.06em;
}
.badge.is-warn { border-color: var(--design); color: var(--design-bright); }
.meta-line { color: var(--text-muted); font-size: 0.85rem; margin: 0 0 12px; }
.teaser {
  margin-top: 12px; padding-top: 12px;
  border-top: 1px dashed var(--ink-line);
  display: flex; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  align-items: center; color: var(--text-muted); font-size: 0.9rem;
}
.center-grid, .channel-list { display: grid; gap: 10px; }
.center-grid { grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); }
.mini-card {
  border: 1px solid var(--ink-line); border-radius: var(--radius-md);
  padding: 12px; background: var(--ink-0);
}
.mini-card h4 { margin: 0 0 6px; font-size: 0.95rem; color: var(--bone); }
.legend { display: flex; flex-wrap: wrap; gap: 10px 16px; font-size: 0.82rem; color: var(--text-muted); margin: 8px 0 14px; }
.legend i { display: inline-block; width: 18px; height: 6px; border-radius: 3px; margin-right: 6px; vertical-align: middle; }
.legend .p { background: #1a1814; box-shadow: 0 0 0 1px #c9b98c; }
.legend .d { background: var(--design); }
.legend .a { background: var(--person-a); }
.legend .b { background: var(--person-b); }
.legend .em { background: linear-gradient(90deg, var(--person-a), var(--person-b)); }
.legend .co { background: var(--companionship); }
.legend .dom { background: var(--dominance); }
.legend .cm { background: var(--compromise); }

.conn-block { margin-bottom: 14px; }
.conn-head { display: flex; align-items: center; gap: 8px; color: var(--bone); margin-bottom: 4px; }
.conn-head svg { flex: none; }
.conn-head.is-em { color: var(--person-a); }
.conn-head.is-co { color: var(--companionship); }
.conn-head.is-dom { color: var(--dominance); }
.conn-head.is-cm { color: var(--compromise); }

.toggle {
  display: inline-flex; align-items: center; gap: 8px;
}
.toggle input { accent-color: var(--gold-1); }

.library-list { display: grid; gap: 8px; }
.lib-item {
  display: flex; justify-content: space-between; gap: 8px; align-items: center;
  padding: 10px 12px; border: 1px solid var(--ink-line); border-radius: 10px;
}
.lib-item button { background: transparent; border: 1px solid var(--ink-line); border-radius: 999px; padding: 4px 10px; }

.toast {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--ink-2); border: 1px solid var(--gold-1); color: var(--bone);
  padding: 10px 16px; border-radius: 999px; z-index: 50;
  box-shadow: var(--shadow-card);
}

.hidden { display: none !important; }
.view-results .only-form { display: none; }
.view-form .only-results { display: none; }

footer.site-foot {
  margin-top: 28px; color: var(--text-muted); font-size: 0.8rem;
  text-align: center; padding: 0 12px;
}

@media (max-width: 820px) {
  .form-grid { grid-template-columns: 1fr; }
  .hd-graph {
    grid-template-columns: 1fr 1fr;
  }
  .hd-svg-wrap { grid-column: 1 / -1; order: -1; }
  .table-3 thead { display: none; }
  .table-3 tr { display: block; padding: 10px 0; border-bottom: 1px solid var(--ink-line); }
  .table-3 td { display: block; border: 0; padding: 4px 0; }
  .table-3 td::before {
    content: attr(data-th) " · ";
    color: var(--gold-2);
    letter-spacing: 0.06em;
    font-size: 0.78rem;
  }
}

@media (max-width: 420px) {
  .app { padding: 14px 10px 64px; }
  .brand h1 { font-size: 1.2rem; letter-spacing: 0.08em; }
  .card { padding: 16px 12px; }
  .hd-planets { font-size: 0.72rem; }
  .hd-gate-num { font-size: 9px; }
}

@media print {
  body { background: white; color: #222; }
  .site-bg, .top-actions, .form-card, .teaser, .privacy-banner, .no-print { display: none !important; }
  .card { background: white; border-color: #ccc; box-shadow: none; color: #222; break-inside: avoid; }
  .card h2, .card h3 { color: #6b5410; }
  .app { max-width: none; }
}

.hd-graph.is-composite .hd-gate.is-a .hd-gate-disk { fill: #163a36; }
.hd-graph.is-composite .hd-gate.is-a .hd-gate-ring { stroke: var(--person-a); stroke-width: 2.4; }
.hd-graph.is-composite .hd-gate.is-a .hd-gate-num { fill: #b7efe6; }
.hd-graph.is-composite .hd-gate.is-b .hd-gate-disk { fill: #3a2a10; }
.hd-graph.is-composite .hd-gate.is-b .hd-gate-ring { stroke: var(--person-b); stroke-width: 2.4; }
.hd-graph.is-composite .hd-gate.is-b .hd-gate-num { fill: #f3d7a0; }
.hd-graph.is-composite .hd-gate.is-both .hd-gate-disk { fill: #1a2420; }
.hd-graph.is-composite .hd-gate.is-both .hd-gate-ring { stroke: var(--person-a); stroke-width: 2.8; }
.hd-graph.is-composite .hd-gate.is-both .hd-gate-num { fill: var(--gold-2); }

body.shot-composite .privacy-banner,
body.shot-composite .form-card,
body.shot-composite .site-foot,
body.shot-composite #library-mount,
body.shot-composite #results-mount > section.card:not(#composite-card) {
  display: none !important;
}
