:root {
  --bg: #0b0f17;
  --bg-2: #121824;
  --panel: rgba(20, 27, 41, 0.92);
  --panel-soft: rgba(26, 34, 50, 0.96);
  --panel-strong: rgba(12, 18, 28, 0.94);
  --border: #32405a;
  --border-soft: rgba(212, 176, 116, 0.18);
  --text: #eef3fb;
  --muted: #9db0d2;
  --accent: #d4b074;
  --accent-2: #6dc7ff;
  --accent-3: #86df9b;
  --danger: #eb7878;
  --shadow: 0 16px 40px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at top right, rgba(84, 121, 187, 0.2) 0%, rgba(11, 15, 23, 0) 28%),
    radial-gradient(circle at bottom left, rgba(212, 176, 116, 0.14) 0%, rgba(11, 15, 23, 0) 35%),
    linear-gradient(180deg, var(--bg-2) 0%, var(--bg) 100%);
  color: var(--text);
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  overflow-wrap: anywhere;
}

img {
  max-width: 100%;
}

button,
select,
input,
textarea {
  font: inherit;
}

a {
  color: var(--accent-2);
}

.skip-link {
  position: absolute;
  left: 16px;
  top: -48px;
  z-index: 100;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--panel-strong);
  color: var(--text);
  text-decoration: none;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.skip-link:focus {
  top: 16px;
}

.app-shell {
  max-width: 1440px;
  margin: 0 auto;
  padding:
    max(18px, env(safe-area-inset-top))
    max(18px, env(safe-area-inset-right))
    max(18px, env(safe-area-inset-bottom))
    max(18px, env(safe-area-inset-left));
  display: grid;
  gap: 16px;
}

.app-header,
.app-hero,
.module-card {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 18px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

.app-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px 20px;
  position: sticky;
  top: 12px;
  z-index: 20;
}

.brand-lockup {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.brand-mark {
  min-width: 64px;
  min-height: 64px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: #1a1308;
  background: linear-gradient(135deg, #f0d598 0%, #c7923e 55%, #8a5b1c 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.38);
}

.brand-copy h1,
.app-header h1,
.app-hero h2 {
  margin: 0;
}

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

.brand-copy p,
.app-header p,
.app-hero p {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.14em;
  font-size: 0.76rem;
  color: var(--accent);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.app-hero {
  display: grid;
  grid-template-columns: minmax(0, 1.35fr) minmax(250px, 0.8fr);
  gap: 16px;
  padding: 18px 20px;
  position: relative;
  overflow: hidden;
}

.app-hero::after {
  content: '';
  position: absolute;
  inset: auto -120px -160px auto;
  width: 320px;
  height: 320px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(212, 176, 116, 0.22) 0%, rgba(212, 176, 116, 0) 70%);
  pointer-events: none;
}

.hero-copy,
.hero-meta {
  display: grid;
  gap: 10px;
}

.hero-meta {
  align-content: start;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.hero-stat {
  border: 1px solid var(--border-soft);
  background: rgba(255, 255, 255, 0.025);
  border-radius: 14px;
  padding: 12px;
  display: grid;
  gap: 4px;
}

.hero-stat span {
  font-size: 0.8rem;
  color: var(--muted);
}

.hero-stat strong {
  font-size: 1rem;
}

.hero-nav {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  grid-column: 1 / -1;
}

.hero-nav button {
  min-width: 0;
}

button,
select,
input {
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  line-height: 1.2;
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease, transform 120ms ease;
}

textarea {
  border: 1px solid var(--border);
  background: var(--panel-soft);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  width: 100%;
  min-height: 100px;
  resize: vertical;
  transition: border-color 120ms ease, box-shadow 120ms ease, background-color 120ms ease;
}

button {
  cursor: pointer;
}

button:hover:not(:disabled) {
  border-color: rgba(212, 176, 116, 0.65);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.72;
}

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

.module-host {
  display: block;
  scroll-margin-top: 122px;
}

.module-host.is-target .module-card {
  border-color: rgba(212, 176, 116, 0.88);
  box-shadow: 0 0 0 1px rgba(212, 176, 116, 0.28), 0 18px 44px rgba(0, 0, 0, 0.3);
}

.module-card {
  padding: 14px;
  display: grid;
  gap: 10px;
  min-height: 280px;
}

.module-card-wide {
  grid-column: span 2;
}

.module-card h2,
.module-card h3,
.module-card h4 {
  margin: 0;
}

.muted {
  color: var(--muted);
}

.prompt-controls,
.prompt-results,
.exp-grid,
.exp-skills,
.exp-milestones {
  display: grid;
  gap: 8px;
}

.prompt-controls {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
}

.prompt-controls label {
  display: grid;
  gap: 6px;
  min-width: 0;
}

.prompt-results {
  max-height: 360px;
  overflow: auto;
}

.prompt-result-item {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  padding: 10px;
  display: grid;
  gap: 4px;
}

.exp-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.stat-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.02);
  padding: 10px;
}

.progress-bar {
  height: 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.1);
  overflow: hidden;
}

