* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  min-height: 100dvh;
  background: var(--ground);
  color: var(--ink);
  font-family: "PingFang SC", "Microsoft YaHei", "Noto Sans SC", system-ui, -apple-system, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}

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

/* ---------- toolbar: a tone step, never a hairline ---------- */

.bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-height: var(--bar);
  padding: 0 1rem;
  background: var(--surface);
  color: var(--ink);
}

.field {
  flex: 1 1 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
}

input {
  flex: 1 1 auto;
  min-width: 0;
  height: 44px;
  padding: 0 0.75rem;
  font: inherit;
  color: var(--ink);
  background: var(--ground);
  border: 0;
  border-radius: var(--radius);
}

input::placeholder { color: var(--ink-2); }

input:focus-visible,
button:focus-visible,
a:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

button {
  font: inherit;
  cursor: pointer;
  border: 0;
  border-radius: var(--radius);
  transition: opacity 120ms ease, transform 120ms ease;
}

.primary {
  flex: 0 0 auto;
  height: 44px;
  padding: 0 1.25rem;
  background: var(--accent);
  color: var(--accent-ink);
  font-weight: 600;
}

.primary:hover { opacity: 0.9; }
.primary:active { transform: translateY(1px); }

.status {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--ink-2);
  font-size: 14px;
  white-space: nowrap;
}

.dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--idle);
}

.dot[data-state="loading"] { background: var(--idle); }
.dot[data-state="ok"] { background: var(--ok); }
.dot[data-state="warn"] { background: var(--warn); }
.dot[data-state="bad"] { background: var(--bad); }

.escape {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 3px;
  font-size: 14px;
}

/* ---------- stage ---------- */

main {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  background: var(--ground);
}

iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
  background: var(--ground);
}

.empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.75rem;
  padding: clamp(1.75rem, 7vw, 4.5rem);
  max-width: 40rem;
}

.empty-title {
  margin: 0;
  font-size: clamp(1.5rem, 4vw, 2rem);
  line-height: 1.1;
  letter-spacing: -0.02em;
  font-weight: 700;
}

.empty-body {
  margin: 0;
  max-width: 34rem;
  color: var(--ink);
}

.empty-body b { font-weight: 700; }

/* ---------- phone: two rows, thumb-sized controls ---------- */

@media (max-width: 40rem) {
  .bar {
    flex-wrap: wrap;
    padding: 0.5rem 0.75rem;
    gap: 0.5rem;
  }

  .field { flex-basis: 100%; }

  .status {
    flex-basis: 100%;
    justify-content: space-between;
    padding-bottom: 0.25rem;
  }

  .primary { padding: 0 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
