/* ==========================================================================
   工具页共享基座（tool base）
   —— 只负责「结构性」样式：面包屑、卡片、表单、按钮、表格、标签页、提示、
      弹窗、打印骨架。
   —— 视觉主题（配色 / 字体 / 装饰）由每个工具自己的 CSS 通过覆写
      .tk-page 上的 --tk-* 变量实现，避免 6 个工具长得一模一样。
   深色模式由导航栏的 #themeToggle 控制，写在 <html data-theme="dark"> 上。
   ========================================================================== */

.tk-page {
    /* —— 主题变量（各工具覆写）—— */
    --tk-bg: #f5f7fb;
    --tk-card: #ffffff;
    --tk-card2: #fafbfe;
    --tk-ink: #131a2c;
    --tk-ink2: #4c566b;
    --tk-ink3: #8b94a7;
    --tk-line: #e4e8f0;
    --tk-line2: #eef1f6;
    --tk-accent: #2563eb;
    --tk-accent2: #1d4ed8;
    --tk-accent-soft: #e9effd;
    --tk-ok: #0e9f6e;
    --tk-ok-soft: #e5f6ef;
    --tk-warn: #c2760a;
    --tk-warn-soft: #fdf2df;
    --tk-danger: #d92d20;
    --tk-danger-soft: #fdeceb;
    --tk-radius: 16px;
    --tk-radius-s: 10px;
    --tk-shadow: 0 18px 44px -30px rgba(19, 26, 44, .5);
    --tk-shadow-s: 0 8px 20px -14px rgba(19, 26, 44, .45);
    --tk-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    --tk-serif: Georgia, "Songti SC", "Noto Serif SC", "SimSun", serif;
    --tk-mono: "SFMono-Regular", "Cascadia Mono", Consolas, "Courier New", monospace;

    position: relative;
    padding: 20px 0 60px;
    color: var(--tk-ink);
    font-family: var(--tk-sans);
    font-size: 15px;
    line-height: 1.78;
    -webkit-font-smoothing: antialiased;
    background: var(--tk-bg);
}

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

.tk-inner { max-width: 1240px; margin: 0 auto; padding: 0 24px; }

/* ---------------- 面包屑 ---------------- */
.tk-crumb {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin: 2px 0 16px;
    font-size: 13px;
    color: var(--tk-ink3);
}
.tk-crumb a {
    color: var(--tk-ink2);
    text-decoration: none;
    padding: 2px 8px;
    border-radius: 7px;
    transition: background .16s, color .16s;
}
.tk-crumb a:hover { color: var(--tk-accent); background: var(--tk-accent-soft); }
.tk-crumb .sep { color: var(--tk-line); }
.tk-crumb .cur {
    color: var(--tk-accent);
    font-weight: 700;
    padding: 2px 9px;
    background: var(--tk-accent-soft);
    border-radius: 7px;
}

/* ---------------- 卡片 ---------------- */
.tk-card {
    background: var(--tk-card);
    border: 1px solid var(--tk-line);
    border-radius: var(--tk-radius);
    box-shadow: var(--tk-shadow-s);
    padding: 22px 24px;
}
.tk-card + .tk-card { margin-top: 18px; }
.tk-card--flat { box-shadow: none; background: var(--tk-card2); }

.tk-card-title {
    display: flex;
    align-items: baseline;
    flex-wrap: wrap;
    gap: 10px;
    margin: 0 0 16px;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: -.01em;
    color: var(--tk-ink);
}
.tk-card-title small {
    font-size: 12.5px;
    font-weight: 600;
    color: var(--tk-ink3);
    letter-spacing: 0;
}
.tk-num {
    display: inline-grid;
    place-items: center;
    width: 24px;
    height: 24px;
    border-radius: 8px;
    background: var(--tk-accent);
    color: #fff;
    font-size: 13px;
    font-weight: 800;
    flex: none;
}

