:root {
  --navy: #0B1229;
  --navy-2: #141C38;
  --line: #26304F;
  --gold: #F5B400;
  --gold-press: #D99F00;
  --text: #FFFFFF;
  --muted: #9AA3BF;
  --ok: #34C77B;
  --bad: #FF5A5F;
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }

html, body {
  margin: 0; height: 100%; background: var(--navy); color: var(--text);
  font: 15px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
body {
  position: fixed; inset: 0; overflow: hidden; overscroll-behavior: none;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
}
button { font: inherit; color: inherit; touch-action: manipulation; cursor: pointer; }

/* ------------------------------------------------------------------ login */
.login {
  height: 100%; display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: max(24px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  gap: 28px;
}
.login-logo { width: 96px; height: 96px; }
#login-form { width: 100%; max-width: 340px; display: flex; flex-direction: column; gap: 12px; }
#key {
  width: 100%; height: 52px; padding: 0 16px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--navy-2); color: var(--text); font-size: 17px; letter-spacing: 0.04em; text-align: center;
  -webkit-user-select: text; user-select: text; outline: none;
}
#key:focus { border-color: var(--gold); }
#key::placeholder { color: var(--muted); letter-spacing: 0; }
.btn-gold {
  height: 52px; border: 0; border-radius: 12px; background: var(--gold); color: var(--navy);
  font-weight: 700; font-size: 17px;
}
.btn-gold:active { background: var(--gold-press); }
.btn-gold:disabled { opacity: 0.6; }
.login-error { margin: 0; text-align: center; color: var(--bad); font-size: 14px; }

/* ------------------------------------------------------------------ main */
.main {
  height: 100%; display: flex; flex-direction: column;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) max(10px, env(safe-area-inset-bottom)) env(safe-area-inset-left);
}
.bar {
  height: 44px; flex: none; display: flex; align-items: center; gap: 8px; padding: 0 10px 0 12px;
  overflow-x: auto; scrollbar-width: none;
}
.bar::-webkit-scrollbar { display: none; }
.bar-logo { width: 28px; height: 28px; flex: none; }
.bar-name { font-weight: 700; font-size: 16px; flex: 1; min-width: 72px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chip {
  flex: none; white-space: nowrap;
  height: 30px; padding: 0 12px; border-radius: 15px; border: 1px solid var(--gold); background: transparent;
  color: var(--gold); font-size: 13px; font-weight: 600;
}
.chip.on { background: var(--gold); color: var(--navy); }
.type-sheet { display: flex; gap: 8px; margin: 8px 8px 0; }
.type-sheet[hidden] { display: none; }
.type-sheet input {
  flex: 1; min-width: 0; height: 44px; padding: 0 12px; border-radius: 10px; border: 1px solid var(--line);
  background: var(--navy-2); color: var(--text); font-size: 16px;
}
.type-sheet .btn-gold { height: 44px; padding: 0 16px; }
.icon-btn {
  width: 36px; height: 36px; display: inline-flex; align-items: center; justify-content: center;
  border: 0; border-radius: 10px; background: transparent; color: var(--muted);
}
.icon-btn:active { background: var(--navy-2); }
.icon-btn.small { width: 28px; height: 28px; font-size: 13px; }
.icon-btn.round { width: 52px; height: 52px; border-radius: 26px; background: var(--navy-2); color: var(--text); }
.icon-btn.round:active { background: var(--line); }

.stage {
  position: relative; flex: 1; min-height: 0; margin: 0 8px; overflow: hidden; border-radius: 10px;
  background: #060B1C; touch-action: none;
}
.screen { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; display: block; }
.cover {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; padding: 24px;
  background: var(--navy); color: var(--muted); text-align: center; font-size: 15px; pointer-events: none;
}

.ios-hint {
  flex: none; margin: 8px 12px 0; padding: 6px 6px 6px 12px; display: flex; align-items: center; gap: 8px;
  border-radius: 10px; background: var(--navy-2); color: var(--text); font-size: 13px;
}
.ios-hint span { flex: 1; }

.status {
  flex: none; margin: 8px 16px 0; height: 20px; display: flex; align-items: center; justify-content: center; gap: 8px;
  color: var(--muted); font-size: 13px; white-space: nowrap; overflow: hidden;
}
.status span { overflow: hidden; text-overflow: ellipsis; }
.dot { width: 8px; height: 8px; border-radius: 4px; background: var(--muted); flex: none; }
.dot.wait { background: var(--gold); }
.dot.ok { background: var(--ok); }
.dot.bad { background: var(--bad); }

.controls {
  flex: none; display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 10px 16px 0; max-width: 480px; width: 100%; margin: 0 auto;
}
.ai-btn {
  flex: 1; max-width: 220px; height: 56px; border-radius: 28px; border: 2px solid var(--gold);
  background: transparent; color: var(--gold); font-weight: 800; font-size: 19px; letter-spacing: 0.06em;
}
.ai-btn.on { background: var(--gold); color: var(--navy); }
.ai-btn.busy { border-color: var(--line); color: var(--muted); background: transparent; }
.ai-btn:active { transform: scale(0.98); }

@media (min-width: 700px) {
  .stage { margin: 0 auto; width: min(100%, 520px); }
}
