:root {
  --bg: #06131a;
  --bg-2: #0d1d24;
  --panel: rgba(10, 28, 36, 0.9);
  --panel-2: rgba(20, 53, 66, 0.86);
  --ink: #e7f7f6;
  --muted: #9cc1bf;
  --accent: #46f2c8;
  --accent-2: #75c8ff;
  --accent-3: #ffb347;
  --line: rgba(231, 247, 246, 0.12);
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.34);
  --positive-color: #46f2c8;
  --negative-color: #75c8ff;
  --cp-color: #4ade80;
  --enemy-color: #f87171;
  --radius-lg: 26px;
  --radius-md: 20px;
  --radius-sm: 16px;
  --radius-xs: 12px;
  --spacing-xs: 8px;
  --spacing-sm: 12px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  color: var(--ink);
  font-family: "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(70, 242, 200, 0.14), transparent 26%),
    radial-gradient(circle at top right, rgba(117, 200, 255, 0.12), transparent 22%),
    linear-gradient(180deg, var(--bg) 0%, var(--bg-2) 100%);
  background-attachment: fixed;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.18;
  background-image:
    linear-gradient(rgba(70, 242, 200, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(70, 242, 200, 0.08) 1px, transparent 1px);
  background-size: 24px 24px;
}

/* ============================================================
   App Shell
   ============================================================ */
.app-shell {
  width: min(1280px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 40px;
}

/* ============================================================
   Panels (shared)
   ============================================================ */
.topbar,
.hero-panel,
.console-panel,
.metric-panel,
.log-panel,
.result-panel {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: var(--panel);
  box-shadow: var(--shadow);
}

/* ============================================================
   Top Bar
   ============================================================ */
.topbar {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  align-items: flex-start;
  padding: 28px 30px;
  margin-bottom: 20px;
}

.eyebrow,
.section-kicker {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  font-family: "IBM Plex Mono", monospace;
}

h1,
h2,
h3 {
  margin: 0;
  line-height: 1.15;
}

h1 {
  font-size: clamp(2.2rem, 5vw, 4.2rem);
  letter-spacing: -0.02em;
}

h2 {
  font-size: clamp(1.6rem, 2.8vw, 2.4rem);
}

/* ============================================================
   Status Cluster & Pills
   ============================================================ */
.status-cluster,
.axis-pills {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.status-cluster span,
.axis-pill,
.result-code {
  border-radius: 999px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  background: rgba(70, 242, 200, 0.08);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.88rem;
  white-space: nowrap;
}

/* ============================================================
   Tab Bar
   ============================================================ */
.tab-bar {
  display: flex;
  gap: 10px;
  margin: 0 0 18px;
}

.tab-button {
  border: 1px solid var(--line);
  background: rgba(70, 242, 200, 0.06);
  color: var(--muted);
  border-radius: 999px;
  padding: 12px 18px;
  cursor: pointer;
  font: inherit;
  font-family: "IBM Plex Mono", monospace;
  transition: all 200ms ease;
}

.tab-button.active {
  color: #052018;
  background: linear-gradient(135deg, var(--accent), #95ffe4);
}

/* ============================================================
   Dashboard Grid
   ============================================================ */
.dashboard {
  display: grid;
  grid-template-columns: 1fr;
  gap: 20px;
}

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

.hero-panel {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: 1fr 420px;
  gap: 18px;
  padding: 24px;
}

.hero-copy p,
.log-panel p,
.result-summary,
.metric-card p,
.result-card p {
  line-height: 1.8;
  color: var(--muted);
}

/* ============================================================
   Terminal Card
   ============================================================ */
.terminal-card {
  border-radius: 22px;
  background: #021017;
  border: 1px solid rgba(70, 242, 200, 0.16);
  overflow: hidden;
}

.terminal-bar {
  display: flex;
  gap: 8px;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(70, 242, 200, 0.12);
}

.terminal-bar span {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--accent);
}

.terminal-bar span:nth-child(2) {
  background: var(--accent-2);
}

.terminal-bar span:nth-child(3) {
  background: var(--accent-3);
}

.terminal-body {
  margin: 0;
  min-height: 160px;
  padding: 18px 20px;
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  line-height: 1.7;
  white-space: pre-wrap;
}

/* ============================================================
   Console / Metric / Log / Result Panels
   ============================================================ */
.console-panel,
.metric-panel,
.log-panel,
.result-panel {
  padding: var(--spacing-lg);
}

.console-head,
.progress-meta,
.nav-row,
.result-header,
.result-actions {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: center;
}

.result-header {
  align-items: flex-start;
}

/* ============================================================
   Progress
   ============================================================ */
.progress-box {
  margin: 22px 0;
}

.progress-meta {
  margin-bottom: 10px;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.92rem;
}

.progress-track,
.metric-bar {
  height: 10px;
  border-radius: 999px;
  background: rgba(70, 242, 200, 0.1);
  overflow: hidden;
}

.progress-fill,
.metric-fill {
  width: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), var(--accent-3));
  transition: width 220ms ease;
}

