:root {
  color-scheme: dark;
  --bg: #0a1018;
  --bg-elevated: rgba(17, 24, 36, 0.86);
  --bg-soft: rgba(255, 255, 255, 0.045);
  --bg-strong: rgba(9, 14, 24, 0.92);
  --line: rgba(197, 221, 255, 0.12);
  --text: #f5f7fb;
  --muted: #98a9c0;
  --accent: #f6b24f;
  --accent-2: #74d4c7;
  --accent-soft: rgba(246, 178, 79, 0.18);
  --shadow: 0 30px 80px rgba(0, 0, 0, 0.38);
  --radius: 24px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", "Trebuchet MS", sans-serif;
  background:
    radial-gradient(circle at top left, rgba(246, 178, 79, 0.16), transparent 30%),
    radial-gradient(circle at 82% 18%, rgba(116, 212, 199, 0.13), transparent 24%),
    linear-gradient(180deg, #0b1220 0%, #070b12 100%);
  color: var(--text);
  overflow-x: hidden;
}

.auth-gate {
  position: fixed;
  inset: 0;
  z-index: 12;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(6, 10, 16, 0.72);
  backdrop-filter: blur(18px);
}

.auth-gate-card {
  width: min(460px, 100%);
  padding: 28px;
  border-radius: 28px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(20, 27, 40, 0.98), rgba(11, 15, 24, 0.98));
  box-shadow: var(--shadow);
}

.auth-gate-card h2 {
  margin: 0 0 10px;
}

.auth-form {
  margin-top: 18px;
}

button,
input,
select {
  font: inherit;
}

.hidden {
  display: none !important;
}

.app-shell {
  display: grid;
  grid-template-columns: 320px minmax(0, 1fr);
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

.sidebar {
  padding: 24px;
  border-right: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(10, 14, 22, 0.94), rgba(8, 11, 19, 0.9));
  backdrop-filter: blur(24px);
}

.content {
  padding: 24px;
}

.backdrop-glow {
  position: fixed;
  width: 520px;
  height: 520px;
  border-radius: 50%;
  filter: blur(90px);
  pointer-events: none;
  opacity: 0.55;
}

.glow-left {
  top: -180px;
  left: -140px;
  background: rgba(246, 178, 79, 0.16);
}

.glow-right {
  top: 140px;
  right: -180px;
  background: rgba(116, 212, 199, 0.15);
}

.brand,
.panel,
.hero,
.toolbar,
.entry-card,
.modal-card {
  border: 1px solid var(--line);
  background: var(--bg-elevated);
  box-shadow: var(--shadow);
}

.brand,
.panel,
.hero,
.toolbar,
.modal-card {
  border-radius: var(--radius);
}

.brand,
.panel {
  padding: 20px;
  margin-bottom: 18px;
}

.brand {
  position: relative;
  overflow: hidden;
}

.brand::after {
  content: "";
  position: absolute;
  inset: auto -10% -20% auto;
  width: 180px;
  height: 180px;
  background: radial-gradient(circle, rgba(116, 212, 199, 0.18), transparent 68%);
  pointer-events: none;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.18em;
}

.brand h1,
.hero h2,
.modal-header h3 {
  margin: 0;
  letter-spacing: 0.02em;
}

.brand-copy,
.muted,
.message {
  color: var(--muted);
}

.error {
  color: #ff9c9c;
}

.panel-heading,
.toolbar,
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.roots-list,
.admin-roots-list,
.admin-users-list {
  display: grid;
  gap: 10px;
}

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

.stat-chip {
  padding: 14px 16px;
  border-radius: 18px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.025));
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 1.6rem;
}

.root-card,
.admin-root-card {
  padding: 13px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.025));
}

.admin-root-card {
  display: grid;
  gap: 12px;
}

.root-card.active {
  border-color: rgba(246, 178, 79, 0.45);
  background:
    linear-gradient(180deg, rgba(246, 178, 79, 0.16), rgba(246, 178, 79, 0.06));
}

