:root {
  --ink: #071126;
  --ink-2: #0b1d3a;
  --blue: #0a2a66;
  --cyan: #1f6feb;
  --line: #dbe6f5;
  --paper: #f6f9fc;
  --white: #ffffff;
  --muted: #5a6b81;
  --green: #0fa36b;
  --danger: #b42318;
  --shadow: 0 22px 70px rgba(7, 17, 38, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
}

a {
  color: inherit;
  text-decoration: none;
}

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

.app-header {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px clamp(18px, 4vw, 54px);
  border-bottom: 1px solid rgba(219, 230, 245, 0.9);
  background: rgba(246, 249, 252, 0.9);
  backdrop-filter: blur(18px);
}

.brand img {
  width: 214px;
  height: 82px;
  object-fit: contain;
  padding: 4px;
  border-radius: 8px;
  background: var(--ink);
  box-shadow: 0 8px 26px rgba(7, 17, 38, 0.18);
}

.app-header nav {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  color: var(--muted);
  font-weight: 850;
}

.app-header nav a:hover {
  color: var(--blue);
}

.shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(340px, 430px);
  gap: 18px;
  min-height: calc(100vh - 111px);
  padding: clamp(18px, 3vw, 34px);
}

.meeting-stage,
.panel-card,
.chat-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--white);
  box-shadow: 0 18px 48px rgba(7, 17, 38, 0.08);
}

.meeting-stage {
  display: grid;
  grid-template-rows: auto auto minmax(320px, 1fr) auto;
  gap: 16px;
  padding: 18px;
}

.stage-toolbar,
.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0;
  color: var(--blue);
  font-size: 0.78rem;
  font-weight: 950;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  margin-top: 6px;
  font-size: clamp(2rem, 4vw, 3.8rem);
  line-height: 0.98;
}

h2 {
  font-size: 1rem;
}

