:root {
  color-scheme: light;
  --bg: #f6f7f9;
  --panel: #ffffff;
  --ink: #171a1f;
  --muted: #626a76;
  --line: #d9dee7;
  --primary: #0f766e;
  --primary-dark: #115e59;
  --danger: #b42318;
  --ok: #087443;
  --warn: #9a6700;
  --shadow: 0 16px 48px rgba(23, 26, 31, 0.08);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  background: var(--bg);
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body.controller-view {
  background: #05070a;
  color: white;
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 40px;
  border: 1px solid transparent;
  border-radius: 8px;
  background: var(--primary);
  color: white;
  cursor: pointer;
  font-weight: 650;
  padding: 0 14px;
}

button:hover {
  background: var(--primary-dark);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.48;
}

button.secondary {
  background: white;
  border-color: var(--line);
  color: var(--ink);
}

button.secondary:hover {
  background: #eef1f5;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  outline: none;
}

input {
  height: 42px;
  padding: 0 12px;
  text-transform: uppercase;
}

textarea {
  min-height: 112px;
  resize: vertical;
  padding: 12px;
  line-height: 1.45;
  text-transform: none;
}

input:focus,
textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.15);
}

.app-shell {
  min-height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr;
}

.topbar {
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(14px);
  position: sticky;
  top: 0;
  z-index: 10;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.brand-mark {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: conic-gradient(from 180deg, #0f766e, #2563eb, #7c3aed, #0f766e);
}

.brand h1 {
  margin: 0;
  font-size: 17px;
  line-height: 1.2;
}

.nav-links {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-links a {
  border-radius: 8px;
  color: var(--muted);
  font-size: 14px;
  font-weight: 650;
  padding: 8px 10px;
  text-decoration: none;
}

.nav-links a.active {
  background: #e8f5f3;
  color: var(--primary-dark);
}

.workspace {
  width: min(1440px, 100%);
  margin: 0 auto;
  padding: 24px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 380px;
  gap: 20px;
}

.workspace.client {
  grid-template-columns: 380px minmax(0, 1fr);
}

.control-stage {
  min-height: 100vh;
  background: #05070a;
  position: relative;
}

.immersive-video {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #05070a;
}

.immersive-video::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(90deg, rgba(5, 7, 10, 0.54), transparent 34%, rgba(5, 7, 10, 0.72)),
    linear-gradient(180deg, rgba(5, 7, 10, 0.36), transparent 28%, rgba(5, 7, 10, 0.46));
  pointer-events: none;
}

.controller-view video {
  width: 100vw;
  height: 100vh;
  min-height: 100vh;
  object-fit: cover;
}

.control-hud {
  position: fixed;
  left: 24px;
  top: 24px;
  z-index: 2;
  display: grid;
  gap: 12px;
  max-width: min(520px, calc(100vw - 420px));
}

.control-hud:empty {
  display: none;
}

.room-chip {
  width: max-content;
  min-width: 172px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(8, 12, 18, 0.62);
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.28);
  backdrop-filter: blur(18px);
  padding: 12px 14px;
}

.room-chip span {
  display: block;
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 650;
}

.room-chip strong {
  display: block;
  margin-top: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 30px;
  line-height: 1;
  letter-spacing: 0.08em;
}

.status-row.glass {
  width: fit-content;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(8, 12, 18, 0.54);
  backdrop-filter: blur(18px);
  padding: 8px;
}

.floating-dock {
  position: fixed;
  top: 50%;
  right: 24px;
  bottom: auto;
  z-index: 3;
  width: 320px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow: visible;
  transform: translateY(-50%);
}

.dock-nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.dock-nav a {
  display: grid;
  place-items: center;
  min-height: 38px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(8, 12, 18, 0.54);
  color: rgba(255, 255, 255, 0.72);
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  backdrop-filter: blur(18px);
}

.dock-nav a.active {
  background: rgba(15, 118, 110, 0.86);
  border-color: rgba(255, 255, 255, 0.2);
  color: white;
}

.dock-card {
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(8, 12, 18, 0.66);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.3);
  backdrop-filter: blur(18px);
  padding: 14px;
}

.pairing-panel {
  gap: 14px;
}

.pairing-panel .room-chip strong {
  font-size: 42px;
}

.task-picker {
  gap: 12px;
}

.task-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.task-select {
  position: relative;
}

.task-select summary {
  min-height: 44px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(15, 118, 110, 0.9);
  color: white;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
  list-style: none;
}

.task-select summary::-webkit-details-marker {
  display: none;
}

.task-option-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 10px;
}

.task-option {
  min-height: 86px;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 6px;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.09);
  padding: 10px 8px;
}

.task-option:hover {
  background: rgba(15, 118, 110, 0.9);
}

.task-option span {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.76);
  font-size: 12px;
  font-weight: 800;
}

.task-option strong {
  color: white;
  font-size: 13px;
  line-height: 1.2;
}

.dock-details,
.panel-details {
  padding: 0;
}

.dock-details summary,
.panel-details summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  font-size: 14px;
  font-weight: 750;
  list-style: none;
  padding: 0 14px;
}

.dock-details summary::-webkit-details-marker,
.panel-details summary::-webkit-details-marker {
  display: none;
}

.dock-details summary::after,
.panel-details summary::after {
  content: "+";
  color: currentColor;
  font-size: 18px;
  line-height: 1;
}

.dock-details[open] summary::after,
.panel-details[open] summary::after {
  content: "-";
}

.dock-details summary {
  color: rgba(255, 255, 255, 0.78);
}

.panel-details summary {
  color: var(--ink);
}

