:root {
  --bg: #0f172a;
  --panel: #1e293b;
  --panel2: #24324a;
  --text: #e5e7eb;
  --muted: #94a3b8;
  --accent: #22c55e;
  --danger: #ef4444;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Ubuntu, Arial, sans-serif;
  background: linear-gradient(180deg, #020617, #0f172a);
  color: var(--text);
}

main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 24px;
}

header { margin-bottom: 24px; }

h1 { margin: 0; font-size: 2.2rem; }

h2 {
  margin: 6px 0 0;
  color: var(--muted);
  font-weight: 500;
}

section {
  background: var(--panel);
  border-radius: 14px;
  padding: 18px;
  margin-bottom: 20px;
  box-shadow: 0 12px 30px rgba(0,0,0,0.35);
}

h3 { margin: 0; }

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

/* === Projects header layout (requested) === */
.project-header-left{
  display:flex;
  align-items:center;
  gap:12px;
  flex-wrap:wrap;
}
.project-board-title{
  margin:0;
  font-weight:900;
}
.project-board-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}
.project-header-actions{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  justify-content:flex-end;
  align-items:center;
}
.only-mine{
  display:flex;
  align-items:center;
  gap:6px;
  color: var(--muted);
  font-weight: 650;
}
.auth-btn{
  border: 1px solid rgba(34,197,94,0.30);
  box-shadow: 0 0 0 1px rgba(34,197,94,0.08) inset;
}

.link-section{
  margin-bottom: 14px;
  background: rgba(0,0,0,0.12);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  padding: 12px;
}
.link-row{
  display:flex;
  gap:10px;
  flex-wrap:wrap;
  align-items:center;
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  color: var(--text);
  text-decoration: none;
  font-weight: 650;
  font-size: 0.95rem;
  transition: transform 120ms ease, background 120ms ease, opacity 120ms ease;
}

.header-btn:hover { background: rgba(255,255,255,0.12); transform: translateY(-1px); }
.header-btn:active { transform: translateY(0px); }
.header-btn.disabled { opacity: 0.45; pointer-events: none; }

.cards { display: grid; gap: 14px; }
.cards-4 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.cards-3 { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
/* 5-up stat row (used in Home Media) */
.cards-5 { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.cards > div,
section > div > div {
  background: var(--panel2);
  border-radius: 12px;
  padding: 14px;
}

.card-span-2 { grid-column: span 2; }
@media (max-width: 720px) { .card-span-2 { grid-column: span 1; } }

.section-pills {
  display: flex;
  gap: 10px;
  margin: 10px 0 14px;
}

.pill {
  display: inline-flex;
  align-items: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.10);
  color: var(--text);
  font-weight: 700;
  font-size: 0.85rem;
}

.muted { color: var(--muted); }
p { margin: 6px 0; }
h4 { margin: 0 0 10px; }

.status-online { color: var(--accent); font-weight: 800; }
.status-offline { color: var(--danger); font-weight: 800; }

svg { display: block; margin: 10px auto 8px; }

#cpuText, #ramText, #diskText, #diskTextRoot, #diskTextShare {
  text-align: center;
  font-size: 1.25rem;
  font-weight: 700;
}

#ramDetail, #diskDetail, #diskDetailRoot, #diskDetailShare, #loadAvg {
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
}

/* =========================
   Server health gauges
   ========================= */
.gauge {
  width: 140px;
  height: 140px;
}

.gauge-bg,
.gauge-fg {
  fill: none;
  stroke-width: 14;
}

.gauge-bg {
  stroke: rgba(255,255,255,0.10);
}

.gauge-fg {
  stroke: rgba(34,197,94,0.85);
  stroke-linecap: round;
  stroke-dasharray: 390;
  stroke-dashoffset: 390;
  transform: rotate(-90deg);
  transform-origin: 70px 70px;
  transition: stroke-dashoffset 260ms ease;
}

.gauge-card svg { margin: 12px auto 8px; }

/* =========================
   Collapsible Home Media caret
   ========================= */
