:root {
  --wood-dark: #2c1a0e;
  --wood-mid: #4a2c17;
  --metal-bg: #22201d;
  --metal-panel: #2b2824;
  --metal-border: #6e6454;
  --text: #eae2d3;
  --muted: #9e9585;
  --gold: #f0be6a;
  --green: #7ce8ac;
  --red: #f27a6c;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  height: 100dvh;
  overflow: hidden;
  background: #060606;
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

/* Mobile Safari minimal-chrome fullscreen mode: allows a 1px scroll nudge to collapse URL/tab bars */
html.mobile-fs, body.mobile-fs {
  overflow-y: auto;
  overscroll-behavior: none;
  min-height: calc(100dvh + 2px);
}

body.mobile-fs #legal-badge {
  display: none !important;
}

#crt {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  cursor: grab;
  touch-action: manipulation;
}

#crt:active {
  cursor: grabbing;
}

#video {
  position: fixed;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.hidden {
  display: none !important;
}

body.embed-mode #drawer-tab,
body.embed-mode #drawer,
body.embed-mode #remote,
body.embed-mode #legal-badge {
  display: none !important;
}

/* Subtle bottom-left non-hosting legal badge */
#legal-badge {
  position: fixed;
  left: max(12px, env(safe-area-inset-left));
  bottom: max(10px, env(safe-area-inset-bottom));
  z-index: 35;
  background: rgba(18, 16, 14, 0.72);
  border: 1px solid rgba(110, 100, 84, 0.45);
  border-radius: 999px;
  padding: 4px 10px;
  color: var(--muted);
  font-size: 11px;
  cursor: pointer;
  opacity: 0.42;
  transition: opacity 0.2s, border-color 0.15s, color 0.15s;
  backdrop-filter: blur(4px);
}

#legal-badge:hover {
  opacity: 1;
  border-color: var(--gold);
  color: var(--text);
}

#legal-badge span {
  color: var(--gold);
  text-decoration: underline;
}

/* Floating status pills */
.pill {
  position: fixed;
  left: 50%;
  transform: translateX(-50%);
  padding: 7px 16px;
  border-radius: 999px;
  background: rgba(24, 21, 18, 0.88);
  border: 1px solid rgba(212, 166, 94, 0.65);
  color: var(--gold);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  z-index: 40;
  backdrop-filter: blur(6px);
}

#sound-pill {
  bottom: 24px;
  cursor: pointer;
}

#sound-pill:hover {
  background: rgba(42, 36, 28, 0.95);
}

#toast {
  top: 20px;
  pointer-events: none;
}

/* Drag & drop overlay */
#drop-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10, 8, 6, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  pointer-events: none;
}

.drop-box {
  border: 2px dashed var(--gold);
  border-radius: 12px;
  padding: 36px 48px;
  text-align: center;
  background: rgba(28, 24, 20, 0.92);
}

.drop-title {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
  letter-spacing: 0.08em;
}

.drop-sub {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

/* WebGPU error modal */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 8, 0.86);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 90;
}

.modal-card {
  max-width: 440px;
  padding: 24px 28px;
  border-radius: 10px;
  background: var(--metal-bg);
  border: 1px solid var(--metal-border);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.7);
}

.modal-card h2 {
  margin: 0 0 10px;
  color: var(--gold);
  font-size: 18px;
}

.legal-card {
  max-width: 520px;
  width: calc(100vw - 32px);
  max-height: calc(100vh - 48px);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.modal-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid #3c362e;
  padding-bottom: 8px;
}

.modal-hdr h2 {
  margin: 0;
}

.legal-body {
  overflow-y: auto;
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--text);
  display: flex;
  flex-direction: column;
  gap: 9px;
  user-select: text;
}

.legal-body p {
  margin: 0;
}

.legal-body code {
  background: #151311;
  border: 1px solid #3a342c;
  border-radius: 3px;
  padding: 1px 4px;
  font-size: 11.5px;
  color: var(--gold);
}

.modal-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid #3c362e;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* Right-edge pull tab */
#drawer-tab {
  position: fixed;
  right: env(safe-area-inset-right, 0px);
  top: 50%;
  transform: translateY(-50%);
  width: 24px;
  height: 88px;
  border: 1px solid var(--metal-border);
  border-right: none;
  border-radius: 7px 0 0 7px;
  background: linear-gradient(180deg, var(--wood-mid), var(--wood-dark));
  color: var(--text);
  cursor: pointer;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.42;
  transition: opacity 0.2s, right 0.22s cubic-bezier(0.22, 1, 0.36, 1), border-color 0.15s;
}

#drawer-tab:hover,
body.drawer-open #drawer-tab {
  opacity: 1;
  border-color: var(--gold);
  color: var(--gold);
}

body.drawer-open #drawer-tab {
  right: min(320px, calc(100vw - 28px));
}

body.drawer-open .tab-chevron {
  transform: rotate(180deg);
}

.tab-chevron {
  font-size: 20px;
  line-height: 1;
  transition: transform 0.22s;
}

/* Slide-in Quick Menu */
#drawer {
  position: fixed;
  top: 0;
  right: -326px;
  width: min(320px, calc(100vw - 28px));
  height: 100%;
  height: 100dvh;
  z-index: 45;
  padding: 4px calc(6px + env(safe-area-inset-right, 0px)) calc(4px + env(safe-area-inset-bottom, 0px)) 6px;
  background: repeating-linear-gradient(
    90deg,
    #3f2514 0px,
    #4e2f19 3px,
    #382010 6px
  );
  box-shadow: -8px 0 28px rgba(0, 0, 0, 0.65);
  transition: right 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

