/* ============================================
   查字数 chazishu.com - 在线字数统计工具
   版权所有 (c) 2026 chazishu.com
   未经授权禁止复制、修改或商业使用
   ============================================ */

/* === 基础重置 === */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background-color: #F8FAFC;
    color: #1E293B;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.6;
}

/* === 容器 === */
.chazishu-container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
    width: 100%;
}

/* === 导航 === */
.chazishu-nav {
    background: #fff;
    border-bottom: 1px solid #E2E8F0;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
    background: rgba(255, 255, 255, 0.95);
}

.chazishu-nav-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 56px;
}

.chazishu-logo {
    font-size: 1.1rem;
    font-weight: 700;
    color: #2563EB;
    text-decoration: none;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chazishu-logo-img {
    height: 28px;
    width: auto;
    display: block;
}

.chazishu-logo:hover {
    opacity: 0.85;
}

.chazishu-nav-links {
    display: flex;
    gap: 8px;
}

.chazishu-nav-links a {
    color: #64748B;
    text-decoration: none;
    font-size: 0.875rem;
    padding: 6px 12px;
    border-radius: 6px;
    transition: all 0.2s ease;
}

.chazishu-nav-links a:hover {
    color: #2563EB;
    background: #EFF6FF;
}

/* === 标题 === */
.chazishu-title {
    font-size: 1.75rem;
    font-weight: 700;
    text-align: center;
    margin: 32px 0 28px;
    color: #1E293B;
    letter-spacing: -0.02em;
}

/* === 主布局 === */
.chazishu-main-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 28px;
    align-items: start;
    margin-bottom: 40px;
}

/* === 输入区域 === */
.chazishu-input-section {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chazishu-input-wrapper {
    position: relative;
}

.chazishu-textarea {
    width: 100%;
    height: 400px;
    padding: 20px;
    font-size: 1rem;
    line-height: 1.7;
    border: 2px solid #E2E8F0;
    border-radius: 12px;
    resize: vertical;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    font-family: inherit;
    background: #fff;
    color: #1E293B;
}

.chazishu-textarea:focus {
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chazishu-textarea::placeholder {
    color: #94A3B8;
}

/* 清空按钮 */
.chazishu-clear-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 32px;
    height: 32px;
    border: none;
    background: #F1F5F9;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.875rem;
    color: #64748B;
    display: none;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
}

.chazishu-clear-btn:hover {
    background: #E2E8F0;
    color: #1E293B;
}

.chazishu-clear-btn.chazishu-visible {
    display: flex;
}

/* 隐私提示与保存状态 */
.chazishu-privacy-notice {
    font-size: 0.8rem;
    color: #94A3B8;
    text-align: center;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-wrap: wrap;
}

.chazishu-privacy-sep {
    color: #CBD5E1;
    font-size: 0.75rem;
}

#chazishu-save-status {
    color: #10B981;
    font-weight: 500;
}

.chazishu-save-time {
    color: #6B7280;
    font-weight: 400;
}

/* === 统计面板 === */
.chazishu-stats {
    background: #fff;
    border-radius: 12px;
    border: 1px solid #E2E8F0;
    padding: 24px;
    min-height: 200px;
}

/* 统计网格 */
.chazishu-stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 20px;
}

.chazishu-stat-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 14px 8px;
    background: #F8FAFC;
    border-radius: 10px;
    transition: background 0.2s ease;
}

.chazishu-stat-item:hover {
    background: #F1F5F9;
}

.chazishu-stat-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: #1E293B;
    line-height: 1.2;
    transition: opacity 0.2s ease;
}

.chazishu-stat-number.chazishu-animate {
    animation: chazishuFadeIn 0.2s ease;
}

@keyframes chazishuFadeIn {
    0% { opacity: 0.3; transform: translateY(-2px); }
    100% { opacity: 1; transform: translateY(0); }
}

.chazishu-stat-label {
    font-size: 0.8rem;
    color: #64748B;
    margin-top: 4px;
    text-align: center;
}

