* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --sky: #28B5F5;
  --navy: #1B4E9B;
  --body-bg: #F3EEF0;
  --text: #1A1A1A;
  --input-border: #B8D4F0;
  --rec-red: #E53935;
  --white: #fff;

  /* Login (matches Android LoginActivity) */
  --login-blue-start: #0878E8;
  --login-blue-end: #18B7EE;
  --login-surface: #FFFFFF;
  --login-input-bg: #F5F8FC;
  --login-input-border: #DCE7F3;
  --login-title: #10233F;
  --login-muted: #6F8097;
  --login-icon: #187FE1;
  --login-security: #4E637C;
}

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  background: var(--login-blue-start);
  color: var(--text);
  overscroll-behavior: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

input,
textarea,
select,
.field-input,
[contenteditable="true"] {
  -webkit-user-select: text;
  user-select: text;
}

.hidden { display: none !important; }

.screen {
  display: none;
  min-height: 100vh;
  min-height: 100dvh;
  flex-direction: column;
}

.screen.active { display: flex; }

/* ---------- Login (Android-matched) ---------- */
#login-screen.active {
  background: linear-gradient(135deg, var(--login-blue-start) 0%, var(--login-blue-end) 100%);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.login-scroll {
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(12px + env(safe-area-inset-top, 0)) 16px calc(24px + env(safe-area-inset-bottom, 0));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-hero {
  position: relative;
  width: 100%;
  height: 245px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.login-orb {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.13);
  pointer-events: none;
}

.login-orb-tr {
  width: 180px;
  height: 180px;
  top: -74px;
  right: -62px;
}

.login-orb-bl {
  width: 82px;
  height: 82px;
  bottom: 8px;
  left: -34px;
}

.login-hero-inner {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 12px;
}

.login-logo-box {
  width: 82px;
  height: 82px;
  border-radius: 20px;
  background: var(--navy);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.22);
}

.login-logo-img {
  width: 64px;
  height: 64px;
  object-fit: contain;
}

.login-brand {
  margin-top: 13px;
  color: var(--white);
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 0.4px;
  line-height: 1.1;
}

.login-tagline {
  margin-top: 2px;
  color: rgba(255, 255, 255, 0.88);
  font-size: 14px;
  font-weight: 500;
}

.login-version {
  margin-top: 10px;
  min-width: 76px;
  height: 30px;
  padding: 0 12px;
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.27);
  color: var(--white);
  font-size: 12px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-card {
  width: 100%;
  margin-top: 4px;
  background: var(--login-surface);
  border-radius: 28px;
  padding: 26px 24px 24px;
  box-shadow: 0 12px 32px rgba(8, 40, 90, 0.18);
}

.login-welcome {
  color: var(--login-title);
  font-size: 25px;
  font-weight: 800;
  line-height: 1.2;
}

.login-subtitle {
  margin-top: 4px;
  margin-bottom: 22px;
  color: var(--login-muted);
  font-size: 14px;
  font-weight: 500;
}

.field-label {
  display: block;
  margin: 0 0 7px 2px;
  color: var(--login-title);
  font-size: 13px;
  font-weight: 700;
}

.field-block {
  margin-bottom: 17px;
  position: relative;
}

.field-block:last-of-type {
  margin-bottom: 0;
}

.input-row {
  display: flex;
  align-items: center;
  height: 56px;
  border: 1px solid var(--login-input-border);
  border-radius: 16px;
  padding: 0 15px;
  background: var(--login-input-bg);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.input-row:focus-within {
  border-color: var(--login-icon);
  box-shadow: 0 0 0 3px rgba(24, 127, 225, 0.12);
  background: var(--white);
}

.field-icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--login-icon);
}

.field-input {
  flex: 1;
  border: none;
  outline: none;
  font-size: 15px;
  font-weight: 600;
  color: var(--login-title);
  background: transparent;
  min-width: 0;
  padding: 0 12px;
}

.field-input::placeholder {
  color: var(--login-muted);
  font-weight: 500;
}

.pass-toggle {
  width: 40px;
  height: 40px;
  border: none;
  background: transparent;
  padding: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border-radius: 20px;
}

.pass-toggle:hover {
  background: rgba(24, 127, 225, 0.08);
}

.pass-toggle-icon {
  width: 22px;
  height: 22px;
  color: var(--login-muted);
}

.error-badge {
  width: 22px;
  height: 22px;
  border-radius: 11px;
  background: var(--rec-red);
  color: var(--white);
  font-weight: 800;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
  flex-shrink: 0;
  margin-right: 4px;
}

.error-tooltip {
  margin-top: 5px;
}

.tooltip-box {
  width: 100%;
  background: #ECEFF1;
  border-top: 3px solid var(--rec-red);
  border-radius: 4px;
  padding: 9px 12px;
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.14);
  color: #424242;
  font-size: 13px;
  line-height: 1.4;
}

