/* ============================================================
   TOKENS
   ============================================================ */
:root {
  --bg-deep: #0B0F1A;
  --bg-panel: #131A2C;
  --bg-panel-raised: #1A2340;
  --bg-input: #0F1526;

  --amber: #FFB454;
  --amber-soft: #7A5424;
  --amber-glow: rgba(255, 180, 84, 0.55);

  --teal: #4FD1C5;
  --teal-glow: rgba(79, 209, 197, 0.4);

  --rose: #FF6B6B;

  --text-primary: #EDEDF2;
  --text-muted: #8B92A8;
  --text-faint: #5A6079;

  --border: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.16);

  --font-display: 'Space Grotesk', sans-serif;
  --font-body: 'Inter', sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --radius: 14px;
  --radius-sm: 8px;

  color-scheme: dark;
}

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

/* ============================================================
   RESET / BASE
   ============================================================ */
* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg-deep);
  color: var(--text-primary);
  font-family: var(--font-body);
  min-height: 100%;
}

body {
  position: relative;
  overflow-x: hidden;
}

h1, h2 {
  font-family: var(--font-display);
  margin: 0;
}

p { margin: 0; }

button {
  font-family: var(--font-body);
  cursor: pointer;
}

input, select {
  font-family: var(--font-mono);
}

:focus-visible {
  outline: 2px solid var(--teal);
  outline-offset: 2px;
}

/* ============================================================
   AMBIENT SKYLINE BACKGROUND
   ============================================================ */
.skyline-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(255, 180, 84, 0.08), transparent 60%),
    linear-gradient(180deg, #0B0F1A 0%, #0D1220 55%, #0B0F1A 100%);
  overflow: hidden;
}

.skyline-bg::before {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 46vh;
  min-height: 260px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='900' height='300' viewBox='0 0 900 300'%3E%3Cg fill='%23141B30'%3E%3Crect x='0' y='140' width='60' height='160'/%3E%3Crect x='55' y='100' width='45' height='200'/%3E%3Crect x='95' y='170' width='50' height='130'/%3E%3Crect x='150' y='60' width='40' height='240'/%3E%3Crect x='195' y='120' width='55' height='180'/%3E%3Crect x='255' y='150' width='45' height='150'/%3E%3Crect x='305' y='40' width='38' height='260'/%3E%3Crect x='348' y='110' width='60' height='190'/%3E%3Crect x='412' y='170' width='42' height='130'/%3E%3Crect x='458' y='80' width='50' height='220'/%3E%3Crect x='512' y='150' width='55' height='150'/%3E%3Crect x='572' y='55' width='40' height='245'/%3E%3Crect x='616' y='130' width='48' height='170'/%3E%3Crect x='668' y='170' width='50' height='130'/%3E%3Crect x='722' y='95' width='42' height='205'/%3E%3Crect x='768' y='150' width='55' height='150'/%3E%3Crect x='827' y='115' width='40' height='185'/%3E%3Crect x='868' y='165' width='32' height='135'/%3E%3C/g%3E%3C/svg%3E");
  background-repeat: repeat-x;
  background-position: bottom;
  background-size: 900px 100%;
  opacity: 0.9;
}

.grain {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  opacity: 0.03;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.window-light {
  position: absolute;
  background: var(--amber);
  box-shadow: 0 0 6px 1px var(--amber-glow);
  animation: twinkle 4.5s ease-in-out infinite;
}

@keyframes twinkle {
  0%, 100% { opacity: 0.15; }
  50% { opacity: 0.9; }
}

/* ============================================================
   LAYOUT
   ============================================================ */
.page {
  position: relative;
  z-index: 2;
  max-width: 1180px;
  margin: 0 auto;
  padding: 72px 24px 48px;
}

.hero {
  max-width: 640px;
  margin-bottom: 56px;
  animation: rise 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
}

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

.eyebrow {
  font-family: var(--font-mono);
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--teal);
  margin-bottom: 18px;
}

.dot { color: var(--text-faint); }

.headline {
  font-size: clamp(34px, 5vw, 52px);
  line-height: 1.08;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.subhead {
  font-size: 16px;
  line-height: 1.6;
  color: var(--text-muted);
  max-width: 520px;
}

.grid {
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr);
  gap: 24px;
  align-items: start;
}

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

/* ============================================================
   PANELS
   ============================================================ */
.panel {
  background: linear-gradient(180deg, var(--bg-panel), var(--bg-panel) 60%, var(--bg-panel-raised));
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px;
  backdrop-filter: blur(6px);
  animation: rise 0.8s cubic-bezier(0.16, 1, 0.3, 1) both;
  animation-delay: 0.12s;
}

.result-panel { animation-delay: 0.22s; }

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
  gap: 12px;
}

.panel-head h2 {
  font-size: 19px;
  font-weight: 600;
}

.ghost-btn {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-size: 13px;
  padding: 7px 14px;
  border-radius: 999px;
  transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease;
}

.ghost-btn:hover {
  border-color: var(--teal);
  color: var(--teal);
  background: rgba(79, 209, 197, 0.06);
}

.api-status {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-faint);
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-faint);
  transition: background 0.3s ease, box-shadow 0.3s ease;
}

.api-status.online .status-dot {
  background: var(--teal);
  box-shadow: 0 0 6px 1px var(--teal-glow);
}

