/* QUIZ-WORLD workspace dock (qw-dock.js): floating glass navigation with a gliding pill, More / Quick-create sheets and a command palette.
   Replaces the old left sidebar once signed in. Light and dark follow [data-theme]. Only transform/opacity animate. */
:root {
  --qd-glass: color-mix(in srgb, var(--surface) 82%, transparent); --qd-line: color-mix(in srgb, var(--text) 14%, transparent);
  --qd-shadow: var(--shadow-float), inset 0 1px 0 color-mix(in srgb, var(--text) 10%, transparent);
  --qd-text: var(--text-muted); --qd-active: var(--accent-text); --qd-pill: color-mix(in srgb, var(--text) 10%, var(--surface)); --qd-pill-shadow: 0 0 20px color-mix(in srgb, var(--accent) 22%, transparent), inset 0 1px 0 color-mix(in srgb, var(--text) 12%, transparent);
  --qd-accent: var(--accent-text); --qd-accent-2: var(--accent); --qd-plus-a: var(--surface-hover); --qd-plus-b: var(--surface-hover); --qd-spring: cubic-bezier(.34, 1.56, .64, 1); --qd-liquid: cubic-bezier(.16, 1, .3, 1);
  --qd-sheet: var(--bg); --qd-sheet-line: var(--border); --qd-tile: var(--surface); --qd-tile-on: var(--surface-hover); --qd-muted: var(--text-muted); --qd-h: 76px;
}
[data-theme="dark"] {
  --qd-glass: color-mix(in srgb, var(--surface) 82%, transparent); --qd-line: color-mix(in srgb, var(--accent) 22%, transparent);
  --qd-shadow: var(--shadow-float), 0 0 25px color-mix(in srgb, var(--accent) 12%, transparent), inset 0 1px 0 color-mix(in srgb, var(--text) 10%, transparent);
  --qd-text: var(--text-muted); --qd-active: var(--accent-text); --qd-pill: color-mix(in srgb, var(--text) 10%, var(--surface)); --qd-pill-shadow: 0 0 20px color-mix(in srgb, var(--accent) 30%, transparent), inset 0 1px 0 color-mix(in srgb, var(--text) 14%, transparent);
  --qd-sheet: var(--surface); --qd-sheet-line: var(--border); --qd-tile: var(--surface-hover); --qd-tile-on: var(--surface-hover); --qd-muted: var(--text-muted);
}

/* people who have not joined yet see only the welcome screen: no sidebar, no dock */
html.qw-onboarding .app-shell { grid-template-columns: minmax(0, 1fr); }
html.qw-onboarding .app-shell .sidebar, html.qw-onboarding .app-shell .menu-button { display: none !important; }

/* the sidebar is gone: the dock is the menu */
html.qd-on .app-shell { grid-template-columns: minmax(0, 1fr); }
html.qd-on .app-shell .sidebar, html.qd-on .app-shell .menu-button { display: none !important; }
html.qd-on .app-shell .app-main { padding-bottom: calc(var(--qd-h) + 56px + env(safe-area-inset-bottom)); }
html.qd-on .focus-mode .qd-wrap { display: none; }

.qd-wrap {
  position: fixed; left: 0; right: 0; bottom: calc(14px + env(safe-area-inset-bottom)); z-index: 120; display: flex; justify-content: center; padding: 0 12px; pointer-events: none;
  transition: transform .5s var(--qd-spring), opacity .35s ease;
}
.qd-wrap.qd-away { transform: translate3d(0, 150%, 0) scale(.94); opacity: 0; }
.qd-wrap.qd-off { display: none; }
.qd {
  position: relative; pointer-events: auto; display: flex; align-items: center; gap: 2px; padding: 7px; max-width: 100%; border-radius: var(--radius-pill); touch-action: pan-y;
  background: var(--qd-glass); border: 1px solid var(--qd-line); box-shadow: var(--qd-shadow); -webkit-backdrop-filter: blur(26px) saturate(190%); backdrop-filter: blur(26px) saturate(190%);
  user-select: none; -webkit-user-select: none;
}
.qd-pill {
  position: absolute; left: 0; top: 50%; height: calc(100% - 14px); border-radius:999px; background: var(--qd-pill); box-shadow: var(--qd-pill-shadow); pointer-events: none; z-index: 0;
  transform: translate3d(0, -50%, 0); will-change: transform, width; transition: transform .5s var(--qd-spring), width .4s var(--qd-spring), opacity .25s ease;
}
.qd-pill-instant { transition: none !important; }
.qd-pill-off { opacity: 0; }
.qd-dragging .qd-pill { box-shadow: none; }