.root-button,
.entry-button,
.ghost-button,
.primary-button,
.danger-button {
  cursor: pointer;
  border: 0;
}

.root-button,
.entry-button {
  width: 100%;
  padding: 0;
  background: transparent;
  color: inherit;
  text-align: left;
}

.ghost-button,
.primary-button,
.danger-button {
  border-radius: 999px;
  padding: 10px 14px;
  transition: transform 160ms ease, background 160ms ease, border-color 160ms ease;
}

.ghost-button {
  color: var(--text);
  background: rgba(255, 255, 255, 0.055);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.primary-button {
  color: #1a1d22;
  background: linear-gradient(135deg, var(--accent), #ffd38e);
}

.danger-button {
  color: #fff;
  background: rgba(255, 98, 98, 0.2);
  border: 1px solid rgba(255, 98, 98, 0.3);
}

.ghost-button:hover,
.primary-button:hover,
.danger-button:hover {
  transform: translateY(-2px);
}

.ghost-button:disabled,
.primary-button:disabled,
.danger-button:disabled {
  opacity: 0.6;
  cursor: wait;
  transform: none;
}

.toolbar,
.hero {
  padding: 20px 22px;
  margin-bottom: 18px;
}

.toolbar {
  background:
    linear-gradient(180deg, rgba(18, 24, 36, 0.9), rgba(13, 17, 28, 0.9));
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 18px;
  background:
    linear-gradient(130deg, rgba(246, 178, 79, 0.14), transparent 42%),
    linear-gradient(180deg, rgba(17, 24, 36, 0.96), rgba(11, 15, 25, 0.94));
}

.hero-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.hero-badge {
  padding: 10px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  white-space: nowrap;
}

.breadcrumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

.crumb {
  padding: 7px 11px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
}

.toolbar-actions {
  display: flex;
  gap: 10px;
}

.empty-state {
  padding: 54px 22px;
  border-radius: var(--radius);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  text-align: center;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.025);
}

.entries {
  display: grid;
  gap: 18px;
}

.entries-grid {
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
}

.entries-list {
  grid-template-columns: 1fr;
}

.entry-card {
  border-radius: 20px;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease;
}

.entry-card:hover {
  transform: translateY(-4px);
  border-color: rgba(246, 178, 79, 0.2);
  box-shadow: 0 34px 74px rgba(0, 0, 0, 0.42);
}

.entry-button {
  display: grid;
  width: 100%;
  min-width: 0;
}

.entries-list .entry-button {
  grid-template-columns: 220px minmax(0, 1fr);
  align-items: stretch;
}

.entry-preview {
  position: relative;
  aspect-ratio: 16 / 9;
  background:
    linear-gradient(135deg, rgba(246, 178, 79, 0.34), transparent 55%),
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.015));
  overflow: hidden;
}

.entries-list .entry-preview {
  height: 100%;
  min-height: 124px;
  width: 100%;
}

.entry-image,
.entry-fallback {
  width: 100%;
  height: 100%;
}

.entry-image {
  object-fit: cover;
}

.entry-fallback {
  display: grid;
  place-items: center;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.08em;
  background:
    radial-gradient(circle at 20% 30%, rgba(255, 255, 255, 0.08), transparent 30%),
    linear-gradient(180deg, rgba(7, 11, 18, 0.2), rgba(7, 11, 18, 0.5));
}

.entry-meta {
  padding: 14px 16px 18px;
  min-width: 0;
  overflow: hidden;
}

.entry-title,
.entry-subtitle {
  margin: 0;
}