/* ============================================================
   Question Console
   ============================================================ */
.question-console {
  padding: 22px;
  border-radius: var(--radius-md);
  background: var(--panel-2);
  border: 1px solid var(--line);
}

.question-text {
  margin: 0 0 22px;
  font-size: clamp(1.1rem, 2vw, 1.45rem);
  line-height: 1.7;
  font-weight: 500;
}

.answers {
  display: grid;
  gap: 12px;
}

.answer-button {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: rgba(4, 18, 24, 0.76);
  color: var(--ink);
  padding: 16px 18px;
  text-align: left;
  font: inherit;
  font-size: 0.95rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  min-height: 56px;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.answer-button:hover {
  transform: translateY(-2px);
  border-color: rgba(70, 242, 200, 0.36);
  background: rgba(9, 33, 40, 0.94);
}

.answer-button.selected {
  border-color: rgba(117, 200, 255, 0.48);
  background: rgba(117, 200, 255, 0.12);
}

.answer-label {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 30px;
  height: 30px;
  min-width: 30px;
  margin-right: 12px;
  border-radius: 8px;
  background: rgba(70, 242, 200, 0.12);
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
  font-weight: 600;
  font-size: 0.85rem;
}

/* ============================================================
   Ops Column / Metrics
   ============================================================ */
.ops-column {
  display: grid;
  gap: 20px;
}

.metric-list,
.axis-summary {
  display: grid;
  gap: 12px;
}

.metric-card,
.result-card {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(8, 23, 28, 0.78);
  padding: 18px;
}

.metric-card strong {
  display: block;
  margin-bottom: 8px;
  font-family: "IBM Plex Mono", monospace;
}

/* ============================================================
   Buttons
   ============================================================ */
button {
  font: inherit;
}

.primary-button,
.secondary-button,
.ghost-button {
  border: 0;
  border-radius: 999px;
  padding: 14px 22px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.95rem;
  transition: transform 160ms ease, opacity 160ms ease;
}

.primary-button {
  color: #052018;
  background: linear-gradient(135deg, var(--accent), #95ffe4);
}

.secondary-button {
  color: var(--ink);
  background: rgba(117, 200, 255, 0.12);
}

.ghost-button {
  color: var(--muted);
  background: transparent;
}

.primary-button:hover,
.secondary-button:hover,
.ghost-button:hover {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.hidden {
  display: none;
}

/* ============================================================
   Result Code
   ============================================================ */
.result-code {
  display: inline-flex;
  margin: 10px 0 14px;
  letter-spacing: 0.18em;
  font-size: 1.1rem;
}

/* ============================================================
   Result Grid
   ============================================================ */
.result-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 20px;
}

.result-card-full {
  grid-column: 1 / -1;
}

/* ============================================================
   Score Overview Section
   ============================================================ */
.score-overview {
  margin-top: 28px;
}

.score-overview h3,
.subdim-detail h3 {
  font-size: 1.2rem;
  margin-bottom: 20px;
  color: var(--ink);
}

#radar-chart {
  display: block;
  margin: 0 auto 24px;
  max-width: 360px;
}

/* Domain Score Cards */
.domain-score-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 14px;
}

.domain-score-card {
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(8, 23, 28, 0.78);
  padding: 16px;
}

.dsc-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.dsc-name {
  font-weight: 600;
  font-size: 1rem;
}

.dsc-score {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
  color: var(--accent);
}

.dsc-poles {
  display: flex;
  justify-content: space-between;
  margin-bottom: 10px;
  font-size: 0.82rem;
  color: var(--muted);
}

.dsc-pole {
  font-family: "IBM Plex Mono", monospace;
  opacity: 0.6;
  transition: opacity 200ms;
}

.dsc-pole-active {
  opacity: 1;
  color: var(--accent);
  font-weight: 600;
}

/* Bidirectional Bar */
.bidirectional-bar {
  position: relative;
  height: 8px;
  background: rgba(231, 247, 246, 0.08);
  border-radius: 4px;
  overflow: hidden;
}

.bidirectional-bar .center-mark {
  position: absolute;
  left: 50%;
  top: 0;
  width: 2px;
  height: 100%;
  background: rgba(231, 247, 246, 0.25);
  transform: translateX(-50%);
  z-index: 2;
}

.bidirectional-bar .fill-positive {
  position: absolute;
  left: 50%;
  top: 0;
  height: 100%;
  background: linear-gradient(90deg, var(--positive-color), rgba(70, 242, 200, 0.5));
  border-radius: 0 4px 4px 0;
  transition: width 400ms ease;
}

.bidirectional-bar .fill-negative {
  position: absolute;
  right: 50%;
  top: 0;
  height: 100%;
  background: linear-gradient(270deg, var(--negative-color), rgba(117, 200, 255, 0.5));
  border-radius: 4px 0 0 4px;
  transition: width 400ms ease;
}

