/* ==============================================
   1. 浏览器默认样式重置（消除跨浏览器差异，基础必备）
   ============================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: "Microsoft YaHei", "微软雅黑", PingFang SC, "苹方", SimSun, "宋体", Arial, sans-serif;
}
html, body {
    height: 100%;
    overflow-x: hidden; /* 禁止横向滚动 */
}
body {
    min-height: 100vh; /* 保证页面至少占满屏幕高度 */
}
button, textarea {
    border: none;
    outline: none;
    background: none;
    cursor: pointer;
    -webkit-appearance: none; /* 移除移动端按钮默认样式 */
    appearance: none;
}
textarea {
    resize: vertical; /* 仅允许垂直拖动改变高度 */
}
ul, ol, li {
    list-style: none;
}
a {
    text-decoration: none;
    color: inherit;
}

/* ==============================================
   2. CSS变量定义（核心！优化后：柔化配色/增大圆角/柔和阴影）
   关键优化：主色更温和、危险色更柔、圆角增大、阴影更弥散、留白更均匀
   ============================================== */
:root {
    /* 主题色：柔化闲鱼橙（更温和不刺眼）、成功绿/危险红弱化，提升舒适度 */
    --primary-color: #ff782e; /* 优化：柔化闲鱼橙，比原#ff6700更温和 */
    --primary-dark: #f56c1f; /* 主色加深（hover），同步柔化 */
    --primary-light: #fff5ee; /* 主色浅背景，用于轻微点缀 */
    --success-color: #10b981; /* 优化：柔化成功绿，不刺眼 */
    --success-light: #f0fdf7; /* 成功浅背景，更淡 */
    --danger-color: #ef4444; /* 优化：柔化危险红，减少视觉冲击 */
    --danger-light: #fef2f2; /* 危险浅背景，更淡 */
    /* 中性灰：优化灰度层级，更柔和的文字/边框/背景 */
    --text-dark: #374151; /* 优化：深灰替代纯黑，阅读更舒服 */
    --text-middle: #6b7280; /* 中灰，用于副文本 */
    --text-light: #9ca3af; /* 浅灰，用于占位/页脚 */
    --border-color: #e5e7eb; /* 边框色，不变 */
    --border-light: #f3f4f6; /* 浅边框，更柔和 */
    --bg-main: #f9fafb; /* 优化：页面主背景，更浅的灰，不沉闷 */
    --bg-white: #ffffff; /* 白色背景（卡片/输入框） */
    --bg-gray: #f8f9fa;  /* 优化：副按钮背景，更浅的灰，更柔和 */
    --bg-gray-hover: #e9ecef; /* 副按钮hover背景，同步柔化 */
    /* 通用样式：优化核心！圆角增大+阴影更弥散+留白更呼吸 */
    --radius-sm: 6px;    /* 优化：从4px→6px，更圆润 */
    --radius-md: 12px;   /* 优化：从8px→12px，卡片/按钮主圆角 */
    --radius-lg: 16px;   /* 优化：从12px→16px，外层大卡片圆角 */
    --spacing-xs: 6px;
    --spacing-sm: 12px;  /* 优化：微调留白，更均匀 */
    --spacing-md: 18px;
    --spacing-lg: 24px;
    --spacing-xl: 32px;
    --shadow-sm: 0 2px 10px rgba(0, 0, 0, 0.03); /* 优化：更弥散的浅阴影 */
    --shadow-md: 0 4px 20px rgba(0, 0, 0, 0.05); /* 核心卡片阴影，柔和不突兀 */
    --shadow-lg: 0 6px 25px rgba(255, 120, 46, 0.15); /* 按钮hover阴影，更淡 */
    --transition-base: all 0.3s ease; /* 通用过渡动画 */
    --transition-fast: all 0.2s ease; /* 快速过渡，用于按钮/输入框 */
}

/* ==============================================
   3. 纯CSS自定义图标（优化：微调大小/间距，更贴合文字，视觉居中）
   ============================================== */
