/* Il pannello visivo della Sala resta scuro: logo bianco sempre. */
.gate-brand .logo-dark { display: block !important; }
.gate-brand .logo-light { display: none !important; }

:root {
  --bg: #050607;
  --panel: #0b0c0e;
  --panel-2: #111315;
  --line: #23262a;
  --line-soft: #171a1d;
  --text: #f3efe7;
  --muted: #a7a9aa;
  --dim: #73767a;
  --lime: #c6f24e;
  --lime-strong: #d8ff66;
  --lime-fill: #c6f24e;
  --lime-fill-strong: #d8ff66;
  --ink: #08090a;
  --sand: #e4c795;
  --red: #ff7669;
  --serif: "Iowan Old Style", "Palatino Linotype", "Book Antiqua", ui-serif, Georgia, serif;
  --sans: -apple-system, BlinkMacSystemFont, "SF Pro Text", "Helvetica Neue", Arial, sans-serif;
  --mono: "SF Mono", ui-monospace, Menlo, monospace;
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  overflow-x: hidden;
}

::selection {
  background: rgba(198, 242, 78, 0.25);
  color: #fff;
}

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

button {
  color: inherit;
}

a {
  color: var(--lime);
}

.sala {
  min-height: 100vh;
}

.loading-screen {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background:
    radial-gradient(700px 400px at 50% 20%, rgba(198, 242, 78, 0.06), transparent 70%),
    var(--bg);
}

.loading-mark {
  display: flex;
  align-items: center;
  justify-content: center;
  animation: breathe 2s ease-in-out infinite;
}

.loading-mark .logo-img { height: 34px; max-width: 150px; }

.loading-line {
  width: 140px;
  height: 1px;
  background: linear-gradient(90deg, transparent, var(--lime), transparent);
  animation: scan 1.6s ease-in-out infinite;
}

.loading-text {
  color: var(--dim);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

@keyframes breathe {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(0.94); opacity: 0.72; }
}

@keyframes scan {
  0%, 100% { opacity: 0.2; transform: scaleX(0.35); }
  50% { opacity: 1; transform: scaleX(1); }
}

.gate {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(460px, 0.9fr);
  min-height: 100vh;
}

.gate-visual {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 46px 54px 48px;
  background:
    radial-gradient(900px 500px at 10% 5%, rgba(198, 242, 78, 0.1), transparent 62%),
    radial-gradient(700px 500px at 95% 95%, rgba(228, 199, 149, 0.08), transparent 60%),
    linear-gradient(145deg, #11130d, #08090a 68%);
}

.gate-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: blur(26px) saturate(0.85) brightness(0.42);
  transform: scale(1.1);
  opacity: 0;
  transition: opacity 0.8s ease;
}

.gate-bg.ready {
  opacity: 1;
}

.gate-visual::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(5, 6, 7, 0.68), rgba(5, 6, 7, 0.2) 60%, rgba(5, 6, 7, 0.55)),
    linear-gradient(to top, rgba(5, 6, 7, 0.92), transparent 55%);
  z-index: 1;
}

.gate-visual::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.028) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.018) 1px, transparent 1px);
  background-size: 80px 80px;
  mask-image: radial-gradient(circle at 25% 25%, black, transparent 78%);
}

.gate-brand {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 12px;
}

.theme-toggle {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}

.theme-toggle:hover {
  color: var(--text);
  background: var(--panel-2);
  border-color: #3a3e44;
}

.theme-toggle svg {
  width: 14px;
  height: 14px;
}

.gate-brand .theme-toggle {
  margin-left: auto;
  border-color: rgba(255, 255, 255, 0.18);
  background: rgba(8, 9, 10, 0.35);
  color: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
}

.gate-brand .theme-toggle:hover {
  background: rgba(8, 9, 10, 0.55);
  border-color: rgba(255, 255, 255, 0.32);
  color: #fff;
}