body.drawer-open #drawer {
  right: 0;
}

.drawer-inner {
  width: 100%;
  height: 100%;
  background: linear-gradient(180deg, #272522, #1d1b19);
  border: 1px solid #8a7e6a;
  border-radius: 3px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 9px 11px;
  border-bottom: 1px solid #3c3730;
  background: #201e1b;
}

.brand {
  font-weight: 800;
  font-size: 13px;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.brand small {
  font-weight: 500;
  color: var(--muted);
  letter-spacing: 0;
  margin-left: 4px;
}

.header-actions {
  display: flex;
  gap: 5px;
}

.drawer-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 10px 11px 14px;
  display: flex;
  flex-direction: column;
  gap: 11px;
}

.group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-bottom: 9px;
  border-bottom: 1px solid #332f29;
}

.group-title {
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--gold);
}

.row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.row.wrap {
  flex-wrap: wrap;
}

.row.checks {
  gap: 12px;
  font-size: 12px;
}

.row.checks label {
  display: flex;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}

.lbl {
  font-size: 12px;
  color: var(--muted);
  width: 46px;
  flex-shrink: 0;
}

input[type="url"], input[type="text"], select {
  flex: 1;
  min-width: 0;
  background: #161412;
  border: 1px solid #4d463c;
  border-radius: 4px;
  color: var(--text);
  padding: 5px 7px;
  font-size: 12px;
  user-select: text;
}

input[type="url"]:focus, input[type="text"]:focus, select:focus {
  outline: none;
  border-color: var(--gold);
}

.btn {
  background: #332f2a;
  color: var(--text);
  border: 1px solid #595044;
  border-radius: 4px;
  padding: 5px 9px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background 0.12s, border-color 0.12s;
}

.btn:hover {
  background: #413b34;
  border-color: #9e8c72;
}

.btn.sm {
  padding: 4px 8px;
  font-size: 11.5px;
}

.btn.accent {
  border-color: #6b9f7e;
  color: var(--green);
}

.btn.active {
  background: #463a26;
  border-color: var(--gold);
  color: var(--gold);
}

.btn.danger {
  border-color: #7c4740;
  color: var(--red);
}

.btn.danger:hover {
  background: #442320;
  border-color: var(--red);
}

.file-btn {
  display: inline-flex;
  align-items: center;
}

.channel-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 2px;
}

.chip {
  background: #1b1916;
  color: #cfc6b5;
  border: 1px solid #453f37;
  border-radius: 999px;
  padding: 3px 9px;
  font-size: 11px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.chip:hover, .chip.active {
  border-color: var(--green);
  color: var(--green);
}

.chip-del {
  color: var(--muted);
  font-weight: 700;
  padding: 0 2px;
  margin-left: 1px;
}

.chip-del:hover {
  color: var(--red);
}

.legal-note {
  margin-top: 4px;
  padding-top: 6px;
  border-top: 1px solid #332f29;
  color: var(--muted);
  line-height: 1.4;
}

.link-btn {
  background: none;
  border: none;
  padding: 0;
  margin-left: 4px;
  color: var(--gold);
  font-size: 11px;
  text-decoration: underline;
  cursor: pointer;
}

.link-btn:hover {
  color: var(--text);
}

.slider-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
}

.slider-row span {
  width: 68px;
  color: var(--muted);
  flex-shrink: 0;
}

.slider-row.disabled {
  opacity: 0.38;
  cursor: not-allowed;
}

.slider-row.disabled input[type="range"] {
  pointer-events: none;
}

input[type="range"] {
  flex: 1;
  accent-color: var(--gold);
}

.drawer-footer {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
}

.cta-card {
  background: linear-gradient(180deg, rgba(64, 46, 26, 0.32), rgba(26, 23, 19, 0.45));
  border: 1px solid rgba(240, 190, 106, 0.38);
  border-radius: 6px;
  padding: 8px 9px;
}

.cta-sub {
  font-size: 11px;
  line-height: 1.38;
  color: #ccc3b3;
}

.cta-btn {
  background: #23382b;
  border-color: #6db387;
  color: var(--green);
}

.cta-btn:hover {
  background: #2b4736;
  border-color: var(--green);
}

.cta-uri {
  font-size: 10px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  word-break: break-all;
  user-select: text;
}

.muted {
  color: var(--muted);
}

/* Clickable Retro TV Remote */
.remote {
  position: fixed;
  left: 22px;
  top: 64px;
  width: 236px;
  padding: 10px;
  border-radius: 8px;
  background: linear-gradient(180deg, #2a2723, #1c1a17);
  border: 1px solid #7d705c;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.72);
  z-index: 60;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.remote-hdr {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--gold);
  padding-bottom: 4px;
  border-bottom: 1px solid #3c362e;
}

.icon-x {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
}

.icon-x:hover {
  color: var(--text);
}

.rem-grid {
  display: grid;
  gap: 6px;
}

.rem-grid.cols-3 {
  grid-template-columns: repeat(3, 1fr);
}

.rem-grid.cols-2 {
  grid-template-columns: repeat(2, 1fr);
}

.rbtn {
  background: #332f2a;
  color: var(--text);
  border: 1px solid #574e42;
  border-radius: 4px;
  padding: 6px 4px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.rbtn:hover {
  background: #423c35;
  border-color: var(--gold);
}

.rbtn.pwr {
  color: var(--red);
  border-color: #7c4740;
}

.rem-sep {
  height: 1px;
  background: #3a342d;
}

.rem-tip {
  font-size: 10.5px;
  color: var(--muted);
  line-height: 1.35;
}
