body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background: linear-gradient(to bottom right, #f8fdfa, #e0f2f4);
    color: #333;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    background-attachment: fixed;
}

.container {
    max-width: 1000px;
    width: 95%;
    margin: 30px auto 10px auto;
    background: #fff;
    padding: 30px 40px;
    border-radius: 12px;
    box-shadow: 0 6px 20px rgba(0,0,0,0.08);
    flex-shrink: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

header {
    text-align: center;
    margin-bottom: 30px;
}

h1 {
    color: #5ac1a6; /* 薄荷绿 */
    margin-bottom: 0.3em;
    font-size: 2.2em;
}

h2 {
     color: #4a4a4a; /* 柔和深灰 */
     margin-top: 0;
     margin-bottom: 1em;
     font-size: 1.5em;
     border-bottom: 1px solid #eee;
     padding-bottom: 8px;
     font-weight: normal;
}

/* 移除旧的 .warning-note 样式 */
/* .warning-note { ... } */

/* Tabs 样式 */
.tabs {
    display: flex;
    margin-bottom: 25px;
    border-bottom: 2px solid #5ac1a6;
    justify-content: center;
    padding-bottom: 0;
    flex-wrap: wrap;
}

.tab-button {
    padding: 12px 25px;
    cursor: pointer;
    border: none;
    background-color: #e0f2f4;
    margin: 0 3px;
    border-radius: 8px 8px 0 0;
    font-size: 1em;
    font-weight: bold;
    transition: background-color 0.3s ease, color 0.3s ease;
    flex-grow: 1;
    text-align: center;
    min-width: 120px;
    box-sizing: border-box;
}

.tab-button:hover:not(.active) {
    background-color: #c7e6ea;
}

.tab-button.active {
    background-color: #5ac1a6;
    color: white;
    position: relative;
    bottom: -2px;
    border-bottom: 2px solid #5ac1a6;
}

/* Tab 内容样式 */
.tab-content {
    display: none;
    padding-top: 25px;
    flex-grow: 1;
}

.tab-content.active {
    display: block;
}

/* 两列布局 */
.content-layout {
    display: flex;
    gap: 40px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    flex-grow: 1;
    align-items: stretch; /* 保证左右两侧等高 */
}

.left-panel,
.right-panel {
    flex: 1;
    min-width: 300px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

/* 确保每个界面的左右面板高度匹配 */
/* 嵌入水印界面 */
#embed .left-panel,
#embed .right-panel {
    min-height: 450px; /* 基础最小高度 */
    display: flex;
    flex-direction: column;
}

#embed .left-panel .form-group:last-child {
    flex-grow: 1; /* 让最后一个表单组（文本区域）填充剩余空间 */
}

#embed .right-panel .result-group {
    flex-grow: 1; /* 让结果组填充空间 */
    display: flex;
    flex-direction: column;
}

/* 提取水印界面 */
#extract .left-panel,
#extract .right-panel {
    min-height: 350px;
    display: flex;
    flex-direction: column;
}

#extract .left-panel .form-group:last-child {
    flex-grow: 1; /* 让包含文本框的表单组填充剩余空间 */
}

#extract .right-panel .result-group {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* 清除零宽字符界面 */
#clean .left-panel,
#clean .right-panel {
    min-height: 300px;
    display: flex;
    flex-direction: column;
}

#clean .left-panel .form-group {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

#clean .right-panel .result-group {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* 右侧面板内文本区域高度设置 */
.right-panel textarea,
.right-panel .output-display {
    height: auto; /* 改为自动高度 */
    min-height: 150px; /* 最小高度 */
    flex-grow: 1; /* 让它填充可用空间 */
    overflow: auto;
    resize: vertical; /* 允许用户手动拉伸（可选） */
}

/* 左侧面板文本框也要自动填充空间 */
.left-panel textarea {
    flex-grow: 1;
    min-height: 150px;
}

.form-group {
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
}

label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
    font-weight: bold;
    color: #555;
    font-size: 1em;
    flex-shrink: 0;
}

/* 字符计数 span 样式 */
.char-count {
    font-weight: normal;
    font-size: 0.9em;
    color: #6c757d;
    margin-left: 10px;
    flex-shrink: 0;
}

input[type="text"],
input[type="password"],
textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid #ced4da;
    border-radius: 6px;
    box-sizing: border-box;
    font-size: 1em;
    font-family: inherit;
    color: #495057;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

