:root {
  --bg: #f6f3ed;
  --panel: #ffffff;
  --text: #1c1f23;
  --muted: #646b73;
  --border: #d9d3ca;
  --accent: #0e6f68;
  --accent-strong: #074f4a;
  --highlight: #d34a24;
  --shadow: 0 10px 28px rgba(24, 31, 35, 0.08);
  --left-panel-width: 360px;
  --right-panel-width: 320px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button,
input {
  font: inherit;
}

.app-header {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  padding: 22px 28px 16px;
  border-bottom: 1px solid var(--border);
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: 28px;
  line-height: 1.1;
}

h2 {
  margin-bottom: 10px;
  font-size: 20px;
  line-height: 1.2;
}

.header-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  color: var(--muted);
  font-size: 14px;
  white-space: nowrap;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--left-panel-width) 8px minmax(0, 1fr) 8px var(--right-panel-width);
  min-height: calc(100vh - 82px);
}

.controls,
.details {
  background: rgba(255, 255, 255, 0.64);
  border-color: var(--border);
  border-style: solid;
}

.controls {
  padding: 18px;
  border-width: 0;
}

.details {
  padding: 20px;
  border-width: 0;
}

.resize-handle {
  position: relative;
  z-index: 3;
  cursor: col-resize;
  background: linear-gradient(90deg, transparent 0, transparent 3px, var(--border) 3px, var(--border) 5px, transparent 5px);
  touch-action: none;
}

.resize-handle::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 3px;
  height: 38px;
  border-radius: 999px;
  background: #bdb5a9;
  transform: translate(-50%, -50%);
  opacity: 0.8;
}

.resize-handle:hover::after,
.app-shell.resizing .resize-handle::after {
  background: var(--accent);
}

body.resizing-panels {
  cursor: col-resize;
  user-select: none;
}

.control-section + .control-section {
  margin-top: 24px;
}

.control-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.segmented {
  display: grid;
  grid-template-columns: 1fr 1fr;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
}

.segmented button {
  min-height: 38px;
  border: 0;
  border-right: 1px solid var(--border);
  background: transparent;
  color: var(--muted);
  cursor: pointer;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--accent);
  color: #fff;
  font-weight: 700;
}

input[type="search"] {
  width: 100%;
  min-height: 40px;
  padding: 9px 11px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  color: var(--text);
}

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

.section-row .control-label {
  margin-bottom: 0;
}

.text-button {
  border: 0;
  background: transparent;
  color: var(--accent-strong);
  cursor: pointer;
  font-size: 13px;
  font-weight: 700;
}

.button-group {
  display: flex;
  align-items: center;
  gap: 10px;
  white-space: nowrap;
}

.cluster-list {
  display: grid;
  gap: 8px;
}

.cluster-option {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 32px;
  padding: 6px 8px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  cursor: pointer;
}

.cluster-option input {
  accent-color: var(--accent);
}

.cluster-swatch {
  width: 12px;
  height: 12px;
  flex: 0 0 auto;
  border-radius: 50%;
}

.plot-region {
  position: relative;
  min-width: 0;
  background: #fffaf2;
}

#plot {
  width: 100%;
  height: calc(100vh - 82px);
  min-height: 560px;
}

.hover-card {
  position: absolute;
  z-index: 10;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 12px;
  max-width: 420px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  pointer-events: none;
  text-align: left;
}

.hover-card img {
  width: 72px;
  height: 84px;
  border-radius: 6px;
  object-fit: cover;
  background: var(--bg);
}

.hover-name {
  margin-bottom: 3px;
  color: var(--text);
  font-size: 16px;
  font-weight: 800;
  line-height: 1.2;
}

.hover-cluster {
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  line-height: 1.25;
}

.hover-citation {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.empty-state {
  color: var(--muted);
}

.empty-state p,
.profile p,
.profile dd {
  color: var(--muted);
  line-height: 1.45;
}

.profile-media {
  width: 116px;
  height: 132px;
  margin-bottom: 16px;
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.profile-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.profile dl {
  margin: 18px 0;
}

.profile dt {
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px solid var(--border);
  color: var(--text);
  font-size: 15px;
  font-weight: 800;
}

.profile dt:not(:first-child) {
  margin-top: 16px;
}

.profile dd {
  margin: 0;
}

.profile-links {
  display: grid;
  gap: 8px;
}

.profile-link {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 40px;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--panel);
  font-weight: 700;
}

.profile-link img {
  width: 22px;
  height: 22px;
  object-fit: contain;
}

@media (max-width: 1050px) {
  .app-shell {
    grid-template-columns: minmax(220px, 28%) minmax(0, 1fr);
  }

  .resize-handle {
    display: none;
  }

  .details {
    grid-column: 1 / -1;
    border-width: 1px 0 0;
  }
}

@media (max-width: 760px) {
  .app-header {
    align-items: start;
    flex-direction: column;
    padding: 18px;
  }

  .header-meta {
    flex-wrap: wrap;
    white-space: normal;
  }

  .app-shell {
    display: block;
  }

  .controls,
  .details {
    border-width: 0 0 1px;
  }

  #plot {
    height: 68vh;
    min-height: 460px;
  }
}
