:root {
  color-scheme: dark;
  --ink: oklch(18% 0.028 250);
  --paper: oklch(96% 0.018 92);
  --paper-strong: oklch(99% 0.009 92);
  --paper-muted: oklch(90% 0.022 92);
  --night: oklch(16% 0.035 252);
  --night-2: oklch(21% 0.04 252);
  --night-3: oklch(27% 0.035 252);
  --muted: oklch(59% 0.026 252);
  --muted-light: oklch(76% 0.022 252);
  --line: oklch(81% 0.024 92);
  --line-dark: oklch(34% 0.035 252);
  --accent: oklch(66% 0.125 63);
  --accent-2: oklch(69% 0.085 174);
  --danger: oklch(63% 0.16 32);
  --shadow-deep: 0 32px 90px oklch(7% 0.025 252 / 0.42);
  --shadow-paper: 0 26px 70px oklch(11% 0.02 252 / 0.24);
  --radius-xs: 6px;
  --radius-sm: 10px;
  --radius-md: 16px;
  --radius-lg: 26px;
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 12px;
  --space-lg: 16px;
  --space-xl: 24px;
  --space-2xl: 36px;
  --space-3xl: 56px;
  --font-ui: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, sans-serif;
  --font-display: "Songti SC", "STSong", "Noto Serif CJK SC", Georgia, serif;
  --font-mono: "SFMono-Regular", "Cascadia Mono", Menlo, Consolas, monospace;
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow-x: hidden;
  background:
    radial-gradient(circle at 18% -8%, oklch(42% 0.065 252 / 0.5), transparent 34rem),
    radial-gradient(circle at 88% 12%, oklch(56% 0.09 63 / 0.22), transparent 28rem),
    linear-gradient(135deg, oklch(13% 0.035 252), oklch(21% 0.032 252) 48%, oklch(12% 0.026 252));
  color: var(--paper);
  font-family: var(--font-ui);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background-image:
    linear-gradient(oklch(100% 0 0 / 0.035) 1px, transparent 1px),
    linear-gradient(90deg, oklch(100% 0 0 / 0.03) 1px, transparent 1px);
  background-size: 42px 42px;
  mask-image: linear-gradient(to bottom, black, transparent 84%);
}

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

button {
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.skip-link {
  position: fixed;
  left: 18px;
  top: 14px;
  z-index: 10;
  transform: translateY(-140%);
  border-radius: var(--radius-xs);
  background: var(--accent);
  color: var(--night);
  font-weight: 800;
  padding: var(--space-sm) var(--space-md);
  transition: transform 180ms ease;
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  position: relative;
  min-height: 100dvh;
  padding: clamp(20px, 3vw, 42px);
}

.topbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: var(--space-xl);
  max-width: 1640px;
  margin: 0 auto var(--space-xl);
}

.eyebrow {
  margin: 0 0 var(--space-sm);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.08em;
}

h1 {
  font-family: var(--font-display);
  font-size: clamp(3rem, 6vw, 6.8rem);
  font-weight: 700;
  letter-spacing: 0;
  line-height: 0.86;
  text-wrap: balance;
}

.is-hidden {
  display: none !important;
}

.login-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  min-height: 100dvh;
  padding: clamp(20px, 5vw, 64px);
  background:
    radial-gradient(circle at 16% 18%, oklch(67% 0.12 63 / 0.2), transparent 24rem),
    radial-gradient(circle at 78% 26%, oklch(70% 0.08 174 / 0.2), transparent 28rem),
    linear-gradient(135deg, oklch(12% 0.034 252), oklch(20% 0.032 252) 54%, oklch(10% 0.024 252));
}

.login-panel {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(280px, 0.85fr);
  gap: clamp(24px, 5vw, 56px);
  align-items: end;
  border: 1px solid oklch(100% 0 0 / 0.14);
  border-radius: var(--radius-lg);
  padding: clamp(24px, 5vw, 54px);
  background:
    linear-gradient(135deg, oklch(100% 0 0 / 0.08), oklch(100% 0 0 / 0.035)),
    oklch(16% 0.035 252 / 0.92);
  box-shadow: var(--shadow-deep);
}