.brand-mark {
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.logo-img {
  height: 26px;
  width: auto;
  max-width: 110px;
  object-fit: contain;
  display: none;
}

.logo-dark { display: none; }
.logo-light { display: none; }

:root:not([data-theme="light"]) .logo-dark { display: block; }
:root[data-theme="light"] .logo-light { display: block; }

.gate-brand .brand-mark .logo-img { height: 30px; max-width: 130px; }
.player-brand .brand-mark .logo-img { height: 24px; max-width: 100px; }

.brand-name {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.brand-sub {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.45);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.2em;
}

.gate-content {
  position: relative;
  z-index: 2;
  max-width: 680px;
  margin: 50px 0;
}

.gate-kicker {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 18px;
  padding: 5px 10px;
  border: 1px solid rgba(198, 242, 78, 0.24);
  border-radius: 999px;
  background: rgba(198, 242, 78, 0.07);
  color: var(--lime);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.gate-kicker .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--lime);
}

.gate-title {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(44px, 6vw, 86px);
  font-weight: 500;
  line-height: 0.94;
  letter-spacing: -0.045em;
  text-shadow: 0 4px 40px rgba(0, 0, 0, 0.35);
}

.gate-description {
  max-width: 540px;
  margin: 20px 0 0;
  color: #b3b4ae;
  font-size: 14px;
  line-height: 1.65;
}

.gate-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 22px;
  margin-top: 30px;
}

.gate-meta-item {
  min-width: 100px;
}

.gate-meta-label {
  color: rgba(255, 255, 255, 0.4);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.gate-meta-value {
  margin-top: 4px;
  font-size: 12px;
  color: #e7e3da;
}

.gate-foot {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  color: rgba(255, 255, 255, 0.38);
  font-size: 9.5px;
  letter-spacing: 0.06em;
}

.gate-foot strong {
  color: rgba(255, 255, 255, 0.62);
  font-weight: 600;
}

.gate-panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 44px clamp(24px, 5vw, 64px);
  border-left: 1px solid var(--line-soft);
  background:
    radial-gradient(600px 300px at 80% 0%, rgba(198, 242, 78, 0.035), transparent 65%),
    #0a0b0d;
}

.gate-card {
  width: min(440px, 100%);
}

.gate-step {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 18px;
}

.step {
  width: 24px;
  height: 3px;
  border-radius: 999px;
  background: #26292d;
}

.step.active {
  background: var(--lime);
}

.step.done {
  background: rgba(198, 242, 78, 0.42);
}

.gate-card h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 500;
  line-height: 1.05;
  letter-spacing: -0.03em;
}

.gate-card .lead {
  margin: 10px 0 24px;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.6;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 13px;
}

.field label {
  color: var(--muted);
  font-size: 9.5px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.input {
  width: 100%;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #08090a;
  color: var(--text);
  font-size: 13px;
  outline: none;
  transition: border-color 0.16s ease, box-shadow 0.16s ease;
}

.input::placeholder {
  color: #4f5358;
}

.input:focus {
  border-color: rgba(198, 242, 78, 0.5);
  box-shadow: 0 0 0 3px rgba(198, 242, 78, 0.07);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 17px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel-2);
  color: var(--text);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, transform 0.16s ease;
}

.btn:hover {
  background: #191b1e;
  border-color: #3a3e43;
}

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--lime-fill);
  border-color: var(--lime-fill);
  color: var(--ink);
}

.btn-primary:hover {
  background: var(--lime-fill-strong);
  border-color: var(--lime-fill-strong);
}

.btn-block {
  width: 100%;
}

.btn-ghost {
  background: transparent;
}

.btn svg {
  width: 15px;
  height: 15px;
}

.gate-error {
  margin-bottom: 14px;
  padding: 10px 12px;
  border: 1px solid rgba(255, 118, 105, 0.3);
  border-radius: 9px;
  background: rgba(255, 118, 105, 0.07);
  color: #ffb0a8;
  font-size: 11.5px;
  line-height: 1.5;
}

.gate-error:empty {
  display: none;
}

.nda-wrap {
  margin: 0 0 14px;
  border: 1px solid var(--line);
  border-radius: 11px;
  background: #08090a;
  overflow: hidden;
}

