/* LuCC-net Web 客户端样式 — 深色终端风格，移动端优先 */

:root {
  --bg: #0f1117;
  --bg-panel: #171a23;
  --bg-hover: #222736;
  --bg-card: #1b1f2b;
  --bg-input: #0c0e14;
  --border: #262c3a;
  --border-light: #363d50;
  --text: #e8eaf0;
  --text-dim: #9aa3b5;
  --text-muted: #6b7488;
  --accent: #6366f1;
  --accent-light: #8b93ff;
  --accent-dark: #5850ec;
  --accent-soft: rgba(99, 102, 241, 0.15);
  --live: #34d399;
  --live-soft: rgba(52, 211, 153, 0.14);
  --gold: #fbbf24;
  --gold-soft: rgba(251, 191, 36, 0.14);
  --danger: #ef4444;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 6px 24px rgba(0, 0, 0, 0.35);
  --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }
ul { margin: 0; padding: 0; list-style: none; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

[hidden] { display: none !important; }

/* ---------- 通用按钮（触摸目标 ≥44px） ---------- */
.btn {
  min-height: 44px;
  padding: 0 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-panel);
  color: var(--text);
  font-size: 15px;
  cursor: pointer;
  white-space: nowrap;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.btn:active { background: var(--bg-hover); }
.btn:disabled { opacity: 0.45; cursor: default; }
.btn-primary { background: var(--accent-dark); border-color: var(--accent-dark); color: #fff; }
.btn-primary:active { background: var(--accent); }
.btn-danger { color: var(--danger); border-color: var(--danger); background: transparent; }
.btn-ghost { background: transparent; }
.btn-block { width: 100%; }

/* ---------- 登录页 ---------- */
#view-login {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.login-card {
  position: relative;
  width: 100%;
  max-width: 360px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 28px 22px;
}
.corner-version {
  position: absolute;
  top: 10px;
  left: 14px;
  font-size: 11px;
  color: var(--text-dim);
  letter-spacing: 0.5px;
}
.login-title { margin: 0; font-size: 22px; text-align: center; color: var(--accent); }
.login-sub { margin: 8px 0 20px; font-size: 13px; color: var(--text-dim); text-align: center; }

/* ---------- 表单 ---------- */
.field { display: block; margin-bottom: 14px; }
.field-label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-dim); }
.field input {
  width: 100%;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px; /* 防止 iOS 聚焦时自动放大 */
}
.field input:focus { outline: none; border-color: var(--accent); }
.input-row { display: flex; gap: 8px; }
.input-row input { flex: 1; min-width: 0; }
.form-error { color: var(--danger); font-size: 13px; margin: 4px 0 10px; }

/* ---------- 设置页 ---------- */
.settings-form { width: 100%; }
.settings-form .field textarea,
.settings-form .field input {
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
.settings-form .field textarea:focus,
.settings-form .field input:focus { outline: none; border-color: var(--accent); }
.settings-textarea { resize: vertical; min-height: 120px; font-family: Menlo, Monaco, monospace; }
.field-note { margin-top: 6px; font-size: 12px; color: var(--text-dim); line-height: 1.5; }

/* ---------- 版本 / 更新历史 ---------- */
.changelog-block { width: 100%; margin-top: 24px; }
.changelog-title { margin: 0 0 8px; font-size: 15px; color: var(--text); }
.changelog-current { margin-bottom: 12px; font-size: 13px; color: var(--text-dim); }
.changelog-list { display: flex; flex-direction: column; gap: 12px; }
.changelog-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  background: var(--bg-panel);
}
.changelog-item-head { margin-bottom: 6px; font-size: 14px; font-weight: 600; color: var(--accent); }
.changelog-item ul { margin: 0; padding-left: 18px; }
.changelog-item li { font-size: 13px; color: var(--text); line-height: 1.7; }

/* ---------- 列表页通用 ---------- */
.page {
  flex: 1;
  width: 100%;
  max-width: 860px;
  margin: 0 auto;
  padding: 12px 12px 84px; /* 底部留出 Tab 栏高度 */
}
.page-head { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; }
.page-title { flex: 1; margin: 0; font-size: 18px; }
.page-actions { display: flex; gap: 8px; }
.status { padding: 26px 0; text-align: center; color: var(--text-dim); font-size: 14px; }
.status-err { color: var(--danger); }