.login-copy h1 {
  margin-bottom: var(--space-xl);
}

.login-copy p:not(.eyebrow) {
  max-width: 30rem;
  color: var(--muted-light);
  font-size: 1rem;
  line-height: 1.7;
}

.login-form {
  border: 1px solid oklch(100% 0 0 / 0.12);
  border-radius: var(--radius-md);
  padding: var(--space-xl);
  background: oklch(9% 0.024 252 / 0.7);
}

.login-form .field-label {
  margin-top: 0;
}

.login-error {
  min-height: 1.35rem;
  margin: var(--space-sm) 0 var(--space-lg);
  color: oklch(76% 0.14 32);
  font-size: 0.8rem;
  font-weight: 750;
}

h2 {
  color: inherit;
  font-size: 1rem;
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.2;
}

h3 {
  color: inherit;
  font-size: 0.9rem;
  font-weight: 850;
  letter-spacing: 0;
}

.topbar-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--space-md);
  flex-wrap: wrap;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(320px, 0.82fr) minmax(520px, 1.55fr) minmax(280px, 0.74fr);
  gap: clamp(16px, 1.5vw, 24px);
  max-width: 1640px;
  margin: 0 auto;
  align-items: start;
}

.input-panel,
.report-panel,
.advisor-panel {
  position: relative;
  border: 1px solid var(--line-dark);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-deep);
}

.input-panel,
.advisor-panel {
  background:
    linear-gradient(180deg, oklch(26% 0.036 252 / 0.96), oklch(18% 0.034 252 / 0.98)),
    var(--night);
  overflow: hidden;
}

.input-panel::before,
.advisor-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  border-radius: inherit;
  background: radial-gradient(circle at 20% 0%, oklch(74% 0.1 63 / 0.1), transparent 18rem);
}

.input-panel {
  padding: var(--space-xl);
}

.advisor-panel {
  position: sticky;
  top: clamp(16px, 2vw, 28px);
  padding: var(--space-xl);
}

.panel-heading {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-md);
  align-items: start;
  margin-bottom: var(--space-xl);
}

.panel-heading p,
.report-header p,
.draft-box p {
  color: var(--muted-light);
  font-size: 0.84rem;
  line-height: 1.55;
  margin-top: var(--space-xs);
  text-wrap: pretty;
}

.panel-heading.small {
  margin-bottom: var(--space-lg);
}

.step-marker {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 1px solid oklch(100% 0 0 / 0.16);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
  background: oklch(100% 0 0 / 0.045);
  flex: 0 0 auto;
}

.field-label {
  display: block;
  margin: var(--space-lg) 0 var(--space-sm);
  color: var(--muted-light);
  font-size: 0.75rem;
  font-weight: 800;
}

.text-input,
textarea {
  width: 100%;
  border: 1px solid oklch(100% 0 0 / 0.12);
  background: oklch(12% 0.025 252 / 0.72);
  border-radius: var(--radius-sm);
  color: var(--paper);
  outline: none;
  box-shadow: inset 0 1px 0 oklch(100% 0 0 / 0.04);
  transition: border-color 180ms ease, background 180ms ease, box-shadow 180ms ease;
}

.text-input {
  height: 44px;
  padding: 0 var(--space-md);
}

select.text-input {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--muted-light) 50%),
    linear-gradient(135deg, var(--muted-light) 50%, transparent 50%);
  background-position:
    calc(100% - 18px) 19px,
    calc(100% - 13px) 19px;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

textarea {
  min-height: 430px;
  resize: vertical;
  padding: var(--space-md);
  line-height: 1.58;
  font-size: 0.92rem;
}

.text-input::placeholder,
textarea::placeholder {
  color: oklch(72% 0.02 252 / 0.62);
}

