/* 全站公共样式：头部、容器、按钮、卡片、移动端布局 */
* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: "Microsoft YaHei", sans-serif;
    background: #f6f8fb;
    color: #222;
}

a {
    color: #1e9fff;
    text-decoration: none;
}

.site-header {
    background: #0f172a;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}

.header-inner {
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

/* 顶栏第一行：Logo +（仅移动端显示）汉堡按钮 */
.header-brand-row {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    flex: 0 1 auto;
    min-width: 0;
}

/* 移动端菜单按钮：三横线，最小约 44px 便于点击 */
.site-mobile-nav-toggle {
    display: none;
    margin-left: auto;
    flex-shrink: 0;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.08);
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 5px;
}

.site-mobile-nav-toggle-bar {
    display: block;
    width: 18px;
    height: 2px;
    background: #e2e8f0;
    border-radius: 1px;
}

/* ---------- 移动端全屏导航抽屉（Layui 无独立「抽屉」组件，用固定层 + layui-nav-tree）---------- */
.site-mobile-nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 1000;
    background: rgba(15, 23, 42, 0.45);
    backdrop-filter: blur(2px);
}

.site-mobile-nav-backdrop.is-open {
    display: block;
}

.site-mobile-nav-drawer {
    position: fixed;
    inset: 0;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    max-width: 100%;
    background: #1a1d2c;
    color: #f1f5f9;
    transform: translateX(100%);
    transition: transform 0.28s ease;
    box-shadow: -6px 0 24px rgba(0, 0, 0, 0.2);
    pointer-events: none;
}

.site-mobile-nav-drawer.is-open {
    transform: translateX(0);
    pointer-events: auto;
}

.site-mobile-nav-drawer-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.site-mobile-nav-drawer-title {
    font-size: 16px;
    font-weight: 600;
    color: #f8fafc;
}

.site-mobile-nav-drawer-close {
    width: 44px;
    height: 44px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    cursor: pointer;
    font-size: 18px;
}

.site-mobile-nav-drawer-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 0 24px;
}

/* 抽屉内 Layui 垂直树：深色顶栏风格 + 子级浅色圆角卡片（贴近参考图） */
.site-mobile-nav-tree.layui-nav {
    width: 100%;
    background: transparent !important;
    padding: 0 12px;
}

.site-mobile-nav-tree > .layui-nav-item {
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    line-height: 1.4;
}

.site-mobile-nav-tree > .layui-nav-item > a {
    color: #f1f5f9 !important;
    font-size: 16px;
    padding: 14px 8px 14px 4px;
    min-height: 48px;
    display: flex;
    align-items: center;
}

.site-mobile-nav-tree > .layui-nav-item > a:hover {
    color: #fff !important;
}

/* Layui 注入的展开箭头颜色 */
.site-mobile-nav-tree .layui-nav-more {
    border-color: rgba(255, 255, 255, 0.65) !important;
}

.site-mobile-nav-tree .layui-nav-mored .layui-nav-more {
    border-color: rgba(255, 255, 255, 0.65) !important;
}

.site-mobile-nav-tree .layui-nav-child {
    position: static !important;
    margin: 4px 0 14px 0 !important;
    padding: 8px 0 !important;
    background: #f1f5f9 !important;
    border-radius: 10px !important;
    box-shadow: none !important;
    border: 1px solid #e2e8f0 !important;
}

.site-mobile-nav-tree .layui-nav-child dd {
    margin: 0 !important;
}

.site-mobile-nav-tree .layui-nav-child a {
    color: #1e293b !important;
    padding: 12px 16px !important;
    font-size: 15px;
    min-height: 44px;
    display: flex;
    align-items: center;
}

.site-mobile-nav-tree .layui-nav-child a:hover {
    background: #e2e8f0 !important;
    color: #0f172a !important;
}

body.site-mobile-nav-locked {
    overflow: hidden;
}

.logo {
    color: #fff;
    font-size: 20px;
    font-weight: 700;
}

/* ---------- 顶栏：Layui 水平导航（layui-nav），深色顶栏上覆写默认配色 ---------- */
/* 整块导航靠右：不占满中间空白，用 margin-left:auto 顶到右侧 */
.site-header-nav-wrap {
    flex: 0 1 auto;
    min-width: 0;
    margin-left: auto;
    display: flex;
    justify-content: flex-end;
}

.site-header .site-header-nav.layui-nav {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 0 4px;
    padding: 0;
    background: transparent;
    border: none;
}

.site-header .site-header-nav > .layui-nav-item {
    line-height: 44px;
}

.site-header .site-header-nav > .layui-nav-item > a {
    position: relative;
    color: #dbeafe;
    font-size: 15px;
    padding: 0 14px;
}

.site-header .site-header-nav > .layui-nav-item > a:hover {
    color: #fff;
}

/* 有子菜单的项：给 Layui 注入的小箭头（.layui-nav-more）留出空隙，避免贴住最后一个汉字 */
.site-header .site-header-nav > .layui-nav-item:has(.layui-nav-child) > a {
    padding-right: 26px;
}

/* Layui 在含子菜单的 a 内追加的三角，默认 right:3px 易与文字挤在一起 */
.site-header .site-header-nav > .layui-nav-item > a .layui-nav-more {
    right: 12px;
}