input[type="text"]:focus,
input[type="password"]:focus,
textarea:focus {
    border-color: #99d5c9;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(90, 193, 166, 0.25);
}

/* Slider 特殊样式 */
.slider-container {
     display: flex;
     align-items: center;
     gap: 10px;
     margin-bottom: 5px;
     width: 100%;
}
.slider-container input[type="range"] {
    width: auto;
    max-width: none;
}

input[type="range"] {
    flex-grow: 1;
    margin: 0;
    padding: 0;
    -webkit-appearance: none;
    appearance: none;
    background: #ddd;
    border-radius: 5px;
    height: 8px;
    cursor: pointer;
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #5ac1a6;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

input[type="range"]::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #5ac1a6;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.15s ease-in-out;
}

input[type="range"]::-webkit-slider-thumb:hover,
input[type="range"]::-moz-range-thumb:hover {
     background: #45a08c;
}

#density-value {
    display: inline-block;
    width: 50px;
    text-align: right;
    font-weight: bold;
    color: #5ac1a6;
    font-variant-numeric: tabular-nums;
    flex-shrink: 0;
}

small {
    display: block;
    color: #6c757d;
    font-size: 0.85em;
    margin-top: 5px;
}

/* Buttons */
.button-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    margin-top: 15px;
    margin-bottom: 20px;
}

.action-button {
    padding: 14px 30px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 1.1em;
    font-weight: bold;
    transition: background-color 0.3s ease, opacity 0.3s ease;
    min-width: 200px;
}

.action-button.primary {
     background-color: #5ac1a6;
     color: white;
}

.action-button.primary:hover {
    background-color: #45a08c;
}

.action-button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
    opacity: 0.7;
}

.copy-button {
    background-color: #6c757d;
    color: white;
    padding: 10px 15px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95em;
    margin-top: 10px;
    display: inline-block;
    transition: background-color 0.3s ease;
}

.copy-button:hover {
    background-color: #5a6268;
}

/* Output Display (for p elements acting as display) */
.output-display {
    background-color: #e9ecef;
    padding: 15px;
    border-radius: 6px;
    min-height: 5em;
    word-break: break-word;
    white-space: pre-wrap;
    border: 1px solid #ced4da;
    color: #495057;
    overflow: auto;
    font-size: 0.95em;
    flex-grow: 0; /* Changed from 1 to 0 to prevent expansion */
    display: block;
    margin-bottom: 10px;
    box-sizing: border-box;
    max-height: 200px; /* Added max-height to limit vertical growth */
}

#extract-output {
    height: 350px; /* Increased height to match left panel */
    max-height: 350px; /* Match with height */
    overflow-y: auto;
}

#clean-output {
    height: 200px; 
    max-height: 200px;
    overflow-y: auto;
}

textarea#embed-output {
    min-height: 150px;
}

/* --- 通知容器和通知框 (用于操作结果提示) --- */

#notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1050;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    width: 100%;
    max-width: 400px;
    padding: 0;
    box-sizing: border-box;
    overflow-x: hidden; /* Prevent horizontal overflow on container */
}

.notification-box {
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    font-size: 1em;
    /* 添加最小高度，防止内容极少时高度塌陷 */
     min-height: 40px;
    opacity: 1;
    transition: opacity 0.4s ease-out, transform 0.4s ease-out;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    word-break: break-word;
    overflow-wrap: break-word;
    flex-shrink: 0;
    width: 100%; /* Ensure box uses up to max-width of container */
    max-width: none; /* Override max-width: 400px from container for flexible wrapping */
    box-sizing: border-box;
    /* Ensure text content does not force box wider than container */
     overflow-x: hidden;
}

.notification-box.hiding {
     opacity: 0;
     transform: translateX(20px);
}

.notification-box .message {
    flex-grow: 1;
    word-break: break-word;
    overflow-wrap: break-word;
}

/* Notification Status Colors */
.notification-box.info {
     background-color: #d0f2f9;
     color: #0c5460;
     border-left: 4px solid #bee5eb;
}
.notification-box.success {
     background-color: #d4edda;
     color: #155724;
     border-left: 4px solid #c3e6cb;
}
.notification-box.warning {
     background-color: #fff3cd;
     color: #856404;
     border-left: 4px solid #ffeeba;
}
.notification-box.error {
     background-color: #f8d7da;
     color: #721c24;
     border-left: 4px solid #f5c6cb;
}

