/* 右上角使用者列（首頁與 /studio 共用，使用各頁既有的色彩 token） */
.user-bar{display:flex;align-items:center;gap:10px;min-width:0}
.user-bar[hidden],.nav-login[hidden]{display:none}
.ub-stack{display:flex;flex-direction:column;align-items:flex-start;justify-content:center;gap:1px;min-width:0;line-height:1.25}
.ub-credits{display:flex;align-items:center;gap:4px;min-height:0;padding:0;white-space:nowrap;font-size:13px;color:var(--text)}
.ub-credits svg{width:14px;height:14px;flex:none;color:var(--accent);fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.ub-credits b{font-variant-numeric:tabular-nums}
.ub-credits small{font-size:12px;color:var(--muted)}
.ub-avatar{width:36px;height:36px;flex:none;display:grid;place-items:center;overflow:hidden;border-radius:50%;background:var(--blue-soft);color:var(--accent);border:1px solid var(--soft-line);font-size:13px;font-weight:700}
.ub-avatar img{width:100%;height:100%;object-fit:cover;display:block}
.ub-name{max-width:8em;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-size:14px;font-weight:600;color:var(--text)}
.ub-logout{flex:none;white-space:nowrap;min-height:44px;padding:0 12px;display:flex;align-items:center;gap:6px;border:1px solid var(--soft-line);border-radius:100px;background:transparent;color:var(--muted);font:inherit;font-size:13px;cursor:pointer;transition:color .2s,border-color .2s,background .2s}
.ub-logout svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round}
.ub-logout:hover{color:#ef4444;border-color:rgba(239,68,68,.45);background:rgba(239,68,68,.08)}
.ub-logout:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.ub-logout:disabled{opacity:.5;cursor:default}
/* 雲端備份晶片：所有寬度都只顯示圖示（狀態以顏色表示，文字在 tooltip / aria-label） */
.backup-chip{flex:none;width:44px;min-width:44px;padding:0;justify-content:center}
.backup-chip span{display:none}
.top-actions{flex:none}
/* 淺深色切換鈕：兩頁共用同一組尺寸，且不被右側內容擠壓 */
.top-actions .theme-toggle{flex:none;width:44px;height:44px;padding:0;box-sizing:border-box}
.top-actions .theme-toggle svg{width:18px;height:18px;display:block;margin:0;vertical-align:top}
.top-actions .theme-toggle .sun,.top-actions .theme-toggle .moon{line-height:0;align-items:center;justify-content:center}
@media (max-width:600px){
  .top-actions .theme-toggle{width:40px;height:40px}
  .top-actions .theme-toggle svg{width:16px;height:16px}
}
/* 桌機：導覽列固定在頁面正中央，不受右側內容寬度影響 */
@media (min-width:901px){
  .topbar{display:grid;grid-template-columns:1fr auto 1fr}
  .topbar .brand{justify-self:start}
  .topbar .header-nav{margin:0;justify-self:center}
  .topbar .top-actions{justify-self:end}
}
/* 帳號選單（手機版專用；桌機版不顯示、頭像不可點） */
.user-bar{position:relative}
.ub-avatar{padding:0;font-family:inherit;cursor:pointer}
.ub-avatar:focus-visible{outline:2px solid var(--accent);outline-offset:2px}
.ub-menu{position:absolute;right:0;top:calc(100% + 12px);z-index:60;min-width:224px;padding:8px;display:flex;flex-direction:column;gap:2px;background:var(--paper);border:1px solid var(--soft-line);border-radius:16px;box-shadow:0 18px 44px rgba(5,8,30,.38)}
.ub-menu[hidden]{display:none}
.ub-menu-head{padding:8px 12px 6px;font-size:13px;font-weight:700;color:var(--muted);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.ub-sep{height:1px;margin:6px 4px;background:var(--soft-line)}
.ub-item{min-height:44px;padding:0 12px;display:flex;align-items:center;border:0;border-radius:10px;background:transparent;color:var(--text);font:inherit;font-size:15px;text-align:left;cursor:pointer}
.ub-item:hover,.ub-item:focus-visible{background:var(--surface);outline:none}
.ub-item[aria-current="page"]{background:var(--blue-soft);font-weight:700}
.ub-danger{color:#ef4444}
@media (min-width:601px){
  .ub-avatar{pointer-events:none}
  .ub-menu{display:none}
}
@media (max-width:600px){
  .user-bar{gap:8px}
  /* 手機：左 logo、右 ☁ 點數 頭像；其餘收進頭像選單 */
  .topbar .brand-word,.topbar .header-nav,.ub-name,.ub-logout{display:none}
  .top-actions{gap:8px}
  .top-actions[data-auth="in"] .theme-toggle{display:none}
  .ub-avatar{width:40px;height:40px}
  .ub-stack{order:-1}
  .ub-credits{font-size:14px;gap:4px}
  .ub-credits svg{display:block;width:16px;height:16px}
  .ub-credits small{display:none}
}
/* 備份已開啟時顯示「已同步」文字，其餘狀態維持只顯示圖示 */
.backup-short{display:none}
.backup-chip[data-state="on"]{width:auto;padding:0 14px 0 12px;gap:6px}
.backup-chip[data-state="on"] .backup-short{display:inline;font-size:14px}
@media (max-width:600px){
  /* 與頭像（40px）同高 */
  .backup-chip{height:40px;min-height:40px}
  .backup-chip:not([data-state="on"]){width:40px;min-width:40px}
  .backup-chip[data-state="on"]{padding:0 12px 0 10px;gap:5px}
  .backup-chip[data-state="on"] .backup-short{font-size:13px}
}
/* 電腦版：右上角的雲端、頭像、登出、主題按鈕統一 44px 高 */
@media (min-width:601px){
  .top-actions .backup-chip,.top-actions .ub-logout,.top-actions .theme-toggle{height:44px;min-height:0}
  .top-actions .ub-avatar{width:44px;height:44px}
  /* 使用者列內部間距 10px，登出補 8px，與其他按鈕之間同為 18px */
  .top-actions .ub-logout{margin-left:8px}
}
