:root {
  color-scheme: light;
  --bg: #ffffff;
  --surface: #f9f9f9;
  --panel: #ffffff;
  --ink: #0f0f0f;
  --muted: #606060;
  --line: #e5e5e5;
  --yt-red: #ff0033;
  --teal: #065fd4;
  --amber: #cc7a00;
  --rose: #c2175b;
  --indigo: #4b5aa8;
  --green: #2ba640;
  --shadow: none;
  font-family: Roboto, Arial, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
}

button,
input {
  font: inherit;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  min-height: 64px;
  padding: 8px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 245px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 26px;
  border-radius: 7px;
  background: var(--yt-red);
  color: #fff;
  font-size: 13px;
  line-height: 1;
}

.icon-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.icon-button:hover {
  background: #f2f2f2;
}

.searchbar {
  flex: 1;
  max-width: 640px;
  display: grid;
  grid-template-columns: 44px 1fr;
  align-items: center;
  height: 40px;
  overflow: hidden;
  border: 1px solid #c6c6c6;
  border-radius: 999px;
  background: #fff;
  color: var(--muted);
}

.searchbar > span:first-child {
  display: grid;
  place-items: center;
  height: 100%;
  border-right: 1px solid var(--line);
  background: #f8f8f8;
}

.searchbar__text {
  overflow: hidden;
  padding: 0 14px;
  color: var(--ink);
  line-height: 40px;
  text-overflow: ellipsis;
  white-space: nowrap;
  user-select: none;
}

.searchbar {
  cursor: default;
}

.searchbar:focus-within {
  outline: none;
}

.topbar h1,
.overview h2,
.inspector h2,
.panel h2,
.panel h3 {
  margin: 0;
  letter-spacing: 0;
}

.topbar h1 {
  font-size: 20px;
  line-height: 1.1;
}

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

.topbar__meta span {
  border: 0;
  border-radius: 999px;
  padding: 7px 11px;
  background: #f2f2f2;
  color: #0f0f0f;
  font-size: 12px;
}

.shell {
  display: grid;
  grid-template-columns: 280px minmax(0, 1fr) 344px;
  gap: 18px;
  padding: 14px 20px 28px;
  min-height: calc(100vh - 72px);
}

.panel {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.person-panel,
.inspector {
  align-self: start;
  position: sticky;
  top: 88px;
  display: grid;
  gap: 20px;
  padding: 14px;
  max-height: calc(100vh - 104px);
  overflow: auto;
}

.person-panel section,
.inspector section {
  display: grid;
  gap: 10px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.muted,
.hint,
.meta {
  color: var(--muted);
}

.hint {
  margin: 0;
  font-size: 12px;
}

.profile-list,
.sliders,
.components,
.model-controls {
  display: grid;
  gap: 8px;
}

.profile-card,
.segmented button,
.ghost,
.tab {
  cursor: pointer;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--ink);
}

.profile-card {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  width: 100%;
  padding: 10px;
  text-align: left;
}

.profile-avatar,
.channel-avatar {
  display: grid;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  font-weight: 700;
}

.profile-avatar {
  width: 38px;
  height: 38px;
  font-size: 14px;
}

.profile-copy {
  min-width: 0;
}

.profile-card strong {
  display: block;
  margin-bottom: 4px;
}

.profile-card span {
  color: var(--muted);
  font-size: 12px;
}

.profile-card small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
}

.profile-card.is-active,
.segmented button.is-active,
.tab.is-active {
  background: #f2f2f2;
}

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

