/* ==========================================================================
   AI 导航 · 共用设计 Token
   前台（index / list / detail / rank / submit / about）
   与后台（admin/*）共用同一套变量。
   页面中不要硬编码颜色、圆角、间距、字号 —— 一律引用这里的变量。
   ========================================================================== */

:root {
  /* --- 品牌 --- */
  --brand: #06B6D4;              /* 主色：图标、强调、选中态、悬停描边、聚焦光晕 */
  --brand-hover: #0891B2;
  --brand-active: #0E7490;
  --brand-soft: rgba(6, 182, 212, .10);
  --brand-soft-2: rgba(6, 182, 212, .18);
  --brand-line: rgba(6, 182, 212, .35);
  --brand-text: #0E7490;         /* 需要以品牌色作文字时使用（对比度 ≥4.5:1） */

  /* --- 中性色 --- */
  --bg-page: #FFFFFF;
  --bg-content: #F8FAFC;
  --bg-sunken: #F1F5F9;
  --surface: #FFFFFF;
  --border: #E2E8F0;
  --border-strong: #CBD5E1;

  /* --- 文字 --- */
  --text-1: #0F172A;
  --text-2: #64748B;
  --text-3: #94A3B8;             /* 仅用于占位符、禁用态、装饰性图标 */
  --text-invert: #FFFFFF;

  /* --- 状态色 --- */
  --success: #10B981;
  --success-soft: rgba(16, 185, 129, .12);
  --warning: #F59E0B;
  --warning-soft: rgba(245, 158, 11, .14);
  --danger: #EF4444;
  --danger-soft: rgba(239, 68, 68, .10);

  /* --- 字号阶梯（中文只有 2–3 个可用字重，层级靠字号 + 颜色 + 间距） ---
     2026-09-25 整体上调一档。原来的 12/13/14/15 对拉丁字母尚可，对中文偏小：
     汉字笔画密度高，同样 13px 下可读性明显低于英文，13px 的正文看久了发闷。
     现在正文 15px、辅助 14px、元信息 13px，各自只比原来大一档，层级关系不变。
     硬编码的 11px 也一并提到 12px —— 阶梯底部不该有 11px 这个档位。 */
  --fs-hero: 42px;
  --fs-h1: 22px;
  --fs-h2: 17px;
  --fs-card: 16px;
  --fs-body: 15px;
  --fs-table: 14px;
  --fs-meta: 13px;

  --lh-hero: 1.25;
  --lh-title: 1.4;
  --lh-body: 1.6;

  /* --- 间距（8 的倍数） --- */
  --sp-1: 8px;
  --sp-2: 12px;
  --sp-3: 16px;
  --sp-4: 24px;
  --sp-5: 32px;
  --sp-6: 48px;
  --sp-7: 64px;

  /* --- 圆角 --- */
  --r-card: 8px;
  --r-control: 6px;
  --r-modal: 12px;
  --r-pill: 999px;

  /* --- 阴影（极轻，靠背景色区分层次） --- */
  --sh-subtle: 0 1px 2px rgba(0, 0, 0, .04);
  --sh-lift: 0 4px 12px rgba(15, 23, 42, .08);
  --sh-pop: 0 12px 32px rgba(15, 23, 42, .14);
  --ring: 0 0 0 3px rgba(6, 182, 212, .25);

  /* --- 动效 --- */
  --dur-micro: 160ms;
  --dur-base: 240ms;
  --dur-exit: 140ms;
  --ease-out: cubic-bezier(.16, .84, .44, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);

  /* --- 布局 --- */
  --front-max: 1280px;
  --admin-sidebar: 220px;
  --z-header: 100;
  --z-drawer: 200;
  --z-modal: 300;
  --z-toast: 400;

  /* --- 字体栈 --- */
  --font: system-ui, "PingFang SC", "Microsoft YaHei", sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Courier New", monospace;
}

/* ==========================================================================
   基础重置
   ========================================================================== */

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