/* ---------------- 栅格 ---------------- */
.tk-grid { display: grid; gap: 18px; }
.tk-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.tk-grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.tk-grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.tk-grid-5 { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.tk-col { display: grid; gap: 18px; align-content: start; }

/* ---------------- 表单 ---------------- */
.tk-field { margin-bottom: 14px; }
.tk-field > label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 700;
    color: var(--tk-ink2);
}
.tk-field > label em {
    font-style: normal;
    color: var(--tk-ink3);
    font-weight: 500;
    margin-left: 4px;
}
.tk-input,
.tk-select,
.tk-textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--tk-line);
    border-radius: var(--tk-radius-s);
    background: var(--tk-card);
    color: var(--tk-ink);
    font-family: inherit;
    font-size: 14.5px;
    line-height: 1.6;
    transition: border-color .16s, box-shadow .16s;
    -webkit-appearance: none;
    appearance: none;
}
.tk-select {
    padding-right: 32px;
    background-image: linear-gradient(45deg, transparent 50%, var(--tk-ink3) 50%),
        linear-gradient(135deg, var(--tk-ink3) 50%, transparent 50%);
    background-position: calc(100% - 17px) 50%, calc(100% - 12px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
}
.tk-textarea { resize: vertical; min-height: 96px; }
.tk-input:focus,
.tk-select:focus,
.tk-textarea:focus {
    outline: none;
    border-color: var(--tk-accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--tk-accent) 16%, transparent);
}
.tk-input::placeholder, .tk-textarea::placeholder { color: var(--tk-ink3); }
.tk-input[readonly] { background: var(--tk-card2); color: var(--tk-ink2); }
.tk-row { display: flex; gap: 12px; flex-wrap: wrap; }
.tk-row > * { flex: 1 1 160px; min-width: 0; }

.tk-hint {
    margin: 8px 0 0;
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--tk-ink3);
}
.tk-hint code,
.tk-page code {
    font-family: var(--tk-mono);
    font-size: .92em;
    padding: 1px 5px;
    border-radius: 5px;
    background: var(--tk-accent-soft);
    color: var(--tk-accent2);
}
.tk-page b { color: var(--tk-ink); font-weight: 700; }

