/* ============================================================
   ASCII 表 /tools/ascii-table
   复刻菜鸟工具 ASCII 表的信息架构（字符集 → 搜索筛选 → 表格 →
   详情 → 导出 → 速查 → 文本互转 → 说明），视觉沿用本站卡片流语言。

   ★ 变量定义在 :root 并用 [data-theme="light"] 覆盖：
     浮层若挂到 body 下，变量只挂在页面根类上会解析失败导致背景透明。
   ============================================================ */

:root {
    --at-card: #16181c;
    --at-card-2: #1c1f24;
    --at-card-3: #22262c;
    --at-line: #2f3336;
    --at-line-2: #3a4046;
    --at-fg: #e7e9ea;
    --at-fg-2: #9aa3ab;
    --at-fg-3: #6b7378;
    --at-blue: #2563eb;
    --at-blue-h: #1d4ed8;
    --at-blue-soft: rgba(37, 99, 235, .14);
    --at-amber: #e3a008;
    --at-red: #f4212e;
    --at-red-soft: rgba(244, 33, 46, .12);
    --at-shadow: 0 1px 2px rgba(0, 0, 0, .3);
    --at-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

[data-theme="light"] {
    --at-card: #ffffff;
    --at-card-2: #f7f9fa;
    --at-card-3: #eff3f4;
    --at-line: #e6eaec;
    --at-line-2: #d6dbdf;
    --at-fg: #0f1419;
    --at-fg-2: #536471;
    --at-fg-3: #7b8792;
    --at-blue: #2563eb;
    --at-blue-h: #1d4ed8;
    --at-blue-soft: rgba(37, 99, 235, .1);
    --at-amber: #b45309;
    --at-red: #e0245e;
    --at-red-soft: rgba(224, 36, 94, .1);
    --at-shadow: 0 1px 2px rgba(15, 20, 25, .06);
}

/* ==================== 骨架 ==================== */
.at-page {
    /* 电脑端满屏（保留左侧导航）：根容器不设限宽，铺满 .main-content */
    max-width: 100%;
    margin: 0 auto;
    padding: 22px 20px 64px;
    box-sizing: border-box;
}

/* 电脑端满屏：解除全站 .app（1280px）与 .main-content 的中心限宽，左侧导航保留 */
body.page-ascii-table-full .app { max-width: 100%; }
body.page-ascii-table-full .main-content { max-width: 100%; width: 100%; border-right: 0; }

/* ★ 本站老坑：凡用 hidden 控制显隐的元素，若选择器设了 display 必须补 [hidden] 兜底 */
.at-page [hidden] {
    display: none !important;
}

.at-hero {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    padding: 20px 22px;
    border: 1px solid var(--at-line);
    border-radius: 16px;
    background: var(--at-card);
    background: linear-gradient(135deg, color-mix(in srgb, var(--at-blue) 12%, var(--at-card)), var(--at-card) 62%);
    box-shadow: var(--at-shadow);
}

.at-hero-ic {
    flex: 0 0 auto;
    width: 52px;
    height: 52px;
    display: grid;
    place-items: center;
    font-size: 26px;
    border-radius: 14px;
    background: var(--at-blue-soft);
}

.at-hero-tx { min-width: 0; flex: 1 1 auto; }
.at-hero-t { margin: 0 0 6px; font-size: 21px; color: var(--at-fg); }
.at-hero-sub { margin: 0; font-size: 13.5px; line-height: 1.65; color: var(--at-fg-2); }

.at-hero-tags { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

.at-tag {
    font-size: 11.5px;
    line-height: 1;
    padding: 6px 9px;
    border-radius: 999px;
    border: 1px solid var(--at-line-2);
    background: var(--at-card-2);
    color: var(--at-fg-2);
    white-space: nowrap;
}

/* ==================== 卡片 ==================== */
.at-card {
    border: 1px solid var(--at-line);
    border-radius: 14px;
    background: var(--at-card);
    box-shadow: var(--at-shadow);
    padding: 16px 18px 18px;
    margin-top: 16px;
    contain: layout style;
}

.at-card-h {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.at-card-t { margin: 0; font-size: 15px; color: var(--at-fg); }
.at-count { font-size: 12px; color: var(--at-fg-3); white-space: nowrap; }

/* ==================== 字符集切换 ==================== */
.at-scope {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.at-scope-btn {
    appearance: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 8px 14px;
    border: 1px solid var(--at-line-2);
    border-radius: 999px;
    background: var(--at-card-2);
    color: var(--at-fg-2);
    transition: background .16s ease, color .16s ease, border-color .16s ease;
}

.at-scope-btn[aria-pressed="true"] {
    background: var(--at-blue);
    border-color: var(--at-blue);
    color: #fff;
}

.at-note { margin: 0; font-size: 12px; line-height: 1.6; color: var(--at-fg-3); }

/* ==================== 搜索 ==================== */
.at-search {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    margin: 12px 0 10px;
}

.at-input {
    box-sizing: border-box;
    padding: 9px 11px;
    border: 1px solid var(--at-line-2);
    border-radius: 9px;
    background: var(--at-card-2);
    color: var(--at-fg);
    font-size: 13.5px;
    font-family: inherit;
}

.at-input:focus {
    outline: none;
    border-color: var(--at-blue);
    box-shadow: 0 0 0 3px var(--at-blue-soft);
}

.at-search .at-input { flex: 1 1 220px; min-width: 0; }
.at-search .at-sel { flex: 0 1 auto; min-width: 150px; }

.at-sel {
    box-sizing: border-box;
    padding: 9px 11px;
    border: 1px solid var(--at-line-2);
    border-radius: 9px;
    background: var(--at-card-2);
    color: var(--at-fg);
    font-size: 13.5px;
    font-family: inherit;
}

.at-sel:focus { outline: none; border-color: var(--at-blue); box-shadow: 0 0 0 3px var(--at-blue-soft); }

/* ==================== 按钮 ==================== */
.at-btn {
    appearance: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    padding: 9px 14px;
    border: 1px solid var(--at-line-2);
    border-radius: 10px;
    background: var(--at-card-2);
    color: var(--at-fg);
    transition: background .16s ease, border-color .16s ease, color .16s ease;
    white-space: nowrap;
}

.at-btn:hover:not(:disabled) { border-color: var(--at-blue); color: var(--at-blue); }
.at-btn:disabled { opacity: .5; cursor: not-allowed; }
.at-btn-blue { background: var(--at-blue); border-color: var(--at-blue); color: #fff; }
.at-btn-blue:hover:not(:disabled) { background: var(--at-blue-h); border-color: var(--at-blue-h); color: #fff; }
.at-btn-danger:hover:not(:disabled) { border-color: var(--at-red); color: var(--at-red); background: var(--at-red-soft); }
.at-btn-sm { padding: 7px 11px; font-size: 12.5px; border-radius: 8px; }

/* ==================== 筛选 / 列 / 速查 ==================== */
.at-row {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}

.at-row-t { font-size: 12px; font-weight: 600; color: var(--at-fg-2); flex: 0 0 auto; }

.at-filters { display: flex; flex-wrap: wrap; gap: 6px; }

.at-filter {
    appearance: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    padding: 6px 11px;
    border: 1px solid var(--at-line-2);
    border-radius: 999px;
    background: var(--at-card-2);
    color: var(--at-fg-2);
    transition: background .16s ease, color .16s ease, border-color .16s ease;
}

.at-filter:hover { border-color: var(--at-blue); color: var(--at-blue); }
.at-filter[aria-pressed="true"] { background: var(--at-blue); border-color: var(--at-blue); color: #fff; }

.at-columns { display: flex; flex-wrap: wrap; gap: 8px 14px; }

.at-cb {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--at-fg-2);
    cursor: pointer;
    user-select: none;
}

.at-cb input[type="checkbox"] { width: 14px; height: 14px; margin: 0; accent-color: var(--at-blue); cursor: pointer; }

.at-quick { display: flex; flex-wrap: wrap; gap: 6px; }

.at-chip {
    appearance: none;
    cursor: pointer;
    font-family: var(--at-mono);
    font-size: 12px;
    padding: 5px 10px;
    border: 1px solid var(--at-line-2);
    border-radius: 8px;
    background: var(--at-card-2);
    color: var(--at-fg-2);
    transition: border-color .16s ease, color .16s ease;
}

.at-chip:hover { border-color: var(--at-blue); color: var(--at-blue); }

/* ==================== 表格 ==================== */
.at-table-wrap {
    overflow: auto;
    max-height: 620px;
    border: 1px solid var(--at-line);
    border-radius: 12px;
    overscroll-behavior: contain;
    contain: layout style;
}

.at-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.at-table thead th {
    position: sticky;
    top: 0;
    z-index: 2;
    background: var(--at-card-3);
    color: var(--at-fg-2);
    font-size: 11.5px;
    font-weight: 600;
    text-align: left;
    padding: 9px 10px;
    border-bottom: 1px solid var(--at-line-2);
    white-space: nowrap;
}

.at-table tbody tr:nth-child(even) { background: var(--at-card-2); }
.at-table tbody tr:hover { background: var(--at-blue-soft); }
.at-table td { padding: 6px 10px; border-bottom: 1px solid var(--at-line); vertical-align: middle; }

.at-c-star { width: 42px; text-align: center; }

.at-star {
    appearance: none;
    cursor: pointer;
    background: none;
    border: 0;
    padding: 2px 4px;
    font-size: 15px;
    line-height: 1;
    color: var(--at-fg-3);
    transition: color .16s ease, transform .16s ease;
}

.at-star.is-on { color: var(--at-amber); }
.at-star:hover { transform: scale(1.15); }

.at-c-sym { width: 72px; }

.at-symbol {
    appearance: none;
    cursor: pointer;
    min-width: 34px;
    min-height: 26px;
    padding: 2px 8px;
    border: 1px solid var(--at-line-2);
    border-radius: 7px;
    background: var(--at-card-3);
    color: var(--at-fg);
    font-family: var(--at-mono);
    font-size: 13px;
    transition: border-color .16s ease, color .16s ease;
}

.at-symbol:hover { border-color: var(--at-blue); color: var(--at-blue); }

.at-mono { font-family: var(--at-mono); font-size: 12.5px; white-space: nowrap; }

.at-cell {
    appearance: none;
    cursor: pointer;
    background: none;
    border: 0;
    padding: 2px 4px;
    border-radius: 5px;
    font-family: var(--at-mono);
    font-size: 12.5px;
    color: var(--at-fg-2);
    transition: background .16s ease, color .16s ease;
}

.at-cell:hover { background: var(--at-blue-soft); color: var(--at-blue); }

.at-description { max-width: 320px; }
.at-desc-cn { display: block; font-size: 12.5px; color: var(--at-fg); }

.at-desc-en {
    display: block;
    font-size: 11px;
    color: var(--at-fg-3);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.at-undefined td { opacity: .55; }
.at-empty { padding: 26px 12px; text-align: center; color: var(--at-fg-3); font-size: 13px; }

/* ==================== 字符详情 ==================== */
.at-detail {
    border: 1px solid var(--at-blue);
    border-radius: 12px;
    background: var(--at-card-2);
    padding: 14px 16px 16px;
    margin-top: 12px;
}

.at-detail-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.at-detail-t { margin: 0; font-size: 14px; color: var(--at-fg); }

.at-character { display: flex; gap: 14px; align-items: center; }

.at-glyph {
    flex: 0 0 auto;
    width: 58px;
    height: 58px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    border: 1px solid var(--at-line-2);
    background: var(--at-card-3);
    font-family: var(--at-mono);
    font-size: 26px;
    color: var(--at-fg);
}

.at-char-tx { min-width: 0; }
.at-char-tx h5 { margin: 0 0 3px; font-size: 15px; color: var(--at-fg); }
.at-hint { margin: 0; font-size: 12px; line-height: 1.6; color: var(--at-fg-3); }

.at-detail-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin: 12px 0;
}

.at-detail-i {
    border: 1px solid var(--at-line);
    border-radius: 9px;
    background: var(--at-card);
    padding: 7px 9px;
    min-width: 0;
}

.at-detail-i span { display: block; font-size: 11px; color: var(--at-fg-3); }

.at-detail-i code {
    display: block;
    font-family: var(--at-mono);
    font-size: 12.5px;
    color: var(--at-fg);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.at-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }

/* ==================== 手动复制兜底 ==================== */
.at-manual {
    border: 1px dashed var(--at-amber);
    border-radius: 12px;
    background: var(--at-card-2);
    padding: 12px 14px 14px;
    margin-top: 12px;
}

.at-manual-h { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.at-manual-t { margin: 0; font-size: 13px; color: var(--at-amber); }

.at-manual textarea {
    width: 100%;
    box-sizing: border-box;
    min-height: 76px;
    resize: vertical;
    padding: 9px 11px;
    border: 1px solid var(--at-line-2);
    border-radius: 9px;
    background: var(--at-card);
    color: var(--at-fg);
    font-family: var(--at-mono);
    font-size: 13px;
}

/* ==================== 转换器 ==================== */
.at-conv { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 14px; }

.at-conv-col { min-width: 0; }

.at-conv-l {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--at-fg-2);
    margin-bottom: 6px;
}

.at-area {
    width: 100%;
    box-sizing: border-box;
    min-height: 110px;
    resize: vertical;
    padding: 10px 12px;
    border: 1px solid var(--at-line-2);
    border-radius: 10px;
    background: var(--at-card-2);
    color: var(--at-fg);
    font-family: var(--at-mono);
    font-size: 13px;
    line-height: 1.6;
}

.at-area:focus { outline: none; border-color: var(--at-blue); box-shadow: 0 0 0 3px var(--at-blue-soft); }

.at-conv-ops { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-top: 12px; }

.at-status { margin: 10px 0 0; font-size: 12.5px; line-height: 1.6; color: var(--at-fg-2); min-height: 18px; }
.at-status.is-err { color: var(--at-red); }

.at-visible {
    margin: 8px 0 0;
    padding: 8px 10px;
    border-radius: 8px;
    background: var(--at-card-2);
    border: 1px dashed var(--at-line-2);
    font-family: var(--at-mono);
    font-size: 12.5px;
    color: var(--at-fg-2);
    overflow-wrap: anywhere;
}

/* ==================== 消息条 ==================== */
.at-message {
    margin-top: 12px;
    font-size: 12.5px;
    color: var(--at-fg-3);
    min-height: 18px;
}

.at-message.is-err { color: var(--at-red); }

/* ==================== 说明 ==================== */
.at-help { margin-top: 16px; }

.at-help summary {
    cursor: pointer;
    font-size: 13.5px;
    font-weight: 600;
    color: var(--at-fg);
    list-style: none;
    padding: 4px 0;
}

.at-help summary::-webkit-details-marker { display: none; }
.at-help summary::marker { content: ''; }

.at-help-ul { margin: 10px 0 0; padding-left: 18px; display: flex; flex-direction: column; gap: 7px; }
.at-help-ul li { font-size: 12.5px; line-height: 1.65; color: var(--at-fg-2); }
.at-help-ul code { font-family: var(--at-mono); color: var(--at-blue); }

.at-ref { margin: 10px 0 0; font-size: 12px; color: var(--at-fg-3); }

/* ==================== 响应式 ==================== */
@media (max-width: 1099px) {
    .at-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .at-conv { grid-template-columns: minmax(0, 1fr); }
}

@media (max-width: 767px) {
    .at-page { padding: 14px 12px 56px; }
    .at-hero { padding: 16px; gap: 12px; }
    .at-hero-ic { width: 44px; height: 44px; font-size: 22px; }
    .at-card { padding: 14px; }
    .at-detail-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .at-search .at-input { flex: 1 1 100%; }
    .at-search .at-sel { flex: 1 1 100%; }
    .at-btn { min-height: 44px; }
    .at-sel,
    .at-input,
    .at-area { font-size: 16px; } /* 防 iOS 聚焦缩放 */
    /* 手机端表格自身限高滚动：128 行全展开会让页面长达数千像素，
       把速查 / 转换器 / 说明挤到很远的地方 */
    .at-table-wrap { max-height: 68vh; }
    .at-description { max-width: 180px; }
    .at-table thead th { font-size: 11px; padding: 8px 8px; }
    .at-table td { padding: 6px 8px; }
}

@media (max-width: 420px) {
    .at-detail-grid { grid-template-columns: minmax(0, 1fr); }
    .at-hero-t { font-size: 18px; }
}

/* 触屏去掉 hover 粘滞反馈 */
@media (hover: none) {
    .at-table tbody tr:hover { background: transparent; }
    .at-btn:hover:not(:disabled) { border-color: var(--at-line-2); color: var(--at-fg); }
    .at-cell:hover { background: none; color: var(--at-fg-2); }
    .at-chip:hover { border-color: var(--at-line-2); color: var(--at-fg-2); }
}

@media (prefers-reduced-motion: reduce) {
    .at-btn,
    .at-filter,
    .at-chip,
    .at-star,
    .at-cell,
    .at-symbol,
    .at-scope-btn { transition: none; }
}

/* ==================== 打印 ==================== */
@media print {
    .at-scope,
    .at-search,
    .at-filters,
    .at-quick,
    .at-actions,
    .at-conv,
    .at-manual,
    .at-message { display: none !important; }

    .at-table-wrap { max-height: none; overflow: visible; }
}
