:root {
  --bg: #080b14;
  --bg-elevated: rgba(16, 22, 38, 0.88);
  --bg-card-inner: rgba(24, 32, 54, 0.72);
  --border: rgba(226, 185, 111, 0.22);
  --border-strong: rgba(226, 185, 111, 0.5);
  --text: #eef1f7;
  --text-muted: #9aa5be;
  --gold: #e2b96f;
  --gold-soft: rgba(226, 185, 111, 0.14);
  --cyan: #38bdf8;
  --emerald: #34d399;
  --crimson: #f87171;
  --amber: #fbbf24;
  --violet: #a855f7;
  --radius: 14px;
  --radius-sm: 9px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background: radial-gradient(circle at 18% 10%, #171e38 0%, #080b14 55%, #05070e 100%);
  color: var(--text);
  font-family: "Yu Gothic UI", "Hiragino Kaku Gothic ProN", "Meiryo", system-ui, -apple-system, sans-serif;
  line-height: 1.6;
  overflow-x: hidden;
}

.arcane-bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 0;
  opacity: 0.06;
  color: var(--gold);
}

.magic-circle-bg {
  width: min(85vw, 760px);
  height: min(85vw, 760px);
  animation: slowSpin 120s linear infinite;
}

@keyframes slowSpin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.container {
  position: relative;
  z-index: 1;
  width: min(1240px, 94vw);
  margin: 0 auto;
}

.site-header {
  border-bottom: 1px solid var(--border);
  background: rgba(8, 11, 20, 0.78);
  backdrop-filter: blur(10px);
  padding: 20px 0;
}

.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 24px;
}

.eyebrow {
  margin: 0 0 2px;
  font-size: 11px;
  letter-spacing: 0.22em;
  color: var(--gold);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 2.5vw, 2.1rem);
  letter-spacing: 0.04em;
  background: linear-gradient(120deg, #fff5dc, var(--gold));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.subtitle {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 580px;
}

.main-content {
  padding: 24px 0 48px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: 0 12px 32px rgba(0, 0, 0, 0.36);
  backdrop-filter: blur(8px);
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.section-header h2,
.section-header h3 {
  margin: 0;
  font-size: 1.08rem;
  color: #f8e7c2;
  letter-spacing: 0.03em;
}

.section-title {
  margin: 0 0 12px;
  font-size: 1.12rem;
  color: #f8e7c2;
  border-left: 3px solid var(--gold);
  padding-left: 10px;
}

.section-title-inline {
  margin: 0;
  font-size: 1.1rem;
  color: #f8e7c2;
}

.hint-text,
.meta-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* LLM Engine Selector Panel */
.engine-panel {
  margin-bottom: 14px;
  padding-bottom: 14px;
  border-bottom: 1px dashed var(--border);
}

.engine-mode-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.engine-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.engine-tab {
  background: var(--bg-card-inner);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 6px 13px;
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s ease;
}

.engine-tab:hover:not(:disabled) {
  color: var(--text);
  border-color: var(--gold);
}

.engine-tab:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}

.engine-tab.is-active {
  background: rgba(56, 189, 248, 0.16);
  border-color: var(--cyan);
  color: #e0f2fe;
}

.llm-settings-box {
  margin-top: 12px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(8, 12, 24, 0.72);
  border: 1px solid rgba(56, 189, 248, 0.25);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

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

.field-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.field-group label {
  font-size: 0.78rem;
  color: var(--gold);
  font-weight: 600;
}

.label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.env-badge {
  font-size: 0.7rem;
  padding: 1px 7px;
  border-radius: 999px;
  background: rgba(52, 211, 153, 0.16);
  border: 1px solid rgba(52, 211, 153, 0.45);
  color: var(--emerald);
  font-weight: 700;
}

.text-input {
  width: 100%;
  background: rgba(16, 22, 38, 0.92);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--text);
  padding: 8px 10px;
  font-size: 0.86rem;
  font-family: inherit;
}

.text-input:focus {
  outline: none;
  border-color: var(--cyan);
}

.key-input-wrap {
  display: flex;
  gap: 6px;
}

.btn-icon {
  background: var(--bg-card-inner);
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: 7px;
  padding: 0 10px;
  font-size: 0.78rem;
  cursor: pointer;
  white-space: nowrap;
}

.btn-icon:hover {
  color: var(--text);
  border-color: var(--gold);
}

.model-quick-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.model-pill {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-muted);
  border-radius: 999px;
  padding: 2px 8px;
  font-size: 0.72rem;
  cursor: pointer;
}

.model-pill:hover {
  color: #fff;
  border-color: var(--cyan);
}

.llm-options-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 20px;
}

.checkbox-label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.8rem;
  color: var(--text-muted);
  cursor: pointer;
}

.source-badge {
  font-size: 0.78rem;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(226, 185, 111, 0.12);
  border: 1px solid var(--border);
  color: var(--gold);
  font-weight: 600;
}

.source-badge.is-llm {
  background: rgba(56, 189, 248, 0.15);
  border-color: rgba(56, 189, 248, 0.45);
  color: #7dd3fc;
}

