/* ============================================================================
   AI Work · Design System  __design.css
   单一真源：所有页面（首页 / 登录 / 控制台 / 注入的旧页）都从这里取令牌与组件。
   明暗由 <html class="dark"> 切换。
   ========================================================================= */

:root {
  /* ---- 画布与表面 ---- */
  --canvas:      #f5f7fc;
  --surface:     #ffffff;
  --surface-2:   #f7f9fd;
  --surface-3:   #eef2f9;

  /* ---- 描边 ---- */
  --line:        rgba(16, 24, 40, .075);
  --line-2:      rgba(16, 24, 40, .14);

  /* ---- 文字 ---- */
  --text:        #0d1424;
  --text-2:      #475467;
  --text-3:      #8a94a6;

  /* ---- 品牌 ---- */
  --brand:       #5b5bf0;
  --brand-2:     #8b5cf6;
  --brand-3:     #22d3ee;
  --grad:        linear-gradient(135deg, #5b5bf0 0%, #8b5cf6 52%, #a855f7 100%);
  --grad-soft:   linear-gradient(135deg, rgba(91, 91, 240, .10), rgba(168, 85, 247, .07));

  /* ---- 语义色 ---- */
  --ok:          #12b76a;
  --ok-bg:       rgba(18, 183, 106, .10);
  --warn:        #f79009;
  --warn-bg:     rgba(247, 144, 9, .12);
  --danger:      #f04438;
  --danger-bg:   rgba(240, 68, 56, .10);

  /* ---- 阴影 ---- */
  --shadow-xs:   0 1px 2px rgba(16, 24, 40, .05);
  --shadow-sm:   0 1px 3px rgba(16, 24, 40, .07), 0 1px 2px rgba(16, 24, 40, .04);
  --shadow:      0 4px 8px -2px rgba(16, 24, 40, .07), 0 12px 28px -6px rgba(16, 24, 40, .10);
  --shadow-lg:   0 12px 24px -6px rgba(16, 24, 40, .10), 0 28px 60px -12px rgba(16, 24, 40, .16);
  --ring:        0 0 0 3px rgba(91, 91, 240, .18);

  /* ---- 圆角 ---- */
  --radius:      16px;
  --radius-sm:   10px;
  --r:           16px;
  --r-sm:        10px;

  /* ---- 字体 ---- */
  /* 拉丁/数字用 Plus Jakarta Sans，中文用 Noto Sans SC（均自托管） */
  --font: "Plus Jakarta Sans", "Noto Sans SC", -apple-system, BlinkMacSystemFont,
          "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei",
          system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "JetBrains Mono", Menlo, Consolas, monospace;

  color-scheme: light;
}

html.dark {
  --canvas:      #080c15;
  --surface:     #0f1523;
  --surface-2:   #141c2d;
  --surface-3:   #1b2438;
  --line:        rgba(255, 255, 255, .075);
  --line-2:      rgba(255, 255, 255, .14);
  --text:        #eef2f9;
  --text-2:      #98a2b3;
  --text-3:      #6b7688;
  --brand:       #818cf8;
  --brand-2:     #a78bfa;
  --grad:        linear-gradient(135deg, #6366f1 0%, #a855f7 55%, #ec4899 100%);
  --grad-soft:   linear-gradient(135deg, rgba(99, 102, 241, .16), rgba(236, 72, 153, .10));
  --ok:          #34d399;
  --ok-bg:       rgba(52, 211, 153, .12);
  --warn:        #fbbf24;
  --warn-bg:     rgba(251, 191, 36, .12);
  --danger:      #f87171;
  --danger-bg:   rgba(248, 113, 113, .12);
  --shadow-xs:   0 1px 2px rgba(0, 0, 0, .4);
  --shadow-sm:   0 1px 3px rgba(0, 0, 0, .45);
  --shadow:      0 4px 10px -2px rgba(0, 0, 0, .5), 0 14px 32px -8px rgba(0, 0, 0, .55);
  --shadow-lg:   0 16px 40px -8px rgba(0, 0, 0, .6);
  --ring:        0 0 0 3px rgba(129, 140, 248, .24);
  color-scheme: dark;
}

/* ============================ 基础 ============================ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { background: var(--canvas); }

body {
  font-family: var(--font);
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  background: var(--canvas);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-feature-settings: "cv11" 1, "ss01" 1;
  /* 防「穿模」：所有文字容器允许换行，不撑破父框 */
  overflow-wrap: anywhere;
  word-break: normal;
}

/* 极光背景：直接铺在 body 上，不用 fixed 图层（滚动时整页重绘会卡） */
body {
  background-image:
    radial-gradient(42% 34% at 6% -4%, rgba(91, 91, 240, .11), transparent 62%),
    radial-gradient(36% 30% at 98% 0%, rgba(168, 85, 247, .09), transparent 62%);
  background-repeat: no-repeat;
}
html.dark body {
  background-image:
    radial-gradient(42% 34% at 6% -4%, rgba(99, 102, 241, .20), transparent 62%),
    radial-gradient(36% 30% at 98% 0%, rgba(236, 72, 153, .13), transparent 62%);
}

h1, h2, h3, h4 {
  font-family: var(--font);
  line-height: 1.32;
  letter-spacing: -.022em;
  font-weight: 700;
  color: var(--text);
}
h1 { font-size: 1.5em; }
h2 { font-size: 1.12em; }
h3 { font-size: 1em; font-weight: 650; }

a { color: inherit; text-decoration: none; }

code, kbd, pre, .mono, .font-mono {
  font-family: var(--mono);
}
code:not(pre code) {
  background: var(--surface-3);
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: .08em .4em;
  font-size: .9em;
  color: var(--text-2);
}

::selection { background: rgba(139, 92, 246, .26); }
html.dark ::selection { background: rgba(167, 139, 250, .32); color: #fff; }

::-webkit-scrollbar { width: 9px; height: 9px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: var(--line-2); border-radius: 99px;
  border: 2px solid transparent; background-clip: content-box;
}
::-webkit-scrollbar-thumb:hover { background: var(--text-3); background-clip: content-box; }

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

/* ============================ 按钮 ============================ */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 16px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line-2);
  background: var(--surface);
  color: var(--text-2);
  font-family: var(--font);
  font-size: 13.5px; font-weight: 600; line-height: 1.25;
  cursor: pointer; white-space: nowrap;
  box-shadow: var(--shadow-xs);
  transition: transform .12s cubic-bezier(.2,.8,.3,1), box-shadow .16s,
              background-color .14s, color .14s, border-color .14s, filter .16s;
}
.btn:hover {
  color: var(--text); background: var(--surface-2);
  box-shadow: var(--shadow-sm); transform: translateY(-1px);
}
.btn:active { transform: scale(.975); }
.btn svg { width: 15px; height: 15px; flex: none; }

