:root {
  color-scheme: dark;
  --bg: #0c0e11;
  --panel: #15191f;
  --panel-2: #1c222b;
  --ink: #eef2f6;
  --muted: #97a4b3;
  --line: #2a323e;
  --cyan: #64d9ef;
  --green: #7dd36f;
  --amber: #f2bf5e;
  --rose: #e377a6;
  --violet: #9f8cff;
  --shadow: rgba(0, 0, 0, 0.24);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  min-width: 320px;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(180deg, rgba(100, 217, 239, 0.07), transparent 300px),
    var(--bg);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  width: min(1800px, 100%);
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 12px 4px 16px;
}

.topbar h1,
.floor-header h2,
.inspector-title h2 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: clamp(1.8rem, 4vw, 3.1rem);
  line-height: 1;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--cyan);
  font-size: 0.76rem;
  font-weight: 760;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: min(560px, 55vw);
}

.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 180px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 25, 31, 0.88);
  box-shadow: 0 12px 30px var(--shadow);
}

.search-box span {
  color: var(--amber);
  font-size: 1.25rem;
}

.search-box input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: 0;
  color: var(--ink);
  background: transparent;
}

.search-box input::placeholder {
  color: #738092;
}

.icon-button,
.text-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 10px 28px var(--shadow);
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  font-size: 1.15rem;
}

.text-button {
  min-height: 38px;
  padding: 8px 12px;
  font-weight: 720;
}

.text-button.strong {
  border-color: rgba(125, 211, 111, 0.62);
  background: #1f3329;
}

.icon-button:hover,
.text-button:hover,
.chip:hover {
  border-color: var(--cyan);
}

.stats-strip {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.stats-strip div {
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 25, 31, 0.74);
}

.stats-strip span {
  display: block;
  font-size: 1.45rem;
  font-weight: 820;
}

.stats-strip small {
  color: var(--muted);
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr) 390px;
  gap: 14px;
  align-items: start;
}

.sidebar,
.inspector,
.museum-floor {
  min-width: 0;
}

.panel,
.inspector,
.museum-floor {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(21, 25, 31, 0.86);
  box-shadow: 0 12px 32px var(--shadow);
}

.panel {
  padding: 14px;
  margin-bottom: 12px;
}

.panel h2,
.floor-header h2 {
  margin: 0 0 10px;
  font-size: 0.98rem;
}

.chip-list,
.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  min-height: 32px;
  padding: 7px 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel-2);
}

.chip.active {
  color: var(--ink);
  border-color: var(--green);
  background: rgba(125, 211, 111, 0.16);
}

select {
  width: 100%;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel-2);
}

.lineage-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.85rem;
}

.lineage-item {
  padding: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10141a;
}

.museum-floor {
  padding: 14px;
}

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

.result-count {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 0.85rem;
}

.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(210px, 1fr));
  gap: 12px;
}

.specimen-card {
  position: relative;
  display: grid;
  grid-template-rows: auto 1fr;
  min-height: 314px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10141a;
}

.specimen-card.selected {
  border-color: var(--cyan);
  box-shadow: 0 0 0 1px rgba(100, 217, 239, 0.42);
}

.specimen-card img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  background: #07090c;
  border-bottom: 1px solid var(--line);
}

.card-body {
  display: grid;
  gap: 8px;
  padding: 10px;
}

.card-kicker {
  color: var(--muted);
  font-size: 0.76rem;
}

.card-title {
  margin: 0;
  font-size: 1rem;
  line-height: 1.22;
}

.score-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.score-row span {
  padding: 6px;
  border-radius: 8px;
  color: var(--muted);
  background: var(--panel);
  font-size: 0.74rem;
}

.card-actions {
  display: flex;
  gap: 8px;
  margin-top: auto;
}

.card-actions button {
  flex: 1;
  min-width: 0;
}

.favorite-dot {
  position: absolute;
  top: 9px;
  right: 9px;
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 8px;
  color: var(--amber);
  background: rgba(12, 14, 17, 0.72);
}

.favorite-dot.active,
#favoriteSelectedButton.active {
  color: #0c0e11;
  background: var(--amber);
}

.inspector {
  position: sticky;
  top: 14px;
  padding: 14px;
  max-height: calc(100vh - 28px);
  overflow: auto;
}

.empty-state {
  display: grid;
  gap: 8px;
  min-height: 260px;
  place-content: center;
  text-align: center;
  color: var(--muted);
}

.empty-state strong {
  color: var(--ink);
  font-size: 1.2rem;
}

.inspector-content {
  display: grid;
  gap: 14px;
}

.inspector-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

#lifeCanvas {
  width: 100%;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #07090c;
}

.control-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.control-grid label {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 6px 10px;
  color: var(--muted);
  font-size: 0.78rem;
}

input[type="range"] {
  grid-column: 1 / -1;
  width: 100%;
  accent-color: var(--green);
}

output {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.inspector-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.facts {
  display: grid;
  gap: 8px;
  margin: 0;
}

.facts div {
  padding: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10141a;
}

.facts dt {
  color: var(--cyan);
  font-size: 0.74rem;
  font-weight: 760;
}

.facts dd {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.38;
}

.tag-row span {
  padding: 5px 8px;
  border-radius: 8px;
  color: #0c0e11;
  background: var(--green);
  font-size: 0.74rem;
  font-weight: 780;
}

.life-note {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 230px minmax(0, 1fr);
  }

  .inspector {
    position: static;
    grid-column: 1 / -1;
    max-height: none;
  }
}

@media (max-width: 760px) {
  .app-shell {
    padding: 10px;
  }

  .topbar,
  .floor-header {
    align-items: stretch;
    flex-direction: column;
  }

  .topbar-actions {
    min-width: 0;
    width: 100%;
  }

  .stats-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

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

  .sidebar {
    order: 2;
  }

  .museum-floor {
    order: 1;
  }

  .inspector {
    order: 3;
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  }
}
