/* ============================================================
   字数字符统计工具 /tools/word-count
   参考 jijie.ink/tool/word-count 的信息架构（输入 → 选项 →
   统计卡片 → 示例 → 历史 → 说明），视觉沿用本站卡片流语言，
   深浅色自动适配。

   ★ 变量一律定义在 :root 并用 [data-theme="light"] 覆盖：
     .wc-toast 是 .wc-page 的兄弟节点（挂在 body 下），
     变量若只挂在 .wc-page 上，浮层里的 var() 会解析失败导致背景透明。
   ============================================================ */

:root {
    --wc-card: #16181c;
    --wc-card-2: #1c1f24;
    --wc-card-3: #22262c;
    --wc-line: #2f3336;
    --wc-line-2: #3a4046;
    --wc-fg: #e7e9ea;
    --wc-fg-2: #9aa3ab;
    --wc-fg-3: #6b7378;
    --wc-blue: #2563eb;
    --wc-blue-h: #1d4ed8;
    --wc-blue-soft: rgba(37, 99, 235, .14);
    --wc-orange: #d97706;
    --wc-orange-h: #b45309;
    --wc-orange-soft: rgba(217, 119, 6, .14);
    --wc-green: #16a34a;
    --wc-red: #f4212e;
    --wc-red-soft: rgba(244, 33, 46, .12);
    --wc-shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --wc-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

[data-theme="light"] {
    --wc-card: #ffffff;
    --wc-card-2: #f7f9fa;
    --wc-card-3: #eff3f4;
    --wc-line: #e6eaec;
    --wc-line-2: #d6dbdf;
    --wc-fg: #0f1419;
    --wc-fg-2: #536471;
    --wc-fg-3: #7b8792;
    --wc-blue: #2563eb;
    --wc-blue-h: #1d4ed8;
    --wc-blue-soft: rgba(37, 99, 235, .1);
    --wc-orange: #d97706;
    --wc-orange-h: #b45309;
    --wc-orange-soft: rgba(217, 119, 6, .1);
    --wc-green: #16a34a;
    --wc-red: #e0243e;
    --wc-red-soft: rgba(224, 36, 62, .1);
    --wc-shadow: 0 1px 2px rgba(15, 20, 25, .06);
}

/* ==================== 页面骨架 ==================== */
.wc-page {
    /* 电脑端满屏（保留左侧导航）：根容器不设限宽，铺满 .main-content */
    max-width: 100%;
    margin: 0 auto;
    padding: 22px 20px 64px;
    box-sizing: border-box;
}

/* 电脑端满屏：解除全站 .app（1280px）与 .main-content 的中心限宽，左侧导航保留 */
body.page-word-count-full .app { max-width: 100%; }
body.page-word-count-full .main-content { max-width: 100%; width: 100%; border-right: 0; }

/* ★ 本仓库老坑：凡用 hidden 控制显隐的元素，若该选择器设了 display，必须补 [hidden] 兜底 */
.wc-page [hidden] {
    display: none !important;
}

/* ==================== 头部 ==================== */
.wc-hero {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 20px 22px;
    border: 1px solid var(--wc-line);
    border-radius: 16px;
    /* 老浏览器不支持 color-mix 时整条 background 声明失效，先给纯色兜底 */
    background: var(--wc-card);
    background: linear-gradient(135deg, color-mix(in srgb, var(--wc-blue) 12%, var(--wc-card)), var(--wc-card) 62%);
    box-shadow: var(--wc-shadow);
}

.wc-hero-ic {
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    font-size: 26px;
    border-radius: 14px;
    background: var(--wc-blue-soft);
}

.wc-hero-tx {
    min-width: 0;
    flex: 1 1 auto;
}

.wc-hero-t {
    margin: 0 0 6px;
    font-size: 21px;
    line-height: 1.3;
    color: var(--wc-fg);
}

.wc-hero-sub {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.65;
    color: var(--wc-fg-2);
}

.wc-hero-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.wc-tag {
    font-size: 11.5px;
    line-height: 1;
    padding: 6px 9px;
    border-radius: 999px;
    border: 1px solid var(--wc-line-2);
    background: var(--wc-card-2);
    color: var(--wc-fg-2);
    white-space: nowrap;
}

/* ==================== 卡片 ==================== */
.wc-card {
    margin-top: 16px;
    padding: 18px 20px;
    border: 1px solid var(--wc-line);
    border-radius: 16px;
    background: var(--wc-card);
    box-shadow: var(--wc-shadow);
    contain: layout style;
}

.wc-card-h {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 12px;
}

.wc-card-t {
    margin: 0;
    font-size: 15.5px;
    line-height: 1.3;
    color: var(--wc-fg);
}

.wc-count {
    font-size: 12px;
    color: var(--wc-fg-3);
    font-variant-numeric: tabular-nums;
}

/* ==================== 输入 ==================== */
.wc-ta {
    display: block;
    width: 100%;
    box-sizing: border-box;
    min-height: 220px;
    padding: 13px 15px;
    border: 1px solid var(--wc-line-2);
    border-radius: 12px;
    background: var(--wc-card-2);
    color: var(--wc-fg);
    font-size: 14px;
    line-height: 1.7;
    resize: vertical;
    outline: none;
    transition: border-color .16s, box-shadow .16s;
}

.wc-ta::placeholder {
    color: var(--wc-fg-3);
}

.wc-ta:focus {
    border-color: var(--wc-blue);
    box-shadow: 0 0 0 3px var(--wc-blue-soft);
}

/* ==================== 按钮与操作 ==================== */
.wc-actions,
.wc-ops {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 12px;
}

.wc-btn {
    appearance: none;
    border: 1px solid var(--wc-line-2);
    background: var(--wc-card-2);
    color: var(--wc-fg);
    font-size: 13px;
    line-height: 1;
    padding: 10px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: border-color .16s, background .16s, color .16s, opacity .16s;
    white-space: nowrap;
}

.wc-btn:hover:not(:disabled) {
    border-color: var(--wc-blue);
    color: var(--wc-blue);
}

.wc-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

.wc-btn-primary {
    background: var(--wc-blue);
    border-color: var(--wc-blue);
    color: #fff;
}

.wc-btn-primary:hover:not(:disabled) {
    background: var(--wc-blue-h);
    border-color: var(--wc-blue-h);
    color: #fff;
}

.wc-btn-danger {
    border-color: color-mix(in srgb, var(--wc-red) 45%, transparent);
    color: var(--wc-red);
    background: var(--wc-red-soft);
}

.wc-btn-danger:hover:not(:disabled) {
    border-color: var(--wc-red);
    color: var(--wc-red);
}

/* ==================== 选项 ==================== */
.wc-chks {
    display: flex;
    flex-wrap: wrap;
    gap: 10px 22px;
}

.wc-opt {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--wc-fg);
    cursor: pointer;
    user-select: none;
}

