/* Element defaults, layout primitives, utilities, icons. */
*{box-sizing:border-box}
html,body{margin:0}
body{font-family:var(--font); font-size:var(--fs-md); line-height:1.5; color:var(--ink); background:var(--bg); -webkit-font-smoothing:antialiased; -moz-osx-font-smoothing:grayscale}
h1,h2,h3{margin:0; font-weight:600; line-height:1.25; letter-spacing:-.011em; text-wrap:balance}
p{margin:0; text-wrap:pretty}
ul,ol{margin:0; padding:0}
button{font:inherit; color:inherit; cursor:pointer; -webkit-tap-highlight-color:transparent}
button:disabled{cursor:default}
[hidden]{display:none!important}
:focus-visible{outline:2px solid var(--accent); outline-offset:2px}
code{font-family:var(--font-mono); font-size:.86em; color:var(--ink); background:var(--surface-2); padding:.1em .4em; border-radius:4px; white-space:nowrap}

.app{max-width:34rem; margin:0 auto; min-height:100vh; min-height:100dvh; display:flex; flex-direction:column}
.boot-fallback{visibility:hidden; animation:show-later 0s 2s forwards}
@keyframes show-later{to{visibility:visible}}

/* utilities */
.zh{font-family:var(--font-zh)}
.tnum{font-variant-numeric:tabular-nums}
.muted{color:var(--ink-2)}
.small{font-size:var(--fs-sm)}
.hint{font-size:var(--fs-sm); color:var(--ink-2)}
.eyebrow{font-size:var(--fs-sm); font-weight:500; color:var(--ink-2)}
.h-lg{font-size:var(--fs-xl); letter-spacing:-.015em}
.h-md{font-size:var(--fs-lg)}
.stack{display:flex; flex-direction:column; gap:var(--gap, var(--s-3))}
.sr{position:absolute; width:1px; height:1px; overflow:hidden; clip:rect(0 0 0 0); white-space:nowrap}
.home > :empty, .stage > :empty, .page > :empty, .recwrap > :empty{display:none}

/* icons: one 24px grid, 2px round strokes, no fills */
.ic{display:inline-flex; flex:none; width:20px; height:20px}
.ic svg{width:100%; height:100%; fill:none; stroke:currentColor; stroke-width:2; stroke-linecap:round; stroke-linejoin:round}
.ic-16{width:16px; height:16px}
.ic-24{width:24px; height:24px}
.glyph svg{display:block}
.nowrap{white-space:nowrap}
.spinner{flex:none; display:inline-block; width:16px; height:16px; border-radius:50%; border:2px solid var(--surface-3); border-top-color:var(--ink-2); animation:spin .7s linear infinite}

@keyframes spin{to{transform:rotate(360deg)}}
@keyframes rise{from{opacity:0; transform:translateY(6px)}}
@keyframes pop{0%{transform:scale(.6)} 60%{transform:scale(1.15)} 100%{transform:scale(1)}}

@media (prefers-reduced-motion: reduce){ *, *::before, *::after{transition:none!important; animation:none!important} }


/* ---------- navigation ---------- */
.tabbar{position:sticky; bottom:0; z-index:3; display:grid; grid-template-columns:repeat(6, 1fr); gap:var(--s-1); padding:6px var(--s-2) calc(6px + env(safe-area-inset-bottom)); background:var(--bg); box-shadow:0 -1px 0 var(--line)}
.tab{display:flex; flex-direction:column; align-items:center; gap:2px; min-height:48px; padding:6px 0; border:0; border-radius:var(--r-ctl); background:transparent; color:var(--ink-3); font-size:var(--fs-xs); font-weight:600; transition:color var(--t-fast), background-color var(--t-fast)}
.tab:hover{color:var(--ink); background:var(--surface-2)}
.tab[aria-current="page"]{color:var(--accent)}
/* scoped to .tabbar so later sheets (.brand in home.css) can't show them again */
.tabbar .tabbar-brand, .tabbar .tab-side, .tabbar .tabbar-search{display:none}
.tabbar-search{align-items:center; gap:var(--s-2); padding:0 var(--s-3); min-height:44px; border-radius:var(--r-ctl); background:var(--surface); box-shadow:var(--raise); color:var(--ink-3)}
.tabbar-search:focus-within{box-shadow:0 0 0 2px var(--accent)}
.tabbar-search-input{flex:1; min-width:0; height:40px; border:0; background:transparent; color:var(--ink); font:inherit}
.tabbar-search-input:focus{outline:none}
dialog.dict-drawer .dict{box-shadow:none; padding:0; background:transparent}
.home, .page, .stage{flex:1}
.page.tabbed{padding-top:var(--s-5)}
.kbd{display:none}
@media (hover:hover) and (pointer:fine){ .kbd{display:inline-block; margin-left:var(--s-2); padding:0 5px; border-radius:4px; box-shadow:inset 0 0 0 1px var(--line-strong); font-size:var(--fs-xs); font-weight:600; color:var(--ink-3); font-variant-numeric:tabular-nums} }