.btn-primary {
  border: 0; color: #fff !important;
  background-image: var(--grad);
  box-shadow: 0 2px 8px rgba(91, 91, 240, .28), inset 0 1px 0 rgba(255, 255, 255, .18);
}
.btn-primary:hover {
  filter: brightness(1.07);
  box-shadow: 0 8px 20px rgba(91, 91, 240, .38), inset 0 1px 0 rgba(255, 255, 255, .22);
}
.btn-ghost { border-color: transparent; background: transparent; box-shadow: none; }
.btn-ghost:hover { background: var(--surface-2); box-shadow: none; }
.btn-sm { height: 31px; padding: 0 11px; font-size: 12.5px; border-radius: 8px; }
.btn-sm svg { width: 13px; height: 13px; }
.btn-lg { height: 46px; padding: 0 24px; font-size: 15px; border-radius: 12px; }
.btn-icon { width: 38px; padding: 0; }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; filter: saturate(.5); }

/* ============================ 卡片 ============================ */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xs);
  transition: box-shadow .2s, border-color .2s, transform .2s cubic-bezier(.2,.8,.3,1);
}
.card-pad { padding: 22px; }
.card-hover:hover { box-shadow: var(--shadow); border-color: var(--line-2); transform: translateY(-2px); }

/* ============================ 徽章 ============================ */
.pill {
  display: inline-flex; align-items: center; gap: 6px;
  height: 23px; padding: 0 9px; border-radius: 99px;
  font-size: 11.5px; font-weight: 650; letter-spacing: .01em;
  background: var(--surface-3); color: var(--text-2);
  white-space: nowrap;
}
.pill i { width: 6px; height: 6px; border-radius: 50%; background: currentColor; flex: none; }
.pill.ok { background: var(--ok-bg); color: var(--ok); }
.pill.warn { background: var(--warn-bg); color: var(--warn); }
.pill.bad { background: var(--danger-bg); color: var(--danger); }
.pill.brand { background: var(--grad-soft); color: var(--brand); }

