/* Shelf — shared mobile layer.
 *
 * Two audiences:
 *  1. The app's own pages (auth, profile/settings, messages): everything under
 *     `.app-page`.
 *  2. The WatchList / Comics / Books pages: an overlay that only switches on at
 *     phone width or inside the installed app (`html.is-app`), so the desktop
 *     site is untouched.
 *
 * Colors lean on the modules' own tokens (--bg, --panel, --accent...) when they
 * exist and fall back to the same values on the app's pages.
 */

:root {
  --app-bg: var(--bg, #0f1117);
  --app-panel: var(--panel, #1a1d27);
  --app-panel-2: var(--panel-2, #232733);
  --app-text: var(--text, #e6e8ee);
  --app-muted: var(--muted, #8b90a0);
  --app-border: var(--border, #2c3140);
  --app-danger: #ef4444;
  --app-ok: #22c55e;
  --app-violet: #7c3aed;
  --app-amber: #eab308;
  --app-emerald: #10b981;
  --app-accent: var(--accent, #7c3aed);
  --app-radius: 16px;
  --app-tabbar-h: 64px;
  --app-safe-top: env(safe-area-inset-top, 0px);
  --app-safe-bottom: env(safe-area-inset-bottom, 0px);
  --app-ease: cubic-bezier(.2, .8, .2, 1);
}

/* ======================================================================
 * 1. Tab bar + toast + pull-to-refresh (used on every app surface)
 * ==================================================================== */

.app-tabbar {
  display: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 900;
  height: calc(var(--app-tabbar-h) + var(--app-safe-bottom));
  padding: 0 6px var(--app-safe-bottom);
  background: color-mix(in srgb, var(--app-panel) 88%, transparent);
  -webkit-backdrop-filter: saturate(160%) blur(18px);
  backdrop-filter: saturate(160%) blur(18px);
  border-top: 1px solid var(--app-border);
  justify-content: space-around;
  align-items: stretch;
}
.app-tab {
  --tab-accent: var(--app-violet);
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  min-width: 0;
  color: var(--app-muted);
  text-decoration: none;
  font: 600 11px/1 "Plus Jakarta Sans", system-ui, sans-serif;
  letter-spacing: .01em;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition: color .2s var(--app-ease);
}
.app-tab i { font-size: 20px; transition: transform .25s var(--app-ease); }
.app-tab .app-tab-pill {
  display: grid;
  place-items: center;
  width: 56px;
  height: 30px;
  border-radius: 999px;
  transition: background-color .25s var(--app-ease);
}
.app-tab.active { color: var(--app-text); }
.app-tab.active .app-tab-pill { background: color-mix(in srgb, var(--tab-accent) 22%, transparent); }
.app-tab.active i { color: var(--tab-accent); transform: translateY(-1px); }
.app-tab:active i { transform: scale(.9); }
.app-tab:focus-visible { outline: 2px solid var(--tab-accent); outline-offset: -6px; border-radius: 12px; }

.app-toast-host {
  position: fixed;
  left: 12px; right: 12px;
  bottom: calc(var(--app-tabbar-h) + var(--app-safe-bottom) + 12px);
  z-index: 1300;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}
body:not(.has-app-tabbar) .app-toast-host { bottom: calc(var(--app-safe-bottom) + 16px); }
.app-toast {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 520px;
  width: 100%;
  padding: 12px 12px 12px 16px;
  border-radius: 14px;
  background: #f4f5f8;
  color: #111318;
  font: 600 14px/1.35 "Plus Jakarta Sans", system-ui, sans-serif;
  box-shadow: 0 10px 30px rgba(0,0,0,.45);
  animation: app-toast-in .28s var(--app-ease);
}
.app-toast.leaving { animation: app-toast-out .2s ease-in forwards; }
.app-toast .app-toast-msg { flex: 1; min-width: 0; }
.app-toast .app-toast-icon { font-size: 16px; }
.app-toast.ok .app-toast-icon { color: #15803d; }
.app-toast.err .app-toast-icon { color: #dc2626; }
.app-toast button {
  border: 0;
  background: transparent;
  color: #6d28d9;
  font: 800 14px/1 "Plus Jakarta Sans", system-ui, sans-serif;
  padding: 10px 10px;
  border-radius: 10px;
  min-height: 40px;
  cursor: pointer;
}
.app-toast button:active { background: rgba(0,0,0,.06); }
@keyframes app-toast-in { from { opacity: 0; transform: translateY(12px) scale(.98); } }
@keyframes app-toast-out { to { opacity: 0; transform: translateY(8px); } }

.app-ptr {
  position: fixed;
  top: calc(var(--app-safe-top) + 8px);
  left: 50%;
  z-index: 950;
  width: 40px; height: 40px;
  margin-left: -20px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: var(--app-panel-2);
  border: 1px solid var(--app-border);
  color: var(--app-accent);
  box-shadow: 0 6px 18px rgba(0,0,0,.35);
  transform: translateY(-70px);
  opacity: 0;
  pointer-events: none;
}
.app-ptr i { transition: transform .1s linear; }
.app-ptr.refreshing i { animation: app-spin .8s linear infinite; }
@keyframes app-spin { to { transform: rotate(360deg); } }

/* ======================================================================
 * 2. Overlay for the media modules (phone width, or inside the app)
 * ==================================================================== */

@media (max-width: 700px) {
  body.has-app-tabbar .app-tabbar { display: flex; }
  body.has-app-tabbar { padding-bottom: calc(var(--app-tabbar-h) + var(--app-safe-bottom) + 8px); }
  #app-version-line { display: none !important; }

  /* Compact, sticky app bar built from the module's existing nav. */
  body.has-app-tabbar > .nav {
    position: sticky;
    top: 0;
    z-index: 800;
    padding: calc(var(--app-safe-top) + 10px) 16px 10px;
    gap: 14px;
    min-height: calc(56px + var(--app-safe-top));
    background: color-mix(in srgb, var(--app-bg) 86%, transparent);
    -webkit-backdrop-filter: saturate(160%) blur(16px);
    backdrop-filter: saturate(160%) blur(16px);
    border-bottom: 1px solid transparent;
    transition: border-color .2s ease;
  }
  body.has-app-tabbar.app-scrolled > .nav { border-bottom-color: var(--app-border); }
  /* The hub link and the module link are replaced by the tab bar; the module
     name stays as the app bar title. */
  body.has-app-tabbar > .nav > a[href="/"] { display: none; }
  body.has-app-tabbar > .nav > a.active {
    color: var(--app-text);
    font-size: 20px;
    font-weight: 800;
    letter-spacing: -.01em;
  }
  body.has-app-tabbar .notif-bell {
    display: grid;
    place-items: center;
    width: 44px; height: 44px;
    margin-right: -8px;
    border-radius: 12px;
    color: var(--app-text);
  }
  body.has-app-tabbar .notif-bell:active { background: var(--app-panel-2); }
  body.has-app-tabbar .notif-badge { top: 4px; right: 2px; }
  body.has-app-tabbar .app-bar-profile {
    display: grid;
    place-items: center;
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--app-violet), var(--app-emerald));
    color: #fff !important;
    font: 800 14px/1 "Plus Jakarta Sans", system-ui, sans-serif;
    text-transform: uppercase;
  }

  /* The page's own title + blurb duplicate the app bar. */
  body.has-app-tabbar .wl-header { display: none; }
  body.has-app-tabbar .wl-main { padding-top: 4px; }
  body.has-app-tabbar .tabs { margin-top: 4px; position: sticky; top: calc(56px + var(--app-safe-top)); z-index: 700; background: var(--app-bg); }
  body.has-app-tabbar .tab-move-group { display: none; }
  /* Drag handles on list tabs: HTML5 drag doesn't work with touch, so they're noise here. */
  body.has-app-tabbar .tab-drag { display: none; }
  body.has-app-tabbar .modal-card > h3:first-of-type { margin-top: 0; }
  body.has-app-tabbar .modal-card { gap: 10px; }

  /* ---- Bottom sheets: every centred modal becomes a sheet ---- */
  body.has-app-tabbar .modal {
    align-items: flex-end;
    padding: 0;
    background: rgba(0,0,0,.55);
    animation: app-fade-in .2s ease;
  }
  body.has-app-tabbar .modal-card,
  body.has-app-tabbar .title-modal-card {
    width: 100%;
    max-width: 100%;
    max-height: calc(100dvh - var(--app-safe-top) - 24px);
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 22px 22px 0 0;
    border-bottom: 0;
    padding: 8px 20px calc(20px + var(--app-safe-bottom));
    animation: app-sheet-in .32s var(--app-ease);
    touch-action: pan-y;
  }
  body.has-app-tabbar .title-modal { align-items: flex-end; padding: 0; overflow: hidden; }
  body.has-app-tabbar .title-modal-card { padding: 0 0 var(--app-safe-bottom); display: flex; flex-direction: column; }
  body.has-app-tabbar .title-modal-body { padding: 0 16px 20px; }
  body.has-app-tabbar .modal-card input,
  body.has-app-tabbar .modal-card select,
  body.has-app-tabbar .modal-card textarea { font-size: 16px; min-height: 46px; padding: 10px 12px; border-radius: 10px; }
  body.has-app-tabbar .modal-actions {
    position: sticky;
    bottom: calc(-20px - var(--app-safe-bottom));
    margin: 8px -20px calc(-20px - var(--app-safe-bottom));
    padding: 12px 20px calc(12px + var(--app-safe-bottom));
    background: var(--app-panel);
    border-top: 1px solid var(--app-border);
    display: grid;
    grid-auto-flow: column;
    grid-auto-columns: 1fr;
    gap: 10px;
  }
  body.has-app-tabbar .modal-actions > * { min-height: 48px; font-size: 15px; border-radius: 12px; }
  .app-sheet-handle {
    display: block;
    width: 100%;
    height: 22px;
    margin: 0 0 4px;
    border: 0;
    background: transparent;
    position: sticky;
    top: -8px;
    z-index: 2;
    cursor: grab;
    touch-action: none;
  }
  .app-sheet-handle::before {
    content: "";
    display: block;
    width: 40px; height: 5px;
    margin: 8px auto 0;
    border-radius: 999px;
    background: var(--app-border);
  }
  body.app-sheet-open { overflow: hidden; }

  /* Anchored popovers become sheets too (inline top/left from JS is overridden). */
  body.has-app-tabbar .addto-popover,
  body.has-app-tabbar .whatsnew-popover,
  body.has-app-tabbar .lang-popover {
    position: fixed !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    bottom: 0 !important;
    width: auto !important;
    max-height: 70dvh;
    overflow-y: auto;
    border-radius: 22px 22px 0 0;
    padding: 14px 16px calc(16px + var(--app-safe-bottom) + var(--app-tabbar-h));
    z-index: 1200;
    box-shadow: 0 -20px 50px rgba(0,0,0,.5);
    animation: app-sheet-in .28s var(--app-ease);
  }
  body.has-app-tabbar .addto-row { min-height: 48px; font-size: 16px; display: flex; align-items: center; gap: 12px; }
  body.has-app-tabbar .addto-row input { width: 22px; height: 22px; accent-color: var(--app-accent); }
  body.has-app-tabbar .addto-foot input { font-size: 16px; min-height: 44px; }
  body.has-app-tabbar .notif-panel {
    position: fixed;
    left: 8px; right: 8px;
    top: calc(var(--app-safe-top) + 60px);
    width: auto;
    max-height: calc(100dvh - var(--app-safe-top) - var(--app-tabbar-h) - var(--app-safe-bottom) - 80px);
    border-radius: 18px;
    z-index: 1150;
  }

  /* ---- Cards ---- */
  body.has-app-tabbar .card { border-radius: 14px; }
  body.has-app-tabbar .btn-follow, body.has-app-tabbar .btn-hide { width: 36px; height: 36px; }

  /* ---- Title detail page ---- */
  body.has-app-tabbar .back-link {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 44px;
    padding: 0 14px 0 10px;
    margin: 0 0 8px -6px;
    border-radius: 12px;
    font-weight: 700;
  }
  body.has-app-tabbar .detail { display: flex; flex-direction: column; gap: 16px; }
  body.has-app-tabbar .detail-poster {
    width: min(58vw, 240px);
    margin: 0 auto;
  }
  body.has-app-tabbar .detail-poster img { border-radius: 16px; box-shadow: 0 18px 40px rgba(0,0,0,.5); }
  body.has-app-tabbar .detail-body h1 { font-size: 1.6rem; line-height: 1.2; text-align: center; margin: 4px 0 10px; }
  body.has-app-tabbar .detail-body > .meta { justify-content: center; display: flex; flex-wrap: wrap; gap: 6px; }
  body.has-app-tabbar .detail .panel { border-radius: 16px; }
  body.has-app-tabbar .detail .panel .btn,
  body.has-app-tabbar .detail .panel .btn-sm { min-height: 46px; border-radius: 12px; }
  body.has-app-tabbar .detail .panel select,
  body.has-app-tabbar .detail .panel input,
  body.has-app-tabbar .detail .panel textarea { font-size: 16px; min-height: 44px; }
}

/* Left-swipe "add to list" reveal (the right-swipe "Hide" overlay is in each
   module's stylesheet). */
.card.swipeable::before {
  content: "\f02e  Add";
  font-family: "Font Awesome 6 Free", "Plus Jakarta Sans", system-ui, sans-serif;
  font-weight: 900;
  position: absolute;
  inset: 0;
  z-index: 3;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 17px;
  letter-spacing: .02em;
  background: linear-gradient(270deg, color-mix(in srgb, var(--accent-2, #00b894) 92%, transparent), color-mix(in srgb, var(--accent-2, #00b894) 55%, transparent));
  border-radius: inherit;
  opacity: var(--swipe-add-progress, 0);
  pointer-events: none;
}


/* Inside the installed app the shell stays on at every width (tablets). */
html.is-app body.has-app-tabbar .app-tabbar { display: flex; }
html.is-app body.has-app-tabbar { padding-bottom: calc(var(--app-tabbar-h) + var(--app-safe-bottom) + 8px); }
html.is-app body.has-app-tabbar > .nav > a[href="/"] { display: none; }
html.is-app #app-version-line { display: none !important; }
html.is-app { -webkit-tap-highlight-color: transparent; }
html.is-app body { overscroll-behavior-y: contain; }

@keyframes app-sheet-in { from { transform: translateY(100%); } }
@keyframes app-fade-in { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  .app-toast, .app-toast.leaving,
  body.has-app-tabbar .modal, body.has-app-tabbar .modal-card, body.has-app-tabbar .title-modal-card,
  body.has-app-tabbar .addto-popover, body.has-app-tabbar .whatsnew-popover, body.has-app-tabbar .lang-popover {
    animation: none !important;
  }
  .app-tab i, .app-tab .app-tab-pill { transition: none; }
}

/* ======================================================================
 * 3. The app's own pages
 * ==================================================================== */

.app-page {
  margin: 0;
  min-height: 100dvh;
  background: var(--app-bg);
  color: var(--app-text);
  font: 400 16px/1.5 "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.app-page *, .app-page *::before, .app-page *::after { box-sizing: border-box; }
.app-page [hidden] { display: none !important; }
.app-page a { color: inherit; }
.app-page :where(button, input, select) { font: inherit; color: inherit; }

.app-screen {
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  min-height: 100dvh;
  padding: calc(var(--app-safe-top) + 12px) 20px calc(var(--app-safe-bottom) + 24px);
  display: flex;
  flex-direction: column;
}
.app-screen--tabbed { padding-bottom: calc(var(--app-tabbar-h) + var(--app-safe-bottom) + 24px); max-width: 640px; }

.app-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 52px;
  margin: 0 -8px 8px;
}
.app-topbar h1 { margin: 0; font-size: 20px; font-weight: 800; letter-spacing: -.01em; flex: 1; }
.app-icon-btn {
  display: grid;
  place-items: center;
  width: 44px; height: 44px;
  border-radius: 12px;
  border: 0;
  background: transparent;
  color: var(--app-text);
  cursor: pointer;
  text-decoration: none;
  font-size: 18px;
}
.app-icon-btn:active { background: var(--app-panel-2); }

/* Brand */
.app-brand { display: flex; align-items: center; gap: 12px; }
.app-logo {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid;
  place-items: center;
  background: conic-gradient(from 210deg, var(--app-violet), var(--app-amber), var(--app-emerald), var(--app-violet));
  box-shadow: 0 8px 22px rgba(124,58,237,.35);
  color: #fff;
  font-size: 20px;
}
.app-logo > span {
  width: 36px; height: 36px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: #121420;
}
.app-brand-name { font-size: 22px; font-weight: 800; letter-spacing: -.02em; }

/* Welcome hero */
.app-hero { flex: 1; display: flex; flex-direction: column; justify-content: center; gap: 28px; padding: 24px 0; }
.app-hero h2 { margin: 0; font-size: clamp(30px, 8.5vw, 40px); line-height: 1.1; letter-spacing: -.03em; font-weight: 800; }
.app-hero h2 em {
  font-style: normal;
  background: linear-gradient(90deg, #a78bfa, #fbbf24 55%, #34d399);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.app-hero p { margin: 0; color: var(--app-muted); font-size: 16px; }
.app-stack { position: relative; height: 188px; margin: 4px 0; }
.app-stack .poster {
  position: absolute;
  top: 10px;
  width: 112px; height: 164px;
  border-radius: 14px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 12px;
  font-weight: 800;
  font-size: 13px;
  color: #fff;
  box-shadow: 0 18px 40px rgba(0,0,0,.45);
  border: 1px solid rgba(255,255,255,.08);
}
.app-stack .poster i { font-size: 26px; margin-bottom: auto; opacity: .95; }
.app-stack .poster small { display: block; font-weight: 600; opacity: .8; font-size: 11px; }
.app-stack .p1 { left: calc(50% - 172px); top: 18px; transform: rotate(-8deg); background: linear-gradient(160deg, #8b5cf6, #4c1d95); }
.app-stack .p2 { left: calc(50% - 56px); top: 0; z-index: 2; background: linear-gradient(160deg, #facc15, #a16207); }
.app-stack .p3 { left: calc(50% + 60px); top: 18px; transform: rotate(8deg); background: linear-gradient(160deg, #34d399, #065f46); }

/* Forms */
.app-form { display: flex; flex-direction: column; gap: 16px; }
.app-heading { margin: 8px 0 4px; }
.app-heading h2 { margin: 0 0 6px; font-size: 28px; line-height: 1.15; letter-spacing: -.02em; font-weight: 800; }
.app-heading p { margin: 0; color: var(--app-muted); }
.app-field { display: flex; flex-direction: column; gap: 6px; }
.app-field > label, .app-field > .app-row-between > label { font-size: 13px; font-weight: 700; color: var(--app-muted); letter-spacing: .01em; }
.app-input-wrap { position: relative; display: flex; align-items: center; }
.app-input-wrap > i.lead { position: absolute; left: 14px; color: var(--app-muted); font-size: 15px; pointer-events: none; }
.app-input {
  width: 100%;
  min-height: 54px;
  padding: 14px 14px 14px 42px;
  border-radius: 14px;
  border: 1.5px solid var(--app-border);
  background: var(--app-panel);
  font-size: 16px;
  outline: none;
  transition: border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
}
.app-input.no-lead { padding-left: 14px; }
.app-input::placeholder { color: #5f6475; }
.app-input:focus { border-color: #8b5cf6; box-shadow: 0 0 0 4px rgba(139,92,246,.18); background: var(--app-panel-2); }
.app-input[aria-invalid="true"] { border-color: var(--app-danger); box-shadow: 0 0 0 4px rgba(239,68,68,.15); }
.app-input-wrap .app-reveal {
  position: absolute;
  right: 4px;
  width: 46px; height: 46px;
  border: 0;
  background: transparent;
  color: var(--app-muted);
  border-radius: 10px;
  cursor: pointer;
}
.app-input-wrap .app-reveal + .app-input, .app-input.has-reveal { padding-right: 52px; }
.app-hint { font-size: 13px; color: var(--app-muted); }
.app-field-error { font-size: 13px; color: #fca5a5; display: flex; gap: 6px; align-items: flex-start; }

.app-strength { display: flex; gap: 6px; margin-top: 2px; }
.app-strength span { flex: 1; height: 4px; border-radius: 999px; background: var(--app-border); transition: background-color .2s ease; }
.app-strength[data-score="1"] span:nth-child(-n+1) { background: #ef4444; }
.app-strength[data-score="2"] span:nth-child(-n+2) { background: #f59e0b; }
.app-strength[data-score="3"] span:nth-child(-n+3) { background: #84cc16; }
.app-strength[data-score="4"] span { background: #22c55e; }
.app-checklist { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 4px; font-size: 13px; color: var(--app-muted); }
.app-checklist li { display: flex; gap: 8px; align-items: center; }
.app-checklist li i { width: 14px; text-align: center; }
.app-checklist li.ok { color: #86efac; }

.app-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: 54px;
  padding: 0 20px;
  border-radius: 14px;
  border: 0;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: .01em;
  cursor: pointer;
  text-decoration: none;
  transition: transform .12s ease, filter .15s ease, background-color .15s ease;
  -webkit-tap-highlight-color: transparent;
}
.app-btn:active { transform: scale(.98); }
.app-btn:disabled { opacity: .6; cursor: default; transform: none; }
.app-btn-primary { background: linear-gradient(135deg, #8b5cf6, #6d28d9); color: #fff; box-shadow: 0 10px 24px rgba(109,40,217,.35); }
.app-btn-secondary { background: var(--app-panel-2); color: var(--app-text); border: 1px solid var(--app-border); }
.app-btn-ghost { background: transparent; color: var(--app-text); }
.app-btn-danger { background: #dc2626; color: #fff; }
.app-btn-danger-soft { background: rgba(239,68,68,.12); color: #fca5a5; border: 1px solid rgba(239,68,68,.25); }
.app-btn .spinner {
  width: 18px; height: 18px;
  border-radius: 50%;
  border: 2.5px solid rgba(255,255,255,.35);
  border-top-color: #fff;
  animation: app-spin .7s linear infinite;
}
.app-link-btn { background: none; border: 0; padding: 8px 4px; color: #c4b5fd; font-weight: 700; cursor: pointer; text-decoration: none; min-height: 44px; display: inline-flex; align-items: center; }
.app-row-between { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.app-center { text-align: center; }
.app-muted { color: var(--app-muted); }
.app-spacer { flex: 1; }
.app-actions { display: flex; flex-direction: column; gap: 10px; }
.app-footer-note { text-align: center; color: var(--app-muted); font-size: 14px; margin-top: 16px; }

.app-alert {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 12px 14px;
  border-radius: 14px;
  font-size: 14px;
  border: 1px solid;
}
.app-alert i { margin-top: 3px; }
.app-alert.err { background: rgba(239,68,68,.1); border-color: rgba(239,68,68,.3); color: #fecaca; }
.app-alert.ok { background: rgba(34,197,94,.1); border-color: rgba(34,197,94,.3); color: #bbf7d0; }
.app-alert.info { background: rgba(139,92,246,.1); border-color: rgba(139,92,246,.3); color: #ddd6fe; }
.app-alert .app-link-btn { padding: 0; min-height: 0; color: inherit; text-decoration: underline; }

/* Switch */
.app-switch { position: relative; display: inline-block; width: 52px; height: 32px; flex-shrink: 0; }
.app-switch input { position: absolute; opacity: 0; inset: 0; margin: 0; cursor: pointer; z-index: 1; }
.app-switch .track {
  position: absolute; inset: 0;
  border-radius: 999px;
  background: #3a3f50;
  transition: background-color .2s var(--app-ease);
}
.app-switch .track::after {
  content: "";
  position: absolute;
  top: 3px; left: 3px;
  width: 26px; height: 26px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 6px rgba(0,0,0,.35);
  transition: transform .22s var(--app-ease);
}
.app-switch input:checked + .track { background: #8b5cf6; }
.app-switch input:checked + .track::after { transform: translateX(20px); }
.app-switch input:focus-visible + .track { outline: 2px solid #c4b5fd; outline-offset: 2px; }
.app-switch input:disabled + .track { opacity: .45; }

/* Settings list */
.app-profile-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 18px;
  border-radius: 20px;
  background:
    radial-gradient(120% 140% at 0% 0%, rgba(139,92,246,.28), transparent 60%),
    radial-gradient(120% 140% at 100% 100%, rgba(16,185,129,.18), transparent 60%),
    var(--app-panel);
  border: 1px solid var(--app-border);
  margin-bottom: 8px;
}
.app-avatar {
  width: 56px; height: 56px;
  flex-shrink: 0;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 22px;
  font-weight: 800;
  color: #fff;
  text-transform: uppercase;
  background: linear-gradient(135deg, var(--app-violet), var(--app-emerald));
}
.app-profile-card .who { min-width: 0; flex: 1; }
.app-profile-card .who strong { display: block; font-size: 18px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-profile-card .who span { display: block; color: var(--app-muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.app-badge { display: inline-flex; align-items: center; gap: 6px; padding: 3px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.app-badge.warn { background: rgba(234,179,8,.14); color: #fde68a; }
.app-badge.ok { background: rgba(34,197,94,.14); color: #86efac; }

.app-section { margin-top: 22px; }
.app-section > h3 {
  margin: 0 4px 8px;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--app-muted);
  font-weight: 800;
}
.app-section > .app-section-note { margin: 8px 6px 0; font-size: 13px; color: var(--app-muted); }
.app-list {
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-radius: 18px;
  overflow: hidden;
}
.app-row {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  min-height: 60px;
  padding: 12px 16px;
  background: transparent;
  border: 0;
  text-align: left;
  text-decoration: none;
  color: var(--app-text);
  cursor: default;
}
button.app-row, a.app-row, label.app-row { cursor: pointer; }
button.app-row:active, a.app-row:active { background: var(--app-panel-2); }
.app-row + .app-row, .app-row + .app-subrows, .app-subrows + .app-row { border-top: 1px solid var(--app-border); }
.app-row .ico {
  width: 34px; height: 34px;
  flex-shrink: 0;
  display: grid;
  place-items: center;
  border-radius: 10px;
  font-size: 15px;
  color: #fff;
}
.ico.violet { background: #7c3aed; }
.ico.amber { background: #ca8a04; }
.ico.emerald { background: #059669; }
.ico.blue { background: #2563eb; }
.ico.pink { background: #db2777; }
.ico.slate { background: #475569; }
.ico.red { background: #dc2626; }
.app-row .txt { flex: 1; min-width: 0; }
.app-row .txt strong { display: block; font-weight: 700; font-size: 15px; }
.app-row .txt small { display: block; color: var(--app-muted); font-size: 13px; line-height: 1.35; margin-top: 2px; }
.app-row .end { color: var(--app-muted); display: flex; align-items: center; gap: 8px; font-size: 14px; }
.app-row.danger .txt strong { color: #fca5a5; }
.app-subrows { transition: opacity .2s ease; }
.app-subrows.disabled { opacity: .45; pointer-events: none; }

.app-section[aria-busy="true"] { pointer-events: none; }
.app-section[aria-busy="true"] .app-switch,
.app-section[aria-busy="true"] .app-segmented,
.app-section[aria-busy="true"] .app-time-row,
.app-section[aria-busy="true"] [data-bind="quiet-times"] {
  opacity: .35;
  animation: app-busy-pulse 1.1s ease-in-out infinite;
}
@keyframes app-busy-pulse { 50% { opacity: .15; } }

.app-segmented {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 4px;
  padding: 4px;
  margin: 0 16px 14px;
  background: var(--app-bg);
  border: 1px solid var(--app-border);
  border-radius: 14px;
}
.app-segmented button {
  min-height: 40px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--app-muted);
  font-weight: 700;
  font-size: 13px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 0 6px;
}
.app-segmented button[aria-pressed="true"] { background: var(--app-panel-2); color: var(--app-text); box-shadow: 0 2px 8px rgba(0,0,0,.25); }
.app-segmented button i { font-size: 13px; }

.app-time-row { display: flex; gap: 10px; padding: 0 16px 14px; }
.app-time-row label { flex: 1; display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--app-muted); font-weight: 700; }
.app-time-row input {
  min-height: 46px;
  border-radius: 12px;
  border: 1.5px solid var(--app-border);
  background: var(--app-bg);
  padding: 0 12px;
  font-size: 16px;
  color-scheme: dark;
}

/* Sheet on app pages */
.app-sheet-backdrop {
  position: fixed; inset: 0;
  z-index: 1000;
  background: rgba(0,0,0,.55);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  animation: app-fade-in .2s ease;
}
.app-sheet {
  width: 100%;
  max-width: 560px;
  max-height: calc(100dvh - var(--app-safe-top) - 20px);
  overflow-y: auto;
  background: var(--app-panel);
  border: 1px solid var(--app-border);
  border-bottom: 0;
  border-radius: 24px 24px 0 0;
  padding: 6px 20px calc(20px + var(--app-safe-bottom));
  animation: app-sheet-in .3s var(--app-ease);
}
.app-sheet h3 { margin: 6px 0 6px; font-size: 20px; }
.app-sheet p { color: var(--app-muted); margin: 0 0 16px; }
.app-sheet .app-form { gap: 14px; }
.app-sheet .app-sheet-handle { display: block; }
@media (min-width: 701px) {
  .app-sheet-backdrop { align-items: center; }
  .app-sheet { border-radius: 24px; border-bottom: 1px solid var(--app-border); }
  .app-sheet .app-sheet-handle { display: none; }
}
.app-sheet-handle-static { display: block; width: 40px; height: 5px; border-radius: 999px; background: var(--app-border); margin: 6px auto 10px; }

.app-message { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center; gap: 14px; padding: 24px 8px; }
.app-message .big-ico {
  width: 84px; height: 84px;
  border-radius: 26px;
  display: grid;
  place-items: center;
  font-size: 34px;
  background: var(--app-panel-2);
  border: 1px solid var(--app-border);
  color: #c4b5fd;
}
.app-message h2 { margin: 6px 0 0; font-size: 26px; letter-spacing: -.02em; }
.app-message p { margin: 0; color: var(--app-muted); max-width: 360px; }
.app-mail-art { position: relative; }
.app-mail-art .dot { position: absolute; top: -4px; right: -4px; width: 20px; height: 20px; border-radius: 50%; background: var(--app-emerald); border: 3px solid var(--app-bg); }

.app-page .app-tabbar { display: flex; }
@media (min-width: 701px) {
  .app-page .app-tabbar {
    left: 50%;
    right: auto;
    width: min(560px, 100%);
    transform: translateX(-50%);
    border: 1px solid var(--app-border);
    border-bottom: 0;
    border-radius: 20px 20px 0 0;
  }
}
.app-about { margin: 28px 0 8px; text-align: center; font-size: 12px; color: #5f6475; }
