/* Shroud — True-black flat (dark) app screen styling */

@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Inter";
  src: url("/fonts/inter-600.woff2") format("woff2");
  font-weight: 600;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-400.woff2") format("woff2");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "JetBrains Mono";
  src: url("/fonts/jetbrains-mono-500.woff2") format("woff2");
  font-weight: 500;
  font-style: normal;
  font-display: swap;
}

:root {
  --ground: #000000;
  --surface: #111111;
  --raised: #2a2a2a;
  --border: #1a1a1a;
  --rule: #161616;
  --control: #444444;

  --text: #ffffff;
  --muted: #b4b4b4;
  --faint: #949494;

  --accent: #34d399;
  --positive: #34d399;
  --negative: #e5566f;
  --warning: #e5a93b;

  --pill-positive-bg: #13261d;
  --pill-positive-ink: #34d399;
  --pill-negative-bg: #2c1a20;
  --pill-negative-ink: #e5566f;
  --pill-warning-bg: #2b2414;
  --pill-warning-ink: #e5a93b;
  --pill-neutral-bg: #222222;
  --pill-neutral-ink: #ffffff;

  --primary: #ffffff;
  --primary-ink: #000000;

  --radius-card: 20px;
  --radius-well: 10px;
  --radius-control: 999px;

  --gap: 16px;
  --pad: 24px;
  --card-pad: 24px;
  --control-height: 36px;

  --font-ui: "Inter", system-ui, -apple-system, sans-serif;
  --font-code: "JetBrains Mono", monospace;
}

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

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--ground);
  color: var(--text);
  font: 400 14px/20px var(--font-ui);
  -webkit-font-smoothing: antialiased;
}

h1,
h2,
h3,
p,
dl,
dd,
dt,
ul {
  margin: 0;
}

ul {
  padding: 0;
  list-style: none;
}

button,
input {
  font: inherit;
  color: inherit;
}

code {
  font-family: var(--font-code);
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.num {
  font-variant-numeric: tabular-nums;
}

.hidden {
  display: none !important;
}

#app {
  min-height: 100svh;
  display: flex;
  flex-direction: column;
}

