:root {
  color-scheme: dark;
  --bg: #15181e;
  --panel: #20252d;
  --panel-strong: #2b313b;
  --line: #3a414c;
  --text: #f1f4f8;
  --muted: #aab4c2;
  --accent: #2fb67d;
  --accent-strong: #42d493;
  --warn: #f2a65a;
  --danger: #dc5b5b;
  --shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background:
    linear-gradient(135deg, rgba(47, 182, 125, 0.12), transparent 32%),
    linear-gradient(315deg, rgba(242, 166, 90, 0.1), transparent 34%),
    var(--bg);
  color: var(--text);
  font-family:
    Inter,
    ui-sans-serif,
    system-ui,
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.shell {
  width: min(1440px, 100%);
  height: 100vh;
  min-height: 620px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 18px;
  padding: 18px;
}

.meeting,
.side-panel {
  min-width: 0;
}

.meeting {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 14px;
}

.topbar,
.controls,
.room-panel,
.chat-panel,
.join-form {
  background: rgba(32, 37, 45, 0.92);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.topbar {
  min-height: 84px;
  border-radius: 8px;
  padding: 18px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent-strong);
  font-size: 0.74rem;
  font-weight: 800;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(1.5rem, 2.2vw, 2.3rem);
  line-height: 1;
}

h2 {
  font-size: 0.98rem;
}

.status-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.pill {
  min-height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 5px 10px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.04);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}

.pill.good {
  border-color: rgba(47, 182, 125, 0.65);
  color: #cdf9e3;
  background: rgba(47, 182, 125, 0.16);
}

.pill.warn {
  border-color: rgba(242, 166, 90, 0.65);
  color: #ffe0bd;
  background: rgba(242, 166, 90, 0.16);
}

.pill.bad {
  border-color: rgba(220, 91, 91, 0.65);
  color: #ffd2d2;
  background: rgba(220, 91, 91, 0.16);
}

.stage {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #0d1014;
  box-shadow: var(--shadow);
}

.video-frame {
  position: relative;
  overflow: hidden;
  background:
    linear-gradient(135deg, rgba(47, 182, 125, 0.18), transparent 38%),
    linear-gradient(315deg, rgba(242, 166, 90, 0.14), transparent 36%),
    #11151b;
}

.remote-frame {
  width: 100%;
  height: 100%;
  min-height: 0;
}

.local-frame {
  position: absolute;
  right: 18px;
  bottom: 18px;
  width: min(260px, 32%);
  aspect-ratio: 16 / 10;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

video {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  background: #080a0d;
}

video.mirrored {
  transform: scaleX(-1);
}

.placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 8px;
  padding: 28px;
  text-align: center;
  color: var(--muted);
}

.placeholder[hidden],
video.has-stream + .placeholder {
  display: none;
}

.placeholder strong {
  color: var(--text);
  font-size: 1.35rem;
}

.placeholder-mark {
  width: 92px;
  height: 92px;
  margin: 0 auto 10px;
  display: grid;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  color: #dcfff0;
  background: radial-gradient(circle at 30% 20%, rgba(255, 255, 255, 0.24), rgba(47, 182, 125, 0.3));
  font-size: 1.4rem;
  font-weight: 900;
}

.compact .placeholder-mark {
  width: 58px;
  height: 58px;
  font-size: 0.9rem;
}

.frame-label {
  position: absolute;
  left: 14px;
  bottom: 14px;
  display: inline-flex;
  max-width: calc(100% - 28px);
  align-items: center;
  gap: 8px;
  border-radius: 999px;
  padding: 7px 11px;
  background: rgba(8, 10, 13, 0.68);
  color: #f7fafc;
  font-size: 0.78rem;
  font-weight: 800;
  backdrop-filter: blur(12px);
}

.frame-label span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.frame-label span + span {
  color: var(--muted);
}

.controls {
  min-height: 88px;
  border-radius: 8px;
  padding: 14px;
  display: grid;
  grid-template-columns: repeat(6, minmax(78px, 1fr));
  gap: 10px;
}

.control-button,
.primary-button,
.icon-button {
  cursor: pointer;
  color: var(--text);
  background: var(--panel-strong);
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    opacity 160ms ease;
}

.control-button:hover:not(:disabled),
.primary-button:hover:not(:disabled),
.icon-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: #343c49;
}

.control-button:disabled,
.primary-button:disabled,
.icon-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.control-button {
  min-height: 60px;
  display: grid;
  place-items: center;
  gap: 5px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px;
  font-size: 0.78rem;
  font-weight: 800;
}

.control-button.active {
  border-color: rgba(47, 182, 125, 0.7);
  background: rgba(47, 182, 125, 0.22);
}

.control-button.danger {
  background: rgba(220, 91, 91, 0.16);
  border-color: rgba(220, 91, 91, 0.45);
}

.control-icon {
  position: relative;
  width: 22px;
  height: 22px;
  display: block;
}

.mic-icon::before {
  content: "";
  position: absolute;
  left: 7px;
  top: 2px;
  width: 8px;
  height: 13px;
  border-radius: 999px;
  background: currentColor;
}