.api-status.offline .status-dot {
  background: var(--rose);
  box-shadow: 0 0 6px 1px rgba(255, 107, 107, 0.5);
}

/* ============================================================
   FORM
   ============================================================ */
fieldset {
  border: none;
  padding: 0;
  margin: 0 0 24px;
}

legend {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  padding: 0 0 14px;
}

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

@media (max-width: 520px) {
  .field-row { grid-template-columns: 1fr; }
}

.field {
  margin-bottom: 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

label {
  font-size: 12.5px;
  color: var(--text-muted);
  font-family: var(--font-body);
}

input[type="number"],
input[type="text"],
select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 12px;
  font-size: 14px;
  width: 100%;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input[type="number"]:hover,
input[type="text"]:hover,
select:hover {
  border-color: var(--border-strong);
}

input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
  border-color: var(--teal);
  box-shadow: 0 0 0 3px rgba(79, 209, 197, 0.12);
  outline: none;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%238B92A8'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 32px;
}

select option { background: var(--bg-panel); color: var(--text-primary); }

input[type="range"] {
  width: 100%;
  accent-color: var(--amber);
  margin-top: 4px;
}

.range-readout {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--text-faint);
  margin-top: 4px;
}

#availabilityValue { color: var(--amber); }

.predict-btn {
  position: relative;
  width: 100%;
  background: linear-gradient(135deg, var(--amber), #E8974C);
  color: #17130A;
  border: none;
  border-radius: var(--radius-sm);
  padding: 14px 20px;
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
  box-shadow: 0 8px 24px -8px rgba(255, 180, 84, 0.5);
  margin-top: 4px;
}

.predict-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 28px -6px rgba(255, 180, 84, 0.6); }
.predict-btn:active { transform: translateY(0); }

.predict-btn:disabled {
  opacity: 0.7;
  cursor: progress;
  transform: none;
}

.btn-spinner {
  width: 15px;
  height: 15px;
  border-radius: 50%;
  border: 2px solid rgba(23, 19, 10, 0.35);
  border-top-color: #17130A;
  display: none;
  animation: spin 0.7s linear infinite;
}

.predict-btn.loading .btn-spinner { display: inline-block; }
.predict-btn.loading .btn-label { opacity: 0.75; }

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

.form-error {
  color: var(--rose);
  font-size: 13px;
  margin-top: 12px;
  min-height: 16px;
  line-height: 1.5;
}

/* ============================================================
   RESULT PANEL
   ============================================================ */
.result-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 22px;
  padding: 40px 12px 20px;
  color: var(--text-faint);
  font-size: 14px;
  line-height: 1.6;
}

.empty-buildings {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  height: 90px;
}

.mini-building {
  width: 28px;
  background: var(--bg-panel-raised);
  border: 1px solid var(--border);
  border-radius: 3px 3px 0 0;
  opacity: 0.6;
}

.mini-building.small { height: 44px; }
.mini-building.medium { height: 68px; }
.mini-building.large { height: 90px; }

.result-content {
  animation: rise 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.predicted-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 28px;
}

.predicted-eyebrow {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.predicted-name {
  font-family: var(--font-display);
  font-size: 30px;
  font-weight: 600;
  color: var(--amber);
  transition: color 0.3s ease;
}

.buildings-row {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 22px;
  height: 150px;
  margin-bottom: 28px;
  padding: 0 8px;
  border-bottom: 1px solid var(--border);
}

.building {
  --h: 40%;
  position: relative;
  width: 56px;
  height: var(--h);
  background: linear-gradient(180deg, #1C2440, #141A30);
  border: 1px solid var(--border-strong);
  border-radius: 4px 4px 0 0;
  transition: height 0.9s cubic-bezier(0.16, 1, 0.3, 1);
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  grid-auto-rows: 10px;
  gap: 4px;
  padding: 6px;
  align-content: start;
}

.building .win {
  background: rgba(255, 255, 255, 0.06);
  border-radius: 1px;
  transition: background 0.4s ease, box-shadow 0.4s ease;
}

.building.lit .win {
  background: var(--amber);
  box-shadow: 0 0 5px 0 var(--amber-glow);
}

.building-caption {
  position: absolute;
  bottom: -26px;
  left: 0;
  right: 0;
  text-align: center;
  font-family: var(--font-mono);
  font-size: 10.5px;
  color: var(--text-faint);
  white-space: nowrap;
}

.building-col {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  height: 100%;
}

.prob-list {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.prob-row {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: center;
  font-size: 13.5px;
}

.prob-row .name { color: var(--text-muted); }

.prob-row .value {
  font-family: var(--font-mono);
  color: var(--text-primary);
  min-width: 52px;
  text-align: right;
}

.prob-track {
  grid-column: 1 / -1;
  height: 6px;
  border-radius: 999px;
  background: var(--bg-input);
  overflow: hidden;
}

.prob-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--teal), var(--amber));
  transition: width 1s cubic-bezier(0.16, 1, 0.3, 1);
}

.prob-row.top .name,
.prob-row.top .value { color: var(--amber); }

/* ============================================================
   FOOTER
   ============================================================ */
.page-footer {
  margin-top: 56px;
  text-align: center;
  font-size: 12px;
  color: var(--text-faint);
}
