:root {
  --ink: #102028;
  --ink-soft: #3a4f5a;
  --mute: #6b7f89;
  --paper: #eef4f2;
  --paper-2: #e2ebe8;
  --line: rgba(16, 32, 40, 0.12);
  --teal: #0f766e;
  --teal-deep: #0a5550;
  --sand: #d4a574;
  --danger: #b42318;
  --ok: #1b7a4a;
  --radius: 18px;
  --shadow: 0 24px 60px rgba(16, 32, 40, 0.12);
  --font-display: "Syne", system-ui, sans-serif;
  --font-body: "Figtree", system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: var(--font-body);
  color: var(--ink);
  background: var(--paper);
  overflow-x: hidden;
}

.atmosphere {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(1200px 700px at 12% -10%, rgba(15, 118, 110, 0.22), transparent 55%),
    radial-gradient(900px 600px at 95% 10%, rgba(212, 165, 116, 0.28), transparent 50%),
    linear-gradient(160deg, #f5f8f6 0%, #e8f0ed 42%, #dde8e4 100%);
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(40px);
  opacity: 0.55;
  animation: drift 18s ease-in-out infinite alternate;
}

.orb-a {
  width: 420px;
  height: 420px;
  left: -80px;
  top: 30%;
  background: rgba(15, 118, 110, 0.35);
}

.orb-b {
  width: 360px;
  height: 360px;
  right: -60px;
  bottom: 8%;
  background: rgba(212, 165, 116, 0.4);
  animation-duration: 22s;
  animation-delay: -4s;
}

.grid-wash {
  position: absolute;
  inset: 0;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(16, 32, 40, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(16, 32, 40, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 75%);
}

@keyframes drift {
  from { transform: translate3d(0, 0, 0) scale(1); }
  to { transform: translate3d(40px, -28px, 0) scale(1.08); }
}

.shell {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  max-width: 720px;
  margin: 0 auto;
  padding: 1.25rem 1.25rem 2rem;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: 2.5rem;
  margin-bottom: 0.5rem;
}

.brand-mark {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  background: linear-gradient(135deg, var(--teal), var(--sand));
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
}

.session-chip {
  margin-left: auto;
  font-size: 0.8rem;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 0.35rem 0.8rem;
  backdrop-filter: blur(8px);
  max-width: min(420px, 70vw);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.session-chip .dot {
  margin: 0 0.25rem;
  opacity: 0.5;
}

.ghost-btn {
  font: inherit;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--ink-soft);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0.4rem 0.5rem;
}

.ghost-btn:hover {
  color: var(--teal-deep);
}

.stage {
  flex: 1;
  display: flex;
  align-items: center;
}

.panel {
  width: 100%;
  animation: rise 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.panel[hidden] {
  display: none !important;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(18px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(3.2rem, 12vw, 5.5rem);
  line-height: 0.9;
  letter-spacing: -0.04em;
  margin: 0 0 1rem;
  background: linear-gradient(120deg, var(--ink) 20%, var(--teal) 90%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.headline {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.6rem, 4.5vw, 2.15rem);
  line-height: 1.15;
  letter-spacing: -0.03em;
  margin: 0 0 0.75rem;
  color: var(--ink);
}

.lede,
.panel-sub {
  margin: 0 0 1.75rem;
  color: var(--ink-soft);
  font-size: 1.05rem;
  line-height: 1.55;
  max-width: 34rem;
}

.eyebrow {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--teal);
  margin: 0 0 0.6rem;
}

.panel-title {
  font-family: var(--font-display);
  font-size: clamp(1.7rem, 4vw, 2.2rem);
  letter-spacing: -0.03em;
  margin: 0 0 0.5rem;
}

.back-link {
  display: inline-block;
  font: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--mute);
  background: none;
  border: none;
  padding: 0;
  margin: 0 0 1.25rem;
  cursor: pointer;
}

.back-link:hover {
  color: var(--teal-deep);
}

.connect-form {
  display: grid;
  gap: 0.85rem;
  max-width: 420px;
}

.field {
  display: grid;
  gap: 0.35rem;
}

.field span {
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--mute);
}

.field input,
.search-row input {
  font: inherit;
  font-size: 1rem;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
}

.field input:focus,
.search-row input:focus {
  border-color: rgba(15, 118, 110, 0.55);
  box-shadow: 0 0 0 4px rgba(15, 118, 110, 0.12);
  background: #fff;
}

.primary-btn,
.secondary-btn {
  font: inherit;
  font-weight: 700;
  border: none;
  cursor: pointer;
  border-radius: 999px;
  padding: 0.95rem 1.4rem;
  transition: transform 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.primary-btn {
  margin-top: 0.5rem;
  color: #fff;
  background: linear-gradient(135deg, var(--teal) 0%, var(--teal-deep) 100%);
  box-shadow: 0 12px 28px rgba(15, 118, 110, 0.28);
}

.primary-btn:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 16px 32px rgba(15, 118, 110, 0.34);
}

.primary-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  box-shadow: none;
}

.primary-btn.loading .btn-label {
  opacity: 0.65;
}

.btn-spinner {
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.secondary-btn {
  color: var(--teal-deep);
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
}

.secondary-btn:hover {
  background: #fff;
  transform: translateY(-1px);
}

.form-error {
  margin: 0;
  color: var(--danger);
  font-size: 0.92rem;
  font-weight: 500;
}

.search-row {
  display: flex;
  gap: 0.65rem;
  align-items: center;
  margin-bottom: 0.85rem;
}

.search-row input {
  flex: 1;
}

.count-pill {
  min-width: 2.4rem;
  height: 2.4rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--teal-deep);
  background: rgba(15, 118, 110, 0.12);
}

.pick-list {
  display: grid;
  gap: 0.45rem;
  max-height: min(42vh, 360px);
  overflow: auto;
  padding: 0.15rem;
  margin-bottom: 1rem;
  scrollbar-width: thin;
}

.pick-item {
  text-align: left;
  font: inherit;
  font-weight: 600;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid transparent;
  border-radius: 14px;
  padding: 0.9rem 1rem;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
}

.pick-item:hover {
  background: rgba(255, 255, 255, 0.9);
  transform: translateX(3px);
}

.pick-item.selected {
  border-color: rgba(15, 118, 110, 0.45);
  background: rgba(15, 118, 110, 0.1);
  box-shadow: inset 3px 0 0 var(--teal);
}

.year-list .pick-item {
  font-family: var(--font-display);
  font-size: 1.15rem;
  letter-spacing: -0.02em;
}

.progress-block {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.5rem 0 0.5rem;
}

.pulse-ring {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 3px solid rgba(15, 118, 110, 0.2);
  border-top-color: var(--teal);
  animation: spin 1s linear infinite;
}

.progress-msg {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--ink-soft);
}