/* ---------- Top bar (56px, #000 ground + 1px bottom rule) ---------- */
.topbar {
  height: 56px;
  padding: 0 var(--pad);
  background: var(--ground);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.topbar-inner {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

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

.brand-mark {
  flex: none;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
}

.topbar-sep {
  color: var(--control);
}

.brand-scope {
  font-size: 13px;
  color: var(--faint);
  white-space: nowrap;
}

.topbar-status {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ---------- Landing workspace ---------- */
.studio-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.studio-main {
  width: 100%;
  padding: 28px var(--pad) 32px;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.title-block {
  margin-bottom: 22px;
}

.title-block h1 {
  font-size: 24px;
  line-height: 1.25;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--text);
}

.subtitle {
  margin-top: 6px;
  max-width: 720px;
  font-size: 14px;
  line-height: 21px;
  color: var(--muted);
}

.studio-grid {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: var(--gap);
  align-items: start;
}

.studio-col-main,
.gate-col-main {
  grid-column: span 7;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
  min-width: 0;
}

.gate-meter {
  margin-top: 12px;
}

.panel {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: var(--card-pad);
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.panel-spec {
  grid-column: span 5;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 18px;
}

.panel-head h2 {
  font-size: 16px;
  line-height: 22px;
  font-weight: 600;
}

.panel-meta {
  font-size: 12px;
  color: var(--faint);
}

/* Underline tabs on a 1px rule */
.mode-tabs {
  display: flex;
  gap: 20px;
  border-bottom: 1px solid var(--rule);
  margin-bottom: 20px;
}

.mode-tab {
  position: relative;
  background: none;
  border: 0;
  padding: 0 0 10px;
  font-size: 14px;
  font-weight: 500;
  color: var(--muted);
  cursor: pointer;
  transition: color 150ms ease;
}

.mode-tab:hover {
  color: var(--text);
}

.mode-tab.is-active {
  color: var(--text);
}

.mode-tab.is-active::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: var(--text);
}

.mode-pane {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Signature element: 5-block Key Vault */
.vault-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.vault-meta {
  font-size: 12px;
  color: var(--faint);
}

.key-vault {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
  padding: 10px;
  background: var(--ground);
  border-radius: var(--radius-well);
}

.vault-block {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 44px;
  background: var(--raised);
  border-radius: var(--radius-well);
  font-size: 15px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0.04em;
  user-select: all;
}

.vault-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* Form fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field-name {
  margin-top: 20px;
}

.field-label {
  font-size: 13px;
  font-weight: 500;
  color: var(--muted);
}

.input {
  width: 100%;
  height: 40px;
  padding: 0 14px;
  background: var(--ground);
  border: 1px solid var(--control);
  border-radius: var(--radius-well);
  color: var(--text);
  font-size: 14px;
  transition: border-color 150ms ease;
}

.input::placeholder {
  color: var(--faint);
}

.input:focus {
  outline: none;
  border-color: var(--text);
}

.input-key {
  font-family: var(--font-code);
  font-size: 15px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.key-meter {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.meter-segments {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  flex: 1;
}

.meter-seg {
  height: 4px;
  border-radius: 999px;
  background: var(--raised);
  transition: background-color 150ms ease;
}

.meter-seg.is-filled {
  background: var(--positive);
}

.inline-error {
  margin-top: 14px;
  padding: 10px 14px;
  background: var(--pill-negative-bg);
  color: var(--pill-negative-ink);
  border-radius: var(--radius-well);
  font-size: 13px;
}

.panel-footer {
  padding-top: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}

.footer-note {
  font-size: 12px;
  color: var(--faint);
}

/* Spec & verification ledgers */
.spec-ledger,
.check-ledger {
  display: flex;
  flex-direction: column;
}

.spec-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
}

.spec-row:last-child {
  border-bottom: 0;
}

.spec-row dt {
  color: var(--muted);
}

.spec-row dd {
  color: var(--text);
  font-weight: 500;
  text-align: right;
}

.subpanel-head {
  margin-top: 20px;
  margin-bottom: 4px;
}

.subpanel-head h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}

/* ---------- Buttons & Pills ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: var(--control-height);
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-control);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background-color 150ms ease, border-color 150ms ease, opacity 120ms ease;
}

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

.btn-sm {
  height: 32px;
  padding: 0 13px;
  font-size: 12px;
}

/* Primary by inversion: white pill, black text */
.btn-primary {
  background: var(--primary);
  color: var(--primary-ink);
}

.btn-primary:hover:not(:disabled) {
  background: #e6e6e6;
}

.btn-outline {
  background: transparent;
  border-color: var(--control);
  color: var(--text);
}

.btn-outline:hover:not(:disabled) {
  background: var(--raised);
}

.btn-text {
  background: transparent;
  color: var(--muted);
  padding: 0 10px;
}

.btn-text:hover:not(:disabled) {
  color: var(--text);
  background: var(--raised);
}

.btn-stop {
  background: var(--pill-negative-bg);
  color: var(--pill-negative-ink);
  border-color: transparent;
}

.btn-stop:hover:not(:disabled) {
  background: #3b2029;
}

.btn-leave {
  color: var(--negative);
}

.pill {
  display: inline-flex;
  align-items: center;
  height: 24px;
  padding: 0 10px;
  border-radius: var(--radius-control);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.pill-neutral {
  background: var(--pill-neutral-bg);
  color: var(--pill-neutral-ink);
}

.pill-positive {
  background: var(--pill-positive-bg);
  color: var(--pill-positive-ink);
}

.pill-negative {
  background: var(--pill-negative-bg);
  color: var(--pill-negative-ink);
}

.pill-warning {
  background: var(--pill-warning-bg);
  color: var(--pill-warning-ink);
}

/* ---------- Active Room Workspace ---------- */
.room-shell {
  height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--ground);
}

.room-topbar {
  height: auto;
  min-height: 56px;
  padding: 10px var(--pad);
  flex-wrap: wrap;
}

.key-bar {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 6px 2px 12px;
  background: var(--surface);
  border-radius: var(--radius-control);
}

.key-bar-code {
  font-size: 12px;
  color: var(--text);
  margin-right: 4px;
}

.room-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.room-banner {
  margin: 12px var(--pad) 0;
  padding: 10px 14px;
  border-radius: var(--radius-well);
  background: var(--pill-warning-bg);
  color: var(--pill-warning-ink);
  font-size: 13px;
}

.room-workspace {
  flex: 1;
  min-height: 0;
  padding: var(--gap) var(--pad) var(--pad);
  display: grid;
  grid-template-columns: minmax(0, 1fr) 272px;
  gap: var(--gap);
}

.room-workspace.rail-hidden {
  grid-template-columns: minmax(0, 1fr);
}

.room-workspace.rail-hidden .session-rail {
  display: none;
}

.viewer {
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: var(--gap);
}

.empty-stage {
  flex: 1;
  background: var(--surface);
  border-radius: var(--radius-card);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}

.empty-inner {
  max-width: 420px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.empty-inner h2 {
  font-size: 18px;
  font-weight: 600;
}

.empty-inner p {
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 6px;
}

/* Stage + Thumbs vs Grid */
.layout-stage .primary-stage {
  flex: 1;
  min-height: 0;
  display: flex;
}

.layout-stage .primary-stage .stream-tile {
  width: 100%;
  height: 100%;
}

.layout-stage .thumbs-strip {
  display: flex;
  gap: var(--gap);
  overflow-x: auto;
  min-height: 0;
}

.layout-stage .thumbs-strip .stream-tile {
  flex: 0 0 264px;
  height: 168px;
}

.layout-grid .primary-stage {
  display: none !important;
}

.layout-grid .thumbs-strip {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  grid-auto-rows: minmax(240px, 1fr);
  gap: var(--gap);
}

.stream-tile {
  background: var(--surface);
  border-radius: var(--radius-card);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.stream-tile video {
  flex: 1;
  min-height: 0;
  width: 100%;
  background: #000000;
  object-fit: contain;
  cursor: pointer;
}

/* Solid flat control strip — no gradient overlay */
.tile-footer {
  height: 44px;
  padding: 0 14px;
  background: var(--surface);
  border-top: 1px solid var(--rule);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex: none;
}

.tile-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.tile-label {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tile-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: none;
}

.tile-volume {
  width: 72px;
  accent-color: var(--text);
}

/* Session rail */
.session-rail {
  background: var(--surface);
  border-radius: var(--radius-card);
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 24px;
  overflow-y: auto;
}

.rail-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  margin-bottom: 10px;
}

.rail-head h2 {
  font-size: 14px;
  font-weight: 600;
}

.participants-list {
  display: flex;
  flex-direction: column;
}

.participant-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--rule);
  font-size: 13px;
}

.participant-row:last-child {
  border-bottom: 0;
}

.participant-id {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.avatar-disc {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 600;
  flex: none;
}

.participant-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ---------- Responsive: Tablet & Phone ---------- */
@media (max-width: 960px) {
  .studio-col-main,
  .gate-col-main,
  .panel-spec {
    grid-column: span 12;
  }

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

  .session-rail {
    max-height: 260px;
  }
}

@media (max-width: 640px) {
  :root {
    --pad: 16px;
    --card-pad: 18px;
  }

  .topbar {
    padding: 0 16px;
  }

  .topbar-sep,
  .brand-scope {
    display: none;
  }

  .studio-main {
    padding: 20px 16px 28px;
  }

  .title-block h1 {
    font-size: 20px;
  }

  .key-vault {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .btn,
  .input {
    min-height: 44px;
  }

  .btn-sm {
    min-height: 36px;
  }

  .layout-grid .thumbs-strip {
    grid-template-columns: minmax(0, 1fr);
  }
}
