/* Launchpad — Popsicle (light) + Popsicle Dark, per CLAUDE.global.md §15.
   Single view: fixed header (chrome never moves) + one scrollable content
   region underneath, the native-app fallback pattern from §3 tier 3 — there's
   no way to make 40+ app tiles fit one screen, so only the middle region
   scrolls while the header (search/refresh/theme) stays put. */
:root, :root[data-theme="light"] {
  --bg: #f6f5fa;
  --card: #ffffff;
  --surface2: #efedf8;
  --line: #e2def0;
  --ink: #241f33;
  --muted: #6f6885;
  --accent: #e2570e;
  --accent-ink: #ffffff;
  --good: #0a9d90;
  --grape: #6b4de6;
  --danger: #d64545;
  --gold: #e0a400;
  --chip-ink: #14100c;
  --radius: 15px;
  --shadow: 0 6px 20px rgba(36,31,51,.08);
  --glass: rgba(255,255,255,.72);
  --header: linear-gradient(120deg, #e2570e 0, #6b4de6 55%, #0a9d90 100%);
}
:root[data-theme="dark"] {
  --bg: #191625;
  --card: #241f33;
  --surface2: #2e2840;
  --line: #3b3352;
  --ink: #f2eef9;
  --muted: #a69dba;
  --accent: #ff8a3d;
  --accent-ink: #2a1206;
  --good: #2fd4c4;
  --grape: #ab8dff;
  --danger: #ff6b78;
  --gold: #e0b24d;
  --chip-ink: #ffffff;
  --shadow: 0 10px 26px rgba(0,0,0,.42);
  --glass: rgba(36,31,51,.72);
  --header: linear-gradient(120deg, #b3430a 0, #5a3fc4 55%, #0a8478 100%);
}
* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; height: 100%; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Segoe UI Variable Display", "Segoe UI", system-ui, "Nunito", sans-serif;
  font-size: 16px;
  line-height: 1.45;
  -webkit-text-size-adjust: 100%;
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden; /* the page itself never scrolls */
}

.app-header {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  flex-wrap: wrap;
  padding: max(12px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-left)) 12px max(16px, env(safe-area-inset-left));
  background: var(--header);
  color: #fff;
}
.brand { font-weight: 800; font-size: 19px; white-space: nowrap; }
.header-right { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.icon-btn {
  background: rgba(255,255,255,.18); color: #fff; border: 0; border-radius: 10px;
  height: 38px; font-size: 14px; font-weight: 700; cursor: pointer;
  padding: 0 12px; display: inline-flex; align-items: center; gap: 6px;
  transition: transform .12s ease, opacity .15s ease;
}
.icon-btn.wide { font-size: 13px; }
.icon-btn:active { transform: scale(.96); }
.icon-btn:disabled { opacity: .65; cursor: default; }
.icon-btn.spinning .spin-ic { display: inline-block; animation: lp-spin 1s linear infinite; }
@keyframes lp-spin { to { transform: rotate(360deg); } }

.theme-pill { display: inline-flex; background: rgba(255,255,255,.18); border-radius: 999px; padding: 2px; }
.theme-pill button {
  border: 0; background: none; color: #fff; font-weight: 800; font-size: 12px;
  width: 26px; height: 26px; border-radius: 999px; cursor: pointer; opacity: .8;
}
.theme-pill button.on { background: #fff; color: var(--accent); opacity: 1; }

/* ---- scrollable content region ---- */
.view {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 16px max(16px, env(safe-area-inset-left)) max(24px, env(safe-area-inset-bottom));
}
.loading, .muted { color: var(--muted); }

.group { margin-bottom: 26px; }
.group-title {
  display: flex; align-items: baseline; gap: 8px;
  font-weight: 800; font-size: 15px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); margin: 0 0 10px 2px;
}
.group-count { font-weight: 600; font-size: 12px; color: var(--muted); opacity: .8; }

.tile-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(96px, 1fr));
  gap: 12px;
}
@media (min-width: 640px) {
  .tile-grid { grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); }
}

.tile {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 8px 10px;
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  text-decoration: none; color: var(--ink);
  cursor: pointer;
  transition: transform .12s ease;
  position: relative;
}
.tile:active { transform: scale(.95); }
.tile-icon {
  font-size: 30px; line-height: 1;
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface2);
}
.tile-name {
  font-size: 12.5px; font-weight: 700; text-align: center;
  overflow: hidden; text-overflow: ellipsis; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; max-width: 100%;
}
.tile-badge {
  position: absolute; top: 8px; right: 8px; width: 9px; height: 9px; border-radius: 50%;
  background: var(--good); box-shadow: 0 0 0 2px var(--card);
}
.tile-badge.no-sso { display: none; }

/* ---- settings (collapsible, per §17 — collapsed by default) ---- */
details.settings { margin-top: 8px; }
details.settings > summary {
  cursor: pointer; font-weight: 800; padding: 12px 4px; list-style: none;
  display: flex; align-items: center; gap: 8px; color: var(--muted);
}
details.settings > summary::-webkit-details-marker { display: none; }
details.settings > summary::before { content: "▸"; transition: transform .15s ease; }
details.settings[open] > summary::before { transform: rotate(90deg); }

.settings-body { padding: 4px 4px 8px; display: flex; flex-direction: column; gap: 14px; }
.settings-card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 14px 16px;
}
.settings-card h3 { margin: 0 0 8px; font-size: 14px; }
.settings-card p, .settings-card li { font-size: 13.5px; color: var(--muted); margin: 4px 0; }
.settings-card a { color: var(--accent); font-weight: 700; text-decoration: none; }
.settings-card ul { margin: 6px 0 0; padding-left: 18px; }

.appear-row { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-top: 6px; }
.appear-row label { font-size: 13px; color: var(--muted); }
.appear-row input[type="time"], .appear-row select {
  background: var(--surface2); border: 1px solid var(--line); border-radius: 8px;
  color: var(--ink); padding: 6px 8px; font-size: 13px; font-family: inherit;
}

.btn {
  border: 0; border-radius: 10px; padding: 10px 16px; font-weight: 800; font-size: 14px;
  cursor: pointer; background: var(--surface2); color: var(--ink);
}
.btn.primary { background: var(--accent); color: var(--accent-ink); }
.btn:active { transform: scale(.97); }

/* ---- toast (§16 — visible feedback for every action) ---- */
.toast {
  position: fixed; left: 50%; bottom: max(20px, env(safe-area-inset-bottom));
  transform: translateX(-50%); background: var(--ink); color: var(--bg);
  padding: 10px 18px; border-radius: 999px; font-size: 13.5px; font-weight: 700;
  box-shadow: var(--shadow); z-index: 50; max-width: min(90vw, 420px); text-align: center;
}
:root[data-theme="dark"] .toast { background: var(--card); color: var(--ink); border: 1px solid var(--line); }

/* ---- PIN keypad ---- */
.kp-wrap { max-width: 320px; margin: 8vh auto; text-align: center; }
.kp-wrap .card {
  background: var(--card); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 22px 18px;
}
.kp-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; margin-top: 12px; }
.kp { font-size: 20px; padding: 14px 0; border-radius: 12px; border: 0; background: var(--surface2); color: var(--ink); cursor: pointer; }
.kp:active { transform: scale(.95); }