/* hidden 属性优先级最高：组件类里写了 display 也不会把它盖掉 */
[hidden] { display: none !important; }

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: var(--fs-body);
  line-height: var(--lh-body);
  color: var(--text-1);
  background: var(--bg-page);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

h1, h2, h3, h4, p, figure { margin: 0; }
ul, ol { margin: 0; padding: 0; list-style: none; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; background: none; border: 0; padding: 0; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
img, svg { display: block; max-width: 100%; }
table { border-collapse: collapse; border-spacing: 0; }

:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
  border-radius: 4px;
}

.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;
}

/* 页宽容器 */
.wrap {
  width: 100%;
  max-width: var(--front-max);
  margin: 0 auto;
  padding: 0 var(--sp-4);
}

/* ==========================================================================
   共用组件 · 按钮
   ========================================================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 36px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-control);
  font-size: var(--fs-body);
  line-height: 1;
  white-space: nowrap;
  cursor: pointer;
  border: 1px solid transparent;
  transition: background-color var(--dur-micro) var(--ease-out),
              border-color var(--dur-micro) var(--ease-out),
              color var(--dur-micro) var(--ease-out),
              box-shadow var(--dur-micro) var(--ease-out);
}

.btn-primary {
  background: var(--brand);
  color: var(--text-invert);
  font-weight: 600;
}
.btn-primary:hover { background: var(--brand-hover); }
.btn-primary:active { background: var(--brand-active); }

.btn-secondary {
  background: var(--surface);
  color: var(--text-1);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--brand); color: var(--brand-text); }

.btn-ghost { color: var(--text-2); }
.btn-ghost:hover { color: var(--brand-text); background: var(--brand-soft); }

.btn-danger { background: var(--danger); color: #fff; font-weight: 600; }
.btn-danger:hover { filter: brightness(.94); }

.btn-sm { height: 30px; padding: 0 var(--sp-2); font-size: var(--fs-table); }
.btn-lg { height: 44px; padding: 0 var(--sp-4); font-size: var(--fs-card); }
.btn-block { width: 100%; }

.btn[disabled], .btn[aria-disabled="true"] {
  background: var(--bg-sunken);
  color: var(--text-3);
  border-color: var(--border);
  cursor: not-allowed;
  font-weight: 400;
}
.btn[disabled]:hover, .btn[aria-disabled="true"]:hover { filter: none; background: var(--bg-sunken); }

/* 文字按钮（表格操作列） */
.link-btn {
  color: var(--brand-text);
  font-size: var(--fs-table);
  cursor: pointer;
  transition: color var(--dur-micro) var(--ease-out);
}
.link-btn:hover { color: var(--brand-active); text-decoration: underline; }
.link-btn.is-danger { color: var(--danger); }
.link-btn.is-danger:hover { color: #B91C1C; }
.link-btn[aria-disabled="true"] {
  color: var(--text-3);
  cursor: not-allowed;
  text-decoration: none;
}

/* ==========================================================================
   共用组件 · 徽章 / 标签
   ========================================================================== */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 22px;
  padding: 0 10px;
  border-radius: var(--r-pill);
  font-size: var(--fs-meta);
  line-height: 1;
  white-space: nowrap;
}
.badge-success { background: var(--success-soft); color: #047857; }
.badge-warning { background: var(--warning-soft); color: #B45309; }
.badge-danger  { background: var(--danger-soft);  color: #B91C1C; }
.badge-neutral { background: var(--bg-sunken);    color: var(--text-2); }
.badge-brand   { background: var(--brand-soft);   color: var(--brand-text); }
.badge-info    { background: #E0F2FE;             color: #0369A1; }
.badge-violet  { background: #EDE9FE;             color: #6D28D9; }

/* 分类小标签（工具卡片底部） */
.tag {
  display: inline-flex;
  align-items: center;
  height: 20px;
  padding: 0 8px;
  border-radius: 4px;
  background: var(--bg-sunken);
  color: var(--text-2);
  font-size: var(--fs-meta);
  line-height: 1;
  white-space: nowrap;
}

/* ==========================================================================
   共用组件 · 表单控件
   ========================================================================== */

.field { display: grid; gap: 6px; }
.field > .field-label {
  display: block;
  font-size: var(--fs-table);
  color: var(--text-1);
}
.field-label .req { color: var(--danger); margin-left: 2px; }
.field-hint { display: block; font-size: var(--fs-meta); color: var(--text-2); line-height: 1.5; }
.field-error { display: block; font-size: var(--fs-meta); color: var(--danger); line-height: 1.5; }

.input, .select, .textarea {
  width: 100%;
  min-height: 36px;
  padding: 7px var(--sp-2);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  font-size: var(--fs-body);
  color: var(--text-1);
  transition: border-color var(--dur-micro) var(--ease-out),
              box-shadow var(--dur-micro) var(--ease-out);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.input:hover, .select:hover, .textarea:hover { border-color: var(--border-strong); }
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
.input.is-error, .textarea.is-error { border-color: var(--danger); }
.input.is-error:focus, .textarea.is-error:focus { box-shadow: 0 0 0 3px rgba(239, 68, 68, .18); }
.input[disabled], .select[disabled], .textarea[disabled] {
  background: var(--bg-sunken);
  color: var(--text-3);
  cursor: not-allowed;
}

.select {
  appearance: none;
  padding-right: 30px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
}

.textarea { min-height: 76px; resize: vertical; line-height: 1.6; }

/* 勾选框 */
.check {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 24px;
  font-size: var(--fs-table);
  color: var(--text-1);
  cursor: pointer;
  user-select: none;
}
.check input[type="checkbox"] {
  width: 16px; height: 16px; margin: 0;
  accent-color: var(--brand);
  cursor: pointer;
}
.check input[type="checkbox"][disabled] { cursor: not-allowed; }
.check.is-disabled { color: var(--text-3); cursor: not-allowed; }

/* 开关 */
.switch { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.switch .switch-track {
  position: relative;
  width: 36px; height: 20px;
  border-radius: var(--r-pill);
  background: var(--border-strong);
  transition: background-color var(--dur-micro) var(--ease-out);
}
.switch .switch-track::after {
  content: "";
  position: absolute; top: 2px; left: 2px;
  width: 16px; height: 16px;
  border-radius: 50%;
  background: #fff;
  box-shadow: var(--sh-subtle);
  transition: transform var(--dur-micro) var(--ease-out);
}
.switch input:checked + .switch-track { background: var(--brand); }
.switch input:checked + .switch-track::after { transform: translateX(16px); }
.switch input:focus-visible + .switch-track { box-shadow: var(--ring); }

/* ==========================================================================
   共用组件 · 卡片 / 区块标题
   ========================================================================== */

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
}

.section-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--sp-3);
  margin-bottom: var(--sp-3);
}
.section-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: var(--fs-h1);
  font-weight: 600;
  line-height: var(--lh-title);
  color: var(--text-1);
}
.section-title .ico { color: var(--brand); }
.section-sub { font-size: var(--fs-table); color: var(--text-2); }
.section-more {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  font-size: var(--fs-table);
  color: var(--text-2);
  transition: color var(--dur-micro) var(--ease-out);
}
.section-more:hover { color: var(--brand-text); }

/* 工具 Logo 占位块（统一为「首字方块」，不使用外部图片） */
.tool-logo {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 40px; height: 40px;
  border-radius: var(--r-card);
  font-size: var(--fs-h2);
  font-weight: 600;
  line-height: 1;
  letter-spacing: 0;
  user-select: none;
}
.tool-logo.lgc-1 { background: #E0F2FE; color: #0369A1; }
.tool-logo.lgc-2 { background: #ECFDF5; color: #047857; }
.tool-logo.lgc-3 { background: #FEF3C7; color: #B45309; }
.tool-logo.lgc-4 { background: #F1F5F9; color: #334155; }
.tool-logo.lgc-5 { background: #EDE9FE; color: #6D28D9; }
.tool-logo.lgc-6 { background: #FFE4E6; color: #BE123C; }
.tool-logo.lgc-7 { background: #CFFAFE; color: #0E7490; }
.tool-logo.lgc-8 { background: #FFEDD5; color: #C2410C; }

/* ==========================================================================
   共用组件 · 表格
   ========================================================================== */

.table-scroll { width: 100%; overflow-x: auto; }

.table { width: 100%; min-width: 860px; font-size: var(--fs-body); }
.table thead th {
  padding: 10px var(--sp-3);
  background: var(--bg-content);
  border-bottom: 1px solid var(--border);
  font-size: var(--fs-table);
  font-weight: 400;
  color: var(--text-2);
  text-align: left;
  white-space: nowrap;
}
.table tbody td {
  padding: var(--sp-2) var(--sp-3);
  border-bottom: 1px solid var(--border);
  color: var(--text-1);
  vertical-align: middle;
}
.table tbody tr { transition: background-color var(--dur-micro) var(--ease-out); }
.table tbody tr:hover { background: var(--bg-content); }
.table tbody tr:last-child td { border-bottom: 0; }
.table .col-num { text-align: right; font-variant-numeric: tabular-nums; }
.table .col-act { white-space: nowrap; }
.table .cell-sub { display: block; font-size: var(--fs-meta); color: var(--text-2); }
.table .cell-mono { font-family: var(--font-mono); font-size: var(--fs-meta); color: var(--text-2); }
.table .cell-time { font-size: var(--fs-table); color: var(--text-2); font-variant-numeric: tabular-nums; }

/* 分页 */
.pager {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-top: 1px solid var(--border);
  font-size: var(--fs-table);
  color: var(--text-2);
}
.pager-list { display: flex; align-items: center; gap: 4px; }
.pager-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px; height: 30px;
  padding: 0 8px;
  border: 1px solid var(--border);
  border-radius: var(--r-control);
  font-size: var(--fs-table);
  color: var(--text-2);
  background: var(--surface);
  transition: border-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.pager-btn:hover { border-color: var(--brand); color: var(--brand-text); }
.pager-btn.is-current {
  background: var(--brand-soft);
  border-color: var(--brand-line);
  color: var(--brand-text);
}
.pager-btn[aria-disabled="true"] { color: var(--text-3); cursor: not-allowed; border-color: var(--border); }
.pager-ellipsis { padding: 0 4px; color: var(--text-3); }

/* ==========================================================================
   共用组件 · 空状态 / 加载态
   ========================================================================== */

.empty {
  display: grid;
  justify-items: center;
  gap: var(--sp-2);
  padding: var(--sp-6) var(--sp-4);
  text-align: center;
}
.empty-art {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 88px; height: 88px;
  border-radius: 50%;
  background: var(--bg-content);
  border: 1px dashed var(--border-strong);
  color: var(--text-3);
  margin-bottom: var(--sp-1);
}
.empty-title { font-size: var(--fs-card); font-weight: 600; color: var(--text-1); }
.empty-desc { font-size: var(--fs-table); color: var(--text-2); max-width: 40ch; }
.empty .btn { margin-top: var(--sp-1); }

.skeleton {
  border-radius: 4px;
  background: linear-gradient(90deg, var(--bg-sunken) 25%, #E8EEF5 37%, var(--bg-sunken) 63%);
  background-size: 400% 100%;
  animation: od-skeleton 1.2s ease-in-out infinite;
}
@keyframes od-skeleton {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}
.skeleton-row { display: flex; align-items: center; gap: var(--sp-3); padding: var(--sp-2) var(--sp-3); }
.skeleton-line { height: 12px; }

/* ==========================================================================
   共用组件 · 模态框
   ========================================================================== */

.modal-scrim {
  position: fixed;
  inset: 0;
  z-index: var(--z-modal);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 8vh var(--sp-4) var(--sp-4);
  background: rgba(15, 23, 42, .45);
  overflow-y: auto;
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur-base) var(--ease-out), visibility var(--dur-base);
}
.modal-scrim.is-open { opacity: 1; visibility: visible; }

.modal {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border-radius: var(--r-modal);
  box-shadow: var(--sh-pop);
  transform: translateY(-8px) scale(.99);
  transition: transform var(--dur-base) var(--ease-out);
}
.modal-scrim.is-open .modal { transform: none; }
.modal-sm { max-width: 420px; }

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--sp-3);
  padding: var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.modal-title { font-size: var(--fs-h2); font-weight: 600; line-height: var(--lh-title); }
.modal-close {
  display: flex; align-items: center; justify-content: center;
  width: 30px; height: 30px;
  border-radius: var(--r-control);
  color: var(--text-2);
  transition: background-color var(--dur-micro) var(--ease-out), color var(--dur-micro) var(--ease-out);
}
.modal-close:hover { background: var(--bg-sunken); color: var(--text-1); }

.modal-body { padding: var(--sp-4); display: grid; gap: var(--sp-3); }
.modal-foot {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: var(--sp-2);
  padding: var(--sp-3) var(--sp-4);
  border-top: 1px solid var(--border);
}
.modal-note {
  padding: var(--sp-3);
  border-radius: var(--r-card);
  background: var(--warning-soft);
  color: #92400E;
  font-size: var(--fs-table);
  line-height: 1.6;
}
.modal-note.is-danger { background: var(--danger-soft); color: #B91C1C; }

/* ==========================================================================
   共用组件 · Toast
   ========================================================================== */

.toast-stack {
  position: fixed;
  top: var(--sp-4);
  right: var(--sp-4);
  z-index: var(--z-toast);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
  pointer-events: none;
}
.toast {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 180px;
  padding: 10px var(--sp-3);
  border-radius: var(--r-card);
  background: var(--surface);
  border: 1px solid var(--border);
  box-shadow: var(--sh-pop);
  font-size: var(--fs-body);
  color: var(--text-1);
  animation: od-toast-in var(--dur-base) var(--ease-out);
}
.toast.is-out { animation: od-toast-out var(--dur-exit) var(--ease-in) forwards; }
.toast-icon { display: flex; color: var(--success); }
.toast.is-error .toast-icon { color: var(--danger); }
@keyframes od-toast-in {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: none; }
}
@keyframes od-toast-out {
  to { opacity: 0; transform: translateY(-6px); }
}

/* ==========================================================================
   共用组件 · 面包屑 / 页头
   ========================================================================== */

.breadcrumb {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  font-size: var(--fs-table);
  color: var(--text-2);
}
.breadcrumb a { transition: color var(--dur-micro) var(--ease-out); }
.breadcrumb a:hover { color: var(--brand-text); }
.breadcrumb .sep { color: var(--text-3); }
.breadcrumb .current { color: var(--text-1); }

.page-head { display: grid; gap: var(--sp-1); }
.page-title { font-size: var(--fs-h1); font-weight: 600; line-height: var(--lh-title); }
.page-desc { font-size: var(--fs-table); color: var(--text-2); }

/* ==========================================================================
   共用 · 头像 / 下拉菜单
   ========================================================================== */

.avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--brand-soft);
  color: var(--brand-text);
  font-size: var(--fs-table);
  font-weight: 600;
  line-height: 1;
  user-select: none;
}

.menu {
  position: absolute;
  z-index: var(--z-drawer);
  min-width: 168px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--r-card);
  box-shadow: var(--sh-pop);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-4px);
  transition: opacity var(--dur-micro) var(--ease-out),
              transform var(--dur-micro) var(--ease-out),
              visibility var(--dur-micro);
}
.menu.is-open { opacity: 1; visibility: visible; transform: none; }
.menu-item {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  border-radius: var(--r-control);
  font-size: var(--fs-table);
  color: var(--text-1);
  text-align: left;
  transition: background-color var(--dur-micro) var(--ease-out);
}
.menu-item:hover { background: var(--bg-content); }
.menu-item.is-danger { color: var(--danger); }
.menu-sep { height: 1px; margin: 4px 0; background: var(--border); }

/* ==========================================================================
   动效降级
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: .01ms !important;
    scroll-behavior: auto !important;
  }
}