.text-input:focus,
textarea:focus {
  border-color: var(--accent);
  background: oklch(10% 0.024 252 / 0.82);
  box-shadow: 0 0 0 3px oklch(66% 0.125 63 / 0.22);
}

.upload-zone {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: var(--space-md);
  min-height: 92px;
  padding: var(--space-md);
  border: 1px dashed oklch(100% 0 0 / 0.22);
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at 14% 16%, oklch(66% 0.125 63 / 0.12), transparent 8rem),
    oklch(12% 0.025 252 / 0.54);
  color: var(--paper);
  cursor: pointer;
  transition: border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.upload-zone:hover,
.upload-zone.drag-over,
.upload-zone.needs-input {
  border-color: var(--accent);
  background:
    radial-gradient(circle at 14% 16%, oklch(66% 0.125 63 / 0.2), transparent 9rem),
    oklch(10% 0.024 252 / 0.72);
  transform: translateY(-1px);
}

.upload-zone.needs-input {
  border-color: var(--danger);
  box-shadow: 0 0 0 3px oklch(63% 0.16 32 / 0.2);
}

.upload-zone:focus-visible {
  outline: 3px solid oklch(72% 0.1 63 / 0.65);
  outline-offset: 3px;
}

.upload-zone input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-zone strong {
  display: block;
  margin-bottom: var(--space-xs);
  font-size: 0.94rem;
  font-weight: 850;
}

.upload-zone span {
  display: block;
  max-width: 34ch;
  color: var(--muted-light);
  font-size: 0.78rem;
  line-height: 1.45;
}

.upload-actions {
  display: grid;
  gap: var(--space-sm);
  justify-items: end;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 850;
  padding: var(--space-xs) 0;
  text-align: right;
}

.text-button:hover {
  color: var(--paper);
}

.text-button:focus-visible {
  outline: 3px solid oklch(72% 0.1 63 / 0.65);
  outline-offset: 3px;
}

.upload-list {
  display: grid;
  gap: var(--space-sm);
  margin-top: var(--space-sm);
}

.upload-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  border: 1px solid oklch(100% 0 0 / 0.1);
  border-radius: var(--radius-sm);
  background: oklch(100% 0 0 / 0.045);
  color: var(--muted-light);
  font-size: 0.78rem;
  line-height: 1.35;
  padding: var(--space-sm) var(--space-md);
}

.upload-item strong {
  color: var(--paper);
  font-weight: 800;
}

.upload-item span {
  color: var(--muted-light);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-md);
}

.input-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--space-lg);
  color: var(--muted-light);
  font-size: 0.82rem;
}

.input-footer strong {
  color: var(--paper);
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.primary-button,
.ghost-button {
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.88rem;
  font-weight: 850;
  letter-spacing: 0;
  padding: 0 var(--space-lg);
  transition:
    transform 180ms ease,
    border-color 180ms ease,
    background 180ms ease,
    color 180ms ease,
    box-shadow 180ms ease;
}

.primary-button {
  background: var(--accent);
  color: var(--night);
  box-shadow: 0 12px 34px oklch(66% 0.125 63 / 0.24);
}

.ghost-button {
  background: oklch(100% 0 0 / 0.065);
  color: var(--paper);
  border-color: oklch(100% 0 0 / 0.14);
}

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

.primary-button:active,
.ghost-button:active {
  transform: translateY(0) scale(0.985);
}

.primary-button:disabled,
.ghost-button:disabled {
  cursor: wait;
  opacity: 0.68;
  transform: none;
}

.primary-button:focus-visible,
.ghost-button:focus-visible,
.tab:focus-visible,
.text-input:focus-visible,
textarea:focus-visible {
  outline: 3px solid oklch(72% 0.1 63 / 0.65);
  outline-offset: 3px;
}

.compact {
  min-height: 34px;
  padding: 0 var(--space-md);
  font-size: 0.78rem;
}

.full {
  width: 100%;
}

.report-panel {
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 780px;
  background:
    linear-gradient(180deg, oklch(99% 0.008 92), oklch(94% 0.018 92)),
    var(--paper);
  color: var(--ink);
  border-color: oklch(100% 0 0 / 0.4);
  box-shadow: var(--shadow-paper);
}

.report-panel::after {
  content: "";
  position: absolute;
  inset: auto 0 0;
  height: 12px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), oklch(68% 0.08 252));
}

