/* shell.css — phone-first styles for the launcher and module pages
 * (everything except the desktop map, which uses dashboard.css).
 * Designed at 375px wide first; wider screens just get more room. */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0f1117;
  --surface:      #1a1d27;
  --surface-2:    #222538;
  --border:       #2a2d3a;
  --border-2:     #343749;
  --accent:       #2e9e57;
  --accent-hover: #26894b;
  --brand:        #266138;
  --amber:        #f59e0b;
  --red:          #ef4444;
  --green:        #22c55e;
  --text:         #e2e8f0;
  --text-muted:   #94a3b8;
  --text-dim:     #64748b;
  --radius:       12px;
  --tap:          48px;   /* minimum touch target */
  --safe-top:     env(safe-area-inset-top, 0px);
  --safe-bottom:  env(safe-area-inset-bottom, 0px);
}

html { -webkit-text-size-adjust: 100%; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 16px;               /* 16px+ stops iOS zooming into inputs */
  line-height: 1.4;
  min-height: 100vh;
  min-height: 100dvh;
  -webkit-tap-highlight-color: transparent;
}
a { color: inherit; }

/* ── App bar ─────────────────────────────────────────────── */
.appbar {
  position: sticky; top: 0; z-index: 50;
  display: flex; align-items: center; gap: 0.5rem;
  padding: calc(0.5rem + var(--safe-top)) 0.75rem 0.5rem;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.appbar-logo { height: 28px; display: block; }
.appbar-title { font-size: 1.05rem; font-weight: 600; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.appbar-spacer { flex: 1; }
.appbar-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-width: var(--tap); height: var(--tap); padding: 0 0.6rem;
  background: none; border: none; border-radius: var(--radius);
  color: var(--text-muted); font-size: 1.15rem; cursor: pointer; text-decoration: none;
}
.appbar-btn:hover, .appbar-btn:active { background: var(--surface-2); color: var(--text); }

/* Account menu */
.menu { position: relative; }
.menu-panel {
  position: absolute; right: 0; top: calc(100% + 4px); min-width: 220px;
  background: var(--surface); border: 1px solid var(--border-2); border-radius: var(--radius);
  box-shadow: 0 12px 32px rgba(0,0,0,0.45); padding: 0.4rem 0; display: none;
}
.menu-panel.open { display: block; }
.menu-head { padding: 0.6rem 1rem 0.7rem; border-bottom: 1px solid var(--border); margin-bottom: 0.3rem; }
.menu-head strong { display: block; font-size: 0.95rem; }
.menu-head span { font-size: 0.8rem; color: var(--text-muted); }
.menu-item {
  display: flex; align-items: center; gap: 0.7rem; width: 100%;
  min-height: 44px; padding: 0 1rem;
  background: none; border: none; color: var(--text-muted);
  font-size: 0.95rem; text-align: left; cursor: pointer; text-decoration: none;
}
.menu-item:hover { background: var(--surface-2); color: var(--text); }
.menu-item.hidden { display: none; }

/* ── Page content ────────────────────────────────────────── */
.page {
  max-width: 760px; margin: 0 auto;
  padding: 1.25rem 1rem calc(2rem + var(--safe-bottom));
}
.page-title { font-size: 1.4rem; font-weight: 700; margin-bottom: 0.25rem; }
.page-sub { color: var(--text-muted); font-size: 0.95rem; margin-bottom: 1.25rem; }

.section { margin-bottom: 1.75rem; }
.section-title {
  font-size: 0.78rem; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--text-dim); margin: 0 0.25rem 0.6rem;
}

/* ── Launcher cards ──────────────────────────────────────── */
.cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0.75rem; }
@media (min-width: 600px) { .cards { grid-template-columns: repeat(3, minmax(0, 1fr)); } }

.card {
  position: relative;
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.6rem;
  min-height: 140px; padding: 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px;
  color: var(--text); text-decoration: none;
  transition: border-color 0.15s, transform 0.1s;
}
a.card:hover { border-color: var(--accent); }
a.card:active { transform: scale(0.98); }
.card-icon {
  width: 48px; height: 48px; border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(46,158,87,0.15); color: var(--accent); font-size: 1.4rem;
}
.card-name { font-weight: 600; font-size: 1rem; }
.card-desc { color: var(--text-muted); font-size: 0.82rem; line-height: 1.3; }
.card.soon { opacity: 0.55; cursor: default; }
.card.soon .card-icon { background: var(--surface-2); color: var(--text-dim); }
.card-badge {
  margin-top: auto;
  font-size: 0.65rem; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase;
  padding: 0.15rem 0.45rem; border-radius: 999px;
  background: var(--surface-2); color: var(--text-muted);
}