.nda-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.nda-text {
  max-height: 190px;
  overflow: auto;
  padding: 12px 13px;
  color: #a9aba6;
  font-size: 10.5px;
  line-height: 1.55;
  white-space: pre-wrap;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  margin: 0 0 15px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.5;
  cursor: pointer;
}

.check input {
  margin: 2px 0 0;
  accent-color: var(--lime);
  flex: none;
}

.check b {
  color: var(--text);
  font-weight: 600;
}

.rules {
  margin: 0 0 16px;
  padding: 12px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.018);
  color: var(--dim);
  font-size: 10.5px;
  line-height: 1.6;
}

.rules b {
  color: var(--muted);
  font-weight: 600;
}

.gate-note {
  margin-top: 14px;
  color: #55595e;
  font-size: 9.5px;
  line-height: 1.6;
  text-align: center;
}

.gate-secure {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  margin-top: 18px;
  color: #5f6368;
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.gate-secure svg {
  width: 12px;
  height: 12px;
}

/* ------------------------------------------------------------------ */
/* Player                                                              */
/* ------------------------------------------------------------------ */

.player {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #050607;
  overflow: hidden;
}

.player-top {
  display: flex;
  align-items: center;
  gap: 18px;
  height: 64px;
  padding: 0 22px;
  border-bottom: 1px solid var(--line-soft);
  background: rgba(8, 9, 10, 0.86);
  backdrop-filter: blur(16px);
  flex: none;
}

.player-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
}

.player-brand .brand-mark {
  width: auto;
  height: auto;
}

.player-brand .brand-name {
  font-size: 11.5px;
}

.player-brand .brand-sub {
  font-size: 8px;
}

.player-title {
  min-width: 0;
  padding-left: 18px;
  border-left: 1px solid var(--line-soft);
}

.player-title h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 17px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-title p {
  margin: 1px 0 0;
  color: var(--dim);
  font-size: 9.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-top .spacer {
  flex: 1;
}

.secure-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 9px;
  border: 1px solid rgba(198, 242, 78, 0.22);
  border-radius: 999px;
  background: rgba(198, 242, 78, 0.06);
  color: #cbe784;
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.secure-pill .dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--lime);
}

.player-exit {
  padding: 7px 11px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 10.5px;
  cursor: pointer;
}

.player-exit:hover {
  color: var(--text);
  background: var(--panel-2);
}

.player-main {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
}

.stage-wrap {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 16px 18px 14px;
}

.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border: 1px solid #1a1d20;
  border-radius: 14px;
  background: #000;
}

.stage video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background: #000;
  outline: none;
}

.stage video::-webkit-media-controls-panel {
  background-image: linear-gradient(transparent, rgba(0, 0, 0, 0.72));
}

.play-overlay {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  background:
    radial-gradient(500px 300px at 50% 50%, rgba(0, 0, 0, 0.12), rgba(0, 0, 0, 0.48)),
    transparent;
  cursor: pointer;
  transition: opacity 0.2s ease;
}

.play-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.play-button {
  width: 74px;
  height: 74px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(8, 9, 10, 0.5);
  color: #fff;
  backdrop-filter: blur(12px);
  transition: transform 0.18s ease, background 0.18s ease;
}

.play-overlay:hover .play-button {
  transform: scale(1.05);
  background: rgba(198, 242, 78, 0.16);
  border-color: rgba(198, 242, 78, 0.5);
}

.play-button svg {
  width: 28px;
  height: 28px;
  margin-left: 3px;
}

.stage-loading {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: none;
  place-items: center;
  background: rgba(5, 6, 7, 0.68);
  backdrop-filter: blur(4px);
}

.stage-loading.visible {
  display: grid;
}

.spinner {
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--lime);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.stage-error {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 24px;
  text-align: center;
  background: rgba(5, 6, 7, 0.92);
}

.stage-error.visible {
  display: flex;
}

.stage-error h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: 22px;
  font-weight: 500;
}

.stage-error p {
  max-width: 400px;
  margin: 0;
  color: var(--dim);
  font-size: 11.5px;
  line-height: 1.6;
}

.watermark {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}