/* ---------------- 按钮 ---------------- */
.tk-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border-radius: var(--tk-radius-s);
    border: 1px solid transparent;
    background: var(--tk-accent);
    color: #fff;
    font-family: inherit;
    font-size: 14.5px;
    font-weight: 700;
    line-height: 1.4;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
    transition: transform .12s, box-shadow .16s, background .16s, opacity .16s;
}
.tk-btn:hover { background: var(--tk-accent2); box-shadow: 0 10px 22px -14px var(--tk-accent); }
.tk-btn:active { transform: translateY(1px); }
.tk-btn:disabled { opacity: .5; cursor: not-allowed; box-shadow: none; }
.tk-btn--line {
    background: transparent;
    color: var(--tk-ink2);
    border-color: var(--tk-line);
}
.tk-btn--line:hover { background: var(--tk-card2); color: var(--tk-accent); border-color: var(--tk-accent); box-shadow: none; }
.tk-btn--ghost { background: var(--tk-accent-soft); color: var(--tk-accent2); }
.tk-btn--ghost:hover { background: var(--tk-accent); color: #fff; }
.tk-btn--sm { padding: 7px 13px; font-size: 13px; border-radius: 9px; }
.tk-btn--xs { padding: 5px 10px; font-size: 12px; border-radius: 8px; font-weight: 600; }
.tk-btn--danger { background: var(--tk-danger); }
.tk-btn--danger:hover { background: #b42318; }
.tk-btn--wide { width: 100%; }
.tk-btns { display: flex; flex-wrap: wrap; gap: 10px; }

/* ---------------- 徽标 / 标签 ---------------- */
.tk-tag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 700;
    background: var(--tk-accent-soft);
    color: var(--tk-accent2);
    white-space: nowrap;
}
.tk-tag--ok { background: var(--tk-ok-soft); color: var(--tk-ok); }
.tk-tag--warn { background: var(--tk-warn-soft); color: var(--tk-warn); }
.tk-tag--danger { background: var(--tk-danger-soft); color: var(--tk-danger); }
.tk-tag--mute { background: var(--tk-line2); color: var(--tk-ink3); }

/* ---------------- 筛选胶囊 ---------------- */
.tk-pill {
    padding: 4px 12px;
    border-radius: 999px;
    border: 1px solid var(--tk-line);
    background: var(--tk-card2);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--tk-ink2);
    cursor: pointer;
    transition: border-color .16s, color .16s, background .16s;
}
.tk-pill:hover { border-color: var(--tk-accent); color: var(--tk-accent); }
.tk-pill.is-on { background: var(--tk-accent); border-color: var(--tk-accent); color: #fff; }

/* ---------------- 表格 ---------------- */
.tk-table-wrap { overflow-x: auto; border: 1px solid var(--tk-line); border-radius: var(--tk-radius-s); }
.tk-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.tk-table th,
.tk-table td { padding: 10px 12px; text-align: left; border-bottom: 1px solid var(--tk-line2); white-space: nowrap; }
.tk-table th {
    background: var(--tk-card2);
    color: var(--tk-ink2);
    font-weight: 700;
    font-size: 12.5px;
    letter-spacing: .02em;
}
.tk-table tbody tr:last-child td { border-bottom: none; }
.tk-table tbody tr:hover { background: var(--tk-accent-soft); }
.tk-table .num { font-family: var(--tk-mono); font-variant-numeric: tabular-nums; }

/* ---------------- 标签页 ---------------- */
.tk-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin: 30px 0 0;
    padding: 5px;
    background: var(--tk-card);
    border: 1px solid var(--tk-line);
    border-radius: 14px;
    box-shadow: var(--tk-shadow-s);
}
.tk-tab {
    padding: 9px 18px;
    border-radius: 10px;
    background: transparent;
    color: var(--tk-ink2);
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
    transition: background .16s, color .16s;
}
.tk-tab:hover { background: var(--tk-card2); color: var(--tk-accent); }
.tk-tab.is-on { background: var(--tk-accent); color: #fff; }
.tk-panel {
    display: none;
    margin-top: 16px;
    padding: 26px 28px;
    background: var(--tk-card);
    border: 1px solid var(--tk-line);
    border-radius: var(--tk-radius);
    box-shadow: var(--tk-shadow-s);
}
.tk-panel.is-on { display: block; }
.tk-panel > h2 {
    margin: 0 0 12px;
    font-size: 19px;
    font-weight: 800;
    color: var(--tk-ink);
    letter-spacing: -.01em;
}
.tk-panel > h2:not(:first-child) { margin-top: 26px; }
.tk-panel h3 { margin: 20px 0 8px; font-size: 16px; font-weight: 800; color: var(--tk-ink); }
.tk-panel p { margin: 0 0 12px; color: var(--tk-ink2); }
.tk-panel ul, .tk-panel ol { margin: 0 0 14px; padding-left: 22px; color: var(--tk-ink2); }
.tk-panel li { margin-bottom: 6px; }
.tk-panel li::marker { color: var(--tk-accent); }

.tk-steps { counter-reset: tkstep; list-style: none; padding-left: 0; }
.tk-steps > li {
    position: relative;
    padding-left: 40px;
    margin-bottom: 12px;
}
.tk-steps > li::before {
    counter-increment: tkstep;
    content: counter(tkstep);
    position: absolute;
    left: 0;
    top: 2px;
    width: 26px;
    height: 26px;
    display: grid;
    place-items: center;
    border-radius: 9px;
    background: var(--tk-accent-soft);
    color: var(--tk-accent2);
    font-weight: 800;
    font-size: 13px;
}

/* ---------------- FAQ ---------------- */
.tk-faq { display: grid; gap: 10px; }
.tk-faq details {
    border: 1px solid var(--tk-line);
    border-radius: 12px;
    background: var(--tk-card2);
    overflow: hidden;
}
.tk-faq summary {
    padding: 13px 16px;
    cursor: pointer;
    font-weight: 700;
    font-size: 14.5px;
    color: var(--tk-ink);
    list-style: none;
    position: relative;
    padding-right: 38px;
}
.tk-faq summary::-webkit-details-marker { display: none; }
.tk-faq summary::after {
    content: "+";
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    display: grid;
    place-items: center;
    border-radius: 6px;
    background: var(--tk-accent-soft);
    color: var(--tk-accent2);
    font-weight: 800;
}
.tk-faq details[open] summary::after { content: "−"; }
.tk-faq .a { padding: 0 16px 15px; color: var(--tk-ink2); font-size: 14px; }

/* ---------------- 更新记录 ---------------- */
.tk-timeline { list-style: none; padding-left: 0; }
.tk-timeline > li {
    display: grid;
    grid-template-columns: 62px 108px 1fr;
    gap: 12px;
    padding: 11px 0;
    border-bottom: 1px dashed var(--tk-line);
    font-size: 13.5px;
    color: var(--tk-ink2);
}
.tk-timeline > li:last-child { border-bottom: none; }
.tk-timeline .ver {
    font-family: var(--tk-mono);
    font-weight: 700;
    color: var(--tk-accent);
}
.tk-timeline .date { color: var(--tk-ink3); font-family: var(--tk-mono); }

/* ---------------- 相关工具 ---------------- */
.tk-related { margin-top: 26px; }
.tk-related > h2 {
    margin: 0 0 12px;
    font-size: 17px;
    font-weight: 800;
    color: var(--tk-ink);
}
.tk-rel-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
.tk-rel {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 13px 14px;
    border: 1px solid var(--tk-line);
    border-radius: 14px;
    background: var(--tk-card);
    text-decoration: none;
    transition: transform .14s, border-color .16s, box-shadow .16s;
}
.tk-rel:hover {
    transform: translateY(-2px);
    border-color: var(--tk-accent);
    box-shadow: var(--tk-shadow-s);
}
.tk-rel .ri { font-size: 22px; line-height: 1; flex: none; }
.tk-rel span:last-child { display: flex; flex-direction: column; min-width: 0; }
.tk-rel b { font-size: 14px; color: var(--tk-ink); font-weight: 700; }
.tk-rel small { font-size: 12px; color: var(--tk-ink3); }

/* ---------------- 轻提示（仅用户操作后出现） ---------------- */
.tk-toast {
    position: fixed;
    left: 50%;
    bottom: 30px;
    transform: translateX(-50%) translateY(12px);
    padding: 11px 20px;
    border-radius: 999px;
    background: rgba(20, 26, 42, .95);
    color: #fff;
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: 0 12px 30px -14px rgba(0, 0, 0, .6);
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s, transform .2s;
    z-index: 99999;
    max-width: 88vw;
    text-align: center;
}
.tk-toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }
.tk-toast.is-err { background: rgba(190, 32, 26, .96); }
.tk-toast.is-ok { background: rgba(12, 122, 80, .96); }