.dsc-strength {
  margin-top: 10px;
  font-size: 0.85rem;
  font-weight: 500;
}

.dsc-strength-strong {
  color: var(--accent);
}

.dsc-strength-moderate {
  color: var(--accent-2);
}

.dsc-strength-mild {
  color: var(--muted);
}

/* ============================================================
   Sub-dimension Detail Section
   ============================================================ */
.subdim-detail {
  margin-top: 28px;
}

.subdim-group {
  margin-bottom: 24px;
  padding: 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: rgba(8, 23, 28, 0.5);
}

.subdim-group h4 {
  margin: 0 0 14px;
  font-size: 1rem;
  color: var(--ink);
}

.subdim-group-letter {
  color: var(--accent);
  font-family: "IBM Plex Mono", monospace;
}

.subdim-row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 4px;
}

.subdim-label {
  width: 110px;
  min-width: 110px;
  font-size: 0.82rem;
  font-family: "IBM Plex Mono", monospace;
  color: var(--muted);
}

.subdim-bar-wrap {
  flex: 1;
}

.subdim-bibar {
  height: 6px;
}

.subdim-score {
  width: 65px;
  min-width: 65px;
  text-align: right;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  color: var(--accent);
}

.subdim-desc {
  font-size: 0.8rem;
  color: var(--muted);
  margin: 0 0 14px 0;
  padding-left: 122px;
  line-height: 1.6;
}

/* ============================================================
   CP & Enemy Cards
   ============================================================ */
.cp-enemy-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-top: 20px;
}

.cp-card {
  border-left: 3px solid var(--cp-color) !important;
}

.enemy-card {
  border-left: 3px solid var(--enemy-color) !important;
}

.cp-enemy-icon {
  font-size: 1.6rem;
  margin-bottom: 8px;
}

.cp-enemy-code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
  color: var(--accent);
  margin: 6px 0 8px;
}

/* ============================================================
   Share Hint
   ============================================================ */
.share-hint {
  margin-top: 24px;
  text-align: center;
  padding: 16px;
  border-radius: var(--radius-sm);
  background: rgba(70, 242, 200, 0.04);
  border: 1px dashed rgba(70, 242, 200, 0.2);
}

.share-hint p {
  color: var(--muted);
  font-size: 0.9rem;
  line-height: 1.6;
  margin: 0;
}

/* ============================================================
   Gallery Nav Link
   ============================================================ */
.gallery-nav-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border-radius: 999px;
  padding: 10px 18px;
  border: 1px solid rgba(70, 242, 200, 0.3);
  background: rgba(70, 242, 200, 0.1);
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.92rem;
  color: var(--accent);
  text-decoration: none;
  transition: background 200ms ease, transform 160ms ease, border-color 200ms ease;
  cursor: pointer;
  white-space: nowrap;
}

.gallery-nav-link:hover {
  background: rgba(70, 242, 200, 0.2);
  border-color: rgba(70, 242, 200, 0.5);
  transform: translateY(-1px);
}

/* ============================================================
   Gallery Toolbar
   ============================================================ */
.gallery-toolbar {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.gallery-search-wrap {
  width: 100%;
}

.gallery-search {
  width: 100%;
  padding: 14px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--panel);
  color: var(--ink);
  font: inherit;
  font-size: 1rem;
  outline: none;
  transition: border-color 200ms ease, box-shadow 200ms ease;
}

.gallery-search::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

.gallery-search:focus {
  border-color: rgba(70, 242, 200, 0.4);
  box-shadow: 0 0 0 3px rgba(70, 242, 200, 0.1);
}

.gallery-filters {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.filter-chip {
  border: 1px solid var(--line);
  background: rgba(70, 242, 200, 0.06);
  color: var(--muted);
  border-radius: 999px;
  padding: 8px 16px;
  cursor: pointer;
  font: inherit;
  font-size: 0.85rem;
  font-family: "IBM Plex Mono", monospace;
  transition: all 200ms ease;
  white-space: nowrap;
}

.filter-chip:hover {
  background: rgba(70, 242, 200, 0.12);
  border-color: rgba(70, 242, 200, 0.3);
}

.filter-chip.active {
  color: #052018;
  background: linear-gradient(135deg, var(--accent), #95ffe4);
  border-color: transparent;
}

/* ============================================================
   Gallery Grid
   ============================================================ */
.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.gallery-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  padding: 22px;
  cursor: pointer;
  transition: transform 260ms ease, border-color 260ms ease, box-shadow 260ms ease;
  position: relative;
  overflow: hidden;
}

.gallery-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: var(--card-accent, var(--accent));
  opacity: 0.6;
  transition: opacity 260ms ease;
}

.gallery-card:hover {
  transform: translateY(-4px);
  border-color: rgba(70, 242, 200, 0.3);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
}

.gallery-card:hover::before {
  opacity: 1;
}

.gallery-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.gallery-card-emoji {
  font-size: 2rem;
}

