:root {
  --bg: #020305;
  --panel: #050608;
  --panel-alt: #0b0f12;
  --accent: #54d6b0;
  --text: #f5f5f5;
  --muted: #a8b8b1;
  --danger: #d95757;
  --scanner-blue-rgb: 114, 184, 255;
  --border: rgba(84, 214, 176, 0.28);
  --glow: 0 0 0.75rem rgba(84, 214, 176, 0.36), 0 0 2rem rgba(84, 214, 176, 0.17);
}

* {
  box-sizing: border-box;
}

::selection {
  background: var(--accent);
  color: var(--bg);
}

/* ===== SCROLLBAR STYLING ===== */
html {
  scrollbar-color: rgba(84, 214, 176, 0.72) rgba(11, 15, 18, 0.95);
  scrollbar-width: thin;
}

::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

::-webkit-scrollbar-track {
  background: linear-gradient(180deg, rgba(11, 15, 18, 0.95), rgba(5, 6, 8, 0.95));
  border-radius: 999px;
}

::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(84, 214, 176, 0.9), rgba(30, 120, 100, 0.95));
  border-radius: 999px;
  border: 2px solid rgba(8, 10, 12, 0.95);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 0 12px rgba(84, 214, 176, 0.25);
}

::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, #6ee5c2, var(--accent));
}

::-webkit-scrollbar-corner {
  background: rgba(5, 6, 8, 0.95);
}

html,
body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 80% -10%, rgba(84, 214, 176, 0.16), transparent 28%),
    radial-gradient(circle at 10% 20%, rgba(84, 214, 176, 0.1), transparent 22%),
    var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

h1,
h2,
h3,
p {
  margin: 0;
}

.app-shell {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.2rem;
}

.app-header {
  margin-bottom: 1rem;
}

.app-feedback {
  min-height: 1.8rem;
  margin-top: 0.6rem;
  color: var(--muted);
  font-size: 0.95rem;
}

.app-feedback.visible {
  color: var(--accent);
}

.app-feedback.error {
  color: #ffd8d8;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.brand-logo {
  width: 44px;
  height: 44px;
  filter: drop-shadow(0 0 0.6rem rgba(84, 214, 176, 0.6));
}

h1 {
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: clamp(1.45rem, 3vw, 2rem);
}

.app-header p {
  color: var(--muted);
}

.tab-nav {
  display: flex;
  gap: 0.55rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}

.tab-btn {
  border: 1px solid var(--border);
  color: var(--text);
  background: var(--panel);
  border-radius: 0.65rem;
  padding: 0.58rem 0.9rem;
  cursor: pointer;
  transition: 180ms ease;
}

