:root {
  color-scheme: dark;
  --bg: #0b1020;
  --panel: rgba(255, 255, 255, 0.06);
  --panel-2: rgba(255, 255, 255, 0.10);
  --border: rgba(255, 255, 255, 0.14);
  --text: rgba(255, 255, 255, 0.92);
  --muted: rgba(255, 255, 255, 0.66);
  --faint: rgba(255, 255, 255, 0.44);
  --accent: #77d1ff;
  --accent-2: #b7ffcf;
  --danger: #ff5c8a;
  --warn: #ffd166;
  --ok: #38f8a5;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  --radius: 14px;
  --radius-sm: 10px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
}

html, body {
  height: 100%;
}

body {
  margin: 0;
  font-family: var(--sans);
  background:
    radial-gradient(1200px 700px at 12% 8%, rgba(119, 209, 255, 0.18), transparent 55%),
    radial-gradient(900px 600px at 82% 22%, rgba(183, 255, 207, 0.14), transparent 55%),
    radial-gradient(900px 700px at 60% 92%, rgba(255, 92, 138, 0.12), transparent 55%),
    var(--bg);
  color: var(--text);
}

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

.app {
  display: grid;
  grid-template-columns: 280px 1fr;
  height: 100vh;
}

.sidebar {
  padding: 20px;
  border-right: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 14px;
}

.brand .title {
  font-size: 14px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
}

.brand .subtitle {
  font-size: 18px;
  font-weight: 650;
  line-height: 1.2;
}

.nav {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.nav button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  padding: 11px 12px;
  border-radius: 12px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  transition: transform 120ms ease, background 140ms ease, border 140ms ease;
}

.nav button:hover {
  background: rgba(255,255,255,0.06);
  border-color: rgba(255,255,255,0.12);
}

.nav button.active {
  background: rgba(119, 209, 255, 0.10);
  border-color: rgba(119, 209, 255, 0.38);
  box-shadow: 0 0 0 1px rgba(119, 209, 255, 0.10) inset;
}

.nav .pill {
  font-family: var(--mono);
  font-size: 12px;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  color: var(--muted);
}

.content {
  padding: 22px 24px;
  overflow: auto;
}

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

.panelHeader {
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panelHeader h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 650;
}

.panelBody {
  padding: 18px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.grid3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 14px;
}

.stat {
  padding: 14px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
}

.stat .k {
  font-size: 12px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--faint);
  margin-bottom: 6px;
}

.stat .v {
  font-size: 22px;
  font-weight: 700;
}

.row {
  display: flex;
  gap: 12px;
  align-items: center;
}

.rowWrap {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.input, select {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(0,0,0,0.20);
  color: var(--text);
  outline: none;
}

.input:focus, select:focus {
  border-color: rgba(119, 209, 255, 0.55);
  box-shadow: 0 0 0 3px rgba(119, 209, 255, 0.14);
}

.btn {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.16);
  background: rgba(255,255,255,0.10);
  color: var(--text);
  cursor: pointer;
  transition: transform 120ms ease, background 140ms ease, border 140ms ease;
}

.btn:hover { background: rgba(255,255,255,0.14); }
.btn:active { transform: translateY(1px); }

.btn.primary {
  border-color: rgba(119, 209, 255, 0.42);
  background: rgba(119, 209, 255, 0.18);
}

.btn.danger {
  border-color: rgba(255, 92, 138, 0.44);
  background: rgba(255, 92, 138, 0.12);
}

.tag {
  font-family: var(--mono);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: var(--muted);
}

.tag.ok { border-color: rgba(56, 248, 165, 0.34); color: rgba(56, 248, 165, 0.9); }
.tag.warn { border-color: rgba(255, 209, 102, 0.34); color: rgba(255, 209, 102, 0.9); }
.tag.bad { border-color: rgba(255, 92, 138, 0.34); color: rgba(255, 92, 138, 0.9); }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.table th, .table td {
  padding: 10px 10px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  vertical-align: top;
}

.table th {
  text-align: left;
  font-size: 12px;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--faint);
}

.table tr:hover td {
  background: rgba(255,255,255,0.04);
}

.clickRow {
  cursor: pointer;
}

.drawer {
  position: fixed;
  top: 0;
  right: 0;
  width: min(580px, 92vw);
  height: 100vh;
  background: rgba(10, 14, 26, 0.96);
  border-left: 1px solid rgba(255,255,255,0.14);
  box-shadow: -20px 0 50px rgba(0,0,0,0.55);
  transform: translateX(105%);
  transition: transform 180ms ease;
  z-index: 30;
  display: flex;
  flex-direction: column;
}

.drawer.open {
  transform: translateX(0);
}

.drawerHeader {
  padding: 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.drawerHeader h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 650;
}

.drawerBody {
  padding: 16px 16px;
  overflow: auto;
  display: grid;
  gap: 12px;
}

.modalOverlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(0,0,0,0.65);
  z-index: 60;
}

.modalCard {
  width: min(1180px, 96vw);
  height: min(86vh, 900px);
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(10, 14, 26, 0.96);
  box-shadow: 0 30px 90px rgba(0,0,0,0.72);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.modalHeader {
  padding: 12px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.10);
}

.modalTitle {
  font-weight: 720;
  letter-spacing: 0.01em;
}

.pageTextScroll {
  flex: 1;
  overflow: auto;
  padding: 0 12px 12px 12px;
}

.pageText {
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(0,0,0,0.18);
  padding: 10px 10px;
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
}

.pageLine {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  padding: 2px 0;
}

.pageLine.hit {
  background: rgba(119, 209, 255, 0.06);
  border-radius: 10px;
  padding: 2px 8px;
  margin: 2px 0;
}