/* ---------- 会话首页 ---------- */
#view-sessions.page { max-width: 1080px; }

/* 头部 */
.session-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 18px;
  padding: 6px 2px;
}
.sh-title { display: flex; align-items: baseline; gap: 10px; flex: 1; min-width: 0; }
.session-head .page-title { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: 0.3px; }
.sessions-version { font-size: 12px; color: var(--text-muted); font-weight: 500; }
.btn-refresh { font-size: 18px; }
.btn-plus { font-size: 16px; line-height: 1; }

/* 区块 */
.block { margin-bottom: 22px; }
.block-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  padding: 0 2px;
}
.block-title {
  margin: 0;
  flex: 1;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 6px;
}
.bt-icon { color: var(--accent); font-size: 11px; }
.block-count {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent-light);
  background: var(--accent-soft);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 1px 9px;
  min-width: 22px;
  text-align: center;
}
.block-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 7px 2px;
  border: none;
  background: none;
  color: var(--text-dim);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.4px;
  cursor: pointer;
  text-align: left;
}
.block-toggle:hover { color: var(--text); }
.rt-arrow { font-size: 11px; flex: none; width: 14px; color: var(--accent); transition: transform 0.15s; }
.block-toggle-main { border-bottom: 1px solid var(--border); margin-bottom: 12px; }

/* 活跃标签（文字标签，不用颜色区分） */
.tag-active {
  flex: none;
  font-size: 11px;
  padding: 1px 8px;
  border-radius: 999px;
  font-weight: 600;
  color: var(--live);
  border: 1px solid var(--live);
  background: var(--live-soft);
}

/* 活跃会话网格 */
.panel-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 14px;
}
.active-empty {
  grid-column: 1 / -1;
  padding: 40px 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  border: 1px dashed var(--border);
  border-radius: var(--radius-lg);
}