.qd-item {
  position: relative; z-index: 1; display: flex; align-items: center; justify-content: center; gap: 8px; min-height: 52px !important; padding: 8px 15px !important; border: 0 !important;
  border-radius:999px !important; background: transparent !important; box-shadow: none !important; color: var(--qd-text) !important; font: 600 13px/1 Inter, system-ui, sans-serif; letter-spacing: .01em;
  cursor: pointer; transition: color .3s var(--qd-liquid), transform .25s var(--qd-spring), padding .35s var(--qd-spring); -webkit-tap-highlight-color: transparent;
}
.qd-item::before, .qd-item::after, .qd-plus::before, .qd-plus::after { display: none !important; }
.qd-item:hover { transform: translateY(-2px); color: var(--qd-active) !important; }
.qd-item:active { transform: scale(.92); }
.qd-item.active { color: var(--qd-active) !important; font-weight:600; }
.qd-item.qd-peek { color: var(--qd-active) !important; }
.qd-ico { display: grid; place-items: center; }
.qd-ico .qi { width: 22px; height: 22px; }
.qd-item.qd-spring .qd-ico { animation: qd-spring .65s var(--qd-spring); }
@keyframes qd-spring { 0% { transform: translateY(0) scale(1); } 35% { transform: translateY(-7px) scale(1.22); } 65% { transform: translateY(3px) scale(.94); } 85% { transform: translateY(-2px) scale(1.04); } 100% { transform: none; } }
.qd-item:focus-visible, .qd-plus:focus-visible { outline: 2px solid var(--qd-accent-2); outline-offset: 2px; }
.qd-badge {
  position: absolute; top: 6px; right: 8px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: var(--radius-pill); background: var(--danger); color: var(--text); font: 800 10px/16px Inter, system-ui, sans-serif; text-align: center; font-style: normal;
  box-shadow: 0 0 0 2px var(--qd-glass); animation: qd-badge 1.8s ease-in-out infinite;
}
.qd-badge[hidden] { display: none; }
@keyframes qd-badge { 50% { transform: scale(1.14); } }

.qd-plus {
  position: relative; z-index: 2; width: 46px; height: 46px !important; min-height: 46px !important; margin: 0 6px; padding: 0 !important; display: grid; place-items: center; border: 0 !important; border-radius:50% !important; cursor: pointer;
  color: var(--cyprus-text) !important; background: var(--cyprus); box-shadow: 0 0 0 1px var(--accent), 0 6px 20px color-mix(in srgb, var(--accent) 45%, transparent);
  transition: transform .35s var(--qd-spring), box-shadow .3s ease; animation: qd-glow 3.6s ease-in-out infinite;
}
.qd-plus .qi { width: 24px; height: 24px; stroke-width: 2.4; transition: transform .45s var(--qd-spring); }
.qd-plus:hover { transform: translateY(-4px) scale(1.08); box-shadow: 0 0 0 1px var(--accent), 0 10px 28px color-mix(in srgb, var(--accent) 60%, transparent); }
.qd-plus:hover .qi, .qd-plus[aria-expanded="true"] .qi { transform: rotate(135deg); }
.qd-plus:active { transform: translateY(-1px) scale(.95); }
@keyframes qd-glow { 50% { box-shadow: 0 0 0 1px var(--accent), 0 10px 30px color-mix(in srgb, var(--accent) 65%, transparent); } }