.lineNo {
  color: rgba(255,255,255,0.44);
  text-align: right;
  user-select: none;
  font-variant-numeric: tabular-nums;
}

.lineText {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  color: rgba(255,255,255,0.86);
}

.markHit {
  background: rgba(255, 226, 109, 0.22);
  border: 1px solid rgba(255, 226, 109, 0.25);
  border-radius: 6px;
  padding: 0 3px;
}

.monoBox {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.35;
  white-space: pre-wrap;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 10px 10px;
}

.diffBox {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.45;
  white-space: pre-wrap;
  background: rgba(0,0,0,0.18);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 10px 10px;
}

.diffAdd {
  background: rgba(56, 248, 165, 0.14);
  border: 1px solid rgba(56, 248, 165, 0.18);
  border-radius: 8px;
  padding: 0 4px;
}

.diffDel {
  background: rgba(255, 92, 138, 0.14);
  border: 1px solid rgba(255, 92, 138, 0.18);
  border-radius: 8px;
  padding: 0 4px;
  text-decoration: line-through;
  opacity: 0.85;
}

.loginShell {
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px;
}

.loginCard {
  width: min(520px, 92vw);
  padding: 20px;
  border-radius: 18px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  box-shadow: var(--shadow);
}

.loginCard h1 {
  margin: 0 0 10px 0;
  font-size: 22px;
}

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

.small {
  font-size: 13px;
}

.charGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
}

.charCard {
  padding: 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  cursor: pointer;
  transition: transform 140ms ease, background 140ms ease, border 140ms ease;
  animation: floatIn 220ms ease both;
}

.charCard:hover {
  transform: translateY(-2px);
  background: rgba(255,255,255,0.07);
  border-color: rgba(119, 209, 255, 0.22);
}

.segmented {
  display: inline-flex;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.05);
  overflow: hidden;
}

.segBtn {
  appearance: none;
  border: none;
  background: transparent;
  color: rgba(255,255,255,0.82);
  padding: 8px 12px;
  cursor: pointer;
  font-weight: 650;
  letter-spacing: 0.01em;
  transition: background 140ms ease, color 140ms ease;
}

.segBtn:hover {
  background: rgba(255,255,255,0.06);
}

.segBtn.active {
  background: rgba(119, 209, 255, 0.20);
  color: rgba(255,255,255,0.96);
}

.heatWrap {
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.18);
  overflow: auto;
  max-height: 70vh;
}

.heatTable {
  border-collapse: separate;
  border-spacing: 0;
  width: max-content;
  min-width: 100%;
  font-size: 12px;
}

.heatTable th,
.heatTable td {
  padding: 6px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}

.heatTable thead th {
  position: sticky;
  top: 0;
  z-index: 2;
  background: rgba(10, 12, 16, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.heatSticky {
  position: sticky;
  left: 0;
  z-index: 3;
  background: rgba(10, 12, 16, 0.92);
  backdrop-filter: blur(10px);
  border-right: 1px solid rgba(255,255,255,0.10);
}

.heatTh {
  text-align: center;
  font-variant-numeric: tabular-nums;
  color: rgba(255,255,255,0.72);
}

.heatTd {
  padding: 4px 6px;
}

.heatCell {
  width: 14px;
  height: 14px;
  border-radius: 5px;
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: 0 10px 22px rgba(0,0,0,0.22);
  transition: transform 100ms ease, border 100ms ease;
}

.heatCell.clickable:hover {
  transform: scale(1.08);
  border-color: rgba(119, 209, 255, 0.28);
}

.graphWrap {
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0,0,0,0.18);
  overflow: hidden;
}

.graphCanvas {
  width: 100%;
  height: 520px;
  display: block;
}

.progressBar {
  width: 220px;
  height: 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  overflow: hidden;
}

.progressFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, rgba(119,209,255,0.32), rgba(119,209,255,0.80));
  transition: width 160ms ease;
}

.sparkline {
  display: flex;
  align-items: flex-end;
  gap: 4px;
  padding: 8px 10px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.04);
  overflow-x: auto;
}

.sparkBar {
  width: 7px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(119, 209, 255, 0.72);
}

.charName {
  font-weight: 720;
  letter-spacing: 0.01em;
}

.silhouette {
  width: 44px;
  height: 44px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.14);
  position: relative;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(0,0,0,0.28);
}

.silhouetteHead {
  position: absolute;
  width: 16px;
  height: 16px;
  border-radius: 999px;
  background: rgba(255,255,255,0.62);
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
}

.silhouetteBody {
  position: absolute;
  width: 26px;
  height: 18px;
  border-radius: 999px 999px 12px 12px;
  background: rgba(255,255,255,0.40);
  bottom: 7px;
  left: 50%;
  transform: translateX(-50%);
}

@keyframes floatIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.chapterMap {
  display: flex;
  align-items: flex-end;
  gap: 7px;
  padding: 14px 14px;
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(0, 0, 0, 0.18);
  overflow-x: auto;
  overflow-y: hidden;
  min-height: 96px;
}

.chapterBar {
  width: 12px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.18);
  cursor: pointer;
  position: relative;
  box-shadow: 0 16px 30px rgba(0,0,0,0.26);
  transition: transform 140ms ease, filter 140ms ease, border 140ms ease;
}

.chapterBar::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(180deg, rgba(255,255,255,0.26), rgba(255,255,255,0.02));
  opacity: 0.22;
  pointer-events: none;
}

.chapterBar:hover {
  transform: translateY(-3px);
  filter: brightness(1.25);
  border-color: rgba(119, 209, 255, 0.26);
}

.chapterBar:active {
  transform: translateY(-1px);
}