.icon {
    display: inline-block;
    width: 20px;
    height: 20px;
    position: relative;
    vertical-align: middle;
    margin-right: var(--spacing-xs);
    flex-shrink: 0; /* 防止图标被挤压 */
}
/* 搜索图标 */
.icon-search::before {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 9px;
    height: 9px;
    border: 2px solid currentColor;
    border-radius: 50%;
}
.icon-search::after {
    content: "";
    position: absolute;
    bottom: 4px;
    right: 3px;
    width: 5px;
    height: 2px;
    background: currentColor;
    transform: rotate(-45deg);
}
/* 文件图标 */
.icon-file::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 5px;
    width: 10px;
    height: 12px;
    border: 2px solid currentColor;
    border-radius: var(--radius-sm);
}
.icon-file::after {
    content: "";
    position: absolute;
    top: 1px;
    left: 8px;
    width: 7px;
    height: 2px;
    background: currentColor;
}
/* 闪电图标（检测按钮）- 优化：更精致 */
.icon-bolt {
    width: 18px;
    height: 18px;
}
.icon-bolt::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 9px solid currentColor;
}
.icon-bolt::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 9px solid currentColor;
    margin-top: -2px;
}
/* 垃圾桶图标（清空按钮）- 优化：更精致 */
.icon-trash {
    width: 18px;
    height: 18px;
}
.icon-trash::before {
    content: "";
    position: absolute;
    top: 3px;
    left: 4px;
    width: 10px;
    height: 8px;
    border: 2px solid currentColor;
    border-bottom: none;
    border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}
.icon-trash::after {
    content: "";
    position: absolute;
    bottom: 3px;
    left: 50%;
    transform: translateX(-50%);
    width: 7px;
    height: 2px;
    background: currentColor;
}
/* 对勾圆图标（成功/结果标题）- 优化：线条更协调 */
.icon-check-circle {
    color: var(--success-color);
}
.icon-check-circle::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--success-color);
    border-radius: 50%;
}
.icon-check-circle::after {
    content: "";
    position: absolute;
    top: 5px;
    left: 8px;
    width: 4px;
    height: 9px;
    border-right: 2px solid var(--success-color);
    border-bottom: 2px solid var(--success-color);
    transform: rotate(45deg);
}
/* 感叹号圆图标（危险/违禁词提示）- 优化：线条更协调 */
.icon-exclamation-circle {
    color: var(--danger-color);
}
.icon-exclamation-circle::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 20px;
    height: 20px;
    border: 2px solid var(--danger-color);
    border-radius: 50%;
}
.icon-exclamation-circle::after {
    content: "!";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    font-size: 15px;
    font-weight: 600;
    color: var(--danger-color);
    line-height: 20px;
}
/* 加载动画图标（检测中）- 优化：更细的边框，更流畅 */
.icon-loading {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid transparent;
    border-top: 2px solid #fff;
    border-radius: 50%;
    animation: loading 1.2s linear infinite;
    margin: 0 0 0 var(--spacing-xs);
    flex-shrink: 0;
}
@keyframes loading {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}
/* 检测中状态：显示加载图标，隐藏按钮文字 */
.checking .icon-loading {
    display: inline-block;
}
.checking .btn-text {
    display: none;
}

/* ==============================================
   4. 页面基础样式（优化：更柔和的背景，更舒服的行高）
   ============================================== */
body {
    background-color: var(--bg-main);
    color: var(--text-dark);
    line-height: 1.7; /* 优化：从1.6→1.7，阅读更舒服 */
    padding: var(--spacing-lg) 0 var(--spacing-xl);
    transition: var(--transition-base);
}

/* ==============================================
   5. 核心容器（优化：微调宽度，更居中的留白）
   ============================================== */
.container {
    max-width: 1140px; /* 优化：从1200→1140，更贴合现代容器宽度 */
    width: 94%; /* 优化：从95%→94%，左右留白更均匀 */
    margin: 0 auto;
    position: relative;
    z-index: 1;
}

/* ==============================================
   6. 标题区样式（优化：弱化分隔线，增加轻微背景，提升层级）
   ============================================== */
