/* v2 app shell (js/router.js): desktop top bar, mobile tab bar (<760px), practice takeover bar,
   route sections. Ported from docs/design/claude-design/ui_kits/app/App.jsx (TopBar, TabBar, App). */

[data-screen][hidden] { display: none !important; }

.gct-main { width: 100%; max-width: 1120px; margin: 0 auto; padding: 36px 40px 56px; box-sizing: border-box; flex: 1; }
.gct-page-title { font: 800 30px/1.2 var(--font-sans); letter-spacing: -.01em; margin: 0 0 24px; color: var(--fg-primary); }
[data-screen="practice"], [data-screen="summary"] { max-width: 768px; margin: 0 auto; }
.gct-login-prompt { margin: 0 0 16px; color: var(--fg-secondary); }
.gct-login-prompt a { color: var(--color-orange-dark); font-weight: 700; }

/* Auth-dependent chrome: js/auth.js updateAuthUI sets body.is-logged-in / body.is-admin. */
body:not(.is-logged-in) [data-auth="user"],
body.is-logged-in [data-auth="anon"],
body:not(.is-admin) [data-auth="admin"] { display: none !important; }

/* Offline chip: shown while navigator.onLine is false (body.is-offline, js/main.js). */
body:not(.is-offline) [data-offline-chip] { display: none; }

