:root {
  --bg: #0b0f17;
  --panel: #121a2a;
  --text: #e8eefc;
  --muted: rgba(232, 238, 252, 0.7);
  --danger: #ff4d4d;
  --border: rgba(255,255,255,0.12);
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: grid;
  gap: 8px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(18,26,42,0.98), rgba(18,26,42,0.90));
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

.field {
  display: grid;
  gap: 4px;
}

.field span {
  font-size: 12px;
  color: var(--muted);
}

input {
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.05);
  color: var(--text);
  outline: none;
}

button {
  height: 38px;
  padding: 0 12px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.08);
  color: var(--text);
  cursor: pointer;
}

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

.primary {
  background: rgba(80, 130, 255, 0.25);
  border-color: rgba(80, 130, 255, 0.55);
}

.danger {
  background: rgba(255, 77, 77, 0.25);
  border-color: rgba(255, 77, 77, 0.55);
}

.ghost {
  background: transparent;
}

.status {
  font-size: 13px;
  color: var(--muted);
}

.layout {
  height: calc(100% - 110px);
  display: grid;
  grid-template-columns: 1fr;
}

.browser {
  padding: 12px;
  display: grid;
  grid-template-rows: auto auto 1fr;
  gap: 10px;
  min-height: 0;
}

.urlbar {
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
}

.hint {
  font-size: 13px;
  color: var(--muted);
}

.hint code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  background: rgba(255,255,255,0.06);
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
}

#webFrame {
  width: 100%;
  height: 100%;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: rgba(255,255,255,0.04);
}

/* Floating call */
.call {
  position: fixed;
  right: calc(12px + env(safe-area-inset-right));
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: min(420px, calc(100vw - 24px));
  height: min(320px, calc(100vh - 160px));
  background: rgba(18, 26, 42, 0.92);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: var(--shadow);
  overflow: hidden;
  z-index: 999;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  touch-action: none;
}

.call.hidden { display: none; }

.callHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  background: rgba(255,255,255,0.04);
  cursor: grab;
}

.callHeader:active { cursor: grabbing; }

.callTitle {
  font-weight: 700;
  font-size: 14px;
}

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

.videos {
  position: relative;
  height: calc(100% - 88px);
  background: rgba(0,0,0,0.35);
}

video {
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: rgba(0,0,0,0.5);
}

#localVideo {
  position: absolute;
  right: 10px;
  bottom: 10px;
  width: 34%;
  height: 34%;
  max-width: 160px;
  max-height: 160px;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
}

.tapToPlay {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.55);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 14px;
}

.tapToPlay.hidden { display: none; }

.callFooter {
  padding: 10px;
  border-top: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
}

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

/* Minimized state */
.call.minimized {
  width: min(220px, calc(100vw - 24px));
  height: 160px;
}

.call.minimized #localVideo {
  width: 38%;
  height: 38%;
}

@media (min-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }
}
