/* ============================================================
   文字脱敏工具 — 视觉样式
   白/浅灰底 + 单一蓝色强调；细边框分层；圆角 6–10px；紧凑密度
   ============================================================ */

:root {
  --primary: #1768f2;
  --primary-hover: #0f5ce5;
  --primary-active: #0b4fcc;
  --primary-soft: #eef4ff;
  --primary-soft-hover: #e5efff;

  --bg-page: #f7f8fa;
  --bg-panel: #ffffff;
  --bg-subtle: #f3f6fa;
  --bg-hover: #f5f7fb;

  --border-default: #e5e8ed;
  --border-light: #edf0f3;
  --border-strong: #d8dde5;

  --text-primary: #1f2329;
  --text-secondary: #646a73;
  --text-tertiary: #9aa1ac;
  --text-disabled: #c2c7d0;

  --success: #20a464;
  --warning: #f5a623;
  --danger: #e5484d;

  --radius-xs: 4px;
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 10px;

  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.03);
  --shadow-sm: 0 2px 8px rgba(15, 23, 42, 0.05);
  --shadow-floating: 0 8px 24px rgba(15, 23, 42, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  font-family: "PingFang SC", "HarmonyOS Sans SC", "Microsoft YaHei", "Noto Sans CJK SC", system-ui, sans-serif;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
}

a {
  color: var(--primary);
  text-decoration: none;
}
a:hover {
  text-decoration: underline;
}

/* ---------------- 顶部栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  background: var(--bg-panel);
  border-bottom: 1px solid var(--border-default);
}

.topbar-inner {
  max-width: 1120px;
  margin: 0 auto;
  padding: 10px 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 15px;
  font-weight: 600;
  color: var(--text-primary);
}

.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 6px;
  display: block;
  flex: none;
  object-fit: cover;
}

.topbar-spacer {
  flex: 1;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 10px;
  border-radius: var(--radius-pill, 999px);
  border: 1px solid var(--border-default);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  font-size: 12.5px;
  white-space: nowrap;
}

.chip strong {
  color: var(--text-primary);
  font-weight: 500;
}

.chip.warn {
  border-color: #f7d9a5;
  background: #fff8ec;
  color: #8a5a00;
}
.chip.warn strong {
  color: #8a5a00;
}

.chip.danger {
  border-color: #f5c2c4;
  background: #fdf0f0;
  color: #a3272b;
}
.chip.danger strong {
  color: #a3272b;
}

/* ---------------- 布局 ---------------- */

.container {
  max-width: 880px;
  margin: 0 auto;
  padding: 24px 20px 56px;
}

.container.wide {
  max-width: 1120px;
}

.page-title {
  font-size: 20px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 4px;
}

.page-sub {
  color: var(--text-secondary);
  font-size: 13px;
  margin: 0 0 20px;
}

/* ---------------- 卡片 ---------------- */

.card {
  background: var(--bg-panel);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  margin-bottom: 16px;
}

.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
}

.card-title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
}

.card-sub {
  color: var(--text-secondary);
  font-size: 12.5px;
}

.card-body {
  padding: 16px 20px;
}

.card-body + .card-body {
  border-top: 1px solid var(--border-light);
}

.card-spacer {
  flex: 1;
}

/* ---------------- 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 34px;
  padding: 0 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  background: var(--bg-panel);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background 140ms ease-out, border-color 140ms ease-out, color 140ms ease-out;
  white-space: nowrap;
  user-select: none;
}

.btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.btn:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(23, 104, 242, 0.1);
}

.btn:disabled,
.btn[disabled] {
  color: var(--text-disabled);
  background: var(--bg-subtle);
  border-color: var(--border-light);
  cursor: not-allowed;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn-primary:hover {
  background: var(--primary-hover);
  border-color: var(--primary-hover);
}
.btn-primary:active {
  background: var(--primary-active);
  border-color: var(--primary-active);
}
.btn-primary:disabled,
.btn-primary[disabled] {
  background: #b8cdf7;
  border-color: #b8cdf7;
  color: #fff;
}

.btn-danger {
  color: var(--danger);
  border-color: #f0c6c8;
  background: #fff;
}
.btn-danger:hover {
  background: #fdf0f0;
  border-color: #e9a9ac;
}

.btn-ghost {
  border-color: transparent;
  background: transparent;
  color: var(--text-secondary);
}
.btn-ghost:hover {
  background: var(--bg-hover);
  border-color: transparent;
  color: var(--text-primary);
}

.btn-sm {
  height: 28px;
  padding: 0 10px;
  font-size: 12.5px;
}

.btn-xs {
  height: 24px;
  padding: 0 8px;
  font-size: 12px;
  border-radius: var(--radius-xs);
}

.btn-block {
  width: 100%;
}

.btn .icon {
  flex: none;
}

/* ---------------- 表单 ---------------- */