.tab-btn:hover,
.tab-btn.active {
  border-color: var(--accent);
  color: var(--accent);
  box-shadow: var(--glow);
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

.panel-grid {
  display: grid;
  gap: 1rem;
}

.panel-grid.two-cols {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.card {
  background:
    linear-gradient(160deg, rgba(84, 214, 176, 0.1), rgba(84, 214, 176, 0) 42%),
    var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.78rem;
  padding: 1rem;
}

.card h2 {
  margin-bottom: 0.7rem;
  letter-spacing: 0.03em;
}

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

.stack-form {
  display: grid;
  gap: 0.65rem;
}

label {
  color: var(--muted);
  font-size: 0.95rem;
}

input,
textarea,
select,
button {
  font: inherit;
}

input,
select,
textarea {
  width: 100%;
  background: var(--panel-alt);
  border: 1px solid rgba(84, 214, 176, 0.22);
  color: var(--text);
  border-radius: 0.55rem;
  padding: 0.56rem 0.64rem;
}

input[type="color"] {
  min-height: 2.4rem;
  padding: 0.2rem;
}

button,
.import-btn {
  border: 1px solid var(--accent);
  background: transparent;
  color: var(--accent);
  border-radius: 0.55rem;
  padding: 0.55rem 0.82rem;
  cursor: pointer;
  transition: 160ms ease;
}

button:hover,
.import-btn:hover {
  box-shadow: var(--glow);
  transform: translateY(-1px);
}

button.ghost {
  border-color: rgba(84, 214, 176, 0.55);
  color: var(--text);
}

button.danger {
  border-color: var(--danger);
  color: #ffd8d8;
}

button.danger:hover,
button.danger:focus-visible {
  background: var(--danger);
  color: #fff;
  border-color: #ff7f7f;
  box-shadow: 0 0 0.65rem rgba(217, 87, 87, 0.62), 0 0 1.4rem rgba(217, 87, 87, 0.42);
  transform: translateY(-1px) scale(1.01);
}

button.danger:active {
  transform: translateY(0) scale(0.99);
}

.actions {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.actions.left {
  justify-content: flex-start;
}

.list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.list-item {
  display: grid;
  gap: 0.7rem;
  border: 1px solid rgba(84, 214, 176, 0.22);
  background: rgba(8, 10, 12, 0.88);
  border-radius: 0.65rem;
  padding: 0.72rem;
}

.inline-edit {
  grid-column: 1 / -1;
  border-top: 1px dashed rgba(84, 214, 176, 0.3);
  padding-top: 0.7rem;
}

.inline-edit .stack-form {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.55rem 0.75rem;
}

.inline-edit label {
  grid-column: span 2;
}

.inline-edit input[type="text"],
.inline-edit input[type="number"],
.inline-edit input[type="url"],
.inline-edit input[type="file"],
.inline-edit textarea,
.inline-edit input[type="color"] {
  grid-column: span 2;
}

.inline-edit .actions {
  grid-column: span 2;
}

.profile-item,
.candidate-item {
  grid-template-columns: 1fr;
  align-items: stretch;
}

.profile-item > .actions,
.candidate-item > .actions {
  justify-content: flex-start;
  gap: 0.65rem;
}

.profile-item > .actions button,
.candidate-item > .actions button {
  flex: 1 1 12rem;
  min-height: 2.8rem;
}


.profile-main {
  text-align: left;
  color: var(--text);
}

.profile-main .name {
  font-weight: 700;
}

.profile-main .name-row {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
}

.profile-main .color-dot {
  width: 0.82rem;
  height: 0.82rem;
  border-radius: 50%;
}

.profile-main .meta {
  color: var(--muted);
  font-size: 0.9rem;
}

.candidate-main {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.candidate-photo {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  object-fit: cover;
  background: #111;
  border: 1px solid rgba(84, 214, 176, 0.35);
}

.candidate-meta strong {
  display: block;
}

.candidate-meta span {
  color: var(--muted);
}

.candidate-item.eliminated {
  border-color: rgba(217, 87, 87, 0.6);
  opacity: 0.78;
}

.candidate-item.eliminated .candidate-meta strong {
  text-decoration: line-through;
}

.vote-air-date-hint {
  margin: 0;
  font-size: 0.92rem;
}

.editor-block {
  position: relative;
  display: grid;
  gap: 0.48rem;
}

.editor-toolbar {
  display: flex;
  gap: 0.45rem;
}

.editor-toolbar button {
  min-width: 2.4rem;
  padding: 0.35rem 0.52rem;
}

.editor {
  min-height: 130px;
  border: 1px solid rgba(84, 214, 176, 0.3);
  border-radius: 0.6rem;
  background: var(--panel-alt);
  padding: 0.65rem;
  outline: none;
  font-weight: normal;
}

.editor:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(84, 214, 176, 0.16);
}

.editor h1 {
  font-size: 1.8rem;
  font-weight: normal;
  margin: 0.5rem 0;
}

.editor p,
.editor div {
  font-size: 1rem;
  font-weight: normal;
  margin: 0.25rem 0;
}

.episode-notes-card {
  display: grid;
  gap: 0.9rem;
}

.episode-notes-card h2 {
  margin-bottom: 0.15rem;
}

.episode-notes-card #episode-notes-meta {
  line-height: 1.45;
}

.episode-notes-card .editor-block {
  gap: 0.75rem;
}

.episode-notes-card .editor-toolbar {
  gap: 0.55rem;
  flex-wrap: wrap;
}

.episode-notes-card .editor {
  min-height: 180px;
  padding: 0.85rem;
  line-height: 1.55;
}

.episode-notes-card .actions {
  margin-top: 0.2rem;
}

.export-import-actions {
  margin-top: 0.7rem;
  gap: 0.85rem;
}

.export-import-actions button,
.export-import-actions .import-btn {
  min-height: 2.55rem;
  padding: 0.6rem 1rem;
}

.autocomplete {
  position: absolute;
  left: 0;
  top: 100%;
  margin-top: 0.2rem;
  background: #06080a;
  border: 1px solid rgba(84, 214, 176, 0.38);
  border-radius: 0.48rem;
  min-width: 190px;
  z-index: 20;
  display: none;
}

.autocomplete.visible {
  display: block;
}

.autocomplete button {
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  border-radius: 0;
  color: var(--text);
  padding: 0.46rem 0.55rem;
}

.autocomplete button:hover,
.autocomplete button.active {
  background: rgba(84, 214, 176, 0.16);
  box-shadow: none;
  transform: none;
}

.episode-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.bar-track {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
  margin-top: 0.35rem;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #1e7864, var(--accent));
}

.stats-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
}

.stats-controls label {
  display: grid;
  gap: 0.35rem;
}

.stats-controls select {
  min-width: 10rem;
}

.stats-chart-wrap {
  display: grid;
  gap: 0.75rem;
}

.stats-columns {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
  gap: 0.65rem;
  align-items: end;
}

.stats-column-item {
  display: grid;
  gap: 0.35rem;
}

.stats-column-value,
.stats-column-label {
  font-size: 0.85rem;
  color: var(--muted);
}

.stats-column-track {
  height: 150px;
  border-radius: 0.5rem;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(84, 214, 176, 0.2);
  display: flex;
  align-items: end;
  overflow: hidden;
}

.stats-column-fill {
  width: 100%;
  min-height: 6px;
  opacity: 0.9;
}

.stats-pie {
  width: min(360px, 100%);
  aspect-ratio: 1;
  border-radius: 50%;
  border: 1px solid rgba(84, 214, 176, 0.35);
  justify-self: center;
  box-shadow: 0 0 0.8rem rgba(84, 214, 176, 0.2);
}

.stats-legend {
  display: grid;
  gap: 0.4rem;
}

.stats-legend-item {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  color: var(--text);
}

.stats-legend-dot {
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
}

.import-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.mt-1 {
  margin-top: 1rem;
}

.splash {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: grid;
  place-items: center;
  background: #020305;
  opacity: 1;
  visibility: visible;
  transition: opacity 560ms ease, visibility 560ms ease;
}

.splash.hidden {
  opacity: 0;
  visibility: hidden;
}

.splash-content {
  position: relative;
  width: min(430px, 88vw);
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 1.4rem;
}

.splash-logo {
  width: 94%;
  height: 94%;
  filter: drop-shadow(0 0 1.45rem rgba(84, 214, 176, 0.55));
  animation: pulse 1.6s ease-in-out infinite;
}

.scanline {
  position: absolute;
  left: 6%;
  width: 88%;
  height: 14%;
  background: linear-gradient(to bottom, rgba(var(--scanner-blue-rgb), 0), rgba(var(--scanner-blue-rgb), 0.48), rgba(var(--scanner-blue-rgb), 0));
  -webkit-mask-image: linear-gradient(to right, transparent 0%, #000 10%, #000 90%, transparent 100%);
  mask-image: linear-gradient(to right, transparent 0%, #000 10%, #000 90%, transparent 100%);
  animation: scan 1.7s linear infinite;
}

.splash-text {
  position: absolute;
  bottom: -2rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
}

.confirm-modal {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
}

.confirm-modal[hidden] {
  display: none;
}

.confirm-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(1, 3, 4, 0.72);
  backdrop-filter: blur(2px);
}

.confirm-card {
  position: relative;
  width: min(500px, calc(100vw - 2rem));
  background:
    linear-gradient(160deg, rgba(84, 214, 176, 0.14), rgba(84, 214, 176, 0) 46%),
    var(--panel);
  border: 1px solid var(--border);
  border-radius: 0.85rem;
  padding: 1rem;
  box-shadow: 0 0 1.6rem rgba(0, 0, 0, 0.5), var(--glow);
  text-align: center;
  display: grid;
  justify-items: center;
}

.confirm-card h3 {
  margin-bottom: 0.55rem;
}

.confirm-card p {
  line-height: 1.5;
  margin-bottom: 0.8rem;
}

.confirm-card .actions,
.confirm-card .actions.left {
  justify-content: center;
}

.pin-form {
  width: min(320px, 100%);
  margin-top: 0.3rem;
}

.pin-error {
  min-height: 1.2rem;
  margin: 0;
  color: #ffd8d8;
  font-size: 0.9rem;
}

@keyframes pulse {
  0%,
  100% {
    transform: scale(1);
    opacity: 0.95;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
  }
}

@keyframes scan {
  0% {
    top: 3%;
  }
  50% {
    top: 84%;
  }
  100% {
    top: 3%;
  }
}

@media (max-width: 920px) {
  .panel-grid.two-cols {
    grid-template-columns: 1fr;
  }

  .profile-item,
  .candidate-item {
    grid-template-columns: 1fr;
  }

  .actions {
    justify-content: flex-start;
  }

  .inline-edit .stack-form {
    grid-template-columns: 1fr;
  }

  .inline-edit label,
  .inline-edit input[type="text"],
  .inline-edit input[type="number"],
  .inline-edit input[type="url"],
  .inline-edit input[type="file"],
  .inline-edit textarea,
  .inline-edit input[type="color"],
  .inline-edit .actions {
    grid-column: span 1;
  }
}
