:root {
  color-scheme: light;
  --bg: #f5f8fb;
  --surface: rgba(255, 255, 255, 0.88);
  --surface-strong: #ffffff;
  --ink: #17212b;
  --muted: #64717f;
  --line: #d8e2ea;
  --teal: #134e4a;
  --blue: #2563eb;
  --shadow: 0 20px 54px rgba(23, 33, 43, 0.11);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  background:
    radial-gradient(circle at 18% 16%, rgba(37, 99, 235, 0.08), transparent 30%),
    radial-gradient(circle at 84% 10%, rgba(19, 78, 74, 0.08), transparent 28%),
    var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
}

a {
  color: inherit;
  text-decoration: none;
}

.studio-header {
  display: flex;
  align-items: center;
  gap: 24px;
  min-height: 74px;
  padding: 12px clamp(18px, 4vw, 48px);
  background: rgba(255, 255, 255, 0.94);
  border-bottom: 1px solid var(--line);
  backdrop-filter: blur(16px);
}

.studio-brand img {
  display: block;
  width: 158px;
  height: auto;
}

.studio-brand-copy {
  display: grid;
  gap: 2px;
  min-width: 0;
}

.studio-brand-copy span {
  color: var(--teal);
  font-size: 0.78rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.studio-brand-copy strong {
  color: var(--ink);
  font-size: clamp(1rem, 2vw, 1.35rem);
  font-weight: 520;
  line-height: 1.15;
}

.studio-nav {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-left: auto;
  color: var(--muted);
  font-weight: 750;
}

.studio-nav a:hover,
.studio-nav a:focus-visible {
  color: var(--teal);
}

.studio-shell {
  width: min(1540px, calc(100% - 32px));
  height: calc(100vh - 74px);
  min-height: 720px;
  margin: 0 auto;
  padding: 18px 0;
}

.studio-grid {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(420px, 2fr);
  gap: 18px;
  height: 100%;
}

.routes-panel,
.candidates-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  padding: 18px;
  background: var(--surface);
  border: 1px solid rgba(216, 226, 234, 0.86);
  border-radius: 22px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

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

h1,
h2 {
  margin: 0;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 690;
  letter-spacing: 0;
}

.route-counts {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.route-count {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 13px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 720;
}

.route-count.is-selected {
  color: #ffffff;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  border-color: transparent;
}

.studio-controls {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
  min-width: 0;
}

.hub-control {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 760;
}

.hub-control span {
  line-height: 1;
}

.hub-control select {
  min-height: 34px;
  width: 210px;
  max-width: 24vw;
  padding: 0 26px 0 11px;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: 999px;
  font: inherit;
  font-weight: 760;
}

.scenario-control {
  display: inline-flex;
  gap: 5px;
  padding: 4px;
  background: rgba(229, 238, 244, 0.66);
  border: 1px solid rgba(216, 226, 234, 0.9);
  border-radius: 999px;
}

.scenario-pill {
  min-height: 28px;
  padding: 0 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 760;
  transition: background 160ms ease, color 160ms ease, box-shadow 160ms ease;
}

.scenario-pill.is-selected {
  color: var(--teal);
  background: #ffffff;
  box-shadow: 0 6px 16px rgba(23, 33, 43, 0.1);
}

.generate-button {
  min-height: 34px;
  padding: 0 14px;
  color: #ffffff;
  background: linear-gradient(135deg, var(--teal), var(--blue));
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 760;
  box-shadow: 0 10px 22px rgba(37, 99, 235, 0.18);
  transition: opacity 160ms ease, transform 160ms ease;
}

.generate-button:hover,
.generate-button:focus-visible {
  transform: translateY(-1px);
}

.generate-button:disabled {
  cursor: default;
  opacity: 0.58;
  transform: none;
}

.map-stage {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid rgba(203, 216, 226, 0.8);
  border-radius: 18px;
}

.route-plot {
  width: 100%;
  height: 100%;
  display: block;
}

.selected-routes {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 40px;
  margin-top: 12px;
}

.selected-routes > span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 780;
}

.candidates-panel {
  position: relative;
}

.candidate-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 12px;
  flex: 1;
  min-height: 0;
  transition: opacity 180ms ease, transform 180ms ease;
}

.candidate-grid.is-refreshing {
  opacity: 0.56;
  transform: scale(0.992);
}

.candidate-card {
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  min-width: 0;
  min-height: 0;
  padding: 12px;
  background: var(--surface-strong);
  border: 1px solid rgba(216, 226, 234, 0.9);
  border-radius: 16px;
  box-shadow: 0 12px 28px rgba(23, 33, 43, 0.08);
  transition: transform 170ms ease, box-shadow 170ms ease, border-color 170ms ease;
}

.candidate-card:hover {
  transform: translateY(-2px);
  border-color: rgba(37, 99, 235, 0.28);
  box-shadow: 0 18px 34px rgba(23, 33, 43, 0.12);
}

.candidate-thumb {
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 62% 28%, rgba(37, 99, 235, 0.14), transparent 34%),
    linear-gradient(135deg, rgba(19, 78, 74, 0.08), rgba(255, 255, 255, 0.7));
  border-radius: 12px;
}

.candidate-thumb svg {
  width: 92%;
  height: 86%;
}

.candidate-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wing-shadow {
  fill: rgba(37, 99, 235, 0.11);
  transform: translate(7px, 8px);
}

.wing-body {
  fill: #2563eb;
  opacity: 0.92;
}

.wing-line {
  fill: none;
  stroke: rgba(255, 255, 255, 0.62);
  stroke-width: 2.4;
  stroke-linecap: round;
}

.candidate-card span {
  display: block;
  min-height: 2.45em;
  color: var(--ink);
  font-size: clamp(0.78rem, 1vw, 0.95rem);
  font-weight: 690;
  line-height: 1.2;
}

.candidate-card small {
  width: fit-content;
  padding: 3px 7px;
  color: var(--teal);
  background: rgba(19, 78, 74, 0.08);
  border-radius: 999px;
  font-size: 0.68rem;
  font-weight: 760;
}

@media (max-width: 1100px) {
  .studio-shell {
    height: auto;
    min-height: 0;
  }

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

  .map-stage {
    min-height: 520px;
  }

  .candidate-grid {
    grid-template-rows: none;
  }
}

@media (max-width: 680px) {
  .studio-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .studio-nav {
    margin-left: 0;
  }

  .studio-shell {
    width: min(100% - 20px, 1540px);
    padding: 10px 0;
  }

  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .studio-controls,
  .selected-routes {
    align-items: flex-start;
    flex-direction: column;
  }

  .map-stage {
    min-height: 430px;
  }

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