/* ============================================================
   现代简约主题 · 文件下载站
   ============================================================ */

:root {
  /* 主色调 */
  --primary: #4f6ef7;
  --primary-light: #eef1ff;
  --primary-dark: #3b5de7;

  /* 中性色 */
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-hover: #fafbfc;
  --border: #e5e7eb;
  --border-light: #f0f0f0;

  /* 文字 */
  --text: #1a1d23;
  --text-secondary: #6b7280;
  --text-tertiary: #9ca3af;

  /* 语义色 */
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;

  /* 尺寸 */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.10);
  --shadow-primary: 0 4px 16px rgba(79, 110, 247, 0.20);

  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  --font-mono: "SF Mono", "Fira Code", "Fira Mono", Menlo, Consolas, monospace;
}

/* ─── 基础重置 ─── */
*, *::before, *::after { box-sizing: border-box; }

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

/* ─── 布局 ─── */
.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 32px 24px 80px;
}

/* ─── 页面头部 ─── */
.page-header {
  margin-bottom: 24px;
}

h1 {
  font-size: 24px;
  font-weight: 700;
  margin: 0;
  letter-spacing: -0.02em;
  color: var(--text);
}

.sub {
  color: var(--text-secondary);
  margin: 6px 0 0;
  font-size: 14px;
}

/* ─── 状态栏 ── */
.bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 16px;
  margin-bottom: 24px;
  box-shadow: var(--shadow-sm);
}

.bar__spacer { flex: 1; }

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  font-weight: 500;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--bg);
  color: var(--text-secondary);
  white-space: nowrap;
  transition: all 0.15s ease;
}

.pill b {
  color: var(--text);
  font-family: var(--font-mono);
  font-weight: 600;
  font-size: 12px;
}

.pill--ok   { background: var(--success-bg); color: var(--success); }
.pill--warn { background: var(--warning-bg); color: var(--warning); }
.pill--err  { background: var(--danger-bg);  color: var(--danger);  }

.dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* ─── 面板 ── */
.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.panel h2 {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 16px;
  color: var(--text);
  letter-spacing: -0.01em;
}

/* ─── 网格布局 ─── */
.grid {
  display: grid;
  gap: 20px;
  grid-template-columns: 1fr;
}

@media (min-width: 860px) {
  .grid { grid-template-columns: 360px 1fr; }
}

/* ─── 表单 ─── */
label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  margin: 12px 0 6px;
}

input, select {
  width: 100%;
  padding: 9px 12px;
  font: inherit;
  font-size: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

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

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-light);
}

/* ─── 按钮 ─── */
button {
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  transition: all 0.15s ease;
}

button:hover {
  background: var(--surface-hover);
  border-color: #d1d5db;
}

button:active {
  transform: scale(0.98);
}

button.primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
  box-shadow: var(--shadow-sm);
}

button.primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
  box-shadow: var(--shadow-primary);
}

button.danger {
  color: var(--danger);
  border-color: #fecaca;
}

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

button.sm {
  padding: 5px 10px;
  font-size: 13px;
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.row {
  display: flex;
  gap: 10px;
  margin-top: 16px;
}

/* ─── 表格 ── */
table {
  width: 100%;
  border-collapse: collapse;
}

th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-light);
  font-size: 13px;
}

th {
  color: var(--text-secondary);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

td.url {
  max-width: 260px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--text-secondary);
}

/* ─── 空状态 ─── */
.empty {
  color: var(--text-tertiary);
  padding: 40px 0;
  text-align: center;
  font-size: 14px;
}

/* ─── 卡片网格 ─── */
.cards {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px;
  transition: all 0.2s ease;
}

.card__name {
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 4px;
  word-break: break-all;
  color: var(--text);
}

.card__meta {
  color: var(--text-secondary);
  font-size: 12px;
}

.card a {
  color: var(--primary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
}

.card a:hover {
  text-decoration: underline;
}

/* ─── 可点击文件夹卡片 ─── */
a.card {
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
}

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

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

.card__icon {
  width: 44px;
  height: 44px;
  margin-bottom: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  background: var(--primary-light);
}

.card__foot {
  margin-top: 8px;
  font-size: 12px;
  color: var(--primary);
  font-weight: 500;
}

/* ─── 文件夹详情页头部 ─── */
.folder-head {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
  box-shadow: var(--shadow-sm);
}

.folder-head__icon {
  width: 52px;
  height: 52px;
  flex: none;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius);
  background: var(--primary-light);
}