.session-code {
  min-width: 180px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.session-code span,
.session-code strong {
  display: block;
}

.session-code span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.session-code strong {
  margin-top: 4px;
  color: var(--blue);
  font-size: 1.25rem;
  letter-spacing: 0;
}

.video-grid {
  position: relative;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  min-height: 0;
}

.join-panel {
  display: grid;
  grid-template-columns: minmax(150px, 1fr) minmax(150px, 0.8fr) minmax(150px, 0.8fr) minmax(120px, 0.5fr) auto auto;
  gap: 10px;
  align-items: end;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.join-panel label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.join-panel span[data-livekit-status] {
  align-self: center;
  color: var(--blue);
  font-size: 0.86rem;
  font-weight: 900;
}

.video-tile {
  position: relative;
  display: grid;
  min-width: 280px;
  min-height: 300px;
  height: clamp(320px, 42vh, 560px);
  overflow: hidden;
  border-radius: 8px;
  background:
    radial-gradient(circle at 80% 20%, rgba(31, 111, 235, 0.28), transparent 24%),
    var(--ink);
  resize: both;
}

.video-tile video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

body.local-screen-sharing .video-grid {
  grid-template-columns: 1fr;
  min-height: clamp(320px, 42vh, 560px);
}

body.local-screen-sharing [data-media-tile="screen"] {
  min-height: clamp(320px, 42vh, 560px);
}

body.local-screen-sharing [data-media-tile="screen"] video {
  opacity: 0;
}

body.local-screen-sharing [data-media-tile="camera"] {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 7;
  width: min(260px, 38vw);
  min-width: 160px;
  min-height: 0;
  height: auto;
  aspect-ratio: 16 / 9;
  resize: both;
  box-shadow: var(--shadow);
}

.tile-label {
  position: absolute;
  top: 12px;
  left: 12px;
  z-index: 2;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 9px;
  border-radius: 8px;
  color: var(--white);
  background: rgba(7, 17, 38, 0.72);
  font-size: 0.78rem;
  font-weight: 900;
}

.tile-label button {
  min-height: 26px;
  padding: 0 8px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 7px;
  color: var(--white);
  background: rgba(255, 255, 255, 0.12);
  font-size: 0.72rem;
}

.video-tile.is-floating {
  position: fixed;
  z-index: 40;
  width: min(560px, calc(100vw - 32px));
  height: min(360px, calc(100vh - 32px));
  box-shadow: var(--shadow);
}

.resize-handle {
  position: absolute;
  z-index: 8;
  display: none;
  background: rgba(247, 201, 72, 0.85);
  box-shadow: 0 0 0 2px rgba(7, 17, 38, 0.25);
  pointer-events: auto;
}

.video-tile.is-floating .resize-handle {
  display: block;
}

.resize-n,
.resize-s {
  left: 42px;
  right: 42px;
  height: 8px;
}

.resize-n {
  top: 0;
  cursor: ns-resize;
}

.resize-s {
  bottom: 0;
  cursor: ns-resize;
}

.resize-e,
.resize-w {
  top: 42px;
  bottom: 42px;
  width: 8px;
}

.resize-e {
  right: 0;
  cursor: ew-resize;
}

.resize-w {
  left: 0;
  cursor: ew-resize;
}

.resize-nw,
.resize-ne,
.resize-se,
.resize-sw {
  width: 22px;
  height: 22px;
  border-radius: 6px;
}

.resize-nw {
  top: 0;
  left: 0;
  cursor: nwse-resize;
}

.resize-ne {
  top: 0;
  right: 0;
  cursor: nesw-resize;
}

.resize-se {
  right: 0;
  bottom: 0;
  cursor: nwse-resize;
}

.resize-sw {
  bottom: 0;
  left: 0;
  cursor: nesw-resize;
}

.screen-tile.control-active {
  cursor: crosshair;
  outline: 3px solid rgba(31, 111, 235, 0.45);
  outline-offset: 3px;
}

.remote-pointer {
  position: absolute;
  z-index: 4;
  width: 18px;
  height: 18px;
  pointer-events: none;
  transform: translate(-50%, -50%);
  border: 3px solid #f7c948;
  border-radius: 999px;
  box-shadow: 0 0 0 5px rgba(247, 201, 72, 0.22);
}

.remote-pointer::after {
  content: attr(data-label);
  position: absolute;
  left: 18px;
  top: 14px;
  min-width: max-content;
  padding: 4px 7px;
  border-radius: 7px;
  color: var(--ink);
  background: #f7c948;
  font-size: 0.72rem;
  font-weight: 950;
}

.remote-pointer.is-click {
  animation: pointer-pulse 260ms ease-out;
}

@keyframes pointer-pulse {
  from {
    box-shadow: 0 0 0 5px rgba(247, 201, 72, 0.28), 0 0 0 0 rgba(247, 201, 72, 0.55);
  }
  to {
    box-shadow: 0 0 0 5px rgba(247, 201, 72, 0.12), 0 0 0 22px rgba(247, 201, 72, 0);
  }
}

.control-hint {
  position: absolute;
  right: 12px;
  bottom: 12px;
  z-index: 3;
  max-width: min(360px, calc(100% - 24px));
  padding: 9px 10px;
  border-radius: 8px;
  color: var(--white);
  background: rgba(7, 17, 38, 0.76);
  font-size: 0.82rem;
  font-weight: 850;
}

.empty-state {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: rgba(255, 255, 255, 0.72);
  text-align: center;
  font-weight: 850;
}

.empty-state.is-hidden {
  display: none;
}

.control-bar,
.approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

button {
  min-height: 42px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  background: var(--white);
  font-weight: 850;
  cursor: pointer;
}

button:hover {
  border-color: rgba(10, 42, 102, 0.35);
}

.control-bar button:first-child,
.chat-form button {
  color: var(--white);
  border-color: var(--ink);
  background: var(--ink);
}

.side-panel {
  display: grid;
  gap: 14px;
}

.panel-card,
.chat-card {
  padding: 16px;
}

.panel-heading span {
  display: inline-flex;
  min-height: 28px;
  align-items: center;
  padding: 0 9px;
  border-radius: 8px;
  color: var(--blue);
  background: #edf5ff;
  font-size: 0.78rem;
  font-weight: 950;
}

.switch-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 10px;
  margin-top: 14px;
  color: var(--ink-2);
  font-weight: 750;
}

.approval-box {
  display: grid;
  gap: 12px;
  margin-top: 14px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.approval-box p {
  color: var(--muted);
}

.audio-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 14px;
}

.audio-grid label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.participant-list {
  display: grid;
  gap: 8px;
  margin-top: 14px;
}

.participant-empty,
.participant-row {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.participant-empty {
  color: var(--muted);
  font-size: 0.9rem;
}

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

.participant-row.is-speaking {
  border-color: rgba(31, 111, 235, 0.55);
  box-shadow: 0 0 0 3px rgba(31, 111, 235, 0.12);
}

.participant-row strong,
.participant-row span {
  display: block;
}

.participant-row strong {
  color: var(--ink);
  font-size: 0.92rem;
}

.participant-row span {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.participant-badge {
  flex: 0 0 auto;
  min-height: 26px;
  padding: 3px 8px;
  border-radius: 8px;
  color: var(--blue);
  background: #edf5ff;
  font-size: 0.72rem;
  font-weight: 950;
}

.audio-badge {
  color: #073b2a;
  background: #ddf8ea;
}

.participant-actions {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
}

.participant-actions button {
  min-height: 30px;
  padding: 5px 9px;
  border: 0;
  border-radius: 8px;
  color: #071126;
  background: #f7c948;
  font-size: 0.72rem;
  font-weight: 950;
  cursor: pointer;
}

.participant-actions button[data-remove-participant] {
  color: #ffffff;
  background: var(--danger);
}

.security-card {
  display: grid;
  gap: 12px;
}

.security-card label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.mobile-share-card p,
.recording-card p,
.support-note {
  margin-top: 12px;
  color: var(--muted);
  font-size: 0.94rem;
}

.support-note {
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
  font-weight: 750;
}

.mobile-share-card .approval-actions {
  margin-top: 14px;
}

.schedule-card {
  display: grid;
  gap: 14px;
}

.schedule-form {
  display: grid;
  gap: 12px;
}

.schedule-form label {
  display: grid;
  gap: 6px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 900;
  text-transform: uppercase;
}

.schedule-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 150px;
  gap: 10px;
}

.scheduled-list {
  display: grid;
  gap: 8px;
}

.scheduled-session {
  display: grid;
  gap: 8px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fbff;
}

.scheduled-session strong,
.scheduled-session span {
  display: block;
}

.scheduled-session strong {
  color: var(--ink);
  font-size: 0.94rem;
}

.scheduled-session span {
  color: var(--muted);
  font-size: 0.82rem;
}

.scheduled-session-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.scheduled-session-actions button {
  min-height: 34px;
  padding-inline: 10px;
  font-size: 0.84rem;
}

textarea,
input,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  color: var(--ink);
  background: #fbfdff;
}

textarea {
  margin-top: 14px;
  resize: vertical;
}

.chat-card {
  display: grid;
  grid-template-rows: auto minmax(220px, 1fr) auto;
  min-height: 380px;
}

.chat-card.is-floating-chat {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 50;
  width: min(460px, calc(100vw - 36px));
  height: min(560px, calc(100vh - 36px));
  box-shadow: var(--shadow);
}

.chat-actions {
  display: inline-flex;
  gap: 8px;
}

.chat-actions button {
  min-height: 32px;
  padding-inline: 10px;
  font-size: 0.78rem;
}

.chat-log {
  display: grid;
  align-content: start;
  gap: 8px;
  margin: 14px 0;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: #f3f7fb;
}

.chat-line {
  width: fit-content;
  max-width: 92%;
  padding: 9px 10px;
  border-radius: 8px;
  background: var(--white);
  color: var(--ink);
  font-size: 0.92rem;
}

.chat-line.user {
  justify-self: end;
  color: var(--white);
  background: var(--blue);
}

.chat-line.system {
  color: var(--muted);
  background: transparent;
  padding-inline: 0;
}

.chat-form {
  display: grid;
  grid-template-columns: 150px minmax(0, 1fr) auto;
  gap: 10px;
}

.chat-meta {
  display: block;
  margin-bottom: 3px;
  opacity: 0.72;
  font-size: 0.72rem;
  font-weight: 950;
  text-transform: uppercase;
}

.chat-line strong {
  display: block;
  font-weight: 750;
}

.chat-line.participant {
  justify-self: start;
  background: var(--white);
}

.chat-line.private {
  border: 1px solid rgba(247, 201, 72, 0.65);
  background: #fff8df;
}

@media (max-width: 980px) {
  .shell,
  .video-grid {
    grid-template-columns: 1fr;
  }

  .shell {
    min-height: auto;
  }

  .meeting-stage {
    grid-template-rows: auto auto auto auto;
  }

  .join-panel {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 680px) {
  body {
    background: var(--white);
  }

  .app-header {
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
  }

  .brand img {
    width: 148px;
    height: 56px;
    padding: 3px;
  }

  .app-header nav {
    overflow-x: auto;
    width: 100%;
    justify-content: flex-end;
    gap: 8px;
    font-size: 0.82rem;
    padding-bottom: 2px;
    scrollbar-width: none;
  }

  .app-header nav::-webkit-scrollbar {
    display: none;
  }

  .app-header nav a,
  .shared-language-switcher button {
    flex: 0 0 auto;
    min-height: 34px;
    padding: 0 9px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--white);
  }

  .shared-language-switcher {
    gap: 6px;
  }

  .shell {
    display: grid;
    gap: 10px;
    padding: 10px;
  }

  .meeting-stage,
  .panel-card,
  .chat-card {
    border-radius: 8px;
    box-shadow: none;
  }

  .meeting-stage {
    gap: 10px;
    padding: 12px;
  }

  .stage-toolbar,
  .panel-heading,
  .join-panel,
  .chat-form,
  .audio-grid,
  .schedule-grid {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  h1 {
    font-size: clamp(1.72rem, 11vw, 2.45rem);
    line-height: 1.02;
  }

  .session-code {
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
  }

  .session-code strong {
    overflow-wrap: anywhere;
    font-size: 1.05rem;
  }

  .join-panel {
    gap: 9px;
    padding: 10px;
  }

  textarea,
  input,
  select {
    min-height: 46px;
    padding: 11px;
    font-size: 1rem;
  }

  .video-tile {
    min-height: 0;
    height: auto;
    aspect-ratio: 16 / 10;
    resize: vertical;
  }

  .video-tile.is-floating {
    width: calc(100vw - 20px);
    height: min(300px, 42vh);
  }

  body.local-screen-sharing [data-media-tile="camera"] {
    top: 10px;
    right: 10px;
    width: min(190px, 48vw);
  }

  .tile-label {
    top: 8px;
    left: 8px;
    padding: 6px 8px;
  }

  .control-bar,
  .approval-actions,
  .scheduled-session-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
  }

  .control-bar {
    position: sticky;
    bottom: 0;
    z-index: 15;
    margin: 0 -12px -12px;
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
    border-top: 1px solid var(--line);
    background: rgba(255, 255, 255, 0.94);
    backdrop-filter: blur(14px);
  }

  .control-bar button {
    min-width: 0;
  }

  button {
    min-height: 46px;
    padding-inline: 10px;
  }

  .side-panel {
    gap: 10px;
  }

  .panel-card,
  .chat-card {
    padding: 12px;
  }

  .panel-heading span {
    width: fit-content;
    max-width: 100%;
  }

  .participant-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .scheduled-session {
    padding: 10px;
  }

  .chat-card {
    min-height: 330px;
    grid-template-rows: auto minmax(180px, 1fr) auto;
  }

  .chat-log {
    margin: 10px 0;
    max-height: 42vh;
  }

  .chat-line {
    max-width: 100%;
    overflow-wrap: anywhere;
  }

  .chat-form {
    gap: 8px;
  }

  .chat-card.is-floating-chat {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    height: min(520px, calc(100vh - 20px));
  }
}

@media (max-width: 420px) {
  .app-header {
    align-items: stretch;
    flex-direction: column;
  }

  .app-header nav {
    justify-content: space-between;
  }

  .brand img {
    width: 138px;
    height: 52px;
  }

  .control-bar,
  .approval-actions,
  .scheduled-session-actions {
    grid-template-columns: 1fr;
  }
}