.details-body {
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  padding: 14px;
}

.panel-details .details-body {
  border-top-color: var(--line);
}

.inline-room {
  width: 100%;
}

.mini-menu {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 5;
}

.mini-menu > summary {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(8, 12, 18, 0.68);
  box-shadow: 0 14px 42px rgba(0, 0, 0, 0.28);
  color: white;
  cursor: pointer;
  font-size: 16px;
  font-weight: 900;
  list-style: none;
  backdrop-filter: blur(18px);
}

.mini-menu > summary::-webkit-details-marker {
  display: none;
}

.mini-menu-panel {
  width: 300px;
  display: grid;
  gap: 12px;
  margin-top: 10px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(8, 12, 18, 0.78);
  box-shadow: 0 18px 52px rgba(0, 0, 0, 0.34);
  backdrop-filter: blur(18px);
  padding: 12px;
}

.mini-group {
  display: grid;
  gap: 10px;
}

.mini-group h2 {
  margin: 0;
  color: rgba(255, 255, 255, 0.74);
  font-size: 13px;
}

.mini-room {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.08);
  padding: 10px;
}

.mini-room span {
  color: rgba(255, 255, 255, 0.62);
  font-size: 12px;
  font-weight: 700;
}

.mini-room strong {
  color: white;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 18px;
  letter-spacing: 0.08em;
}

.dock-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.dock-title h2 {
  margin: 0;
  color: white;
  font-size: 14px;
}

.controller-view label {
  color: rgba(255, 255, 255, 0.68);
}

.controller-view textarea,
.controller-view input {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.controller-view textarea::placeholder {
  color: rgba(255, 255, 255, 0.42);
}

.controller-view button.secondary {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.09);
  color: white;
}

.controller-view button.secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.controller-view button.danger-action {
  border-color: rgba(248, 113, 113, 0.42);
  background: rgba(127, 29, 29, 0.42);
  color: #ffe7e7;
}

.controller-view button.danger-action:hover {
  background: rgba(153, 27, 27, 0.58);
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.panel-header {
  min-height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--line);
}

.panel-header h2 {
  margin: 0;
  font-size: 15px;
}

.panel-body {
  padding: 16px;
}

.video-wrap {
  overflow: hidden;
  background: #0a0f14;
  border-radius: 8px;
  min-height: 520px;
  position: relative;
}

video {
  width: 100%;
  height: 100%;
  min-height: 520px;
  display: block;
  object-fit: cover;
  background: #0a0f14;
}

.video-empty {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #cad2dc;
  font-size: 14px;
  pointer-events: none;
}

.status-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 28px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
  padding: 0 10px;
  white-space: nowrap;
}

.pill.ok {
  border-color: rgba(8, 116, 67, 0.24);
  background: rgba(8, 116, 67, 0.08);
  color: var(--ok);
}

.pill.warn {
  border-color: rgba(154, 103, 0, 0.24);
  background: rgba(154, 103, 0, 0.08);
  color: var(--warn);
}

.pill.danger {
  border-color: rgba(180, 35, 24, 0.24);
  background: rgba(180, 35, 24, 0.08);
  color: var(--danger);
}

.stack {
  display: grid;
  gap: 14px;
}

.inline {
  display: flex;
  gap: 8px;
}

.inline > input {
  flex: 1;
}

.room-code {
  display: grid;
  place-items: center;
  min-height: 92px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.task-list {
  display: grid;
  gap: 10px;
  max-height: 360px;
  overflow: auto;
}

.current-task {
  min-height: 96px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--ink);
  padding: 12px;
  line-height: 1.5;
  white-space: pre-wrap;
}

.current-task.empty {
  display: grid;
  place-items: center;
  color: var(--muted);
}

.controller-view .current-task {
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: white;
}

.controller-view .current-task.empty {
  color: rgba(255, 255, 255, 0.48);
}

.task-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #fbfcfd;
}

.task-item p {
  margin: 0 0 10px;
  line-height: 1.45;
  white-space: pre-wrap;
}

.task-meta {
  color: var(--muted);
  font-size: 12px;
}

.log {
  min-height: 120px;
  max-height: 220px;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  padding: 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.controller-view .log {
  min-height: 96px;
  max-height: 180px;
  border-color: rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
  color: rgba(255, 255, 255, 0.7);
}

.log div + div {
  margin-top: 6px;
}

label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 650;
}

@media (max-width: 960px) {
  .workspace,
  .workspace.client {
    grid-template-columns: 1fr;
    padding: 16px;
  }

  .topbar {
    height: auto;
    min-height: 64px;
    align-items: flex-start;
    flex-direction: column;
    padding: 14px 16px;
  }

  .video-wrap,
  video {
    min-height: 360px;
  }

  body.controller-view {
    overflow: auto;
  }

  .immersive-video,
  .floating-dock {
    position: relative;
    inset: auto;
  }

  .control-stage {
    display: grid;
    min-height: 100vh;
  }

  .immersive-video {
    min-height: 56vh;
  }

  .controller-view video {
    width: 100%;
    height: 56vh;
    min-height: 56vh;
  }

  .control-hud {
    position: absolute;
    left: 16px;
    top: 16px;
    max-width: calc(100% - 32px);
  }

  .floating-dock {
    width: auto;
    margin: -18px 16px 16px;
    overflow: visible;
    transform: none;
  }

  .mini-menu {
    top: 16px;
    right: 16px;
  }

  .mini-menu-panel {
    width: min(300px, calc(100vw - 32px));
  }
}

@media (max-width: 560px) {
  .inline {
    flex-direction: column;
  }

  .room-code {
    font-size: 28px;
  }
}
