/* ============================================================
   小工具站 · 样式（工具箱风格，自成一套）
   ------------------------------------------------------------
   跟班主任工作平台**故意不是同一套视觉**：那边是政务感的浅蓝，
   这边是更现代的工具箱——大圆角、留白多、一个靛蓝主色。
   两边的 CSS 变量名也不一样（这里统一 tb- 前缀），互不干扰。

   画一个页面需要的东西（按顺序往下读）：
     ① 变量与底色
     ② 基础排版
     ③ 顶栏
     ④ 首页：工具卡片网格
     ⑤ 通用零件：按钮 / 输入 / 卡片 / 标签 / 开关 / 提示
     ⑥ 登录页、加载态、空态、手机适配

   ★ 2026-10-02：**深色模式已整体移除**（用户要求）。原来那套
     `[data-theme="dark"]` 变量、顶栏的切换按钮、localStorage 里的 tools_theme、
     以及后端只为它存在的 `/api/prefs` 接口，全都清掉了 —— 不留死代码。
     哪天要做回去：变量块加在 ① 后面，顶栏按钮和 shell.js 里的 Theme 照当年那样写。

   ★ 加新工具时**不需要碰这个文件**：用下面的零件（tb-card / tb-field /
     tb-btn…）就能拼出一个像样的工具页。要加自己专属的样式，写在自己的
     目录里，别往这里塞。
   ============================================================ */

/* ---------- ① 变量 ---------- */

:root {
    --tb-bg: #f3f4f7;
    --tb-bg-soft: #ffffff;
    --tb-surface: #ffffff;
    --tb-surface-2: #f8f9fb;
    --tb-line: rgba(17, 22, 30, .10);
    --tb-line-strong: rgba(17, 22, 30, .18);
    --tb-text: #12161c;
    --tb-text-2: #5a6472;
    --tb-text-3: #8b95a4;
    --tb-accent: #4f46e5;
    --tb-accent-hover: #4338ca;
    --tb-accent-soft: rgba(79, 70, 229, .10);
    --tb-accent-fg: #ffffff;
    --tb-ok: #0f7a55;
    --tb-ok-soft: rgba(15, 122, 85, .10);
    --tb-warn: #a16207;
    --tb-warn-soft: rgba(161, 98, 7, .12);
    --tb-danger: #c53434;
    --tb-danger-soft: rgba(197, 52, 52, .10);
    --tb-r: 10px;
    --tb-r-lg: 16px;
    --tb-shadow: 0 1px 2px rgba(17, 22, 30, .05);
    --tb-shadow-lg: 0 12px 32px -12px rgba(17, 22, 30, .22);
    --tb-max: 1180px;
    --tb-topbar-h: 60px;
    --tb-font: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Source Han Sans SC", sans-serif;
    --tb-mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* ---------- ② 基础排版 ---------- */

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
    margin: 0;
    background: var(--tb-bg);
    color: var(--tb-text);
    font-family: var(--tb-font);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

a { color: var(--tb-accent); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 16px; }
h3 { font-size: 14px; }

p { margin: 0; }

[hidden] { display: none !important; }

.tb-shell { min-height: 100%; display: flex; flex-direction: column; }

.tb-wrap {
    width: 100%;
    max-width: var(--tb-max);
    margin: 0 auto;
    padding: 0 24px;
}

/* ---------- ③ 顶栏 ---------- */

.tb-topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: color-mix(in srgb, var(--tb-bg-soft) 88%, transparent);
    backdrop-filter: saturate(180%) blur(12px);
    border-bottom: 1px solid var(--tb-line);
}

.tb-topbar__in {
    height: var(--tb-topbar-h);
    display: flex;
    align-items: center;
    gap: 14px;
}

.tb-brand {
    display: flex;
    align-items: center;
    gap: 9px;
    color: var(--tb-text);
    font-weight: 600;
    font-size: 15px;
    white-space: nowrap;
}
.tb-brand:hover { text-decoration: none; }

.tb-brand svg { display: block; }

