:root {
  color-scheme: dark;
  --bg: #080b12;
  --surface: #101724;
  --surface-2: #151f2e;
  --surface-3: #1c293b;
  --text: #eef4ff;
  --muted: #91a0b8;
  --line: rgba(255, 255, 255, 0.12);
  --brand: #38bdf8;
  --brand-strong: #0ea5e9;
  --ok: #22c55e;
  --warn: #f59e0b;
  --danger: #ef4444;
  --radius: 8px;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 0%, rgba(56, 189, 248, 0.15), transparent 28rem),
    var(--bg);
  color: var(--text);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-3);
  color: var(--text);
  min-height: 44px;
  padding: 0 16px;
  cursor: pointer;
  transition:
    transform 150ms ease,
    border-color 150ms ease,
    background 150ms ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: #24344b;
}

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

button.accent {
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #04111d;
  font-weight: 800;
}

button.secondary {
  border: 1px solid var(--line);
}

.app-shell {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.app-header {
  display: grid;
  gap: 16px;
  align-items: end;
  padding: 18px 0;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--brand);
  font-size: 0.76rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 8vw, 3.5rem);
  line-height: 1;
}

h2 {
  margin-bottom: 0;
  font-size: 1.1rem;
}

.lead {
  margin-bottom: 0;
  max-width: 760px;
  color: var(--muted);
}

.status-pill,
.mini-note {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.05);
  color: var(--muted);
  font-size: 0.85rem;
}

.warning-banner {
  margin: 0 0 18px;
  border: 1px solid rgba(245, 158, 11, 0.35);
  border-radius: var(--radius);
  background: rgba(245, 158, 11, 0.12);
  color: #fde68a;
  padding: 12px 14px;
  font-weight: 700;
}

.workspace-grid {
  display: grid;
  gap: 18px;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 23, 36, 0.9);
  padding: 16px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.28);
}

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

.pdf-drop-zone {
  display: grid;
  gap: 10px;
  place-items: center;
  min-height: 220px;
  border: 1px dashed rgba(56, 189, 248, 0.45);
  border-radius: var(--radius);
  background: #0b1220;
  padding: 18px;
  text-align: center;
  cursor: pointer;
}

.pdf-drop-zone input {
  max-width: 280px;
  min-height: auto;
  border: 0;
  background: transparent;
  padding: 0;
  color: var(--muted);
}

.pdf-drop-zone span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  border-radius: var(--radius);
  background: linear-gradient(135deg, var(--brand), var(--brand-strong));
  color: #04111d;
  padding: 0 18px;
  font-weight: 900;
}

.pdf-drop-zone strong {
  overflow-wrap: anywhere;
}

.pdf-drop-zone small,
.serial-hint {
  color: var(--muted);
}

.page-strip {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 14px;
}

.page-strip article {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b1220;
  padding: 10px;
}

.page-strip span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.page-strip canvas {
  width: 100%;
  min-height: 120px;
  border-radius: 6px;
  background: #020617;
}

.button-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.button-row button {
  flex: 1 1 150px;
}

.tips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.tips-grid span {
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 10px;
  color: var(--muted);
  font-size: 0.82rem;
}

.error-text {
  min-height: 1.3em;
  margin: 12px 0 0;
  color: #fecaca;
  font-weight: 700;
}

.preview-frame {
  display: grid;
  place-items: center;
  min-height: 220px;
  margin: 0;
  overflow: hidden;
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  background: #0b1220;
}

.preview-frame img {
  display: none;
  width: 100%;
  max-height: 300px;
  object-fit: contain;
}

.preview-frame.has-image img {
  display: block;
}

.preview-frame.has-image figcaption {
  display: none;
}

figcaption,
.helper-note {
  color: var(--muted);
  text-align: center;
}

.quality-card {
  margin: 14px 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 12px;
}

.quality-label {
  display: inline-flex;
  margin-bottom: 6px;
  font-weight: 900;
}

.quality-card.good .quality-label {
  color: var(--ok);
}

.quality-card.warning .quality-label {
  color: var(--warn);
}

.quality-card.danger .quality-label {
  color: var(--danger);
}

.quality-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.input-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-weight: 800;
}

.serial-hint {
  margin: 8px 0 0;
  font-size: 0.86rem;
}

input,
select {
  width: 100%;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: #0b1220;
  color: var(--text);
  padding: 0 14px;
}

select {
  cursor: pointer;
}

input:focus,
select:focus {
  border-color: var(--brand);
  outline: 2px solid rgba(56, 189, 248, 0.2);
}

.gemini-settings {
  display: grid;
  gap: 12px;
  align-items: end;
  margin: 0 0 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: rgba(16, 23, 36, 0.9);
  padding: 14px;
}

.gemini-settings strong {
  display: block;
  margin-bottom: 4px;
}

.gemini-settings p {
  margin-bottom: 0;
  color: var(--muted);
}

.settings-field {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-weight: 800;
}

.access-gate {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(3, 7, 18, 0.82);
}

.access-panel {
  width: min(460px, 100%);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
  padding: 18px;
  box-shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
}

.access-panel h2 {
  margin-bottom: 8px;
}

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

.access-actions {
  margin-top: 14px;
}

.access-actions button {
  width: 100%;
}

.app-locked .app-shell {
  pointer-events: none;
  user-select: none;
  filter: blur(1px);
}

.loading-state {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 14px;
  color: var(--muted);
}

.spinner {
  width: 18px;
  height: 18px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--brand);
  border-radius: 50%;
  animation: spin 800ms linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.result-grid {
  display: grid;
  gap: 12px;
}

.result-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface-2);
  padding: 14px;
}

.result-card span {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 800;
}

.result-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.2rem;
}

.result-card p {
  margin-bottom: 0;
  color: var(--muted);
}

.score-track {
  overflow: hidden;
  height: 9px;
  border-radius: 999px;
  background: #263349;
}

.score-track div {
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--warn), var(--brand), var(--ok));
  transition: width 280ms ease;
}

.reasons-card {
  margin-top: 12px;
}

.reasons-card ul {
  margin: 0;
  padding-left: 20px;
  color: var(--muted);
}

.risk-high {
  color: var(--danger);
}

.risk-medium {
  color: var(--warn);
}

.risk-low {
  color: var(--ok);
}

@media (min-width: 760px) {
  .app-header {
    grid-template-columns: minmax(0, 1fr) auto;
  }

  .workspace-grid {
    grid-template-columns: minmax(0, 1.35fr) minmax(320px, 0.65fr);
  }

  .gemini-settings {
    grid-template-columns: minmax(0, 1fr) minmax(220px, 320px) auto;
  }

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