/* === Token 统计（特殊紫色） === */
.chazishu-stat-token {
    background: linear-gradient(135deg, #F5F3FF, #EDE9FE);
    border-radius: 10px;
    padding: 16px 20px;
    border: 1px solid #DDD6FE;
}

.chazishu-token-row {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.chazishu-token-row + .chazishu-token-row {
    margin-top: 6px;
}

.chazishu-token-number {
    color: #8B5CF6 !important;
    font-size: 1.3rem !important;
}

.chazishu-token-percent {
    color: #8B5CF6 !important;
    font-size: 1.1rem !important;
}

.chazishu-token-sub {
    font-size: 0.85rem;
}

.chazishu-token-sub .chazishu-stat-label {
    font-size: 0.8rem;
}

/* === 内页通用样式（隐私政策等） === */
.chazishu-page-content {
    max-width: 800px;
    padding-top: 20px;
    padding-bottom: 40px;
}

.chazishu-page-title {
    font-size: 1.6rem;
    font-weight: 700;
    color: #1E293B;
    margin-bottom: 8px;
}

.chazishu-page-meta {
    font-size: 0.85rem;
    color: #94A3B8;
    margin-bottom: 32px;
    padding-bottom: 16px;
    border-bottom: 1px solid #E2E8F0;
}

.chazishu-policy-section {
    margin-bottom: 28px;
}

.chazishu-policy-section h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: #2563EB;
    margin-bottom: 10px;
}

.chazishu-policy-section p {
    font-size: 0.92rem;
    color: #475569;
    line-height: 1.8;
}

.chazishu-policy-section a {
    color: #2563EB;
    text-decoration: underline;
}

.chazishu-policy-section a:hover {
    color: #1D4ED8;
}

@media (max-width: 768px) {
    .chazishu-page-title {
        font-size: 1.3rem;
    }

    .chazishu-policy-section h2 {
        font-size: 1rem;
    }

    .chazishu-policy-section p {
        font-size: 0.88rem;
    }
}

/* === 使用说明（SEO友好） === */
.chazishu-guide {
    background: #fff;
    border-top: 1px solid #E2E8F0;
    padding: 40px 0 32px;
    margin-top: 20px;
}

.chazishu-guide-title {
    font-size: 1.3rem;
    font-weight: 700;
    color: #1E293B;
    text-align: center;
    margin-bottom: 24px;
}

.chazishu-guide-content {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
}

.chazishu-guide-item {
    padding: 16px 20px;
    background: #F8FAFC;
    border-radius: 10px;
    border: 1px solid #F1F5F9;
}

.chazishu-guide-item h3 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #2563EB;
    margin-bottom: 8px;
}

.chazishu-guide-item p {
    font-size: 0.85rem;
    color: #475569;
    line-height: 1.7;
}

.chazishu-guide-item strong {
    color: #1E293B;
}

