/* VB 导航 · 单文件样式
   结构：变量 → 基础 → 顶栏 → 列表/卡片 → 空态 → 登录 → 表单 → 按钮
        → 弹层 → 后台 → Toast → 响应式 */

/* ---------------- 1. 变量 ---------------- */

:root {
  color-scheme: light;

  --bg: #f5f6fa;
  --bg-elev: #ffffff;
  --bg-soft: #f2f4f8;
  --bg-blur: rgba(255, 255, 255, 0.86);

  --text: #111827;
  --text-2: #4b5563;
  --text-3: #8a94a6;

  --border: #e6e8ee;
  --border-strong: #d3d8e2;

  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-weak: #eef4ff;
  --ring: rgba(37, 99, 235, 0.16);

  --danger: #dc2626;
  --danger-hover: #b91c1c;
  --danger-weak: #fef2f2;
  --ok: #059669;
  --warn-fg: #b45309;
  --warn-weak: #fffbeb;

  --chip-dl-bg: #f5f3ff;
  --chip-dl-fg: #6d28d9;
  --chip-dl-bd: #ddd6fe;
  --chip-ok-bg: #ecfdf5;
  --chip-ok-fg: #047857;
  --chip-ok-bd: #a7f3d0;

  --shadow-sm: 0 1px 2px rgba(16, 24, 40, 0.05), 0 1px 3px rgba(16, 24, 40, 0.06);
  --shadow-md: 0 10px 28px rgba(16, 24, 40, 0.12);

  --radius-lg: 18px;
  --radius: 14px;
  --radius-sm: 10px;

  --topbar-h: 60px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
    "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

[data-theme="dark"] {
  color-scheme: dark;

  --bg: #0b1220;
  --bg-elev: #111827;
  --bg-soft: #1a2332;
  --bg-blur: rgba(17, 24, 39, 0.86);

  --text: #e5e7eb;
  --text-2: #b6bfcc;
  --text-3: #7d8899;

  --border: #243044;
  --border-strong: #374151;

  --primary: #3b82f6;
  --primary-hover: #60a5fa;
  --primary-weak: #172554;
  --ring: rgba(59, 130, 246, 0.28);

  --danger: #ef4444;
  --danger-hover: #f87171;
  --danger-weak: #3f1414;
  --ok: #34d399;
  --warn-fg: #fbbf24;
  --warn-weak: #3a2a0d;

  --chip-dl-bg: #2a1b4d;
  --chip-dl-fg: #c4b5fd;
  --chip-dl-bd: #4c1d95;
  --chip-ok-bg: #0f2f26;
  --chip-ok-fg: #6ee7b7;
  --chip-ok-bd: #065f46;

  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;

    --bg: #0b1220;
    --bg-elev: #111827;
    --bg-soft: #1a2332;
    --bg-blur: rgba(17, 24, 39, 0.86);

    --text: #e5e7eb;
    --text-2: #b6bfcc;
    --text-3: #7d8899;

    --border: #243044;
    --border-strong: #374151;

    --primary: #3b82f6;
    --primary-hover: #60a5fa;
    --primary-weak: #172554;
    --ring: rgba(59, 130, 246, 0.28);

    --danger: #ef4444;
    --danger-hover: #f87171;
    --danger-weak: #3f1414;
    --ok: #34d399;
    --warn-fg: #fbbf24;
    --warn-weak: #3a2a0d;

    --chip-dl-bg: #2a1b4d;
    --chip-dl-fg: #c4b5fd;
    --chip-dl-bd: #4c1d95;
    --chip-ok-bg: #0f2f26;
    --chip-ok-fg: #6ee7b7;
    --chip-ok-bd: #065f46;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 12px 32px rgba(0, 0, 0, 0.45);
  }
}

/* ---------------- 2. 基础 ---------------- */

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
p {
  margin: 0;
}

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

button {
  font: inherit;
  color: inherit;
}

