* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    overflow: hidden;
}

@media (max-width: 768px) {
    html, body {
        height: auto;
        min-height: 100%;
        overflow-y: auto;
        overflow-x: hidden;
    }
}

:root {
    --bg-dark: #1a1a2e;
    --bg-panel: #16213e;
    --bg-display: #0f3460;
    --accent: #e94560;
    --accent-glow: rgba(233, 69, 96, 0.5);
    --text-light: #eaeaea;
    --text-dim: #a0a0a0;
    --success: #00d26a;
    --warning: #ffd700;
    --shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    --radius: 16px;
    --transition: all 0.2s ease;
    --text-xs: 0.72rem;
    --text-sm: 0.8rem;
    --text-md: 0.95rem;
    --scanline-speed: 4s;
}

body {
    font-family: 'Microsoft YaHei', 'PingFang SC', 'Hiragino Sans GB', sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
    color: var(--text-light);
    height: 100%;
}

.container {
    max-width: 100%;
    margin: 0 auto;
    padding: 15px;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* 顶部控制栏 */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 16px;
    background: transparent; /* 去掉背景色 */
    border-radius: var(--radius);
    margin-bottom: 15px;
    flex-shrink: 0;
}

.title-section h1 {
    font-size: 1.4rem;
    color: var(--accent);
    text-shadow: 0 0 20px var(--accent-glow);
    margin-bottom: 2px;
}

.title-section .subtitle {
    font-size: var(--text-xs);
    color: var(--text-dim);
    text-align: right;
    padding-right: 2px;
}

.controls-section {
    display: flex;
    gap: 18px;
    align-items: stretch;
    width: 100%;
    max-width: 520px;
}

.control-item {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 6px 6px;
    background: transparent;
    border-radius: var(--radius);
    min-width: 0;
}

.control-item.speed-control {
    flex: 3; /* 使用比例分配空间，自动处理 gap */
    min-width: 0; /* 防止内容溢出 */
}

.control-item.volume-control {
    flex: 2; /* 使用比例分配空间 */
    min-width: 0;
}

.control-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.control-item label {
    font-size: var(--text-sm);
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    flex: 1;
    text-align: right;
}

.control-value {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.25);
    color: var(--accent);
    font-weight: 700;
}

.control-value input[type="number"] {
    width: 56px;
    background: transparent;
    border: none;
    color: var(--accent);
    font-weight: 700;
    text-align: right;
    font-size: var(--text-sm);
    font-family: inherit;
    outline: none;
}

.control-unit {
    font-size: var(--text-xs);
    color: var(--text-dim);
}

.speed-level-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-dim);
    margin-left: 4px;
    transition: var(--transition);
    white-space: nowrap;
}

.speed-level-badge.level-novice {
    background: rgba(0, 210, 106, 0.2);
    color: var(--success);
}

.speed-level-badge.level-qualified {
    background: rgba(255, 215, 0, 0.2);
    color: var(--warning);
}

.speed-level-badge.level-professional {
    background: rgba(233, 69, 96, 0.2);
    color: var(--accent);
}

.speed-level-badge.level-competition {
    background: linear-gradient(135deg, #ff00cc, #333399);
    color: white;
    text-shadow: 0 0 5px rgba(255, 255, 255, 0.5);
}

.control-slider {
    display: flex;
    align-items: center;
    gap: 10px;
}

.control-slider input[type="range"] {
    flex: 1;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 999px;
    outline: none;
    -webkit-appearance: none;
}

.control-slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 18px;
    height: 18px;
    background: var(--accent);
    border-radius: 50%;
    cursor: pointer;
    box-shadow: 0 0 10px var(--accent-glow);
}

.control-btn {
    width: 22px; /* 缩小尺寸 */
    height: 22px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.1); /* 减弱边框 */
    background: rgba(255, 255, 255, 0.05); /* 减弱背景 */
    color: var(--text-dim); /* 降低图标亮度 */
    font-size: 0.8rem; /* 缩小字体 */
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0; /* 防止按钮变形 */
    display: flex;
    align-items: center;
    justify-content: center;
}

