/* ============ FLASH 存储搜索 — 样式 ============ */
:root {
  --slate-900: #0f172a;
  --slate-800: #1e293b;
  --slate-500: #64748b;
  --slate-200: #e2e8f0;
  --slate-100: #f1f5f9;
  --slate-50: #f8fafc;
  --sky-500: #0ea5e9;
  --sky-600: #0284c7;
  --sky-50: #f0f9ff;
  --red-50: #fef2f2;
  --red-600: #dc2626;
  --white: #ffffff;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(15, 23, 42, 0.08), 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-lg: 0 12px 24px rgba(15, 23, 42, 0.12);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Helvetica Neue", "Segoe UI", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--slate-50);
  color: var(--slate-900);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 16px;
}

.hidden { display: none !important; }

/* ============ 顶部导航 ============ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(248, 250, 252, 0.92);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--slate-200);
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  text-decoration: none;
  color: var(--slate-900);
  flex-shrink: 0;
}

.brand-logo {
  width: 30px;
  height: 30px;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--sky-500), var(--slate-800));
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.brand-title {
  font-weight: 600;
  font-size: 15px;
  white-space: nowrap;
}

.search-row { flex: 1; min-width: 0; display: flex; justify-content: flex-end; }
.search-row .search-form { width: 100%; max-width: 620px; }

/* ============ Hero ============ */
/* 主内容区撑满视口，使初始搜索框垂直居中；header 与 footer 不参与 flex */
.main-content {
  display: flex;
  flex-direction: column;
  flex: 1 0 auto;
}

.hero {
  flex: 1 0 auto;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 48px 0 24px;
}

.hero-inner {
  width: 100%;
  max-width: 720px;
  text-align: center;
}

/* 搜索后：搜索区紧凑靠上，结果在其下方展示 */
.hero.hero-compact {
  flex: 0 0 auto;
  align-items: flex-start;
  padding: 24px 0 8px;
}
.hero.hero-compact .hero-title { font-size: 22px; margin-bottom: 4px; }
.hero.hero-compact .hero-sub { font-size: 13px; margin-bottom: 16px; }

.hero-title {
  font-size: clamp(26px, 6vw, 36px);
  font-weight: 700;
  color: var(--slate-800);
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.hero-sub {
  color: var(--slate-500);
  font-size: 15px;
  margin-bottom: 28px;
}

/* ============ 搜索框容器 ============ */
.search-form { text-align: left; }

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

.search-primary-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 模式下拉 */
.mode-select-wrap { position: relative; flex-shrink: 0; }

.mode-select {
  appearance: none;
  -webkit-appearance: none;
  height: 44px;
  padding: 0 32px 0 12px;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  background: var(--white) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E") no-repeat right 10px center;
  background-size: 14px;
  font-size: 14px;
  color: var(--slate-800);
  font-family: inherit;
  cursor: pointer;
  outline: none;
}
.mode-select:focus { border-color: var(--sky-500); box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15); }

/* 输入框 */
.input-wrap { position: relative; flex: 1; min-width: 0; }

.search-input {
  width: 100%;
  height: 44px;
  padding: 0 38px 0 14px;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  color: var(--slate-900);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.search-input:focus {
  border-color: var(--sky-500);
  box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15);
}
.search-input:disabled { opacity: 0.7; background: var(--slate-100); }

.clear-btn {
  position: absolute;
  top: 50%;
  right: 10px;
  transform: translateY(-50%);
  width: 20px;
  height: 20px;
  border: none;
  background: var(--slate-200);
  color: var(--slate-500);
  border-radius: 50%;
  font-size: 12px;
  line-height: 1;
  display: none;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.clear-btn.visible { display: flex; }
.clear-btn:hover { background: var(--slate-200); color: var(--slate-800); }

/* 搜索按钮 */
.search-btn {
  height: 44px;
  padding: 0 22px;
  border: none;
  border-radius: 10px;
  background: var(--sky-500);
  color: #fff;
  font-size: 15px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  white-space: nowrap;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-shrink: 0;
  transition: background 0.15s;
  width: 100%;
}
.search-btn:hover { background: var(--sky-600); }
.search-btn:disabled { opacity: 0.7; cursor: not-allowed; }
.search-btn .spinner {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.35);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: none;
}
.search-btn.loading .spinner { display: inline-block; }

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

/* 桌面端：按钮与输入同行 */
@media (min-width: 640px) {
  .search-controls { flex-direction: row; align-items: center; }
  .search-btn { width: auto; }
}

