:root {
  --bg-deep: #05080f;
  --bg: #08111c;
  --bg-elevated: #0d1a2a;
  --bg-panel: rgba(12, 28, 46, 0.72);
  --line: rgba(140, 190, 220, 0.14);
  --line-strong: rgba(160, 210, 235, 0.28);
  --text: #e8f0f6;
  --text-muted: #8fa6b8;
  --text-dim: #5f7588;
  --accent: #5ec8e8;
  --accent-soft: rgba(94, 200, 232, 0.14);
  --accent-strong: #9ae0f5;
  --warn: #e8b85e;
  --danger: #e86a6a;
  --ok: #5ed4a2;
  --font-display: "Syne", "Segoe UI", sans-serif;
  --font-body: "IBM Plex Sans", "Segoe UI", sans-serif;
  --font-mono: "IBM Plex Mono", ui-monospace, monospace;
  --radius: 2px;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: var(--font-body);
  background:
    radial-gradient(1200px 700px at 12% -10%, rgba(40, 110, 150, 0.28), transparent 55%),
    radial-gradient(900px 600px at 90% 10%, rgba(20, 70, 100, 0.22), transparent 50%),
    linear-gradient(180deg, var(--bg-deep) 0%, var(--bg) 45%, #06101a 100%);
  background-attachment: fixed;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    linear-gradient(rgba(120, 180, 210, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(120, 180, 210, 0.04) 1px, transparent 1px);
  background-size: 48px 48px;
  mask-image: radial-gradient(ellipse at center, black 30%, transparent 80%);
  z-index: 0;
}

a {
  color: var(--accent-strong);
  text-decoration: none;
}

a:hover {
  color: #fff;
}

.shell {
  position: relative;
  z-index: 1;
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}

.sidebar {
  border-right: 1px solid var(--line);
  background: rgba(5, 10, 18, 0.78);
  backdrop-filter: blur(12px);
  padding: 1.75rem 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  animation: rise 0.7s ease both;
}

.brand-mark {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.55rem;
  letter-spacing: -0.03em;
  line-height: 1.05;
  color: #fff;
}

.brand-mark span {
  color: var(--accent);
}

.brand-sub {
  font-size: 0.72rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.nav {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.7rem 0.85rem;
  color: var(--text-muted);
  border: 1px solid transparent;
  border-radius: var(--radius);
  transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.2s;
}

.nav a:hover {
  color: var(--text);
  background: var(--accent-soft);
  border-color: var(--line);
  transform: translateX(2px);
}

.nav a.active {
  color: #fff;
  background: linear-gradient(90deg, rgba(94, 200, 232, 0.18), transparent);
  border-color: var(--line-strong);
}

.nav-ico {
  width: 1.1rem;
  text-align: center;
  opacity: 0.8;
  font-size: 0.85rem;
}

.sidebar-foot {
  margin-top: auto;
  font-size: 0.75rem;
  color: var(--text-dim);
  line-height: 1.5;
}

.main {
  padding: 1.75rem 2rem 3rem;
  max-width: 1280px;
}

.page-head {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.75rem;
  animation: rise 0.55s ease both;
}

.page-head h1 {
  margin: 0;
  font-family: var(--font-display);
  font-size: clamp(1.8rem, 3vw, 2.4rem);
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.1;
}

.page-head p {
  margin: 0.45rem 0 0;
  color: var(--text-muted);
  max-width: 42rem;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
  margin-bottom: 1.75rem;
}

.metric {
  position: relative;
  overflow: hidden;
  padding: 1.2rem 1.25rem;
  border: 1px solid var(--line);
  background: var(--bg-panel);
  backdrop-filter: blur(10px);
  animation: rise 0.65s ease both;
}

.metric:nth-child(2) { animation-delay: 0.06s; }
.metric:nth-child(3) { animation-delay: 0.12s; }
.metric:nth-child(4) { animation-delay: 0.18s; }

.metric::after {
  content: "";
  position: absolute;
  inset: auto -20% -40% auto;
  width: 120px;
  height: 120px;
  background: radial-gradient(circle, rgba(94, 200, 232, 0.18), transparent 70%);
  pointer-events: none;
}

.metric-label {
  font-size: 0.72rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.metric-value {
  margin-top: 0.55rem;
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.metric-hint {
  margin-top: 0.35rem;
  font-size: 0.8rem;
  color: var(--text-dim);
}

.panel {
  border: 1px solid var(--line);
  background: var(--bg-panel);
  backdrop-filter: blur(10px);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
  animation: rise 0.7s ease both;
}

.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.panel-title h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.table-wrap {
  overflow-x: auto;
}

table.data {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

table.data th,
table.data td {
  text-align: left;
  padding: 0.75rem 0.65rem;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

table.data th {
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  font-weight: 500;
}

table.data tr:hover td {
  background: rgba(94, 200, 232, 0.04);
}

.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid var(--line);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
  background: rgba(0, 0, 0, 0.25);
}

.badge.ok { color: var(--ok); border-color: rgba(94, 212, 162, 0.35); }
.badge.warn { color: var(--warn); border-color: rgba(232, 184, 94, 0.35); }
.badge.error, .badge.danger { color: var(--danger); border-color: rgba(232, 106, 106, 0.35); }
.badge.missing { color: var(--text-dim); }

.btn {
  appearance: none;
  border: 1px solid var(--line-strong);
  background: linear-gradient(180deg, rgba(94, 200, 232, 0.18), rgba(94, 200, 232, 0.06));
  color: #fff;
  font-family: var(--font-body);
  font-size: 0.82rem;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  transition: transform 0.15s, background 0.2s, border-color 0.2s;
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(94, 200, 232, 0.28), rgba(94, 200, 232, 0.1));
  transform: translateY(-1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-ghost {
  background: transparent;
  border-color: var(--line);
  color: var(--text-muted);
}

.btn-danger {
  border-color: rgba(232, 106, 106, 0.4);
  background: rgba(232, 106, 106, 0.12);
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

select,
input[type="search"] {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
}

.media-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.25rem;
}

.project-list {
  max-height: calc(100vh - 10rem);
  overflow-y: auto;
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
}

.project-item {
  display: block;
  padding: 0.9rem 1rem;
  border-bottom: 1px solid var(--line);
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s;
}

.project-item:hover,
.project-item.active {
  background: var(--accent-soft);
  color: var(--text);
}

.project-item .pid {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--accent);
}

.project-item .ptitle {
  display: block;
  margin-top: 0.25rem;
  font-size: 0.9rem;
  color: inherit;
}

.player-shell {
  border: 1px solid var(--line);
  background: #000;
  overflow: hidden;
  box-shadow: var(--shadow);
}

.player-shell video {
  display: block;
  width: 100%;
  max-height: 52vh;
  background: #000;
}

.scene-block {
  border-left: 2px solid var(--accent);
  padding: 0.75rem 0 0.75rem 1rem;
  margin: 0.75rem 0;
}

.scene-block h4 {
  margin: 0 0 0.35rem;
  font-size: 0.85rem;
  color: var(--accent-strong);
}

.scene-block p {
  margin: 0.25rem 0;
  color: var(--text-muted);
  font-size: 0.88rem;
  line-height: 1.45;
}

.ass-preview {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  line-height: 1.45;
  white-space: pre-wrap;
  max-height: 280px;
  overflow: auto;
  padding: 0.9rem;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--line);
  color: #b8c8d4;
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 1rem;
}

.status-card {
  border: 1px solid var(--line);
  background: rgba(0, 0, 0, 0.22);
  padding: 1.1rem 1.2rem;
}

.status-card h3 {
  margin: 0 0 0.35rem;
  font-family: var(--font-display);
  font-size: 1.05rem;
}

.status-card .detail {
  color: var(--text-muted);
  font-size: 0.85rem;
  margin: 0.5rem 0 0;
}

.meta-list {
  margin: 0;
  padding: 0;
  list-style: none;
}

.meta-list li {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.55rem 0;
  border-bottom: 1px solid var(--line);
  font-size: 0.85rem;
}

.meta-list .k { color: var(--text-muted); }
.meta-list .v {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--text);
  text-align: right;
  word-break: break-all;
}

.toast {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 50;
  min-width: 260px;
  max-width: 420px;
  padding: 0.9rem 1rem;
  border: 1px solid var(--line-strong);
  background: rgba(8, 18, 30, 0.95);
  box-shadow: var(--shadow);
  transform: translateY(120%);
  opacity: 0;
  transition: transform 0.35s ease, opacity 0.35s ease;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast .t-title {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.toast .t-body {
  color: var(--text-muted);
  font-size: 0.82rem;
}

.empty {
  color: var(--text-dim);
  padding: 1.5rem 0;
  text-align: center;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 980px) {
  .shell {
    grid-template-columns: 1fr;
  }

  .sidebar {
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding-bottom: 1rem;
  }

  .nav {
    flex-direction: row;
    flex-wrap: wrap;
  }

  .sidebar-foot {
    display: none;
  }

  .metrics {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .media-layout,
  .status-grid {
    grid-template-columns: 1fr;
  }

  .main {
    padding: 1.25rem 1rem 2.5rem;
  }
}

.tts-form {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin: 1rem 0 0.75rem;
}

.tts-form label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.02em;
}

.tts-form select,
.tts-form input {
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--line);
  color: var(--text);
  padding: 0.55rem 0.75rem;
  font-family: var(--font-body);
  font-size: 0.85rem;
  width: 100%;
}

.tts-actions {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-top: 0.25rem;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: grid;
  place-items: center;
  padding: 1.25rem;
}

.modal[hidden] {
  display: none !important;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(2, 6, 12, 0.72);
  backdrop-filter: blur(4px);
}

.modal-panel {
  position: relative;
  z-index: 1;
  width: min(520px, 100%);
  border: 1px solid var(--line-strong);
  background: rgba(8, 18, 30, 0.96);
  box-shadow: var(--shadow);
  padding: 1.25rem 1.35rem 1.4rem;
  animation: rise 0.35s ease both;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
}

.modal-head h2 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 1.2rem;
}

.modal .tts-form {
  grid-template-columns: 1fr;
}

@media (max-width: 900px) {
  .tts-form {
    grid-template-columns: 1fr;
  }
}