img {
  display: block;
  max-width: 100%;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

.app {
  min-height: 100vh;
  min-height: 100dvh;
}

.wrap {
  width: 100%;
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 20px;
}

.content {
  padding-top: 22px;
  padding-bottom: 72px;
}

.muted {
  color: var(--text-3);
  font-size: 13px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.center-page {
  min-height: 70vh;
  display: grid;
  place-items: center;
  padding: 40px 16px;
}

.noscript {
  margin: 40px auto;
  max-width: 480px;
  padding: 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  text-align: center;
}

/* ---------------- 3. 顶栏 ---------------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--bg-blur);
  border-bottom: 1px solid var(--border);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

.topbar-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: var(--topbar-h);
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

.back-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: var(--text-2);
}

.back-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.page-title {
  font-size: 16px;
  font-weight: 650;
  white-space: nowrap;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 0 0 auto;
}

.brand-logo {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  flex: 0 0 auto;
  border-radius: 10px;
  background: linear-gradient(135deg, #3b82f6, #1d4ed8);
  color: #fff;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.4px;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.28);
}

.brand-logo-lg {
  width: 52px;
  height: 52px;
  border-radius: 15px;
  font-size: 18px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  min-width: 0;
}

.brand-title {
  font-size: 15px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.brand-sub {
  font-size: 11px;
  color: var(--text-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-search {
  flex: 1;
  display: flex;
  justify-content: center;
  min-width: 0;
}

.topbar-spacer {
  flex: 1;
}

.search {
  position: relative;
  display: flex;
  align-items: center;
  width: 100%;
  max-width: 420px;
}

.search-icon {
  position: absolute;
  left: 12px;
  color: var(--text-3);
  pointer-events: none;
}

.search-input {
  width: 100%;
  height: 38px;
  padding: 0 12px 0 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
  color: var(--text);
  font-size: 14px;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s, background 0.16s;
  -webkit-appearance: none;
  appearance: none;
}

.search-input::placeholder {
  color: var(--text-3);
}

.search-input:focus {
  border-color: var(--primary);
  background: var(--bg-elev);
  box-shadow: 0 0 0 3px var(--ring);
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
  flex: 0 0 auto;
}

.icon-btn {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--text-2);
  cursor: pointer;
  transition: background 0.14s, color 0.14s;
}

.icon-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
}

.icon-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.icon-btn:disabled:hover {
  background: transparent;
}

.icon-btn.is-active {
  background: var(--primary-weak);
  color: var(--primary);
}

.icon-btn-sm {
  width: 30px;
  height: 30px;
  border-radius: 8px;
}

.icon-btn.danger:hover {
  background: var(--danger-weak);
  color: var(--danger);
}

.user-chip {
  max-width: 180px;
  padding: 4px 10px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---------------- 4. 分组与卡片 ---------------- */

.group {
  margin-bottom: 26px;
}

.group-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  width: 100%;
  padding: 6px 2px 12px;
  border: 0;
  background: none;
  color: inherit;
  text-align: left;
  cursor: pointer;
}

.group-title {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  font-size: 15px;
  font-weight: 650;
}

.group-emoji {
  font-size: 17px;
  line-height: 1;
}

.group-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.group-count {
  padding: 1px 8px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-soft);
  color: var(--text-3);
  font-size: 12px;
  font-weight: 500;
}

.group-caret {
  display: grid;
  place-items: center;
  color: var(--text-3);
  transition: transform 0.18s;
}

.group-caret.is-collapsed {
  transform: rotate(-90deg);
}

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 12px;
}

.card {
  position: relative;
  min-width: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elev);
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s, border-color 0.16s, box-shadow 0.16s;
}

.card:hover {
  transform: translateY(-2px);
  border-color: var(--border-strong);
  box-shadow: var(--shadow-md);
}

.card:active {
  transform: translateY(0);
}

.card-link {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  min-height: 86px;
  padding: 12px;
  color: inherit;
  -webkit-tap-highlight-color: transparent;
}