.status-banner {
  margin-top: 10px;
  padding: 9px 12px;
  border-radius: 8px;
  font-size: 0.84rem;
  border: 1px solid;
}

.status-banner.is-info {
  background: rgba(56, 189, 248, 0.12);
  border-color: rgba(56, 189, 248, 0.4);
  color: #bae6fd;
}

.status-banner.is-error {
  background: rgba(248, 113, 113, 0.14);
  border-color: rgba(248, 113, 113, 0.45);
  color: #fecaca;
}

.status-banner.is-warn {
  background: rgba(251, 191, 36, 0.12);
  border-color: rgba(251, 191, 36, 0.45);
  color: #fde68a;
}

/* Input Area */
.preset-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.preset-label {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-weight: 600;
}

.preset-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
}

.preset-btn {
  background: var(--bg-card-inner);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 5px 12px;
  font-size: 0.79rem;
  cursor: pointer;
  transition: all 0.16s ease;
}

.preset-btn:hover {
  border-color: var(--gold);
  background: var(--gold-soft);
  color: #fff5dc;
}

.preset-btn.is-active {
  border-color: var(--gold);
  background: rgba(226, 185, 111, 0.25);
  color: #fff6dc;
}

.chant-textarea {
  width: 100%;
  min-height: 110px;
  resize: vertical;
  background: rgba(7, 10, 19, 0.85);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: 14px;
  font-size: 1rem;
  line-height: 1.65;
  font-family: inherit;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.chant-textarea:focus {
  outline: none;
  border-color: var(--gold);
  box-shadow: 0 0 0 3px rgba(226, 185, 111, 0.16);
}

.input-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  margin-top: 12px;
}

.btn-primary {
  background: linear-gradient(135deg, #d4a44e, #b77e28);
  color: #110d04;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 20px;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.15s ease;
}

.btn-primary:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

.btn-secondary {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 16px;
  font-size: 0.88rem;
  cursor: pointer;
}

.btn-secondary:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.live-toggle {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
  font-size: 0.84rem;
  color: var(--text-muted);
  cursor: pointer;
}

/* Annotated Chant Highlight */
.annotated-wrap {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.annotated-header {
  font-size: 0.8rem;
  color: var(--gold);
  font-weight: 600;
  margin-bottom: 8px;
}

.annotated-chant {
  background: rgba(7, 10, 19, 0.65);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  font-size: 0.95rem;
  line-height: 1.9;
}

.token-hl {
  border-radius: 5px;
  padding: 2px 5px;
  margin: 0 1px;
  border-bottom: 2px solid;
  font-weight: 600;
}

.annotated-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  margin-top: 8px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.legend-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
}

.hidden {
  display: none !important;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 36px 20px;
}

.results-root {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Profile 6 Cards */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

.profile-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.profile-label {
  font-size: 0.76rem;
  color: var(--gold);
  letter-spacing: 0.06em;
  font-weight: 700;
}

.profile-value {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
}

.profile-reason {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* Two-col Combo & Accident */
.two-col-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.pill {
  font-size: 0.76rem;
  font-weight: 700;
  padding: 3px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border);
}

.pill-emerald {
  color: var(--emerald);
  border-color: rgba(52, 211, 153, 0.4);
  background: rgba(52, 211, 153, 0.12);
}

.pill-crimson {
  color: var(--crimson);
  border-color: rgba(248, 113, 113, 0.45);
  background: rgba(248, 113, 113, 0.12);
}

.diagnostic-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.diag-item {
  border-radius: var(--radius-sm);
  padding: 11px 13px;
  background: var(--bg-card-inner);
  border-left: 3px solid var(--border);
}

.diag-item.is-combo {
  border-left-color: var(--emerald);
}

.diag-item.is-critical {
  border-left-color: #ef4444;
  background: rgba(127, 29, 29, 0.25);
}

.diag-item.is-high {
  border-left-color: #f97316;
  background: rgba(124, 45, 18, 0.22);
}

.diag-item.is-medium {
  border-left-color: var(--amber);
  background: rgba(120, 53, 15, 0.2);
}

.diag-title {
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 4px;
}

.diag-sub {
  font-size: 0.81rem;
  color: var(--text-muted);
  margin: 0;
}

.diag-mitigation {
  margin: 6px 0 0;
  font-size: 0.8rem;
  color: #fde68a;
}

.diag-empty {
  color: var(--text-muted);
  font-size: 0.85rem;
  padding: 10px 4px;
}

/* Charts & Attributes */
.charts-grid {
  display: grid;
  grid-template-columns: 1.45fr 1fr;
  gap: 16px;
  align-items: start;
}

.side-stack {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.chart-split {
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(240px, 1fr);
  gap: 16px;
  align-items: center;
}

.radar-box {
  width: 100%;
  max-width: 390px;
  margin: 0 auto;
}

.radar-box-sm {
  max-width: 300px;
}

.radar-svg {
  width: 100%;
  height: auto;
  overflow: visible;
}

.radar-outer-circle {
  fill: rgba(12, 16, 30, 0.45);
  stroke: rgba(226, 185, 111, 0.16);
  stroke-width: 1;
}

.radar-grid-ring {
  fill: none;
  stroke: rgba(154, 165, 190, 0.18);
  stroke-width: 1;
}

.radar-spoke {
  stroke: rgba(154, 165, 190, 0.2);
  stroke-width: 1;
}

.radar-data-poly {
  transition: all 0.25s ease;
}

.radar-axis-group {
  cursor: pointer;
}

.radar-label {
  fill: var(--text);
  font-size: 11px;
  font-weight: 600;
}

.radar-value-badge {
  fill: var(--gold);
  font-size: 10px;
  font-weight: 700;
}

.radar-axis-group.is-active .radar-label {
  fill: #ffffff;
  font-size: 12px;
}

.radar-axis-group.is-active .radar-vertex-dot {
  stroke: #ffffff;
  stroke-width: 2;
}

.axis-detail-pane {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.selected-axis-box {
  background: rgba(226, 185, 111, 0.1);
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-sm);
  padding: 12px;
}

.selected-axis-head {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.selected-axis-head strong {
  color: #fff4d8;
  font-size: 0.96rem;
}

.selected-axis-score {
  color: var(--gold);
  font-weight: 800;
  font-size: 1.08rem;
}

.selected-axis-box p {
  margin: 0;
  font-size: 0.82rem;
  color: var(--text-muted);
}

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

.axis-chip {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-card-inner);
  border: 1px solid transparent;
  border-radius: 7px;
  padding: 6px 9px;
  font-size: 0.8rem;
  color: var(--text);
  cursor: pointer;
  text-align: left;
}

.axis-chip:hover,
.axis-chip.is-active {
  border-color: var(--gold);
  background: rgba(226, 185, 111, 0.14);
}

.axis-chip-val {
  font-weight: 700;
  color: var(--gold);
}

/* Attributes */
.attributes-list {
  display: flex;
  flex-direction: column;
  gap: 9px;
}

.attr-row {
  background: var(--bg-card-inner);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  border-left: 4px solid;
}

.attr-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 700;
  font-size: 0.92rem;
  margin-bottom: 3px;
}

.attr-reason {
  margin: 0;
  font-size: 0.79rem;
  color: var(--text-muted);
}

.ailment-reasons {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.ailment-row {
  display: flex;
  gap: 8px;
  font-size: 0.79rem;
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--bg-card-inner);
}

.ailment-name {
  min-width: 58px;
  font-weight: 700;
  color: var(--cyan);
}

.ailment-desc {
  color: var(--text-muted);
}

/* Special Effects */
.effects-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 12px;
}

.effect-card {
  background: var(--bg-card-inner);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 12px;
  opacity: 0.62;
  transition: all 0.16s ease;
}

.effect-card.is-active {
  opacity: 1;
  border-color: rgba(56, 189, 248, 0.55);
  background: linear-gradient(155deg, rgba(14, 48, 72, 0.62), rgba(20, 29, 52, 0.85));
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.12);
}