/* --- 新增：初次访问重要提示弹窗 Modal --- */

.modal-overlay {
    position: fixed; /* 固定定位 */
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5); /* 半透明黑色背景 */
    backdrop-filter: blur(2px); /* 可选：背景模糊 */
    display: flex;
    justify-content: center; /* 水平居中 */
    align-items: center; /* 垂直居中 */
    z-index: 2000; /* 确保在通知框之上 */
    /* 初始隐藏 */
    visibility: hidden;
    opacity: 0;
    transition: opacity 0.3s ease, visibility 0.3s ease; /* 过渡动画 */
}

.modal-overlay.visible {
    visibility: visible;
    opacity: 1;
}

.modal-content {
    background-color: #fff; /* 白色背景 */
    padding: 30px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3); /* 阴影 */
    text-align: left; /* 内容左对齐 */
    max-width: 500px; /* 最大宽度 */
    width: 90%; /* 小屏幕下占宽度比例 */
    position: relative; /* 用于内部元素的定位 */
    /* 动画：从上方稍微滑入 */
    transform: translateY(-30px);
    transition: transform 0.3s ease;
}
/* 当 overlay 可见时，modal content 恢复原位 */
.modal-overlay.visible .modal-content {
    transform: translateY(0);
}

.modal-content .modal-message {
    margin-bottom: 20px; /* 消息内容下方间距 */
    line-height: 1.8;
}
.modal-content .modal-message p {
    margin-bottom: 1em; /* 段落间距 */
}

.modal-content .modal-footer {
    text-align: center; /* 底部按钮居中 */
}

.modal-close {
    background-color: #5ac1a6; /* 主色调按钮 */
    color: white;
    border: none;
    padding: 10px 25px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1em;
    transition: background-color 0.3s ease;
}

.modal-close:hover {
    background-color: #45a08c; /* 鼠标悬停稍深 */
}

/* Footer */
footer {
    margin-top: 40px;
    padding: 20px;
    text-align: center;
    color: #6c757d;
    font-size: 0.9em;
    width: 100%;
    flex-shrink: 0;
    box-sizing: border-box;
}

footer a {
    color: #007bff;
    text-decoration: none;
    transition: color 0.3s ease;
}

footer a:hover {
    color: #0056b3;
    text-decoration: underline;
}

/* Responsive adjustments */
@media (max-width: 850px) {
    .container {
        padding: 25px 25px;
    }
    .content-layout {
        flex-direction: column;
        gap: 30px;
    }

    .left-panel,
    .right-panel {
        min-width: auto;
    }
    
    /* 在移动视图中，每个面板使用固定最小高度 */
    #embed .left-panel, #embed .right-panel,
    #extract .left-panel, #extract .right-panel,
    #clean .left-panel, #clean .right-panel {
        min-height: auto;
    }
    
    .left-panel textarea,
    .right-panel textarea {
        min-height: 120px;
        height: auto;
    }
    
    /* 保持输出显示区域的固定高度 */
    #clean-output, #extract-output {
        height: 180px; /* 略微减小在较小屏幕上的高度 */
        max-height: 180px;
    }
}

@media (max-width: 480px) {
    .container {
         padding: 15px 15px;
    }
    h1 { font-size: 1.6em; }
    h2 { font-size: 1.1em; }

    .tab-button {
         font-size: 0.9em;
         padding: 10px 15px;
         min-width: auto;
    }
    .action-button {
         font-size: 1em;
    }
    
    .left-panel textarea,
    .right-panel textarea {
        min-height: 90px;
        height: auto;
    }
    
    /* 保持输出显示区域的固定高度 */
    #clean-output, #extract-output {
        height: 150px; /* 在最小屏幕上进一步减小高度 */
        max-height: 150px;
    }
    
    footer {
         font-size: 0.8em;
         padding: 15px;
    }
}

/* 水印长度信息指示器样式 */
#watermark-length-info {
    display: inline-block;
    font-size: 0.85em;
    padding: 2px 8px;
    border-radius: 4px;
    transition: all 0.3s ease;
    font-weight: 500;
}

#watermark-length-info.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

#watermark-length-info.warning {
    background-color: #fff3cd;
    color: #856404;
    border: 1px solid #ffeeba;
}

#watermark-length-info.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
