/* Focus mode, Music, Quick add, Offline. Layers: page < music dock 55 < ＋ 60 < sheets 70 < focus 85 < dock in focus 86
   < quick add 88 < toasts 90 < offline pill 92 < lock screen 100. */

/* room at the bottom of every page for the ＋ and the music player */
.content { padding-bottom: calc(96px + var(--mp-h, 0px) + env(safe-area-inset-bottom)); }

/* ---------- focus overlay ---------- */
.fm { position: fixed; inset: 0; z-index: 85; display: flex; flex-direction: column; align-items: center; gap: 14px; overflow-x: hidden; overflow-y: auto; overscroll-behavior: contain;
  padding: calc(22px + env(safe-area-inset-top)) 16px calc(18px + env(safe-area-inset-bottom) + var(--mp-h, 0px));
  background: radial-gradient(ellipse at 50% 40%, color-mix(in srgb, var(--a2) 16%, var(--bg)), var(--bg) 72%); }
.fm > * { position: relative; z-index: 1; }
.fm > .aurora { position: absolute; z-index: 0; }
.fm-top { text-align: center; max-width: 640px; }
.fm-title { font-size: calc(clamp(20px, 5vw, 30px) * var(--text-k)); font-weight: 600; letter-spacing: -.01em; margin: 6px 0 4px; overflow-wrap: anywhere; }
.fm-sub { font-size: 11px; letter-spacing: .16em; color: var(--muted); text-transform: uppercase; }
.fm-stage { position: relative; width: min(360px, 80vw, 44dvh); aspect-ratio: 1; flex: none; transition: width .4s cubic-bezier(.2, .8, .2, 1); }
.fm.asking .fm-stage { width: min(210px, 52vw, 26dvh); }
.fm-stage .core { position: absolute; inset: 13%; width: auto; }
.fm-stage .cring { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; }
.fm-stage .cring svg { overflow: visible; }
.fm-stage .cring .cr-t b { font-size: clamp(30px, 9vw, 54px); text-shadow: 0 0 calc(18px * var(--glow-k)) color-mix(in srgb, var(--a1) 60%, transparent); }
.fm.asking .fm-stage .cring .cr-t b { font-size: clamp(22px, 6vw, 30px); }
.fm-hint { font: 600 11.5px var(--mono); letter-spacing: .12em; text-transform: uppercase; color: var(--a1); text-align: center; min-height: 1.3em; max-width: 520px; }
.fm-panel { width: min(480px, 100%); }
.fm-panel:empty { display: none; }
.fm-card { background: color-mix(in srgb, var(--bg) 82%, var(--a1)); }
.fm-pin .lk-pad { grid-template-columns: repeat(3, 58px); gap: 10px; }
.fm-pin .lk-pad button { width: 58px; height: 58px; font-size: 21px; }
.fm-tools { width: min(640px, 100%); display: flex; flex-direction: column; align-items: center; gap: 10px; margin-top: auto; }
.fm-sounds { justify-content: center; }
.fm-tool-row { justify-content: center; }
.fm-vol { width: 120px; flex: none; }
.fm-leave { border-color: color-mix(in srgb, var(--a1) 40%, transparent); }
body.fm-on .qa-fab { display: none; }
body.fm-on { overflow: hidden; }
:root[data-motion="calm"] .fm-stage { transition: none; }

/* focus page */
.fm-setup select, .fm-setup input:not([type="range"]) { max-width: 100%; }
.fm-dial .dial { width: min(220px, 64vw); }
.fm-go { min-height: 52px; font-size: calc(16px * var(--text-k)); }

/* ---------- music ---------- */
.mu-list { list-style: none; margin: 10px 0 0; padding: 0; display: flex; flex-direction: column; }
.mu-row { display: flex; align-items: center; gap: 10px; padding: 10px 4px; border-bottom: 1px solid var(--edge-2); border-radius: 12px; background: transparent; min-width: 0; }
.mu-row:last-child { border-bottom: 0; }
.mu-row.on { background: color-mix(in srgb, var(--a1) 10%, transparent); }
.mu-handle { cursor: grab; touch-action: none; padding: 8px 2px; color: var(--faint); user-select: none; -webkit-user-select: none; }
.mu-em { font-size: 22px; width: 28px; text-align: center; flex: none; }
.mu-acts { flex: none; }
.mu-acts .btn { min-width: 36px; }

.mp-dock { position: fixed; z-index: 55; left: 16px; right: 16px; bottom: calc(12px + env(safe-area-inset-bottom)); padding: 8px; border-radius: 16px;
  background: color-mix(in srgb, var(--bg) 86%, var(--a1)); }
