:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #0b0e11;
  color: #f3f6f8;
}

* {
  box-sizing: border-box;
}

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

body {
  background:
    radial-gradient(circle at 20% 0%, rgba(62, 112, 168, 0.16), transparent 34rem),
    #0b0e11;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.hidden {
  display: none !important;
}

.portal-view {
  width: 100%;
  min-height: 100dvh;
  padding:
    max(24px, env(safe-area-inset-top))
    max(20px, env(safe-area-inset-right))
    max(24px, env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
}

.login-view {
  display: grid;
  place-items: center;
}

.login-card,
.device-card,
.prompt-card {
  border: 1px solid #29323c;
  background: rgba(21, 26, 32, 0.96);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.35);
}

.login-card {
  width: min(100%, 390px);
  padding: 30px;
  border-radius: 20px;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(28px, 6vw, 40px);
  letter-spacing: -0.04em;
}

h2 {
  margin-bottom: 4px;
  font-size: 19px;
}

.eyebrow {
  margin-bottom: 10px;
  color: #79b8ff;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.muted {
  color: #99a7b5;
}

.login-card label {
  display: grid;
  gap: 8px;
  margin-top: 18px;
  color: #c7d0d9;
  font-size: 13px;
  font-weight: 650;
}

.login-card input {
  width: 100%;
  height: 46px;
  padding: 0 13px;
  color: #f3f6f8;
  background: #0e1217;
  border: 1px solid #39444f;
  border-radius: 10px;
  outline: none;
}

.login-card input:focus {
  border-color: #69aefc;
  box-shadow: 0 0 0 3px rgba(77, 157, 246, 0.16);
}

.primary-button,
.secondary-button {
  min-height: 43px;
  padding: 0 17px;
  border-radius: 10px;
  font-weight: 700;
}

.primary-button {
  color: #07101a;
  background: #7dbbff;
  border: 1px solid #8fc5ff;
}

.primary-button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.secondary-button {
  color: #dce4eb;
  background: #1c232b;
  border: 1px solid #3a4652;
}

.login-card .primary-button {
  width: 100%;
  margin-top: 22px;
}

.form-error {
  margin: 14px 0 -6px;
  color: #ffb4ad;
  font-size: 13px;
}

.dashboard-view {
  width: min(100%, 1040px);
  margin: 0 auto;
}

.dashboard-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 34px;
}

.dashboard-header h1 {
  margin-bottom: 0;
}

.device-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 310px), 390px));
  gap: 20px;
}

.device-card {
  padding: 22px;
  border-radius: 18px;
}

.device-card-header {
  display: grid;
  grid-template-columns: 48px 1fr auto;
  align-items: center;
  gap: 13px;
}

.device-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  color: #07101a;
  background: linear-gradient(145deg, #9bd0ff, #5e9fe9);
  border-radius: 14px;
  font-size: 20px;
  font-weight: 900;
}

.device-card-header p {
  margin-bottom: 0;
  font-size: 13px;
}

.status-pill {
  padding: 5px 9px;
  color: #b5c0ca;
  background: #252d35;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 750;
}

.status-pill.ready {
  color: #a9e8c3;
  background: #173729;
}

.status-pill.error {
  color: #ffc3be;
  background: #432522;
}

.metrics {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin: 24px 0 18px;
}

.metrics div {
  padding: 12px;
  background: #0f1419;
  border: 1px solid #252e37;
  border-radius: 11px;
}

.metrics dt {
  margin-bottom: 6px;
  color: #8593a1;
  font-size: 11px;
}

.metrics dd {
  margin: 0;
  font-size: 14px;
  font-weight: 720;
}

.device-message {
  min-height: 38px;
  margin-bottom: 16px;
  font-size: 13px;
}

.device-card > .primary-button {
  width: 100%;
}

.phone-view {
  position: fixed;
  inset: 0;
  overflow: hidden;
  background: #080a0d;
  overscroll-behavior: none;
  touch-action: none;
}

.phone-page {
  display: flex;
  flex-direction: column;
  width: min(100vw, calc((100dvh - 53px) * 0.5625 + 54px));
  height: 100dvh;
  min-height: 0;
  margin: 0 auto;
  background: #0b0e11;
}

.ad-slot {
  flex: 0 0 calc(50px + env(safe-area-inset-top));
  display: flex;
  align-items: center;
  padding-top: env(safe-area-inset-top);
  background: #171c22;
}

.fake-ad {
  width: 100%;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 0 14px;
  color: #d8dee5;
  background: #252c34;
  border: 1px solid #39434e;
  font-size: 13px;
  line-height: 1;
  user-select: none;
  pointer-events: none;
}

.impression {
  color: #9eabb8;
  font-size: 11px;
  white-space: nowrap;
}

.impression strong {
  color: #d8dee5;
  font-weight: 650;
}

.divider {
  flex: 0 0 3px;
  background: #3a4550;
}

.android-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  background: #0b0e11;
}

#android-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #0b0e11;
  touch-action: none;
}

.ios-touch-proxy {
  position: absolute;
  z-index: 2;
  inset: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}

.stream-message {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #b8c2cc;
  background: #0b0e11;
  text-align: center;
  font-size: 14px;
}

.stream-message.error {
  color: #ffb4ad;
}

.floating-button {
  position: fixed;
  z-index: 6;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  color: #e7edf3;
  background: rgba(18, 23, 29, 0.76);
  border: 1px solid rgba(126, 144, 161, 0.55);
  border-radius: 50%;
  backdrop-filter: blur(12px);
  font-size: 24px;
}

.floating-back {
  top: max(64px, calc(env(safe-area-inset-top) + 12px));
  left: max(12px, env(safe-area-inset-left));
}

.floating-fullscreen {
  top: max(64px, calc(env(safe-area-inset-top) + 12px));
  right: max(12px, env(safe-area-inset-right));
  font-size: 18px;
}

.fullscreen-prompt {
  position: fixed;
  z-index: 10;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(3, 5, 7, 0.72);
  backdrop-filter: blur(8px);
}

.prompt-card {
  width: min(100%, 410px);
  padding: 24px;
  border-radius: 18px;
}

.prompt-card p {
  color: #a9b5c0;
  line-height: 1.5;
}

.prompt-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 22px;
}

@media (max-width: 620px) {
  .portal-view {
    padding-left: 16px;
    padding-right: 16px;
  }

  .dashboard-header {
    align-items: flex-start;
  }

  .login-card {
    padding: 24px;
  }

  .phone-page {
    width: 100vw;
  }
}

@media (display-mode: fullscreen) {
  .floating-back,
  .floating-fullscreen {
    opacity: 0.35;
  }
}