.folder-head__name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.folder-head__meta {
  color: var(--text-secondary);
  font-size: 13px;
  margin-top: 2px;
}

.folder-head__spacer { flex: 1; }

/* ─── 返回链接 ─── */
.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 16px;
  transition: color 0.15s ease;
}

.back-link:hover {
  color: var(--primary);
}

/* ─── 已删除提示 ─── */
.gone {
  text-align: center;
  padding: 60px 20px;
}

.gone__title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
}

.gone__desc {
  color: var(--text-secondary);
  margin-bottom: 20px;
}

/* ─── Toast 提示 ─── */
.flash {
  position: fixed;
  left: 50%;
  bottom: 32px;
  transform: translateX(-50%) translateY(8px);
  background: var(--text);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
  max-width: 90vw;
  z-index: 50;
  box-shadow: var(--shadow-lg);
}

.flash.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.flash.err { background: var(--danger); }
.flash.ok  { background: var(--success); }

/* ─── 提示框 ─── */
.hint {
  background: var(--primary-light);
  border: 1px solid #d4dbff;
  color: #3b5de7;
  border-radius: var(--radius);
  padding: 12px 16px;
  font-size: 13px;
  margin-bottom: 20px;
}

code {
  font-family: var(--font-mono);
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 12px;
}

/* ─── 安装向导 ─── */
.setup {
  max-width: 640px;
  margin: 0 auto;
  padding: 48px 24px 80px;
}

.setup__logo {
  width: 48px;
  height: 48px;
  margin-bottom: 16px;
  border-radius: var(--radius);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.setup h1 {
  font-size: 22px;
  margin: 0 0 8px;
}

.setup__sub {
  color: var(--text-secondary);
  margin: 0 0 28px;
}

.driver-opts {
  display: grid;
  gap: 10px;
}

.driver-opt {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 16px;
  cursor: pointer;
  background: var(--surface);
  transition: all 0.15s ease;
}

.driver-opt:hover {
  border-color: #d1d5db;
  background: var(--surface-hover);
}

.driver-opt.is-active {
  border-color: var(--primary);
  background: var(--primary-light);
}

.driver-opt input {
  width: auto;
  margin-top: 3px;
  flex: none;
}

.driver-opt__name {
  font-weight: 600;
  font-size: 14px;
}

.driver-opt__desc {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 2px;
}

.driver-opt.is-disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.driver-opt__badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--success-bg);
  color: var(--success);
  margin-left: 8px;
  font-weight: 500;
}

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

details.adv {
  margin-top: 20px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

details.adv summary {
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 500;
}

details.adv summary:hover {
  color: var(--text);
}

.result {
  margin-top: 16px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  display: none;
}

.result.show { display: block; }
.result--ok   { background: var(--success-bg); color: #065f46; border: 1px solid #a7f3d0; }
.result--err  { background: var(--danger-bg);  color: #991b1b; border: 1px solid #fecaca; }
.result--info { background: var(--primary-light); color: #3b5de7; border: 1px solid #d4dbff; }

/* ─── 登录遮罩 ── */
.mask {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(244, 245, 247, 0.8);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.mask[hidden] { display: none; }

.login {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px 28px;
  box-shadow: var(--shadow-lg);
}

.login__logo {
  width: 48px;
  height: 48px;
  margin: 0 auto 16px;
  border-radius: var(--radius);
  background: var(--primary-light);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login__title {
  font-size: 18px;
  font-weight: 600;
  text-align: center;
  margin: 0 0 6px;
  letter-spacing: -0.01em;
}

.login__sub {
  color: var(--text-secondary);
  font-size: 13px;
  text-align: center;
  margin: 0 0 20px;
}

.login__check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  color: var(--text-secondary);
  margin: 12px 0 16px;
}

.login__check input { width: auto; }

.btn--block { width: 100%; }
.btn--primary {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}
.btn--primary:hover {
  background: var(--primary-dark);
  border-color: var(--primary-dark);
}

.token-row {
  display: flex;
  gap: 8px;
}

.token-row input {
  flex: 1;
  font-family: var(--font-mono);
  font-size: 12px;
}

.setup__hint {
  color: var(--text-secondary);
  font-size: 12px;
  margin-top: 8px;
}

/* ─── 响应式 ─── */
@media (max-width: 640px) {
  .wrap { padding: 20px 16px 60px; }
  h1 { font-size: 20px; }
  .bar { padding: 8px 12px; gap: 6px; }
  .panel { padding: 16px; }
  .cards { grid-template-columns: 1fr; }
  .field-row2 { grid-template-columns: 1fr; }
}
