body { display: flex; flex-direction: column; }

#shell-top {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 14px;
  height: 46px;
  flex: 0 0 46px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
}

.shell-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text);
  font-weight: 700;
  text-decoration: none;
  white-space: nowrap;
}
.shell-logo {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--fill);
  color: var(--ink);
  display: grid;
  place-items: center;
  font: 800 12px var(--font);
}

#shell-tabs { display: flex; gap: 4px; margin-left: 8px; }

#shell-tabs a {
  padding: 6px 12px;
  border-radius: var(--radius);
  color: var(--text-2);
  text-decoration: none;
  font-weight: 500;
}
#shell-tabs a:hover { color: var(--text); background: var(--panel-2); }

#shell-tabs a.on {
  background: var(--fill);
  color: var(--ink);
  font-weight: 600;
}

#shell-tabs a:focus-visible,
.shell-brand:focus-visible,
#theme-toggle:focus-visible,
#auth-action:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

#shell-right {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 12px;
}

#conn { display: flex; align-items: center; gap: 6px; color: var(--text-2); }
/* main.js 收到 store 的連線狀態後才顯示；'idle'（這頁沒有行情訂閱）保持隱藏 */
#conn:not([data-shown]) { display: none; }

#conn::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-3);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--text-3) 20%, transparent);
}

#conn[data-state="connected"]::before { background: var(--up); box-shadow: 0 0 0 3px color-mix(in srgb, var(--up) 20%, transparent); }
#conn[data-state="reconnecting"] { color: var(--accent); }
#conn[data-state="reconnecting"]::before { background: var(--fill); box-shadow: 0 0 0 3px var(--fill-soft); animation: blink 1s infinite; }
#conn[data-state="disconnected"] { color: var(--down); }
#conn[data-state="disconnected"]::before { background: var(--down); box-shadow: 0 0 0 3px var(--down-soft); }

@keyframes blink { 50% { opacity: .25; } }

/* 最後同步時間（個人模式）。超過 90 分鐘沒成功同步 → data-stale，改用警告色 */
#sync-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--text-3);
  white-space: nowrap;
  cursor: help;
}
#sync-status[hidden] { display: none; }
#sync-status[data-stale] { color: var(--down); font-weight: 500; }
@media (max-width: 760px) {
  #sync-status .sync-label { display: none; }
}

#proto-badge {
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--line);
  color: var(--text-2);
  font-size: 11px;
}

#theme-toggle {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text-2);
}
#theme-toggle:hover { color: var(--accent); border-color: var(--line-2); }
/* 顯示「按下去會變成的那一個」：深色時顯示太陽，淺色時顯示月亮 */
#theme-toggle .theme-moon { display: none; }
:root[data-theme="light"] #theme-toggle .theme-sun { display: none; }
:root[data-theme="light"] #theme-toggle .theme-moon { display: block; }

#auth-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 1px 10px 1px 1px;
  border: 1px solid var(--line);
  border-radius: 999px;
  color: var(--text-2);
  background: var(--panel);
  font: inherit;
  font-weight: 500;
  cursor: pointer;
}
#auth-action[hidden] { display: none; }
.shell-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--panel-2);
  display: grid;
  place-items: center;
  color: var(--text-2);
}

#auth-action:hover { border-color: var(--line-2); color: var(--text); }
#auth-action:disabled { opacity: .55; cursor: wait; }

#page { flex: 1; min-height: 0; overflow: hidden; }

.page-error { padding: 40px; color: var(--down); }