.page-header {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    padding: 0 0 var(--spacing-lg);
    border-bottom: 1px solid var(--border-light); /* 优化：更浅的分隔线 */
    position: relative;
}
.page-header h1 {
    font-size: 30px; /* 优化：从28→30，更醒目但不突兀 */
    color: var(--primary-color);
    margin-bottom: var(--spacing-sm);
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: var(--spacing-xs); /* 替换margin，更灵活 */
}
.subtitle {
    font-size: 15px; /* 优化：从14→15，阅读更舒服 */
    color: var(--text-light);
    line-height: 1.6;
    max-width: 600px;
    margin: 0 auto; /* 让副标题居中，适配小屏 */
}

/* ==============================================
   7. 核心内容区（优化：更大圆角、更柔和阴影、轻微内边距微调）
   现代卡片质感：圆润+柔和阴影+纯白背景，层级明显但不刺眼
   ============================================== */
.main-content {
    background: var(--bg-white);
    padding: var(--spacing-xl);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 2;
}

/* ==============================================
   8. 文本输入区样式（核心优化：质感提升，更柔和的边框/聚焦态）
   ============================================== */
.input-area {
    margin-bottom: var(--spacing-lg);
}
.input-area label {
    display: block;
    font-size: 16px;
    font-weight: 500;
    margin-bottom: var(--spacing-sm);
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
}
#text-input {
    width: 100%;
    height: 200px;
    padding: var(--spacing-md);
    border: 1px solid var(--border-light); /* 优化：更浅的边框，初始更柔和 */
    border-radius: var(--radius-md);
    font-size: 16px;
    color: var(--text-dark);
    line-height: 1.8;
    letter-spacing: 0.6px; /* 优化：轻微增大字间距，阅读更舒服 */
    background-color: var(--bg-white);
    transition: var(--transition-fast);
}
/* 输入框聚焦态：优化！更淡的阴影，柔化主色边框，不刺眼 */
#text-input:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(255, 120, 46, 0.08); /* 优化：更淡的聚焦阴影 */
}
/* 输入框占位符样式：优化颜色和字体，更柔和 */
#text-input::placeholder {
    color: var(--text-light);
    font-size: 15px;
    line-height: 1.8;
    opacity: 0.8;
}
#text-input:disabled {
    background-color: var(--bg-gray);
    cursor: not-allowed;
    color: var(--text-light);
    border-color: var(--border-light);
}

/* ==============================================
   9. 按钮区样式（核心优化：质感提升，渐变背景+柔和阴影，按压感更自然）
   ============================================== */
.btn-area {
    display: flex;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
    flex-wrap: wrap;
}
.btn-area button {
    padding: 14px var(--spacing-xl); /* 优化：增加上下内边距，按钮更饱满 */
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 500;
    transition: var(--transition-fast);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px; /* 图标和文字间距，固定更舒服 */
    flex: 1;
    max-width: 320px; /* 优化：增大最大宽度，按钮更舒展 */
    letter-spacing: 0.8px;
    position: relative;
    overflow: hidden; /* 隐藏渐变溢出 */
}
/* 主按钮：检测按钮 - 优化：增加轻微渐变，提升质感，不是纯平色 */
#check-btn {
    background: linear-gradient(120deg, var(--primary-color), var(--primary-dark));
    color: #fff;
}
#check-btn:hover {
    background: linear-gradient(120deg, var(--primary-dark), #e86414);
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px); /* 优化：轻微上移，hover更灵动 */
}
#check-btn:active {
    transform: translateY(0) scale(0.99); /* 优化：按压更自然，先复位再轻微缩放 */
    box-shadow: 0 2px 8px rgba(255, 120, 46, 0.1);
}
/* 检测中禁用态：优化透明度和阴影，更自然 */
#check-btn.checking {
    background: var(--primary-dark);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    opacity: 0.9;
}
/* 副按钮：清空按钮 - 优化：边框更浅，hover背景更柔和 */
#clear-btn {
    background-color: var(--bg-gray);
    color: var(--text-middle);
    border: 1px solid var(--border-light);
}
#clear-btn:hover {
    background-color: var(--bg-gray-hover);
    box-shadow: var(--shadow-sm);
    transform: translateY(-1px);
    border-color: var(--border-color);
}
#clear-btn:active {
    transform: translateY(0) scale(0.99);
    box-shadow: none;
}
#clear-btn:disabled {
    background-color: var(--border-light);
    color: var(--text-light);
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
    border-color: var(--border-light);
}