.section-summary {
  list-style: none;
}
.section-summary::-webkit-details-marker { display: none; }
.details-caret {
  width: 34px;
  height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.10);
}
.details-caret::before {
  content: "▾";
  font-size: 1.05rem;
  opacity: 0.9;
}
details[open] .details-caret::before { content: "▴"; }

/* =========================
   Home Media layout fixes
   ========================= */

/* Add breathing room under the Home Media header row */
#mediaDetails > summary.section-summary {
  padding: 10px 0 14px 0;
}

/* Space title vs actions */
#mediaDetails .section-header {
  gap: 14px;
}

/* Space between the buttons themselves */
#mediaDetails .topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Add space between header and divider line */
#mediaDetails > .divider {
  margin-top: 10px;
}

/* Fix stretched / weird cover images */
.media-thumb {
  overflow: hidden;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
}

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

/* Plex TV list rows + ABS recent list rows */
.plex-row .media-thumb {
  width: 60px;
  height: 90px;
  flex: 0 0 60px;
}

/* Plex movie grid posters */
.plex-grid .media-thumb {
  width: 100%;
  aspect-ratio: 2 / 3;
}

/* =========================
   Home Media: Plex movies formatting
   ========================= */

#plexRecentMovies.plex-grid {
  display: grid;
  grid-template-columns: 1fr; /* keep single column in that narrow card */
  gap: 12px;
}

#plexRecentMovies .plex-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

#plexRecentMovies .media-thumb {
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 12px;
}

#plexRecentMovies .media-title {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 2;       /* limit title height */
  -webkit-box-orient: vertical;
  overflow: hidden;
}

#plexRecentMovies .media-subtitle {
  opacity: 0.75;
  font-size: 0.85rem;
}

/* =========================
   Players page: Founder + gold title
   ========================= */
.founder-tag {
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 6px 0 10px;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(34,197,94,0.14);
  border: 1px solid rgba(34,197,94,0.32);
  color: rgba(134,239,172,0.98);
  font-weight: 800;
  font-size: 0.78rem;
  letter-spacing: 0.02em;
  width: fit-content;
}

.player-title-gold {
  color: #fbbf24;
  font-weight: 950;
  text-shadow: 0 0 18px rgba(251,191,36,0.22);
}

ol, ul { margin: 0; padding-left: 18px; }
.list li { margin: 6px 0; }

/* ===== Online Now (clean) ===== */
.online-count-line { margin-bottom: 8px; }

.count-online { color: var(--accent); font-weight: 900; }
.count-offline { color: var(--muted); font-weight: 900; }

.online-now { margin-top: 6px; }
.online-now ul { list-style: none; padding-left: 0; margin: 0; }
.online-now li {
  margin: 6px 0;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(0,0,0,0.12);
}

/* =========================
   Media thumbs (ABS + Plex)
   ========================= */
.media-thumb {
  width: 100%;
  height: 170px;
  border-radius: 10px;
  overflow: hidden;
  background: rgba(0,0,0,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #cbd5e1;
}

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

.thumb-fallback {
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  font-weight: 600;
  color: rgba(229,231,235,0.8);
}

/* =========================
   Plex grids + compact lists
   ========================= */
.plex-grid {
  display: grid;
  gap: 14px;
}

/* =========================
   Projects board
   ========================= */
.board {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(3, minmax(240px, 1fr));
}

@media (max-width: 980px) {
  .board { grid-template-columns: 1fr; }
}

.col {
  background: rgba(0,0,0,0.12);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 14px;
  padding: 12px;
}

.col-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.col-body {
  display: grid;
  gap: 10px;
  min-height: 140px;
}

.project-card {
  background: var(--panel2);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid rgba(255,255,255,0.08);
}

.project-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
}

.project-title {
  font-weight: 900;
  font-size: 1.02rem;
}

.project-meta {
  margin-top: 6px;
  color: var(--muted);
  font-size: 0.92rem;
}

.project-desc { margin-top: 10px; }

.project-actions { display: flex; gap: 8px; }

.mini-btn {
  appearance: none;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  border-radius: 10px;
  padding: 6px 10px;
  font-weight: 750;
  cursor: pointer;
}
.mini-btn:hover { background: rgba(255,255,255,0.12); }

