:root {
  --brand: #0B3D91;
  --brand-dark: #082A66;
  --brand-hover: #0A3580;
  --brand-light: #E8F0FC;
  --ink: #1C2430;
  --muted: #5F6B7A;
  --line: #D5DBE3;
  --danger: #B3261E;
  --success: #1E8E3E;
  --page: #F3F5F8;
  --surface: #FFFFFF;
  --toolbar: #1A1F29;
  --toolbar-hover: #2A3140;
  --toolbar-text: #E6E9EF;
  --stage: #0E1117;
  color-scheme: light;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Roboto, sans-serif;
  color: var(--ink);
  background: var(--page);
  -webkit-text-size-adjust: 100%;
}
[hidden] { display: none !important; }
.sprite { position: absolute; }
.mono { font-family: Consolas, "SF Mono", Menlo, monospace; }
.muted { color: var(--muted); margin: 4px 0 20px; }

/* ---------- conexão ---------- */
.connect {
  min-height: 100%;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 24px 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand-dark));
}
.brand { text-align: center; color: #fff; margin-bottom: 20px; }
.brand h1 { margin: 0; font-size: 26px; font-weight: 600; }
.brand p { margin: 4px 0 0; color: #C9D8F5; }
.card {
  width: 100%; max-width: 420px;
  background: var(--surface); border-radius: 12px; padding: 28px 24px;
  box-shadow: 0 8px 28px rgba(0, 0, 0, .25);
}
.card h2 { margin: 0; font-size: 20px; font-weight: 600; }
label { display: block; font-weight: 600; margin: 16px 0 6px; font-size: 14px; }
.field {
  width: 100%; padding: 10px 12px; font-size: 16px; color: var(--ink);
  border: 1px solid var(--line); border-radius: 6px; background: #fff; font-family: inherit;
}
.field:focus { outline: 2px solid var(--brand); outline-offset: -1px; border-color: var(--brand); }
.field.mono { font-family: Consolas, "SF Mono", Menlo, monospace; letter-spacing: 1px; }
.field.big { font-size: 26px; font-weight: 700; text-align: center; padding: 8px; }
.error { color: var(--danger); margin: 12px 0 0; font-size: 14px; }
.warning { color: #fff; background: rgba(179, 38, 30, .85); border-radius: 8px; padding: 10px 14px; max-width: 420px; margin-top: 16px; font-size: 14px; }
button { font: inherit; cursor: pointer; }
.primary {
  width: 100%; margin-top: 20px; padding: 12px; border: 0; border-radius: 6px;
  background: var(--brand); color: #fff; font-weight: 600; font-size: 16px;
}
.primary:hover { background: var(--brand-hover); }
.primary:disabled { opacity: .6; cursor: default; }
.primary.small { width: auto; margin: 0; padding: 8px 20px; font-size: 14px; }
.secondary {
  padding: 8px 14px; border: 0; border-radius: 6px; background: var(--brand-light); color: var(--brand); font-weight: 600;
}
.recent { margin-top: 22px; }
.caption { display: block; font-size: 11px; font-weight: 600; color: var(--muted); text-transform: uppercase; margin-bottom: 8px; }
.recent button {
  margin: 0 6px 6px 0; padding: 6px 12px; border: 1px solid var(--line); border-radius: 14px;
  background: #fff; color: var(--ink); font-family: Consolas, "SF Mono", Menlo, monospace; font-size: 14px;
}
.recent button:hover { background: var(--brand-light); border-color: var(--brand); }

/* ---------- sessão ---------- */
.session { position: fixed; inset: 0; display: flex; flex-direction: column; background: var(--stage); }
.toolbar {
  display: flex; align-items: center; gap: 8px; padding: 4px 8px;
  padding-top: max(4px, env(safe-area-inset-top));
  background: var(--toolbar); color: var(--toolbar-text);
}
.title { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 1; }
.dot { width: 9px; height: 9px; border-radius: 50%; background: var(--success); flex: none; }
.tools { display: flex; gap: 2px; overflow-x: auto; scrollbar-width: none; flex: none; max-width: 100%; }
.tools::-webkit-scrollbar { display: none; }
.tool {
  display: flex; align-items: center; gap: 6px; padding: 7px 10px; border: 0; border-radius: 4px;
  background: transparent; color: var(--toolbar-text); font-size: 13px; white-space: nowrap;
}
.tool:hover { background: var(--toolbar-hover); }
.tool.toggle.on { background: #34507F; }
.tool.danger { background: var(--danger); margin-left: 6px; }
.tool svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }

.stage { position: relative; flex: 1; overflow: auto; overscroll-behavior: contain; }
.stage-inner { display: grid; place-items: center; min-width: 100%; min-height: 100%; width: max-content; height: max-content; }
#screen { display: block; touch-action: none; cursor: default; background: #000; }
.waiting { position: absolute; inset: 0; margin: auto; height: 1.5em; text-align: center; color: #6B7588; pointer-events: none; }
.drop {
  position: absolute; inset: 0; display: grid; place-items: center; background: rgba(11, 61, 145, .6);
  color: #fff; font-size: 20px; font-weight: 600; pointer-events: none;
}
.statusbar {
  display: flex; justify-content: space-between; gap: 12px; padding: 3px 12px;
  padding-bottom: max(3px, env(safe-area-inset-bottom));
  background: var(--toolbar); color: #9AA4B5; font-size: 12px; white-space: nowrap; overflow: hidden;
}
progress { width: 110px; height: 6px; vertical-align: middle; }
.kbd { position: fixed; left: 0; bottom: 0; width: 1px; height: 1px; opacity: 0; border: 0; padding: 0; font-size: 16px; resize: none; }

.menu {
  position: fixed; z-index: 10; min-width: 260px; max-width: calc(100vw - 16px);
  background: #fff; border-radius: 8px; padding: 6px 0; box-shadow: 0 8px 24px rgba(0, 0, 0, .35);
}
.menu button { display: block; width: 100%; text-align: left; border: 0; background: none; padding: 9px 16px; font-size: 14px; color: var(--ink); }
.menu button:hover { background: var(--brand-light); }

.dialog { border: 0; border-radius: 12px; padding: 20px; width: min(460px, calc(100vw - 32px)); box-shadow: 0 8px 28px rgba(0, 0, 0, .35); }
.dialog::backdrop { background: rgba(0, 0, 0, .45); }
.dialog h3 { margin: 0 0 4px; }
.dialog .row { display: flex; gap: 8px; margin-top: 8px; }
.dialog .row.end { justify-content: flex-end; margin-top: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 48px; transform: translateX(-50%); z-index: 20;
  max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 6px;
  background: rgba(31, 36, 48, .92); color: #fff; font-size: 13px; pointer-events: none;
}

/* celular: só ícones na barra */
@media (max-width: 760px) {
  .tool span { display: none; }
  .tool { padding: 8px; }
  .title { font-size: 12px; }
  #stats { font-size: 11px; }
}