/* ---------- responsive layout ---------- */
/* Tablets: a wider reading column. */
@media (min-width:700px){
  :root{--gutter:var(--s-5)}
  .app{max-width:42rem}
}
/* Laptops: navigation becomes a sidebar. */
@media (min-width:960px){
  body:has(.tabbar){padding-left:232px}
  .tabbar{position:fixed; top:0; bottom:0; left:0; width:232px; display:flex; flex-direction:column; gap:var(--s-1); padding:var(--s-5) var(--s-4); box-shadow:1px 0 0 var(--line)}
  .tabbar .tabbar-brand{display:flex; margin:0 0 var(--s-5) var(--s-3)}
  .tab{flex-direction:row; justify-content:flex-start; gap:var(--s-3); min-height:44px; padding:0 var(--s-3); font-size:var(--fs-md); font-weight:500; color:var(--ink-2)}
  .tab[aria-current="page"]{background:var(--surface-2); color:var(--ink); font-weight:600}
  .tab[aria-current="page"] .ic{color:var(--accent)}
  .tabbar .tab-side{display:flex}
  .tabbar .tab-account{margin-top:0}
  .tabbar .tabbar-search{display:flex; margin-top:auto; margin-bottom:var(--s-2)}
  body:has(.tabbar) .home{padding-top:var(--s-6)}
}
/* Wide screens: Gaau-zai sits on the right. */
.mascot{display:none}
@media (min-width:1240px){
  body{padding-right:360px}
  .mascot{position:fixed; top:0; right:0; bottom:0; width:360px; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:var(--s-2); padding:var(--s-6) var(--s-5); box-shadow:-1px 0 0 var(--line); background:var(--bg); overflow:auto}
}

/* The page's name stays in view (ui/sticky-title.js): a slim bar on tab pages, the name in the Back bar elsewhere.
   The bar's holder has no height (and cancels the page's gap), so nothing moves when it appears. */
.page-bar{position:sticky; top:0; z-index:4; height:0; margin-bottom:calc(-1 * var(--s-6))}
.page-bar-in{position:absolute; top:0; left:calc(-1 * var(--gutter)); right:calc(-1 * var(--gutter)); display:flex; align-items:center; height:52px; padding:0 var(--gutter); background:var(--bg); box-shadow:0 1px 0 var(--line); font-weight:650; font-size:var(--fs-lg); letter-spacing:-.01em; opacity:0; transform:translateY(-6px); pointer-events:none; transition:opacity var(--t-fast), transform var(--t-fast)}
.page-bar.show .page-bar-in{opacity:1; transform:none}
.top-title{flex:1; min-width:0; margin-right:44px; text-align:center; font-weight:650; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; opacity:0; transition:opacity var(--t-fast)}
.top-title.show{opacity:1}
/* Phones: a slim bar at the top of every tab page (ui/tabs.js): the app's name, or the page's once its title has
   scrolled away, with Friends, your account and Settings on the right. Pages with a Back bar use that instead. */