.wc-opt input {
    width: 15px;
    height: 15px;
    accent-color: var(--wc-blue);
    cursor: pointer;
}

.wc-field {
    margin-top: 14px;
}

.wc-lab {
    display: block;
    font-size: 12.5px;
    color: var(--wc-fg-2);
    margin-bottom: 6px;
}

.wc-sel {
    appearance: none;
    min-width: 200px;
    padding: 9px 32px 9px 12px;
    border: 1px solid var(--wc-line-2);
    border-radius: 10px;
    background: var(--wc-card-2) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%239aa3ab' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 12px center;
    color: var(--wc-fg);
    font-size: 13px;
    cursor: pointer;
    outline: none;
}

.wc-sel:focus {
    border-color: var(--wc-blue);
    box-shadow: 0 0 0 3px var(--wc-blue-soft);
}

.wc-hint {
    margin: 10px 0 0;
    font-size: 12px;
    line-height: 1.7;
    color: var(--wc-fg-3);
}

.wc-hint-ops {
    margin-top: 8px;
}

/* ==================== 统计结果 ==================== */
.wc-stats-main {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 12px;
}

.wc-stat {
    display: flex;
    flex-direction: column;
    gap: 3px;
    padding: 16px 18px;
    border: 1px solid var(--wc-line);
    border-radius: 14px;
    /* 同上：color-mix 不支持时回落纯色，避免整张卡背景透明 */
    background: var(--wc-card);
    background: linear-gradient(160deg, color-mix(in srgb, var(--wc-blue) 7%, var(--wc-card)), var(--wc-card) 70%);
    min-width: 0;
}

.wc-stat-v {
    font-size: 30px;
    font-weight: 700;
    line-height: 1.15;
    color: var(--wc-fg);
    font-variant-numeric: tabular-nums;
    word-break: break-all;
}

.wc-stat-l {
    font-size: 13px;
    font-weight: 600;
    color: var(--wc-fg);
}

.wc-stat-s {
    font-size: 11.5px;
    color: var(--wc-fg-3);
}

.wc-stats-sub {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
    gap: 10px;
    margin-top: 12px;
}

.wc-mini {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 11px 13px;
    border: 1px solid var(--wc-line);
    border-radius: 11px;
    background: var(--wc-card-2);
    min-width: 0;
}

.wc-mini-v {
    font-size: 18px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--wc-fg);
    font-variant-numeric: tabular-nums;
}

.wc-mini-l {
    font-size: 11.5px;
    color: var(--wc-fg-2);
}