.control-btn:hover {
    background: rgba(255, 255, 255, 0.15);
    border-color: rgba(255, 255, 255, 0.3);
    color: var(--text-light);
}

/* 主发报区域 */
.main-telegraph {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    min-height: 0;
    overflow-y: auto; /* 允许垂直滚动，防止内容被遮挡 */
    overflow-x: hidden;
    gap: 15px;
    padding-bottom: 20px; /* 增加底部内边距，优化滚动体验 */
    scrollbar-width: thin;
    scrollbar-color: var(--accent) rgba(255, 255, 255, 0.1);
}

/* 主区域滚动条样式 */
.main-telegraph::-webkit-scrollbar {
    width: 6px;
}

.main-telegraph::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
}

.main-telegraph::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

/* 发报按钮 */
.telegraph-key {
    width: 140px;
    height: 140px;
    border-radius: 50%;
    background: linear-gradient(145deg, #2d2d44, #1a1a2e);
    border: 4px solid var(--bg-panel);
    box-shadow: 
        0 10px 40px rgba(0, 0, 0, 0.5),
        inset 0 2px 10px rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    position: relative;
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.telegraph-key::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border-radius: 50%;
    background: linear-gradient(145deg, #3d3d54, #2a2a3e);
    box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.3);
}

.telegraph-key .key-content {
    position: relative;
    z-index: 1;
    text-align: center;
}

.telegraph-key .key-icon {
    font-size: 2.5rem;
    margin-bottom: 5px;
    display: block;
}

.telegraph-key .key-text {
    font-size: var(--text-xs);
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.telegraph-key.active {
    transform: scale(0.95);
    box-shadow: 
        0 5px 20px rgba(0, 0, 0, 0.5),
        inset 0 2px 20px var(--accent-glow);
    border-color: var(--accent);
}

.telegraph-key.active::before {
    background: linear-gradient(145deg, #4d4d64, #3a3a4e);
}

/* 状态指示器 */
.status-indicator {
    display: flex;
    gap: 15px;
    flex-shrink: 0;
    user-select: none;
    -webkit-user-select: none;
}

.status-light {
    height: 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: var(--transition);
}

#dot-light {
    width: 12px;
    border-radius: 50%;
}

#dash-light {
    width: 36px;
    border-radius: 2px;
}

.status-light.dot {
    background: var(--success);
    box-shadow: 0 0 15px var(--success);
}

.status-light.dash {
    background: var(--warning);
    box-shadow: 0 0 15px var(--warning);
}

.status-labels {
    display: flex;
    gap: 15px;
    font-size: var(--text-sm);
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    flex-shrink: 0;
}

/* 电码输入显示区域 - 重点优化 */
.morse-display-container {
    width: 100%;
    max-width: 900px;
    height: 200px; /* 强制固定高度 */
    flex: 0 0 200px; /* 确保Flexbox也遵守 */
    display: flex;
    flex-direction: column;
    overflow: hidden; /* 防止内部内容撑开 */
}

.morse-display-container .display-box {
    padding: 20px;
    height: 100%; /* 撑满容器 */
    max-height: 100%; /* 再次强制 */
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.morse-display-container .display-content {
    font-family: 'Courier New', Courier, monospace;
    font-size: 2.8rem;
    letter-spacing: 8px;
    text-align: left;
    flex: 1;
    overflow-y: hidden;
    overflow-x: auto;
    white-space: nowrap;
    line-height: 1;
    padding: 10px; /* 恢复正常内边距，靠顶对齐 */
    display: grid; /* 改用 Grid 布局 */
    align-content: start; /* 强制所有内容从顶部开始排列 */
    justify-items: start;
    scrollbar-width: none;
}

.morse-display-container .display-content::-webkit-scrollbar {
    display: none; /* Chrome/Safari 隐藏滚动条 */
}

/* 提示词单独样式 - 独立字体与样式 */
.morse-display-container .display-content .placeholder {
    font-family: 'Microsoft YaHei', 'PingFang SC', sans-serif;
    font-size: 1rem;
    font-style: normal;
    color: var(--text-dim);
    opacity: 0.8;
    white-space: normal;
    display: block;
    line-height: 1.6;
    letter-spacing: 1px;
}

/* 自定义滚动条 */
.morse-display-container .display-content::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.morse-display-container .display-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.morse-display-container .display-content::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

.morse-display-container .display-label {
    font-size: var(--text-sm);
    margin-bottom: 10px;
    flex-shrink: 0;
}

.label-icon {
    font-size: 1.2rem;
    margin-right: 5px;
}

/* 转换结果显示区域 */
.result-display-container {
    width: 100%;
    max-width: 900px;
    flex-shrink: 0;
    height: 120px; /* 固定高度 */
}

.result-display-container .display-box {
    background: rgba(255, 255, 255, 0.05);
    border: none;
    box-shadow: none;
    padding: 15px 20px;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.result-display-container .display-content {
    font-size: 1.3rem;
    text-align: center;
    flex: 1; /* 自动占据剩余空间 */
    overflow: hidden; /* 隐藏滚动条 */
    word-break: break-all;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-display-container .display-content::-webkit-scrollbar {
    width: 6px;
}

.result-display-container .display-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.result-display-container .display-content::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

/* 显示框通用样式 */
.display-box {
    background: var(--bg-display);
    border-radius: var(--radius);
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

/* 电码输入区域突出显示 */
.display-box.morse-input {
    background: linear-gradient(135deg, rgba(15, 52, 96, 0.9), rgba(22, 33, 62, 0.9));
    border: 3px solid var(--accent);
    box-shadow: 
        0 0 30px rgba(233, 69, 96, 0.3),
        inset 0 0 60px rgba(233, 69, 96, 0.1);
}

.display-box.morse-input::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--accent), var(--warning), var(--accent));
    opacity: 1;
    animation: scanline var(--scanline-speed) linear infinite;
}

.delete-btn {
    position: absolute;
    right: 15px;
    bottom: 15px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: var(--text-dim);
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
    z-index: 10;
}

.delete-btn:hover {
    background: rgba(233, 69, 96, 0.2);
    color: var(--accent);
    border-color: var(--accent);
    box-shadow: 0 0 10px var(--accent-glow);
}

.delete-btn:active {
    transform: scale(0.9);
}

.delete-btn.inactive {
    opacity: 0.15;
    pointer-events: none;
    cursor: default;
    box-shadow: none;
    border-color: rgba(255, 255, 255, 0.05);
}

@keyframes scanline {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.display-label {
    font-size: var(--text-sm);
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.display-label::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
}

.display-content .active {
    color: var(--accent);
    text-shadow: 0 0 15px var(--accent-glow);
    display: block; /* 改为块级以配合 Grid 对齐 */
    margin: 0;
    padding: 0;
}

/* 操作按钮 */
.action-row {
    width: 100%;
    max-width: 900px;
    display: flex;
    align-items: center;
    gap: 16px;
    justify-content: space-between;
    flex-shrink: 0;
}

.action-buttons {
    display: flex;
    gap: 15px;
    flex-shrink: 0;
}

.clear-btn-wrapper {
    position: relative;
    display: flex;
}

.confirm-popover {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    margin-bottom: 12px;
    background: var(--bg-panel);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 10px 14px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    z-index: 1000;
    min-width: 160px;
    opacity: 1;
    visibility: visible;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.confirm-popover.hidden {
    opacity: 0;
    visibility: hidden;
    transform: translateX(-50%) translateY(10px) scale(0.9);
    pointer-events: none;
}

.popover-arrow {
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -6px;
    width: 0;
    height: 0;
    border-left: 6px solid transparent;
    border-right: 6px solid transparent;
    border-top: 6px solid var(--bg-panel);
}

.popover-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
}

.popover-text {
    font-size: var(--text-sm);
    color: var(--text-light);
    white-space: nowrap;
}

.popover-actions {
    display: flex;
    gap: 8px;
    width: 100%;
    justify-content: center;
}

.btn-popover {
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: var(--text-xs);
    padding: 4px 10px;
    border-radius: 4px;
    transition: var(--transition);
}

.btn-popover.cancel {
    color: var(--text-dim);
    background: rgba(255, 255, 255, 0.05);
}

.btn-popover.cancel:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
}

.btn-popover.confirm {
    color: white;
    background: var(--accent);
}

.btn-popover.confirm:hover {
    background: #ff5773; /* lighter accent */
    box-shadow: 0 0 10px var(--accent-glow);
}


.action-controls {
    flex: 1;
    max-width: 360px;
    align-items: center;
    min-width: 0;
}

.action-controls .control-item {
    padding: 0;
    gap: 4px;
    min-height: 44px;
    display: grid;
    grid-template-rows: 22px 22px; /* 顶部数值区域 + 底部滑条区域 */
    min-width: 0;
}

.action-controls .control-header {
    gap: 6px;
    height: 22px;
    align-items: center;
    min-width: 0;
}

.action-controls .control-item label {
    font-size: var(--text-xs);
    line-height: 1;
}

.action-controls .control-value {
    padding: 3px 6px;
    height: 22px;
    display: flex;
    align-items: center;
    line-height: 1;
}

.action-controls .control-value input[type="number"] {
    width: 44px;
}

.action-controls .control-slider {
    gap: 8px;
    display: flex;
    height: 22px;
    opacity: 0;
    transform: translateY(-4px);
    pointer-events: none;
    visibility: hidden;
    transition: opacity 0.2s ease, transform 0.2s ease;
    min-width: 0;
}

.action-controls .control-slider input[type="range"] {
    height: 4px;
    min-width: 0;
}

.action-controls .control-slider input[type="range"]::-webkit-slider-thumb {
    width: 14px;
    height: 14px;
}

.action-controls .control-item.expanded .control-slider {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
    visibility: visible;
}

.action-controls input[type="number"] {
    -moz-appearance: textfield;
}

.action-controls input[type="number"]::-webkit-outer-spin-button,
.action-controls input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.btn {
    padding: 10px 25px;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    transition: var(--transition);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: inherit;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.btn:active {
    transform: translateY(0);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    filter: grayscale(0.8);
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    background: #ff5773;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-light);
    border: none; /* 去掉边框线条 */
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 移动端气泡位置优化 */
@media (max-width: 768px) {
    .confirm-popover {
        left: auto;
        right: -10px; /* 微调，避免紧贴屏幕边缘 */
        transform: none;
    }

    .confirm-popover.hidden {
        transform: translateY(10px) scale(0.9);
    }

    .popover-arrow {
        left: auto;
        right: 40px; /* 约对应清空按钮的中心位置 */
        margin-left: 0;
    }
}

.btn-secondary.clear-ready {
    background: rgba(233, 69, 96, 0.18);
    border-color: rgba(233, 69, 96, 0.28);
}

.btn-secondary.clear-ready:hover {
    background: rgba(233, 69, 96, 0.24);
}

/* 破解区域 */
.crack-section {
    display: none;
    width: 100%;
    max-width: 900px; /* 与上方结果区域保持一致 */
    background: rgba(255, 255, 255, 0.05); /* 统一背景样式 */
    border: none;
    box-shadow: none;
    border-radius: var(--radius);
    padding: 20px; /* 统一内边距 */
    animation: slideIn 0.3s ease;
    flex-shrink: 0;
    height: 120px; /* 固定高度，防止跳动 */
    overflow: visible;
}

.crack-section.visible {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.crack-title {
    font-size: var(--text-sm);
    color: var(--text-dim); /* 统一文字颜色 */
    text-transform: uppercase;
    letter-spacing: 2px;
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 5px;
    width: 100%;
}

/* 添加统一的标题前缀点 */
.crack-title::before {
    content: '';
    width: 6px;
    height: 6px;
    background: var(--accent);
    border-radius: 50%;
}

.crack-controls {
    display: flex;
    gap: 15px;
    align-items: center;
    width: 100%;
    justify-content: center;
}

.password-book-label {
    font-size: var(--text-sm);
    color: var(--text-light);
    font-weight: 600;
    white-space: nowrap;
}

.book-select {
    display: none;
}

.book-select option {
    background-color: var(--bg-panel);
    color: var(--text-light);
}

.book-select:focus {
    outline: none;
}

.book-select-wrapper {
    position: relative;
    flex: 1;
    max-width: 250px;
}

.book-select-trigger {
    width: 100%;
    padding: 8px 40px 8px 12px;
    font-size: 0.9rem;
    background: var(--bg-panel);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius);
    color: var(--text-light);
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    position: relative;
}

.book-select-trigger::after {
    content: '';
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    width: 14px;
    height: 14px;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e94560' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 14px;
    pointer-events: none;
}

.book-select-panel {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100% + 8px);
    background: #111c3a;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 6px;
    display: none;
    z-index: 1000;
    max-height: 260px;
    overflow-y: auto;
}

.book-select-panel.open {
    display: block;
}

.book-select-panel.up {
    top: auto;
    bottom: calc(100% + 8px);
}

.book-select-option {
    padding: 8px 10px;
    border-radius: 10px;
    color: var(--text-light);
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.book-select-option:hover {
    background: rgba(233, 69, 96, 0.12);
    color: #ffffff;
}

.book-select-option.selected {
    background: rgba(233, 69, 96, 0.18);
    color: #ffffff;
}

.btn-crack {
    background: linear-gradient(135deg, var(--accent), #ff5773);
    color: white;
    padding: 8px 20px;
}

.btn-crack:hover {
    box-shadow: 0 5px 20px var(--accent-glow);
}

/* 结果展示 */
.result-display {
    margin-top: 10px;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: var(--radius);
    border-left: 4px solid var(--accent);
    font-size: 1.1rem;
    line-height: 1.6;
    text-align: center;
    animation: fadeIn 0.5s ease;
    flex: 1; /* 撑满剩余高度 */
    overflow-y: auto; /* 内容过多时滚动 */
    scrollbar-width: thin;
    scrollbar-color: var(--accent) rgba(255, 255, 255, 0.1);
}

.result-display::-webkit-scrollbar {
    width: 6px;
}

.result-display::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.result-display::-webkit-scrollbar-thumb {
    background: var(--accent);
    border-radius: 3px;
}

/* 破解结果内容 */
#crack-result-content {
    width: 100%;
    animation: fadeIn 0.5s ease;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center; /* 垂直居中 */
    overflow: hidden;
}

.crack-wait {
    width: 100%;
    padding: 14px;
    border-radius: var(--radius);
    background: transparent;
    border: none;
    display: flex;
    flex-direction: column;
    gap: 10px;
    justify-content: center; /* 内容垂直居中 */
}

.crack-wait-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-sm);
    color: var(--text-light);
    letter-spacing: 1px;
    text-transform: uppercase;
}

.crack-wait-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    box-shadow: 0 0 8px var(--warning);
    animation: crackPulse 0.8s ease-in-out infinite;
}

.crack-wait-bar {
    position: relative;
    height: 8px;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 999px;
    overflow: hidden;
}

.crack-wait-bar-fill {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0%;
    background: linear-gradient(90deg, var(--warning), var(--accent));
    animation: crackProgress linear forwards;
}

.crack-wait-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--text-xs);
    color: var(--text-dim);
}