.field {
  margin-bottom: 14px;
}

.field:last-child {
  margin-bottom: 0;
}

.label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  margin-bottom: 6px;
}

.hint {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 6px;
  line-height: 1.5;
}

.input,
.textarea,
select.input {
  width: 100%;
  font-family: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-panel);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  transition: border-color 140ms ease-out, box-shadow 140ms ease-out;
}

.input {
  height: 36px;
  padding: 0 10px;
}

.textarea {
  padding: 10px 12px;
  line-height: 1.7;
  resize: vertical;
  min-height: 160px;
}

.input:focus,
.textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(23, 104, 242, 0.1);
}

.input::placeholder,
.textarea::placeholder {
  color: var(--text-tertiary);
}

.input:disabled,
.textarea:disabled {
  background: var(--bg-subtle);
  color: var(--text-disabled);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px 14px;
}

/* 数值 + 单位（分钟/小时/天） */
.input-group {
  display: flex;
  gap: 8px;
}

.input-group .input:first-child {
  flex: 1;
  min-width: 0;
}

.input-group select.input {
  width: 88px;
  flex: none;
}

.form-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

/* ---------------- 模式选择 ---------------- */

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.mode-card {
  position: relative;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  background: var(--bg-panel);
  padding: 14px 14px 12px;
  cursor: pointer;
  transition: border-color 140ms ease-out, background 140ms ease-out;
}

.mode-card:hover {
  background: var(--bg-hover);
  border-color: var(--border-strong);
}

.mode-card.active {
  border-color: var(--primary);
  background: var(--primary-soft);
}

.mode-card.active .mode-name {
  color: var(--primary);
}

.mode-head {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.mode-icon {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--bg-subtle);
  color: var(--text-secondary);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
}

.mode-card.active .mode-icon {
  background: #fff;
  color: var(--primary);
}

.mode-name {
  font-size: 14px;
  font-weight: 600;
}

.mode-desc {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.55;
}

.mode-check {
  position: absolute;
  top: 10px;
  right: 10px;
  color: var(--primary);
  display: none;
}

.mode-card.active .mode-check {
  display: block;
}

/* 复选框行（例如"顺手处理空格"） */
.check-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 12px;
  font-size: 13px;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1.5;
}

.check-row input {
  width: 15px;
  height: 15px;
  flex: none;
  accent-color: var(--primary);
  cursor: pointer;
}

/* ---------------- 徽标 ---------------- */

.badge {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 7px;
  border-radius: var(--radius-xs);
  font-size: 12px;
  font-weight: 500;
  white-space: nowrap;
}

.badge-ok {
  background: #e9f7f0;
  color: #147a4a;
}
.badge-warn {
  background: #fff4e2;
  color: #96620a;
}
.badge-danger {
  background: #fdeeee;
  color: #b02a2f;
}
.badge-muted {
  background: var(--bg-subtle);
  color: var(--text-secondary);
}

/* ---------------- 提示条 ---------------- */

.alert {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-default);
  font-size: 13px;
  line-height: 1.6;
  margin-bottom: 14px;
  background: var(--bg-panel);
}

.alert .icon {
  flex: none;
  margin-top: 2px;
}

.alert-warn {
  border-color: #f7d9a5;
  background: #fffaf1;
  color: #7a5200;
}

.alert-danger {
  border-color: #f0c6c8;
  background: #fdf5f5;
  color: #a3272b;
}

.alert-info {
  border-color: #c9dcfb;
  background: var(--primary-soft);
  color: #1c4f9c;
}

/* ---------------- 表格 ---------------- */

.table-wrap {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  font-weight: 500;
  color: var(--text-secondary);
  background: var(--bg-subtle);
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-default);
  white-space: nowrap;
}

td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

tbody tr:last-child td {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--bg-hover);
}

.cell-main {
  font-weight: 500;
}

.cell-sub {
  font-size: 12px;
  color: var(--text-tertiary);
  margin-top: 2px;
}

.cell-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

