/* ============================================================
 * 速查表网站样式 —— 浅色 / 深色双主题
 * ============================================================ */

:root {
  --bg: #f6f7f9;
  --bg-soft: #ffffff;
  --sidebar-bg: #ffffff;
  --text: #1a2233;
  --text-soft: #5b6472;
  --text-faint: #8b93a1;
  --border: #e4e7ec;
  --accent: #4f6ef7;
  --card-hover: #f4f6ff;
  --code-bg: #f2f4f8;
  --code-text: #d63384;
  --shadow: 0 1px 3px rgba(20, 30, 60, 0.06), 0 4px 16px rgba(20, 30, 60, 0.05);
  --radius: 12px;
  --header-h: 62px;
}

[data-theme='dark'] {
  --bg: #0e1117;
  --bg-soft: #161b26;
  --sidebar-bg: #12161f;
  --text: #e6e9f0;
  --text-soft: #a6adbd;
  --text-faint: #6c7383;
  --border: #262d3d;
  --card-hover: #1b2233;
  --code-bg: #1c2333;
  --code-text: #ff7bac;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.35), 0 4px 16px rgba(0, 0, 0, 0.25);
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB',
    'Microsoft YaHei', 'Noto Sans CJK SC', 'Noto Sans Arabic', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
}

code, pre, .copy-btn, kbd {
  font-family: 'SF Mono', 'JetBrains Mono', Menlo, Consolas, 'Liberation Mono', monospace;
}

/* ---------- 布局骨架 ---------- */
.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  width: 280px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  border-inline-end: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 20px 14px;
  gap: 10px;
  overflow-y: auto;
  z-index: 40;
}

.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 30;
  height: var(--header-h);
  display: grid;
  grid-template-columns: 1fr minmax(0, 720px) 1fr;
  align-items: center;
  gap: 12px;
  padding: 0 22px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}

.menu-btn {
  grid-column: 1;
  justify-self: start;
  display: none;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 8px;
  width: 38px;
  height: 38px;
  font-size: 17px;
  cursor: pointer;
  color: var(--text);
}

.search-wrap { grid-column: 2; position: relative; width: 100%; min-width: 0; }

.topbar-right {
  grid-column: 3;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

.search-wrap .search-icon {
  position: absolute;
  inset-inline-start: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-faint);
  pointer-events: none;
  font-size: 14px;
}

#search {
  width: 100%;
  height: 42px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  background: var(--bg-soft);
  color: var(--text);
  padding: 0 92px 0 38px;
  font-size: 14.5px;
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

[dir='rtl'] #search { padding: 0 38px 0 92px; }

#search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 18%, transparent);
}

.search-kbd {
  position: absolute;
  inset-inline-end: 12px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 11px;
  color: var(--text-faint);
  border: 1px solid var(--border);
  border-radius: 5px;
  padding: 2px 7px;
  background: var(--bg);
  pointer-events: none;
}

.search-meta { font-size: 12.5px; color: var(--text-faint); white-space: nowrap; }

.theme-btn {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: 10px;
  width: 42px;
  height: 42px;
  font-size: 17px;
  cursor: pointer;
  transition: transform 0.15s;
  flex-shrink: 0;
}
.theme-btn:hover { transform: scale(1.07); }

.lang-select {
  height: 42px;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  color: var(--text);
  border-radius: 10px;
  padding: 0 6px;
  font-size: 13px;
  cursor: pointer;
  flex-shrink: 0;
  max-width: 130px;
  outline: none;
}
.lang-select:focus { border-color: var(--accent); }