.entry-title {
  font-size: 1rem;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.entry-subtitle {
  margin-top: 8px;
  font-size: 0.92rem;
  overflow-wrap: anywhere;
}

.modal {
  width: min(720px, calc(100vw - 24px));
  border: 0;
  padding: 0;
  background: transparent;
}

.player-modal {
  width: min(1100px, calc(100vw - 24px));
}

.modal::backdrop {
  background: rgba(3, 5, 8, 0.72);
  backdrop-filter: blur(8px);
}

.modal-card {
  padding: 22px;
  background:
    linear-gradient(180deg, rgba(18, 24, 36, 0.96), rgba(10, 14, 23, 0.98));
}

.player-card video {
  width: 100%;
  margin-top: 16px;
  border-radius: 18px;
  background: #000;
  max-height: 75vh;
}

.player-tools {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 14px;
  min-height: 38px;
}

.player-tools .muted {
  margin: 0;
  font-size: 0.9rem;
}

.field {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
}

.field input {
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.field select {
  padding: 13px 14px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
}

.field input:focus {
  outline: none;
  border-color: rgba(246, 178, 79, 0.45);
  box-shadow: 0 0 0 3px rgba(246, 178, 79, 0.12);
}

.field select:focus {
  outline: none;
  border-color: rgba(246, 178, 79, 0.45);
  box-shadow: 0 0 0 3px rgba(246, 178, 79, 0.12);
}

.inset-panel {
  margin-top: 14px;
}

.picker-row {
  display: grid;
  gap: 10px;
  margin-bottom: 14px;
}

.picker-hint {
  margin: 0;
}

.admin-root-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}

.admin-user-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.05), rgba(255, 255, 255, 0.025));
}

.root-access-panel {
  padding: 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
}

.root-access-hint {
  margin: 0 0 12px;
}

.root-access-users {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.root-access-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.025);
}

.root-access-user input {
  width: 18px;
  height: 18px;
}

.root-access-actions {
  margin-top: 14px;
}

.admin-root-meta {
  min-width: 0;
}

.admin-user-meta {
  min-width: 0;
}

.admin-root-meta p {
  margin: 0;
  word-break: break-word;
}

.admin-user-meta p {
  margin: 0;
  word-break: break-word;
}

.admin-user-line {
  margin: 0 0 8px;
}

.role-badge {
  padding: 8px 12px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.04);
  color: var(--muted);
  white-space: nowrap;
}

.browser-modal {
  width: min(960px, calc(100vw - 24px));
}

.browser-card {
  min-height: 70vh;
}

.browser-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 18px 0 12px;
}

.browser-shortcuts {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}

.browser-path {
  padding: 12px 14px;
  border-radius: 16px;
  border: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.03);
  margin-bottom: 14px;
  word-break: break-word;
}

.browser-entries {
  display: grid;
  gap: 12px;
  max-height: 48vh;
  overflow: auto;
  padding-right: 4px;
}

.browser-entry {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.035);
  color: var(--text);
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease;
}

.browser-entry:hover {
  transform: translateY(-1px);
  border-color: rgba(246, 178, 79, 0.25);
  background: rgba(246, 178, 79, 0.08);
}

.browser-entry-icon {
  display: inline-grid;
  place-items: center;
  min-width: 52px;
  height: 52px;
  border-radius: 14px;
  background: linear-gradient(135deg, rgba(246, 178, 79, 0.3), rgba(116, 212, 199, 0.16));
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.browser-entry-text {
  display: grid;
  gap: 4px;
  min-width: 0;
}

.browser-entry-text small {
  word-break: break-word;
}

.browser-empty {
  padding: 18px;
  border-radius: 16px;
  border: 1px dashed var(--line);
  background: rgba(255, 255, 255, 0.025);
}

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

  .sidebar {
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .hero {
    flex-direction: column;
    align-items: stretch;
  }
}

@media (max-width: 640px) {
  .content,
  .sidebar {
    padding: 16px;
  }

  .toolbar,
  .modal-header,
  .panel-heading {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-actions {
    flex-direction: column;
  }

  .entries-list .entry-button {
    grid-template-columns: 1fr;
  }

  .stats-panel {
    grid-template-columns: 1fr;
  }
}