@media (max-width: 768px) {
    .chazishu-guide-content {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .chazishu-guide {
        padding: 28px 0 24px;
    }

    .chazishu-guide-title {
        font-size: 1.1rem;
    }
}

/* === 历史记录页面 === */
.chazishu-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.chazishu-history-header .chazishu-page-title {
    margin-bottom: 0;
}

.chazishu-btn-danger {
    padding: 8px 16px;
    border: 1px solid #FCA5A5;
    background: #FEF2F2;
    color: #DC2626;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.chazishu-btn-danger:hover {
    background: #FEE2E2;
    border-color: #F87171;
}

.chazishu-btn-primary {
    display: inline-block;
    padding: 10px 24px;
    background: #2563EB;
    color: #fff;
    border-radius: 8px;
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: background 0.2s ease;
    margin-top: 12px;
}

.chazishu-btn-primary:hover {
    background: #1D4ED8;
}

.chazishu-btn-secondary {
    padding: 8px 20px;
    border: 1px solid #E2E8F0;
    background: #fff;
    color: #475569;
    border-radius: 8px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.chazishu-btn-secondary:hover {
    background: #F8FAFC;
    border-color: #CBD5E1;
}

/* 历史记录列表 */
.chazishu-history-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.chazishu-history-item {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    padding: 16px 20px;
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 10px;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.chazishu-history-item:hover {
    border-color: #93C5FD;
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.08);
}

.chazishu-history-item-main {
    flex: 1;
    min-width: 0;
}

.chazishu-history-item-preview {
    font-size: 0.9rem;
    color: #1E293B;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.chazishu-history-item-meta {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 8px;
    font-size: 0.78rem;
    color: #94A3B8;
}

.chazishu-history-item-actions {
    display: flex;
    gap: 6px;
    flex-shrink: 0;
    padding-top: 2px;
}

.chazishu-btn-view {
    padding: 6px 14px;
    border: 1px solid #BFDBFE;
    background: #EFF6FF;
    color: #2563EB;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.chazishu-btn-view:hover {
    background: #DBEAFE;
    border-color: #93C5FD;
}

.chazishu-btn-del {
    padding: 6px 14px;
    border: 1px solid #FECACA;
    background: #FEF2F2;
    color: #DC2626;
    border-radius: 6px;
    font-size: 0.8rem;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.chazishu-btn-del:hover {
    background: #FEE2E2;
    border-color: #FCA5A5;
}

/* 空状态 */
.chazishu-history-empty {
    text-align: center;
    padding: 60px 20px;
    background: #fff;
    border: 1px solid #E2E8F0;
    border-radius: 12px;
}

.chazishu-history-empty p {
    font-size: 0.95rem;
    color: #94A3B8;
    margin-bottom: 6px;
}

.chazishu-history-empty p:first-child {
    font-size: 1.2rem;
    color: #64748B;
    margin-bottom: 10px;
}

/* === 模态框 === */
.chazishu-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.chazishu-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
}

.chazishu-modal-content {
    position: relative;
    background: #fff;
    border-radius: 14px;
    width: 100%;
    max-width: 640px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    animation: chazishuModalIn 0.2s ease;
}

@keyframes chazishuModalIn {
    0% { opacity: 0; transform: scale(0.95) translateY(10px); }
    100% { opacity: 1; transform: scale(1) translateY(0); }
}

.chazishu-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid #E2E8F0;
}

.chazishu-modal-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1E293B;
}

.chazishu-modal-close {
    width: 32px;
    height: 32px;
    border: none;
    background: #F1F5F9;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.9rem;
    color: #64748B;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-family: inherit;
}

.chazishu-modal-close:hover {
    background: #E2E8F0;
    color: #1E293B;
}

.chazishu-modal-body {
    padding: 20px 24px;
    overflow-y: auto;
    flex: 1;
}

.chazishu-modal-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 0.82rem;
    color: #64748B;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid #F1F5F9;
    flex-wrap: wrap;
}

.chazishu-modal-text {
    font-size: 0.92rem;
    line-height: 1.8;
    color: #1E293B;
    white-space: pre-wrap;
    word-break: break-word;
    font-family: inherit;
    background: #F8FAFC;
    padding: 16px;
    border-radius: 8px;
    border: 1px solid #F1F5F9;
    max-height: 400px;
    overflow-y: auto;
}

.chazishu-modal-footer {
    padding: 14px 24px;
    border-top: 1px solid #E2E8F0;
    display: flex;
    justify-content: flex-end;
}

/* 导航激活状态 */
.chazishu-nav-active {
    color: #2563EB !important;
    background: #EFF6FF !important;
    font-weight: 500;
}

/* === 朗读版控制面板 === */
.chazishu-langdu-panel {
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.chazishu-langdu-panel-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: #1E293B;
    padding-bottom: 12px;
    border-bottom: 1px solid #E2E8F0;
}