.tag-row { margin-top: 10px; display: flex; flex-wrap: wrap; gap: 8px; }
.tag {
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(34,197,94,0.12);
  border: 1px solid rgba(34,197,94,0.25);
  color: #bbf7d0;
  font-weight: 800;
  font-size: 0.82rem;
}

.inline-form { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.text-input {
  width: min(420px, 100%);
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  outline: none;
}

.text-area {
  width: 100%;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--text);
  outline: none;
  resize: vertical;
}

.field { display: grid; gap: 6px; margin-bottom: 12px; }
.field-label { font-weight: 800; color: rgba(229,231,235,0.85); }

.modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: none;
  place-items: center;
  padding: 18px;
  z-index: 1000;
}


/* ===== Top nav active (green highlight) ===== */
.nav-btn.nav-active,
.header-btn.nav-active {
  background: rgba(34,197,94,0.22);
  border: 1px solid rgba(34,197,94,0.40);
  color: rgba(187,247,208,0.98);
}

/* ===== Name badges (crown/star) ===== */
.name-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  margin-right: 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  line-height: 1;
  font-size: 0.95rem;
}

.name-badge.badge-crown {
  background: rgba(251,191,36,0.18);
  border-color: rgba(251,191,36,0.35);
}

.name-badge.badge-star {
  background: rgba(96,165,250,0.18);
  border-color: rgba(96,165,250,0.35);
}

/* Katie: black crown */
.name-badge.badge-tiara {
  background: rgba(0,0,0,0.35);
  border-color: rgba(0,0,0,0.55);
}

/* ===== Modal styling (Projects: New Project / Details) ===== */
.modal-card {
  width: min(720px, 100%);
  background: rgba(30,41,59,0.92);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 18px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.45);
  overflow: hidden;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: rgba(255,255,255,0.06);
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.modal-head h3 { margin: 0; font-size: 1.05rem; }

.modal-body {
  padding: 16px;
}

.modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 10px;
}

@media (max-width: 520px) {
  .inline-form .text-input { width: 100%; }
  .modal-actions .header-btn, .modal-actions .mini-btn { width: 100%; justify-content: center; }
}


/* =========================
   Unified media cards (Movies / TV / Books)
   ========================= */

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

.media-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.media-title {
  font-size: 0.95rem;
  font-weight: 750;
  line-height: 1.15;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.media-subtitle {
  font-size: 0.85rem;
  opacity: 0.75;
}

.poster-contain img {
  object-fit: contain !important;
  background: rgba(0,0,0,0.18);
}

/* Make legacy movie grid selector still work */
#plexRecentMovies.plex-grid,
#plexRecentTv.plex-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

/* =========================
   Home Media layout
   ========================= */

.media-block {
  display: block;
}

.media-subsection {
  margin-top: 12px;
}

.media-subhead {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 6px 0 10px 0;
}

.cards-abs-metrics {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 14px;
  margin-top: 14px;
  margin-bottom: 10px;
}

.hero-text {
  font-size: 1.05rem;
  line-height: 1.2;
}

/* =========================
   Audiobookshelf "POP" featured card
   ========================= */

.cards-abs-feature {
  margin-bottom: 14px;
}

.card.abs-feature {
  border: 1px solid rgba(99, 102, 241, 0.22);
  background: linear-gradient(180deg, rgba(30,41,59,0.95), rgba(17,24,39,0.75));
  box-shadow:
    0 0 0 1px rgba(99, 102, 241, 0.10),
    0 12px 30px rgba(0,0,0,0.35);
}

.card.abs-feature.is-empty {
  opacity: 0.75;
}

.abs-feature-head {
  display: flex;
  gap: 14px;
  align-items: center;
}

.abs-feature-cover .media-thumb {
  width: 92px;
  height: 130px;
  border-radius: 14px;
  background: rgba(0,0,0,0.20);
}

.abs-feature-meta {
  flex: 1;
  min-width: 0;
}

.abs-feature-label {
  font-size: 0.85rem;
  color: rgba(167, 139, 250, 0.95);
  font-weight: 700;
  letter-spacing: 0.3px;
  margin-bottom: 6px;
}

.abs-feature-title {
  font-size: 1.15rem;
  font-weight: 800;
  line-height: 1.15;
  margin-bottom: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.abs-feature-sub {
  color: var(--muted);
  font-size: 0.95rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.abs-progress {
  margin-top: 10px;
}

.abs-progress-bar {
  width: 100%;
  height: 10px;
  border-radius: 999px;
  background: rgba(255,255,255,0.08);
  overflow: hidden;
}

.abs-progress-fill {
  height: 100%;
  width: 0%;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(99,102,241,1), rgba(34,197,94,1));
}


/* =========================
   ABS Recently Added: compact strip cards
   ========================= */
.abs-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px;
}

.abs-strip-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: rgba(0,0,0,0.14);
  border: 1px solid rgba(255,255,255,0.06);
}