.gallery-card-code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--card-accent, var(--accent));
  padding: 4px 10px;
  border-radius: 8px;
  background: rgba(70, 242, 200, 0.08);
  letter-spacing: 0.1em;
}

.gallery-card-name {
  font-size: 1.15rem;
  font-weight: 700;
  margin: 0 0 8px;
  color: var(--ink);
}

.gallery-card-summary {
  font-size: 0.88rem;
  line-height: 1.7;
  color: var(--muted);
  margin: 0 0 16px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.gallery-card-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.gallery-card-tag {
  font-size: 0.78rem;
  color: var(--muted);
  font-family: "IBM Plex Mono", monospace;
}

.gallery-card-action {
  font-size: 0.82rem;
  color: var(--card-accent, var(--accent));
  font-weight: 500;
  opacity: 0;
  transform: translateX(-8px);
  transition: opacity 260ms ease, transform 260ms ease;
}

.gallery-card:hover .gallery-card-action {
  opacity: 1;
  transform: translateX(0);
}

/* ============================================================
   Gallery Empty State
   ============================================================ */
.gallery-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
  font-size: 1.1rem;
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  animation: fadeIn 200ms ease;
}

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

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal-content {
  position: relative;
  width: min(640px, 100%);
  max-height: calc(100vh - 40px);
  max-height: calc(100dvh - 40px);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background: var(--bg);
  box-shadow: 0 32px 80px rgba(0, 0, 0, 0.5);
  animation: slideUp 300ms ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.modal-close {
  position: sticky;
  top: 12px;
  float: right;
  margin: 12px 12px 0 0;
  z-index: 10;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--panel);
  color: var(--muted);
  font-size: 1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 200ms, color 200ms;
}

.modal-close:hover {
  background: rgba(248, 113, 113, 0.2);
  color: #f87171;
}

.modal-hero {
  text-align: center;
  padding: 40px 24px 28px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(70, 242, 200, 0.06) 0%, transparent 100%);
}

.modal-emoji {
  font-size: 3.5rem;
  display: block;
  margin-bottom: 12px;
}

.modal-code-badge {
  display: inline-block;
  font-family: "IBM Plex Mono", monospace;
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: var(--card-accent, var(--accent));
  padding: 6px 16px;
  border-radius: 999px;
  background: rgba(70, 242, 200, 0.1);
  border: 1px solid rgba(70, 242, 200, 0.2);
  margin-bottom: 12px;
}

.modal-name {
  font-size: 1.8rem;
  margin: 0 0 8px;
}

.modal-summary {
  color: var(--muted);
  line-height: 1.7;
  margin: 0;
  font-size: 0.95rem;
}

.modal-section {
  padding: 20px 24px;
  border-bottom: 1px solid var(--line);
}

.modal-section h3 {
  font-size: 1rem;
  margin: 0 0 10px;
}

.modal-section p {
  color: var(--muted);
  line-height: 1.8;
  margin: 0;
  font-size: 0.92rem;
}

.modal-quote {
  margin: 0;
  padding: 14px 20px;
  border-left: 3px solid var(--accent);
  background: rgba(70, 242, 200, 0.06);
  border-radius: 0 12px 12px 0;
  color: var(--ink);
  font-size: 1.05rem;
  font-style: italic;
  line-height: 1.7;
}

.modal-danger {
  padding: 14px 20px;
  border-left: 3px solid var(--enemy-color);
  background: rgba(248, 113, 113, 0.06);
  border-radius: 0 12px 12px 0;
}

.modal-cp-enemy {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.modal-cp,
.modal-enemy {
  padding: 20px 24px;
}

.modal-cp {
  border-right: 1px solid var(--line);
}

.modal-relation-icon {
  font-size: 1.4rem;
  margin-bottom: 6px;
}

.modal-cp h4,
.modal-enemy h4 {
  margin: 0 0 6px;
  font-size: 0.9rem;
  color: var(--ink);
}

.modal-relation-code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.82rem;
  color: var(--accent);
  margin-bottom: 8px;
}

.modal-cp p,
.modal-enemy p {
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 0;
}

/* ============================================================
   Detail Card
   ============================================================ */
.detail-card {
  border-left: 3px solid var(--accent);
  background: rgba(70, 242, 200, 0.04);
}

.detail-card h3 {
  color: var(--accent);
  margin-bottom: 12px;
}

.detail-card p {
  line-height: 2;
  font-size: 0.92rem;
}

/* QR Code section in download card */
.dl-card-qr-section {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-top: 16px;
  padding: 14px 16px;
  background: rgba(70, 242, 200, 0.06);
  border-radius: 10px;
  border: 1px solid rgba(70, 242, 200, 0.15);
  position: relative;
  z-index: 1;
}

.dl-card-qrcode {
  flex-shrink: 0;
  border-radius: 6px;
  border: 2px solid #0a0e14;
}