.effect-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}

.effect-name {
  font-weight: 700;
  font-size: 0.93rem;
}

.effect-badge {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 999px;
  font-weight: 700;
}

.effect-card.is-active .effect-badge {
  background: rgba(56, 189, 248, 0.22);
  color: #7dd3fc;
}

.effect-card:not(.is-active) .effect-badge {
  background: rgba(255, 255, 255, 0.06);
  color: var(--text-muted);
}

.effect-sub {
  font-size: 0.76rem;
  color: var(--gold);
  margin-bottom: 5px;
}

.effect-reason {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* 10 Pillars */
.pillars-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.pillar-card {
  background: var(--bg-card-inner);
  border: 1px solid rgba(226, 185, 111, 0.16);
  border-radius: var(--radius-sm);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.pillar-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.pillar-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: #f8e7c2;
}

.pillar-score {
  font-weight: 800;
  font-size: 0.92rem;
  color: var(--gold);
}

.pillar-bar-track {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}

.pillar-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #c69138, #f3cf88);
}

.pillar-summary {
  font-size: 0.83rem;
  font-weight: 600;
  color: #dce4f5;
}

.pillar-reason {
  margin: 0;
  font-size: 0.79rem;
  color: var(--text-muted);
}

/* 9 Factors */
.factors-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.factor-card {
  background: var(--bg-card-inner);
  border-radius: var(--radius-sm);
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.factor-name {
  font-size: 0.78rem;
  color: var(--gold);
  font-weight: 700;
}

.factor-value {
  font-size: 0.94rem;
  font-weight: 700;
  margin: 3px 0 4px;
}

.factor-detail {
  margin: 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 18px 0 28px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.8rem;
}

@media (max-width: 1040px) {
  .charts-grid,
  .chart-split {
    grid-template-columns: 1fr;
  }
  .effects-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .profile-grid,
  .factors-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 720px) {
  .two-col-grid,
  .pillars-grid,
  .profile-grid,
  .factors-grid,
  .effects-grid,
  .llm-grid {
    grid-template-columns: 1fr;
  }
  .live-toggle {
    margin-left: 0;
  }
}