.login-btn {
  width: 100%;
  height: 56px;
  margin-top: 24px;
  border: none;
  border-radius: 16px;
  background: linear-gradient(90deg, var(--login-blue-start), var(--login-blue-end));
  color: var(--white);
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 1.2px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(8, 120, 232, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.12s, box-shadow 0.12s, opacity 0.12s;
}

.login-btn:hover:not(:disabled) {
  box-shadow: 0 6px 18px rgba(8, 120, 232, 0.42);
}

.login-btn:active:not(:disabled) {
  transform: scale(0.985);
}

.login-btn:disabled {
  opacity: 0.75;
  cursor: wait;
}

.login-spinner {
  width: 22px;
  height: 22px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

.login-security {
  margin-top: 18px;
  text-align: center;
  color: var(--login-security);
  font-size: 12px;
  font-weight: 500;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- User room ---------- */
#room-screen {
  background: var(--body-bg);
}

.room-header {
  background: var(--sky);
  text-align: center;
  padding: calc(12px + env(safe-area-inset-top, 0)) 16px 18px;
  position: relative;
}

.settings-btn {
  position: absolute;
  top: calc(22px + env(safe-area-inset-top, 0));
  right: 16px;
  border: none;
  background: none;
  font-size: 26px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
  color: var(--text);
}

.user-line {
  font-size: 16px;
  font-weight: 600;
  margin: 8px 0 10px;
  color: var(--text);
}

.brand-card {
  width: 120px;
  height: 150px;
  margin: 0 auto 10px;
  border-radius: 6px;
  overflow: hidden;
  background: #111;
}

.brand-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.agent-name {
  color: var(--white);
  font-size: clamp(24px, 7vw, 34px);
  font-weight: 800;
  letter-spacing: 1px;
}

.room-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-top: 18px;
}

.tool-row {
  display: flex;
  gap: 18px;
  justify-content: center;
  padding: 0 16px;
}

.circle-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  background: var(--white);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.12);
  font-size: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.circle-btn.rec-btn {
  font-size: 11px;
  font-weight: 800;
  color: var(--text);
}

.circle-btn.power-btn {
  color: var(--rec-red);
  font-size: 22px;
}

.circle-btn.lock-btn:disabled {
  opacity: 1;
  cursor: default;
}

.status-text {
  margin-top: 16px;
  font-size: 18px;
  font-weight: 700;
  color: #111;
}

.mic-outer {
  margin-top: 24px;
  touch-action: none;
  cursor: pointer;
}

.mic-ring3 {
  width: min(220px, 72vw);
  height: min(220px, 72vw);
  aspect-ratio: 1;
  border-radius: 50%;
  background: #2E2E2E;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-ring2 {
  width: 86%;
  height: 86%;
  border-radius: 50%;
  background: #3D3D3D;
  display: flex;
  align-items: center;
  justify-content: center;
}

.mic-ring1 {
  width: 78%;
  height: 78%;
  border-radius: 50%;
  background: #757575;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

.mic-ring1.live { background: #5C9E54; }

.mic-emoji { font-size: clamp(40px, 12vw, 64px); line-height: 1; }

.circle-btn.rec-btn.recording {
  background: var(--rec-red);
  color: #fff;
  animation: rec-pulse 1.2s ease-in-out infinite;
}

@keyframes rec-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.45); }
  50% { box-shadow: 0 0 0 8px rgba(229, 57, 53, 0); }
}

/* Keep Zoom Component View off-screen — we only want its audio pipeline.
   Do NOT display:none the SDK roots or audio/WebRTC can break. */
#zoom-sdk-root {
  position: fixed !important;
  left: -9999px !important;
  top: 0 !important;
  width: 320px !important;
  height: 180px !important;
  overflow: hidden !important;
  opacity: 0.01 !important;
  pointer-events: none !important;
  z-index: -1 !important;
}

/* Hide Zoom toast / AI disclaimer overlays that float on body. */
#aria-notify-area {
  display: none !important;
}

.room-footer {
  background: var(--sky);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px calc(10px + env(safe-area-inset-bottom, 0));
  gap: 8px;
}

.footer-left, .footer-right {
  color: var(--white);
  font-size: 14px;
  font-weight: 600;
}

.footer-left { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.footer-right { font-weight: 800; white-space: nowrap; }

.toast {
  position: fixed;
  bottom: calc(70px + env(safe-area-inset-bottom, 0));
  left: 20px;
  right: 20px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  padding: 14px;
  border-radius: 10px;
  text-align: center;
  font-size: 14px;
  z-index: 30;
}

.settings-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 40;
}

.settings-menu {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: calc(16px + env(safe-area-inset-bottom, 0));
  background: #fff;
  border-radius: 12px;
  overflow: hidden;
  z-index: 50;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}

.settings-menu button {
  display: block;
  width: 100%;
  border: none;
  background: #fff;
  padding: 16px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  border-bottom: 1px solid #eee;
}

.settings-menu button:last-child { border-bottom: none; color: #666; }

.settings-menu #btn-logout-menu { color: var(--rec-red); }

/* Narrow phones */
@media (max-width: 360px) {
  .tool-row { gap: 10px; }
  .circle-btn {
    width: 52px;
    height: 52px;
    font-size: 22px;
  }
  .login-card {
    padding-left: 18px;
    padding-right: 18px;
  }
  .brand-card {
    width: 100px;
    height: 125px;
  }
  .login-hero { height: 210px; }
  .login-brand { font-size: 24px; }
}

/* Short screens */
@media (max-height: 720px) {
  .login-hero {
    height: 180px;
  }

  .login-logo-box {
    width: 68px;
    height: 68px;
  }

  .login-logo-img {
    width: 52px;
    height: 52px;
  }

  .login-brand { font-size: 24px; margin-top: 8px; }
  .login-card { padding-top: 20px; }

  .brand-card {
    width: 96px;
    height: 120px;
  }

  .user-line {
    margin: 4px 0 8px;
  }

  .room-body {
    padding-top: 10px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .mic-outer { margin-top: 12px; }
  .status-text { margin-top: 10px; font-size: 16px; }
}

/* Tablets / wider screens — keep phone-like layout centered */
@media (min-width: 520px) {
  .room-header,
  .room-body,
  .room-footer {
    max-width: 480px;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
  }

  #room-screen.active {
    align-items: center;
  }

  #room-screen.active .room-header,
  #room-screen.active .room-footer {
    width: 100%;
    max-width: 480px;
  }
}
