:root {
  color-scheme: light;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC", "Helvetica Neue", sans-serif;
  --sidebar: #18211f;
  --sidebar-muted: #8fa09b;
  --sidebar-text: #f3f6f5;
  --accent: #21a179;
  --accent-soft: rgba(33, 161, 121, 0.16);
  --surface: #ffffff;
  --canvas: #f4f5f2;
  --border: #dfe3df;
  --text: #202725;
  --muted: #68736f;
  --danger: #c1453d;
}

* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: var(--canvas); color: var(--text); user-select: none; }
button { font: inherit; cursor: pointer; }

/* 侧栏 */
.sidebar {
  position: fixed; inset: 0 auto 0 0; width: 248px; background: var(--sidebar); color: var(--sidebar-text);
  z-index: 3; display: flex; flex-direction: column; overflow: hidden;
  border-right: 1px solid rgba(255,255,255,0.06); transition: width 180ms ease;
}
:root.sidebar-collapsed .sidebar { width: 72px; }

.brand { display: flex; align-items: center; gap: 11px; padding: 7px 18px 22px; flex: 0 0 auto; }
.brand-mark { width: 36px; height: 36px; display: grid; place-items: center; border-radius: 9px; background: var(--accent); color: white; font-size: 18px; }
.brand-copy { min-width: 0; flex: 1 1 auto; }
.brand h1 { margin: 0 0 3px; font-size: 15px; font-weight: 650; }
.brand p { margin: 0; color: var(--sidebar-muted); font-size: 11px; }
.sidebar-toggle { width: 26px; height: 26px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid rgba(255,255,255,0.12); border-radius: 6px; background: transparent; color: #b9c5c1; font-size: 12px; }
.sidebar-toggle:hover { border-color: rgba(89,187,152,0.6); color: white; background: rgba(33,161,121,0.18); }

.account-nav { display: flex; flex-direction: column; min-height: 0; flex: 1 1 auto; }
.account-nav-head { display: flex; align-items: center; gap: 6px; padding: 0 12px 9px; }
.account-toggle { min-width: 0; flex: 1 1 auto; display: flex; align-items: center; gap: 7px; border: 0; border-radius: 6px; padding: 5px 6px; background: transparent; color: var(--sidebar-muted); text-align: left; }
.account-toggle:hover { background: rgba(255,255,255,0.06); color: #dbe3e1; }
.account-toggle .chevron { width: 14px; font-size: 11px; transition: transform 140ms ease; }
.account-nav.collapsed .account-toggle .chevron { transform: rotate(-90deg); }
.account-nav.collapsed .account-list { display: none; }
.section-label { color: var(--sidebar-muted); font-size: 11px; font-weight: 600; }
.account-count { min-width: 18px; height: 17px; display: grid; place-items: center; border-radius: 9px; padding: 0 5px; background: rgba(255,255,255,0.08); color: #b9c5c1; font-size: 10px; font-weight: 600; }
.add-account-button { width: 26px; height: 26px; flex: 0 0 auto; display: grid; place-items: center; border: 1px solid rgba(255,255,255,0.12); border-radius: 6px; background: transparent; color: #b9c5c1; font-size: 15px; }
.add-account-button:hover:not(:disabled) { border-color: rgba(89,187,152,0.6); color: white; background: rgba(33,161,121,0.18); }
.add-account-button:disabled { opacity: 0.4; cursor: default; }
.add-account-row { margin: 8px 10px 0; height: 34px; flex: 0 0 auto; display: flex; align-items: center; justify-content: center; gap: 7px; border: 1px dashed rgba(255,255,255,0.16); border-radius: 7px; background: transparent; color: #b9c5c1; font-size: 11px; }
.add-account-row:hover:not(:disabled) { border-color: rgba(89,187,152,0.5); color: white; background: rgba(33,161,121,0.12); }
.add-account-row:disabled { opacity: 0.4; cursor: default; }

.account-list { display: flex; flex-direction: column; gap: 5px; padding: 0 10px; min-height: 0; overflow-y: auto; }
.account-item { width: 100%; min-height: 52px; flex: 0 0 auto; display: grid; grid-template-columns: 31px minmax(0,1fr) auto; align-items: center; gap: 10px; border: 0; border-radius: 7px; padding: 7px 8px 7px 10px; color: #c9d2cf; background: transparent; text-align: left; }
.account-item:hover { background: rgba(255,255,255,0.055); color: white; }
.account-item.active { background: var(--accent-soft); color: white; }
.account-avatar { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 50%; background: #34403d; color: #dbe3e1; font-size: 12px; font-weight: 700; }
.account-item.active .account-avatar { background: var(--accent); color: white; }
.account-copy { min-width: 0; }
.account-name { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; font-weight: 550; }
.account-session { display: block; margin-top: 3px; color: var(--sidebar-muted); font-size: 10px; }
.item-actions { display: flex; gap: 2px; opacity: 0; }
.account-item:hover .item-actions, .account-item.active .item-actions { opacity: 1; }
.mini-button { width: 24px; height: 24px; display: grid; place-items: center; border: 0; border-radius: 5px; background: transparent; color: #a8b5b1; font-size: 12px; }
.mini-button:hover { background: rgba(255,255,255,0.1); color: white; }
.mini-button.danger { color: #d59b95; }
.mini-button.danger:hover { background: rgba(193,69,61,0.2); color: #ffd3cf; }
.account-edit-input { width: 100%; height: 30px; min-width: 0; padding: 0 8px; border: 1px solid rgba(100,213,173,0.65); border-radius: 6px; outline: none; color: white; background: #24302d; user-select: text; font-size: 12px; }

.sidebar-footer { margin-top: auto; flex: 0 0 auto; padding: 14px 14px 18px; border-top: 1px solid rgba(255,255,255,0.07); }
.privacy-note { display: flex; align-items: center; gap: 8px; color: var(--sidebar-muted); font-size: 10px; }

/* 收起为图标竖排 */
:root.sidebar-collapsed .brand { justify-content: center; gap: 0; padding: 8px 0 16px; }
:root.sidebar-collapsed .brand-mark, :root.sidebar-collapsed .brand-copy { display: none; }
:root.sidebar-collapsed .sidebar-toggle svg, :root.sidebar-collapsed .sidebar-toggle { transform: rotate(180deg); }
:root.sidebar-collapsed .account-nav-head { flex-direction: column; gap: 6px; padding: 0 0 9px; }
:root.sidebar-collapsed .account-toggle { justify-content: center; padding: 3px 0; }
:root.sidebar-collapsed .account-toggle .chevron, :root.sidebar-collapsed .account-toggle .section-label { display: none; }
:root.sidebar-collapsed .account-nav.collapsed .account-count { display: none; }
:root.sidebar-collapsed .account-list { align-items: center; padding: 0; }
:root.sidebar-collapsed .account-item { width: 44px; grid-template-columns: 1fr; padding: 6px 0; justify-items: center; }
:root.sidebar-collapsed .account-copy, :root.sidebar-collapsed .item-actions { display: none; }
:root.sidebar-collapsed .account-add-row { width: 34px; margin: 8px auto 0; padding: 0; }
:root.sidebar-collapsed .account-add-row span:last-child { display: none; }
:root.sidebar-collapsed .privacy-note { justify-content: center; }
:root.sidebar-collapsed .privacy-note { font-size: 0; }
:root.sidebar-collapsed .privacy-note::before { content: "🔒"; font-size: 14px; }

/* 工具栏 */
.toolbar { position: fixed; inset: 0 0 auto 248px; height: 54px; display: grid; grid-template-columns: auto minmax(160px, 520px) 1fr; align-items: center; gap: 16px; padding: 0 14px; background: rgba(255,255,255,0.97); border-bottom: 1px solid var(--border); z-index: 2; transition: left 180ms ease; }
:root.sidebar-collapsed .toolbar { left: 72px; }
.nav-controls, .toolbar-right { display: flex; align-items: center; gap: 4px; }
.toolbar-right { justify-content: flex-end; }
.icon-button { width: 32px; height: 32px; display: grid; place-items: center; border: 0; border-radius: 6px; color: #53605c; background: transparent; font-size: 16px; }
.icon-button:hover:not(:disabled) { background: #edf0ed; color: #17211e; }
.icon-button:disabled { color: #bdc5c2; cursor: default; }
.address { min-width: 0; height: 32px; display: flex; align-items: center; gap: 8px; padding: 0 11px; border: 1px solid var(--border); border-radius: 7px; background: #f6f7f5; color: var(--muted); font-size: 11px; }
.address span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.status { display: flex; align-items: center; gap: 7px; margin-right: 6px; color: var(--muted); font-size: 10px; white-space: nowrap; }
.status-dot { width: 7px; height: 7px; border-radius: 50%; background: #c5ccc9; }
.status.ready .status-dot { background: #4fc79a; }
.status.error .status-dot { background: var(--danger); }

/* 画面区 */
.stage { position: fixed; inset: 54px 0 0 248px; background: #1a1f1e; transition: left 180ms ease; }
:root.sidebar-collapsed .stage { left: 72px; }
.screen { position: relative; width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.screen canvas { display: block; background: #fff; box-shadow: 0 4px 24px rgba(0,0,0,0.4); }
.loading { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; gap: 6px; color: #b7c1be; font-size: 13px; background: #1a1f1e; }
.loading.hidden { display: none; }
