/* base.css — 变量、重置、整体布局 */

:root {
  --brand: #4f46e5;
  --brand-dark: #4338ca;
  --brand-soft: #eef2ff;
  --brand-line: #c7d2fe;

  --bg: #f6f7f9;
  --surface: #ffffff;
  --surface-2: #fafbfc;
  --border: #e5e7eb;
  --border-strong: #d1d5db;

  --text: #111827;
  --text-2: #374151;
  --muted: #6b7280;
  --muted-2: #9ca3af;

  --ok: #047857;
  --ok-soft: #ecfdf5;
  --warn: #b45309;
  --warn-soft: #fffbeb;
  --danger: #dc2626;
  --danger-soft: #fef2f2;
  --info-soft: #eff6ff;

  --radius: 12px;
  --radius-sm: 8px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .05);
  --shadow: 0 4px 16px rgba(16, 24, 40, .07);
  --shadow-lg: 0 16px 48px rgba(16, 24, 40, .16);

  --sidebar-w: 236px;
  --font: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
          "Microsoft YaHei", "Source Han Sans SC", "Noto Sans CJK SC", sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

* { box-sizing: border-box; }

/*
 * 关键：hidden 属性的 UA 样式是 display:none，但优先级低于作者样式表。
 * 只要有任何一条作者规则写了 display:grid/flex，hidden 就会失效 ——
 * 遮罩层会一直盖在页面上吃掉所有点击。这条规则必须放在最前面兜底。
 */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

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

h1, h2, h3, h4 { margin: 0; font-weight: 600; line-height: 1.35; }
p { margin: 0 0 8px; }
ul, ol { margin: 0; padding-left: 20px; }

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-thumb { background: #d8dade; border-radius: 8px; border: 3px solid transparent; background-clip: content-box; }
::-webkit-scrollbar-thumb:hover { background: #b9bcc2; background-clip: content-box; }
::-webkit-scrollbar-track { background: transparent; }

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

.app {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  height: 100vh;
  overflow: hidden;
}

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 30;
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 18px 14px;
}

.brand-mark {
  width: 34px; height: 34px;
  border-radius: 10px;
  background: linear-gradient(135deg, var(--brand), #7c3aed);
  color: #fff;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(79, 70, 229, .3);
  flex: none;
}

.brand-text { display: flex; flex-direction: column; line-height: 1.25; }
.brand-text strong { font-size: 14px; }
.brand-text span { font-size: 11px; color: var(--muted); }

.nav { padding: 4px 10px 12px; display: flex; flex-direction: column; gap: 2px; flex: 1; }

.nav-group {
  font-size: 11px;
  color: var(--muted-2);
  padding: 14px 8px 4px;
  letter-spacing: .06em;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13.5px;
  transition: background .12s, color .12s;
  text-decoration: none;
}
.nav-item:hover { background: var(--surface-2); text-decoration: none; }
.nav-item.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 600;
}
.nav-ico { width: 16px; text-align: center; opacity: .8; font-size: 13px; flex: none; }

.nav-badge {
  margin-left: auto;
  font-style: normal;
  font-size: 11px;
  min-width: 20px;
  text-align: center;
  padding: 1px 6px;
  border-radius: 20px;
  background: var(--danger-soft);
  color: var(--danger);
  font-weight: 600;
}
.nav-badge:empty { display: none; }
.nav-badge.star { background: var(--warn-soft); color: var(--warn); }

.sidebar-foot {
  padding: 12px 18px 16px;
  border-top: 1px solid var(--border);
  font-size: 11px;
  color: var(--muted);
}
.storage { font-weight: 600; color: var(--text-2); }
.hint-line { color: var(--muted-2); margin-top: 2px; }

.main { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  height: 60px;
  flex: none;
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 24px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.page-title { font-size: 17px; flex: 1; }

.topbar-actions { display: flex; align-items: center; gap: 10px; }

.quick-search input {
  width: 240px;
  padding: 7px 12px;
  border: 1px solid var(--border);
  border-radius: 20px;
  background: var(--surface-2);
  outline: none;
  font-size: 13px;
  transition: border-color .15s, background .15s, width .2s;
}
.quick-search input:focus { border-color: var(--brand-line); background: #fff; width: 300px; }

.view {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
}

.only-mobile { display: none; }
.mobile-account { display: none; }

@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: 250px;
    transform: translateX(-100%);
    transition: transform .22s ease;
    box-shadow: var(--shadow-lg);
  }
  .sidebar.open { transform: none; }
  .only-mobile { display: inline-flex; }
  .view { padding: 16px; }
  .topbar {
    min-height: 108px;
    height: auto;
    padding: 10px 12px;
    display: grid;
    grid-template-columns: 36px minmax(0, 1fr);
    grid-template-rows: 40px 42px;
    gap: 8px 10px;
    align-items: center;
  }
  .topbar .icon-btn { grid-column: 1; grid-row: 1; }
  .page-title {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    font-size: 17px;
  }
  .desktop-account { display: none !important; }
  .topbar-actions {
    grid-column: 1 / -1;
    grid-row: 2;
    min-width: 0;
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
  }
  .quick-search { min-width: 0; }
  .quick-search input,
  .quick-search input:focus {
    width: 100%;
    min-width: 0;
    height: 36px;
    font-size: 13px;
  }
  #btn-quick-import { height: 36px; padding: 6px 10px; }
  .mobile-account {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 12px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
  }
  .mobile-user-email {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--text-2);
    font-size: 12px;
  }
}

@media (max-width: 420px) {
  .view { padding: 12px; }
  .topbar { padding-left: 10px; padding-right: 10px; }
  .btn-ghost { padding-left: 8px; padding-right: 8px; }
}
