:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-glass: rgba(30, 41, 59, 0.68);
  --bg-glass-strong: rgba(15, 23, 42, 0.78);
  --border-glass: rgba(255, 255, 255, 0.1);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-faint: #64748b;
  --accent: #38bdf8;
  --accent-deep: #2563eb;
  --gold: #fbbf24;
  --pink: #f472b6;
  --purple: #a78bfa;
  --green: #4ade80;
  --red: #ef4444;
  --outlier: #f43f5e;
  --shadow: rgba(0, 0, 0, 0.34);
  --font-display: "Outfit", sans-serif;
  --font-body: "Inter", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--bg-primary);
  background-image:
    linear-gradient(135deg, rgba(56, 189, 248, 0.08), transparent 34%),
    linear-gradient(315deg, rgba(192, 132, 252, 0.08), transparent 38%);
  background-attachment: fixed;
  color: var(--text-primary);
  font-family: var(--font-body);
  line-height: 1.5;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  border: 1px solid var(--border-glass);
  background: rgba(15, 23, 42, 0.72);
  color: var(--text-primary);
}

button {
  cursor: pointer;
}

.app-shell {
  display: flex;
  flex-direction: column;
  width: min(1720px, 100%);
  height: 100vh;
  height: 100dvh;
  margin: 0 auto;
  padding: 18px;
}

.app-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 14px;
}

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

h1,
h2,
h3 {
  font-family: var(--font-display);
  letter-spacing: 0;
}

h1 {
  margin: 0;
  font-size: 2.6rem;
  font-weight: 800;
  line-height: 1;
  background: linear-gradient(135deg, #38bdf8, #818cf8, #c084fc);
  background-clip: text;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

h2 {
  margin: 0;
  font-size: 1.08rem;
  font-weight: 700;
}

h3 {
  margin: 0;
  font-size: 0.9rem;
}

.summary-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 0.86rem;
}

.summary-strip span {
  display: inline-flex;
  align-items: center;
  min-height: 26px;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.56);
  padding: 4px 8px;
}