/* 最近打开：平铺堆叠 */
.panel-stack {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* 面板式会话卡片 */
.panel {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
  min-height: 0;
}
.panel:hover { border-color: var(--accent); box-shadow: var(--shadow-sm); }
.panel:active { transform: scale(0.995); }
/* 最近打开的会话面板：灰色弱化，与活跃会话区分，点击仍直接进入 */
.panel-recent {
  background: var(--bg);
  border-color: var(--border);
  opacity: 0.82;
}
.panel-recent:hover { opacity: 1; border-color: var(--border-light); }
.panel-recent .panel-title { color: var(--text-muted); }
/* 正在打开（当前有连接）卡片：绿色描边强调 */
.panel-live { border-color: rgba(52, 211, 153, 0.4); }
.panel-live:hover { border-color: var(--live); box-shadow: 0 2px 12px rgba(52, 211, 153, 0.16); }
.panel-head { display: flex; align-items: center; gap: 8px; min-width: 0; }
.panel-title {
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.panel-dir {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
  font-size: 12px;
  color: var(--text-muted);
}
.panel-dir .icon { font-size: 12px; }
.panel-dir-text { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.panel-meta { display: flex; flex-wrap: wrap; gap: 4px 12px; }
.panel-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: auto;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}
.panel-act {
  min-height: 32px;
  padding: 0 12px;
  font-size: 12px;
  border-radius: 999px;
}
.panel-act:hover { background: var(--bg-hover); }

/* 卡片列表（通用） */
.card-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.card {
  display: flex;
  align-items: stretch;
  gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: border-color 0.15s, transform 0.1s, box-shadow 0.15s;
}
.card:hover { border-color: var(--border-light); box-shadow: var(--shadow-sm); }
.card:active { transform: scale(0.995); }
.card-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 5px;
  padding: 11px 14px;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  font-size: 15px;
  text-decoration: none;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.card-main:active { background: var(--bg-hover); }
.card-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.card-title {
  font-weight: 600;
  font-size: 15px;
  overflow: hidden;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 1;
  line-clamp: 1;
  word-break: break-all;
}
.card-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; }
.meta-item { font-size: 12px; color: var(--text-dim); word-break: break-all; display: inline-flex; align-items: center; gap: 4px; }
.badge { flex: none; font-size: 11px; padding: 2px 8px; border-radius: 999px; border: 1px solid; font-weight: 600; }
.badge-remote { color: var(--text); border-color: var(--border-light); background: var(--bg-panel); }
.badge-local { color: var(--gold); border-color: var(--gold); background: var(--gold-soft); }
/* 卡片元信息着色：记录条数(靛蓝) / 时间(弱化) */
.meta-count { color: var(--accent-light); font-weight: 700; }
.meta-time { color: var(--text-muted); }
.card-dir { font-size: 12px; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.card-kill {
  align-self: center;
  margin-right: 12px;
  padding: 6px 12px;
  font-size: 12px;
  min-height: 34px;
  border-radius: 999px;
}
.card-kill:hover { background: rgba(239, 68, 68, 0.12); }
.card-file { align-self: center; margin-right: 12px; padding: 6px 10px; font-size: 15px; min-height: 34px; }

/* 最近打开 chips */
.recent-list { display: flex; flex-wrap: wrap; gap: 8px; }
.recent-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 999px;
  font-size: 13px;
  color: var(--text);
  cursor: pointer;
  max-width: 260px;
  transition: border-color 0.15s, background 0.15s;
}
.recent-chip:hover { border-color: var(--accent); background: var(--bg-hover); }
.recent-chip .rc-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recent-chip .rc-close { font-size: 13px; color: var(--text-muted); flex: none; line-height: 1; }
.recent-chip .rc-close:hover { color: var(--danger); }

/* 打开已有会话：双栏（项目 + 会话） */
.sessions-split {
  display: flex;
  gap: 14px;
  align-items: stretch;
  min-height: 60vh;
}
.project-pane {
  flex: 0 0 264px;
  max-width: 300px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow-y: auto;
  padding: 10px;
}
.project-browser-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-dim);
  padding: 4px 6px 10px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.project-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.project-item { display: flex; align-items: center; gap: 6px; border-radius: var(--radius); border: 1px solid transparent; }
.project-item.active { background: var(--accent-soft); border-color: var(--accent-dark); }
.project-item .project-card { flex: 1; min-width: 0; }
.project-item .card-file { margin-right: 4px; }
.project-card {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 10px;
  background: none;
  border: none;
  color: var(--text);
  text-align: left;
  cursor: pointer;
  font-size: 14px;
  border-radius: var(--radius);
}
.project-item:not(.active):hover .project-card { background: var(--bg-hover); }
.project-name { flex: 1; min-width: 0; font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.project-count {
  flex: 0 0 auto;
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-light);
  background: var(--accent-soft);
  border-radius: 999px;
  padding: 1px 8px;
  min-width: 20px;
  text-align: center;
}
.project-desc { font-size: 12px; color: var(--text-dim); word-break: break-all; }

.session-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.session-pane .card-list { flex: 1; }

/* 会话唯一 ID 徽标 */
.badge-id { font-family: Menlo, Monaco, monospace; font-size: 11px; }

@media (max-width: 640px) {
  .sessions-split { flex-direction: column; }
  .project-pane { flex: none; max-width: none; max-height: 42vh; }
}

/* ---------- 文件页 / 目录选择 ---------- */
.path-bar {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow-x: auto;
}
.dir-item, .file-item { flex-direction: row; align-items: center; justify-content: flex-start; gap: 10px; text-align: left; }
/* 目录选择器卡片确保占满宽度，靠左对齐 */
.dir-list .card { width: 100%; }
.icon { flex: none; display: inline-flex; color: var(--text-dim); }
.file-mid { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.file-name { word-break: break-all; }
.file-meta { font-size: 12px; color: var(--text-dim); }
.file-act { flex: none; font-size: 13px; color: var(--accent); }

/* ---------- 文件管理器（Windows 资源管理器风格） ---------- */
.page-files {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-bottom: 60px; /* 底部导航高度 */
}

.fm-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 8px;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}

