: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: "Segoe UI", Inter, Arial, 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: 1140px;
  margin: 0 auto;
}

/* Hero */
.hero {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: linear-gradient(180deg, #ffffff 0%, #fbfdff 100%);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.05);
  margin-bottom: 16px;
}

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

.title-with-cap {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.title-cap {
  width: 1.06rem;
  height: 1.06rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.title-cap svg {
  width: 100%;
  height: 100%;
  fill: currentColor;
}

.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: 12px;
  padding: 18px 20px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.04);
}

.panel-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.panel-header-row h2 {
  margin-bottom: 0;
}

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

.grid-main {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 300px;
}

.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: 8px;
  padding: 10px 12px;
  background: #fcfdff;
}

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;
}

.repo-fieldset {
  padding: 12px;
}

.repo-layout {
  display: grid;
  grid-template-columns: minmax(150px, 0.85fr) 1fr 1fr;
  gap: 10px 12px;
  align-items: start;
}

.repo-all-card {
  border: 1px solid #cfdfff;
  border-radius: 8px;
  background: linear-gradient(180deg, #eff6ff 0%, #f6faff 100%);
  padding: 10px;
}

.repo-list {
  grid-column: 2 / 4;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 10px;
}

.repo-checkbox {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 6px 9px;
}

.repo-checkbox-all {
  min-height: 44px;
  border-color: #b8ceff;
  background: #eef5ff;
  font-weight: 700;
}

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[type="checkbox"],
input[type="radio"] {
  width: auto;
  padding: 0;
  border: 0;
  border-radius: 0;
}

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: 9px 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;
}

.result-alert {
  margin: 10px 0 0;
  line-height: 1.45;
}

.result-alert ul {
  margin: 6px 0 0;
  padding-left: 18px;
}

.result-alert li {
  margin: 3px 0;
}

.success {
  border: 1px solid rgba(22, 101, 52, 0.18);
  background: rgba(22, 101, 52, 0.04);
  color: #166534;
  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;
}

.trace-line {
  margin: 0 0 6px;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--muted);
}

.trace-line strong {
  color: var(--ink);
}

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

.trace-url {
  font-family: "JetBrains Mono", "Consolas", monospace;
  font-size: 0.72rem;
  color: var(--accent);
}

.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;
}

.spinner-dark {
  width: 18px;
  height: 18px;
  border-color: rgba(15, 23, 42, 0.2);
  border-top-color: var(--accent);
}

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

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

.processing-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(248, 250, 252, 0.78);
  backdrop-filter: blur(3px);
}

.processing-overlay[hidden] {
  display: none;
}

.processing-box {
  width: min(360px, 100%);
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 22px 20px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  text-align: center;
  box-shadow: 0 20px 60px rgba(15, 23, 42, 0.16);
}

.processing-box strong {
  font-size: 0.95rem;
  font-weight: 700;
}

.processing-box span:last-child {
  font-size: 0.78rem;
  color: var(--muted);
  line-height: 1.45;
}

body.is-processing {
  cursor: progress;
}

/* 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-page {
  background:
    radial-gradient(circle at 8% 12%, rgba(15, 98, 254, 0.1), transparent 30%),
    radial-gradient(circle at 92% 88%, rgba(8, 145, 178, 0.09), transparent 28%),
    #f4f7fb;
}

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

.auth-shell {
  width: min(920px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(330px, 0.85fr);
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.28);
  border-radius: 20px;
  background: #fff;
  box-shadow: 0 30px 80px rgba(15, 23, 42, 0.13);
}

.auth-intro {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-height: 560px;
  padding: 54px 50px;
  overflow: hidden;
  color: #fff;
  background: linear-gradient(145deg, #0b2554 0%, #0f62fe 58%, #0891b2 100%);
}

.auth-intro::after {
  content: "";
  position: absolute;
  right: -100px;
  bottom: -130px;
  width: 320px;
  height: 320px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  box-shadow: 0 0 0 48px rgba(255, 255, 255, 0.05), 0 0 0 96px rgba(255, 255, 255, 0.03);
}

.auth-mark {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  margin-bottom: 28px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.12);
}

.auth-mark svg { width: 26px; height: 26px; fill: currentColor; }
.auth-kicker { margin: 0 0 12px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.13em; text-transform: uppercase; opacity: 0.78; }
.auth-intro h1 { max-width: 480px; margin: 0; font-size: clamp(2rem, 4vw, 3rem); line-height: 1.08; letter-spacing: -0.045em; }
.auth-intro > p:not(.auth-kicker) { max-width: 470px; margin: 20px 0 0; color: rgba(255, 255, 255, 0.82); font-size: 0.96rem; line-height: 1.7; }
.auth-benefits { display: grid; gap: 11px; margin: 28px 0 0; padding: 0; list-style: none; }
.auth-benefits li { display: flex; align-items: center; gap: 10px; font-size: 0.84rem; color: rgba(255, 255, 255, 0.9); }
.auth-benefits li::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: #67e8f9; box-shadow: 0 0 0 4px rgba(103, 232, 249, 0.16); }

.auth-card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
  padding: 48px 40px;
  background: #fff;
}

.auth-title {
  margin: 4px 0 8px;
  color: var(--ink);
  font-size: 1.65rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  text-transform: none;
}

.auth-form { margin-top: 26px; gap: 16px; }
.auth-form label { color: #334155; font-size: 0.7rem; }
.auth-form input { min-height: 46px; border-radius: 9px; padding: 10px 12px; }
.password-field { position: relative; display: block; }
.password-field input { padding-right: 74px; }
.password-toggle { position: absolute; top: 50%; right: 8px; transform: translateY(-50%); padding: 6px 7px; background: transparent; color: var(--accent); font-size: 0.72rem; box-shadow: none; }
.password-toggle:hover { opacity: 1; box-shadow: none; }
.auth-submit { min-height: 46px; margin-top: 2px; border-radius: 9px; }
.auth-alert { margin-top: 18px; }
.auth-footnote { margin: 20px 0 0; color: #94a3b8; font-size: 0.7rem; text-align: center; }

@media (max-width: 780px) {
  .auth-shell { grid-template-columns: 1fr; max-width: 460px; }
  .auth-intro { min-height: auto; padding: 34px 28px; }
  .auth-intro h1 { font-size: 2rem; }
  .auth-intro > p:not(.auth-kicker), .auth-benefits { display: none; }
  .auth-mark { margin-bottom: 20px; }
  .auth-card { padding: 36px 28px; }
}

/* 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; }
  .repo-layout { grid-template-columns: 1fr; gap: 10px; }
  .repo-list {
    grid-column: auto;
    grid-template-columns: 1fr;
  }
  .auth-wrap { min-height: calc(100vh - 28px); }
}