.tb-brand__mark {
    width: 30px; height: 30px;
    border-radius: 9px;
    /* 2026-10-06：★ 用户要求跟站点图标统一 —— 底色换成**同一个靛蓝渐变**
       （#8B9CFF → #6366F1，与 public/img/logo.svg 同源，见 tools/gen-icons.py）。
       这跟 2026-10-04 试过又被否掉的那版**不是一回事**：那版是「浅靛蓝底 + 深靛蓝图」
       （浅底深图，看着发灰）；这版**白图形不动**，只把底色换成渐变，方向正好相反。
       色值必须与图标一致 —— smoke 有断言盯着，别只改一边。 */
    background: linear-gradient(180deg, #8B9CFF 0%, #6366F1 100%);
    color: var(--tb-accent-fg);
    display: flex; align-items: center; justify-content: center;
    flex: none;
}

.tb-brand__sub {
    font-size: 12px;
    font-weight: 400;
    color: var(--tb-text-3);
    padding-left: 10px;
    border-left: 1px solid var(--tb-line-strong);
}

.tb-topbar__spacer { flex: 1; }

.tb-back {
    display: inline-flex; align-items: center; gap: 6px;
    font-size: 13px; color: var(--tb-text-2);
    padding: 6px 10px 6px 8px;
    border-radius: 999px;
    border: 1px solid transparent;
}
.tb-back:hover {
    text-decoration: none;
    color: var(--tb-text);
    background: var(--tb-surface);
    border-color: var(--tb-line);
}

.tb-userchip {
    display: flex; align-items: center; gap: 8px;
    font-size: 13px; color: var(--tb-text-2);
    white-space: nowrap;
}

.tb-avatar {
    width: 26px; height: 26px; border-radius: 50%;
    background: var(--tb-accent-soft);
    color: var(--tb-accent);
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 600;
    flex: none;
}

.tb-iconbtn {
    width: 32px; height: 32px;
    border: 1px solid var(--tb-line);
    background: var(--tb-surface);
    color: var(--tb-text-2);
    border-radius: 9px;
    display: inline-flex; align-items: center; justify-content: center;
    cursor: pointer; padding: 0;
    font-family: inherit;
}
.tb-iconbtn:hover { color: var(--tb-text); border-color: var(--tb-line-strong); }

/* 顶栏里的搜索框 */
.tb-search { position: relative; width: 220px; max-width: 38vw; }
.tb-search input {
    width: 100%;
    height: 34px;
    padding: 0 12px 0 32px;
    border-radius: 999px;
    border: 1px solid var(--tb-line);
    background: var(--tb-surface);
    color: var(--tb-text);
    font: inherit; font-size: 13px;
    outline: none;
}
.tb-search input:focus { border-color: var(--tb-accent); box-shadow: 0 0 0 3px var(--tb-accent-soft); }
.tb-search svg {
    position: absolute; left: 10px; top: 50%; transform: translateY(-50%);
    color: var(--tb-text-3); pointer-events: none;
}

/* ---------- ④ 首页 ---------- */

.tb-main { flex: 1; padding: 28px 0 56px; }

.tb-section + .tb-section { margin-top: 28px; }

.tb-section__head {
    display: flex; align-items: baseline; gap: 10px;
    margin-bottom: 12px;
}
.tb-section__head h2 { font-size: 15px; }
.tb-section__head span { font-size: 12px; color: var(--tb-text-3); }

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

.tb-toolcard {
    display: block;
    background: var(--tb-surface);
    border: 1px solid var(--tb-line);
    border-radius: var(--tb-r-lg);
    padding: 16px;
    color: inherit;
    box-shadow: var(--tb-shadow);
    transition: transform .14s ease, box-shadow .14s ease, border-color .14s ease;
}
.tb-toolcard:hover {
    text-decoration: none;
    transform: translateY(-2px);
    border-color: var(--tb-line-strong);
    box-shadow: var(--tb-shadow-lg);
}

.tb-toolcard__top { display: flex; align-items: center; gap: 11px; margin-bottom: 9px; }

.tb-toolicon {
    width: 38px; height: 38px;
    border-radius: 11px;
    display: flex; align-items: center; justify-content: center;
    flex: none;
    color: var(--tb-icon-fg, var(--tb-accent));
    background: var(--tb-icon-bg, var(--tb-accent-soft));
}

.tb-toolcard__name { font-size: 14px; font-weight: 600; }
.tb-toolcard__desc { font-size: 13px; color: var(--tb-text-2); line-height: 1.65; }

.tb-toolcard__tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 11px; }