.phonebar{display:none}
.nav-avatar{display:grid; place-items:center; width:26px; height:26px; border-radius:50%; background:var(--accent-soft); color:var(--accent); font-size:var(--fs-sm); font-weight:700}
.nav-dot{width:9px; height:9px; border-radius:50%; background:var(--accent); box-shadow:0 0 0 2px var(--bg)}
.phonebar-btn .nav-dot{position:absolute; top:8px; right:8px}
.tab .nav-dot{margin-left:auto}
@media (max-width:959px){
  .phonebar{position:fixed; top:0; left:0; right:0; z-index:5; display:flex; align-items:center; gap:var(--s-2); height:calc(52px + env(safe-area-inset-top)); padding:env(safe-area-inset-top) var(--gutter) 0; background:var(--bg); box-shadow:0 1px 0 var(--line)}
  body:has(#app > .top) .phonebar{display:none}
  body:has(.phonebar):not(:has(#app > .top)) .app{padding-top:calc(52px + env(safe-area-inset-top))}
  .phonebar-title{position:relative; flex:1; min-width:0; height:100%; display:flex; align-items:center}
  .phonebar-title .brand{font-size:var(--fs-lg); transition:opacity var(--t-fast)}
  .phonebar-page{position:absolute; left:0; right:0; overflow:hidden; white-space:nowrap; text-overflow:ellipsis; font-size:var(--fs-lg); font-weight:650; opacity:0; transition:opacity var(--t-fast)}
  :root.titled .phonebar-title .brand{opacity:0}
  :root.titled .phonebar-page{opacity:1}
  .phonebar-actions{display:flex; align-items:center; margin-right:-8px}
  .phonebar-btn{position:relative; color:var(--ink-2)}
  .phonebar-btn[aria-current="page"]{color:var(--accent)}
  .page.tabbed{padding-top:var(--s-4)}
}
/* A page's Back button says where it goes (ui/components.js backBar) */
.backbtn{display:inline-flex; align-items:center; gap:2px; min-height:44px; margin-left:-10px; padding:0 12px 0 4px; border:0; border-radius:var(--r-ctl); background:transparent; color:var(--ink-2); font:inherit; font-weight:600; cursor:pointer}
.backbtn:hover{background:var(--surface-2); color:var(--ink)}
/* Phones: on a scene's page the Start button takes the bottom of the screen instead of the tab bar */
@media (max-width:959px){ body:has(.start-bar) .tabbar{display:none} }

/* ---------- launch screen of the installed app (scripts/build-splash.js writes it into index.html) ----------
   Only when Gong runs as an installed app: Gaau-zai's hanging scroll unrolls, then fades once the app has started.
   main.js also removes it after a moment, so it can never stay (with reduced motion it simply isn't shown). */
#splash{display:none}
:root.app-mode #splash{position:fixed; inset:0; z-index:1000; display:flex; flex-direction:column; align-items:center; justify-content:center; gap:var(--s-4); background:#EFE6D2; color:#2A2522}
:root.app-mode.booted #splash{animation:splash-out .4s ease .9s forwards}
:root.app-mode .splash-scroll{transform-box:fill-box; transform-origin:50% 0; animation:splash-unroll .7s cubic-bezier(.2, .8, .2, 1) both}
:root.app-mode .splash-roller{animation:splash-roll .7s cubic-bezier(.2, .8, .2, 1) both}
.splash-art{width:min(62vw, 300px); height:auto}
.splash-name{font-size:var(--fs-xl); font-weight:700; letter-spacing:.02em}
.splash-name span{color:#C8102E; font-family:var(--font-zh)}
:root.app-mode[data-theme="dark"] #splash{background:#1A1714; color:#F3EEE6}
@media (prefers-color-scheme: dark){ :root.app-mode:not([data-theme="light"]) #splash{background:#1A1714; color:#F3EEE6} }
@media (prefers-reduced-motion: reduce){ :root.app-mode.booted #splash{display:none} }
@keyframes splash-unroll{from{transform:scaleY(.04)}}
@keyframes splash-roll{from{transform:translateY(-250px)}}
@keyframes splash-out{to{opacity:0; visibility:hidden}}