.watermark span {
  position: absolute;
  display: block;
  white-space: nowrap;
  color: rgba(255, 255, 255, 0.24);
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
  transform: rotate(-24deg);
  transform-origin: center;
  opacity: 0.7;
}

.stage-caption {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
  padding: 0 2px;
}

.stage-caption h2 {
  margin: 0;
  font-size: 12.5px;
  font-weight: 600;
}

.stage-caption p {
  margin: 1px 0 0;
  color: var(--dim);
  font-size: 9.5px;
}

.stage-caption .spacer {
  flex: 1;
}

.stage-caption .meta {
  color: var(--dim);
  font-size: 9px;
  font-family: var(--mono);
  white-space: nowrap;
}

.approve-bar {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: none;
  padding: 10px 13px;
  border: 1px solid var(--line-soft);
  border-radius: 11px;
  background: linear-gradient(90deg, rgba(198, 242, 78, 0.055), rgba(255, 255, 255, 0.015));
}

.approve-bar .text {
  min-width: 0;
  flex: 1;
}

.approve-bar .text b {
  display: block;
  color: var(--text);
  font-size: 10.5px;
  font-weight: 600;
}

.approve-bar .text span {
  display: block;
  margin-top: 1px;
  color: var(--dim);
  font-size: 9.5px;
}

.approve-bar .btn {
  flex: none;
  padding: 8px 12px;
  font-size: 10.5px;
}

.player-side {
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-left: 1px solid var(--line-soft);
  background: #090a0b;
}

.side-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.side-head .label {
  color: var(--dim);
  font-size: 8.5px;
  font-weight: 700;
  letter-spacing: 0.17em;
  text-transform: uppercase;
}

.side-head .count {
  color: var(--muted);
  font-size: 10px;
}

.playlist {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 6px;
}

.playlist-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 8px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.playlist-item:hover {
  background: rgba(255, 255, 255, 0.03);
}

.playlist-item.active {
  border-color: rgba(198, 242, 78, 0.18);
  background: rgba(198, 242, 78, 0.065);
}

.playlist-thumb {
  position: relative;
  width: 76px;
  height: 43px;
  flex: none;
  overflow: hidden;
  border-radius: 5px;
  background: linear-gradient(135deg, #191c16, #0c0e0f);
  border: 1px solid #232629;
}

.playlist-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.playlist-item.active .playlist-thumb {
  border-color: rgba(198, 242, 78, 0.35);
}

.playlist-info {
  min-width: 0;
  flex: 1;
}

.playlist-name {
  display: block;
  font-size: 10.5px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-meta {
  display: block;
  margin-top: 2px;
  color: var(--dim);
  font-size: 8.5px;
}

.playlist-item.active .playlist-name {
  color: #e7f8bd;
}

.side-foot {
  flex: none;
  padding: 12px 16px 16px;
  border-top: 1px solid var(--line-soft);
  color: #5a5e63;
  font-size: 8.5px;
  line-height: 1.65;
}

.side-foot b {
  color: var(--muted);
  font-weight: 600;
}

.side-foot .mono {
  font-family: var(--mono);
  font-size: 8px;
  letter-spacing: 0.04em;
}

/* ------------------------------------------------------------------ */
/* Chiusura / errore                                                   */
/* ------------------------------------------------------------------ */

.closed-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 32px;
  background:
    radial-gradient(700px 420px at 50% 15%, rgba(198, 242, 78, 0.055), transparent 70%),
    var(--bg);
}

.closed-card {
  width: min(480px, 100%);
  padding: 38px 34px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.022), transparent), var(--panel);
  box-shadow: 0 40px 100px rgba(0, 0, 0, 0.45);
  text-align: center;
}

.closed-icon {
  width: 54px;
  height: 54px;
  margin: 0 auto 18px;
  border: 1px solid rgba(198, 242, 78, 0.24);
  border-radius: 16px;
  display: grid;
  place-items: center;
  background: rgba(198, 242, 78, 0.07);
  color: var(--lime);
}

.closed-icon svg {
  width: 23px;
  height: 23px;
}

