:root {
  --bg: #ffffff;
  --fg: #111111;
  --muted: #555555;
  --accent: #111111;
  --accent-fg: #ffffff;
  --border: #e5e5e5;
  --card: #fafafa;
}

* {
  box-sizing: border-box;
}

html, body, #root {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  background: var(--bg);
  color: var(--fg);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Apple SD Gothic Neo', 'Noto Sans KR', sans-serif;
  -webkit-font-smoothing: antialiased;
  overscroll-behavior: none;
}

#root {
  display: flex;
  flex-direction: column;
  /* So the absolutely-positioned .loading overlay (which covers the iframe
     until it's done mounting) anchors to the root, not the document body. */
  position: relative;
}

.gate {
  display: flex;
  flex-direction: column;
  min-height: 100%;
  padding: 32px 24px 24px;
  padding-top: max(32px, env(safe-area-inset-top));
  padding-bottom: max(24px, env(safe-area-inset-bottom));
  gap: 24px;
}

.gate__header {
  text-align: center;
}

.gate__logo {
  display: block;
  width: 56px;
  height: 56px;
  margin: 0 auto 16px;
  border-radius: 14px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.gate__header h1 {
  font-size: 22px;
  line-height: 1.3;
  margin: 0 0 8px;
}

.gate__sub {
  color: var(--muted);
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}

.instructions {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.instructions__intro {
  margin: 0;
  font-size: 15px;
  color: var(--muted);
}

.instructions__note {
  font-size: 13px;
  color: var(--muted);
  background: var(--card);
  padding: 12px 14px;
  border-radius: 10px;
  margin: 0;
}

.steps {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.steps li {
  display: flex;
  gap: 14px;
  align-items: center;
  padding: 14px 16px;
  background: var(--card);
  border-radius: 12px;
  border: 1px solid var(--border);
}

.step__num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 32px;
  height: 32px;
  padding: 0 8px;
  background: var(--accent);
  color: var(--accent-fg);
  border-radius: 50%;
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

.step__body {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  justify-content: space-between;
}

.step__body p {
  margin: 0;
  font-size: 15px;
  line-height: 1.4;
}

.step__icon {
  width: 28px;
  height: 28px;
  color: var(--accent);
  flex-shrink: 0;
}

.gate__footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
}

.gate__skip {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 14px;
  padding: 12px;
  cursor: pointer;
  text-decoration: underline;
}

/* Language toggle pill — sits below the skip button. Two buttons inside
   a rounded container; the active language is filled, the inactive one
   is muted text on the same background. Tapping the inactive flips
   languages and re-renders the gate in place. */
.gate__lang {
  display: inline-flex;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 3px;
  font-size: 13px;
}

.gate__lang-btn {
  background: transparent;
  border: none;
  color: var(--muted);
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  min-width: 64px;
  transition: background 0.15s ease, color 0.15s ease;
}

.gate__lang-btn:hover {
  color: var(--fg);
}

.gate__lang-btn--active {
  background: var(--accent);
  color: var(--accent-fg);
}

.gate__lang-btn--active:hover {
  color: var(--accent-fg);
}

.gate__primary {
  width: 100%;
  padding: 16px;
  background: var(--accent);
  color: var(--accent-fg);
  border: none;
  border-radius: 12px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.gate__primary:disabled {
  opacity: 0.6;
}

.loading {
  /* Overlay the iframe while it's still mounting. Position absolute so it
     stacks on top of the iframe without taking flex space — that way the
     iframe can be in the DOM and mounting in the background while the
     customer still sees the calm branded loading screen. Hidden by
     main.ts once iframe.load fires + a 250ms settle delay. */
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  background: var(--bg);
  color: var(--muted);
  z-index: 1;
}

/* Pet Bucket logo above the connecting text. Same icon the home-screen
   PWA app uses so the customer immediately recognises this as the
   freshly-launched app, not a generic browser load. */
.loading__logo {
  width: 80px;
  height: 80px;
  border-radius: 18px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  display: block;
}

.loading__text {
  font-size: 15px;
  color: var(--muted);
}

/* Version + boot-id marker. Kept for diagnostics but now faint/small in
   the bottom corner instead of large+red — the debugging is mostly done
   and we don't want the customer-visible loading screen dominated by
   developer text. */
.loading__ver {
  position: absolute;
  right: 8px;
  bottom: 8px;
  font-size: 10px;
  color: var(--border);
  opacity: 0.5;
  font-family: -apple-system, monospace;
}

/* Forensic banner: shows the previous boot's unload cause on boots #2+.
   Faint green so it doesn't interfere with the branded look. */
.loading__nav {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 24px;
  text-align: center;
  font-size: 10px;
  color: #6c9;
  opacity: 0.6;
  font-family: -apple-system, monospace;
  padding: 4px 12px;
  word-break: break-all;
  line-height: 1.3;
}

.mirror {
  border: 0;
  flex: 1;
  /* Lock the iframe's logical width to the viewport from the FIRST paint so
     the upstream's responsive JS doesn't see a 0px-then-grow transition
     during mount and toggle the mobile-menu state mid-load. Without this,
     iOS measures the iframe at 0×0 first, then re-measures after CSS, which
     fires resize events inside the iframe that cause the hamburger menu to
     visibly snap open and back closed. */
  width: 100vw;
  max-width: 100%;
  min-height: 100%;
  height: 100%;
  display: block;
}

.error {
  padding: 32px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.error h1 {
  font-size: 20px;
  margin: 0;
}

.error p {
  color: var(--muted);
  margin: 0;
  font-size: 15px;
}