/* 子菜单：白底下拉，与 Layui 默认子级一致、略加圆角阴影 */
.site-header .site-header-nav .layui-nav-child {
    min-width: 220px;
    border-radius: 8px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.15);
    border: 1px solid #e2e8f0;
}

.site-header .site-header-nav .layui-nav-child a {
    color: #334155;
}

.site-header .site-header-nav .layui-nav-child a:hover {
    background: #f1f5f9;
    color: #0f172a;
}

.main-content {
    min-height: calc(100vh - 120px);
    padding: 24px 0;
}

.page-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: 0 3px 12px rgba(15, 23, 42, 0.06);
    margin-bottom: 20px;
}

/* ---------- 工具页统一标题与控件间距（对齐 Layui 表单项/字段集节奏）---------- */
.page-card > h1 {
    margin: 0 0 8px 0;
    font-size: 22px;
    font-weight: 600;
    color: #1f2937;
    line-height: 1.35;
}

.page-card > h1 + p,
.page-card > h1 + .tool-intro {
    margin: 0 0 4px 0;
    color: #64748b;
    font-size: 14px;
    line-height: 1.55;
}

/* 字段集/表单内简短说明（放在 textarea 上方） */
.tool-field-desc {
    margin: 0 0 12px 0;
    color: #8c8c8c;
    font-size: 13px;
    line-height: 1.55;
}

/* 使用说明内的问答段落（可与 .tool-about-list 混排） */
.tool-about-qa {
    margin: 12px 0 0 0;
    color: #575757;
    font-size: 14px;
    line-height: 1.65;
}

.tool-about-qa + .tool-about-qa {
    margin-top: 10px;
}

/* 分区小标题：底部分割线 + 与下方首块控件留白（避免标题紧贴 textarea） */
.page-card > h2 {
    margin: 0;
    padding-bottom: 10px;
    border-bottom: 1px solid #f2f2f2;
    font-size: 16px;
    font-weight: 600;
    color: #393d49;
    line-height: 1.5;
}

/* h2 后第一个子元素统一顶距（Layui .layui-form-item 约 15～22px 量级） */
.page-card > h2 + * {
    margin-top: 16px;
}

/* 说明段再接控件时：压缩说明与控件之间间距，由说明的下边距承担 */
.page-card > h2 + p,
.page-card > h2 + .tool-intro,
.page-card > h2 + .tool-field-desc,
.page-card > h2 + .regex-muted {
    margin-top: 14px;
    margin-bottom: 14px;
    color: #8c8c8c;
    font-size: 13px;
    line-height: 1.6;
}

.page-card > h2 + p + textarea,
.page-card > h2 + p + input,
.page-card > h2 + p + .layui-form,
.page-card > h2 + p + div:not(.tool-actions):not(.regex-preset-tags) {
    margin-top: 0;
}

/* 使用说明 / 工具介绍：列表与标题的衔接 */
.page-card > h2 + ul.tool-about-list,
.page-card > h2 + ol.tool-about-list {
    margin-top: 14px;
    margin-bottom: 0;
    padding-left: 1.25rem;
    color: #575757;
    font-size: 14px;
    line-height: 1.65;
}

.page-card > h2 + ul.tool-about-list > li,
.page-card > h2 + ol.tool-about-list > li {
    margin-bottom: 8px;
}

.page-card > h2 + p + ul.tool-about-list,
.page-card > h2 + p + ol {
    margin-top: 10px;
}

/* h2 后为 div 区块（统计、预览容器等） */
.page-card > h2 + div:not(.tool-actions) {
    margin-top: 14px;
}

/* Layui 字段集放在卡片内时与卡片边距协调 */
.page-card > fieldset.layui-elem-field {
    margin: 0;
}

.page-card > fieldset.layui-elem-field + fieldset.layui-elem-field {
    margin-top: 18px;
}

/* Layui 字段集内：legend 与内容区留白（全站工具页可用，不依赖 formatter-tool.css） */
.page-card fieldset.layui-elem-field {
    border-radius: 2px;
}

.page-card fieldset.layui-elem-field legend {
    font-size: 16px;
    font-weight: 600;
}

.page-card fieldset.layui-elem-field .layui-field-box .tool-actions {
    margin-top: 12px;
    margin-bottom: 0;
}

.tool-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 12px;
}

.tool-actions .layui-btn {
    min-height: 40px;
    line-height: 40px;
}

.result-box {
    min-height: 200px;
    white-space: pre-wrap;
    word-break: break-word;
}

.site-footer {
    background: #fff;
    border-top: 1px solid #e5e7eb;
    padding: 16px 0;
    text-align: center;
    color: #6b7280;
}

@media (max-width: 768px) {
    .header-inner {
        flex-wrap: nowrap;
        padding: 10px 0;
        min-height: 52px;
    }

    .header-brand-row {
        width: 100%;
    }

    /* 小屏：顶栏内嵌 Layui 水平导航隐藏，改由汉堡 + 抽屉内 layui-nav-tree 展示（手风琴 lay-accordion） */
    .site-mobile-nav-toggle {
        display: inline-flex;
    }

    .site-header-nav-wrap {
        display: none !important;
    }

    .main-content {
        padding: 14px 0;
    }

    .page-card {
        padding: 14px;
        border-radius: 8px;
    }

    textarea.layui-textarea,
    input.layui-input {
        width: 100%;
    }

    .result-box {
        overflow-x: auto;
    }
}