.dl-card-qr-text {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dl-card-qr-title {
  font-size: 13px;
  font-weight: 600;
  color: #e7f7f6;
  line-height: 1.4;
}

.dl-card-qr-url {
  font-family: "IBM Plex Mono", monospace;
  font-size: 11px;
  color: #46f2c8;
  opacity: 0.8;
}

/* Modal detail section */
.modal-detail-section {
  border-left: 3px solid var(--accent);
  background: rgba(70, 242, 200, 0.04);
  padding-left: 16px;
  border-radius: 8px;
}

.modal-detail-section h3 {
  color: var(--accent);
}

.modal-detail-section p {
  line-height: 2;
  font-size: 0.9rem;
}

/* ============================================================
   Download Card Button
   ============================================================ */
.download-card-button {
  border: 2px solid var(--accent);
  border-radius: 999px;
  padding: 14px 24px;
  cursor: pointer;
  color: var(--accent);
  background: rgba(70, 242, 200, 0.08);
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  transition: transform 160ms ease, background 200ms ease, box-shadow 200ms ease;
}

.download-card-button:hover {
  transform: translateY(-1px);
  background: rgba(70, 242, 200, 0.16);
  box-shadow: 0 4px 20px rgba(70, 242, 200, 0.2);
}

.download-card-button:active {
  transform: scale(0.97);
}

.download-card-button.downloading {
  opacity: 0.6;
  pointer-events: none;
}

/* ============================================================
   Download Card (for screenshot)
   ============================================================ */
.dl-card {
  width: 420px;
  background: linear-gradient(170deg, #0a1e28 0%, #061318 40%, #0d2a35 100%);
  border-radius: 24px;
  padding: 32px 28px 24px;
  font-family: "IBM Plex Sans", "PingFang SC", "Microsoft YaHei", sans-serif;
  color: #e7f7f6;
  position: relative;
  overflow: hidden;
}

.dl-card::before {
  content: "";
  position: absolute;
  top: -60px;
  right: -60px;
  width: 200px;
  height: 200px;
  background: radial-gradient(circle, rgba(70, 242, 200, 0.15) 0%, transparent 70%);
  pointer-events: none;
}

.dl-card::after {
  content: "";
  position: absolute;
  bottom: -40px;
  left: -40px;
  width: 160px;
  height: 160px;
  background: radial-gradient(circle, rgba(117, 200, 255, 0.1) 0%, transparent 70%);
  pointer-events: none;
}

.dl-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}

.dl-card-brand {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.72rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: #46f2c8;
  opacity: 0.8;
}

.dl-card-badge {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  color: #46f2c8;
  padding: 5px 14px;
  border-radius: 999px;
  background: rgba(70, 242, 200, 0.12);
  border: 1px solid rgba(70, 242, 200, 0.25);
}

.dl-card-emoji {
  font-size: 3.2rem;
  text-align: center;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.dl-card-name {
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  margin-bottom: 10px;
  position: relative;
  z-index: 1;
}

.dl-card-summary {
  font-size: 0.88rem;
  line-height: 1.7;
  color: #9cc1bf;
  text-align: center;
  margin-bottom: 20px;
  position: relative;
  z-index: 1;
}

.dl-card-divider {
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(70, 242, 200, 0.2), transparent);
  margin: 16px 0;
}

.dl-card-section {
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.dl-card-section-title {
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 8px;
  color: #e7f7f6;
}

.dl-card-section-text {
  font-size: 0.82rem;
  line-height: 1.75;
  color: #9cc1bf;
}

.dl-card-quote {
  font-size: 0.9rem;
  line-height: 1.7;
  color: #e7f7f6;
  padding: 10px 14px;
  border-left: 3px solid #46f2c8;
  background: rgba(70, 242, 200, 0.06);
  border-radius: 0 10px 10px 0;
  font-style: italic;
}

.dl-card-row {
  display: flex;
  gap: 12px;
  margin: 16px 0;
  position: relative;
  z-index: 1;
}

.dl-card-relation {
  flex: 1;
  padding: 12px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(231, 247, 246, 0.08);
}

.dl-card-cp {
  border-left: 3px solid #4ade80;
}

.dl-card-enemy {
  border-left: 3px solid #f87171;
}

.dl-card-relation-icon {
  font-size: 1.2rem;
  margin-bottom: 4px;
}

.dl-card-relation-label {
  font-size: 0.72rem;
  color: #9cc1bf;
  margin-bottom: 4px;
}

.dl-card-relation-code {
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.8rem;
  font-weight: 600;
  color: #46f2c8;
}

.dl-card-footer {
  margin-top: 16px;
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(248, 113, 113, 0.06);
  border: 1px solid rgba(248, 113, 113, 0.12);
  position: relative;
  z-index: 1;
}

.dl-card-footer span {
  font-size: 0.78rem;
  font-weight: 600;
  color: #f87171;
  display: block;
  margin-bottom: 6px;
}

.dl-card-danger {
  font-size: 0.8rem;
  line-height: 1.7;
  color: #9cc1bf;
}

.dl-card-watermark {
  text-align: center;
  margin-top: 20px;
  font-family: "IBM Plex Mono", monospace;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: rgba(70, 242, 200, 0.4);
  position: relative;
  z-index: 1;
}

/* ============================================================
   RESPONSIVE — Tablet (max-width: 980px)
   ============================================================ */
@media (max-width: 980px) {
  .dashboard,
  .hero-panel,
  .result-grid {
    grid-template-columns: 1fr;
  }

  .cp-enemy-row {
    grid-template-columns: 1fr 1fr;
  }

  .domain-score-cards {
    grid-template-columns: 1fr;
  }

  .gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  }
}

/* ============================================================
   RESPONSIVE — Small Tablet (max-width: 768px)
   ============================================================ */
@media (max-width: 768px) {
  .app-shell {
    width: min(100% - 20px, 1280px);
    padding: 14px 0 32px;
  }

  .topbar {
    flex-direction: column;
    padding: 20px;
    gap: 16px;
  }

  .status-cluster {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px;
  }

  .status-cluster span,
  .gallery-nav-link {
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  h1 {
    font-size: clamp(1.8rem, 7vw, 2.6rem);
    line-height: 1.15;
  }

  h2 {
    font-size: clamp(1.3rem, 5vw, 1.8rem);
  }

  .topbar,
  .console-panel,
  .metric-panel,
  .log-panel,
  .result-panel,
  .hero-panel {
    padding: 18px;
    border-radius: var(--radius-md);
  }

  .result-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .cp-enemy-row {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }

  .gallery-card {
    padding: 16px;
    border-radius: var(--radius-sm);
  }

  .gallery-card-emoji {
    font-size: 1.6rem;
  }

  .gallery-card-name {
    font-size: 1rem;
  }

  .gallery-card-summary {
    font-size: 0.82rem;
    -webkit-line-clamp: 2;
  }

  .gallery-card-action {
    opacity: 1;
    transform: translateX(0);
  }

  .modal-content {
    border-radius: var(--radius-md);
  }

  .modal-hero {
    padding: 30px 18px 22px;
  }

  .modal-emoji {
    font-size: 2.8rem;
  }

  .modal-name {
    font-size: 1.5rem;
  }

  .modal-section {
    padding: 16px 18px;
  }

  .modal-cp-enemy {
    grid-template-columns: 1fr;
  }

  .modal-cp {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .modal-cp,
  .modal-enemy {
    padding: 16px 18px;
  }

  /* Sub-dimension responsive */
  .subdim-row {
    flex-wrap: wrap;
    gap: 8px;
  }

  .subdim-label {
    width: 100%;
    min-width: unset;
    margin-bottom: 0;
  }

  .subdim-desc {
    padding-left: 0;
    font-size: 0.78rem;
  }

  .subdim-group {
    padding: 14px;
  }

  #radar-chart {
    max-width: 320px;
  }
}

/* ============================================================
   RESPONSIVE — Mobile (max-width: 480px)
   ============================================================ */
@media (max-width: 480px) {
  :root {
    --radius-lg: 20px;
    --radius-md: 16px;
    --radius-sm: 14px;
    --radius-xs: 10px;
  }

  body {
    background: linear-gradient(180deg, #07131a 0%, #091920 100%);
  }

  .app-shell {
    width: calc(100% - 16px);
    padding: 10px 0 calc(20px + env(safe-area-inset-bottom));
  }

  /* Topbar mobile */
  .topbar {
    padding: 16px;
    gap: 14px;
    border-radius: var(--radius-md);
    margin-bottom: 14px;
  }

  .eyebrow,
  .section-kicker {
    font-size: 0.7rem;
    margin-bottom: 6px;
  }

  h1 {
    font-size: clamp(1.6rem, 8vw, 2.2rem);
    line-height: 1.2;
  }

  h2 {
    font-size: clamp(1.15rem, 5.5vw, 1.5rem);
  }

  .status-cluster {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 6px;
  }

  .status-cluster span {
    padding: 7px 10px;
    font-size: 0.75rem;
  }

  .gallery-nav-link {
    padding: 8px 14px;
    font-size: 0.82rem;
  }

  /* Tab bar mobile */
  .tab-bar {
    gap: 8px;
    margin-bottom: 14px;
  }

  .tab-button {
    flex: 1;
    text-align: center;
    padding: 11px 14px;
    font-size: 0.88rem;
  }

  /* Panels mobile */
  .topbar,
  .console-panel,
  .metric-panel,
  .log-panel,
  .result-panel,
  .hero-panel {
    padding: 14px;
    border-radius: var(--radius-md);
  }

  /* Console head */
  .console-head {
    flex-direction: row;
    align-items: center;
  }

  .ghost-button {
    padding: 8px 14px;
    font-size: 0.82rem;
  }

  /* Progress */
  .progress-box {
    margin: 14px 0;
  }

  .progress-meta {
    font-size: 0.82rem;
  }

  /* Question */
  .question-console {
    padding: 16px;
    border-radius: var(--radius-sm);
  }

  .question-text {
    font-size: 1rem;
    line-height: 1.65;
    margin-bottom: 16px;
  }

  .answers {
    gap: 10px;
  }

  .answer-button {
    min-height: 60px;
    border-radius: var(--radius-sm);
    padding: 14px 14px;
    font-size: 0.9rem;
    line-height: 1.5;
  }

  .answer-label {
    width: 28px;
    height: 28px;
    min-width: 28px;
    margin-right: 10px;
    font-size: 0.8rem;
  }

  /* Nav row sticky */
  .nav-row {
    flex-direction: row;
    gap: 10px;
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 12px 0 calc(8px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(7, 19, 26, 0) 0%, rgba(7, 19, 26, 0.96) 30%);
  }

  .nav-row button {
    flex: 1;
    min-height: 48px;
    font-size: 0.92rem;
  }

  /* Result panel mobile */
  .result-header {
    flex-direction: column;
    gap: 8px;
  }

  .result-code {
    font-size: 0.95rem;
    padding: 8px 12px;
  }

  .result-summary {
    font-size: 0.88rem;
    line-height: 1.7;
  }

  /* Score overview */
  .score-overview {
    margin-top: 20px;
  }

  .score-overview h3,
  .subdim-detail h3 {
    font-size: 1.05rem;
    margin-bottom: 14px;
  }

  #radar-chart {
    max-width: 280px;
  }

  .domain-score-cards {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .domain-score-card {
    padding: 14px;
    border-radius: var(--radius-xs);
  }

  .dsc-name {
    font-size: 0.92rem;
  }

  .dsc-score {
    font-size: 0.82rem;
  }

  .dsc-poles {
    font-size: 0.75rem;
  }

  /* Sub-dimensions mobile */
  .subdim-detail {
    margin-top: 20px;
  }

  .subdim-group {
    padding: 12px;
    margin-bottom: 16px;
    border-radius: var(--radius-xs);
  }

  .subdim-group h4 {
    font-size: 0.92rem;
    margin-bottom: 10px;
  }

  .subdim-row {
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 2px;
  }

  .subdim-label {
    width: 100%;
    min-width: unset;
    font-size: 0.78rem;
  }

  .subdim-bar-wrap {
    flex: 1;
    min-width: 0;
  }

  .subdim-score {
    width: auto;
    min-width: auto;
    font-size: 0.78rem;
  }

  .subdim-desc {
    padding-left: 0;
    font-size: 0.76rem;
    margin-bottom: 12px;
  }

  /* Result grid mobile */
  .result-grid {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 14px;
  }

  .result-card,
  .metric-card {
    padding: 14px;
    border-radius: var(--radius-sm);
  }

  .result-card h3 {
    font-size: 0.95rem;
  }

  .result-card p {
    font-size: 0.88rem;
    line-height: 1.7;
  }

  /* Detail card */
  .detail-card p {
    font-size: 0.86rem;
    line-height: 1.85;
  }

  /* CP & Enemy mobile */
  .cp-enemy-row {
    grid-template-columns: 1fr;
    gap: 10px;
    margin-top: 14px;
  }

  .cp-enemy-icon {
    font-size: 1.4rem;
  }

  .cp-enemy-code {
    font-size: 0.82rem;
  }

  /* Share hint mobile */
  .share-hint {
    margin-top: 16px;
    padding: 14px;
  }

  .share-hint p {
    font-size: 0.82rem;
  }

  /* Result actions sticky */
  .result-actions {
    flex-direction: column;
    gap: 10px;
    position: sticky;
    bottom: 0;
    z-index: 5;
    padding: 14px 0 calc(8px + env(safe-area-inset-bottom));
    background: linear-gradient(180deg, rgba(7, 19, 26, 0) 0%, rgba(7, 19, 26, 0.96) 30%);
  }

  .result-actions button {
    width: 100%;
    min-height: 48px;
  }

  .download-card-button {
    font-size: 0.92rem;
    padding: 12px 20px;
  }

  .primary-button,
  .secondary-button {
    font-size: 0.92rem;
    padding: 12px 20px;
  }

  /* Gallery mobile */
  .gallery-toolbar {
    margin-bottom: 14px;
    gap: 10px;
  }

  .gallery-search {
    padding: 12px 16px;
    font-size: 0.92rem;
    border-radius: var(--radius-sm);
  }

  .gallery-filters {
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    gap: 6px;
    padding-bottom: 4px;
  }

  .gallery-filters::-webkit-scrollbar {
    display: none;
  }

  .filter-chip {
    white-space: nowrap;
    flex-shrink: 0;
    padding: 7px 12px;
    font-size: 0.78rem;
  }

  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .gallery-card {
    padding: 14px;
    border-radius: var(--radius-sm);
  }

  .gallery-card-emoji {
    font-size: 1.5rem;
  }

  .gallery-card-code {
    font-size: 0.72rem;
    padding: 3px 8px;
  }

  .gallery-card-name {
    font-size: 0.92rem;
    margin-bottom: 6px;
  }

  .gallery-card-summary {
    font-size: 0.78rem;
    margin-bottom: 10px;
    -webkit-line-clamp: 2;
  }

  .gallery-card-footer {
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
  }

  .gallery-card-tag {
    font-size: 0.72rem;
  }

  .gallery-card-action {
    opacity: 1;
    transform: translateX(0);
    font-size: 0.75rem;
  }

  .gallery-empty {
    padding: 40px 16px;
    font-size: 0.95rem;
  }

  /* Modal mobile */
  .modal-overlay {
    padding: 10px;
    align-items: flex-end;
  }

  .modal-content {
    max-height: calc(100vh - 20px);
    max-height: calc(100dvh - 20px);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    width: 100%;
  }

  .modal-close {
    width: 36px;
    height: 36px;
    margin: 10px 10px 0 0;
  }

  .modal-hero {
    padding: 28px 16px 20px;
  }

  .modal-emoji {
    font-size: 2.4rem;
    margin-bottom: 8px;
  }

  .modal-code-badge {
    font-size: 0.85rem;
    padding: 5px 12px;
  }

  .modal-name {
    font-size: 1.3rem;
  }

  .modal-summary {
    font-size: 0.88rem;
  }

  .modal-section {
    padding: 14px 16px;
  }

  .modal-section h3 {
    font-size: 0.92rem;
    margin-bottom: 8px;
  }

  .modal-section p {
    font-size: 0.85rem;
    line-height: 1.75;
  }

  .modal-quote {
    font-size: 0.92rem;
    padding: 12px 14px;
  }

  .modal-danger {
    padding: 12px 14px;
  }

  .modal-cp-enemy {
    grid-template-columns: 1fr;
  }

  .modal-cp {
    border-right: none;
    border-bottom: 1px solid var(--line);
  }

  .modal-cp,
  .modal-enemy {
    padding: 14px 16px;
  }

  .modal-detail-section {
    padding-left: 14px;
  }

  .modal-detail-section p {
    font-size: 0.84rem;
    line-height: 1.85;
  }

  .terminal-body {
    min-height: 96px;
    padding: 12px 14px;
    font-size: 0.84rem;
  }
}

/* ============================================================
   RESPONSIVE — Very Small Mobile (max-width: 360px)
   ============================================================ */
@media (max-width: 360px) {
  .app-shell {
    width: calc(100% - 12px);
  }

  h1 {
    font-size: 1.5rem;
  }

  .topbar {
    padding: 14px;
  }

  .status-cluster span {
    padding: 6px 8px;
    font-size: 0.7rem;
  }

  .gallery-grid {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .gallery-card {
    padding: 14px;
  }

  .gallery-card-name {
    font-size: 1rem;
  }

  .gallery-card-summary {
    font-size: 0.82rem;
  }

  .gallery-card-footer {
    flex-direction: row;
    align-items: center;
  }

  .answer-button {
    min-height: 54px;
    padding: 12px;
    font-size: 0.85rem;
  }

  .question-text {
    font-size: 0.95rem;
  }

  #radar-chart {
    max-width: 240px;
  }

  .modal-overlay {
    padding: 0;
  }

  .modal-content {
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
  }
}

/* ============================================================
   Print / Accessibility
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Focus visible for keyboard navigation */
:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button:focus-visible,
a:focus-visible,
input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ============================================================
   Topic Toggle Switch
   ============================================================ */
.topic-switch {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.topic-switch-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
  transition: color 200ms ease;
  cursor: default;
  user-select: none;
  font-family: "IBM Plex Sans", sans-serif;
}

.topic-switch-label.active {
  color: var(--accent);
}

/* Toggle switch */
.toggle-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}

.toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.toggle-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: rgba(70, 242, 200, 0.2);
  border: 1px solid rgba(70, 242, 200, 0.3);
  border-radius: 24px;
  transition: all 250ms ease;
}

.toggle-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background: var(--accent);
  border-radius: 50%;
  transition: transform 250ms ease;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.3);
}

.toggle-switch input:checked + .toggle-slider {
  background: rgba(70, 242, 200, 0.2);
}

.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(20px);
}

/* Gallery reuses the same topic-switch for consistency */
.topic-switcher {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 16px;
}

.topic-switcher .topic-button {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: all 200ms ease;
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
}

.topic-switcher .topic-button:hover {
  border-color: rgba(70, 242, 200, 0.3);
  color: var(--ink);
}

.topic-switcher .topic-button.active {
  border-color: var(--accent);
  color: var(--accent);
  background: rgba(70, 242, 200, 0.08);
}

.topic-switcher .topic-icon {
  font-size: 1rem;
}

.topic-switcher .topic-label {
  font-size: 0.82rem;
  font-weight: 600;
}