:root {
  color-scheme: dark;
  --bg: #020910;
  --panel: #071421;
  --panel-2: #0b1a2a;
  --card: rgba(11, 26, 42, .82);
  --line: rgba(100, 149, 186, .28);
  --line-hot: rgba(38, 151, 255, .85);
  --text: #f7fbff;
  --muted: #aeb9c8;
  --blue: #1788ff;
  --blue-2: #1e6ce7;
  --green: #20d99b;
  --danger: #ec403c;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 55% -20%, rgba(29, 111, 169, .34), transparent 36rem),
    linear-gradient(180deg, rgba(9, 38, 63, .42), rgba(1, 6, 12, .92)),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1600' height='900' viewBox='0 0 1600 900'%3E%3Crect width='1600' height='900' fill='%23040c14'/%3E%3Cg fill='%230d3454' opacity='.55'%3E%3Cpath d='M0 640 160 565l165 92 190-150 260 165 175-92 260 120 215-170 175 120v150H0z'/%3E%3Cpath d='M0 720 230 610l155 85 230-145 230 145 200-110 260 130 295-190v375H0z' opacity='.55'/%3E%3C/g%3E%3Cg fill='white' opacity='.55'%3E%3Ccircle cx='105' cy='80' r='1.4'/%3E%3Ccircle cx='290' cy='35' r='1.2'/%3E%3Ccircle cx='510' cy='96' r='1.1'/%3E%3Ccircle cx='780' cy='48' r='1.3'/%3E%3Ccircle cx='1040' cy='74' r='1.2'/%3E%3Ccircle cx='1280' cy='40' r='1.5'/%3E%3Ccircle cx='1500' cy='94' r='1.1'/%3E%3C/g%3E%3C/svg%3E") center/cover fixed;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }

.desktop-shell {
  position: fixed;
  inset: 58px 84px 58px;
  display: grid;
  grid-template-columns: 205px 1fr;
  overflow: hidden;
  border: 1px solid rgba(188, 216, 238, .44);
  border-radius: 24px;
  background: rgba(1, 8, 14, .88);
  box-shadow: 0 30px 90px rgba(0, 0, 0, .55), inset 0 1px rgba(255, 255, 255, .08);
  backdrop-filter: blur(22px);
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 22px 16px 18px;
  border-right: 1px solid rgba(110, 156, 190, .18);
  background: linear-gradient(180deg, rgba(7, 22, 35, .96), rgba(3, 13, 21, .96));
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  height: 66px;
  padding: 0 10px 18px;
  border-bottom: 1px solid rgba(112, 153, 184, .16);
  font-size: 22px;
}

.shield, .mini-shield {
  display: grid;
  place-items: center;
  color: #62b5ff;
  font-weight: 900;
  text-shadow: 0 0 18px rgba(24, 137, 255, .8);
  background: linear-gradient(145deg, rgba(13, 57, 99, .9), rgba(5, 24, 43, .9));
  border: 2px solid #218dff;
  clip-path: polygon(50% 0, 91% 16%, 82% 75%, 50% 100%, 18% 75%, 9% 16%);
}

.shield { width: 48px; height: 54px; font-size: 24px; }
.mini-shield { width: 50px; height: 56px; margin: 0 auto 12px; font-size: 24px; }

.nav {
  display: grid;
  gap: 18px;
  padding-top: 2px;
}

.nav-btn {
  width: 100%;
  min-height: 56px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 0 18px;
  border: 1px solid transparent;
  border-radius: 10px;
  color: rgba(231, 239, 249, .74);
  background: transparent;
  text-align: left;
  font-size: 16px;
}

.nav-btn span { width: 26px; color: #b7c7da; font-size: 22px; }
.nav-btn.active {
  color: white;
  border-color: var(--line-hot);
  background: linear-gradient(100deg, rgba(23, 136, 255, .33), rgba(4, 32, 55, .68));
  box-shadow: inset 3px 0 #1592ff, 0 0 22px rgba(22, 133, 255, .16);
}

.privacy-card {
  margin-top: auto;
  min-height: 148px;
  padding: 22px 14px;
  border: 1px solid rgba(28, 129, 213, .48);
  border-radius: 10px;
  background: radial-gradient(circle at 50% 12%, rgba(20, 102, 180, .22), rgba(4, 18, 30, .76));
  color: rgba(242, 247, 252, .84);
  text-align: center;
}

.privacy-card p { margin: 0; line-height: 1.35; }
.privacy-card span { color: var(--green); }

.app {
  min-width: 0;
  display: grid;
  grid-template-rows: 86px 1fr;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 22px;
  padding: 0 38px;
  border-bottom: 1px solid rgba(95, 136, 169, .18);
}

.room-title, .top-status {
  display: flex;
  align-items: center;
  gap: 17px;
  white-space: nowrap;
  color: rgba(234, 241, 248, .82);
}

.room-title strong { color: white; font-size: 20px; }
.lock { color: white; font-size: 20px; }
.chev { color: rgba(239, 245, 252, .74); font-size: 20px; }
.divider { width: 1px; height: 25px; background: rgba(147, 176, 200, .18); }
.secure-badge {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  padding: 0 17px;
  border: 1px solid rgba(31, 204, 149, .18);
  border-radius: 12px;
  color: #18e69f;
  background: rgba(8, 59, 48, .52);
}
.connected-dot { width: 9px; height: 9px; border-radius: 50%; background: var(--green); box-shadow: 0 0 16px rgba(32, 217, 155, .8); }
.signal { color: var(--green); letter-spacing: 1px; }
.window-dot { min-width: 24px; text-align: center; color: rgba(235, 241, 248, .8); font-size: 19px; }

.view { display: none; min-height: 0; position: relative; }
.view.active { display: block; }

.view-call {
  padding: 0 22px 24px;
}

.video-grid {
  height: calc(100% - 116px);
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(280px, 1fr);
  grid-template-rows: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.tile {
  position: relative;
  overflow: hidden;
  min-height: 210px;
  border: 1px solid rgba(201, 221, 238, .18);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 35%, rgba(128, 161, 183, .23), rgba(13, 25, 36, .82) 42%, #07111b),
    linear-gradient(145deg, rgba(255,255,255,.07), transparent);
  box-shadow: 0 20px 54px rgba(0, 0, 0, .26);
}

.tile.main { grid-row: 1 / span 2; }
.tile video { width: 100%; height: 100%; object-fit: cover; display: block; background: #050b11; }
.tile audio { display: none; }
.tile video.mirror { transform: scaleX(-1); }

.tile-placeholder {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 10px;
  text-align: center;
  color: rgba(226, 237, 248, .72);
}
.tile-placeholder span { font-size: 72px; }
.tile-placeholder small { font-size: 15px; }

.tile-menu {
  position: absolute;
  top: 18px;
  right: 18px;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 50%;
  color: white;
  background: rgba(0, 0, 0, .52);
  font-weight: 900;
}

.badge {
  position: absolute;
  left: 18px;
  bottom: 18px;
  max-width: calc(100% - 36px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 8px 13px;
  border-radius: 8px;
  color: white;
  background: rgba(2, 8, 12, .68);
  font-weight: 700;
}
.badge::before { content: "▮▮ "; color: var(--green); }

.call-controls {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  width: min(810px, calc(100% - 80px));
  min-height: 92px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  padding: 14px 26px;
  border: 1px solid rgba(105, 146, 178, .26);
  border-radius: 19px;
  background: rgba(8, 22, 34, .86);
  box-shadow: 0 20px 58px rgba(0, 0, 0, .34);
  backdrop-filter: blur(18px);
}

.call-controls button {
  border: 0;
  border-radius: 16px;
  color: white;
  background: transparent;
  display: grid;
  place-items: center;
  gap: 4px;
  font-size: 13px;
}
.call-controls span {
  display: grid;
  place-items: center;
  min-width: 58px;
  height: 48px;
  border: 1px solid rgba(44, 141, 229, .45);
  border-radius: 16px;
  color: #58b0ff;
  background: rgba(14, 45, 71, .75);
  font-size: 25px;
  box-shadow: inset 0 0 18px rgba(23, 136, 255, .15);
}
.call-controls .danger { color: #ff5252; }
.call-controls .danger span {
  color: white;
  border: 0;
  background: linear-gradient(180deg, #ff504d, #c7252d);
}

.center-view {
  height: 100%;
  border-top: 1px solid transparent;
  background: radial-gradient(circle at 50% 38%, rgba(10, 56, 91, .28), transparent 34rem);
}
.join-wrap, .create-wrap {
  width: min(720px, 86%);
  margin: 56px auto 0;
  text-align: center;
}
.join-wrap h1, .create-wrap h1 { margin: 0 0 18px; font-size: 34px; letter-spacing: -.02em; }
.join-wrap > p, .create-wrap > p { color: rgba(226, 235, 245, .78); font-size: 17px; margin: 0 0 32px; }

.form-card {
  display: grid;
  gap: 18px;
  padding: 32px 36px 36px;
  border: 1px solid rgba(34, 142, 235, .62);
  border-radius: 17px;
  background: rgba(9, 23, 37, .7);
  text-align: left;
}

label, .wide-label {
  display: grid;
  gap: 8px;
  color: white;
  font-weight: 650;
  text-align: left;
}

.field {
  min-height: 64px;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 14px;
  border: 1px solid rgba(171, 198, 220, .22);
  border-radius: 10px;
  background: rgba(14, 26, 39, .78);
}
.field span { color: rgba(238, 244, 250, .78); font-size: 23px; }
.field input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  color: white;
  background: transparent;
  font-size: 17px;
}
.field input::placeholder { color: rgba(224, 232, 240, .55); }
.field.joined { padding-right: 10px; }
.field.joined button {
  min-height: 48px;
  padding: 0 16px;
  border: 1px solid rgba(55, 145, 229, .22);
  border-radius: 8px;
  color: #2aa1ff;
  background: rgba(8, 26, 44, .78);
  font-weight: 750;
}

.primary {
  min-height: 62px;
  border: 1px solid rgba(62, 170, 255, .9);
  border-radius: 9px;
  color: white;
  background: linear-gradient(180deg, #168dff, #176ad9);
  font-size: 18px;
  font-weight: 800;
  box-shadow: inset 0 1px rgba(255,255,255,.22), 0 18px 34px rgba(23, 112, 232, .2);
}
.privacy-note {
  margin-top: 32px !important;
  color: rgba(220, 229, 239, .72) !important;
  line-height: 1.45;
}

.prejoin-wrap {
  width: min(920px, 90%);
  margin: 42px auto 0;
  text-align: center;
}
.prejoin-copy h1 {
  margin: 0 0 12px;
  font-size: 34px;
  letter-spacing: -.02em;
}
.prejoin-copy p {
  margin: 0 0 26px;
  color: rgba(226, 235, 245, .78);
  font-size: 17px;
}
.prejoin-card {
  display: grid;
  grid-template-columns: minmax(360px, 1.15fr) minmax(300px, .85fr);
  gap: 18px;
  padding: 20px;
  border: 1px solid rgba(34, 142, 235, .5);
  border-radius: 22px;
  background: rgba(7, 20, 34, .74);
  box-shadow: 0 24px 70px rgba(0, 0, 0, .28);
}
.prejoin-preview {
  position: relative;
  overflow: hidden;
  min-height: 360px;
  border: 1px solid rgba(201, 221, 238, .17);
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 35%, rgba(38, 137, 220, .2), rgba(8, 22, 34, .9) 42%, #050d16),
    linear-gradient(145deg, rgba(255,255,255,.07), transparent);
}
.prejoin-preview video {
  width: 100%;
  height: 100%;
  display: none;
  object-fit: cover;
  background: #050b11;
}
.prejoin-preview.video-on video { display: block; }
.prejoin-preview.video-on .prejoin-avatar { display: none; }
.prejoin-avatar {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  color: #72c0ff;
  font-size: 64px;
  font-weight: 900;
  text-shadow: 0 0 26px rgba(24, 137, 255, .6);
}
.prejoin-badge {
  position: absolute;
  left: 18px;
  bottom: 18px;
  padding: 8px 13px;
  border-radius: 8px;
  color: white;
  background: rgba(2, 8, 12, .68);
  font-weight: 800;
}
.prejoin-settings {
  display: grid;
  gap: 14px;
  align-content: start;
  padding: 4px;
}
.prejoin-settings label {
  grid-template-columns: 1fr;
  gap: 8px;
}
.prejoin-settings select {
  width: 100%;
  min-height: 46px;
  border: 1px solid rgba(144, 177, 204, .22);
  border-radius: 10px;
  color: white;
  background: #0d1d2c;
  padding: 0 12px;
}
.prejoin-toggles {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.prejoin-toggles button, .ghost {
  min-height: 54px;
  border: 1px solid rgba(38, 151, 255, .38);
  border-radius: 12px;
  color: white;
  background: rgba(8, 24, 38, .86);
  font-weight: 800;
}
.prejoin-toggles button.is-on {
  border-color: rgba(38, 151, 255, .88);
  background: linear-gradient(180deg, rgba(23, 136, 255, .42), rgba(9, 42, 70, .86));
  box-shadow: inset 0 0 18px rgba(23, 136, 255, .18);
}
.prejoin-toggles span { margin-right: 8px; }

.create-wrap {
  width: min(740px, 88%);
  margin-top: 36px;
}
.wide-label { margin: 0 auto 22px; width: min(600px, 100%); }
.create-wrap > .primary { width: min(600px, 100%); }
.code-card {
  width: min(740px, 100%);
  min-height: 156px;
  display: grid;
  place-items: center;
  gap: 8px;
  margin: 24px auto 18px;
  padding: 22px;
  border: 1px solid rgba(28, 148, 255, .7);
  border-radius: 14px;
  background: radial-gradient(circle at 50% 20%, rgba(35, 205, 166, .12), rgba(8, 25, 39, .78));
}
.code-card span { font-weight: 800; }
.code-card strong {
  color: #7af2d1;
  font-family: Consolas, "SFMono-Regular", monospace;
  font-size: clamp(30px, 4vw, 46px);
  letter-spacing: .32em;
  text-indent: .32em;
}
.code-card em { color: rgba(235, 242, 249, .78); font-style: normal; }
.code-card b { color: #2de6b4; }
.create-actions {
  width: min(740px, 100%);
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin: 0 auto 24px;
}
.create-actions button, .settings-card button {
  min-height: 58px;
  border: 1px solid rgba(38, 151, 255, .78);
  border-radius: 10px;
  color: white;
  background: rgba(8, 24, 38, .86);
  font-weight: 750;
}

.settings-view {
  padding: 0 30px 18px;
  overflow: hidden;
}
.settings-view h2 { margin: 0 0 12px; font-size: 26px; }
.settings-grid {
  height: calc(100% - 68px);
  display: grid;
  grid-template-columns: 1.12fr 1fr 1fr;
  grid-template-rows: repeat(3, minmax(0, 1fr));
  gap: 10px;
}
.settings-card {
  position: relative;
  overflow: hidden;
  display: grid;
  gap: 10px;
  align-content: start;
  min-height: 0;
  padding: 16px 22px;
  border: 1px solid rgba(103, 148, 183, .27);
  border-radius: 12px;
  background: rgba(11, 27, 43, .78);
}
.settings-card.tall { grid-row: span 2; }
.settings-card h3 {
  margin: 0 0 8px;
  color: #9cc9ff;
  font-size: 16px;
}
.settings-card label {
  grid-template-columns: minmax(110px, 1fr) minmax(135px, 1.1fr);
  align-items: center;
  gap: 10px;
  color: rgba(246, 250, 255, .9);
  font-size: 14px;
}
.settings-card select {
  width: 100%;
  min-height: 34px;
  border: 1px solid rgba(144, 177, 204, .2);
  border-radius: 6px;
  color: white;
  background: #0d1d2c;
  padding: 0 10px;
}
.switch-row input {
  justify-self: end;
  width: 42px;
  height: 22px;
  accent-color: var(--green);
}
.settings-card small { color: rgba(210, 220, 231, .62); }
.preview-face {
  position: absolute;
  top: 54px;
  right: 20px;
  width: 86px;
  height: 70px;
  display: grid;
  place-items: center;
  border-radius: 10px;
  background: linear-gradient(145deg, #d9ccb9, #493b33);
  font-size: 36px;
}
.info-row {
  display: flex;
  align-items: center;
  gap: 14px;
  color: rgba(239, 246, 252, .92);
}
.info-row > :first-child {
  display: grid;
  place-items: center;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  color: var(--green);
  background: rgba(26, 200, 142, .14);
}
.settings-footer {
  height: 34px;
  display: flex;
  justify-content: space-between;
  align-items: end;
  color: rgba(227, 236, 245, .7);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%);
  max-width: min(720px, calc(100vw - 40px));
  min-height: 0;
  margin: 0;
  padding: 0;
  border: 0;
  opacity: 0;
  pointer-events: none;
  transition: opacity .16s ease, transform .16s ease;
}
.toast.show {
  min-height: 42px;
  padding: 11px 18px;
  border: 1px solid rgba(73, 149, 221, .35);
  border-radius: 999px;
  color: white;
  background: rgba(5, 19, 31, .92);
  box-shadow: 0 20px 48px rgba(0,0,0,.42);
  opacity: 1;
  transform: translateX(-50%) translateY(-4px);
}

@media (max-width: 1000px) {
  body { overflow: auto; background-attachment: scroll; }
  .desktop-shell {
    position: static;
    min-height: 100dvh;
    inset: auto;
    grid-template-columns: 1fr;
    border: 0;
    border-radius: 0;
  }
  .sidebar {
    min-height: 74px;
    display: grid;
    grid-template-columns: auto 1fr;
    align-items: center;
    padding: max(10px, env(safe-area-inset-top)) 14px 8px;
  }
  .brand { height: auto; padding: 0; border: 0; font-size: 18px; }
  .shield { width: 38px; height: 42px; font-size: 18px; }
  .nav {
    display: flex;
    gap: 8px;
    justify-content: end;
    overflow: auto;
    padding: 0;
  }
  .nav-btn {
    min-height: 44px;
    min-width: 92px;
    justify-content: center;
    gap: 6px;
    padding: 0 10px;
    font-size: 12px;
  }
  .nav-btn span { width: auto; font-size: 16px; }
  .privacy-card { display: none; }
  .app { grid-template-rows: auto 1fr; }
  .topbar {
    min-height: 64px;
    padding: 10px 14px;
    gap: 10px;
    overflow: auto;
  }
  .room-title strong { font-size: 15px; }
  .secure-badge { min-height: 30px; padding: 0 10px; }
  .window-dot, .divider, .participants, #callTimer { display: none; }
  .view-call { min-height: calc(100dvh - 138px); padding: 8px 8px 110px; }
  .video-grid {
    height: 100%;
    display: grid;
    grid-template-columns: 1fr;
    grid-auto-rows: minmax(220px, 1fr);
  }
  .tile.main { grid-row: auto; }
  .tile { border-radius: 22px; }
  .call-controls {
    position: fixed;
    left: 8px;
    right: 8px;
    bottom: max(8px, env(safe-area-inset-bottom));
    transform: none;
    width: auto;
    min-height: 78px;
    grid-template-columns: repeat(5, 1fr);
    padding: 8px;
    border-radius: 22px;
  }
  .call-controls button { font-size: 10px; }
  .call-controls span { min-width: 0; width: 42px; height: 40px; border-radius: 14px; font-size: 20px; }
  .join-wrap, .create-wrap { width: calc(100% - 28px); margin-top: 28px; }
  .prejoin-wrap { width: calc(100% - 28px); margin-top: 22px; }
  .prejoin-card { grid-template-columns: 1fr; padding: 14px; }
  .prejoin-preview { min-height: 260px; }
  .form-card { padding: 22px; }
  .create-actions { grid-template-columns: 1fr; }
  .settings-view { min-height: calc(100dvh - 140px); overflow: auto; padding: 14px; }
  .settings-grid { height: auto; grid-template-columns: 1fr; grid-template-rows: auto; }
  .settings-card.tall { grid-row: auto; }
  .settings-footer { padding-bottom: 16px; }
}