/* ---------- 侧栏 ---------- */
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 10px 14px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 6px;
}
.brand-logo {
  width: 38px; height: 38px;
  border-radius: 10px;
  background: linear-gradient(135deg, #4f6ef7, #9f5ff7);
  display: flex; align-items: center; justify-content: center;
  font-size: 19px;
  flex-shrink: 0;
}
.brand-name { font-weight: 700; font-size: 16px; letter-spacing: 0.2px; }
.brand-sub { font-size: 11.5px; color: var(--text-faint); }

.nav-label {
  font-size: 11.5px;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 8px 10px 2px;
  font-weight: 600;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: 10px;
  text-decoration: none;
  color: var(--text);
  border: 1px solid transparent;
  transition: background 0.13s, border-color 0.13s;
}

.nav-item:hover { background: var(--card-hover); }

.nav-item.active {
  background: color-mix(in srgb, var(--accent) 10%, var(--bg-soft));
  border-color: color-mix(in srgb, var(--accent) 30%, transparent);
}

.nav-icon { font-size: 20px; width: 26px; text-align: center; flex-shrink: 0; }

.nav-text { display: flex; flex-direction: column; min-width: 0; }
.nav-name { font-weight: 600; font-size: 14px; }
.nav-sub {
  font-size: 11.5px;
  color: var(--text-faint);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-foot {
  margin-top: auto;
  padding: 12px 10px 2px;
  font-size: 11.5px;
  color: var(--text-faint);
  border-top: 1px solid var(--border);
}
.sidebar-foot a { color: var(--accent); text-decoration: none; }

/* ---------- 内容区 ---------- */
.content {
  flex: 1;
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 26px 90px;
}

/* 首页 Hero */
.hero-wrap {
  width: 100%;
  max-width: 1180px;
  margin: 0 auto;
  padding: 26px 26px 0;
}

.hero {
  background:
    radial-gradient(1000px 400px at 15% -10%, color-mix(in srgb, var(--accent) 14%, transparent), transparent 60%),
    radial-gradient(800px 400px at 95% 0%, rgba(159, 95, 247, 0.12), transparent 55%),
    var(--bg-soft);
  border: 1px solid var(--border);
  border-radius: 18px;
  padding: 44px 40px 38px;
  margin-bottom: 0;
  box-shadow: var(--shadow);
}

.hero h1 {
  margin: 0 0 10px;
  font-size: 32px;
  letter-spacing: 0.3px;
}

.hero .hero-badge {
  display: inline-block;
  font-size: 12px;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: 99px;
  padding: 3px 12px;
  margin-bottom: 14px;
}

.hero p { margin: 0; color: var(--text-soft); font-size: 15.5px; max-width: 640px; }

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 26px;
  margin-top: 26px;
}
.stat b { display: block; font-size: 22px; }
.stat span { font-size: 12.5px; color: var(--text-faint); }

/* 表头 */
.sheet-head {
  margin-bottom: 26px;
  padding-bottom: 18px;
  border-bottom: 2px solid var(--accent, var(--border));
}

.sheet-head h1 { margin: 0 0 6px; font-size: 27px; display: flex; align-items: center; gap: 10px; }
.sheet-icon { font-size: 30px; }
.sheet-head p { margin: 0; color: var(--text-soft); font-size: 14.5px; }

.quick-jumps {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 16px;
}

.quick-jumps a {
  font-size: 12.5px;
  color: var(--text-soft);
  text-decoration: none;
  border: 1px solid var(--border);
  background: var(--bg-soft);
  padding: 4px 12px;
  border-radius: 99px;
  transition: all 0.13s;
}
.quick-jumps a:hover {
  color: var(--accent);
  border-color: var(--accent);
}

/* 分节 */
.sec { margin-bottom: 34px; scroll-margin-top: calc(var(--header-h) + 14px); }

.sec h2 {
  font-size: 18px;
  margin: 0 0 14px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.count {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 11%, transparent);
  border-radius: 99px;
  padding: 2px 10px;
}

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

/* 命令卡片 */
.cmd-card {
  border: 1px solid var(--border);
  background: var(--bg-soft);
  border-radius: var(--radius);
  padding: 12px 14px;
  transition: border-color 0.13s, box-shadow 0.13s, transform 0.13s;
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.cmd-card:hover {
  border-color: color-mix(in srgb, var(--accent) 45%, var(--border));
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

.cmd-line { display: flex; align-items: flex-start; gap: 8px; }

.cmd {
  flex: 1;
  min-width: 0;
  background: var(--code-bg);
  border-radius: 8px;
  overflow-x: auto;
}

.cmd pre {
  margin: 0;
  padding: 8px 11px;
  font-size: 13px;
  line-height: 1.55;
  color: var(--code-text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  user-select: all;
}

/* RTL 页面中命令代码保持从左到右 */
[dir='rtl'] .cmd pre {
  direction: ltr;
  text-align: left;
  unicode-bidi: embed;
}

.copy-btn {
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text-soft);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.13s;
}
.copy-btn:hover { border-color: var(--accent); color: var(--accent); }
.copy-btn.copied {
  background: #27c07d;
  border-color: #27c07d;
  color: #fff;
}

.cmd-meta { display: flex; align-items: baseline; gap: 10px; flex-wrap: wrap; }
.desc { font-size: 13.5px; color: var(--text-soft); }

.tip {
  font-size: 12px;
  color: #b8860b;
  background: color-mix(in srgb, #ffd666 16%, transparent);
  border-radius: 6px;
  padding: 1px 8px;
  white-space: nowrap;
}
[data-theme='dark'] .tip { color: #ffd666; }

.more-card {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1.5px dashed color-mix(in srgb, var(--accent, #4f6ef7) 50%, var(--border));
  border-radius: var(--radius);
  color: var(--accent, #4f6ef7);
  font-weight: 600;
  font-size: 14px;
  text-decoration: none;
  min-height: 90px;
  transition: all 0.15s;
}
.more-card:hover { background: color-mix(in srgb, var(--accent) 7%, transparent); }

.no-result {
  text-align: center;
  color: var(--text-faint);
  padding: 70px 20px;
  font-size: 15px;
}

/* 搜索结果表头 */
.search-head h1 { font-size: 22px; border: none; }

/* ---------- Toast ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 34px;
  transform: translateX(-50%) translateY(16px);
  background: #1f2430;
  color: #fff;
  padding: 9px 20px;
  border-radius: 99px;
  font-size: 13.5px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
  z-index: 100;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- 响应式 ---------- */
@media (max-width: 960px) {
  .sidebar {
    position: fixed;
    inset-inline-start: 0;
    top: 0;
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.2);
  }
  [dir='rtl'] .sidebar { transform: translateX(100%); }
  .sidebar.open, [dir='rtl'] .sidebar.open { transform: translateX(0); }
  .menu-btn { display: block; }
  body.sidebar-open::after {
    content: '';
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 35;
  }
  .grid { grid-template-columns: 1fr; }
  .content { padding: 18px 16px 70px; }
  .hero-wrap { padding: 16px 16px 0; }
  .hero { padding: 30px 22px; }
  .hero h1 { font-size: 25px; }
  .search-kbd { display: none; }
  .search-meta { display: none; }
  #search { padding-inline-start: 34px; padding-inline-end: 12px; }
  [dir='rtl'] #search { padding: 0 34px 0 12px; }
  .lang-select { max-width: 104px; font-size: 12px; }
}

@media (max-width: 480px) {
  .topbar { padding: 0 12px; gap: 8px; }
  #search { padding-left: 34px; }
}