/* ── Lists ───────────────────────────────────────────────── */
.list {
  list-style: none; background: var(--surface);
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.list-row {
  display: flex; align-items: center; gap: 0.75rem;
  min-height: 60px; padding: 0.6rem 0.75rem 0.6rem 1rem;
}
.list-row + .list-row { border-top: 1px solid var(--border); }
.list-main { flex: 1; min-width: 0; }
.list-title { font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.list-sub { font-size: 0.82rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
/* Rows with several controls: on a phone the controls drop under the text */
@media (max-width: 520px) {
  .list-row.stack { flex-wrap: wrap; row-gap: 0.4rem; padding-top: 0.75rem; padding-bottom: 0.6rem; }
  .list-row.stack .list-main { flex-basis: 100%; }
  .list-row.stack .select.compact { flex: 1; }
}
.field-help { font-size: 0.8rem; color: var(--text-dim); margin-top: 0.35rem; }
.list-empty { padding: 1.25rem; text-align: center; color: var(--text-dim); font-size: 0.9rem; }
.pill {
  display: inline-block; font-size: 0.68rem; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.04em; padding: 0.1rem 0.4rem; border-radius: 999px;
  background: var(--surface-2); color: var(--text-muted); vertical-align: middle;
}
.pill.ok { background: rgba(34,197,94,0.15); color: var(--green); }

/* ── Forms & buttons ─────────────────────────────────────── */
.form { display: grid; gap: 0.75rem; padding: 1rem;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.field label { display: block; font-size: 0.8rem; color: var(--text-muted); margin-bottom: 0.3rem; }
.input, .select {
  width: 100%; min-height: var(--tap); padding: 0 0.85rem;
  background: var(--bg); color: var(--text);
  border: 1px solid var(--border-2); border-radius: 10px;
  font-size: 16px; outline: none;
}
.input:focus, .select:focus { border-color: var(--accent); }
.select.compact { width: auto; min-height: 40px; font-size: 0.9rem; padding: 0 0.5rem; }
@media (min-width: 600px) { .form-2col { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; } }
.form-2col { display: grid; gap: 0.75rem; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: var(--tap); padding: 0 1.1rem;
  border: 1px solid var(--border-2); border-radius: 10px;
  background: var(--surface-2); color: var(--text);
  font-size: 0.95rem; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { border-color: var(--text-dim); }
.btn:disabled { opacity: 0.6; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); border-color: var(--accent-hover); }
.btn-block { width: 100%; }
.icon-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 40px; height: 40px; flex-shrink: 0;
  background: none; border: none; border-radius: 10px;
  color: var(--text-muted); font-size: 1rem; cursor: pointer;
}
.icon-btn:hover { background: var(--surface-2); color: var(--text); }
.icon-btn.danger:hover { color: var(--red); }
.icon-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── Install hint ────────────────────────────────────────── */
.install {
  display: flex; align-items: center; gap: 0.75rem;
  padding: 0.85rem 1rem; margin-bottom: 1.25rem;
  background: rgba(46,158,87,0.1); border: 1px solid rgba(46,158,87,0.35); border-radius: var(--radius);
  font-size: 0.9rem;
}
.install i.lead { color: var(--accent); font-size: 1.2rem; }
.install p { flex: 1; }
.install.hidden { display: none; }

/* ── Toasts ──────────────────────────────────────────────── */
.toast-container {
  position: fixed; left: 50%; transform: translateX(-50%); z-index: 100;
  bottom: calc(1rem + var(--safe-bottom));
  display: flex; flex-direction: column; gap: 0.5rem;
  width: min(420px, calc(100vw - 2rem));
}
.toast {
  display: flex; align-items: center; gap: 0.6rem;
  padding: 0.8rem 1rem; border-radius: 10px;
  background: var(--surface-2); border: 1px solid var(--border-2);
  box-shadow: 0 8px 24px rgba(0,0,0,0.4); font-size: 0.92rem;
}
.toast.warning { border-left: 3px solid var(--amber); }
.toast.critical { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--accent); }
.toast.success { border-left: 3px solid var(--green); }

/* ── Device Test page ────────────────────────────────────── */
.lab-status { font-size: 0.92rem; color: var(--text-muted); line-height: 1.45; }
.lab-status.hidden, .lab-request.hidden { display: none; }
.lab-status b.ok, .lab-request b.ok { color: var(--green); }
.lab-status b.warn, .list-sub .warn { color: var(--amber); }
.lab-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.btn.hidden { display: none; }
.lab-map {
  height: 260px; margin-bottom: 0.75rem;
  border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden;
}
.lab-request {
  display: flex; align-items: flex-start; gap: 0.75rem;
  padding: 1rem; margin-bottom: 1.25rem;
  background: rgba(46,158,87,0.12); border: 1px solid rgba(46,158,87,0.45); border-radius: var(--radius);
}
.lab-request i.lead { color: var(--accent); font-size: 1.4rem; margin-top: 0.15rem; }
.lab-request p { color: var(--text-muted); font-size: 0.92rem; margin-top: 0.2rem; }
.lab-checks { margin-top: 0.75rem; }
.lab-check { font-size: 1.15rem; flex-shrink: 0; }
.lab-check.ok  { color: var(--green); }
.lab-check.bad { color: var(--red); }
.lab-check.dim { color: var(--text-dim); }
.list-sub.lab-wrap, .list-title.lab-wrap { white-space: normal; }
.lab-hint { color: var(--amber); margin-top: 0.2rem; }
.lab-subtitle { font-size: 0.85rem; color: var(--text-muted); margin: 1rem 0.25rem 0.5rem; font-weight: 600; }