.report-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-lg);
  padding: var(--space-2xl) var(--space-2xl) var(--space-xl);
}

.report-header .eyebrow {
  color: oklch(43% 0.105 63);
}

#reportTitle {
  color: var(--ink);
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 2.6vw, 3.2rem);
  line-height: 0.95;
}

.report-header .ghost-button {
  background: var(--ink);
  color: var(--paper-strong);
  border-color: var(--ink);
}

.tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-sm);
  padding: 0 var(--space-2xl) var(--space-xl);
  background: transparent;
}

.tab {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: transparent;
  color: oklch(42% 0.028 252);
  cursor: pointer;
  font-size: 0.82rem;
  font-weight: 850;
  transition: background 180ms ease, color 180ms ease, transform 180ms ease, border-color 180ms ease;
}

.tab:hover {
  transform: translateY(-1px);
  border-color: oklch(60% 0.045 92);
}

.tab.active {
  background: var(--ink);
  color: var(--paper-strong);
  border-color: var(--ink);
}

.report-body {
  flex: 1;
  overflow: auto;
  padding: 0 var(--space-2xl) var(--space-3xl);
  scrollbar-color: oklch(63% 0.04 92) transparent;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
  animation: panel-in 300ms ease both;
}

.empty-state {
  display: grid;
  min-height: 520px;
  place-items: center;
  text-align: center;
  color: oklch(52% 0.026 252);
  border: 1px dashed oklch(75% 0.026 92);
  border-radius: var(--radius-md);
  background:
    radial-gradient(circle at 50% 45%, oklch(83% 0.035 63 / 0.2), transparent 13rem),
    oklch(97% 0.01 92);
}

.empty-state strong {
  display: block;
  color: var(--ink);
  font-family: var(--font-display);
  font-size: 1.55rem;
  margin-bottom: var(--space-sm);
}

.section-stack {
  display: grid;
  gap: var(--space-lg);
}

.report-section {
  padding: var(--space-lg) 0;
  background: transparent;
}

.report-section h3 {
  margin-bottom: var(--space-md);
  color: var(--ink);
  font-size: 0.95rem;
}

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
  grid-auto-flow: dense;
}

.asset-card,
.candidate {
  border: 1px solid oklch(83% 0.025 92);
  border-radius: var(--radius-md);
  background:
    linear-gradient(180deg, var(--paper-strong), oklch(96% 0.014 92)),
    var(--paper-strong);
  box-shadow: 0 14px 32px oklch(14% 0.02 252 / 0.08);
  transition: transform 190ms ease, border-color 190ms ease, box-shadow 190ms ease;
}

.asset-card {
  padding: var(--space-md);
}

.asset-card:hover,
.candidate:hover,
.metric:hover {
  transform: translateY(-2px);
  border-color: oklch(68% 0.06 63);
  box-shadow: 0 18px 42px oklch(14% 0.02 252 / 0.12);
}

.asset-card header,
.candidate header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-sm);
}

.asset-card h4,
.candidate h4 {
  margin: 0;
  color: var(--ink);
  font-size: 0.98rem;
  font-weight: 850;
  line-height: 1.25;
}

.score-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 38px;
  height: 26px;
  border-radius: var(--radius-xs);
  background: oklch(89% 0.046 63);
  color: oklch(31% 0.072 63);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.asset-card ul,
.risk-box ul,
.report-section ul {
  margin: 0;
  padding-left: 1.05rem;
  color: oklch(43% 0.028 252);
  font-size: 0.88rem;
  line-height: 1.58;
}

