:root {
  --bg: #0B0F14;

  --panel: #0D1116;
  --panel-outline: #11151A;

  --sidebar-search-bg: #0E1217;
  --sidebar-search-outline: #11151A;

  --text-main: #F6F6F6;
  --text-muted: #5C626C;

  --vet-purple: #A532FF;

  --green: #15C948;
  --green-faded: rgba(21, 201, 72, 0.14);

  --yellow: #D6DC19;
  --yellow-faded: #15170E;

  --red: #E32222;
  --red-faded: #170E0E;

  --radius-xl: 24px;
  --radius-lg: 22px;

  --page-pad-y: 32px;
  --page-pad-x: 24px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text-main);
  font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

body {
  padding: var(--page-pad-y) var(--page-pad-x);
  overflow-y: auto;
  overflow-x: hidden;
}

.app {
  max-width: 1220px;
  margin: 0 auto;
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

/* ─── Sidebar ─────────────────────────────────────────────────── */

.sidebar {
  width: 300px;
  flex-shrink: 0;
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-outline);
  background: var(--panel);
  padding: 16px;
  position: sticky;
  top: var(--page-pad-y);
  height: calc(100vh - (var(--page-pad-y) * 2));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 8px;
  margin-bottom: 12px;
  flex-shrink: 0;
}

.sidebar-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text-main);
}

.sidebar-count {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
}

/* ─── Main column ─────────────────────────────────────────────── */
/*
  Mirror the sidebar pattern: fixed viewport height, flex column,
  overflow hidden. The topbar sits at the top (flex-shrink: 0) and
  the cards area scrolls below it — clipping cards exactly where the
  topbar ends, just like the sidebar clips its player list.
*/

.main {
  min-width: 0;
  flex: 1;
  position: sticky;
  top: var(--page-pad-y);
  height: calc(100vh - (var(--page-pad-y) * 2));
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ─── Topbar ──────────────────────────────────────────────────── */

.topbar {
  /* No longer needs position:sticky — the parent handles the fixed
     positioning.  flex-shrink:0 keeps it from squishing. */
  flex-shrink: 0;
  margin-bottom: 16px;
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-outline);
  background: var(--panel);
  padding: 14px 20px;
  overflow: hidden;
  isolation: isolate;
}

/* ─── Search ──────────────────────────────────────────────────── */

.search-wrap {
  position: relative;
}

.sidebar-search-wrap {
  margin-bottom: 16px;
  flex-shrink: 0;
}

.search-icon {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  pointer-events: none;
}

.search-icon svg,
.copy-btn svg,
.updated svg {
  width: 100%;
  height: 100%;
  display: block;
  fill: var(--text-muted);
}

.search-input {
  width: 100%;
  height: 48px;
  border-radius: 16px;
  padding: 0 16px 0 42px;
  color: var(--text-muted);
  outline: none;
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
}

.sidebar-search-input {
  border: 1.5px solid var(--sidebar-search-outline);
  background: var(--sidebar-search-bg);
}

.main-search-input {
  border: 0;
  background: transparent;
  height: 40px;
  font-size: 16px;
  letter-spacing: -0.02em;
  padding-left: 36px;
}

.search-input::placeholder,
.main-search-input::placeholder {
  color: var(--text-muted);
  opacity: 1;
}

/* ─── Sidebar list ────────────────────────────────────────────── */

.sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-right: 4px;
}

.sidebar-list::-webkit-scrollbar {
  width: 8px;
}

.sidebar-list::-webkit-scrollbar-track {
  background: #0D1116;
  border-radius: 999px;
}

.sidebar-list::-webkit-scrollbar-thumb {
  background: #191F27;
  border-radius: 999px;
  border: 2px solid #0D1116;
}

.sidebar-list::-webkit-scrollbar-button,
.sidebar-list::-webkit-scrollbar-button:single-button,
.sidebar-list::-webkit-scrollbar-button:start,
.sidebar-list::-webkit-scrollbar-button:end,
.sidebar-list::-webkit-scrollbar-button:vertical:start,
.sidebar-list::-webkit-scrollbar-button:vertical:end,
.sidebar-list::-webkit-scrollbar-button:increment,
.sidebar-list::-webkit-scrollbar-button:decrement {
  display: none;
  width: 0;
  height: 0;
  background: transparent;
}

.sidebar-list::-webkit-scrollbar-corner {
  background: transparent;
}

/* ─── Sidebar player rows ─────────────────────────────────────── */

.sidebar-player {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  border: 0;
  background: transparent;
  color: inherit;
  text-align: left;
  padding: 8px;
  border-radius: 12px;
  cursor: pointer;
}

.avatar-small,
.avatar-large {
  display: block;
  object-fit: cover;
  image-rendering: pixelated;
}

.avatar-small {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  flex-shrink: 0;
}

.avatar-large {
  width: 92px;
  height: 92px;
  border-radius: 18px;
  padding: 0;
  flex-shrink: 0;
  background: transparent;
  border: 0;
}

.sidebar-player-name {
  font-weight: 700;
  color: var(--vet-purple);
  font-family: 'Inter', sans-serif;
}

