/* The shared look of every app in the family (see apps.json), the same as mod's: true black
   (OLED pixels switch off) with Ghastly's purple for everything that stands out. One look only:
   no themes and no colour picker. An app keeps only what is particular to it in its own styles. */

:root {
  --bg: #000;
  --surface: #0b0910;
  --surface-2: #15111c;
  --line: #1b1622;
  --line-2: #2a2234;
  --text: #f1edf6;
  --muted: #8b8396;
  --faint: #5f5869;
  --accent: #b163ff;        /* Ghastly's body */
  --accent-2: #7d449e;      /* his shading */
  --accent-rgb: 177, 99, 255;   /* --accent again, for see-through tints; an app with its own colour sets both */
  --accent-soft: rgba(var(--accent-rgb), .14);
  --on-accent: #fff;
  --danger: #ff6b8b;
  --scrim: rgba(0, 0, 0, .72);
  --radius: 14px;
  --card-radius: 20px;
  --font: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color-scheme: dark;
}

/* The page is exactly the screen, like mod: the document itself never moves (no rubber band,
   nothing slides under the iPhone keyboard) and the body scrolls inside it. --app-h follows the
   visible area (/fit.js); without the script it is the dynamic viewport. Apps scroll to the top
   with document.body.scrollTo. */
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html { position: fixed; inset: 0; width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--bg); color: var(--text); }
body {
  position: absolute; inset: 0 0 auto; margin: 0;
  height: var(--app-h, 100dvh);
  overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain; -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  font: 16px/1.5 var(--font); color: var(--text);
  -webkit-text-size-adjust: 100%;
}
body::-webkit-scrollbar { display: none; }
/* a faint purple glow from the top, as in mod */
body::before { content: ""; position: fixed; inset: 0 0 auto; height: 260px; z-index: -1; pointer-events: none; background: radial-gradient(90% 100% at 50% 0, rgba(var(--accent-rgb), .11), transparent 70%); }
[hidden] { display: none !important; }
button, input, select, textarea { font: inherit; color: inherit; }
button { background: none; border: 0; padding: 0; cursor: pointer; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
svg.i { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }
::selection { background: rgba(var(--accent-rgb), .35); }

/* Header: the app's name in lowercase with a purple full stop, round actions on the right */
.app-head {
  position: sticky; top: 0; z-index: 2;
  background: rgba(0, 0, 0, .78);
  -webkit-backdrop-filter: blur(18px) saturate(140%); backdrop-filter: blur(18px) saturate(140%);
  padding: max(10px, calc(env(safe-area-inset-top) + 10px)) max(16px, env(safe-area-inset-right)) 0 max(16px, env(safe-area-inset-left));   /* clear of iOS's fade under the status bar */
}
.app-title { display: flex; align-items: center; gap: 8px; min-height: 48px; }
.app-title h1 { flex: 1; margin: 0; font-size: 30px; font-weight: 700; letter-spacing: -.03em; }
.app-title h1::after { content: "."; color: var(--accent); }

.icon-btn { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; color: var(--muted); flex: none; transition: background .15s, color .15s; }
.icon-btn:active { background: var(--surface-2); }
@media (hover: hover) { .icon-btn:hover { color: var(--text); background: var(--surface-2); } }
.app-title .icon-btn, .sheet-bar > .icon-btn { background: var(--surface); border: 1px solid var(--line); }

/* Buttons: pills; the main one in Ghastly's gradient */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; padding: 10px 18px; border-radius: 999px; background: var(--surface-2); border: 1px solid var(--line-2); color: var(--text); font-weight: 600; font-size: 15px; text-decoration: none; transition: transform .1s, opacity .15s; }
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; }
.btn.primary { background: linear-gradient(145deg, var(--accent), var(--accent-2)); border-color: transparent; color: var(--on-accent); box-shadow: 0 4px 14px rgba(var(--accent-rgb), .28); }
.btn.danger { background: transparent; border-color: transparent; color: var(--danger); box-shadow: none; }

/* Chips: filters and toggles in a sideways-scrolling row */
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 0 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips button { flex: none; padding: 7px 14px; border-radius: 999px; background: var(--surface); border: 1px solid var(--line); color: var(--muted); font-size: 14px; white-space: nowrap; transition: background .15s, color .15s; }
.chips button[aria-pressed="true"] { background: var(--accent-soft); border-color: rgba(var(--accent-rgb), .45); color: var(--text); font-weight: 600; }

/* Fields: 16px so iPhone Safari doesn't zoom when one is tapped */
.field { width: 100%; padding: 12px 14px; border-radius: var(--radius); border: 1px solid var(--line-2); background: var(--surface); font-size: 16px; outline: 0; transition: border-color .2s, box-shadow .2s; }
.field:focus { border-color: rgba(var(--accent-rgb), .55); box-shadow: 0 0 0 4px rgba(var(--accent-rgb), .12); }
.field::placeholder { color: var(--muted); }

/* Full-screen sheets (reader, settings), closed with the back gesture. They are the visible
   screen's height too, so a form's last field stays above the keyboard. The bar sits flush at
   the very top (it carries the phone's status-bar space itself), so nothing scrolls by above it. */
.sheet {
  position: fixed; inset: 0 0 auto; height: var(--app-h, 100dvh); z-index: 5; background: var(--bg); overflow-y: auto;
  padding: 0 0 calc(32px + env(safe-area-inset-bottom));
  overscroll-behavior: contain;               /* scrolling it never moves the page underneath */
  scrollbar-width: none;
}
.sheet::-webkit-scrollbar { display: none; }
/* While a sheet is open the page underneath stays put, so only the sheet scrolls. */
html:has(.sheet:not([hidden])) body { overflow: hidden; }
.sheet-bar { position: sticky; top: 0; z-index: 1; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: max(8px, calc(env(safe-area-inset-top) + 10px)) max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left)); background: rgba(0, 0, 0, .82); -webkit-backdrop-filter: blur(18px); backdrop-filter: blur(18px); }
.sheet-inner { max-width: 680px; margin: 0 auto; padding: 0 20px; }
.sheet h2 { font-size: 24px; font-weight: 700; letter-spacing: -.02em; margin: 8px 0 6px; }

/* Lists with hairline rows */
.rows { list-style: none; margin: 0; padding: 0; }
.rows > li { border-bottom: 1px solid var(--line); }

.note { color: var(--muted); text-align: center; padding: 48px 24px; }
.meta { font-size: 12px; color: var(--muted); }
.meta b { color: var(--accent); font-weight: 600; }

.toast {
  position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 10;
  background: var(--surface-2); color: var(--text); border: 1px solid rgba(var(--accent-rgb), .45); box-shadow: 0 10px 30px rgba(0, 0, 0, .6), 0 0 0 4px rgba(var(--accent-rgb), .08);
  padding: 10px 18px; border-radius: 999px; font-size: 14px; font-weight: 600; max-width: calc(100% - 32px);
}
.toast button { color: var(--accent); }

@keyframes spin { to { transform: rotate(360deg); } }
.spin svg { animation: spin .9s linear infinite; }
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
