:root {
  color-scheme: dark;
  --bg: #07111f;
  --panel: rgba(7, 17, 31, 0.72);
  --panel-border: rgba(157, 181, 214, 0.15);
  --text: #edf3ff;
  --muted: #9eafc9;
  --accent-blue: #66b4ff;
  --accent-amber: #ffc96b;
  --accent-green: #65d6a7;
  --accent-red: #ff7e79;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.35);
}

* {
  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(33, 86, 154, 0.35), transparent 35%),
    radial-gradient(circle at bottom right, rgba(43, 160, 125, 0.2), transparent 28%),
    linear-gradient(135deg, #030813, #091628 55%, #0b1f34);
  color: var(--text);
  overflow-x: hidden;
}

main {
  min-height: 100vh;
}

body:not([data-view]) #authScreen,
body[data-view="auth"] #authScreen,
body[data-view="face"] #authScreen {
  display: grid;
}

body[data-view="dashboard"] #authScreen {
  display: none;
}

body:not([data-view]) #appShell,
body[data-view="auth"] #appShell,
body[data-view="face"] #appShell {
  display: none;
}

body[data-view="dashboard"] #appShell {
  display: block;
}

.background-glow {
  position: fixed;
  width: 32rem;
  height: 32rem;
  filter: blur(90px);
  opacity: 0.18;
  pointer-events: none;
}

.glow-a {
  top: -10rem;
  left: -8rem;
  background: #52a2ff;
}

.glow-b {
  right: -10rem;
  bottom: -12rem;
  background: #6be0a6;
}

.shell {
  width: min(1200px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 1.25rem 0 2rem;
}

.auth-screen {
  min-height: 100vh;
  place-items: center;
  padding: 1rem 0;
}

.shell-auth {
  width: min(1100px, calc(100vw - 2rem));
  display: grid;
  gap: 1.25rem;
}

.shell-app {
  animation: rise-in 550ms ease;
  padding-top: 0.5rem;
  padding-bottom: 2rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 24px;
  backdrop-filter: blur(22px);
  box-shadow: var(--shadow);
}

.auth-panel {
  width: min(440px, 100%);
  margin: 0 auto;
  padding: 2rem;
  animation: rise-in 500ms ease;
}

.face-panel {
  width: min(980px, 100%);
  margin: 6vh auto 0;
  padding: 1.75rem;
  animation: rise-in 500ms ease;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.18em;
  font-size: 0.78rem;
  color: var(--muted);
  margin-bottom: 0.75rem;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 3.6rem);
  line-height: 0.95;
}

h2 {
  margin: 0;
}

.lede {
  color: var(--muted);
  max-width: 42rem;
  line-height: 1.55;
}

.login-form {
  display: grid;
  gap: 1rem;
  margin-top: 1.75rem;
}

.login-form label,
.metric-card {
  display: grid;
  gap: 0.45rem;
}

.login-form span,
.metric-label {
  color: var(--muted);
  font-size: 0.92rem;
}

.login-form input {
  width: 100%;
  border: 1px solid rgba(157, 181, 214, 0.18);
  border-radius: 14px;
  background: rgba(3, 10, 18, 0.82);
  padding: 0.95rem 1rem;
  color: var(--text);
  font-size: 1rem;
  outline: none;
}

.login-form input:focus {
  border-color: rgba(102, 180, 255, 0.7);
  box-shadow: 0 0 0 4px rgba(102, 180, 255, 0.12);
}