/* Desktop top bar — no wordmark. */
.gct-topbar { position: sticky; top: 0; z-index: 20; height: 56px; flex: none; display: flex; align-items: center; gap: 20px; padding: 0 20px; background: var(--gradient-header); box-shadow: var(--shadow-header); }
.gct-topbar__scope:empty { display: none; }
.gct-topbar__nav { display: flex; gap: 4px; }
.gct-topbar__nav a { display: inline-flex; align-items: center; height: 36px; padding: 0 14px; border-radius: 8px; font: 700 14px/1 var(--font-sans); color: rgba(255, 248, 240, .78); text-decoration: none; }
.gct-topbar__nav a:hover { color: var(--fg-on-dark); }
.gct-topbar__nav a[aria-current="page"] { color: #fff; background: rgba(255, 248, 240, .16); }
.gct-topbar__spacer { flex: 1; }
.gct-topbar__manage { display: inline-flex; align-items: center; gap: 6px; height: 36px; padding: 0 12px; border-radius: 8px; border: 1px solid rgba(255, 248, 240, .25); color: var(--fg-on-dark); font: 700 13px/1 var(--font-sans); text-decoration: none; }
.gct-topbar__manage[aria-current="page"] { background: rgba(255, 248, 240, .16); }
.gct-topbar__login { height: 36px; padding: 0 14px; border-radius: 8px; border: 1px solid rgba(255, 248, 240, .4); background: rgba(255, 248, 240, .12); color: var(--fg-on-dark); font: 700 14px/1 var(--font-sans); cursor: pointer; }
.gct-topbar__avatar { width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 2px solid rgba(255, 248, 240, .5); background: #ffd49a; color: var(--color-orange-900); display: inline-flex; align-items: center; justify-content: center; cursor: pointer; }

/* Avatar menu (native popover: light dismiss + Esc for free). */
.gct-menu { position: fixed; inset: 60px 20px auto auto; margin: 0; width: 240px; padding: 6px; box-shadow: var(--shadow-pop); color: var(--fg-primary); }
.gct-menu__item { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 8px; font: 600 14px/1.2 var(--font-sans); color: var(--fg-primary); text-decoration: none; }
.gct-menu__item svg { color: var(--fg-secondary); }
.gct-menu__item:hover { background: var(--bg-hover); }

/* Practice / summary takeover: nav hidden, practice bar shown. */
.gct-practicebar, .gct-tabbar { display: none; }
body.is-focused .gct-topbar, body.is-focused .gct-tabbar { display: none; }
body.is-focused .gct-practicebar { display: flex; position: sticky; top: 0; z-index: 20; height: 64px; flex: none; align-items: center; gap: 16px; padding: 0 24px; background: var(--bg-glass); backdrop-filter: blur(16px); border-bottom: 1px solid var(--color-border); }
.gct-practicebar__crumbs { min-width: 0; flex: 0 1 420px; font: 600 13px/1.3 var(--font-sans); color: var(--fg-secondary); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gct-practicebar__progress { flex: 1; min-width: 0; display: flex; align-items: center; gap: 12px; justify-content: flex-end; }
.gct-practicebar__progress .gct-progress { flex: 0 1 240px; }
.gct-practicebar__count { font: 800 13px/1 var(--font-sans); color: var(--fg-secondary); white-space: nowrap; font-variant-numeric: tabular-nums; }

/* Mobile: bottom tab bar replaces the top bar. */
@media (max-width: 759px) {
    .gct-topbar { display: none; }
    .gct-main { padding: 16px 16px 92px; }
    body.is-focused .gct-main { padding-bottom: 28px; }
    .gct-page-title { font-size: 26px; margin-bottom: 16px; }
    .gct-tabbar { display: grid; grid-template-columns: repeat(5, 1fr); position: fixed; left: 0; right: 0; bottom: 0; z-index: 20; height: 64px; padding-bottom: max(4px, env(safe-area-inset-bottom)); background: rgba(255, 252, 247, .94); backdrop-filter: blur(16px); border-top: 1px solid var(--color-border); }
    .gct-tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--fg-muted); font: 600 12px/1 var(--font-sans); text-decoration: none; }
    .gct-tabbar a[aria-current="page"] { color: var(--color-orange-dark); font-weight: 800; }
    .gct-tabbar__badge { position: absolute; top: 6px; left: 50%; margin-left: 6px; min-width: 18px; height: 16px; padding: 0 4px; border-radius: 8px; background: var(--color-orange); color: #fff; font: 800 12px/16px var(--font-sans); }
    body:not(.is-focused) { --toast-bottom: 76px; } /* toast sits above the tab bar */
    body.is-focused .gct-practicebar { height: 56px; gap: 8px; padding: 0 8px 0 4px; }
    .gct-practicebar__crumbs { display: none; }
    .gct-practicebar__progress .gct-progress { flex: 1; }
}

/* Topic scope (js/scope.js), ported from ui_kits/app/Scope.jsx. */
.gct-topbar__scope { min-width: 0; flex: 0 1 380px; display: flex; }
body[data-route="me"] .gct-topbar__scope, body[data-route="manage"] .gct-topbar__scope { display: none; }
.gct-scope-btn { display: flex; align-items: center; gap: 8px; height: 38px; max-width: 380px; min-width: 0; padding: 0 10px 0 12px; border-radius: 10px; border: 1px solid rgba(255, 248, 240, .35); background: rgba(255, 248, 240, .12); color: #fff8f0; font: 14px/1 var(--font-sans); cursor: pointer; }
.gct-scope-btn:hover, .gct-scope-btn[aria-expanded="true"] { background: rgba(255, 248, 240, .22); }
.gct-scope-btn > svg:first-child { flex: none; color: #ffd49a; }
.gct-scope-btn > svg:last-child { flex: none; opacity: .8; }
.gct-scope-btn__due { flex: none; min-width: 22px; height: 20px; padding: 0 6px; border-radius: 10px; background: #ffd49a; color: var(--color-orange-900); font: 800 12px/20px var(--font-sans); text-align: center; box-sizing: border-box; }
.gct-scope-label { display: inline-flex; align-items: center; gap: 4px; min-width: 0; overflow: hidden; }
.gct-scope-label > svg { flex: none; opacity: .6; }
.gct-scope-label > span, .gct-scope-label > b { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gct-scope-label > span { flex: none; font-weight: 600; opacity: .8; }
.gct-scope-label > b { flex: 0 1 auto; min-width: 0; font-weight: 800; }

/* Mobile scope bar (first row of Today, Listen, History); desktop scope note on filtered pages. */
.gct-scopebar { display: none; }
.gct-scope-note { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin-bottom: 18px; font: 600 14px/1.4 var(--font-sans); color: var(--fg-secondary); }
.gct-scope-note[hidden] { display: none; }
.gct-scope-note > svg { color: var(--color-orange); }
.gct-scope-note b { color: var(--fg-primary); }
.gct-scope-note button { padding: 0; border: 0; background: none; font: 700 14px/1.4 var(--font-sans); color: var(--color-orange-dark); cursor: pointer; }
@media (max-width: 759px) {
    .gct-scope-note { display: none; }
    .gct-scopebar { display: flex; align-items: center; gap: 10px; width: 100%; height: 48px; margin-bottom: 16px; padding: 0 12px 0 14px; font: 14px/1 var(--font-sans); color: var(--fg-primary); box-shadow: var(--shadow-sm); cursor: pointer; }
    .gct-scopebar > svg:first-child { flex: none; color: var(--color-orange); }
    .gct-scopebar > svg:last-child { flex: none; color: var(--fg-muted); }
    .gct-scopebar__label { flex: 1; min-width: 0; display: flex; overflow: hidden; text-align: left; }
}

/* Picker: popover under the scope button (desktop), bottom sheet (mobile). Native <dialog>: Esc + focus trap. */
.gct-scope-picker { position: fixed; inset: 64px auto auto 20px; margin: 0; padding: 0; width: min(460px, calc(100vw - 16px)); max-height: calc(100vh - 80px); display: none; flex-direction: column; overflow: hidden; background: var(--bg-card); border: 1px solid var(--color-border); border-radius: var(--radius-lg); box-shadow: var(--shadow-pop); color: var(--fg-primary); box-sizing: border-box; }
.gct-scope-picker[open] { display: flex; }
.gct-scope-picker::backdrop { background: transparent; }
.gct-scope-picker__head { padding: 12px; border-bottom: 1px solid var(--color-border); }
.gct-scope-picker__title { display: none; }
.gct-scope-picker__search { position: relative; }
.gct-scope-picker__search > svg { position: absolute; left: 11px; top: 12px; color: var(--fg-muted); }
.gct-scope-picker__search .gct-input { padding-left: 34px; box-sizing: border-box; }
.gct-scope-picker__hint { margin: 8px 0 0; font: 600 12px/1.4 var(--font-sans); color: var(--fg-muted); }
.gct-scope-picker__list { flex: 1; overflow: auto; padding: 6px; }
.gct-scope-picker__caption { padding: 12px 10px 4px; font: 700 12px/1 var(--font-sans); letter-spacing: .06em; text-transform: uppercase; color: var(--fg-muted); }
.gct-scope-picker__recent { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 10px; }
.gct-scope-picker__recent .gct-pill { max-width: 100%; }
.gct-scope-picker__recent .gct-pill span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gct-scope-picker__empty { padding: 20px; margin: 0; font: 600 14px/1.4 var(--font-sans); color: var(--fg-muted); }
.gct-scope-row { display: flex; align-items: center; gap: 4px; min-height: 38px; padding-right: 4px; border-radius: 8px; }
.gct-scope-row.is-current { background: var(--color-orange-tint); }
.gct-scope-row__toggle { flex: none; width: 22px; height: 22px; padding: 0; display: flex; align-items: center; justify-content: center; border: 0; border-radius: 6px; background: none; color: var(--fg-muted); cursor: pointer; }
.gct-scope-row__pick { flex: 1; min-width: 0; display: flex; align-items: center; gap: 8px; min-height: 38px; padding: 6px 8px 6px 4px; border: 0; background: none; color: inherit; font: inherit; text-align: left; cursor: pointer; }
.gct-scope-row__icon { flex: none; display: flex; color: var(--fg-muted); }
.gct-scope-row__icon.is-folder { color: var(--color-orange); }
.gct-scope-row__text { flex: 1; min-width: 0; }
.gct-scope-row__name { display: block; font: 500 14px/1.3 var(--font-sans); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gct-scope-row__name.is-folder, .is-current .gct-scope-row__name { font-weight: 700; }
.is-current .gct-scope-row__name, .is-current .gct-scope-row__pick > svg { color: var(--color-orange-dark); }
.gct-scope-row__trail { display: block; font: 600 12px/1.3 var(--font-sans); color: var(--fg-muted); }
.gct-scope-row__new { flex: none; width: 7px; height: 7px; border-radius: 50%; background: var(--color-orange-bright); }
.gct-scope-row__due { flex: none; min-width: 20px; text-align: right; font: 800 12px/1 var(--font-sans); color: var(--color-orange-dark); }
@media (max-width: 759px) {
    .gct-scope-picker { inset: auto 0 0 0 !important; /* beats the desktop anchor style after a resize */ width: 100%; max-width: 100%; height: 82%; max-height: 82%; border: 0; border-radius: 20px 20px 0 0; padding-top: 8px; }
    .gct-scope-picker::before { content: ""; flex: none; width: 40px; height: 4px; margin: 0 auto 8px; border-radius: 2px; background: var(--color-neutral-border); }
    .gct-scope-picker::backdrop { background: rgba(67, 40, 27, .38); backdrop-filter: blur(2px); }
    .gct-scope-picker__head { padding: 4px 16px 12px; }
    .gct-scope-picker__title { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font: 800 18px/1.2 var(--font-sans); }
    .gct-scope-picker__search .gct-input { min-height: 44px; }
    .gct-scope-picker__search > svg { top: 14px; }
    .gct-scope-row, .gct-scope-row__pick { min-height: 48px; }
    .gct-scope-row__name { white-space: normal; }
}