.summary {
  animation: rise 0.45s ease both;
}

.summary-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.9rem 1.2rem;
  margin: 0 0 1.25rem;
  padding: 1.1rem 0;
  border-top: 1px solid var(--line);
  border-bottom: 1px solid var(--line);
}

.summary-grid .wide {
  grid-column: 1 / -1;
}

.summary-grid dt {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mute);
  margin-bottom: 0.2rem;
}

.summary-grid dd {
  margin: 0;
  font-weight: 600;
  word-break: break-word;
}

.summary-grid dd.ok {
  color: var(--ok);
}

.summary-grid dd.bad {
  color: var(--danger);
}

.download-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1rem;
}

.output-tail {
  max-height: 180px;
  overflow: auto;
  font-size: 0.75rem;
  line-height: 1.4;
  background: rgba(16, 32, 40, 0.06);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  margin: 0 0 1rem;
  white-space: pre-wrap;
  word-break: break-word;
  color: var(--ink-soft);
}

.foot {
  margin-top: 2rem;
  padding-top: 1rem;
  border-top: 1px solid var(--line);
  font-size: 0.8rem;
  color: var(--mute);
}

@media (max-width: 560px) {
  .shell {
    padding: 1rem 1rem 1.5rem;
  }

  .session-chip {
    display: none;
  }

  .ghost-btn {
    margin-left: auto;
  }

  .summary-grid {
    grid-template-columns: 1fr;
  }

  .connect-form {
    max-width: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .orb,
  .panel,
  .pulse-ring,
  .btn-spinner,
  .summary {
    animation: none !important;
  }
}