.chazishu-langdu-control {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chazishu-langdu-label {
    font-size: 0.88rem;
    font-weight: 500;
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chazishu-langdu-select {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.9rem;
    border: 2px solid #E2E8F0;
    border-radius: 8px;
    background: #fff;
    color: #1E293B;
    outline: none;
    cursor: pointer;
    transition: border-color 0.2s ease;
    font-family: inherit;
    appearance: auto;
}

.chazishu-langdu-select:focus {
    border-color: #2563EB;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.chazishu-langdu-slider {
    width: 100%;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: #E2E8F0;
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.chazishu-langdu-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2563EB;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
    transition: transform 0.15s ease;
}

.chazishu-langdu-slider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.chazishu-langdu-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2563EB;
    cursor: pointer;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.chazishu-langdu-slider-labels {
    display: flex;
    justify-content: space-between;
    font-size: 0.72rem;
    color: #94A3B8;
    padding: 0 2px;
}

/* 朗读按钮 */
.chazishu-langdu-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.chazishu-langdu-btn {
    flex: 1;
    min-width: 100px;
    padding: 12px 16px;
    border: none;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    text-align: center;
}

.chazishu-langdu-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.chazishu-langdu-btn-play {
    background: #2563EB;
    color: #fff;
}

.chazishu-langdu-btn-play:hover:not(:disabled) {
    background: #1D4ED8;
}

.chazishu-langdu-btn-pause {
    background: #F59E0B;
    color: #fff;
}

.chazishu-langdu-btn-pause:hover:not(:disabled) {
    background: #D97706;
}

.chazishu-langdu-btn-stop {
    background: #EF4444;
    color: #fff;
}

.chazishu-langdu-btn-stop:hover:not(:disabled) {
    background: #DC2626;
}

/* 朗读状态 */
.chazishu-langdu-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #F8FAFC;
    border-radius: 8px;
    border: 1px solid #F1F5F9;
}

.chazishu-langdu-status-icon {
    font-size: 1.1rem;
}

.chazishu-langdu-status-text {
    font-size: 0.85rem;
    color: #64748B;
}

/* 朗读进度 */
.chazishu-langdu-progress {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.chazishu-langdu-progress-bar {
    width: 100%;
    height: 6px;
    background: #E2E8F0;
    border-radius: 3px;
    overflow: hidden;
}

.chazishu-langdu-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #2563EB, #8B5CF6);
    border-radius: 3px;
    transition: width 0.3s ease;
}

.chazishu-langdu-progress-text {
    font-size: 0.78rem;
    color: #94A3B8;
    text-align: right;
}

/* === 底部 === */
.chazishu-footer {
    margin-top: auto;
    border-top: 1px solid #E2E8F0;
    padding: 24px 0;
    text-align: center;
    background: #fff;
}

.chazishu-footer p {
    font-size: 0.8rem;
    color: #94A3B8;
}

.chazishu-footer-links {
    margin-top: 6px;
}

.chazishu-footer-links a {
    color: #64748B;
    text-decoration: none;
    transition: color 0.2s ease;
}

.chazishu-footer-links a:hover {
    color: #2563EB;
}

.chazishu-footer-sep {
    margin: 0 8px;
    color: #CBD5E1;
}

/* === 响应式 === */
@media (max-width: 768px) {
    .chazishu-main-layout {
        grid-template-columns: 1fr;
        gap: 20px;
    }

    .chazishu-title {
        font-size: 1.35rem;
        margin: 24px 0 20px;
    }

    .chazishu-textarea {
        height: 300px;
        padding: 16px;
        font-size: 0.95rem;
    }

    .chazishu-stats {
        padding: 18px;
    }

    .chazishu-stats-grid {
        gap: 12px;
    }

    .chazishu-stat-number {
        font-size: 1.25rem;
    }

    .chazishu-stat-item {
        padding: 12px 6px;
    }

    .chazishu-nav-links a {
        font-size: 0.8rem;
        padding: 4px 8px;
    }

    .chazishu-logo {
        font-size: 1rem;
    }
}

@media (max-width: 480px) {
    .chazishu-container {
        padding: 0 14px;
    }

    .chazishu-stats-grid {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .chazishu-stat-item {
        padding: 10px 4px;
    }

    .chazishu-stat-number {
        font-size: 1.1rem;
    }

    .chazishu-stat-label {
        font-size: 0.75rem;
    }

    .chazishu-nav-links {
        gap: 4px;
    }

    .chazishu-nav-links a {
        font-size: 0.75rem;
        padding: 4px 6px;
    }
}