.controls-panel {
  display: grid;
  grid-template-columns: minmax(150px, 190px) max-content minmax(220px, 1fr) minmax(140px, 180px) max-content max-content;
  gap: 10px;
  align-items: end;
  padding: 12px;
  margin-bottom: 14px;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  box-shadow: 0 18px 38px -18px var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field > span {
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

select,
input[type="search"] {
  width: 100%;
  height: 38px;
  border-radius: 8px;
  padding: 0 10px;
  outline: none;
}

select:focus,
input[type="search"]:focus {
  border-color: rgba(56, 189, 248, 0.8);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.22);
}

.segmented,
.toggles {
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 38px;
}

.segmented button,
.toggles label {
  border-radius: 8px;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.segmented button {
  min-width: 64px;
  height: 38px;
  padding: 0 10px;
}

.segmented button.active,
.toggles label:has(input:checked) {
  border-color: rgba(56, 189, 248, 0.55);
  background: rgba(56, 189, 248, 0.2);
  color: #ffffff;
}

.toggles label {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 38px;
  border: 1px solid var(--border-glass);
  background: rgba(15, 23, 42, 0.55);
  color: var(--text-secondary);
  padding: 0 10px;
  user-select: none;
}

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

.main-layout {
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: minmax(780px, 1fr) minmax(520px, 640px);
  grid-auto-rows: minmax(0, 1fr);
  gap: 14px;
  align-items: stretch;
  min-height: 0;
}

.table-panel,
.detail-panel {
  min-height: 0;
  background: var(--bg-glass);
  border: 1px solid var(--border-glass);
  border-radius: 14px;
  box-shadow: 0 18px 38px -18px var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.table-panel {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

.table-head {
  flex: 0 0 auto;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 14px;
  border-bottom: 1px solid var(--border-glass);
}

.table-wrap {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  overflow: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
  font-size: 0.8rem;
}

.col-mean {
  width: 68px;
}

.col-skill {
  width: 255px;
}

.col-efficiency {
  width: 70px;
}

.col-stat {
  width: 58px;
}

.col-rate {
  width: 58px;
}

thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(15, 23, 42, 0.96);
}

th,
td {
  padding: 8px 7px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

th {
  color: var(--text-secondary);
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

th:nth-child(2),
td:nth-child(2) {
  text-align: left;
}

th:first-child,
td:first-child {
  padding-left: 12px;
  text-align: left;
}

th:last-child,
td:last-child {
  padding-right: 16px;
}

tbody tr {
  cursor: pointer;
}

tbody tr:hover,
tbody tr.active {
  background: rgba(56, 189, 248, 0.12);
}

.skill-cell {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.skill-icon {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.skill-name {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.skill-title-line {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.skill-title-line strong {
  font-weight: 800;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rarity-name-1 {
  color: #dbeafe;
}

.rarity-name-2 {
  color: var(--gold);
}

.rarity-name-other {
  color: var(--pink);
}

.rarity-name-inherited {
  color: #ffffff;
}

.mean-cell {
  color: var(--mean-text, #ecfdf5);
  font-family: var(--font-display);
  font-size: 1.08rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.mean-cell strong {
  display: inline-block;
  text-align: left;
  text-shadow: 0 0 12px color-mix(in srgb, var(--mean-text, #ecfdf5) 22%, transparent);
}

.efficiency-cell {
  color: var(--text-primary);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.detail-panel {
  align-self: start;
  padding: 14px;
}

.detail-header,
.section-title {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

.detail-header {
  justify-content: flex-start;
}

.detail-icon {
  width: 54px;
  height: 54px;
  flex: 0 0 54px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.detail-title {
  min-width: 0;
}

.detail-title h2 {
  overflow-wrap: anywhere;
}

.detail-meta {
  margin-top: 3px;
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.25;
  overflow-wrap: anywhere;
}

.distribution-card,
.track-visualizer {
  margin-top: 14px;
}

.distribution-card {
  padding: 12px;
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.42);
}

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

.distribution-head span,
.distribution-note {
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 800;
  text-transform: uppercase;
}

.histogram-scale-control {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  gap: 7px;
}

.scale-segmented {
  display: inline-flex;
  gap: 2px;
  height: 28px;
  padding: 2px;
  border: 1px solid var(--border-glass);
  border-radius: 8px;
  background: rgba(15, 23, 42, 0.62);
}

.scale-segmented button {
  height: 22px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 800;
  padding: 0 8px;
  transition: background 0.15s ease, color 0.15s ease;
}

.scale-segmented button.active {
  background: rgba(56, 189, 248, 0.22);
  color: #ffffff;
}

.boxplot {
  position: relative;
  height: 34px;
  margin: 6px 7px 4px;
}

.boxplot-line {
  position: absolute;
  left: 0;
  right: 0;
  top: 16px;
  height: 2px;
  background: rgba(148, 163, 184, 0.55);
}

.boxplot-iqr {
  position: absolute;
  top: 8px;
  height: 18px;
  border: 1px solid rgba(56, 189, 248, 0.65);
  border-radius: 6px;
  background: rgba(56, 189, 248, 0.18);
}

.boxplot-marker {
  position: absolute;
  top: 11px;
  width: 2px;
  height: 12px;
  background: var(--text-secondary);
  transform: translateX(-1px);
}

.boxplot-q2 {
  top: 5px;
  width: 1px;
  height: 24px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(248, 250, 252, 0.95) 0 4px,
    transparent 4px 7px
  );
  transform: translateX(-0.5px);
}

.boxplot-mean {
  top: 5px;
  width: 1px;
  height: 24px;
  background: repeating-linear-gradient(
    to bottom,
    rgba(251, 191, 36, 0.95) 0 4px,
    transparent 4px 7px
  );
  transform: translateX(-0.5px);
}

.boxplot-scale {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  color: var(--text-secondary);
  font-size: 0.68rem;
}

.boxplot-scale span {
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.boxplot-empty,
.histogram-empty,
.track-empty {
  padding: 18px;
  color: var(--text-secondary);
  text-align: center;
}

.histogram-plot {
  position: relative;
  height: 96px;
  margin-top: 12px;
  padding: 8px;
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 10px;
  background: rgba(2, 6, 23, 0.34);
  overflow: hidden;
}

.histogram-bars {
  display: flex;
  align-items: flex-end;
  gap: 1px;
  height: 100%;
}

.histogram-bars span {
  flex: 1 1 2px;
  min-width: 0;
  border-radius: 2px 2px 0 0;
  background: #38bdf8;
  opacity: 0.78;
}

.histogram-bars .histogram-clipped-low {
  box-shadow: inset 3px 0 0 var(--outlier);
}

.histogram-bars .histogram-clipped-high {
  box-shadow: inset -3px 0 0 var(--outlier);
}

.histogram-bars .histogram-y-clipped {
  border-top: 2px solid var(--outlier);
}

.histogram-marker {
  position: absolute;
  top: 7px;
  bottom: 7px;
  z-index: 2;
  width: 1px;
  transform: translateX(-0.5px);
  pointer-events: none;
}

.histogram-zero-marker {
  position: absolute;
  top: 6px;
  bottom: 6px;
  z-index: 1;
  width: 1px;
  border-left: 1px solid rgba(148, 163, 184, 0.7);
  transform: translateX(-0.5px);
  pointer-events: none;
}

.histogram-zero-marker::after {
  content: "0";
  position: absolute;
  top: -2px;
  left: 4px;
  color: var(--text-secondary);
  font-size: 0.62rem;
  font-weight: 800;
}

.histogram-marker-median {
  background: repeating-linear-gradient(
    to bottom,
    rgba(248, 250, 252, 0.95) 0 4px,
    transparent 4px 7px
  );
}

.histogram-marker-mean {
  background: repeating-linear-gradient(
    to bottom,
    rgba(251, 191, 36, 0.95) 0 4px,
    transparent 4px 7px
  );
}

.histogram-axis {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 4px;
  color: var(--text-faint);
  font-size: 0.68rem;
}

.histogram-axis span:nth-child(2) {
  color: var(--text-secondary);
}

.activation-panel {
  margin-top: 0;
}

.track-visualizer {
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.42);
  overflow: hidden;
}

.track-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 7px 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.track-head strong {
  font-family: var(--font-display);
}

.track-head span {
  color: var(--text-secondary);
  font-size: 0.76rem;
}

.track-svg {
  display: block;
  width: calc(100% - 24px);
  height: auto;
  margin: 12px;
  max-height: 159px;
  aspect-ratio: 1000 / 196;
}

.track-bg {
  fill: rgba(15, 23, 42, 0.2);
}

.track-section {
  stroke: rgba(15, 23, 42, 0.55);
  stroke-width: 1;
}

.slope-flat {
  fill: rgba(148, 163, 184, 0.28);
}

.slope-uphill {
  fill: rgba(251, 191, 36, 0.5);
}

.slope-downhill {
  fill: rgba(45, 212, 191, 0.45);
}

.straight {
  fill: rgba(56, 189, 248, 0.42);
}

.corner {
  fill: rgba(251, 146, 60, 0.5);
}

.phase-early {
  fill: rgba(74, 222, 128, 0.5);
}

.phase-mid {
  fill: rgba(251, 191, 36, 0.5);
}

.phase-late {
  fill: rgba(244, 114, 182, 0.48);
}

.phase-spurt {
  fill: rgba(167, 139, 250, 0.5);
}

.track-label {
  fill: rgba(255, 255, 255, 0.82);
  font-size: 14px;
  font-weight: 800;
  text-anchor: middle;
}

.track-marker {
  stroke: rgba(148, 163, 184, 0.18);
  stroke-width: 1;
}

.track-marker-label {
  fill: rgba(203, 213, 225, 0.95);
  font-size: 18px;
  font-weight: 800;
  text-anchor: middle;
}

.activation-row {
  fill: rgba(2, 6, 23, 0.34);
  stroke: rgba(255, 255, 255, 0.08);
  stroke-width: 1;
}

.activation-band {
  fill: rgba(56, 189, 248, 0.42);
  stroke: #38bdf8;
  stroke-width: 2;
}

.activation-immediate {
  fill: rgba(251, 191, 36, 0.32);
  stroke: #fbbf24;
}

.activation-line {
  stroke: #fbbf24;
  stroke-width: 2.5;
}

.order-window {
  margin-top: 8px;
  border: 1px solid var(--border-glass);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.42);
  overflow: hidden;
}

.order-window-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 6px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
}

.order-window-head strong {
  font-family: var(--font-display);
  font-size: 0.84rem;
}

.order-window-head span {
  color: var(--text-secondary);
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
}

.order-window-body {
  display: grid;
  gap: 7px;
  padding: 9px 10px 10px;
}

.order-window-row {
  display: grid;
  grid-template-columns: 58px minmax(0, 1fr);
  gap: 8px;
  align-items: center;
  min-width: 0;
}

.order-window-label {
  color: var(--text-faint);
  font-size: 0.66rem;
  font-weight: 800;
  text-transform: uppercase;
  white-space: nowrap;
}

.order-window-positions {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 4px;
  min-width: 0;
}

.order-position {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  height: 28px;
  border: 1px solid rgba(148, 163, 184, 0.2);
  border-radius: 6px;
  background: rgba(2, 6, 23, 0.34);
  color: var(--text-faint);
  font-size: 0.72rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

.order-position.active {
  border-color: rgba(56, 189, 248, 0.7);
  background: rgba(56, 189, 248, 0.22);
  color: #ffffff;
  box-shadow: inset 0 0 0 1px rgba(56, 189, 248, 0.18);
}

.skill-logic {
  margin-top: 8px;
}

.logic-panel {
  border: 1px solid var(--border-glass);
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.42);
  overflow: hidden;
}

.skill-description {
  margin: 0;
  padding: 9px 10px;
  color: var(--text-primary);
  font-size: 0.78rem;
  line-height: 1.45;
}

.logic-row {
  display: grid;
  gap: 6px;
  margin: 0;
  padding: 8px 10px;
}

.skill-description + .logic-row,
.logic-row + .logic-row {
  border-top: 1px solid rgba(255, 255, 255, 0.07);
}

.logic-row div {
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr);
  gap: 8px;
  align-items: start;
}

.logic-row span {
  color: var(--text-faint);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.logic-row strong {
  color: var(--text-secondary);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.logic-empty {
  padding: 9px 10px;
  color: var(--text-faint);
  font-size: 0.76rem;
}

.empty-state {
  padding: 24px;
  color: var(--text-secondary);
  text-align: center;
}

.hidden {
  display: none;
}

@media (max-width: 1380px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
  }

  .controls-panel,
  .main-layout {
    grid-template-columns: 1fr;
  }

  .main-layout {
    flex: 0 0 auto;
    grid-auto-rows: auto;
    min-height: 0;
  }

  .table-panel {
    height: auto;
    min-height: 360px;
  }

  .table-wrap {
    max-height: 58vh;
    min-height: 300px;
  }
}

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

  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .summary-strip {
    justify-content: flex-start;
  }

  .segmented,
  .toggles {
    flex-wrap: wrap;
  }

  .segmented button {
    flex: 1 1 84px;
  }

  .table-wrap {
    overflow-x: auto;
  }

  table {
    min-width: 980px;
  }

  .boxplot-scale {
    grid-template-columns: repeat(2, 1fr);
  }

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

  .order-window-row {
    grid-template-columns: 1fr;
    gap: 5px;
  }

}
