:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-soft: #fafbfd;
  --ink: #0f172a;
  --ink-2: #1e293b;
  --muted: #64748b;
  --line: #e2e8f0;
  --accent: #0f62fe;
  --accent-ink: #ffffff;
  --accent-soft: #eff6ff;
  --danger: #dc2626;
  font-family: "Manrope", "Segoe UI", sans-serif;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  color: var(--ink);
  background: var(--bg);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.page-shell {
  min-height: 100vh;
  padding: 20px;
}

.layout {
  max-width: 1100px;
  margin: 0 auto;
}

/* Hero */
.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 20px;
}

.hero-copy h1 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.eyebrow {
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--accent);
  margin-bottom: 2px;
}

h2 {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--muted);
  margin: 0 0 14px 0;
}

h3 {
  font-size: 0.66rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin: 14px 0 10px;
}

/* Panels */
.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px 18px;
}

.panel-side {
  background: var(--surface-soft);
}

.grid-main {
  display: grid;
  gap: 12px;
  grid-template-columns: 1fr 290px;
}

.panel-wide {
  margin-top: 12px;
}

/* Form */
.form-grid { display: grid; gap: 10px; }

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

label, fieldset {
  display: grid;
  gap: 4px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

fieldset {
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 9px 12px;
}

legend {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  padding: 0 4px;
}

.checkbox {
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  color: var(--ink);
  font-size: 0.82rem;
}

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

input, select, textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 7px 10px;
  background: #fff;
  color: var(--ink);
  font-size: 0.86rem;
  transition: border-color 0.15s, box-shadow 0.15s;
}

input:focus, select:focus, textarea:focus {
  border-color: var(--accent);
  outline: none;
  box-shadow: 0 0 0 3px rgba(15, 98, 254, 0.08);
}

textarea { resize: vertical; }

/* Buttons */
button {
  border: 0;
  border-radius: 6px;
  padding: 8px 14px;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.01em;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  transition: opacity 0.15s, box-shadow 0.15s;
}

button:hover { opacity: 0.88; box-shadow: 0 3px 10px rgba(15, 98, 254, 0.18); }
button:disabled { opacity: 0.5; cursor: not-allowed; box-shadow: none; }

button.ghost {
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
  box-shadow: none;
  font-size: 0.78rem;
}

button.ghost:hover { border-color: var(--ink-2); color: var(--ink-2); box-shadow: none; opacity: 1; }

/* Alert */
.alert {
  border: 1px solid rgba(220, 38, 38, 0.18);
  background: rgba(220, 38, 38, 0.04);
  color: var(--danger);
  border-radius: 6px;
  padding: 7px 10px;
  font-size: 0.8rem;
}

/* Divider */
.divider { border-top: 1px solid var(--line); margin: 12px 0; }

/* Preview list */
.preview-list { display: grid; gap: 0; margin: 0; }

.preview-list div {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}

.preview-list div:last-child { border-bottom: none; }

.preview-list dt {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--muted);
  white-space: nowrap;
  flex-shrink: 0;
}

.preview-list dd {
  margin: 0;
  font-size: 0.8rem;
  color: var(--ink);
  text-align: right;
}

/* Result blocks */
.result-block {
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.result-block:first-child { padding-top: 0; }
.result-block:last-child { border-bottom: none; padding-bottom: 0; }

.result-block p {
  margin: 0 0 8px;
  font-size: 0.9rem;
  line-height: 1.72;
  color: var(--ink-2);
}

.source-line {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 5px;
}

.source-tag {
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  padding: 2px 7px;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  color: var(--accent);
  text-decoration: none;
  background: var(--accent-soft);
  transition: border-color 0.12s, background 0.12s;
}

.source-tag:hover {
  border-color: #9ebfff;
  background: #dce9ff;
  text-decoration: none;
}

/* References */
.ref-list { margin: 0; padding-left: 18px; }

.ref-list li {
  margin-bottom: 9px;
  font-size: 0.86rem;
  line-height: 1.65;
  color: var(--ink-2);
}

/* Download */
.download-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  padding: 8px;
  border: 1px solid #c8d7ff;
  border-radius: 6px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 0.8rem;
  font-weight: 700;
  text-decoration: none;
  letter-spacing: 0.02em;
  margin-top: 12px;
  transition: background 0.12s, border-color 0.12s;
}

.download-btn:hover {
  background: #dce9ff;
  border-color: #9ebfff;
  text-decoration: none;
}

/* Spinner */
.spinner {
  width: 11px;
  height: 11px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  flex-shrink: 0;
}

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

.processing-hint {
  margin: 0;
  font-size: 0.74rem;
  color: var(--muted);
  text-align: center;
  letter-spacing: 0.01em;
}

/* Muted */
.muted { color: var(--muted); font-size: 0.84rem; margin: 0; line-height: 1.55; }

/* Links */
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }

/* Auth */
.auth-wrap {
  min-height: calc(100vh - 40px);
  display: grid;
  place-items: center;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  padding: 28px 24px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.auth-card h1 {
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 0 0 4px;
}

/* Responsive */
@media (max-width: 720px) {
  .page-shell { padding: 14px; }
  .grid-main { grid-template-columns: 1fr; }
  .hero, .row { display: grid; grid-template-columns: 1fr; }
  .hero { align-items: start; }
  .auth-wrap { min-height: calc(100vh - 28px); }
}