.tb-tag {
    font-size: 12px; line-height: 1;
    padding: 4px 8px;
    border-radius: 999px;
    background: var(--tb-surface-2);
    color: var(--tb-text-2);
    border: 1px solid var(--tb-line);
}

/* ---------- ⑤ 通用零件 ---------- */

.tb-card {
    background: var(--tb-surface);
    border: 1px solid var(--tb-line);
    border-radius: var(--tb-r-lg);
    padding: 20px;
    box-shadow: var(--tb-shadow);
}

.tb-card__head {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 16px;
}
.tb-card__head h2 { font-size: 15px; }
.tb-card__head .tb-topbar__spacer { flex: 1; }

.tb-hint { font-size: 12px; color: var(--tb-text-3); line-height: 1.7; }

.tb-row { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }

.tb-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 7px;
    height: 36px; padding: 0 15px;
    border-radius: var(--tb-r);
    border: 1px solid var(--tb-line-strong);
    background: var(--tb-surface);
    color: var(--tb-text);
    font: inherit; font-size: 13px; font-weight: 500;
    cursor: pointer;
    white-space: nowrap;
}
.tb-btn:hover { border-color: var(--tb-text-3); }
.tb-btn:disabled { opacity: .5; cursor: not-allowed; }

.tb-btn--primary {
    background: var(--tb-accent);
    border-color: var(--tb-accent);
    color: var(--tb-accent-fg);
}
.tb-btn--primary:hover { background: var(--tb-accent-hover); border-color: var(--tb-accent-hover); }

.tb-btn--ghost { background: transparent; border-color: transparent; color: var(--tb-text-2); }
.tb-btn--ghost:hover { background: var(--tb-surface); border-color: var(--tb-line); color: var(--tb-text); }

.tb-btn--danger { color: var(--tb-danger); border-color: var(--tb-line); }
.tb-btn--danger:hover { background: var(--tb-danger-soft); border-color: var(--tb-danger); }

.tb-btn--sm { height: 30px; padding: 0 11px; font-size: 12px; }
.tb-btn--block { width: 100%; }

.tb-field { margin-bottom: 15px; }
.tb-label {
    display: block;
    font-size: 12px; font-weight: 500; color: var(--tb-text-2);
    margin-bottom: 6px;
}

.tb-input, .tb-select, .tb-textarea {
    width: 100%;
    min-height: 36px;
    padding: 7px 11px;
    border-radius: var(--tb-r);
    border: 1px solid var(--tb-line-strong);
    background: var(--tb-bg-soft);
    color: var(--tb-text);
    font: inherit; font-size: 13px;
    outline: none;
}
.tb-input:focus, .tb-select:focus, .tb-textarea:focus {
    border-color: var(--tb-accent);
    box-shadow: 0 0 0 3px var(--tb-accent-soft);
}
.tb-textarea { min-height: 120px; resize: vertical; line-height: 1.6; }

/* 开关 */
.tb-switch { display: inline-flex; align-items: center; gap: 9px; cursor: pointer; font-size: 13px; }
.tb-switch input { position: absolute; opacity: 0; width: 0; height: 0; }
.tb-switch__track {
    width: 38px; height: 22px; border-radius: 999px;
    background: var(--tb-line-strong);
    position: relative; flex: none;
    transition: background .15s ease;
}
.tb-switch__track::after {
    content: ""; position: absolute; top: 3px; left: 3px;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff;
    transition: transform .15s ease;
}
.tb-switch input:checked + .tb-switch__track { background: var(--tb-accent); }
.tb-switch input:checked + .tb-switch__track::after { transform: translateX(16px); }