.fm-nav-btns {
  display: flex;
  gap: 2px;
}

.fm-btn {
  min-width: 36px;
  min-height: 36px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.fm-btn:active { background: var(--bg-hover); }
.fm-btn:disabled { opacity: 0.35; cursor: default; }
.fm-btn-back-session {
  border-color: var(--accent);
  color: var(--accent-light);
  font-size: 13px;
  white-space: nowrap;
}

.fm-breadcrumb {
  flex: 1;
  min-width: 0;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow-x: auto;
  display: flex;
  align-items: center;
  gap: 2px;
}
.fm-breadcrumb .crumb {
  color: var(--accent);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}
.fm-breadcrumb .crumb:active { background: var(--bg-hover); }
.fm-breadcrumb .sep { color: var(--text-dim); }

.fm-actions {
  display: flex;
  gap: 2px;
}

.fm-container {
  flex: 1;
  overflow: auto;
  position: relative;
}

.fm-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
.fm-table thead {
  position: sticky;
  top: 0;
  z-index: 2;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
}
.fm-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 12px;
  color: var(--text-dim);
  font-weight: 500;
  user-select: none;
}
.fm-table td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}
.fm-table tbody tr {
  cursor: pointer;
  transition: background 0.1s;
}
.fm-table tbody tr:active { background: var(--bg-hover); }
.fm-table tbody tr.selected { background: var(--accent-soft); }
.fm-col-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.fm-col-name .icon { display: inline-block; vertical-align: middle; margin-right: 8px; flex: none; }
.fm-col-name .file-name { vertical-align: middle; }
.fm-col-size, .fm-col-date { white-space: nowrap; color: var(--text-dim); font-size: 12px; }
.fm-col-ops { width: 44px; text-align: center; }
.fm-ops-btn {
  min-width: 32px;
  min-height: 32px;
  padding: 0 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-dim);
  font-size: 18px;
  cursor: pointer;
  line-height: 1;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.fm-ops-btn:active { background: var(--bg-hover); color: var(--text); }

/* 右键菜单 */
.fm-context-menu {
  position: fixed;
  z-index: 50;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  min-width: 140px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.fm-ctx-item {
  display: block;
  width: 100%;
  padding: 8px 12px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}
.fm-ctx-item:active { background: var(--bg-hover); }

/* 拖拽上传提示 */
.fm-container.drag-over::after {
  content: '释放以上传文件';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-soft);
  border: 2px dashed var(--accent);
  color: var(--accent);
  font-size: 18px;
  z-index: 10;
  pointer-events: none;
}

/* 桌面端：导航移到顶部 */
@media (min-width: 768px) {
  .page-files { padding-bottom: 0; }
}

/* ---------- 终端页 ---------- */
body.mode-terminal { overflow: hidden; }
#view-terminal {
  height: 100dvh; /* 手机键盘弹出时跟随可视高度 */
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.term-toolbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 8px;
  padding-top: calc(6px + env(safe-area-inset-top));
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border);
  flex-wrap: nowrap;
  overflow-x: auto;
}
.term-toolbar .btn { padding: 0 10px; font-size: 14px; flex: none; }
.term-title {
  flex: 1;
  min-width: 0;
  text-align: center;
  font-size: 14px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.term-wrap { flex: 1; position: relative; min-height: 0; }
#term-container { position: absolute; inset: 0; padding: 4px; }
.term-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.6);
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  z-index: 5;
}

/* 终端字号调节按钮 */
.term-font-btn {
  min-width: 36px;
  min-height: 36px;
  padding: 0 8px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}
.term-font-btn:active { background: var(--bg-hover); }
.term-font-size { font-size: 12px; color: var(--text-dim); flex: none; min-width: 32px; text-align: center; }

/* 终端关闭按钮 */
.btn-term-close { color: var(--danger); border-color: var(--danger); }