/* phones: labelled pages under their icons, a raised "+" in the middle; extra pages live in More */
@media (max-width: 640px) {
  .qd-ph-off { display: none !important; }
  .qd { width: 100%; max-width: 440px; justify-content: space-around; padding: 6px 6px 7px; gap: 0; border-radius: var(--radius-pill); }
  .qd-item { flex: 1 1 0; min-width: 0; flex-direction: column; gap: 3px; padding: 6px 0 5px !important; min-height: 58px !important; border-radius: var(--radius-pill) !important; }
  .qd-item.active { padding: 6px 2px 5px !important; }
  .qd-ico .qi { width: 22px; height: 22px; }
  .qd-label { display: block; max-width: 100%; opacity: 1; overflow: hidden; text-overflow: clip; white-space: nowrap; font-size: 10px; font-weight:600; letter-spacing: 0; line-height: 1.1; }
  .qd-pill { border-radius: var(--radius-pill); }
  .qd-plus { top: -17px; margin: 0 4px; width: 54px; height: 54px !important; min-height: 54px !important; flex: none; border: 4px solid var(--surface-page, var(--border)) !important; }
  .qd-plus:hover { transform: scale(1.06); }
  .qd-badge { right: calc(50% - 22px); top: 3px; }
  .qd-sheet-back { padding-bottom: calc(var(--qd-h) + 24px + env(safe-area-inset-bottom)); }
  html.qd-on .app-shell .app-main { padding-bottom: calc(var(--qd-h) + 40px + env(safe-area-inset-bottom)); }
}
@media (max-width: 360px) { .qd-label { font-size: 10px; } .qd-plus { width: 50px; height: 50px !important; min-height: 50px !important; } }
@media (min-width: 641px) { .qd-item { gap: 9px; } }