/* ---------------- 模态框 ---------------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 50;
}

.modal {
  background: var(--bg-panel);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-floating);
  width: 100%;
  max-width: 480px;
  max-height: calc(100vh - 40px);
  display: flex;
  flex-direction: column;
}

.modal-head {
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-light);
  font-size: 15px;
  font-weight: 600;
}

.modal-body {
  padding: 16px 20px;
  overflow-y: auto;
}

.modal-foot {
  padding: 12px 20px;
  border-top: 1px solid var(--border-light);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.modal-note {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.65;
}

.quick-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.hr {
  border: none;
  border-top: 1px solid var(--border-light);
  margin: 14px 0;
}

/* ---------------- 提示浮层 ---------------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 28px;
  transform: translateX(-50%);
  background: #1f2329;
  color: #fff;
  font-size: 13px;
  padding: 10px 16px;
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-floating);
  z-index: 80;
  max-width: calc(100vw - 40px);
  animation: toast-in 160ms ease-out;
}

.toast.danger {
  background: var(--danger);
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(-50%) translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
  }
}

/* ---------------- 登录页 ---------------- */

.auth-wrap {
  position: relative;
  overflow: hidden;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  background-color: var(--bg-page);
  background-image:
    radial-gradient(circle at 10% -12%, rgba(23, 104, 242, 0.1), transparent 42%),
    radial-gradient(circle at 108% 110%, rgba(23, 104, 242, 0.12), transparent 46%),
    radial-gradient(rgba(23, 104, 242, 0.13) 1.1px, transparent 1.1px);
  background-size: auto, auto, 22px 22px;
}