button {
  cursor: pointer;
  border: 0;
  border-radius: 14px;
  padding: 0.95rem 1.15rem;
  font-size: 1rem;
  font-weight: 700;
  color: #03111d;
  background: linear-gradient(135deg, #8dd2ff, #7df1bf);
}

.ghost-button {
  color: var(--text);
  background: transparent;
  border: 1px solid rgba(157, 181, 214, 0.18);
}

.error-text {
  color: #ff9792;
  margin: 0;
}

.dashboard {
  display: grid;
  gap: 1rem;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  align-items: flex-start;
  padding: 1.35rem;
}

.hero-actions {
  display: flex;
  align-items: center;
  gap: 0.8rem;
}

.status-pill {
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  background: rgba(255, 126, 121, 0.12);
  border: 1px solid rgba(255, 126, 121, 0.28);
  color: #ffb0ab;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  font-size: 0.72rem;
}

.status-pill.live {
  background: rgba(101, 214, 167, 0.12);
  border-color: rgba(101, 214, 167, 0.28);
  color: #aaf0cb;
}

.workspace {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
}

.nav-panel {
  position: sticky;
  top: 1rem;
  padding: 1rem;
}

.nav-list {
  display: grid;
  gap: 0.55rem;
}

.nav-tab {
  width: 100%;
  text-align: left;
  color: var(--text);
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(157, 181, 214, 0.14);
}

.nav-tab.is-active {
  color: #03111d;
  border-color: transparent;
  background: linear-gradient(135deg, #8dd2ff, #7df1bf);
}

.tab-stack {
  display: grid;
}

.tab-panel {
  display: none;
  gap: 1rem;
}

.tab-panel.is-active {
  display: grid;
}

.grid {
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  gap: 1rem;
}

.metric-card {
  min-height: 170px;
  padding: 1.3rem;
  grid-column: span 4;
}

.metric-card:nth-child(5),
.metric-card:nth-child(6),
.metric-card:nth-child(7) {
  grid-column: span 4;
}

.metric-value {
  font-size: clamp(2rem, 4vw, 3.2rem);
  font-weight: 700;
  line-height: 1;
}

.metric-value.small {
  font-size: clamp(1.2rem, 3vw, 1.8rem);
  line-height: 1.25;
}

.progress-track {
  margin-top: auto;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.07);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, rgba(255,255,255,0.28), rgba(255,255,255,0.88));
  transition: width 360ms ease;
}

.face-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 1rem;
  margin-top: 1.5rem;
}

.video-shell {
  position: relative;
  min-height: 360px;
  border-radius: 22px;
  overflow: hidden;
  background: linear-gradient(180deg, rgba(6, 13, 25, 0.9), rgba(13, 31, 52, 0.9));
  border: 1px solid rgba(157, 181, 214, 0.15);
}

.video-shell::after {
  content: "";
  position: absolute;
  inset: 12%;
  border: 2px solid rgba(141, 210, 255, 0.45);
  border-radius: 26px;
  pointer-events: none;
}

#faceVideo {
  width: 100%;
  height: 100%;
  min-height: 360px;
  object-fit: cover;
  transform: scaleX(-1);
}

.face-controls {
  display: grid;
  align-content: start;
  gap: 1rem;
}

.face-hint {
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.button-row {
  display: flex;
  gap: 0.8rem;
  flex-wrap: wrap;
}

.face-settings,
.admin-panel,
.logs-panel {
  padding: 1.35rem;
}

.face-settings {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.admin-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 1rem;
  margin-bottom: 1rem;
}

.subtle-text {
  color: var(--muted);
  margin: 0 0 1rem;
}

.admin-list {
  display: grid;
  gap: 0.9rem;
}

.admin-summary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

.files-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.7rem;
  margin-bottom: 1rem;
}

.file-select {
  min-width: 220px;
  border: 1px solid rgba(157, 181, 214, 0.18);
  border-radius: 14px;
  background: rgba(3, 10, 18, 0.82);
  padding: 0.8rem 0.95rem;
  color: var(--text);
  font-size: 0.96rem;
}

.path-pill {
  margin-bottom: 1rem;
  padding: 0.85rem 1rem;
  border-radius: 16px;
  border: 1px solid rgba(157, 181, 214, 0.12);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  word-break: break-all;
}

.upload-progress {
  margin-bottom: 1rem;
  display: grid;
  gap: 0.45rem;
}