.mic-icon::after {
  content: "";
  position: absolute;
  left: 4px;
  top: 11px;
  width: 14px;
  height: 8px;
  border: 2px solid currentColor;
  border-top: 0;
  border-radius: 0 0 12px 12px;
}

.camera-icon::before {
  content: "";
  position: absolute;
  left: 1px;
  top: 6px;
  width: 14px;
  height: 10px;
  border-radius: 3px;
  background: currentColor;
}

.camera-icon::after {
  content: "";
  position: absolute;
  right: 1px;
  top: 8px;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
  border-left: 7px solid currentColor;
}

.screen-icon::before,
.link-icon::before,
.refresh-icon::before,
.send-icon::before,
.mirror-icon::before,
.hangup-icon::before {
  content: "";
  position: absolute;
}

.screen-icon::before {
  inset: 4px 2px 6px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.screen-icon::after {
  content: "";
  position: absolute;
  left: 7px;
  right: 7px;
  bottom: 2px;
  height: 2px;
  background: currentColor;
}

.mirror-icon::before {
  left: 2px;
  top: 4px;
  width: 7px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 2px 0 0 2px;
}

.mirror-icon::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 4px;
  width: 7px;
  height: 14px;
  border: 2px dashed currentColor;
  border-radius: 0 2px 2px 0;
}

.link-icon::before {
  left: 3px;
  top: 8px;
  width: 9px;
  height: 6px;
  border: 2px solid currentColor;
  border-right: 0;
  border-radius: 7px 0 0 7px;
}

.link-icon::after {
  content: "";
  position: absolute;
  right: 3px;
  top: 8px;
  width: 9px;
  height: 6px;
  border: 2px solid currentColor;
  border-left: 0;
  border-radius: 0 7px 7px 0;
}

.hangup-icon::before {
  left: 4px;
  top: 8px;
  width: 14px;
  height: 8px;
  border-radius: 12px 12px 3px 3px;
  background: currentColor;
  transform: rotate(180deg);
}

.refresh-icon::before {
  inset: 4px;
  border: 2px solid currentColor;
  border-left-color: transparent;
  border-radius: 50%;
}

.refresh-icon::after {
  content: "";
  position: absolute;
  right: 2px;
  top: 4px;
  border-left: 6px solid currentColor;
  border-top: 4px solid transparent;
  border-bottom: 4px solid transparent;
}

.send-icon::before {
  left: 3px;
  top: 4px;
  border-left: 15px solid currentColor;
  border-top: 8px solid transparent;
  border-bottom: 8px solid transparent;
}

.side-panel {
  min-height: 0;
  height: 100%;
  padding: 0;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  gap: 14px;
  overflow: auto;
}

.join-form,
.room-panel,
.chat-panel {
  box-shadow: none;
  border-radius: 8px;
  padding: 14px;
}

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

label {
  display: grid;
  gap: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
}

input,
select {
  width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  color: var(--text);
  background: #151a21;
  outline: none;
}

select {
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 18px) 18px / 6px 6px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 12px) 18px / 6px 6px no-repeat,
    #151a21;
}

input:focus,
select:focus {
  border-color: rgba(47, 182, 125, 0.8);
  box-shadow: 0 0 0 3px rgba(47, 182, 125, 0.16);
}

.room-input-row,
.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 42px;
  gap: 8px;
}

.icon-button {
  min-width: 42px;
  min-height: 42px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.primary-button {
  min-height: 44px;
  border-radius: 8px;
  background: var(--accent);
  color: #06140f;
  font-weight: 900;
}

.primary-button:hover:not(:disabled) {
  background: var(--accent-strong);
}

.panel-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

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

.detail-list div {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  color: var(--muted);
  font-size: 0.82rem;
}

.detail-list div:last-child {
  border-bottom: 0;
}

.detail-list strong {
  color: var(--text);
}

.chat-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: auto minmax(160px, 1fr) auto;
}

.chat-log {
  min-height: 0;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
  display: grid;
  align-content: start;
  gap: 8px;
}

.chat-log li {
  padding: 9px 10px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  overflow-wrap: anywhere;
}

.chat-log strong {
  display: block;
  margin-bottom: 3px;
  color: var(--accent-strong);
  font-size: 0.72rem;
}

.chat-form {
  margin-top: 12px;
}

@media (max-width: 1040px) {
  .shell {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100vh;
  }

  .side-panel {
    height: auto;
    min-height: auto;
    overflow: visible;
  }
}

@media (max-width: 700px) {
  .shell {
    padding: 10px;
  }

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

  .status-strip {
    justify-content: flex-start;
  }

  .meeting {
    grid-template-rows: auto minmax(360px, 56vh) auto;
  }

  .remote-frame {
    min-height: 360px;
  }

  .local-frame {
    width: 42%;
    right: 10px;
    bottom: 10px;
  }

  .controls {
    grid-template-columns: repeat(6, minmax(50px, 1fr));
    gap: 6px;
    padding: 8px;
  }

  .control-button {
    min-height: 58px;
    padding: 6px 4px;
    font-size: 0.68rem;
  }

  .control-icon {
    width: 20px;
    height: 20px;
  }
}