.asset-card li,
.candidate li,
.risk-box li {
  margin-bottom: var(--space-xs);
}

.candidate {
  display: grid;
  gap: var(--space-sm);
  padding: var(--space-lg);
}

.candidate-meta {
  color: oklch(40% 0.03 252);
  font-size: 0.88rem;
  line-height: 1.62;
  text-wrap: pretty;
}

.candidate-meta strong {
  color: var(--ink);
  font-weight: 850;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.tag {
  border-radius: var(--radius-xs);
  background: oklch(90% 0.032 174);
  color: oklch(31% 0.065 174);
  font-size: 0.74rem;
  font-weight: 850;
  padding: var(--space-xs) var(--space-sm);
}

.metric-stack {
  position: relative;
  display: grid;
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.metric {
  border: 1px solid oklch(100% 0 0 / 0.12);
  border-radius: var(--radius-md);
  padding: var(--space-md);
  background: oklch(100% 0 0 / 0.055);
  transition: transform 190ms ease, border-color 190ms ease, background 190ms ease;
}

.metric div {
  display: flex;
  justify-content: space-between;
  gap: var(--space-md);
  color: var(--paper);
  font-size: 0.82rem;
  font-weight: 850;
}

.metric strong {
  font-family: var(--font-mono);
  font-variant-numeric: tabular-nums;
}

.bar {
  height: 7px;
  border-radius: 999px;
  background: oklch(100% 0 0 / 0.09);
  margin-top: var(--space-sm);
  overflow: hidden;
}

.bar span {
  display: block;
  height: 100%;
  width: var(--value);
  border-radius: inherit;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
}

.risk-box,
.draft-box {
  border: 1px solid oklch(100% 0 0 / 0.12);
  border-radius: var(--radius-md);
  padding: var(--space-lg);
  background: oklch(100% 0 0 / 0.055);
  margin-bottom: var(--space-lg);
}

.risk-box h3,
.draft-box h3 {
  margin-bottom: var(--space-sm);
}

.risk-box ul {
  color: var(--muted-light);
  padding-left: 1rem;
}

pre {
  white-space: pre-wrap;
  margin: var(--space-md) 0 0;
  max-height: 280px;
  overflow: auto;
  color: var(--paper);
  background: oklch(8% 0.024 252 / 0.72);
  border: 1px solid oklch(100% 0 0 / 0.1);
  border-radius: var(--radius-sm);
  padding: var(--space-md);
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.55;
}

.strategy-report {
  max-height: none;
  color: var(--ink);
  background: oklch(97% 0.01 92);
  border-color: oklch(83% 0.025 92);
  font-family: var(--font-ui);
  font-size: 0.9rem;
  line-height: 1.72;
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 1260px) {
  .workspace {
    grid-template-columns: minmax(300px, 0.9fr) minmax(480px, 1.5fr);
  }

  .advisor-panel {
    position: relative;
    top: auto;
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  .topbar,
  .workspace {
    grid-template-columns: 1fr;
  }

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

  .report-panel {
    min-height: 640px;
  }
}

@media (max-width: 680px) {
  .app-shell {
    padding: var(--space-md);
  }

  .topbar {
    margin-bottom: var(--space-lg);
  }

  .topbar-actions,
  .primary-button,
  .ghost-button {
    width: 100%;
  }

  .two-col,
  .tabs,
  .upload-zone {
    grid-template-columns: 1fr;
  }

  .upload-zone .ghost-button,
  .upload-actions {
    width: 100%;
    justify-items: stretch;
  }

  .text-button {
    text-align: center;
  }

  .report-header {
    align-items: stretch;
    flex-direction: column;
    padding: var(--space-xl) var(--space-lg) var(--space-lg);
  }

  .tabs {
    padding: 0 var(--space-lg) var(--space-lg);
  }

  .report-body {
    padding: 0 var(--space-lg) var(--space-2xl);
  }

  textarea {
    min-height: 340px;
  }
}

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