.upload-progress-head {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.upload-progress-track {
  margin-top: 0;
}

.file-dropzone {
  margin-bottom: 1rem;
  padding: 1rem;
  border-radius: 18px;
  border: 1px dashed rgba(141, 210, 255, 0.35);
  background: rgba(102, 180, 255, 0.05);
  color: var(--muted);
  text-align: center;
}

.file-dropzone.is-dragover {
  border-color: rgba(101, 214, 167, 0.55);
  background: rgba(101, 214, 167, 0.08);
  color: var(--text);
}

.files-list .admin-item {
  grid-template-columns: minmax(0, 1fr);
}

.file-name-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.file-icon {
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 12px;
  display: grid;
  place-items: center;
  font-size: 0.85rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(157, 181, 214, 0.14);
  color: var(--muted);
}

.file-icon.is-directory {
  color: #aaf0cb;
  border-color: rgba(101, 214, 167, 0.28);
  background: rgba(101, 214, 167, 0.1);
}

.admin-item {
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid rgba(157, 181, 214, 0.12);
  background: rgba(255, 255, 255, 0.03);
}

.admin-item-head {
  display: flex;
  justify-content: space-between;
  align-items: start;
  gap: 0.75rem;
}

.admin-item h3 {
  margin: 0;
  font-size: 1rem;
}

.admin-item p {
  margin: 0.2rem 0 0;
  color: var(--muted);
  line-height: 1.4;
}

.admin-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.tag {
  padding: 0.35rem 0.65rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(157, 181, 214, 0.14);
  color: var(--muted);
  font-size: 0.82rem;
}

.tag.is-active {
  color: #aaf0cb;
  border-color: rgba(101, 214, 167, 0.28);
  background: rgba(101, 214, 167, 0.1);
}

.tag.is-failed,
.tag.is-exited {
  color: #ffb0ab;
  border-color: rgba(255, 126, 121, 0.28);
  background: rgba(255, 126, 121, 0.1);
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.admin-actions button {
  padding: 0.7rem 0.9rem;
  font-size: 0.92rem;
}

.preview-modal {
  position: fixed;
  inset: 0;
  z-index: 30;
  display: grid;
  place-items: center;
  padding: 1rem;
}

.preview-modal[hidden] {
  display: none !important;
}

.preview-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(3, 10, 18, 0.72);
}

.preview-panel {
  position: relative;
  z-index: 1;
  width: min(960px, calc(100vw - 2rem));
  max-height: calc(100vh - 2rem);
  overflow: auto;
  padding: 1.35rem;
}

.preview-head {
  margin-bottom: 0.75rem;
}

.preview-image {
  width: 100%;
  max-height: 70vh;
  object-fit: contain;
  border-radius: 18px;
  border: 1px solid rgba(157, 181, 214, 0.12);
  background: rgba(3, 10, 18, 0.82);
}

.preview-text {
  min-height: 360px;
  max-height: 70vh;
}

.logs-output {
  margin: 0;
  min-height: 280px;
  max-height: 540px;
  overflow: auto;
  padding: 1rem;
  border-radius: 18px;
  border: 1px solid rgba(157, 181, 214, 0.12);
  background: rgba(3, 10, 18, 0.82);
  color: #d8e5ff;
  font: 0.9rem/1.5 Consolas, "Courier New", monospace;
  white-space: pre-wrap;
}

.browser-firefox .background-glow {
  filter: blur(42px);
  opacity: 0.1;
}

.browser-firefox .panel {
  backdrop-filter: none;
  background: rgba(7, 17, 31, 0.92);
}

.browser-firefox .progress-fill {
  transition: none;
}

.browser-firefox .shell-app,
.browser-firefox .auth-panel,
.browser-firefox .face-panel {
  animation: none;
}

.accent-blue .metric-value { color: var(--accent-blue); }
.accent-amber .metric-value { color: var(--accent-amber); }
.accent-green .metric-value { color: var(--accent-green); }
.accent-red .metric-value { color: var(--accent-red); }

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 900px) {
  .auth-screen {
    align-items: start;
  }

  .hero {
    flex-direction: column;
  }

  .hero-actions {
    width: 100%;
    justify-content: space-between;
  }

  .workspace {
    grid-template-columns: 1fr;
  }

  .nav-panel {
    position: static;
  }

  .nav-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .metric-card,
  .metric-card:nth-child(5),
  .metric-card:nth-child(6),
  .metric-card:nth-child(7) {
    grid-column: span 12;
  }

  .face-layout,
  .face-settings {
    display: grid;
    grid-template-columns: 1fr;
  }

  .admin-head,
  .admin-item-head {
    grid-template-columns: 1fr;
    display: grid;
  }

  .preview-panel {
    width: calc(100vw - 1rem);
    padding: 1rem;
  }
}