.history-item {
  display: grid;
  grid-template-columns: 86px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  border: 0;
  border-radius: 10px;
  padding: 6px;
  background: transparent;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.history-item:hover {
  background: #f2f2f2;
}

.history-item img {
  width: 86px;
  aspect-ratio: 16 / 9;
  border-radius: 6px;
  object-fit: cover;
  background: #ddd;
}

.history-item strong,
.history-item small {
  display: block;
}

.history-item strong {
  overflow: hidden;
  font-size: 12px;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.history-item small {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

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

.segmented button,
.ghost,
.tab {
  padding: 10px 12px;
  text-align: center;
}

.model-controls {
  grid-template-columns: minmax(150px, 0.8fr) minmax(280px, 1.35fr);
  align-items: start;
  gap: 18px;
  padding: 14px;
}

.model-controls section {
  display: grid;
  gap: 10px;
}

.objective-section .segmented {
  display: grid;
  grid-template-columns: 1fr;
}

.mode-section {
  grid-column: 1 / -1;
  align-content: start;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 18px;
}

.weight-section .sliders {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px 16px;
}

@media (min-width: 1500px) {
  .model-controls {
    grid-template-columns: minmax(150px, 0.85fr) minmax(300px, 1.55fr) minmax(220px, 0.9fr);
  }

  .mode-section {
    grid-column: auto;
    display: grid;
  }
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.ghost {
  padding: 6px 8px;
  color: var(--muted);
  font-size: 12px;
}

.slider-row {
  display: grid;
  gap: 6px;
}

.slider-row label {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.weight-slider {
  position: relative;
  width: 100%;
  height: 26px;
  cursor: pointer;
  touch-action: none;
}

.weight-slider::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 5px;
  border-radius: 999px;
  background: #d9d9d9;
  transform: translateY(-50%);
}

.weight-slider__fill {
  position: absolute;
  left: 0;
  top: 50%;
  height: 5px;
  border-radius: 999px;
  background: var(--yt-red);
  transform: translateY(-50%);
}

.weight-slider__thumb {
  position: absolute;
  top: 50%;
  width: 18px;
  height: 18px;
  border: 3px solid #fff;
  border-radius: 999px;
  background: var(--yt-red);
  box-shadow: 0 1px 6px rgba(0, 0, 0, 0.25);
  transform: translate(-50%, -50%);
}

.weight-slider:focus-visible .weight-slider__thumb {
  outline: 3px solid rgba(255, 0, 51, 0.22);
  outline-offset: 2px;
}

.weight-slider:active {
  cursor: grab;
}

.checkline {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 14px;
}

.workspace {
  display: grid;
  align-content: start;
  gap: 14px;
  min-width: 0;
}

.overview {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
  padding: 16px;
}

.overview h2 {
  font-size: 24px;
  line-height: 1.15;
}

.axis-strip {
  display: grid;
  gap: 8px;
}

.axis-row {
  display: grid;
  grid-template-columns: minmax(172px, max-content) 1fr 36px;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.axis-track {
  position: relative;
  height: 8px;
  border-radius: 999px;
  background: linear-gradient(90deg, #ffb1c0, #e9ece8 50%, #8cc3ff);
}

.axis-pin {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  border: 2px solid #fff;
  border-radius: 999px;
  background: var(--ink);
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.tabs {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.tab {
  min-width: max-content;
  border-radius: 8px;
  background: #f2f2f2;
  text-align: center;
}

.tab.is-active {
  background: #0f0f0f;
  color: #fff;
}

.view {
  display: none;
}

.view.is-active {
  display: block;
}

.feed-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(285px, 1fr));
  gap: 22px 16px;
}

.video-card {
  min-width: 0;
}

.video-card__button {
  width: 100%;
  height: 100%;
  padding: 0;
  overflow: hidden;
  text-align: left;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
}

.video-card__button:hover,
.video-card__button:focus-visible {
  outline: none;
}

.video-card.is-selected .video-card__button {
  outline: 3px solid rgba(255, 0, 51, 0.18);
  outline-offset: 4px;
}

.video-card.is-watched .thumb {
  filter: grayscale(0.7);
  opacity: 0.58;
}

.video-card.is-watched .video-card__body {
  opacity: 0.72;
}

.video-card.is-watched .rank {
  color: var(--muted);
}

.thumb-wrap {
  position: relative;
  aspect-ratio: 16 / 9;
  overflow: hidden;
  border-radius: 12px;
  background: #e5e5e5;
}

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

.duration {
  position: absolute;
  right: 8px;
  bottom: 8px;
  border-radius: 4px;
  padding: 3px 6px;
  background: rgba(0, 0, 0, 0.72);
  color: #fff;
  font-size: 12px;
}

.video-card__body {
  display: grid;
  gap: 8px;
  padding: 10px 0 0;
}

.video-card__main {
  display: grid;
  grid-template-columns: 38px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
}

.channel-avatar {
  width: 36px;
  height: 36px;
  font-size: 12px;
}

.video-card__text {
  min-width: 0;
}

.video-card__title-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.video-card h3 {
  margin: 0;
  overflow: hidden;
  font-size: 15px;
  line-height: 1.3;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.rank {
  color: var(--yt-red);
  font-weight: 780;
}

.meta {
  margin: 0;
  font-size: 12px;
}

.score-row {
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 10px;
}

.score {
  font-size: 16px;
}

.watched-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  border-radius: 999px;
  padding: 2px 8px;
  background: #eeeeee;
  color: #606060;
  font-size: 11px;
  font-weight: 720;
}

.mini-bars,
.components {
  display: grid;
  gap: 6px;
}

.bar-row {
  display: grid;
  grid-template-columns: 64px 1fr 38px;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 12px;
}

.bar {
  height: 5px;
  overflow: hidden;
  border-radius: 999px;
  background: #e8ece9;
}

.bar span {
  display: block;
  height: 100%;
  border-radius: inherit;
  background: var(--teal);
}

.bar-row:nth-child(2) .bar span {
  background: var(--amber);
}

.bar-row:nth-child(3) .bar span {
  background: var(--green);
}

.bar-row:nth-child(4) .bar span {
  background: var(--rose);
}

.table-panel {
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 760px;
}

th,
td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  font-size: 13px;
}

th {
  position: sticky;
  top: 0;
  background: #fbfcfa;
  color: var(--muted);
  font-weight: 720;
}

tr.is-watched {
  color: #6f6f6f;
}

tr.is-watched td {
  background: #f7f7f7;
}

td .watched-pill {
  margin-left: 8px;
  vertical-align: 1px;
}

.space-panel {
  position: relative;
  padding: 16px;
}

.drift-panel {
  padding: 16px;
}

.space-panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.space-panel canvas {
  width: 100%;
  height: min(58vh, 560px);
  min-height: 420px;
  margin-top: 8px;
  border-radius: 12px;
  background: #0f0f0f;
  cursor: grab;
  touch-action: none;
}

.space-panel canvas:active {
  cursor: grabbing;
}

.space-tooltip {
  position: absolute;
  z-index: 5;
  width: min(260px, calc(100% - 32px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 12px;
  background: rgba(20, 20, 20, 0.94);
  color: #fff;
  box-shadow: 0 12px 34px rgba(0, 0, 0, 0.28);
  pointer-events: none;
}

.space-tooltip img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #222;
}

.space-tooltip div {
  padding: 9px 10px 10px;
}

.space-tooltip strong {
  display: block;
  font-size: 13px;
  line-height: 1.25;
}

.space-tooltip span {
  display: block;
  margin-top: 4px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 12px;
}

.plot-grid {
  stroke: #d9dfdb;
  stroke-width: 1;
}

.plot-axis {
  stroke: #89948f;
  stroke-width: 1.6;
}

.plot-label {
  fill: var(--muted);
  font-size: 12px;
}

.plot-point {
  cursor: pointer;
  stroke: #fff;
  stroke-width: 2;
}

.profile-dot,
.plot-profile {
  fill: var(--ink);
}

.drift-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
  margin-top: 14px;
}

.drift-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfa;
}

.drift-card h3 {
  margin: 0 0 6px;
}

.drift-card ol {
  display: grid;
  gap: 10px;
  margin: 12px 0 0;
  padding-left: 20px;
}

.drift-card li {
  color: var(--ink);
}

.drift-card li span,
.drift-card li small {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 999px;
  background: var(--ink);
}

.note,
.conflict {
  margin: 0;
  border-left: 3px solid var(--teal);
  padding: 10px 12px;
  background: #eef6f4;
  color: #31413c;
  font-size: 14px;
  line-height: 1.45;
}

.conflict {
  border-left-color: var(--amber);
  background: #fff6e8;
}

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

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

  .model-controls {
    grid-template-columns: 1fr;
  }

  .objective-section .segmented {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}

@media (max-width: 860px) {
  .topbar,
  .shell,
  .overview {
    display: block;
  }

  .topbar {
    position: static;
    padding: 10px 12px;
  }

  .brand {
    min-width: 0;
    margin-bottom: 10px;
  }

  .topbar__meta {
    display: none;
  }

  .searchbar {
    max-width: none;
    width: 100%;
  }

  .shell {
    padding: 10px;
  }

  .person-panel,
  .workspace,
  .inspector {
    position: static;
    max-height: none;
    margin-bottom: 12px;
  }

  .person-panel {
    padding: 12px;
  }

  .profile-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(230px, 78vw);
    overflow-x: auto;
    padding-bottom: 4px;
    scroll-snap-type: x proximity;
  }

  .profile-card {
    scroll-snap-align: start;
  }

  .history-list {
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: minmax(210px, 70vw);
    overflow-x: auto;
    padding-bottom: 4px;
  }

  .history-item {
    grid-template-columns: 92px minmax(0, 1fr);
  }

  .model-controls {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .objective-section .segmented {
    display: grid;
    grid-template-columns: 1fr;
    overflow: visible;
    padding-bottom: 0;
  }

  .objective-section .segmented button {
    white-space: normal;
  }

  .weight-section .sliders {
    grid-template-columns: 1fr;
  }

  .tabs {
    overflow-x: auto;
    padding-bottom: 4px;
  }

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

  .space-panel canvas {
    height: 360px;
    min-height: 320px;
  }

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

@media (max-width: 520px) {
  .topbar h1 {
    font-size: 18px;
  }

  .brand-mark {
    width: 34px;
    height: 24px;
  }

  .searchbar {
    grid-template-columns: 38px 1fr;
  }

  .overview h2,
  .space-panel h2,
  .drift-panel h2 {
    font-size: 21px;
  }

  .axis-row {
    grid-template-columns: 1fr 34px;
  }

  .axis-row span {
    grid-column: 1 / -1;
  }

  .inspector {
    padding: 12px;
  }
}