/* ==============================================
   10. 检测结果区样式（优化：虚线分隔线更淡，留白更均匀）
   ============================================== */
.result-area {
    display: none;
    padding-top: var(--spacing-lg);
    border-top: 1px dashed var(--border-light); /* 优化：更浅的虚线，不突兀 */
    position: relative;
    z-index: 2;
}
.result-area h3 {
    font-size: 18px;
    margin-bottom: var(--spacing-md);
    color: var(--text-dark);
    display: flex;
    align-items: center;
    font-weight: 600;
    gap: var(--spacing-xs);
}

/* ==============================================
   11. 结果统计样式（优化：更柔和的背景，轻微内阴影，提升卡片感）
   ============================================== */
.result-count {
    font-size: 16px;
    font-weight: 500;
    margin-bottom: var(--spacing-md);
    padding: var(--spacing-sm) var(--spacing-md);
    border-radius: var(--radius-md);
    line-height: 1.8;
    display: flex;
    align-items: center;
    gap: var(--spacing-xs);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02); /* 轻微内阴影，提升质感 */
}
.result-count.success {
    background-color: var(--success-light);
    color: var(--text-dark);
}
.result-count.danger {
    background-color: var(--danger-light);
    color: var(--text-dark);
}
/* 违禁词数量高亮：优化字体大小，不刺眼 */
.result-count strong {
    color: var(--danger-color);
    font-size: 19px;
    font-weight: 700;
    margin: 0 4px;
}

/* ==============================================
   12. 结果详情样式（核心优化：柔化边框，违禁词高亮更舒服，辨识度不变）
   ============================================== */
.result-detail {
    font-size: 16px;
    line-height: 2.1; /* 优化：从2→2.1，违禁词行间距更呼吸 */
    word-wrap: break-word;
    word-break: break-all;
    min-height: 90px; /* 优化：增大最小高度，避免空区域太局促 */
    padding: var(--spacing-md);
    border: 1px solid var(--border-light); /* 优化：更浅的边框 */
    border-radius: var(--radius-md);
    background-color: var(--bg-white);
    color: var(--text-dark);
    letter-spacing: 0.6px;
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.02);
}
/* 违禁词高亮：核心优化！柔化红色，增大圆角，轻微内边距，不扎眼但辨识度高 */
.banned-word {
    background-color: var(--danger-color);
    color: #ffffff;
    padding: 3px 8px; /* 优化：增大内边距，更饱满 */
    border-radius: var(--radius-sm);
    margin: 0 3px; /* 优化：增大左右间距，不拥挤 */
    font-weight: 500;
    white-space: nowrap;
    box-shadow: 0 1px 3px rgba(239, 68, 68, 0.2); /* 轻微阴影，提升高亮层级 */
}

/* ==============================================
   13. 页脚样式（优化：弱化文字，增加上间距，不抢注意力）
   ============================================== */
.page-footer {
    text-align: center;
    margin-top: var(--spacing-xl);
    padding: var(--spacing-sm) 0;
    position: relative;
    z-index: 1;
}
.page-footer p {
    font-size: 13px; /* 优化：从12→13，阅读更舒服但不抢镜 */
    color: var(--text-light);
    line-height: 1.6;
    opacity: 0.9;
}
.page-footer .copyright {
    margin-top: var(--spacing-xs);
    font-size: 12px;
    opacity: 0.8;
}

/* ==============================================
   14. 自定义滚动条（核心优化：更细的滑块，更柔和的颜色，贴合整体风格）
   ============================================== */