.closed-card h1 {
  margin: 0;
  font-family: var(--serif);
  font-size: 34px;
  font-weight: 500;
  letter-spacing: -0.035em;
}

.closed-card p {
  margin: 12px 0 0;
  color: var(--dim);
  font-size: 12px;
  line-height: 1.65;
}

.closed-code {
  display: inline-block;
  margin-top: 18px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: #5f6368;
  font-family: var(--mono);
  font-size: 8.5px;
  letter-spacing: 0.08em;
}

.closed-actions {
  display: flex;
  justify-content: center;
  gap: 9px;
  margin-top: 24px;
}

.closed-foot {
  margin-top: 26px;
  color: #4f5358;
  font-size: 9px;
  line-height: 1.6;
}

.sala-toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  z-index: 300;
  transform: translateX(-50%);
  max-width: min(440px, calc(100vw - 40px));
  padding: 11px 15px;
  border: 1px solid rgba(198, 242, 78, 0.3);
  border-radius: 10px;
  background: #141711;
  color: var(--text);
  font-size: 11.5px;
  line-height: 1.5;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.45);
  transition: opacity 0.2s ease, transform 0.2s ease;
}

@media (max-width: 1100px) {
  .gate {
    grid-template-columns: 1fr;
  }
  .gate-visual {
    min-height: 52vh;
    padding: 34px 30px;
  }
  .gate-panel {
    border-left: 0;
    border-top: 1px solid var(--line-soft);
    padding: 38px 24px 50px;
  }
  .gate-content {
    margin: 44px 0 30px;
  }
  .gate-foot {
    display: none;
  }
  .player-main {
    grid-template-columns: 220px minmax(0, 1fr);
  }
}