/* 终端右键菜单 */
.term-context-menu {
  position: fixed;
  z-index: 50;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px;
  min-width: 180px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
}
.term-ctx-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 9px 12px;
  border: none;
  background: none;
  color: var(--text);
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  border-radius: 4px;
}
.term-ctx-item:active { background: var(--bg-hover); }
.term-ctx-item.danger { color: var(--danger); }
.term-ctx-sep { height: 1px; background: var(--border); margin: 4px 0; }

/* 六分段滚动条 */
.lucc-scrollbar {
  position: absolute;
  right: 0;
  top: 0;
  bottom: 0;
  width: 18px;
  background: rgba(255, 255, 255, 0.04);
  z-index: 20;
  cursor: pointer;
  transition: background 0.2s;
}
.lucc-scrollbar:hover { background: rgba(255, 255, 255, 0.06); }

/* 会话列表展开/收起 */
.sessions-collapse { display: none; }
.sessions-collapse.show { display: flex; }

/* ---------- 主导航：移动端底部 Tab ---------- */
.main-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  background: var(--bg-panel);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 10;
}
.nav-item {
  flex: 1;
  min-height: 52px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 14px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.nav-item:active { background: var(--bg-hover); }
.nav-item.active { color: var(--accent); }

/* 桌面端：导航移到顶部 */
@media (min-width: 768px) {
  .main-nav {
    position: static;
    order: -1;
    justify-content: center;
    border-top: none;
    border-bottom: 1px solid var(--border);
    padding-bottom: 0;
    padding-left: 0;
  }
  .nav-item { flex: none; min-width: 140px; min-height: 48px; }
  .page { padding-bottom: 24px; }
}

/* ---------- 弹窗 ---------- */
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal-mask { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.55); }
.modal-panel {
  position: relative;
  width: 100%;
  max-width: 420px;
  max-height: 82dvh;
  overflow-y: auto;
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 18px;
}
.modal-title { margin: 0 0 14px; font-size: 16px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dir-head { display: flex; gap: 8px; margin-bottom: 10px; }
.dir-head .btn { padding: 0 12px; font-size: 14px; }
.dir-list { max-height: 46dvh; overflow-y: auto; margin-bottom: 6px; }

/* 选择目录弹窗：新建子目录 */
.dir-mkdir { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.dir-mkdir input {
  flex: 1;
  min-width: 0;
  min-height: 40px;
  padding: 0 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-size: 15px;
}
.dir-mkdir input:focus { outline: none; border-color: var(--accent); }
.dir-mkdir .btn { min-height: 40px; padding: 0 12px; font-size: 14px; }

/* 新建会话：启动模式开关 */
.nc-toggles { display: flex; flex-direction: column; gap: 10px; margin: 4px 0 14px; border-top: 1px solid var(--border); padding-top: 14px; }
.toggle-row { display: flex; align-items: center; gap: 10px; cursor: pointer; }
.toggle-check { position: absolute; opacity: 0; pointer-events: none; }
.toggle-box {
  flex: none;
  width: 40px;
  height: 22px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--border);
  position: relative;
  transition: background .15s, border-color .15s;
}
.toggle-box::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: transform .15s, background .15s;
}
.toggle-check:checked + .toggle-box { background: var(--accent-dark); border-color: var(--accent-dark); }
.toggle-check:checked + .toggle-box::after { transform: translateX(18px); background: #fff; }
.toggle-label { display: flex; flex-direction: column; gap: 2px; }
.toggle-label strong { font-size: 14px; }
.toggle-label .toggle-desc { font-size: 12px; color: var(--text-dim); }
.nc-clear { margin: 2px 0 6px; }
.nc-clear .btn { font-size: 13px; }

/* ---------- 全局提示条 ---------- */
.toast-box {
  position: fixed;
  top: calc(10px + env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: min(92vw, 420px);
  pointer-events: none;
}
.toast {
  max-width: 100%;
  padding: 12px 16px;
  border-radius: var(--radius);
  background: #333;
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
  text-align: center;
  word-break: break-all;
  opacity: 0;
  transition: opacity 0.25s;
}
.toast.show { opacity: 1; }
.toast-err { background: #5a1d1d; border-color: var(--danger); color: #ffd7d7; }
.toast-ok { background: #1a3a2e; border-color: var(--accent); color: #c7d7ff; }
