:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #172033;
  background: #eef1f5;
  font-synthesis: none;
}

* { box-sizing: border-box; }

html,
body {
  width: 100%;
  min-width: 320px;
  height: 100%;
  margin: 0;
  overflow: hidden;
}

button,
input { font: inherit; }

button { -webkit-tap-highlight-color: transparent; }

.app,
.browser-stage {
  position: fixed;
  inset: 0;
}

.app { isolation: isolate; }

.browser-stage {
  z-index: 0;
  overflow: hidden;
  background: #fff;
}

#browser-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  transition: transform 180ms cubic-bezier(.2, .8, .2, 1);
}

#browser-frame[hidden],
[hidden] { display: none !important; }

.controls {
  position: fixed;
  z-index: 10;
  top: max(8px, env(safe-area-inset-top));
  right: 8px;
  left: 8px;
  max-width: 760px;
  padding: 7px;
  background: rgb(255 255 255 / 94%);
  border: 1px solid rgb(207 213 223 / 88%);
  border-radius: 14px;
  box-shadow: 0 10px 32px rgb(24 32 50 / 16%);
  backdrop-filter: blur(14px);
  transition: transform 180ms cubic-bezier(.2, .8, .2, 1), opacity 140ms ease-out;
}

.toolbar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto 40px;
  gap: 6px;
}

input {
  width: 100%;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  color: #172033;
  background: #f4f6f8;
  border: 1px solid #d3d8e1;
  border-radius: 9px;
  outline: none;
  transition: border-color 120ms ease-out, box-shadow 120ms ease-out, background 120ms ease-out;
}

input::placeholder { color: #8a93a3; }

input:focus {
  background: #fff;
  border-color: #5969e8;
  box-shadow: 0 0 0 3px rgb(89 105 232 / 14%);
}

input[aria-invalid="true"] {
  border-color: #c43b4d;
  box-shadow: 0 0 0 3px rgb(196 59 77 / 12%);
}

.open-button,
.secondary-button,
.icon-button,
.reveal-button {
  border: 0;
  cursor: pointer;
  transition: transform 120ms ease-out, background 120ms ease-out;
}

.open-button {
  height: 40px;
  padding: 0 15px;
  color: #fff;
  font-weight: 680;
  background: #3548d4;
  border-radius: 9px;
}

.open-button:disabled { cursor: wait; opacity: .62; }

.icon-button,
.reveal-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  padding: 0;
  color: #525e70;
  background: transparent;
  border-radius: 9px;
}

.icon-button svg,
.reveal-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
}

.status {
  display: flex;
  align-items: center;
  min-height: 17px;
  margin: 5px 4px 0;
  color: #697386;
  font-size: 11px;
  line-height: 17px;
}

.status-dot {
  width: 6px;
  height: 6px;
  margin-right: 6px;
  background: #aeb5c0;
  border-radius: 50%;
}

.status[data-state="loading"] .status-dot {
  background: #e5a324;
  animation: pulse 1s ease-in-out infinite;
}

.status[data-state="ready"] .status-dot { background: #23a26d; }
.status[data-state="error"] { color: #ad3043; }
.status[data-state="error"] .status-dot { background: #d84356; }

.controls-collapsed .controls {
  pointer-events: none;
  opacity: 0;
  transform: translateY(calc(-100% - max(12px, env(safe-area-inset-top))));
}

.controls-collapsed #browser-frame:not([hidden]) {
  height: calc(100% + 48px);
  transform: translateY(-48px);
}

.reveal-button {
  position: fixed;
  z-index: 2147483647;
  bottom: max(7px, env(safe-area-inset-bottom));
  left: 50%;
  width: 48px;
  height: 28px;
  color: #475268;
  background: rgb(255 255 255 / 88%);
  border: 1px solid rgb(207 213 223 / 80%);
  border-radius: 999px;
  box-shadow: 0 4px 16px rgb(24 32 50 / 15%);
  backdrop-filter: blur(12px);
  transform: translateX(-50%);
}

.empty-state,
.loading-state,
.render-error {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  padding: 30px;
  text-align: center;
}

.empty-state,
.loading-state { color: #7a8495; }

.empty-state strong,
.loading-state strong,
.render-error strong {
  margin-top: 22px;
  color: #283247;
  font-size: 17px;
}

.empty-state p,
.loading-state p,
.render-error p {
  max-width: 460px;
  margin: 7px 0 0;
  font-size: 13px;
  line-height: 1.5;
}

.desktop-icon {
  display: block;
  width: 52px;
  height: 35px;
  border: 2px solid #c5ccd7;
  border-radius: 6px;
}

.desktop-icon::after {
  display: block;
  width: 20px;
  height: 6px;
  margin: 38px auto 0;
  border-top: 2px solid #c5ccd7;
  border-bottom: 2px solid #c5ccd7;
  content: "";
}

.spinner {
  width: 34px;
  height: 34px;
  border: 3px solid #dfe3ea;
  border-top-color: #4a5ddd;
  border-radius: 50%;
  animation: spin .8s linear infinite;
}

.render-error { background: #fff; }

.error-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: #b72f43;
  font-size: 22px;
  font-weight: 700;
  background: #fff0f2;
  border-radius: 50%;
}

.secondary-button {
  height: 40px;
  margin-top: 18px;
  padding: 0 15px;
  color: #344054;
  font-weight: 650;
  background: #eef1f5;
  border-radius: 9px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes pulse { 50% { opacity: .35; } }
@keyframes spin { to { transform: rotate(360deg); } }

@media (hover: hover) {
  .open-button:hover { background: #293bbb; }
  .icon-button:hover,
  .reveal-button:hover { background: rgb(229 233 240 / 88%); }
  .secondary-button:hover { background: #e2e6ec; }
}

@media (min-width: 780px) {
  .controls { left: 50%; transform: translateX(-50%); width: calc(100% - 24px); }
  .controls-collapsed .controls { transform: translate(-50%, calc(-100% - max(12px, env(safe-area-inset-top)))); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: .01ms !important;
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
  }
}

.open-button:active,
.secondary-button:active,
.icon-button:active,
.reveal-button:active { transform: scale(.97); }

.reveal-button:active { transform: translateX(-50%) scale(.97); }