.crack-wait-ellipsis {
    display: inline-block;
    animation: crackBlink 1s steps(2, end) infinite;
}

.crack-result-text {
    font-size: 1.2rem;
    color: var(--text-light);
    text-align: center;
    padding: 10px;
    line-height: 1.8;
    border-radius: var(--radius);
    background: transparent;
}

@keyframes crackProgress {
    from { width: 0%; }
    to { width: 100%; }
}

@keyframes crackPulse {
    0%, 100% { transform: scale(1); opacity: 0.7; }
    50% { transform: scale(1.4); opacity: 1; }
}

@keyframes crackBlink {
    0%, 100% { opacity: 0.2; }
    50% { opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 底部信息栏 */
.bottom-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 20px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: var(--radius);
    margin-top: 10px;
    flex-shrink: 0;
    /* 防止右侧内容被悬浮按钮遮挡 */
    padding-right: 80px; 
}

.info-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: var(--text-sm);
    color: var(--text-dim);
}

.info-item .indicator {
    width: 6px;
    height: 6px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* 快速参考 - 可收起 */
.quick-ref {
    position: fixed;
    bottom: 80px;
    right: 20px;
    background: var(--bg-panel);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius);
    padding: 0; /* 移除内边距，由内部元素控制 */
    max-width: 1100px; /* 进一步增加宽度 */
    max-height: none; /* 取消高度限制 */
    overflow-y: visible; /* 取消滚动条 */
    box-shadow: var(--shadow);
    transition: transform 0.3s ease, opacity 0.3s ease; /* 仅过渡变换和透明度，避免拖拽时的位置延迟 */
    display: flex;
    flex-direction: column;
}

