/* Shared look for the phone apps: dark like the calculator apps, laid out for an iPhone 16
   (393 x 852 pt, Dynamic Island up top, home bar below). Every app sets --accent. */
:root {
  color-scheme: dark;
  --bg: #000;
  --card: #141416;
  --card-2: #1e1e21;
  --card-3: #2a2a2e;
  --line: #2c2c30;
  --fg: #fff;
  --dim: #9d9d9d;
  --faint: #636366;
  --accent: #ff9900;
  --live: #ff3b3b;
  --good: #5fdc6f;
  --bad: #ff6b6b;
  --ct: #6f9dff;
  --t: #ffcc66;
  --radius: 16px;
  --top: env(safe-area-inset-top, 0px);
  --bottom: env(safe-area-inset-bottom, 0px);
  --tabbar-h: 54px;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", system-ui, sans-serif;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--fg); }
body {
  font-size: 16px; line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior-y: none;
  min-height: 100dvh;
}
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input { font: inherit; color: inherit; }
img { display: block; }
.num { font-variant-numeric: tabular-nums; }

/* ------------------------------------------------ navigation bar */
.nav {
  position: sticky; top: 0; z-index: 20;
  padding: calc(var(--top) + 6px) 16px 8px;
  background: rgba(0, 0, 0, .78);
  -webkit-backdrop-filter: saturate(160%) blur(18px); backdrop-filter: saturate(160%) blur(18px);
  border-bottom: .5px solid transparent;
  transition: border-color .2s;
}
.nav.scrolled { border-bottom-color: var(--line); }
.nav-row { display: flex; align-items: center; gap: 8px; min-height: 36px; }
.nav-title { flex: 1; min-width: 0; font-size: 17px; font-weight: 600; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nav-side { width: 84px; display: flex; align-items: center; }
.nav-side.right { justify-content: flex-end; }
.back { display: flex; align-items: center; gap: 2px; color: var(--accent); font-size: 17px; height: 36px; margin-left: -6px; }
.back svg { width: 22px; height: 22px; }
.large-title { font-size: 34px; font-weight: 700; letter-spacing: -.025em; margin: 2px 0 0; line-height: 1.15; }
.pill-btn {
  height: 30px; padding: 0 12px; border-radius: 15px; background: var(--card-2);
  font-size: 14px; font-weight: 600; color: var(--dim); display: inline-flex; align-items: center; gap: 6px;
}
.pill-btn.on { color: #000; background: var(--accent); }
.icon-btn { width: 36px; height: 36px; border-radius: 18px; display: grid; place-items: center; color: var(--accent); }
.icon-btn svg { width: 22px; height: 22px; }

/* ------------------------------------------------ content */
main { padding: 8px 16px calc(var(--tabbar-h) + var(--bottom) + 24px); }
main.no-tabbar { padding-bottom: calc(var(--bottom) + 24px); }
.section-head {
  display: flex; align-items: baseline; justify-content: space-between;
  margin: 22px 4px 8px; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--dim);
}
.section-head:first-child { margin-top: 8px; }
.card { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.card + .card { margin-top: 10px; }
.list { background: var(--card); border-radius: var(--radius); overflow: hidden; }
.list > * + * { border-top: .5px solid var(--line); }
.empty { text-align: center; color: var(--dim); padding: 64px 24px; }
.empty b { display: block; color: var(--fg); font-size: 19px; margin-bottom: 6px; }
.error-bar { margin: 8px 0; padding: 10px 14px; border-radius: 12px; background: rgba(255, 80, 80, .12); color: var(--bad); font-size: 14px; }
.spinner { width: 26px; height: 26px; margin: 72px auto; border-radius: 50%; border: 3px solid var(--card-3); border-top-color: var(--accent); animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.tap { transition: background-color .15s, transform .15s; }
.tap:active { background-color: var(--card-2); }

/* segmented control */
.segmented {
  display: flex; padding: 2px; border-radius: 10px; background: var(--card-2); gap: 2px; margin: 12px 0;
}
.segmented button {
  flex: 1; height: 32px; border-radius: 8px; font-size: 14px; font-weight: 600; color: var(--dim);
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
}
.segmented button.on { background: var(--card-3); color: var(--fg); box-shadow: 0 1px 3px rgba(0, 0, 0, .4); }

/* horizontally scrolling chips */
.chips { display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; margin: 0 -16px; padding: 4px 16px 8px; scroll-padding: 16px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 34px; padding: 0 14px; border-radius: 17px; background: var(--card-2);
  font-size: 14px; font-weight: 600; color: var(--dim); white-space: nowrap; display: inline-flex; align-items: center; gap: 6px;
}
.chip.on { background: var(--accent); color: #000; }

/* ------------------------------------------------ tab bar */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30;
  display: flex; padding: 6px 8px calc(var(--bottom) + 2px);
  background: rgba(10, 10, 12, .82);
  -webkit-backdrop-filter: saturate(160%) blur(18px); backdrop-filter: saturate(160%) blur(18px);
  border-top: .5px solid var(--line);
}
.tabbar a {
  flex: 1; height: var(--tabbar-h); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  color: var(--faint); text-decoration: none; font-size: 10.5px; font-weight: 600; position: relative;
}
.tabbar a svg { width: 26px; height: 26px; }
.tabbar a.on { color: var(--accent); }
.tabbar .badge {
  position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
  background: var(--live); color: #fff; font-size: 11px; font-weight: 700; display: grid; place-items: center;
}

.toast {
  position: fixed; left: 50%; bottom: calc(var(--tabbar-h) + var(--bottom) + 18px); transform: translateX(-50%) translateY(20px);
  background: var(--card-3); color: var(--fg); padding: 10px 16px; border-radius: 20px; font-size: 14px; font-weight: 600;
  opacity: 0; transition: opacity .2s, transform .2s; pointer-events: none; z-index: 50; white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