/* 几何装饰（不参与交互） */
.auth-deco {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.deco {
  position: absolute;
  display: block;
}

.deco.ring {
  width: 240px;
  height: 240px;
  border-radius: 50%;
  border: 1.5px solid rgba(23, 104, 242, 0.18);
  top: -70px;
  left: -80px;
}

.deco.ring::after {
  content: "";
  position: absolute;
  inset: 30px;
  border-radius: 50%;
  border: 1.5px dashed rgba(23, 104, 242, 0.14);
}

.deco.square {
  width: 118px;
  height: 118px;
  border-radius: 16px;
  border: 1.5px solid rgba(23, 104, 242, 0.16);
  transform: rotate(18deg);
  right: 7%;
  top: 13%;
}

.deco.square::after {
  content: "";
  position: absolute;
  inset: 14px;
  border-radius: 10px;
  background: rgba(23, 104, 242, 0.05);
}

.deco.stripes {
  width: 240px;
  height: 148px;
  border-radius: 20px;
  right: -66px;
  bottom: -26px;
  transform: rotate(-16deg);
  background: repeating-linear-gradient(-45deg, rgba(23, 104, 242, 0.13) 0 4px, rgba(23, 104, 242, 0) 4px 16px);
}

.deco.dot {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: rgba(23, 104, 242, 0.24);
  right: 17%;
  bottom: 16%;
  box-shadow:
    26px 24px 0 -4px rgba(23, 104, 242, 0.16),
    -32px -28px 0 -5px rgba(23, 104, 242, 0.14);
}

.deco.tri {
  width: 0;
  height: 0;
  left: 7%;
  bottom: 13%;
  border-left: 32px solid transparent;
  border-right: 32px solid transparent;
  border-bottom: 56px solid rgba(23, 104, 242, 0.11);
  transform: rotate(-14deg);
}

.auth-card {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 380px;
  background: var(--bg-panel);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: 30px 26px 24px;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

/* 卡片顶部条纹装饰 */
.auth-card::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 4px;
  background: repeating-linear-gradient(-45deg, var(--primary) 0 6px, #7aabf9 6px 12px);
}

.auth-brand {
  display: flex;
  align-items: center;
  gap: 9px;
  margin-bottom: 18px;
}

.auth-title {
  font-size: 19px;
  font-weight: 600;
  margin: 0 0 4px;
}

.auth-sub {
  font-size: 13px;
  color: var(--text-secondary);
  margin: 0 0 20px;
}

.auth-foot {
  position: relative;
  z-index: 1;
  max-width: 380px;
  width: 100%;
  margin-top: 16px;
  font-size: 12.5px;
  color: var(--text-tertiary);
  text-align: center;
  line-height: 1.7;
}

/* 启动加载态：避免刷新页面时先闪一下登录框 */
.boot-loading {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--text-secondary);
  font-size: 13px;
}

.loading-view {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 64px 0;
  color: var(--text-secondary);
  font-size: 13px;
}

.spinner {
  width: 18px;
  height: 18px;
  flex: none;
  border-radius: 50%;
  border: 2px solid var(--primary-soft-hover);
  border-top-color: var(--primary);
  animation: spinner-rotate 0.7s linear infinite;
}

@keyframes spinner-rotate {
  to {
    transform: rotate(360deg);
  }
}

@media (max-width: 640px) {
  .deco.square,
  .deco.tri {
    display: none;
  }

  .deco.ring {
    width: 170px;
    height: 170px;
    top: -60px;
    left: -70px;
  }

  .deco.stripes {
    width: 180px;
    height: 110px;
  }
}

/* ---------------- 到期遮罩卡 ---------------- */

.expired-card {
  border: 1px solid #f0c6c8;
  background: var(--bg-panel);
  border-radius: var(--radius-md);
  padding: 28px 24px;
  text-align: center;
}

.expired-icon {
  width: 44px;
  height: 44px;
  border-radius: 999px;
  background: #fdeeee;
  color: var(--danger);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 12px;
}

.expired-title {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 6px;
}

.expired-desc {
  color: var(--text-secondary);
  font-size: 13.5px;
  margin: 0 0 18px;
  line-height: 1.7;
}

/* 用量日志里的内容摘要：只显示一行，超出用省略号 */
.log-preview {
  display: inline-block;
  max-width: 190px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: bottom;
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* ---------------- 折叠区 ---------------- */

details.card > summary {
  list-style: none;
  cursor: pointer;
}

details.card > summary::-webkit-details-marker {
  display: none;
}

details.card[open] > summary {
  border-bottom: 1px solid var(--border-light);
}

details.card > summary .chev {
  transition: transform 140ms ease-out;
  color: var(--text-tertiary);
}

details.card[open] > summary .chev {
  transform: rotate(90deg);
}

/* ---------------- AI 优化结果 ---------------- */

.ai-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  margin-bottom: 8px;
}

.ai-problem {
  font-size: 13px;
  font-weight: 600;
}

.ai-suggestion {
  margin-top: 5px;
  font-size: 12.5px;
  line-height: 1.65;
  color: #1c4f9c;
  background: var(--primary-soft);
  border-radius: var(--radius-xs);
  padding: 6px 9px;
}

/* AI 改写版本 */
.ai-rewrite-title {
  margin: 14px 0 8px;
  font-size: 13px;
  font-weight: 600;
}

.ai-rewrite {
  border: 1px solid var(--border-default);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  margin-bottom: 8px;
  background: var(--bg-subtle);
}

.ai-rewrite-label {
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 5px;
}

.ai-rewrite-text {
  font-size: 13px;
  line-height: 1.7;
  white-space: pre-wrap;
  word-break: break-word;
  background: var(--bg-panel);
  border-radius: var(--radius-xs);
  padding: 8px 10px;
  border: 1px solid var(--border-light);
  /* 这里只是预览：不可选中复制，避免用户拿到"没带隐形字符"的纯文本 */
  user-select: none;
  -webkit-user-select: none;
  cursor: default;
}

.ai-used-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding: 9px 14px;
  background: var(--bg-panel);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: 12.5px;
  color: var(--text-secondary);
}

/* ---------------- 悬浮客服按钮 / 敏感词提示 / 设备行 ---------------- */

.contact-fab {
  position: fixed;
  right: 20px;
  bottom: 22px;
  z-index: 30;
  height: 38px;
  padding: 0 16px;
  border-radius: 999px;
  border: 1px solid var(--primary);
  background: var(--primary);
  color: #fff;
  font-size: 13px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: background 140ms ease-out;
}

.contact-fab:hover {
  background: var(--primary-hover);
}

.word-hint {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-top: 12px;
  padding: 9px 12px;
  border: 1px solid #f7d9a5;
  background: #fffaf1;
  border-radius: var(--radius-sm);
  font-size: 12.5px;
  color: #7a5200;
  line-height: 1.6;
}

.word-hint .icon {
  flex: none;
  margin-top: 2px;
}

.word-hint b {
  color: #7a5200;
}

.word-hint .btn {
  margin-left: 6px;
}

.device-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border-light);
}

.device-row:last-of-type {
  border-bottom: none;
}

.device-name {
  font-size: 13px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 6px;
}

@media (max-width: 768px) {
  .contact-fab {
    right: 14px;
    bottom: 16px;
  }
}

/* ---------------- 结果区 ---------------- */

.result-textarea {
  background: var(--bg-subtle);
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 13px;
}

