/* Tudo aqui vale só no celular. A base é a mesma do app do PC. */
body.mobile {
  font-size: 15px;
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}
body.mobile #root { height: 100dvh; }
body.mobile button { touch-action: manipulation; }
/* Abaixo de 16px, o iPhone dá zoom na tela ao tocar no campo. */
body.mobile input, body.mobile textarea { font-size: 16px; }

.m-app {
  display: flex; flex-direction: column; height: 100%;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) 0 env(safe-area-inset-left);
}
.m-top {
  flex: none; display: flex; align-items: center; gap: 10px; min-height: 48px; padding: 0 12px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.m-link { font-size: 12px; color: var(--muted); }
.m-link-online { color: var(--green); }
.m-link-offline { color: var(--yellow); }
.m-alert {
  flex: none; min-height: 44px; padding: 8px 12px; text-align: left; font-weight: 600;
  color: #1d1608; background: var(--yellow); border: 0;
}
.m-main { flex: 1; min-height: 0; overflow: hidden; position: relative; }
.m-tabs {
  flex: none; display: flex; padding-bottom: env(safe-area-inset-bottom);
  background: var(--panel); border-top: 1px solid var(--line);
}
.m-tabs button {
  flex: 1; height: 52px; color: var(--muted); background: transparent; border: 0;
  border-top: 2px solid transparent; font-weight: 600;
}
.m-tabs button.on { color: var(--text); border-top-color: var(--accent); }

.link { min-height: 36px; padding: 2px 12px; }
.m-danger { color: #f79590; }
.link:disabled { color: #5d5c58; }

/* Lista de sessões */
.m-list { height: 100%; overflow-y: auto; padding: 10px 12px 24px; display: flex; flex-direction: column; gap: 10px; }
.m-summary { display: flex; align-items: center; justify-content: space-between; gap: 10px; color: var(--muted); font-size: 13px; }
.m-card, .m-row { height: auto; }
.m-card { padding: 0; }
.m-card-main {
  display: block; width: 100%; padding: 11px 12px 8px; text-align: left; background: transparent; border: 0;
}
.m-card-main > span { display: block; }
.m-card-main .agent-top { display: flex; }
.m-card-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; padding: 0 12px 10px; }
.m-row {
  display: block; margin-top: 6px; text-align: left; color: var(--text);
}
.m-row > span { display: block; }
.m-row .agent-top { display: flex; }
.m-empty { padding: 48px 16px; text-align: center; color: var(--muted); }
.m-empty h2 { margin: 0 0 6px; font-size: 18px; color: var(--text); }
.m-empty p { margin: 0; }

/* Mapa */
.m-map { position: absolute; inset: 0; }
.m-map-empty { position: absolute; inset: 0; pointer-events: none; }
.m-map-fit { position: absolute; top: 10px; right: 10px; z-index: 5; }
.m-map-terminal {
  width: 100%; height: 100%; padding: 22px 26px; background: #141416;
  border: 2px solid var(--line); border-radius: 12px; cursor: pointer;
}
.m-map-terminal.status-running { border-color: var(--accent); }
.m-map-terminal.status-needs_you { border-color: var(--yellow); }
.m-map-head { display: flex; align-items: center; gap: 12px; font-size: 32px; }
.m-map-head .dot { width: 18px; height: 18px; }
.m-map-head .badge { margin-left: auto; font-size: 22px; padding: 3px 14px; }
.m-map-terminal p { margin: 16px 0 0; font-size: 24px; color: var(--muted); overflow-wrap: anywhere; }

/* Telas por cima de tudo */
body.mobile .drawer {
  position: fixed; inset: 0; z-index: 50; width: 100%; height: 100dvh; border: 0;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
body.mobile .drawer header strong { overflow-wrap: anywhere; }
body.mobile .drawer .icon { width: 40px; height: 40px; font-size: 24px; }
body.mobile .line-prompt { max-width: 92%; }
body.mobile .composer { padding: 10px 12px; }
body.mobile .composer textarea { resize: none; }
body.mobile .attach, body.mobile .send { height: 44px; min-width: 44px; }
body.mobile .permission-options button { min-height: 44px; }
body.mobile .attachment { max-width: 100%; }

.m-terminal {
  position: fixed; inset: 0; z-index: 60; height: 100dvh; display: flex; flex-direction: column;
  background: #141416;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}
.m-sub {
  flex: none; display: flex; align-items: center; gap: 6px; min-height: 48px; padding: 0 8px 0 2px;
  background: var(--panel); border-bottom: 1px solid var(--line);
}
.m-back { width: 44px; height: 44px; font-size: 28px; line-height: 1; background: transparent; border: 0; }
.m-chip {
  min-width: 40px; height: 36px; padding: 0 10px; font-size: 13px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px;
}
.m-font-size { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
/* Mais colunas do que cabe na tela: arrasta para o lado. */
.m-term-box { flex: 1; min-height: 0; overflow: auto; padding: 2px; }
.m-term-box .xterm { width: fit-content; }
.m-term-box .xterm-viewport { background-color: #141416 !important; }
.m-term-note { flex: none; margin: 6px 10px 0; }
.m-resume { flex: none; margin: 8px 10px 0; }
.m-keys {
  flex: none; display: flex; gap: 5px; padding: 6px 8px; overflow-x: auto; scrollbar-width: none;
  background: var(--panel); border-top: 1px solid var(--line);
}
.m-keys button {
  flex: none; min-width: 44px; height: 40px; padding: 0 10px; font-size: 13px;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 7px;
}
.m-keys button.on { color: #1a0f0a; background: var(--accent); border-color: var(--accent); }
.m-term-input { flex: none; display: flex; align-items: center; gap: 6px; padding: 0 8px 8px; background: var(--panel); }
.m-term-input input[type='text'] {
  flex: 1; min-width: 0; height: 44px; padding: 0 10px; color: var(--text);
  background: #111113; border: 1px solid var(--line); border-radius: 7px;
}
.m-term-input input[type='text']:focus { outline: none; border-color: var(--accent); }

/* Explorador de pastas do PC */
.x { display: flex; flex-direction: column; height: 100%; }
.x-bar { flex: none; display: flex; align-items: center; gap: 2px; padding: 6px 6px 4px; background: var(--panel); }
.x-nav {
  flex: none; display: flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  color: var(--text); background: transparent; border: 0; border-radius: 7px;
}
.x-nav:active:not(:disabled) { background: var(--panel-2); }
.x-nav:disabled { color: #4a4a50; cursor: default; }
.x-nav.on { color: var(--accent); }
.x-address {
  flex: 1; min-width: 0; height: 38px; margin: 0 4px; display: flex; align-items: center;
  background: #111113; border: 1px solid var(--line); border-radius: 7px; overflow: hidden;
}
.x-crumbs { flex: 1; min-width: 0; display: flex; align-items: center; height: 100%; overflow-x: auto; scrollbar-width: none; white-space: nowrap; padding: 0 2px; }
.x-crumbs::-webkit-scrollbar { display: none; }
.x-crumb { flex: none; height: 100%; padding: 0 6px; font-size: 14px; color: var(--text); background: transparent; border: 0; }
.x-crumb:last-child { font-weight: 600; }
.x-sep { flex: none; font-size: 13px; color: #6d6c69; }
.x-address input { flex: 1; min-width: 0; height: 100%; padding: 0 10px; color: var(--text); background: transparent; border: 0; outline: 0; }
.x-address:focus-within { border-color: var(--accent); }
.x-tools { flex: none; display: flex; align-items: center; gap: 2px; padding: 0 6px 6px; background: var(--panel); }
.x-search {
  flex: 1; min-width: 0; height: 36px; padding: 0 10px; color: var(--text);
  background: #111113; border: 1px solid var(--line); border-radius: 7px;
}
.x-search:focus { outline: 0; border-color: var(--accent); }
.x-places {
  flex: none; display: flex; gap: 6px; padding: 8px; overflow-x: auto; scrollbar-width: none;
  background: var(--bg); border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.x-places::-webkit-scrollbar { display: none; }
.x-place {
  flex: none; display: flex; align-items: center; gap: 6px; height: 36px; padding: 0 10px; font-size: 13px;
  white-space: nowrap; background: var(--panel); border: 1px solid var(--line); border-radius: 7px;
}
.x-place.on { border-color: var(--accent); }
.x-head {
  flex: none; display: flex; align-items: center; height: 30px; padding: 0 12px; font-size: 12px; color: var(--muted);
  border-bottom: 1px solid var(--line);
}
.x-head button { padding: 0; font-size: 12px; color: var(--muted); background: transparent; border: 0; height: 100%; }
.x-head button.on { color: var(--text); font-weight: 600; }
.x-list { flex: 1; min-height: 0; overflow-y: auto; }
.x-list.loading { opacity: 0.5; }
.x-row {
  display: flex; align-items: center; gap: 12px; width: 100%; min-height: 48px; padding: 6px 12px; text-align: left;
  color: var(--text); background: transparent; border: 0; border-bottom: 1px solid #1f1f23;
}
.x-row:active:not(:disabled) { background: var(--panel-2); }
.x-row:disabled { color: var(--muted); cursor: default; opacity: 1; }
.x-row.hidden-item { opacity: 0.55; }
.x-icon { flex: none; display: flex; }
.x-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.x-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.x-meta { font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.x-usage { height: 5px; margin-top: 3px; background: #2e2e33; border-radius: 3px; overflow: hidden; }
.x-usage span { display: block; height: 100%; background: var(--blue); }
.x-usage span.full { background: #f0746e; }
.x-section { padding: 12px 12px 4px; font-size: 12px; font-weight: 600; color: var(--muted); }
.x-note { margin: 0; padding: 24px 16px; text-align: center; color: var(--muted); }
.x-note.error { color: #f0746e; }
.x-newfolder { flex: none; display: flex; gap: 6px; padding: 8px; background: var(--panel); border-bottom: 1px solid var(--line); }
.x-newfolder input {
  flex: 1; min-width: 0; height: 40px; padding: 0 10px; color: var(--text);
  background: #111113; border: 1px solid var(--line); border-radius: 7px;
}
.x-newfolder input:focus { outline: 0; border-color: var(--accent); }
.x-newfolder .send { height: 40px; min-width: 0; }
.x-foot { flex: none; display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--panel); border-top: 1px solid var(--line); }
.x-foot label { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.x-foot select {
  flex: 1; min-width: 0; height: 40px; padding: 0 8px; font: inherit; font-size: 15px; color: var(--text);
  background: #111113; border: 1px solid var(--line); border-radius: 7px;
}
.x-foot .send { width: 100%; height: 46px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* Conectar */
.m-connect {
  display: flex; flex-direction: column; gap: 14px; justify-content: center; height: 100%;
  max-width: 440px; margin: 0 auto; padding: 24px 20px;
}
.m-connect h1 { margin: 0; font-size: 26px; }
.m-connect p { margin: 0; color: var(--muted); }
.m-connect p.error { color: #f0746e; }
.m-connect label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.m-connect input {
  height: 48px; padding: 0 12px; color: var(--text);
  background: #111113; border: 1px solid var(--line); border-radius: 8px;
}
.m-connect input:focus { outline: none; border-color: var(--accent); }
.m-connect .send { height: 48px; }
