:root {
  color-scheme: dark;
  --ink: #edf0e7;
  --muted: #9ba69e;
  --canvas: #0b0f0d;
  --surface: #121815;
  --surface-2: #18201c;
  --line: #2c3831;
  --yellow: #f5c443;
  --yellow-strong: #ffcf48;
  --green: #6faa78;
  --red: #d66a5e;
  --blue: #80a9b8;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { min-height: 100%; margin: 0; }
body { background: var(--canvas); color: var(--ink); font-size: 14px; letter-spacing: 0; }
button, input, select, textarea { font: inherit; letter-spacing: 0; }
button, a, select { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--yellow); outline-offset: 2px; }

.topbar {
  height: 66px; display: flex; align-items: center; justify-content: space-between; gap: 24px;
  padding: 0 24px; border-bottom: 1px solid var(--line); background: rgba(11, 15, 13, .96);
  position: sticky; top: 0; z-index: 20;
}
.brand { display: inline-flex; align-items: center; gap: 12px; color: var(--ink); text-decoration: none; }
.brand-mark { width: 38px; height: 38px; display: grid; place-items: center; border: 1px solid var(--yellow); color: var(--yellow); font-weight: 900; font-size: 12px; transform: skew(-7deg); }
.brand strong, .brand small { display: block; }
.brand strong { font-size: 15px; }
.brand small { margin-top: 2px; color: var(--muted); font-size: 9px; font-weight: 700; }
.top-actions { min-width: 0; display: flex; align-items: center; gap: 10px; }
.version-chip { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: 11px; }
.account-name { max-width: 150px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; font-weight: 700; }
.icon-button { width: 36px; height: 36px; display: grid; place-items: center; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-decoration: none; cursor: pointer; font-size: 18px; }
.icon-button:hover { border-color: #526159; }

.center-view { min-height: calc(100vh - 66px); display: grid; align-content: center; justify-items: center; gap: 14px; padding: 32px; text-align: center; }
.center-view h1 { margin: 0; font-size: 28px; }
.center-view p { max-width: 480px; margin: 0; color: var(--muted); line-height: 1.7; }
.center-view .primary-button { width: auto; min-width: 190px; margin-top: 8px; }
.text-link { color: var(--muted); }
.login-emblem { width: 72px; height: 72px; display: grid; place-items: center; border: 2px solid var(--yellow); color: var(--yellow); font-size: 20px; font-weight: 900; transform: skew(-7deg); }
.radar-loader { width: 56px; height: 56px; border: 1px solid #4e5d55; border-radius: 50%; position: relative; overflow: hidden; }
.radar-loader::before { content: ""; position: absolute; inset: 50% 50% 0 0; transform-origin: 100% 0; background: linear-gradient(45deg, transparent, rgba(245,196,67,.6)); animation: sweep 1.2s linear infinite; }
.radar-loader::after { content: ""; position: absolute; inset: 14px; border: 1px solid #39463f; border-radius: 50%; }
@keyframes sweep { to { transform: rotate(360deg); } }

.app-shell { min-height: calc(100vh - 66px); display: grid; grid-template-columns: 370px minmax(0, 1fr); }
.control-panel { position: relative; min-width: 0; padding: 26px 24px 34px; border-right: 1px solid var(--line); background: #0f1411; }
.panel-heading, .result-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; }
.eyebrow { margin: 0 0 5px; color: var(--yellow); font-size: 10px; font-weight: 900; }
.panel-heading h1 { margin: 0; font-size: 24px; }
#loadout-form { display: grid; gap: 16px; margin-top: 24px; }
.field { display: grid; gap: 7px; min-width: 0; }
.field > span { font-size: 12px; font-weight: 800; }
.field b { color: var(--muted); font-size: 10px; font-weight: 500; }
.field small { min-height: 18px; color: var(--muted); font-size: 11px; line-height: 1.5; }
.field-row { min-width: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
select, textarea { width: 100%; border: 1px solid var(--line); border-radius: 3px; background: var(--surface-2); color: var(--ink); }
select { height: 43px; padding: 0 34px 0 11px; }
textarea { min-height: 78px; padding: 11px; resize: vertical; line-height: 1.5; }
select:hover, textarea:hover { border-color: #526159; }
.primary-button, .secondary-button { display: inline-flex; align-items: center; justify-content: center; border-radius: 3px; cursor: pointer; text-decoration: none; font-weight: 800; }
.primary-button { min-height: 44px; border: 1px solid var(--yellow); background: var(--yellow); color: #14160f; }
.primary-button:hover { background: var(--yellow-strong); }
.secondary-button { min-height: 34px; padding: 0 12px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); }
.generate-button { width: 100%; position: relative; }
.generate-button[disabled] { opacity: .72; cursor: wait; }
.button-loader { width: 17px; height: 17px; margin-left: 9px; border: 2px solid rgba(20,22,15,.35); border-top-color: #14160f; border-radius: 50%; animation: spin .8s linear infinite; display: none; }
.generate-button[disabled] .button-loader { display: block; }
@keyframes spin { to { transform: rotate(360deg); } }
.error { min-height: 18px; margin: -6px 0 0; color: #ef8d81; font-size: 12px; }

.history-panel { position: absolute; z-index: 8; inset: 0; padding: 24px; background: #0f1411; overflow-y: auto; }
.history-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; font-size: 16px; }
.history-heading button { width: 34px; height: 34px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); cursor: pointer; font-size: 20px; }
.history-list { display: grid; gap: 8px; }
.history-item { width: 100%; display: grid; grid-template-columns: 1fr auto; gap: 10px; padding: 13px; border: 1px solid var(--line); background: var(--surface); color: var(--ink); text-align: left; cursor: pointer; }
.history-item:hover { border-color: var(--yellow); }
.history-copy strong, .history-copy small { display: block; }
.history-copy strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.history-copy small { margin-top: 5px; color: var(--muted); font-size: 10px; }
.delete-history { width: 28px; height: 28px; border: 0; background: transparent; color: var(--muted); cursor: pointer; font-size: 17px; }
.delete-history:hover { color: var(--red); }
.empty-note { color: var(--muted); text-align: center; }

.workspace { min-width: 0; padding: 36px clamp(26px, 4vw, 64px) 70px; overflow: hidden; }
.welcome-view { min-height: calc(100vh - 172px); display: grid; grid-template-columns: minmax(300px, 580px) minmax(280px, 1fr); align-items: center; gap: 7vw; }
.welcome-copy { order: -1; max-width: 590px; }
.welcome-copy h2 { max-width: 520px; margin: 0; font-size: clamp(42px, 5vw, 72px); line-height: 1.02; font-weight: 850; }
.welcome-copy > p:not(.eyebrow) { max-width: 570px; margin: 22px 0 0; color: var(--muted); font-size: 15px; line-height: 1.85; }
.capability-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 26px; }
.capability-row span { padding: 7px 9px; border-left: 2px solid var(--yellow); background: var(--surface); color: #c6cec8; font-size: 11px; }
.sector-visual { width: min(36vw, 480px); aspect-ratio: 1; justify-self: center; position: relative; border: 1px solid #28332d; border-radius: 50%; overflow: hidden; background: repeating-radial-gradient(circle at 52% 50%, transparent 0 46px, rgba(125,145,133,.13) 47px 48px), radial-gradient(circle at 52% 50%, #27362e 0 20%, #151e19 21% 48%, #0e1310 49%); box-shadow: 0 0 80px rgba(113, 145, 124, .1); }
.sector-visual::before, .sector-visual::after { content: ""; position: absolute; background: rgba(151,168,158,.17); }
.sector-visual::before { width: 1px; height: 100%; left: 50%; }
.sector-visual::after { height: 1px; width: 100%; top: 50%; }
.planet { position: absolute; width: 38%; aspect-ratio: 1; left: 33%; top: 31%; border-radius: 47% 53% 49% 51%; background: radial-gradient(circle at 35% 30%, #9ca982 0 4%, #64735a 5% 21%, #39473b 22% 44%, #202a23 45% 100%); box-shadow: inset -18px -10px 24px rgba(0,0,0,.42), 0 0 22px rgba(165,181,141,.18); }
.orbit { position: absolute; border: 1px solid rgba(245,196,67,.35); border-radius: 50%; transform: rotate(-22deg); }
.orbit-one { inset: 24%; }
.orbit-two { inset: 14% 28%; transform: rotate(52deg); }
.scan-line { position: absolute; left: 50%; top: 50%; width: 44%; height: 1px; transform-origin: left; background: linear-gradient(90deg, var(--yellow), transparent); animation: scan 5s linear infinite; }
@keyframes scan { to { transform: rotate(360deg); } }
.point { position: absolute; width: 7px; height: 7px; border: 1px solid var(--yellow); background: #3a3420; transform: rotate(45deg); }
.p1 { top: 21%; left: 28%; }.p2 { top: 67%; left: 71%; }.p3 { top: 37%; left: 78%; }

#result-view { max-width: 1120px; margin: 0 auto; }
.result-heading h2 { margin: 0; font-size: 30px; }
.result-time { color: var(--muted); font-size: 11px; }
.result-summary { margin: 18px 0 0; padding: 17px 20px; border-left: 3px solid var(--yellow); background: var(--surface); color: #cbd2cd; line-height: 1.75; }
.condition-strip { display: flex; flex-wrap: wrap; gap: 7px; margin: 15px 0 30px; }
.condition-strip span { padding: 6px 9px; border: 1px solid var(--line); color: var(--muted); font-size: 10px; }
.result-section { margin-top: 34px; }
.section-title { display: flex; align-items: center; gap: 12px; margin-bottom: 15px; }
.section-title > span { width: 34px; height: 34px; display: grid; place-items: center; background: var(--yellow); color: #12150f; font-size: 11px; font-weight: 900; }
.section-title h3, .section-title p { margin: 0; }
.section-title h3 { font-size: 17px; }
.section-title p { margin-top: 3px; color: var(--muted); font-size: 10px; }
.stratagem-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.gear-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.equipment-card { min-width: 0; padding: 16px; border: 1px solid var(--line); background: var(--surface); }
.equipment-card-top { display: flex; justify-content: space-between; gap: 10px; }
.equipment-card .slot { color: var(--yellow); font-size: 9px; font-weight: 900; }
.score { color: var(--green); font-size: 11px; font-weight: 800; }
.equipment-card h4 { margin: 11px 0 5px; font-size: 15px; }
.equipment-card .category { margin: 0; color: var(--muted); font-size: 10px; }
.equipment-card .reason { min-height: 62px; margin: 14px 0; color: #b9c2bc; font-size: 12px; line-height: 1.65; }
.tag-row { display: flex; flex-wrap: wrap; gap: 5px; }
.tag-row span { padding: 4px 6px; background: #202a24; color: #aebbb2; font-size: 9px; }
.source { display: block; margin-top: 12px; padding-top: 10px; border-top: 1px solid #252e29; color: #78857d; font-size: 9px; }
.analysis-grid { display: grid; grid-template-columns: 1.35fr 1fr; gap: 10px; margin-top: 34px; }
.analysis-panel { padding: 19px; border: 1px solid var(--line); background: var(--surface); }
.analysis-panel h3 { margin: 0 0 13px; font-size: 14px; }
.analysis-panel ul { margin: 0; padding-left: 18px; color: #b9c2bc; line-height: 1.7; }
.analysis-panel li + li { margin-top: 7px; }
.priority-tags { display: flex; flex-wrap: wrap; gap: 7px; }
.priority-tags span { padding: 6px 8px; border: 1px solid #4e5f55; color: #c2ccc5; font-size: 10px; }
.method-note { margin: 15px 0 0; color: var(--muted); font-size: 10px; line-height: 1.65; }
.alternatives-list { display: grid; gap: 8px; }
.alternative-row { display: grid; grid-template-columns: 100px 1fr; gap: 15px; padding: 12px 14px; border-bottom: 1px solid var(--line); background: var(--surface); }
.alternative-row > strong { color: var(--yellow); font-size: 10px; }
.alternative-items { display: flex; flex-wrap: wrap; gap: 12px 20px; color: #c3cbc5; font-size: 11px; }
.alternative-items span small { margin-left: 5px; color: var(--muted); }
.data-notice { margin: 28px 0 0; color: #738078; font-size: 10px; line-height: 1.6; }
.toast { position: fixed; z-index: 40; right: 20px; bottom: 20px; max-width: min(380px, calc(100vw - 40px)); padding: 12px 15px; border: 1px solid #53645a; background: #1a231e; color: var(--ink); box-shadow: 0 15px 40px rgba(0,0,0,.35); }

@media (max-width: 980px) {
  .app-shell { grid-template-columns: 330px minmax(0, 1fr); }
  .stratagem-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .welcome-view { grid-template-columns: 1fr; align-content: center; }
  .sector-visual { width: min(60vw, 360px); order: -1; }
  .welcome-copy { text-align: center; }
  .welcome-copy > p:not(.eyebrow) { margin-left: auto; margin-right: auto; }
  .capability-row { justify-content: center; }
}

@media (max-width: 720px) {
  .topbar { height: 60px; padding: 0 14px; }
  .brand small, .version-chip, .account-name { display: none; }
  .brand-mark { width: 34px; height: 34px; }
  .app-shell { display: block; min-height: calc(100vh - 60px); }
  .control-panel { padding: 22px 16px 26px; border-right: 0; border-bottom: 1px solid var(--line); }
  .history-panel { position: fixed; inset: 60px 0 0; z-index: 30; }
  .workspace { padding: 30px 16px 54px; }
  .welcome-view { min-height: auto; padding: 30px 0 46px; }
  .welcome-copy h2 { font-size: 42px; }
  .sector-visual { width: min(82vw, 330px); }
  .stratagem-grid, .gear-grid, .analysis-grid { grid-template-columns: 1fr; }
  .equipment-card .reason { min-height: 0; }
  .alternative-row { grid-template-columns: 1fr; gap: 8px; }
  .result-heading h2 { font-size: 25px; }
}

@media (max-width: 380px) {
  .field-row { grid-template-columns: 1fr; }
  .welcome-copy h2 { font-size: 36px; }
}

@media (prefers-reduced-motion: reduce) {
  .radar-loader::before, .button-loader, .scan-line { animation: none; }
}