.mp-bar { display: flex; align-items: center; gap: 6px; min-width: 0; }
.mp-bar > span { font-size: 18px; padding: 0 4px; flex: none; }
.mp-bar .btn { flex: none; }
.mp-body { margin-top: 8px; border-radius: 12px; overflow: hidden; }
.mp-body iframe { display: block; width: 100%; height: min(450px, 46dvh); border: 0; border-radius: 12px; background: transparent; }
.mp-dock.song .mp-body iframe { height: 175px; }
.mp-dock.closed .mp-body { height: 0; margin: 0; } /* the player keeps playing while hidden */
body.mp-on .qa-fab { bottom: calc(24px + var(--mp-h, 0px) + env(safe-area-inset-bottom)); }
body.mp-on .toast { bottom: calc(24px + var(--mp-h, 0px) + env(safe-area-inset-bottom)); }
body.fm-on .mp-dock { z-index: 86; }
@media (min-width: 900px) { .mp-dock { left: auto; right: 24px; width: 400px; } }
#shell[hidden] ~ .mp-dock, #shell[hidden] ~ .qa-fab { display: none; }

/* ---------- quick add ---------- */
.qa-fab { position: fixed; z-index: 60; right: 18px; bottom: calc(18px + env(safe-area-inset-bottom)); width: 56px; height: 56px; border-radius: 50%; border: 0; padding: 0; cursor: pointer;
  display: grid; place-items: center; font: 400 30px / 1 var(--font); color: var(--bg); background: linear-gradient(135deg, var(--a1), var(--a2));
  box-shadow: var(--glow), 0 0 0 1px color-mix(in srgb, var(--a3) 40%, transparent), var(--shadow); transition: transform .15s, box-shadow .2s; }
.qa-fab::after { content: ""; position: absolute; inset: -6px; border-radius: 50%; border: 1px solid color-mix(in srgb, var(--a1) 60%, transparent); animation: qa-ping calc(2.8s / max(var(--motion-k), .1)) ease-out infinite; pointer-events: none; }
.qa-fab:hover { transform: scale(1.06); }
.qa-fab:active { transform: scale(.94); }
.qa-fab:focus-visible { outline: 2px solid var(--a3); outline-offset: 3px; }
@keyframes qa-ping { 0% { transform: scale(.9); opacity: .9; } 80%, 100% { transform: scale(1.35); opacity: 0; } }
:root[data-motion="calm"] .qa-fab::after { animation: none; opacity: .5; }
body.qa-on .qa-fab { display: none; }

.qa-back { position: fixed; inset: 0; z-index: 88; display: flex; align-items: flex-start; justify-content: center; padding: calc(10vh + env(safe-area-inset-top)) 16px 16px;
  background: rgb(0 0 0 / .55); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); animation: fade .2s ease; overflow-y: auto; }
.qa-panel { width: min(620px, 100%); padding: 14px; display: flex; flex-direction: column; gap: 12px; background: color-mix(in srgb, var(--bg) 88%, var(--a1)); box-shadow: var(--glow), var(--shadow); animation: rise .22s ease; }
.qa-row { align-items: center; }
.qa-plus { font-size: 24px; color: var(--a1); flex: none; text-shadow: 0 0 12px var(--a1); }
.qa-input { flex: 1; min-width: 0; font-size: 18px; border: 0; background: none; box-shadow: none !important; padding: 8px 2px; }
.qa-preview { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; min-height: 34px; min-width: 0; font-weight: 600; color: var(--text); }
.qa-preview .ellipsis { flex: 1 1 160px; }
.qa-arrow { color: var(--a1); font-size: 18px; }
.qa-kinds .chip { padding: 5px 10px; }
.qa-recent .list li { padding-bottom: 8px; }
.qa-toast { display: flex; align-items: center; gap: 10px; }
.mic-btn.live { animation: pop 1s ease-in-out infinite; }
@media (max-width: 560px) { .qa-keys { display: none; } .qa-back { padding-top: calc(12px + env(safe-area-inset-top)); } }

/* ---------- offline ---------- */
.off-pill { position: fixed; z-index: 92; left: 50%; transform: translateX(-50%); top: calc(10px + env(safe-area-inset-top)); max-width: calc(100% - 32px);
  font: 600 11px var(--mono); letter-spacing: .08em; padding: 6px 12px; border-radius: 99px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  border: 1px solid var(--warn); color: var(--text); background: color-mix(in srgb, var(--bg) 82%, var(--warn)); box-shadow: 0 0 14px color-mix(in srgb, var(--warn) 30%, transparent); pointer-events: none; }
@media (max-width: 860px) { .off-pill { top: calc(62px + env(safe-area-inset-top)); } }
@media (prefers-reduced-motion: reduce) { .qa-fab::after, .mic-btn.live { animation: none; } .fm-stage { transition: none; } }