/* ─── Cards scroll area ───────────────────────────────────────── */
/*
  This takes up all remaining vertical space below the topbar and
  scrolls internally — the same way .sidebar-list works inside the
  sidebar.  Cards are clipped the moment they travel behind the
  topbar edge.
*/

.cards {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding-right: 12px;
  /* Small bottom pad so the last card isn't flush against the edge */
  padding-bottom: 4px;
}

.cards::-webkit-scrollbar {
  width: 8px;
}

.cards::-webkit-scrollbar-track {
  background: #0B0F14;
  border-radius: 999px;
}

.cards::-webkit-scrollbar-thumb {
  background: #191F27;
  border-radius: 999px;
  border: 2px solid #0B0F14;
}

.cards::-webkit-scrollbar-button,
.cards::-webkit-scrollbar-button:single-button,
.cards::-webkit-scrollbar-button:start,
.cards::-webkit-scrollbar-button:end,
.cards::-webkit-scrollbar-button:vertical:start,
.cards::-webkit-scrollbar-button:vertical:end,
.cards::-webkit-scrollbar-button:increment,
.cards::-webkit-scrollbar-button:decrement {
  display: none;
  width: 0;
  height: 0;
  background: transparent;
}

.cards::-webkit-scrollbar-corner {
  background: transparent;
}

/* ─── Individual card ─────────────────────────────────────────── */

.card {
  border-radius: var(--radius-xl);
  border: 1px solid var(--panel-outline);
  background: var(--panel);
  padding: 16px;
  /* scroll-margin-top is relative to the cards scroll container now,
     so a small value is enough to keep the card header visible */
  scroll-margin-top: 8px;
  flex-shrink: 0;
}

.card-inner {
  display: flex;
  gap: 16px;
  align-items: flex-start;
}

.card-content {
  flex: 1;
  min-width: 0;
  padding-top: 4px;
}

.card-top {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
}

.name-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
}

.name {
  margin: 0;
  font-size: 19px;
  font-weight: 700;
  line-height: 1;
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
}

.uuid-row {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
}

.copy-btn {
  border: 0;
  background: transparent;
  cursor: pointer;
  padding: 0;
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.copy-btn:hover svg {
  fill: var(--text-main);
}

.summary {
  margin: 10px 0 0;
  max-width: 760px;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-muted);
  font-weight: 600;
  font-family: 'Inter', sans-serif;
}

.updated {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 600;
  font-family: 'Inter', sans-serif;
  padding-top: 2px;
  white-space: nowrap;
}

.updated .time-icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.status-block {
  margin-top: 12px;
  max-width: 390px;
}

.status-label {
  margin-bottom: 6px;
  font-size: 14px;
  font-weight: 700;
  font-family: 'Inter', sans-serif;
}

.progress-track {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  border-radius: 999px;
}

.tone-green .status-label { color: var(--green); }
.tone-green .progress-track { background: var(--green-faded); }
.tone-green .progress-bar { background: var(--green); }

.tone-yellow .status-label { color: var(--yellow); }
.tone-yellow .progress-track { background: var(--yellow-faded); }
.tone-yellow .progress-bar { background: var(--yellow); }

.tone-red .status-label { color: var(--red); }
.tone-red .progress-track { background: var(--red-faded); }
.tone-red .progress-bar { background: var(--red); }

.empty-state,
.loading-state,
.error-state {
  border-radius: var(--radius-lg);
  border: 1px solid var(--panel-outline);
  background: var(--panel);
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  padding: 20px;
  flex-shrink: 0;
}

/* ─── Page-level scrollbar ────────────────────────────────────── */

html::-webkit-scrollbar,
body::-webkit-scrollbar {
  width: 12px;
}

html::-webkit-scrollbar-track,
body::-webkit-scrollbar-track {
  background: #0D1116;
}

html::-webkit-scrollbar-thumb,
body::-webkit-scrollbar-thumb {
  background: #191F27;
  border-radius: 999px;
  border: 2px solid #0D1116;
}

html::-webkit-scrollbar-button,
body::-webkit-scrollbar-button,
html::-webkit-scrollbar-button:single-button,
body::-webkit-scrollbar-button:single-button {
  display: none;
  width: 0;
  height: 0;
  background: transparent;
}

html {
  scrollbar-color: #191F27 #0D1116;
  scrollbar-width: thin;
}

/* ─── Responsive ──────────────────────────────────────────────── */

@media (max-width: 980px) {
  body {
    padding: 16px;
  }

  .app {
    flex-direction: column;
  }

  /* Both panels revert to natural height on mobile */
  .sidebar,
  .main {
    position: static;
    width: 100%;
    height: auto;
    overflow: visible;
    padding-right: 0;
  }

  .topbar {
    position: static;
  }

  .sidebar-list {
    max-height: 300px;
    overflow-y: auto;
  }

  /* Cards revert to normal flow on mobile */
  .cards {
    overflow-y: visible;
    max-height: none;
    padding-right: 0;
    padding-bottom: 0;
  }
}

@media (max-width: 760px) {
  .card-inner,
  .card-top {
    flex-direction: column;
  }

  .updated {
    padding-top: 0;
  }

  .avatar-large {
    width: 72px;
    height: 72px;
  }

  .main-search-input {
    font-size: 18px;
  }
}