.quick-ref .display-label {
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius) var(--radius) 0 0;
    cursor: move; /* 鼠标变为移动图标 */
    user-select: none;
    font-weight: bold;
    color: var(--accent);
}

.quick-ref .cheat-grid-wrapper {
    padding: 15px;
}

.quick-ref.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px) scale(0.95); /* 原地淡出下沉，适应任意位置 */
    visibility: hidden; /* 确保不可点击不可见 */
}

.quick-ref-toggle {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 45px;
    height: 45px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 4px 15px var(--accent-glow);
    transition: var(--transition);
    z-index: 100;
    opacity: 0.4;
}

.quick-ref-toggle:hover {
    transform: scale(1.1);
    opacity: 1;
}

.cheat-grid-mini {
    display: grid;
    grid-template-columns: repeat(10, 1fr); /* 增加列数以降低高度 (8 -> 10) */
    gap: 15px; /* 增加间距 */
    font-size: 1.2rem; /* 再次增大基准字体 */
}

.cheat-item-mini {
    text-align: center;
    padding: 10px; /* 增加内边距 */
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

/* 样式互换：电码突出显示 */
.cheat-item-mini .letter {
    color: var(--text-dim);
    font-weight: normal;
    font-size: 0.9rem;
    display: block;
    margin-bottom: 4px;
}

.cheat-item-mini .code {
    color: var(--accent);
    font-weight: bold;
    font-size: 1.5rem; /* 大幅增大电码字体 */
    display: block;
    line-height: 1.1;
    letter-spacing: 1px;
}

/* 响应式 */
@media (max-width: 768px) {
    /* 隐藏滚动条但允许滚动（提升移动端美观度） */
    *::-webkit-scrollbar {
        display: none;
    }
    
    * {
        -ms-overflow-style: none;
        scrollbar-width: none;
    }

    /* 核心布局调整：允许滚动 */
    html, body {
        height: auto;
        min-height: 100%;
        overflow-y: auto;
        overflow-x: hidden;
    }

    .container {
        height: auto;
        min-height: 100vh;
        overflow: visible;
        padding: 10px;
        position: relative; /* 确保绝对定位相对于容器 */
    }

    .main-telegraph {
        overflow: visible;
        flex: 0 0 auto; /* 允许内容撑开 */
        min-height: 0;
        width: 100%;
    }

    /* 顶部控制栏 */
    .top-bar {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }

    .controls-section {
        width: 100%;
        flex-direction: column;
        gap: 12px;
        max-width: none;
    }

    .control-item {
        width: 100%;
        flex: 0 0 auto !important; /* 强制取消 flex-basis */
        padding: 0;
    }

    .control-slider {
        width: 100%;
        justify-content: space-between;
    }

    .control-slider input[type="range"] {
        flex: 1;
        margin: 0 10px;
    }

    .control-btn {
        width: 28px;
        height: 28px;
        font-size: 1rem; /* 稍微缩小移动端按钮 */
    }

    /* 发报按钮 */
    .telegraph-key {
        width: clamp(110px, 30vw, 140px);
        height: clamp(110px, 30vw, 140px);
        margin: 10px 0;
    }

    .telegraph-key .key-icon {
        font-size: clamp(2rem, 5vw, 2.5rem);
    }

    /* 显示区域 */
    .morse-display-container {
        min-height: 180px;
        max-height: 30vh;
    }

    .morse-display-container .display-content {
        font-size: 1.3rem;
        letter-spacing: 3px;
        padding: 8px;
    }

    /* 操作按钮 */
    .action-row {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    .action-buttons {
        width: 100%;
        justify-content: center;
    }
    .action-controls {
        width: 100%;
        max-width: 360px;
        margin: 0 auto;
    }

    .action-controls .control-item {
        min-height: auto;
        display: flex;
        flex-direction: column;
    }

    .action-controls .control-value {
        height: auto;
        align-items: center;
    }

    .action-controls .control-slider {
        height: auto;
        max-height: 0;
        opacity: 0;
        transform: translateY(-4px);
        pointer-events: none;
        visibility: hidden;
        transition: max-height 0.2s ease, opacity 0.2s ease, transform 0.2s ease;
    }

    .action-controls .control-item.expanded .control-slider {
        max-height: 60px;
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
        visibility: visible;
    }

    .btn {
        flex: 1;
        justify-content: center;
        padding: 12px;
        font-size: 1rem;
    }

    /* 快速参考表 */
    .quick-ref {
        position: fixed; /* 移动端改回 fixed，但限制高度 */
        left: 10px;
        right: 10px;
        bottom: 80px;
        max-width: none;
        max-height: 30vh; /* 进一步减小最大高度，防止遮挡输入框 */
        z-index: 200;
        transform: none;
        overflow-y: auto; /* 内容过多时滚动 */
        -webkit-overflow-scrolling: touch;
    }

    .quick-ref.hidden {
        display: none;
        transform: none;
        opacity: 0;
    }
    
    .quick-ref .display-label {
        cursor: default;
        position: sticky; /* 标题栏吸顶 */
        top: 0;
        z-index: 10;
        background: var(--bg-panel); /* 确保背景不透明 */
        padding: 10px; /* 稍微减小内边距 */
    }

    /* 移动端隐藏拖动提示 */
    .drag-hint {
        display: none;
    }

    .cheat-grid-mini {
        grid-template-columns: repeat(4, 1fr);
        gap: 8px;
        font-size: 1rem;
    }
    
    .cheat-item-mini {
        padding: 8px 4px;
    }

    /* 移动端字体调整 */
    .cheat-item-mini .letter {
        font-size: 0.8rem;
        margin-bottom: 2px;
    }

    .cheat-item-mini .code {
        font-size: 1.2rem; /* 移动端电码字体 */
    }

    .quick-ref-toggle {
        width: 50px;
        height: 50px;
        font-size: 1.4rem;
        bottom: 20px;
        right: 20px;
    }
}

@media (max-width: 380px) {
    .cheat-grid-mini {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .status-indicator {
        gap: 8px;
    }
    
    .status-labels {
        font-size: 0.7rem;
        gap: 8px;
    }
}

/* Mobile specific fixes for crack controls */
@media (max-width: 768px) {
    .crack-controls {
        gap: 8px;
    }

    .book-select-wrapper {
        max-width: none; /* Remove width restriction */
        flex: 1; /* Allow it to take remaining space */
    }

    .book-select-trigger {
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        padding-right: 30px; /* Reduce padding for arrow */
        padding-left: 10px;
    }

    .btn-crack {
        flex: 0 0 auto; /* Prevent growing */
        width: auto; /* Auto width based on content */
        padding: 8px 16px; /* Smaller padding */
        white-space: nowrap;
    }
}
