/* 全局变量与基础样式 */
:root {
    --primary: #7c4dff;
    --danger: #ff5252;
    --default: #607d8b;
    --express: #ff9800;
    --border: #e0e0e0;
    --border-dashed: #ccc;
    --text-primary: #333;
    --text-secondary: #666;
    --bg-light: #f5f5f5;
    --bg-dark: #121212;
    --input-bg-light: #fff;
    --input-text-light: #333;
    --input-placeholder-light: #999;
    --input-bg-dark: #2d2d2d;
    --input-text-dark: #fff;
    --input-placeholder-dark: #888;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

body {
    background-color: var(--bg-light);
    color: var(--text-primary);
    line-height: 1.6;
    padding: 20px;
    transition: all 0.3s ease;
}

body.dark-mode {
    background-color: var(--bg-dark);
    color: #fff;
    --border: #333;
    --border-dashed: #444;
    --text-primary: #fff;
    --text-secondary: #aaa;
    --bg-light: #1e1e1e;
}

.container {
    max-width: 800px;
    margin: 0 auto;
}

/* 密文破译模块 */
.decrypt-module {
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}

.dark-mode .decrypt-module {
    background: #1e1e1e;
}

.decrypt-module h3 {
    font-size: 20px;
    margin-bottom: 15px;
    color: var(--primary);
}

.form-group {
    margin-bottom: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-secondary);
}

/* 输入框样式 - 白天模式 */
.form-control {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: all 0.2s ease;
    background: var(--input-bg-light);
    color: var(--input-text-light);
}

.form-control::placeholder {
    color: var(--input-placeholder-light);
}

.form-control.short {
    max-width: 300px;
}

/* 输入框样式 - 暗黑模式 */
.dark-mode .form-control {
    background-color: var(--input-bg-dark);
    border-color: #444;
    color: var(--input-text-dark);
}

.dark-mode .form-control::placeholder {
    color: var(--input-placeholder-dark);
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
}

.dark-mode .form-control:focus {
    background-color: #333;
}

/* 按钮组基础样式 - 图标与文字隔开 + 按钮缩小 */
.btn-group {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.btn {
    padding: 10px 18px; /* 缩小按钮内边距 */
    border: none;
    border-radius: 8px;
    font-size: 16px; /* 缩小按钮字体 */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px; /* 图标和文字之间的间距 */
    flex-direction: column; /* 移动端图标在上，文字在下 */
}

/* 桌面端按钮恢复水平布局 */
@media (min-width: 768px) {
    .btn {
        flex-direction: row;
        font-size: 14px;
        padding: 10px 18px;
    }
}

.btn-primary {
    background: var(--primary);
}

.btn-danger {
    background: #ff5252;
}

.btn-default {
    background: #607d8b;
}

/* 按钮颜色 - 暗黑模式（保持彩色+白色文字） */
.dark-mode .btn {
    color: #fff;
}

/* 移动端解密按钮布局调整 */
@media (max-width: 767px) {
    .decrypt-module .btn-group {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }
    .decrypt-module .btn-group #decrypt-btn {
        grid-column: 1 / -1; /* 立即破译占满整行，放到最下方 */
    }
    .decrypt-module .btn-group .btn-danger,
    .decrypt-module .btn-group .btn-default {
        grid-column: span 1; /* 清空内容、一键粘贴各占一半，放到上方 */
    }
}

/* 底部导航按钮组 - 双列对齐 + 虚线分隔 */
.nav-btn-group {
    margin: 24px 0;
    padding: 16px;
    border: 2px solid var(--border);
    border-radius: 12px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    position: relative;
}

/* 列之间的竖虚线 */
.nav-btn-group::before {
    content: '';
    position: absolute;
    top: 16px;
    bottom: 16px;
    left: 50%;
    width: 1px;
    background: repeating-linear-gradient(
        to bottom,
        var(--border-dashed),
        var(--border-dashed) 4px,
        transparent 4px,
        transparent 8px
    );
    transform: translateX(-50%);
}

.nav-left, .nav-right {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* 行之间的横虚线 */
.nav-left .nav-btn:not(:last-child),
.nav-right .nav-btn:not(:last-child) {
    position: relative;
    margin-bottom: 12px;
}

.nav-left .nav-btn:not(:last-child)::after,
.nav-right .nav-btn:not(:last-child)::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -6px;
    height: 1px;
    background: repeating-linear-gradient(
        to right,
        var(--border-dashed),
        var(--border-dashed) 4px,
        transparent 4px,
        transparent 8px
    );
}

.nav-btn {
    width: 100%;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s ease;
    background: #424242;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px; /* 导航按钮图标与文字间距 */
}

/* 快递查询按钮特殊颜色 */
.nav-btn.express-btn {
    background: var(--express);
}

/* 白天模式下导航按钮颜色修正 */
body:not(.dark-mode) .nav-btn {
    background: #424242;
    color: #fff;
}

body:not(.dark-mode) .nav-btn.express-btn {
    background: var(--express);
}

/* 暗黑模式下导航按钮 */
.dark-mode .nav-btn {
    background: #333;
    color: #fff;
}

.dark-mode .nav-btn.express-btn {
    background: var(--express);
}

/* 「正在添加」按钮样式 */
.nav-btn.disabled {
    background: #333;
    color: #666;
    cursor: not-allowed;
    opacity: 0.7;
}
.dark-mode .nav-btn.disabled {
    background: #222;
    color: #555;
}