.card-main {
  display: flex;
  flex-direction: column;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.card-name {
  padding-right: 24px;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.card-desc {
  display: -webkit-box;
  overflow: hidden;
  color: var(--text-3);
  font-size: 12px;
  line-height: 1.45;
  word-break: break-word;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 3px;
}

.card-info {
  position: absolute;
  top: 7px;
  right: 5px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-3);
  opacity: 0.5;
  cursor: pointer;
  transition: opacity 0.14s, background 0.14s, color 0.14s;
}

.card:hover .card-info,
.card-info:focus-visible {
  opacity: 1;
}

.card-info:hover {
  background: var(--bg-soft);
  color: var(--primary);
}

.item-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  overflow: hidden;
  border-radius: 10px;
  background: var(--bg-soft);
}

.item-icon img {
  width: 100%;
  height: 100%;
  padding: 6px;
  object-fit: contain;
}

.item-icon-sm {
  width: 36px;
  height: 36px;
  border-radius: 9px;
}

.item-emoji {
  font-size: 20px;
  line-height: 1;
}

.item-letter {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  color: #fff;
  font-size: 16px;
  font-weight: 650;
}

.tone-0 { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.tone-1 { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.tone-2 { background: linear-gradient(135deg, #ec4899, #db2777); }
.tone-3 { background: linear-gradient(135deg, #f59e0b, #d97706); }
.tone-4 { background: linear-gradient(135deg, #10b981, #059669); }
.tone-5 { background: linear-gradient(135deg, #06b6d4, #0891b2); }
.tone-6 { background: linear-gradient(135deg, #f43f5e, #e11d48); }
.tone-7 { background: linear-gradient(135deg, #64748b, #475569); }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 19px;
  padding: 0 7px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  color: var(--text-2);
  font-size: 11px;
  white-space: nowrap;
}

.chip-download {
  border-color: var(--chip-dl-bd);
  background: var(--chip-dl-bg);
  color: var(--chip-dl-fg);
}

.chip-ok {
  border-color: var(--chip-ok-bd);
  background: var(--chip-ok-bg);
  color: var(--chip-ok-fg);
}

.list-stats {
  margin: 30px 0 0;
  color: var(--text-3);
  font-size: 12px;
  text-align: center;
}

/* ---------------- 5. 空态 / 横幅 ---------------- */

.empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 52px 20px;
  border: 1px dashed var(--border-strong);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  text-align: center;
}

.empty-icon {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  margin-bottom: 4px;
  border-radius: 50%;
  background: var(--bg-soft);
  color: var(--text-3);
}

.empty-title {
  font-size: 15px;
  font-weight: 650;
}

.empty-text {
  max-width: 380px;
  color: var(--text-3);
  font-size: 13px;
}

.empty .btn {
  margin-top: 10px;
}

.banner {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin: 16px 0;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13px;
  line-height: 1.5;
}

.banner svg {
  flex: 0 0 auto;
  margin-top: 1px;
}

.banner-warn {
  border-color: var(--warn-weak);
  background: var(--warn-weak);
  color: var(--warn-fg);
}

.banner-error {
  border-color: var(--danger-weak);
  background: var(--danger-weak);
  color: var(--danger);
}

/* ---------------- 6. 登录页 ---------------- */

.login-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 32px 16px calc(32px + env(safe-area-inset-bottom));
  background: radial-gradient(1100px 520px at 50% -10%, var(--primary-weak), transparent 62%), var(--bg);
}

.login-card {
  width: 100%;
  max-width: 384px;
  padding: 26px 22px 22px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--bg-elev);
  box-shadow: var(--shadow-md);
}

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  margin-bottom: 18px;
}

.login-title {
  margin-top: 10px;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.2px;
}

.login-sub {
  color: var(--text-3);
  font-size: 13px;
}

.login-page .banner {
  margin: 0 0 16px;
}

.login-options {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.machine-hint {
  color: var(--text-3);
  font-size: 12px;
}

.login-foot {
  margin-top: 16px;
  color: var(--text-3);
  font-size: 11px;
  line-height: 1.6;
  text-align: center;
}

.checkbox {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
}

.checkbox input {
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--primary);
}

/* ---------------- 7. 表单 ---------------- */

.form {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.label {
  color: var(--text-2);
  font-size: 13px;
  font-weight: 550;
}

.req {
  color: var(--danger);
}

.hint {
  color: var(--text-3);
  font-size: 11px;
  line-height: 1.5;
}

.field-error {
  display: none;
  color: var(--danger);
  font-size: 12px;
}

.field.has-error .field-error {
  display: block;
}

.field.has-error .hint {
  display: none;
}

.field.has-error .input,
.field.has-error .select,
.field.has-error .textarea {
  border-color: var(--danger);
}

.char-count {
  align-self: flex-end;
  color: var(--text-3);
  font-size: 11px;
}

.input,
.select,
.textarea {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font-family: inherit;
  font-size: 15px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.16s, box-shadow 0.16s;
  -webkit-appearance: none;
  appearance: none;
}

.select {
  padding-right: 32px;
  background-image: linear-gradient(45deg, transparent 50%, var(--text-3) 50%),
    linear-gradient(135deg, var(--text-3) 50%, transparent 50%);
  background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
  background-size: 5px 5px, 5px 5px;
  background-repeat: no-repeat;
}

.textarea {
  resize: vertical;
  min-height: 64px;
}

.input:focus,
.select:focus,
.textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--ring);
}

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

.input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.input-group .input {
  padding-right: 46px;
}

.pass-toggle {
  position: absolute;
  right: 4px;
  width: 34px;
  height: 34px;
}

.advanced {
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

.advanced-summary {
  padding: 9px 0;
  color: var(--text-2);
  font-size: 13px;
  cursor: pointer;
  list-style: none;
}

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

.advanced-body {
  padding-bottom: 12px;
}

.form-error {
  display: none;
  padding: 9px 11px;
  border: 1px solid var(--danger-weak);
  border-radius: var(--radius-sm);
  background: var(--danger-weak);
  color: var(--danger);
  font-size: 13px;
  line-height: 1.5;
}

.form-error.show {
  display: block;
}

.form-error-hint {
  margin-top: -8px;
  color: var(--text-3);
  font-size: 12px;
}

/* ---------------- 8. 按钮 ---------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 38px;
  padding: 0 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-elev);
  color: var(--text);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.14s, border-color 0.14s, color 0.14s, transform 0.08s;
  -webkit-tap-highlight-color: transparent;
}

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

.btn:active {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn svg {
  flex: 0 0 auto;
}

.btn-primary {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}

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

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

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

.btn-block {
  width: 100%;
  height: 44px;
  font-size: 15px;
}

.btn.is-loading {
  opacity: 0.85;
  cursor: progress;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
}

.row-actions.end {
  justify-content: flex-end;
}

.spacer {
  flex: 1;
}

/* ---------------- 9. 弹层 ---------------- */

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.15s;
}

.overlay.show {
  opacity: 1;
}

.overlay.is-closing {
  opacity: 0;
}

.modal {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: 520px;
  max-height: min(88vh, 760px);
  max-height: min(88dvh, 760px);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.3);
  transform: translateY(9px) scale(0.99);
  transition: transform 0.18s;
}

.overlay.show .modal {
  transform: none;
}

.modal-sm {
  max-width: 400px;
}

.modal-lg {
  max-width: 680px;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 18px;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  font-size: 16px;
  font-weight: 650;
}

.modal-body {
  padding: 16px 18px;
  overflow: auto;
  overscroll-behavior: contain;
}

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

.overlay-drawer {
  align-items: stretch;
  justify-content: flex-end;
  padding: 0;
}

.drawer {
  display: flex;
  flex-direction: column;
  width: min(440px, 100vw);
  height: 100vh;
  height: 100dvh;
  border-left: 1px solid var(--border);
  background: var(--bg-elev);
  box-shadow: -24px 0 60px rgba(0, 0, 0, 0.18);
  transform: translateX(18px);
  transition: transform 0.22s;
}

.overlay.show .drawer {
  transform: none;
}

.drawer-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 18px 18px 12px;
  border-bottom: 1px solid var(--border);
}

.drawer-title {
  font-size: 16px;
  font-weight: 650;
  word-break: break-word;
}

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

.drawer-body {
  flex: 1;
  padding: 16px 18px;
  overflow: auto;
  overscroll-behavior: contain;
}

.drawer-foot {
  display: flex;
  justify-content: flex-end;
  padding: 12px 18px calc(12px + env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

.drawer-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 10px;
}

.guide-url {
  font-size: 13px;
  word-break: break-all;
}

.guide-url a {
  color: var(--text-2);
}

.guide-heading {
  margin: 20px 0 8px;
  color: var(--text-2);
  font-size: 13px;
  font-weight: 600;
}

.guide-text {
  color: var(--text);
  font-size: 14px;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.dialog-text {
  color: var(--text-2);
  font-size: 14px;
  line-height: 1.7;
}

/* ---------------- 10. 后台 ---------------- */

.admin-head {
  margin-bottom: 16px;
}

.admin-note {
  margin-top: 8px;
  color: var(--text-3);
  font-size: 12px;
}

.tabs {
  display: flex;
  gap: 4px;
  overflow-x: auto;
  border-bottom: 1px solid var(--border);
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.tabs::-webkit-scrollbar {
  display: none;
}

.tab {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 44px;
  padding: 0 14px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--text-2);
  font-size: 14px;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.14s, border-color 0.14s;
}

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

.tab.is-active {
  border-color: var(--primary);
  color: var(--primary);
  font-weight: 600;
}

.admin-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.input-sm,
.select-sm {
  height: 36px;
  padding: 0 10px;
  font-size: 14px;
}

.admin-toolbar .input-sm {
  width: auto;
  min-width: 200px;
  flex: 0 1 260px;
}

.admin-toolbar .select-sm {
  width: auto;
  min-width: 150px;
  flex: 0 0 auto;
}

.panel-hint {
  margin: 0 0 14px;
  color: var(--text-3);
  font-size: 12px;
}

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

.list-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-elev);
}

.group-icon {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  border-radius: 9px;
  background: var(--bg-soft);
  font-size: 18px;
}

.row-main {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
  min-width: 0;
}

.row-title {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  min-width: 0;
}

.row-name {
  max-width: 100%;
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-sub {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.row-url,
.row-desc {
  overflow: hidden;
  color: var(--text-3);
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.row-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  flex: 0 0 auto;
}

.row-tools {
  display: flex;
  gap: 2px;
  flex: 0 0 auto;
}

.stats {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
  margin: 4px 0 12px;
}

.stat {
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg-soft);
}

.stat-value {
  font-size: 18px;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-label {
  color: var(--text-3);
  font-size: 12px;
}

.data-section {
  padding: 16px 0;
  border-top: 1px solid var(--border);
}

.section-title {
  margin-bottom: 10px;
  font-size: 14px;
  font-weight: 650;
}

.import-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.file-name {
  max-width: 220px;
  overflow: hidden;
  font-size: 12px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.textarea-lg {
  min-height: 260px;
  line-height: 1.7;
  resize: vertical;
}

.preview-wrap {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px dashed var(--border);
}

.preview-wrap .doc-text {
  padding: 14px;
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

/* ---------------- 11. 文档页 ---------------- */

.doc {
  padding: 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--bg-elev);
}

.doc-title {
  margin-bottom: 14px;
  font-size: 19px;
  font-weight: 700;
}

.doc-text {
  color: var(--text);
  font-size: 14px;
  line-height: 1.85;
  white-space: pre-wrap;
  word-break: break-word;
}

.doc-meta {
  margin-top: 20px;
  color: var(--text-3);
  font-size: 12px;
}

/* ---------------- 12. Toast ---------------- */

.toast-root {
  position: fixed;
  bottom: calc(24px + env(safe-area-inset-bottom));
  left: 50%;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  width: max-content;
  max-width: min(92vw, 480px);
  transform: translateX(-50%);
  pointer-events: none;
}

.toast {
  padding: 9px 14px;
  border-radius: 10px;
  background: #111827;
  color: #fff;
  font-size: 13px;
  line-height: 1.5;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.25);
  opacity: 0;
  transform: translateY(6px);
  transition: opacity 0.2s, transform 0.2s;
}

.toast.show {
  opacity: 1;
  transform: none;
}

.toast-success {
  background: #065f46;
}

.toast-error {
  background: #991b1b;
}

.toast-warn {
  background: #92400e;
}

.storage-banner {
  position: sticky;
  top: 0;
  z-index: 120;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--warn-weak);
  color: var(--warn-fg);
  font-size: 12px;
  text-align: center;
}

/* ---------------- 13. 响应式 ---------------- */

@media (max-width: 900px) {
  .grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

@media (max-width: 640px) {
  .wrap {
    padding: 0 12px;
  }

  .content {
    padding-top: 14px;
    padding-bottom: 56px;
  }

  .topbar-inner {
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px 0;
    row-gap: 8px;
  }

  .brand {
    flex: 1;
  }

  .brand-sub {
    display: none;
  }

  .topbar-search {
    order: 3;
    flex-basis: 100%;
  }

  .topbar-spacer {
    display: none;
  }

  .topbar-actions {
    gap: 0;
  }

  .icon-btn {
    width: 36px;
    height: 36px;
  }

  .search {
    max-width: none;
  }

  .grid {
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 10px;
  }

  .card-link {
    gap: 8px;
    min-height: 78px;
    padding: 10px;
  }

  .item-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
  }

  .card-name {
    padding-right: 22px;
    font-size: 13px;
  }

  .card-desc {
    font-size: 11px;
  }

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

  .input,
  .select,
  .textarea {
    font-size: 16px;
  }

  .modal {
    max-height: 92vh;
    max-height: 92dvh;
    border-radius: 16px;
  }

  .overlay {
    padding: 10px;
  }

  .overlay-drawer {
    align-items: flex-end;
    padding: 0;
  }

  .drawer {
    width: 100vw;
    height: auto;
    max-height: 84vh;
    max-height: 84dvh;
    border-top: 1px solid var(--border);
    border-left: 0;
    border-radius: 20px 20px 0 0;
    transform: translateY(24px);
    padding-bottom: env(safe-area-inset-bottom);
  }

  .drawer-body {
    padding-bottom: 22px;
  }

  .modal-foot,
  .drawer-foot {
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }

  .stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .list-row {
    flex-wrap: wrap;
    row-gap: 8px;
    padding: 10px;
  }

  .row-main {
    flex: 1 1 calc(100% - 48px);
  }

  .row-meta {
    order: 3;
  }

  .row-tools {
    order: 4;
    margin-left: auto;
  }

  .tab svg {
    display: none;
  }

  .tab {
    padding: 0 10px;
    font-size: 13px;
  }

  .admin-toolbar .input-sm {
    flex: 1 1 140px;
    min-width: 0;
  }

  .admin-toolbar .select-sm {
    flex: 1 1 120px;
    min-width: 0;
  }

  .doc {
    padding: 18px;
  }

  .login-card {
    padding: 22px 18px 18px;
    border-radius: 18px;
  }
}

@media (max-width: 380px) {
  .grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .brand-title {
    font-size: 14px;
  }

  .item-icon {
    width: 32px;
    height: 32px;
    border-radius: 9px;
  }

  .card-name {
    padding-right: 18px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    transition-duration: 0.001ms !important;
    animation-duration: 0.001ms !important;
  }
}