/* ---------- sheets ---------- */
.qd-sheet-back {
  position: fixed; inset: 0; z-index: 110; background: var(--surface-hover); display: flex; align-items: flex-end; justify-content: center; padding: 0 12px calc(var(--qd-h) + 28px + env(safe-area-inset-bottom));
  transition: background .3s ease, backdrop-filter .3s ease;
}
.qd-sheet-back.in { background: var(--overlay); -webkit-backdrop-filter: blur(10px) saturate(1.1); backdrop-filter: blur(10px) saturate(1.1); }
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .qd-sheet-back.in { background: color-mix(in srgb, var(--bg) 88%, black); } }
.qd-sheet {
  width: min(560px, 100%); max-height: calc(100dvh - var(--qd-h) - 70px); overflow-y: auto; padding: 16px; border-radius: var(--radius-card); background: var(--qd-sheet); color: var(--ink, var(--text)); border: 1px solid var(--qd-sheet-line);
  box-shadow: none; transform: translate3d(0, 40px, 0) scale(.94); opacity: 0; transform-origin: 50% 100%; transition: transform .5s var(--qd-spring), opacity .3s ease;
}
[data-theme="dark"] .qd-sheet { color: var(--text); }
.qd-sheet-back.in .qd-sheet { transform: none; opacity: 1; }
.qd-me { display: flex; align-items: center; gap: 12px; padding: 4px 4px 12px; }
.qd-me strong { display: block; font-size: 1rem; } .qd-me small { color: var(--qd-muted); text-transform: capitalize; }
.qd-avatar { width: 44px; height: 44px; border-radius: var(--radius-card); display: grid; place-items: center; background: var(--surface); color: var(--text); font-weight:600; }
.qd-chip { margin-left: auto; display: inline-flex; align-items: center; gap: 6px; min-height: 40px !important; padding: 0 14px !important; border-radius:999px !important; font-weight:600; font-size: .82rem; }
.qd-group { margin: 14px 4px 8px; font-size: .68rem; font-weight:600; letter-spacing: .14em; text-transform: uppercase; color: var(--qd-muted); }
.qd-tiles { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.qd-tile {
  position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 8px; min-height: 84px !important; padding: 12px 6px !important; border-radius: var(--radius-card) !important; border: 1px solid transparent !important;
  background: var(--qd-tile) !important; color: inherit !important; box-shadow: none !important; font: 700 .78rem/1.2 Inter, system-ui, sans-serif; text-align: center; transition: transform .3s var(--qd-spring), background .2s ease, border-color .2s ease;
}
.qd-tile .qi { width: 24px; height: 24px; color: var(--qd-accent); transition: transform .4s var(--qd-spring); }
[data-theme="dark"] .qd-tile .qi { color: var(--text-muted); }
.qd-tile:hover { transform: translateY(-3px); border-color: var(--border) !important; }
.qd-tile:hover .qi { transform: scale(1.18) rotate(-6deg); }
.qd-tile:active { transform: scale(.95); }
.qd-tile.on { background: var(--qd-tile-on) !important; border-color: var(--border) !important; }
.qd-tile.qd-danger .qi { color: var(--danger); } [data-theme="dark"] .qd-tile.qd-danger .qi { color: var(--danger); }
.qd-tile .qd-badge { top: 8px; right: 12px; box-shadow: none; }
.qd-actions { display: grid; gap: 8px; }
.qd-action {
  display: flex; align-items: center; gap: 14px; width: 100%; min-height: 66px !important; padding: 10px 16px !important; border-radius: var(--radius-card) !important; border: 1px solid transparent !important; background: var(--qd-tile) !important; color: inherit !important;
  box-shadow: none !important; text-align: left; justify-content: flex-start !important; transition: transform .3s var(--qd-spring), border-color .2s ease;
}
.qd-action:hover { transform: translateX(4px); border-color: var(--border) !important; }
.qd-action > .qi:last-child { margin-left: auto; opacity: .45; transition: transform .3s var(--qd-spring), opacity .2s; } .qd-action:hover > .qi:last-child { transform: translateX(4px); opacity: 1; }
.qd-action-ico { width: 42px; height: 42px; flex: none; border-radius: var(--radius-input); display: grid; place-items: center; background: var(--surface); color: var(--text); }
.qd-action-text strong { display: block; font-size: .95rem; } .qd-action-text small { display: block; margin-top: 2px; color: var(--qd-muted); font-weight:600; font-size: .8rem; }
@media (max-width: 420px) { .qd-tiles { grid-template-columns: repeat(3, 1fr); gap: 6px; } .qd-tile { font-size: .72rem; } }

/* ---------- command palette ---------- */
.qd-pal-modal .qu-modal-head { display: none; } .qd-pal-modal .qu-modal-body { padding: 0; }
.qd-pal-box { display: flex; align-items: center; gap: 12px; padding: 16px 18px; border-bottom: 1px solid var(--qu-line, var(--border)); color: var(--qu-muted, var(--text-muted)); }
.qd-pal-box input { flex: 1; min-height: 32px; padding: 0 !important; border: 0 !important; background: transparent !important; font-size: 17px; color: var(--qu-text, var(--text)); outline: none; }
.qd-pal-box kbd { padding: 3px 8px; border-radius:var(--radius-input); border: 1px solid var(--qu-line, var(--border)); font: 700 .7rem ui-monospace, monospace; }
.qd-pal-list { padding: 8px; max-height: 52dvh; overflow-y: auto; display: grid; gap: 2px; }
.qd-pal-row { display: flex !important; align-items: center; gap: 12px; width: 100%; min-height: 48px !important; padding: 0 14px !important; justify-content: flex-start !important; border-radius: var(--radius-input) !important; border: 0 !important; background: transparent !important; box-shadow: none !important; color: var(--qu-text, var(--text)) !important; text-align: left; font-weight:600; }
.qd-pal-row .qi { color: var(--qu-accent, var(--text-muted)); } .qd-pal-row small { margin-left: auto; color: var(--qu-muted, var(--text-muted)); font-weight: 600; }
.qd-pal-row.on, .qd-pal-row:hover { background: var(--surface-hover) !important; }
.qd-pal-empty { padding: 28px; text-align: center; color: var(--qu-muted, var(--text-muted)); }

/* ---------- page loading line and page enter ---------- */
.qd-progress { position: fixed; top: 0; left: 0; right: 0; height: 3px; z-index: 500; pointer-events: none; opacity: 0; }
.qd-progress i { display: block; height: 100%; width: 100%; transform: scaleX(0); transform-origin: left; background: var(--surface); box-shadow: none; }
.qd-progress.run { opacity: 1; } .qd-progress.run i { animation: qd-load 2.4s cubic-bezier(.1, .7, .2, 1) forwards; }
.qd-progress.done i { animation: none; transform: scaleX(1); transition: transform .2s ease; } .qd-progress.done { opacity: 0; transition: opacity .3s ease .15s; }
@keyframes qd-load { to { transform: scaleX(.92); } }
.qv-enter { animation: qv-enter .5s var(--qd-liquid) both; }
@keyframes qv-enter { from { opacity: 0; transform: translate3d(0, 14px, 0); } to { opacity: 1; transform: none; } }

/* ---------- top bar tidy-up for the dock layout ---------- */
.topbar-brand { display: none; }
html.qd-on .topbar-brand { display: inline-flex; align-items: center; flex: none; }
html.qd-on .topbar-brand img { width: 44px; height: 44px; object-fit: contain; }
html.qd-on .topbar-brand .logo-on-dark { display: none; } [data-theme="dark"] html.qd-on .topbar-brand .logo-on-light, html[data-theme="dark"].qd-on .topbar-brand .logo-on-light { display: none; }
html[data-theme="dark"].qd-on .topbar-brand .logo-on-dark { display: block; }
.icon-action { width: 44px; min-height: 44px !important; padding: 0 !important; border-radius:50% !important; display: inline-grid; place-items: center; }
.icon-action .qi { width: 20px; height: 20px; }
.notification-button { position: relative; } .notification-button b { position: absolute; top: 2px; right: 2px; min-width: 18px; height: 18px; border-radius: var(--radius-pill); background: var(--danger); color: var(--text); font: 800 10px/18px Inter, system-ui, sans-serif; text-align: center; padding: 0 4px; }
.notification-button .qi { width: 20px; height: 20px; }
@media (max-width: 640px) { html.qd-on .app-shell .topbar { grid-template-columns: auto minmax(0, 1fr); } html.qd-on .topbar-brand img { width: 38px; height: 38px; } }
@media (prefers-reduced-motion: reduce) { .qd-pill, .qd-wrap, .qd-sheet, .qd-item, .qd-plus, .qd-tile { transition-duration: .01ms !important; } .qd-plus, .qd-badge { animation: none; } .qv-enter { animation: none; } }

/* ---------- first-visit tour ("How to move around") ---------- */
.qd-tour { position: fixed; inset: 0; z-index: 300; display: flex; align-items: flex-end; justify-content: center; padding: 16px 16px calc(var(--qd-h) + 36px + env(safe-area-inset-bottom)); background: var(--surface-hover); transition: background .3s ease; }
.qd-tour.in { background: var(--overlay); -webkit-backdrop-filter: blur(10px) saturate(1.1); backdrop-filter: blur(10px) saturate(1.1); }   /* the old look: dimmed and blurred, not an opaque page */
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) { .qd-tour.in { background: color-mix(in srgb, var(--bg) 90%, black); } }
.qd-tour-card {
  width: min(430px, 100%); padding: 20px 20px 18px; border-radius: var(--radius-card); background: var(--qd-sheet); color: var(--ink, var(--text)); border: 1px solid var(--qd-sheet-line);
  box-shadow: none; transform: translate3d(0, 28px, 0) scale(.96); opacity: 0; transition: transform .5s var(--qd-spring), opacity .3s ease;
}
html[data-theme="dark"] .qd-tour-card { color: var(--text); }
.qd-tour.in .qd-tour-card { transform: none; opacity: 1; }
.qd-tour-top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.qd-tour-count { font-size: .7rem; font-weight:600; letter-spacing: .14em; text-transform: uppercase; color: var(--qd-accent); }
html[data-theme="dark"] .qd-tour-count { color: var(--text-muted); }
.qd-tour-skip { min-height: 36px !important; padding: 0 10px !important; font-size: .85rem; }
.qd-tour-art { width: 62px; height: 62px; margin: 4px 0 12px; border-radius: var(--radius-card); display: grid; place-items: center; color: var(--text); background: var(--surface); box-shadow: none; }
.qd-tour-art .qi { width: 30px; height: 30px; }
.qd-tour h3 { margin: 0 0 6px; font-size: 1.25rem; letter-spacing: -.01em; }
.qd-tour p { margin: 0 0 16px; color: var(--qd-muted); line-height: 1.5; font-size: .95rem; }
.qd-tour-foot { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.qd-tour-dots { display: flex; gap: 6px; align-items: center; }
.qd-tour-dots i { width: 7px; height: 7px; border-radius: var(--radius-pill); background: var(--qd-sheet-line); transition: width .3s var(--qd-spring), background .3s ease; }
.qd-tour-dots i.on { width: 22px; background: var(--surface-hover); }
.qd-tour-swap .qd-tour-art, .qd-tour-swap h3, .qd-tour-swap > p { animation: qd-tour-in .45s var(--qd-liquid) both; }
.qd-tour-swap h3 { animation-delay: .04s; } .qd-tour-swap > p { animation-delay: .08s; }
@keyframes qd-tour-in { from { opacity: 0; transform: translate3d(14px, 0, 0); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .qd-tour-card, .qd-tour { transition-duration: .01ms !important; } .qd-tour-swap .qd-tour-art, .qd-tour-swap h3, .qd-tour-swap > p { animation: none; } }

/* ---------- deeper pages: back arrow instead of the logo, phone-friendly top bar ---------- */
.topbar-back { display: none !important; }
.topbar.has-back .topbar-back { display: inline-grid !important; flex: none; }
.topbar.has-back .topbar-brand { display: none !important; }
.topbar-back .qi { width: 22px; height: 22px; }
@media (max-width: 640px) {
  html.qd-on .app-shell .topbar { display: flex; flex-wrap: nowrap; align-items: center; gap: 8px; margin-bottom: .75rem; }
  html.qd-on .app-shell .topbar > div:not(.topbar-actions) { flex: 1 1 auto; min-width: 0; }
  html.qd-on .app-shell .topbar h1 { font-size: clamp(1.35rem, 6.2vw, 1.75rem); letter-spacing: -.02em; }
  html.qd-on .app-shell .topbar .eyebrow { display: block; margin: 0; font-size: .64rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html.qd-on .app-shell .topbar-actions { flex: none; width: auto; margin: 0; flex-wrap: nowrap; gap: 6px; }
  html.qd-on .topbar-actions .icon-action { width: 40px; min-height: 40px !important; }
}

/* One navigation per screen size (batch 2): where the page header shows the same links (public pages, 1101px and wider) the floating dock steps aside;
   on phones and tablets the header folds into its menu and the dock is the navigation. The signed-in workspace has no header links, so its dock always stays. */
@media (min-width: 1101px) { html.qw-has-nav:not(.qd-keep) .qd-wrap { display: none; } }