/* 快递查询结果 - 物流订单详情样式 + 与按钮间距 + 字号缩小 */
.express-order {
    margin-top: 16px;
}
.express-order .order-header {
    background: var(--bg-light);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 12px;
}
.dark-mode .express-order .order-header {
    background: #2d2d2d;
}
.express-order .order-header h4 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.express-order .order-header p {
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary);
}

.express-order .order-info p {
    padding: 8px 0;
    border-bottom: 1px dashed var(--border-dashed);
    font-size: 14px;
}

.express-order .order-info p:last-child {
    border-bottom: none;
}

.express-order .order-tips {
    margin-top: 10px;
    padding: 8px;
    font-size: 12px;
    color: var(--text-secondary);
    border-top: 1px dashed var(--border-dashed);
}

/* 物流轨迹样式 */
.express-routes .routes-list {
    max-height: 300px;
    overflow-y: auto;
    font-size: 13px;
    line-height: 1.8;
}

/* 弹窗与其他模块样式 */
.module-container {
    display: none;
}

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.popup-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* 移动端弹窗可滚动 */
.module-popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.dark-mode .module-popup {
    background: #1e1e1e;
}

.module-popup.active {
    opacity: 1;
    visibility: visible;
}

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.close-btn {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.overlay.active {
    opacity: 1;
    visibility: visible;
}

.popup {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 24px;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.dark-mode .popup {
    background: #1e1e1e;
}

.popup.active {
    opacity: 1;
    visibility: visible;
}

.popup-title {
    font-size: 18px;
    font-weight: 500;
}

.popup-close {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

/* 复制按钮右下角显示 */
.popup .btn-copy {
    margin-top: 20px;
    display: block;
    margin-left: auto;
}

.copy-toast {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #4caf50;
    color: #fff;
    padding: 10px 20px;
    border-radius: 8px;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.copy-toast.active {
    opacity: 1;
    visibility: visible;
}

.settings-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(124, 77, 255, 0.4);
}

.settings-panel {
    position: fixed;
    bottom: 90px;
    right: 20px;
    background: #fff;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.dark-mode .settings-panel {
    background: #1e1e1e;
}

.settings-panel.active {
    opacity: 1;
    visibility: visible;
}

.settings-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.toggle-switch {
    width: 48px;
    height: 24px;
    background: #ccc;
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: all 0.2s ease;
}

.toggle-switch.active {
    background: var(--primary);
}

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: #fff;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: all 0.2s ease;
}

.toggle-switch.active::after {
    left: 26px;
}

.select-wrapper {
    position: relative;
    width: 100%; /* 让选择框容器占满宽度 */
}

.custom-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: #fff;
    font-size: 14px;
    width: 100%; /* 选择框宽度100%，与内容框对齐 */
}

.dark-mode .custom-select {
    background: #2d2d2d;
    border-color: #444;
    color: #fff;
}

/* --- 核心修改：让密语类型/关键词选择框与内容框宽度完全对齐 --- */
/* 待加密内容保持原有布局（标签在上，输入框在下） */
.module-popup .form-group:first-child {
    display: block;
}
.module-popup .form-group:first-child label {
    display: block;
    margin-bottom: 8px;
}
.module-popup .form-group:first-child .form-control {
    width: 100%;
}

/* 密语类型/关键词行：flex布局，标签+虚线+输入框，输入框宽度100% */
.module-popup .form-group:not(:first-child) {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}
.module-popup .form-group:not(:first-child) label {
    min-width: 20px;
    text-align: left;
    margin-bottom: 0;
}
/* 中间虚线分隔 */
.module-popup .form-group:not(:first-child)::after {
/*     content: '';
    flex: 1;*/
    height: 1px;
    background: repeating-linear-gradient(
        to right,
        var(--border-dashed),
        var(--border-dashed) 4px,
        transparent 4px,
        transparent 8px
    );
    margin: 0 10px;
}
/* 输入框/选择框宽度100%，与上方内容框完全对齐 */
.module-popup .form-group:not(:first-child) .form-control,
.module-popup .form-group:not(:first-child) .select-wrapper {
    flex: 1;
    width: 100%;
}
/* --- 核心修改结束 --- */

/* 关键词查询表格样式 */
.keyword-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 10px;
}

.keyword-table th, .keyword-table td {
    padding: 8px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.keyword-table th {
    background: var(--bg-light);
    font-weight: 500;
}

.dark-mode .keyword-table th {
    background: #2d2d2d;
}

.time-wrapper {
    display: flex;
    align-items: center;
    gap: 4px;
}

.time-wrapper .date {
    font-size: 12px;
    color: var(--text-secondary);
}

.time-wrapper .divider {
    width: 1px;
    height: 10px;
    background: var(--border);
}

.time-wrapper .time {
    font-size: 12px;
    color: var(--text-secondary);
}

.btn-copy-plain {
    padding: 4px 8px;
    font-size: 12px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    white-space: nowrap;
}

.top-plain-copy {
    display: none;
    align-items: center;
    gap: 8px;
    margin-top: 10px;
    padding: 8px;
    background: var(--bg-light);
    border-radius: 6px;
}

.dark-mode .top-plain-copy {
    background: #2d2d2d;
}

.top-plain-copy input {
    flex: 1;
    padding: 6px;
    border: 1px solid var(--border);
    border-radius: 4px;
    background: #fff;
}

.dark-mode .top-plain-copy input {
    background: #333;
    border-color: #444;
    color: #fff;
}

.inspire-text {
    margin-top: 10px;
    color: #67c23a;
    font-size: 14px;
}

/* 新增：一言弹窗样式（复用现有样式，无额外修改） */
#hitokoto-content {
    background-color: var(--bg-light);
}
.dark-mode #hitokoto-content {
    background-color: #2d2d2d;
}