.progress-bar i {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.stats-row {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
}

.module-head {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}

.inline-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 6px 10px;
  background: rgba(255, 255, 255, 0.04);
}

.chip-button {
  cursor: pointer;
}

.prompt-status {
  border-radius: 12px;
  border: 1px solid var(--border);
  padding: 10px;
  display: grid;
  gap: 6px;
}

.prompt-status.good {
  border-color: rgba(134, 223, 155, 0.6);
}

.prompt-status.bad {
  border-color: rgba(235, 120, 120, 0.6);
}

.prompt-status-line {
  line-height: 1.4;
}

.prompt-status-meta,
.prompt-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.prompt-result-row {
  display: grid;
  gap: 4px;
}

.prompt-empty-state {
  border: 1px dashed rgba(156, 176, 212, 0.35);
  border-radius: 12px;
  padding: 12px;
  display: grid;
  gap: 6px;
  background: rgba(255, 255, 255, 0.02);
}

.gear-web-grid {
  display: grid;
  gap: 10px;
  grid-template-columns: minmax(230px, 300px) minmax(0, 1fr);
}

.gear-slot-list,
.gear-search-results,
.prompt-results {
  scrollbar-width: thin;
}

.gear-slot-list {
  display: grid;
  gap: 6px;
  max-height: 480px;
  overflow: auto;
}

.gear-slot-row {
  text-align: left;
  display: grid;
  gap: 4px;
}

.gear-slot-row.active {
  border-color: var(--accent);
  box-shadow: inset 0 0 0 1px rgba(212, 176, 116, 0.45);
}

.gear-search-panel,
.gear-detail-panel,
.ai-shell,
.ai-output,
.feedback-shell {
  display: grid;
  gap: 8px;
}

.ai-shell textarea,
.ai-correction {
  min-height: 92px;
  border-radius: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  background: rgba(9, 14, 24, 0.92);
  color: var(--text);
}

.ai-answer {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  line-height: 1.45;
  background: rgba(255, 255, 255, 0.02);
}

.ai-citations {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.citation-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.03);
}

.citation-link {
  color: var(--text);
  text-decoration: none;
}

.market-row {
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.market-price,
.micro-value {
  font-weight: 700;
}

.market-price {
  font-size: 1.05rem;
}

.micro-card {
  min-height: 130px;
}

.micro-value {
  font-size: 1.4rem;
}

button:focus-visible,
select:focus-visible,
input:focus-visible,
textarea:focus-visible,
.citation-link:focus-visible,
.prompt-result-item:focus-visible,
.gear-slot-row:focus-visible,
.skip-link:focus-visible {
  outline: none;
  border-color: rgba(212, 176, 116, 0.95);
  box-shadow: 0 0 0 1px rgba(212, 176, 116, 0.42), 0 0 0 4px rgba(212, 176, 116, 0.16);
}

@media (max-width: 1100px) {
  .app-header,
  .app-hero {
    grid-template-columns: 1fr;
  }

  .header-actions {
    justify-content: flex-start;
  }

  .hero-meta {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 980px) {
  .app-shell {
    padding: 14px;
  }

  .module-grid,
  .exp-grid,
  .prompt-controls,
  .gear-web-grid {
    grid-template-columns: 1fr;
  }

  .module-card-wide {
    grid-column: span 1;
  }

  .module-host {
    scroll-margin-top: 96px;
  }
}

@media (max-width: 720px) {
  .app-shell {
    padding: 12px;
    gap: 12px;
  }

  .app-header,
  .app-hero,
  .module-card {
    border-radius: 16px;
  }

  .app-header,
  .app-hero,
  .module-card {
    padding: 12px;
  }

  .brand-lockup {
    grid-template-columns: 1fr;
  }

  .brand-mark {
    width: 58px;
    min-width: 58px;
    min-height: 58px;
  }

  .hero-meta {
    grid-template-columns: 1fr 1fr;
  }

  .hero-nav,
  .inline-actions,
  .header-actions {
    width: 100%;
  }

  .hero-nav > *,
  .inline-actions > button,
  .header-actions > button {
    flex: 1 1 160px;
  }

  .module-card {
    min-height: auto;
  }

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

  .market-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .prompt-results,
  .gear-search-results,
  .gear-slot-list {
    max-height: 300px;
  }
}

@media (max-width: 560px) {
  .hero-meta,
  .stats-row {
    grid-template-columns: 1fr;
  }

  .chip,
  .hero-nav > *,
  .inline-actions > * {
    width: 100%;
  }

  .header-actions {
    align-items: stretch;
  }

  .header-actions > * {
    width: 100%;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