/* ============ 联想下拉 ============ */
.suggestions {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  max-height: 240px;
  overflow: auto;
  z-index: 100;
  padding: 4px;
}
.suggestions:empty { display: none; }
.suggestion-item {
  padding: 9px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 14px;
  color: var(--slate-800);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.suggestion-item:hover, .suggestion-item.active { background: var(--sky-50); color: var(--sky-600); }
.suggestion-item .s-label { color: var(--sky-500); margin-right: 6px; font-size: 13px; }

/* ============ 结果区 ============ */
.results { padding: 16px 0 48px; }
.results-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.results-count { color: var(--slate-500); font-size: 13px; }

.card {
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
  margin-bottom: 14px;
  transition: transform 0.15s, box-shadow 0.15s;
}
.card:hover { transform: translateY(-2px); box-shadow: var(--shadow-lg); }

.card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.card-title { font-size: 18px; font-weight: 600; color: var(--slate-900); }
.card-title-link {
  background: none; border: none; padding: 0; margin: 0; cursor: pointer; text-align: left;
  font: inherit; color: var(--sky-600); text-decoration: underline;
}
.card-title-link:hover { color: var(--sky-500); }
.card-sub { font-size: 13px; color: var(--slate-500); margin-top: 2px; }

.card-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}
@media (min-width: 640px) {
  .card-grid { grid-template-columns: 1fr 1fr; }
}

.field { display: flex; align-items: baseline; gap: 8px; min-width: 0; }
.field-label {
  flex-shrink: 0;
  min-width: 72px;
  font-size: 13px;
  font-weight: 500;
  color: var(--slate-500);
}
.field-value {
  font-size: 14px;
  color: var(--slate-900);
  word-break: break-all;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
}

/* 闪存型号可点击 */
.pn-link {
  color: var(--sky-600);
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  font-family: inherit;
  font-size: 14px;
}
.pn-link:hover { color: var(--sky-500); }

.pn-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--sky-50);
  color: var(--sky-600);
  border-radius: 6px;
  padding: 1px 8px;
  font-size: 13px;
}
.pn-chip .dot { width: 4px; height: 4px; background: var(--sky-500); border-radius: 50%; }

/* 折叠按钮 */
.toggle-btn {
  margin-top: 12px;
  border: none;
  background: var(--slate-100);
  color: var(--slate-500);
  border-radius: 8px;
  padding: 6px 12px;
  font-size: 13px;
  font-family: inherit;
  cursor: pointer;
}
.toggle-btn:hover { background: var(--slate-200); color: var(--slate-800); }

/* 原始 JSON */
.raw-block {
  margin-top: 12px;
  background: var(--slate-900);
  color: #cbd5e1;
  border-radius: 8px;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 12px;
  white-space: pre-wrap;
  word-break: break-all;
  max-height: 300px;
  overflow: auto;
}

/* ============ 状态提示 ============ */
.empty-state, .error-state { text-align: center; padding: 60px 16px; color: var(--slate-500); }
.error-state { color: var(--red-600); }
.error-state .err-card {
  display: inline-block;
  background: var(--red-50);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
  padding: 16px 24px;
  font-size: 14px;
}

/* ============ Footer ============ */
.site-footer {
  margin-top: auto;
  text-align: center;
  padding: 24px 16px;
  color: var(--slate-500);
  font-size: 13px;
  border-top: 1px solid var(--slate-200);
}

/* 桌面端横向布局 */
@media (min-width: 640px) {
  .search-controls {
    flex-direction: row;
    align-items: center;
    gap: 10px;
  }
  .search-primary-row { flex: 1; min-width: 0; }
  .search-controls > .search-btn {
    flex-shrink: 0;
    height: 44px;
    padding: 0 28px;
  }
  /* 顶部导航的搜索控件略紧凑 */
  .header-inner { padding: 12px 24px; gap: 20px; }
  .search-row .search-form { max-width: 640px; }
}

/* 手机端适配 */
@media (max-width: 639px) {
  .hero { padding: 32px 0 16px; }
  .hero.hero-compact { padding: 18px 0 8px; }
  .brand-title { font-size: 13px; }
  .search-btn { height: 42px; }
  .mode-select, .search-input { height: 42px; font-size: 15px; }
  .card { padding: 14px; }
  .field { flex-direction: column; gap: 2px; }
  .field-label { min-width: 0; }
}

/* ============ 登录页 / 用户管理页 ============ */
.auth-body {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

/* 登录卡片 */
.auth-shell { width: 100%; display: flex; justify-content: center; }
.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--white);
  border: 1px solid var(--slate-200);
  border-radius: 12px;
  padding: 32px 28px;
  box-shadow: var(--shadow-md);
}
.auth-logo {
  font-size: 20px;
  font-weight: 700;
  color: var(--slate-900);
  letter-spacing: 0.5px;
}
.auth-sub { color: var(--slate-500); font-size: 13px; margin: 6px 0 20px; }
.auth-error {
  background: #fef2f2;
  color: var(--red-600);
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 9px 12px;
  font-size: 13px;
  margin-bottom: 14px;
}

/* 表单 */
.form-field { display: block; margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; font-weight: 500; color: var(--slate-800); margin-bottom: 6px; }
.form-input {
  width: 100%;
  height: 42px;
  border: 1px solid var(--slate-200);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--slate-900);
  background: var(--white);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
  box-sizing: border-box;
}
.form-input:focus { border-color: var(--sky-500); box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.15); }