@media (max-width: 820px) {
  .player {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }
  .player-top {
    height: 56px;
    padding: 0 14px;
  }
  .player-title {
    padding-left: 12px;
  }
  .secure-pill {
    display: none;
  }
  .player-main {
    display: flex;
    flex-direction: column;
  }
  .stage-wrap {
    padding: 10px;
    gap: 8px;
  }
  .stage {
    flex: none;
    height: 46vh;
    min-height: 260px;
  }
  .player-tree {
    border-right: 0;
    border-bottom: 1px solid var(--line-soft);
    max-height: 30vh;
  }
  .playlist {
    max-height: 38vh;
  }
  .gate-title {
    font-size: clamp(40px, 12vw, 64px);
  }
  .gate-meta {
    gap: 16px;
  }
  .gate-panel {
    padding: 32px 20px 44px;
  }
  .approve-bar {
    flex-wrap: wrap;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ------------------------------------------------------------------ */
/* Tema chiaro                                                         */
/* ------------------------------------------------------------------ */

:root[data-theme="light"] {
  --bg: #edf2f7;
  --panel: #ffffff;
  --panel-2: #f4f8fc;
  --line: #cbd8e5;
  --line-soft: #dfe8f1;
  --text: #111a24;
  --muted: #46586b;
  --dim: #5a6d80;
  --lime: #0f5fa8;
  --lime-strong: #0a4b87;
  --lime-fill: #0b6cb8;
  --lime-fill-strong: #095a9b;
  --ink: #ffffff;
  --sand: #526b82;
  --red: #b23a48;
}

:root[data-theme="light"] ::selection {
  background: rgba(0, 127, 201, 0.18);
  color: var(--text);
}

:root[data-theme="light"] .gate-visual {
  --text: #f4f8fc;
  --muted: #a9b8c8;
  --dim: #8fa2b5;
  --lime: #7ec8ff;
  --lime-strong: #b5e2ff;
  background:
    radial-gradient(900px 500px at 10% 5%, rgba(0, 159, 227, 0.18), transparent 62%),
    radial-gradient(700px 500px at 95% 95%, rgba(31, 99, 184, 0.14), transparent 60%),
    linear-gradient(145deg, #0e1a26, #070b10 68%);
  color: var(--text);
}

:root[data-theme="light"] .gate-panel {
  border-left-color: var(--line-soft);
  background:
    radial-gradient(600px 300px at 80% 0%, rgba(0, 159, 227, 0.05), transparent 65%),
    var(--bg);
}

:root[data-theme="light"] .step {
  background: #d3dee9;
}

:root[data-theme="light"] .input {
  background: #ffffff;
  border-color: var(--line);
}

:root[data-theme="light"] .input::placeholder {
  color: #8a9bad;
}

:root[data-theme="light"] .input:focus {
  border-color: rgba(0, 127, 201, 0.55);
  box-shadow: 0 0 0 3px rgba(0, 127, 201, 0.1);
}

:root[data-theme="light"] .btn {
  background: var(--panel-2);
  border-color: var(--line);
}

:root[data-theme="light"] .btn:hover {
  background: #e7eef6;
  border-color: #c0cfdf;
}

:root[data-theme="light"] .btn-ghost {
  background: transparent;
}

:root[data-theme="light"] .gate-error {
  color: var(--red);
  border-color: rgba(178, 58, 72, 0.28);
  background: rgba(178, 58, 72, 0.07);
}

:root[data-theme="light"] .nda-wrap {
  background: #ffffff;
  border-color: var(--line);
}

:root[data-theme="light"] .nda-text {
  color: var(--muted);
}

:root[data-theme="light"] .rules {
  border-color: var(--line);
  background: rgba(17, 26, 36, 0.025);
}

:root[data-theme="light"] .gate-note,
:root[data-theme="light"] .gate-secure {
  color: var(--dim);
}

:root[data-theme="light"] .player {
  background: var(--bg);
}

:root[data-theme="light"] .player-top {
  background: rgba(237, 242, 247, 0.9);
  border-bottom-color: var(--line-soft);
}

:root[data-theme="light"] .secure-pill {
  color: var(--lime);
  border-color: rgba(15, 95, 168, 0.25);
  background: rgba(0, 159, 227, 0.07);
}

:root[data-theme="light"] .player-exit {
  border-color: var(--line);
}

:root[data-theme="light"] .player-exit:hover {
  background: var(--panel-2);
  border-color: #c0cfdf;
}

:root[data-theme="light"] .theme-toggle:hover {
  border-color: #c0cfdf;
  background: rgba(17, 26, 36, 0.045);
}

:root[data-theme="light"] .stage {
  border-color: var(--line);
}

:root[data-theme="light"] .approve-bar {
  border-color: var(--line-soft);
  background: linear-gradient(90deg, rgba(0, 159, 227, 0.07), rgba(0, 0, 0, 0.015));
}

:root[data-theme="light"] .player-side {
  background: var(--panel);
  border-left-color: var(--line-soft);
}

:root[data-theme="light"] .playlist-item:hover {
  background: rgba(17, 26, 36, 0.03);
}

:root[data-theme="light"] .playlist-item.active {
  border-color: rgba(15, 95, 168, 0.22);
  background: rgba(0, 159, 227, 0.08);
}

:root[data-theme="light"] .playlist-thumb {
  background: linear-gradient(135deg, #eef4fa, #dfe8f1);
  border-color: var(--line);
}

:root[data-theme="light"] .playlist-item.active .playlist-thumb {
  border-color: rgba(15, 95, 168, 0.38);
}

:root[data-theme="light"] .playlist-item.active .playlist-name {
  color: var(--lime);
}

:root[data-theme="light"] .side-foot {
  color: var(--dim);
}

:root[data-theme="light"] .closed-screen {
  background:
    radial-gradient(700px 420px at 50% 15%, rgba(0, 159, 227, 0.08), transparent 70%),
    var(--bg);
}

:root[data-theme="light"] .closed-card {
  background: var(--panel);
  border-color: var(--line);
  box-shadow: 0 40px 100px rgba(20, 35, 55, 0.18);
}

:root[data-theme="light"] .closed-code,
:root[data-theme="light"] .closed-foot {
  color: var(--dim);
}

:root[data-theme="light"] .sala-toast {
  background: var(--panel);
  border-color: rgba(15, 95, 168, 0.3);
  box-shadow: 0 18px 40px rgba(20, 35, 55, 0.16);
}

/* Rifiniture del design system chiaro: elimina le tracce del vecchio lime. */
:root[data-theme="light"] .loading-screen {
  background:
    radial-gradient(700px 400px at 50% 20%, rgba(0, 159, 227, 0.08), transparent 70%),
    var(--bg);
}

:root[data-theme="light"] .gate-kicker {
  border-color: rgba(126, 200, 255, 0.28);
  background: rgba(0, 159, 227, 0.1);
}

:root[data-theme="light"] .step.done {
  background: rgba(126, 200, 255, 0.42);
}

:root[data-theme="light"] .secure-pill {
  border-color: rgba(15, 95, 168, 0.25);
  background: rgba(0, 159, 227, 0.07);
  color: var(--lime);
}

:root[data-theme="light"] .play-overlay:hover .play-button {
  background: rgba(0, 159, 227, 0.18);
  border-color: rgba(126, 200, 255, 0.55);
}

:root[data-theme="light"] .closed-icon {
  border-color: rgba(15, 95, 168, 0.24);
  background: rgba(0, 159, 227, 0.07);
}

:root[data-theme="light"] .btn-primary {
  background: var(--lime-fill);
  border-color: var(--lime-fill);
  color: var(--ink);
}

:root[data-theme="light"] .btn-primary:hover {
  background: var(--lime-fill-strong);
  border-color: var(--lime-fill-strong);
  color: var(--ink);
}

/* ------------------------------------------------------------------ */
/* Albero contenuti + viewer (invito ristrutturato)                    */
/* ------------------------------------------------------------------ */

.player-main {
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
  min-height: 0;
  flex: 1;
}

.player-tree {
  display: flex;
  flex-direction: column;
  min-height: 0;
  border-right: 1px solid var(--line-soft);
  background: rgba(8, 9, 10, 0.55);
  overflow: auto;
}

.tree-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 14px 10px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--muted);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.tree-head .count {
  font-family: var(--mono);
  color: var(--dim);
}

.tree-group {
  padding: 8px 8px 4px;
}

.tree-group-title {
  padding: 6px 8px 4px;
  color: var(--dim);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.tree-item {
  display: grid;
  grid-template-columns: 18px minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 8px;
  margin-bottom: 2px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font-size: 11.5px;
  cursor: pointer;
  text-align: left;
}

.tree-item:hover {
  background: rgba(255, 255, 255, 0.035);
  border-color: var(--line-soft);
}

.tree-item.active {
  background: rgba(198, 242, 78, 0.08);
  border-color: rgba(198, 242, 78, 0.28);
}

.tree-item .tree-icon {
  color: var(--lime);
  display: flex;
  align-items: center;
  justify-content: center;
}

.tree-item .tree-icon svg {
  width: 14px;
  height: 14px;
}

.tree-item .tree-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tree-item .tree-meta {
  color: var(--dim);
  font-size: 9px;
  font-family: var(--mono);
  white-space: nowrap;
}

.tree-empty {
  padding: 8px 10px;
  color: var(--dim);
  font-size: 11px;
  font-style: italic;
}

.viewer-pane {
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.drawing-viewer {
  display: flex;
  flex-direction: column;
  height: 100%;
  min-height: 0;
}

.drawing-viewer .drawing-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line-soft);
}

.drawing-viewer .drawing-head h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.drawing-viewer .drawing-head .meta {
  color: var(--dim);
  font-size: 10px;
  font-family: var(--mono);
}

.drawing-viewer .drawing-body {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  overflow: auto;
  background: rgba(0, 0, 0, 0.18);
}

.drawing-viewer .drawing-body img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 8px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
}

.drawing-viewer .drawing-body iframe {
  width: 100%;
  height: 100%;
  border: 0;
  border-radius: 8px;
  background: #fff;
}

:root[data-theme="light"] .player-tree {
  background: rgba(237, 242, 247, 0.7);
}

:root[data-theme="light"] .tree-item:hover {
  background: rgba(17, 26, 36, 0.04);
}

:root[data-theme="light"] .tree-item.active {
  background: rgba(0, 159, 227, 0.1);
  border-color: rgba(0, 127, 201, 0.28);
}