.abs-strip-cover {
  width: 56px;
  flex: 0 0 56px;
}

.abs-strip-cover .media-thumb {
  width: 56px;
  height: 80px;
  border-radius: 10px;
  overflow: hidden;
}

.abs-strip-cover .media-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover; /* keep small covers crisp */
}

.abs-strip-text {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.abs-strip-title {
  font-weight: 750;
  font-size: 0.95rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.abs-strip-author {
  opacity: 0.75;
  font-size: 0.85rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* ---------------------------
   Player Directory readability
---------------------------- */
.player-name {
  color: rgba(255,255,255,0.92) !important;
  font-weight: 700;
  letter-spacing: 0.2px;
  text-shadow: 0 1px 8px rgba(0,0,0,0.45);
}
.player-name.link:hover { opacity: 0.95; }

/* ---------------------------
   Home Media grouping
---------------------------- */
.media-group {
  padding: 14px;
  border-radius: 16px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.06);
}
.media-group + .media-group { margin-top: 12px; }

.media-group-header {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 10px;
}
.media-group-title {
  margin: 0;
  font-size: 1.02rem;
}
.media-group-sub { margin-left: auto; }

.media-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  transform: translateY(-1px);
}
.media-dot.abs { background: rgba(80,200,120,0.95); }
.media-dot.plex { background: rgba(255,200,80,0.95); }

/* ---------------------------
   Modal (Add to the Hoard)
---------------------------- */
body.modal-open { overflow: hidden; }

.modal {
  position: fixed;
  inset: 0;
  display: none;
  z-index: 9999;
}
.modal.open { display: block; }

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
}

.modal-dialog {
  position: relative;
  width: min(720px, calc(100vw - 28px));
  margin: 10vh auto 0;
  border-radius: 18px;
  background: rgba(25,33,50,0.95);
  border: 1px solid rgba(255,255,255,0.10);
  box-shadow: 0 24px 80px rgba(0,0,0,0.55);
}

.modal-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 10px;
}
.modal-head h3 { margin: 4px 0 0; }

.modal-body { padding: 0 16px 16px; }

.icon-btn {
  border: 1px solid rgba(255,255,255,0.14);
  background: rgba(255,255,255,0.06);
  color: rgba(255,255,255,0.9);
  border-radius: 12px;
  padding: 8px 10px;
  cursor: pointer;
}
.icon-btn:hover { background: rgba(255,255,255,0.10); }

.modal-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  margin-top: 12px;
}

.modal-choice {
  display: block;
  text-decoration: none;
  padding: 12px 12px;
  border-radius: 16px;
  border: 1px solid rgba(255,255,255,0.10);
  background: rgba(255,255,255,0.04);
}
.modal-choice:hover {
  background: rgba(255,255,255,0.07);
  border-color: rgba(255,255,255,0.16);
}
.choice-title { font-weight: 800; color: rgba(255,255,255,0.92); }
.choice-sub { margin-top: 4px; }

@media (max-width: 620px) {
  .modal-grid { grid-template-columns: 1fr; }
  .modal-dialog { margin-top: 7vh; }
}