/* ---------------- 结果弹窗（只在用户完成操作后触发） ---------------- */
.tk-modal {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(14, 18, 30, .55);
    backdrop-filter: blur(3px);
}
.tk-modal.is-open { display: flex; }
.tk-modal-box {
    width: min(560px, 100%);
    max-height: 86vh;
    overflow: auto;
    background: var(--tk-card);
    border: 1px solid var(--tk-line);
    border-radius: 18px;
    box-shadow: 0 30px 70px -30px rgba(0, 0, 0, .6);
    padding: 24px 26px;
    animation: tkPop .22s ease;
}
@keyframes tkPop { from { opacity: 0; transform: translateY(12px) scale(.97); } }
.tk-modal-box h3 { margin: 0 0 12px; font-size: 18px; font-weight: 800; }
.tk-modal-box .tk-modal-body { font-size: 14px; color: var(--tk-ink2); }
.tk-modal-foot { display: flex; justify-content: flex-end; gap: 10px; margin-top: 18px; }

/* ---------------- 校验提示条 ---------------- */
.tk-alert {
    display: flex;
    gap: 10px;
    align-items: flex-start;
    padding: 11px 14px;
    border-radius: 12px;
    font-size: 13.5px;
    line-height: 1.7;
    background: var(--tk-warn-soft);
    color: var(--tk-warn);
    border: 1px solid color-mix(in srgb, var(--tk-warn) 22%, transparent);
}
.tk-alert--err { background: var(--tk-danger-soft); color: var(--tk-danger); border-color: color-mix(in srgb, var(--tk-danger) 22%, transparent); }
.tk-alert--ok { background: var(--tk-ok-soft); color: var(--tk-ok); border-color: color-mix(in srgb, var(--tk-ok) 22%, transparent); }
.tk-alert--info { background: var(--tk-accent-soft); color: var(--tk-accent2); border-color: color-mix(in srgb, var(--tk-accent) 20%, transparent); }
.tk-alert[hidden] { display: none; }

/* ---------------- 响应式 ---------------- */
@media (max-width: 1080px) {
    .tk-rel-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tk-grid-3 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 860px) {
    .tk-page { padding: 14px 0 44px; }
    .tk-inner { padding: 0 16px; }
    .tk-grid-2, .tk-grid-3 { grid-template-columns: minmax(0, 1fr); }
    .tk-card { padding: 18px 16px; }
    .tk-panel { padding: 20px 16px; }
    .tk-timeline > li { grid-template-columns: 54px 1fr; }
    .tk-timeline > li .txt { grid-column: 1 / -1; }
    .tk-tab { padding: 8px 13px; font-size: 13px; }
}
@media (max-width: 560px) {
    .tk-rel-grid { grid-template-columns: minmax(0, 1fr); }
    .tk-row > * { flex-basis: 100%; }
}

/* ---------------- 打印 ---------------- */
@media print {
    .tk-page { background: #fff; padding: 0; }
    .tk-crumb, .tk-tabs, .tk-related, .tk-btns, .tk-no-print { display: none !important; }
    .tk-panel { display: none !important; box-shadow: none; border: none; padding: 0; }
    .tk-panel.is-on { display: block !important; }
    .tk-card { box-shadow: none; border-color: #ccc; break-inside: avoid; }
    .tk-outer-print { display: block !important; }
}