::-webkit-scrollbar {
    width: 8px; /* 优化：从6→8px，拖动更舒服 */
    height: 8px;
}
::-webkit-scrollbar-track {
    background: var(--border-light);
    border-radius: var(--radius-sm);
}
::-webkit-scrollbar-thumb {
    background: var(--border-color); /* 优化：初始更柔和的颜色 */
    border-radius: var(--radius-sm);
    transition: var(--transition-fast);
}
::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color); /* hover变主色，辨识度高 */
    opacity: 0.8;
}
/* 输入框/结果区滚动条：更细，适配小容器 */
#text-input::-webkit-scrollbar,
.result-detail::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
#text-input::-webkit-scrollbar-thumb:hover,
.result-detail::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
    opacity: 0.7;
}

/* ==============================================
   15. 文本选中样式（优化：更淡的主色背景，不刺眼，贴合整体）
   ============================================== */
::selection {
    background-color: rgba(255, 120, 46, 0.12); /* 优化：更淡的选中背景 */
    color: var(--primary-color);
}
::-moz-selection {
    background-color: rgba(255, 120, 46, 0.12);
    color: var(--primary-color);
}

/* ==============================================
   16. 移动端触摸反馈（保留，优化：更彻底的透明）
   ============================================== */
* {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
    tap-highlight-color: rgba(0, 0, 0, 0);
    -webkit-touch-callout: none; /* 禁止移动端长按菜单 */
}

/* ==============================================
   17. 媒体查询 - 三级自适应（优化：微调留白和字体，适配更自然）
   保持平板/手机/小手机三级，过渡更流畅
   ============================================== */
/* 平板端（768px - 1140px）：微调间距，适配平板横/竖屏 */
@media (max-width: 1140px) and (min-width: 768px) {
    .main-content {
        padding: calc(var(--spacing-xl) - 4px);
    }
    .page-header h1 {
        font-size: 28px;
    }
    .btn-area button {
        max-width: 300px;
    }
}
/* 手机端（≤768px）：核心适配，优化留白和按钮大小 */
@media (max-width: 768px) {
    .main-content {
        padding: var(--spacing-lg);
    }
    .page-header {
        margin-bottom: var(--spacing-lg);
        padding-bottom: var(--spacing-md);
    }
    .page-header h1 {
        font-size: 26px;
    }
    .input-area label, 
    #text-input, 
    .btn-area button, 
    .result-count, 
    .result-detail {
        font-size: 15px;
    }
    #text-input {
        height: 160px; /* 优化：从150→160，移动端输入更舒服 */
        line-height: 1.7;
        padding: var(--spacing-sm);
    }
    .btn-area button {
        padding: 12px var(--spacing-md);
        width: 100%;
        max-width: none;
        font-size: 15px;
    }
    .result-area h3 {
        font-size: 17px;
    }
    .result-count strong {
        font-size: 18px;
    }
    .banned-word {
        padding: 2px 7px;
        margin: 0 2px;
    }
}
/* 小手机端（≤480px，手机竖屏）：极致适配，优化手持体验 */
@media (max-width: 480px) {
    body {
        padding: var(--spacing-md) 0 var(--spacing-lg);
    }
    .container {
        width: 92%; /* 优化：从94→92%，左右更宽的留白，手持更舒服 */
    }
    .page-header h1 {
        font-size: 24px;
    }
    .main-content {
        padding: var(--spacing-md);
    }
    .input-area, .btn-area {
        margin-bottom: var(--spacing-md);
    }
    #text-input {
        height: 140px; /* 优化：从120→140，不局促 */
        padding: var(--spacing-sm);
    }
    .result-count {
        padding: var(--spacing-xs) var(--spacing-sm);
        font-size: 14px;
    }
    .result-detail {
        padding: var(--spacing-sm);
        line-height: 2;
        font-size: 14px;
        min-height: 80px;
    }
    .page-footer {
        margin-top: var(--spacing-lg);
    }
    .page-footer p {
        font-size: 12px;
    }
}

/* ==============================================
   18. 备用样式（保留，优化：更柔和的配色）
   ============================================== */
.result-empty {
    text-align: center;
    color: var(--text-light);
    padding: var(--spacing-xl) 0;
    font-size: 15px;
    opacity: 0.9;
}
.error-tip {
    color: var(--danger-color);
    font-size: 13px;
    margin-top: var(--spacing-xs);
    display: none;
    opacity: 0.9;
}
.error-tip.show {
    display: block;
}