.stat-line {
  font-size: 12.5px;
  color: var(--text-secondary);
}

.stat-line b {
  color: var(--primary);
  font-weight: 600;
}

.counter-over {
  color: var(--danger);
}

.hidden {
  display: none !important;
}

/* ---------------- 工具页双栏 + 侧边栏（历史 / 收藏） ---------------- */

.app-wide {
  max-width: 1120px;
}

.app-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 16px;
  align-items: start;
}

.app-main {
  min-width: 0;
}

.sidebar {
  position: sticky;
  top: 62px;
  background: var(--bg-panel);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  display: flex;
  flex-direction: column;
  max-height: calc(100vh - 84px);
}

.sidebar-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
}

.tabs {
  display: flex;
  gap: 3px;
  flex: 1;
  background: var(--bg-subtle);
  border-radius: var(--radius-sm);
  padding: 3px;
}

.tab {
  flex: 1;
  border: none;
  background: transparent;
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 5px 8px;
  border-radius: var(--radius-xs);
  cursor: pointer;
  transition: background 140ms ease-out, color 140ms ease-out;
}

.tab:hover {
  color: var(--text-primary);
}

.tab.active {
  background: var(--bg-panel);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

.sidebar-body {
  overflow-y: auto;
  padding: 10px;
}

.pane-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 2px 8px;
}

.list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.list-item {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  background: var(--bg-panel);
  transition: border-color 140ms ease-out, background 140ms ease-out;
}

.list-item:hover {
  border-color: var(--border-strong);
  background: var(--bg-hover);
}

.item-top {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 5px;
}

.item-time {
  margin-left: auto;
  font-size: 11.5px;
  color: var(--text-tertiary);
  white-space: nowrap;
}

.item-title {
  font-size: 12.5px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.item-line {
  display: flex;
  gap: 6px;
  font-size: 12.5px;
  line-height: 1.55;
  word-break: break-all;
}

.item-line + .item-line {
  margin-top: 3px;
}

.item-line .k {
  flex: none;
  color: var(--text-tertiary);
}

.item-line .v {
  min-width: 0;
  color: var(--text-primary);
}

.item-line.muted .v {
  color: var(--text-secondary);
}

.item-actions {
  display: flex;
  gap: 6px;
  margin-top: 7px;
  flex-wrap: wrap;
}

.empty {
  color: var(--text-tertiary);
  font-size: 12.5px;
  text-align: center;
  padding: 22px 8px;
  line-height: 1.8;
}

.sidebar-toggle,
.sidebar-close {
  display: none;
}

@media (max-width: 1023px) {
  .app-grid {
    grid-template-columns: 1fr;
  }

  .sidebar-toggle {
    display: inline-flex;
  }

  .sidebar-close {
    display: inline-flex;
  }

  .sidebar {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    width: min(360px, 92vw);
    max-height: none;
    border-radius: 0;
    border: none;
    border-left: 1px solid var(--border-default);
    box-shadow: var(--shadow-floating);
    z-index: 60;
    transform: translateX(102%);
    transition: transform 180ms ease-out;
  }

  .sidebar.open {
    transform: none;
  }

  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.35);
    z-index: 55;
  }
}

/* ---------------- 移动端 ---------------- */

@media (max-width: 760px) {
  .topbar-inner {
    padding: 10px 14px;
  }

  .container {
    padding: 16px 14px 44px;
  }

  .mode-grid {
    grid-template-columns: 1fr;
  }

  .card-header,
  .card-body {
    padding-left: 14px;
    padding-right: 14px;
  }

  .btn {
    height: 36px;
  }

  /* 表格转卡片 */
  .table-cards thead {
    display: none;
  }

  .table-cards tbody tr {
    display: block;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    margin: 0 14px 12px;
    padding: 8px 12px;
    background: var(--bg-panel);
  }

  .table-cards tbody tr:hover {
    background: var(--bg-panel);
  }

  .table-cards td {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px dashed var(--border-light);
    padding: 7px 0;
  }

  .table-cards tbody tr td:last-child {
    border-bottom: none;
  }

  .table-cards td::before {
    content: attr(data-label);
    flex: none;
    color: var(--text-tertiary);
    font-size: 12px;
    padding-top: 2px;
  }

  .table-cards td[data-label="操作"] {
    display: block;
  }

  .table-cards td[data-label="操作"]::before {
    display: block;
    margin-bottom: 6px;
  }

  .table-wrap {
    overflow-x: visible;
  }
}