/* ============================ 表格 ============================ */
.tbl { width: 100%; border-collapse: separate; border-spacing: 0; font-size: 13.5px; table-layout: auto; }
.tbl th {
  text-align: left; font-size: 11.5px; font-weight: 650; letter-spacing: .05em;
  text-transform: uppercase; color: var(--text-3);
  padding: 11px 14px; border-bottom: 1px solid var(--line); white-space: nowrap;
}
.tbl td {
  padding: 12px 14px; border-bottom: 1px solid var(--line);
  color: var(--text-2); vertical-align: middle;
  /* 长内容截断，不撑破布局 */
  max-width: 320px; overflow: hidden; text-overflow: ellipsis;
}
.tbl td.wrap { white-space: normal; overflow-wrap: anywhere; max-width: 420px; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl tbody tr { transition: background-color .13s; }
.tbl tbody tr:hover { background: var(--surface-2); }
.tbl .strong { color: var(--text); font-weight: 600; }
.num { font-variant-numeric: tabular-nums; }

/* ============================ 输入 ============================ */
.input, .select, textarea.input {
  height: 38px; padding: 0 12px; width: 100%;
  border: 1px solid var(--line-2); border-radius: var(--radius-sm);
  background: var(--surface); color: var(--text);
  font-family: var(--font); font-size: 13.5px; line-height: 1.3;
  box-shadow: var(--shadow-xs); outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:focus, .select:focus { border-color: var(--brand); box-shadow: var(--ring); }
.input::placeholder { color: var(--text-3); }
.field { margin-bottom: 14px; }
.field label {
  display: block; font-size: 12.5px; font-weight: 600;
  color: var(--text-2); margin-bottom: 7px;
}
.hint { font-size: 11.5px; color: var(--text-3); margin-top: 6px; line-height: 1.5; }

/* ============================ 空状态 ============================ */
.empty { text-align: center; padding: 52px 24px; }
.empty-ico {
  width: 54px; height: 54px; border-radius: 16px; margin: 0 auto 18px;
  display: grid; place-items: center;
  background: var(--grad-soft); border: 1px solid var(--line);
}
.empty-ico svg { width: 24px; height: 24px; stroke: var(--brand); fill: none; stroke-width: 1.7; stroke-linecap: round; stroke-linejoin: round; }
.empty h3 { font-size: 15px; font-weight: 650; margin-bottom: 7px; }
.empty p { font-size: 13px; color: var(--text-3); max-width: 360px; margin: 0 auto 20px; line-height: 1.65; }

/* ============================ 布局助手 ============================ */
.grid { display: grid; gap: 16px; }
.g4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.g3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.g2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
@media (max-width: 1100px) { .g4 { grid-template-columns: repeat(2, minmax(0, 1fr)); } .g3 { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 720px) { .g4, .g3, .g2 { grid-template-columns: minmax(0, 1fr); } }

.sec { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin: 0 0 14px; flex-wrap: wrap; }
.sec h2 { font-size: 14.5px; font-weight: 700; letter-spacing: -.015em; }
.sec p { font-size: 12.5px; color: var(--text-3); margin-top: 2px; }
.mt { margin-top: 22px; }

/* Toast */
#toasts { position: fixed; right: 20px; bottom: 20px; z-index: 9999; display: flex; flex-direction: column; gap: 9px; }
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 16px; border-radius: 12px; min-width: 220px; max-width: 380px;
  background: var(--surface); border: 1px solid var(--line-2);
  box-shadow: var(--shadow-lg); font-size: 13.5px; color: var(--text);
  overflow-wrap: anywhere;
  animation: tin .24s cubic-bezier(.2,.8,.3,1);
}
.toast.ok { border-color: rgba(18, 183, 106, .4); }
.toast.bad { border-color: rgba(240, 68, 56, .4); }
@keyframes tin { from { opacity: 0; transform: translateY(10px) scale(.97); } to { opacity: 1; transform: none; } }

/* 主题切换按钮（首页 / 登录 / 控制台通用） */
.theme-btn {
  width: 38px; height: 38px; border-radius: var(--radius-sm); flex: none;
  display: grid; place-items: center; cursor: pointer;
  border: 1px solid var(--line-2); background: var(--surface); color: var(--text-2);
  box-shadow: var(--shadow-xs);
  transition: transform .16s, box-shadow .16s, color .14s;
}
.theme-btn:hover { transform: translateY(-1px); box-shadow: var(--shadow-sm); color: var(--text); }
.theme-btn svg { width: 17px; height: 17px; stroke: currentColor; fill: none; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.theme-btn .sun { display: none; }
html.dark .theme-btn .sun { display: block; }
html.dark .theme-btn .moon { display: none; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; }
}