.tb-note {
    display: flex; gap: 9px;
    padding: 11px 13px;
    border-radius: var(--tb-r);
    font-size: 12px; line-height: 1.7;
    background: var(--tb-accent-soft);
    color: var(--tb-text-2);
}
.tb-note--warn { background: var(--tb-warn-soft); color: var(--tb-warn); }
.tb-note--ok { background: var(--tb-ok-soft); color: var(--tb-ok); }
.tb-note--danger { background: var(--tb-danger-soft); color: var(--tb-danger); }

.tb-code {
    font-family: var(--tb-mono);
    font-size: 12px; line-height: 1.7;
    background: var(--tb-surface-2);
    border: 1px solid var(--tb-line);
    border-radius: var(--tb-r);
    padding: 12px 14px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.tb-kv { display: grid; grid-template-columns: minmax(90px, auto) 1fr; gap: 6px 14px; font-size: 13px; }
.tb-kv dt { color: var(--tb-text-3); }
.tb-kv dd { margin: 0; }

/* ---------- ⑥ 登录页 / 加载 / 空态 ---------- */

.tb-login {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 24px;
}
.tb-login__card {
    width: 100%; max-width: 380px;
    background: var(--tb-surface);
    border: 1px solid var(--tb-line);
    border-radius: 20px;
    padding: 30px 28px;
    box-shadow: var(--tb-shadow-lg);
}
.tb-login__brand {
    display: flex; align-items: center; gap: 10px;
    margin-bottom: 6px;
}
.tb-login__title { font-size: 18px; font-weight: 600; }
.tb-login__sub { font-size: 13px; color: var(--tb-text-2); margin-bottom: 22px; line-height: 1.7; }
.tb-login__foot { margin-top: 18px; }

.tb-boot {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    color: var(--tb-text-3); font-size: 13px; gap: 10px;
}

.tb-spin {
    width: 16px; height: 16px; flex: none;
    border: 2px solid var(--tb-line-strong);
    border-top-color: var(--tb-accent);
    border-radius: 50%;
    animation: tb-spin .7s linear infinite;
}
@keyframes tb-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .tb-spin { animation-duration: 2s; } }

.tb-empty {
    text-align: center;
    padding: 54px 20px;
    color: var(--tb-text-3);
    font-size: 13px;
}
.tb-empty svg { margin-bottom: 12px; opacity: .5; }

/* 提示条（右下角） */
.tb-toasts {
    position: fixed; right: 18px; bottom: 18px;
    display: flex; flex-direction: column; gap: 8px;
    z-index: 60; pointer-events: none;
}
.tb-toast {
    background: var(--tb-text);
    color: var(--tb-bg-soft);
    font-size: 13px;
    padding: 9px 14px;
    border-radius: var(--tb-r);
    box-shadow: var(--tb-shadow-lg);
    max-width: 320px;
    animation: tb-in .18s ease;
}
.tb-toast--err { background: var(--tb-danger); color: #fff; }
.tb-toast--ok { background: var(--tb-ok); color: #fff; }
@keyframes tb-in { from { opacity: 0; transform: translateY(6px); } }

/* 工具页的内容区 */
.tb-toolhead { margin-bottom: 18px; }
.tb-toolhead h1 { font-size: 19px; }
.tb-toolhead p { font-size: 13px; color: var(--tb-text-2); margin-top: 5px; }

.tb-split { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }

/* ---------- 手机适配 ---------- */

@media (max-width: 720px) {
    .tb-wrap { padding: 0 14px; }
    .tb-main { padding: 18px 0 40px; }
    .tb-grid { grid-template-columns: 1fr; gap: 11px; }
    .tb-split { grid-template-columns: 1fr; }
    .tb-brand__sub { display: none; }
    .tb-search { width: 100%; max-width: none; }
    .tb-userchip__name { display: none; }
    .tb-login__card { padding: 24px 20px; }
    .tb-card { padding: 16px; }
    /* 顶栏在手机上两行：第一行品牌+用户，第二行搜索 */
    .tb-topbar__in { height: auto; flex-wrap: wrap; padding: 10px 0; row-gap: 10px; }
    .tb-topbar__spacer { flex: 1 1 auto; }
    .tb-search { order: 3; flex: 1 1 100%; }
}