/* ==================== 历史记录 ==================== */
.wc-hist {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.wc-hist-item {
    position: relative;
    padding: 12px 14px;
    border: 1px solid var(--wc-line);
    border-radius: 12px;
    background: var(--wc-card-2);
    cursor: pointer;
    transition: border-color .16s, background .16s;
}

.wc-hist-item:hover,
.wc-hist-item:focus-visible {
    border-color: var(--wc-blue);
    background: color-mix(in srgb, var(--wc-blue) 5%, var(--wc-card-2));
    outline: none;
}

.wc-hist-hd {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 7px;
    padding-right: 26px;
}

.wc-badge {
    font-size: 11px;
    line-height: 1;
    padding: 5px 8px;
    border-radius: 999px;
    border: 1px solid var(--wc-line-2);
    color: var(--wc-fg-2);
    background: var(--wc-card-3);
    white-space: nowrap;
}

.wc-badge-num {
    border-color: color-mix(in srgb, var(--wc-blue) 40%, transparent);
    color: var(--wc-blue);
    background: var(--wc-blue-soft);
    font-variant-numeric: tabular-nums;
}

.wc-hist-time {
    margin-left: auto;
    font-size: 11.5px;
    color: var(--wc-fg-3);
}

.wc-hist-del {
    position: absolute;
    top: 9px;
    right: 9px;
    width: 24px;
    height: 24px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: 7px;
    background: transparent;
    color: var(--wc-fg-3);
    font-size: 13px;
    line-height: 1;
    cursor: pointer;
    transition: color .16s, background .16s;
}

.wc-hist-del:hover {
    color: var(--wc-red);
    background: var(--wc-red-soft);
}

.wc-hist-line {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.6;
    color: var(--wc-fg-2);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wc-hist-tip {
    margin-top: 4px;
    font-size: 11.5px;
    color: var(--wc-fg-3);
}

/* ==================== 空态 ==================== */
.wc-empty {
    text-align: center;
    padding: 28px 16px;
    color: var(--wc-fg-2);
}

.wc-empty[hidden] {
    display: none !important;
}

.wc-empty-ic {
    font-size: 30px;
    margin-bottom: 8px;
}

.wc-empty p {
    margin: 0;
    font-size: 13.5px;
}

.wc-empty-s {
    margin-top: 6px;
    font-size: 12px;
    color: var(--wc-fg-3);
}

/* ==================== 使用说明 ==================== */
/* ★ 这里刻意不用 content-visibility: auto：
   说明区是静态文字，性能收益近零，却会带来「整页截图/打印时该区块空白」
   与浏览器页内查找（Ctrl+F）跳过的隐患，得不偿失。 */
.wc-tips-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 18px 24px;
}

.wc-tips-h {
    margin: 0 0 8px;
    font-size: 13.5px;
    color: var(--wc-fg);
}

.wc-tips-ul {
    margin: 0;
    padding-left: 18px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.wc-tips-ul li {
    font-size: 12.5px;
    line-height: 1.7;
    color: var(--wc-fg-2);
}

.wc-tips-note {
    margin: 14px 0 0;
    padding-top: 12px;
    border-top: 1px dashed var(--wc-line-2);
    font-size: 12px;
    line-height: 1.7;
    color: var(--wc-fg-3);
}

/* ==================== Toast ==================== */
.wc-toast {
    position: fixed;
    left: 50%;
    bottom: 42px;
    transform: translateX(-50%) translateY(12px);
    z-index: 100000;
    max-width: min(86vw, 520px);
    padding: 10px 18px;
    border-radius: 999px;
    border: 1px solid var(--wc-line-2);
    background: var(--wc-card-3);
    color: var(--wc-fg);
    font-size: 13px;
    line-height: 1.5;
    box-shadow: 0 10px 32px rgba(0, 0, 0, .28);
    opacity: 0;
    pointer-events: none;
    transition: opacity .22s, transform .22s;
    text-align: center;
}

.wc-toast.is-on {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.wc-toast.is-err {
    border-color: color-mix(in srgb, var(--wc-red) 55%, transparent);
    color: var(--wc-red);
}

.wc-toast[hidden] {
    display: none !important;
}

/* ==================== 响应式 ==================== */
@media (max-width: 1099px) {
    .wc-stats-main {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .wc-tips-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

@media (max-width: 767px) {
    .wc-page {
        padding: 14px 12px 48px;
    }

    .wc-hero {
        padding: 16px;
    }

    .wc-hero-ic {
        width: 44px;
        height: 44px;
        font-size: 22px;
    }

    .wc-card {
        padding: 14px 15px;
    }

    .wc-ta {
        font-size: 16px; /* 防 iOS 聚焦缩放 */
        min-height: 200px;
    }

    .wc-stat-v {
        font-size: 25px;
    }

    .wc-btn {
        min-height: 42px;
    }

    .wc-sel {
        width: 100%;
    }

    .wc-tips-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 420px) {
    .wc-stats-main {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px;
    }

    .wc-stat {
        padding: 13px 14px;
    }

    .wc-stats-sub {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}