/* 按钮 */
.form-btn {
  border: none;
  border-radius: 10px;
  height: 42px;
  padding: 0 16px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s, transform 0.05s, box-shadow 0.15s;
}
.form-btn:active { transform: translateY(1px); }
.form-btn-primary { background: var(--sky-500); color: #fff; }
.form-btn-primary:hover { background: #0284c7; }
.form-btn-block { width: 100%; margin-top: 6px; }
.form-btn-ghost { background: transparent; color: var(--slate-500); border: 1px solid var(--slate-200); }
.form-btn-ghost:hover { background: var(--slate-100); }
.form-btn-sm { height: 32px; font-size: 13px; padding: 0 12px; border-radius: 8px; }
.form-btn-danger { background: transparent; color: var(--red-600); border: 1px solid #fecaca; }
.form-btn-danger:hover { background: #fef2f2; }

/* 管理页布局 */
.admin-shell { width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px 48px; }
.admin-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  padding: 18px 0;
  border-bottom: 1px solid var(--slate-200);
  margin-bottom: 20px;
}
.admin-brand { font-size: 18px; font-weight: 700; color: var(--slate-900); }
.admin-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.admin-user { font-size: 13px; color: var(--slate-500); }
.admin-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-bottom: 20px;
}
@media (min-width: 640px) {
  .admin-grid { grid-template-columns: 1fr 1fr; }
}
.admin-card { padding: 20px; }

/* flash 消息 */
.flash { border-radius: 8px; padding: 10px 14px; font-size: 13px; margin-bottom: 16px; }
.flash-success { background: #f0fdf4; color: #15803d; border: 1px solid #bbf7d0; }
.flash-error { background: #fef2f2; color: var(--red-600); border: 1px solid #fecaca; }

/* 表格 */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { text-align: left; padding: 10px 12px; border-bottom: 1px solid var(--slate-100); white-space: nowrap; }
.table th { color: var(--slate-500); font-weight: 500; font-size: 12px; }
.table tbody tr:hover { background: var(--slate-50); }
.td-actions { display: flex; gap: 8px; }
.inline-form { display: inline; }
.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 12px; }
.badge-admin { background: #e0f2fe; color: #0369a1; }
.badge-user { background: var(--slate-100); color: var(--slate-500); }
.hint { font-size: 12px; color: var(--slate-500); margin-top: 12px; }
.hint code { background: var(--slate-100); padding: 1px 5px; border-radius: 4px; }

/* 顶部导航用户区 */
.header-user { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.header-user-name { font-size: 13px; color: var(--slate-500); font-weight: 500; }
.header-user-link { font-size: 13px; color: var(--sky-600); text-decoration: none; }
.header-user-link:hover { text-decoration: underline; }

/* 验证码 */
.captcha-row { display: flex; gap: 10px; align-items: stretch; }
.captcha-input { flex: 1; min-width: 0; text-transform: uppercase; letter-spacing: 2px; }
.captcha-img {
  height: 42px;
  width: 120px;
  border-radius: 8px;
  border: 1px solid var(--slate-200);
  cursor: pointer;
  background: var(--slate-100);
  user-select: none;
}

/* 记住我 */
.remember-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
  cursor: pointer;
  font-size: 14px;
  color: var(--slate-500);
}
.remember-row input { width: 16px; height: 16px; accent-color: var(--sky-500); cursor: pointer; }

@media (max-width: 639px) {
  .auth-body { padding: 16px; align-items: flex-start; padding-top: 8vh; }
  .form-input { height: 46px; }
  .captcha-img { width: 104px; height: 42px; }
}

/* 历史搜索记录 */
.history-bar {
  display: none;
  width: 100%;
  max-width: 720px;
  margin: 18px auto 0;
  text-align: left;
}
.history-bar.show { display: block; }
.history-head {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 10px;
}
.history-title {
  font-size: 13px; font-weight: 600; color: var(--slate-500);
  display: inline-flex; align-items: center; gap: 6px;
}
.history-title::before {
  content: ""; display: inline-block; width: 3px; height: 13px;
  background: var(--sky-500); border-radius: 2px;
}
.history-clear {
  border: none; background: none; cursor: pointer;
  font-size: 12px; color: var(--slate-500); padding: 2px 4px;
}
.history-clear:hover { color: var(--red-600); }
.history-links {
  display: flex; flex-wrap: wrap;
  gap: 2px 22px;
}
.history-link {
  font-size: 13px;
  color: var(--sky-600);
  text-decoration: none;
  line-height: 1.8;
  max-width: 100%;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  transition: color .15s;
}
.history-link:hover { color: var(--sky-500); text-decoration: underline; }

@media (max-width: 639px) {
  .history-bar { margin-top: 14px; }
  .history-link { max-width: 140px; }
}