/* Magneterie — dark cinematic UI */
:root {
  --bg: #100e0c;
  --bg-elev: #1b1713;
  --bg-elev-2: #241f1a;
  --line: rgba(243, 236, 228, 0.1);
  --text: #f3ece4;
  --muted: #a3988c;
  --accent: #e8a54b;
  --accent-2: #ff6b4a;
  --accent-soft: rgba(232, 165, 75, 0.16);
  --danger: #ff7a6e;
  --danger-bg: rgba(255, 122, 110, 0.12);
  --ok: #8ad4a6;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  --radius: 18px;
  --font: "Manrope", "Segoe UI", sans-serif;
  --display: "Fraunces", Georgia, serif;
}

*, *::before, *::after { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

.bg {
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(900px 500px at 10% -10%, rgba(232, 165, 75, 0.14), transparent 55%),
    radial-gradient(700px 420px at 100% 0%, rgba(255, 107, 74, 0.1), transparent 50%),
    repeating-linear-gradient(
      180deg,
      transparent,
      transparent 3px,
      rgba(0, 0, 0, 0.08) 3px,
      rgba(0, 0, 0, 0.08) 4px
    );
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 880px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.header { margin-bottom: 4px; }

.brand {
  display: flex;
  gap: 14px;
  align-items: center;
}

.brand img {
  border-radius: 10px;
  box-shadow: 0 0 0 1px var(--line);
}

h1 {
  font-family: var(--display);
  font-weight: 620;
  font-size: clamp(1.6rem, 3vw, 2.15rem);
  letter-spacing: -0.03em;
  margin: 0;
  line-height: 1.15;
}

.tagline {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.95rem;
}

.card, .player-wrap {
  background: linear-gradient(180deg, var(--bg-elev), #161310);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 22px;
  box-shadow: var(--shadow);
}

label:not(.file-btn):not(.switch) {
  display: block;
  font-weight: 600;
  font-size: 0.86rem;
  margin-bottom: 8px;
  color: var(--muted);
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

textarea {
  width: 100%;
  resize: vertical;
  min-height: 110px;
  background: #0d0b0a;
  color: var(--text);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 14px;
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  font-size: 0.86rem;
  line-height: 1.45;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
  align-items: center;
  justify-content: space-between;
}

.file-btn, .primary, .text-btn {
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
}

.file-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--bg-elev-2);
  color: var(--text);
  font-size: 0.9rem;
}

.file-btn:hover { border-color: rgba(243, 236, 228, 0.28); }

.demo-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 1rem;
  margin-top: 0.4rem;
}


.file-btn input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.primary {
  border: 0;
  background: linear-gradient(180deg, #f0b45d, var(--accent));
  color: #1a1208;
  padding: 11px 22px;
  border-radius: 999px;
  font-size: 0.98rem;
  box-shadow: 0 8px 20px rgba(232, 165, 75, 0.25);
}

.primary:hover { filter: brightness(1.06); }
.primary:disabled {
  opacity: 0.55;
  cursor: wait;
  filter: none;
}

.mode-row { margin-top: 18px; }

.switch {
  display: flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  font-weight: 500;
  user-select: none;
}

.switch input { position: absolute; opacity: 0; width: 0; height: 0; }

.track {
  width: 42px;
  height: 24px;
  border-radius: 999px;
  background: #3a332c;
  position: relative;
  flex: 0 0 auto;
  transition: background 0.15s;
}

.track::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f3ece4;
  top: 3px;
  left: 3px;
  transition: transform 0.15s;
}

.switch input:focus-visible + .track {
  box-shadow: 0 0 0 3px var(--accent-soft);
}

.switch input:checked + .track { background: var(--accent); }
.switch input:checked + .track::after { transform: translateX(18px); }

.hint {
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.88rem;
}

.hint strong { color: var(--text); font-weight: 600; }

.text-btn {
  margin-top: 12px;
  background: none;
  border: 0;
  color: var(--accent);
  padding: 0;
  font-size: 0.92rem;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.text-btn:hover { color: #ffc16a; }

.player-wrap { display: flex; flex-direction: column; gap: 16px; }

[hidden] { display: none !important; }

.video-shell {
  position: relative;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 16 / 9;
  box-shadow: inset 0 0 0 1px var(--line);
}

video {
  width: 100%;
  height: 100%;
  display: block;
  background: #000;
}

.bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 4px;
  background: rgba(255, 255, 255, 0.12);
}

.bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-2), var(--accent));
  transition: width 0.25s linear;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
}

.stat {
  background: var(--bg-elev-2);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
}

.stat .label {
  display: block;
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.stat .value {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 0.98rem;
}

.status {
  font-size: 0.92rem;
  color: var(--muted);
  min-height: 1.2em;
}

.status.ok { color: var(--ok); }

.error {
  background: var(--danger-bg);
  color: var(--danger);
  border: 1px solid rgba(255, 122, 110, 0.25);
  border-radius: 12px;
  padding: 12px 14px;
  font-size: 0.92rem;
}

.files-wrap h3 {
  margin: 0 0 10px;
  font-size: 0.86rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  font-weight: 600;
}

.files {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.files li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #14110e;
  font-size: 0.9rem;
}

.files li.playable { cursor: pointer; }
.files li.playable:hover { border-color: rgba(232, 165, 75, 0.45); }
.files li.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.files .meta { color: var(--muted); font-variant-numeric: tabular-nums; white-space: nowrap; }
.files .name { word-break: break-all; }

.footer {
  margin-top: auto;
  text-align: center;
  color: var(--muted);
  font-size: 0.82rem;
  padding: 8px 4px 0;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 640px) {
  .app { padding: 20px 14px 32px; }
  .card, .player-wrap { padding: 16px; }
  .stats { grid-template-columns: repeat(2, 1fr); }
  .actions { flex-direction: column; align-items: stretch; }
  .primary, .file-btn { justify-content: center; text-align: center; }
  .brand { align-items: flex-start; }
}

.switch.disabled {
  opacity: 0.55;
  cursor: not-allowed;
}
.switch.disabled input { cursor: not-allowed; }
.offline-note { margin-top: 8px; }
