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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Display', 'Helvetica Neue', sans-serif;
    background: linear-gradient(135deg, #f2f2f7 0%, #ffffff 100%);
    color: #1c1c1e;
    min-height: 100vh;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    overflow: hidden;
}

.container {
    max-width: 100vw;
    height: 100vh;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
}

/* 顶部状态栏 */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: rgba(255, 255, 255, 0.8);
    border-bottom: 0.5px solid rgba(60, 60, 67, 0.1);
    backdrop-filter: blur(20px);
    min-height: 70px;
    flex-shrink: 0;
}

.status-info {
    display: flex;
    align-items: center;
    gap: 24px;
}

.app-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: #1c1c1e;
    letter-spacing: -0.5px;
}

/* 淘宝链接样式 */
.taobao-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #FF4000, #FF8C00);
    color: white;
    text-decoration: none;
    border-radius: 14px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    border: 0.5px solid rgba(255, 107, 0, 0.3);
    backdrop-filter: blur(20px);
}

.taobao-link:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(255, 64, 0, 0.3);
}

.taobao-link:active {
    transform: scale(0.95);
}

.link-icon {
    font-size: 0.9rem;
}

.link-text {
    font-size: 0.9rem;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: rgba(120, 120, 128, 0.1);
    border-radius: 14px;
    border: 0.5px solid rgba(120, 120, 128, 0.2);
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #ff453a;
    animation: pulse 2s infinite;
}

.status-dot.connected {
    background: #32d74b;
    animation: none;
}

.status-text {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1c1c1e;
}

.control-buttons {
    display: flex;
    gap: 8px;
}

.control-btn {
    padding: 12px 16px;
    border: none;
    border-radius: 12px;
    background: rgba(120, 120, 128, 0.1);
    color: #1c1c1e;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(20px);
    border: 0.5px solid rgba(120, 120, 128, 0.2);
    font-size: 0.9rem;
    font-weight: 600;
    min-width: 60px;
}

.control-btn:hover:not(:disabled) {
    background: rgba(120, 120, 128, 0.2);
    transform: scale(1.05);
}

.control-btn:active:not(:disabled) {
    transform: scale(0.95);
}

.control-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none;
}

.control-btn.clear {
    background: rgba(255, 149, 0, 0.15);
    border-color: rgba(255, 149, 0, 0.3);
}

.control-btn.connect {
    background: rgba(52, 199, 89, 0.15);
    border-color: rgba(52, 199, 89, 0.3);
}

.control-btn.connect.disconnected {
    background: rgba(255, 59, 48, 0.15);
    border-color: rgba(255, 59, 48, 0.3);
}

.control-btn.settings {
    background: rgba(0, 122, 255, 0.15);
    border-color: rgba(0, 122, 255, 0.3);
}

.btn-text {
    font-size: 0.9rem;
    font-weight: 600;
}

/* 设置面板 */
.settings-panel {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(40px);
    border-radius: 20px;
    padding: 0;
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.2),
        0 0 0 0.5px rgba(255, 255, 255, 0.5);
    border: 0.5px solid rgba(120, 120, 128, 0.2);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    min-width: 360px;
    max-width: 400px;
}

.settings-panel.active {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

.settings-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 24px 16px;
    border-bottom: 0.5px solid rgba(120, 120, 128, 0.2);
}

.settings-header h3 {
    font-size: 1.2rem;
    font-weight: 700;
    color: #1c1c1e;
    margin: 0;
}

.close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(120, 120, 128, 0.1);
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    font-size: 1.1rem;
}

.close-btn:hover {
    background: rgba(120, 120, 128, 0.2);
}

.settings-content {
    padding: 24px;
    max-height: 70vh;
    overflow-y: auto;
}

.setting-section {
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 0.5px solid rgba(120, 120, 128, 0.1);
}

.setting-section:last-child {
    border-bottom: none;
    margin-bottom: 16px;
}

.setting-section h4 {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1c1c1e;
    margin-bottom: 16px;
}

.setting-group {
    margin-bottom: 16px;
}

.setting-group label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: #1c1c1e;
    margin-bottom: 6px;
}

.setting-group input {
    width: 100%;
    padding: 10px 14px;
    border: 0.5px solid rgba(120, 120, 128, 0.3);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.8);
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.setting-group input:focus {
    outline: none;
    border-color: #007AFF;
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.2);
}

.setting-hint {
    font-size: 0.75rem;
    color: rgba(60, 60, 67, 0.5);
    margin-top: 4px;
    font-style: italic;
}

.apply-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #007AFF, #0056CC);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 8px;
}

.apply-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(0, 122, 255, 0.3);
}

/* 波形容器 */
.waveform-container {
    flex: 1;
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    grid-template-rows: repeat(3, 1fr);
    gap: 2px;
    background: rgba(120, 120, 128, 0.1);
    padding: 2px;
    overflow: hidden;
}

.waveform {
    background: #ffffff;
    position: relative;
    overflow: hidden;
    border-radius: 16px;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.04),
        0 1px 2px rgba(0, 0, 0, 0.08);
    border: 0.5px solid rgba(120, 120, 128, 0.1);
    transition: all 0.3s ease;
}

.waveform:hover {
    box-shadow:
        0 4px 16px rgba(0, 0, 0, 0.08),
        0 2px 4px rgba(0, 0, 0, 0.12);
    transform: translateY(-1px);
}

.waveform-title {
    position: absolute;
    top: 16px;
    left: 16px;
    font-size: 0.85rem;
    font-weight: 600;
    color: rgba(60, 60, 67, 0.8);
    z-index: 10;
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 12px;
    border-radius: 10px;
    border: 0.5px solid rgba(120, 120, 128, 0.2);
    backdrop-filter: blur(20px);
}

/* 更新频道信息显示样式 */
.channel-info {
    position: absolute;
    top: 16px;
    right: 16px;
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(60, 60, 67, 0.6);
    background: rgba(255, 255, 255, 0.9);
    padding: 6px 10px;
    border-radius: 10px;
    border: 0.5px solid rgba(120, 120, 128, 0.2);
    backdrop-filter: blur(20px);
    text-align: center;
    min-width: 80px;
}

.channel-value {
    color: #007AFF;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 2px;
}

.channel-count {
    font-size: 0.65rem;
    color: rgba(60, 60, 67, 0.5);
    font-weight: 500;
}

.axis-label {
    position: absolute;
    font-size: 0.7rem;
    font-weight: 500;
    color: rgba(60, 60, 67, 0.5);
    background: rgba(255, 255, 255, 0.8);
    padding: 2px 6px;
    border-radius: 4px;
    border: 0.5px solid rgba(120, 120, 128, 0.1);
}

.x-axis-label {
    bottom: 8px;
    right: 16px;
}

.y-axis-label {
    top: 16px;
    left: 16px;
    writing-mode: vertical-rl;
    transform: rotate(180deg);
}

canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 16px;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: rgba(120, 120, 128, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb {
    background: rgba(120, 120, 128, 0.3);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(120, 120, 128, 0.5);
}

/* 通道数显示样式 */
.channel-count-display {
    padding: 8px 16px;
    background: rgba(0, 122, 255, 0.15);
    border-radius: 14px;
    border: 0.5px solid rgba(0, 122, 255, 0.3);
    font-size: 0.9rem;
    font-weight: 600;
    color: #007AFF;
    backdrop-filter: blur(20px);
}

.channel-count-number {
    font-weight: 700;
    color: #0056CC;
    margin: 0 4px;
}

/* 缓冲区状态样式 */
#bufferStatus {
    font-weight: 600;
    color: #32D74B;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .top-bar {
        padding: 12px 16px;
    }

    .status-info {
        gap: 16px;
    }

    .app-title {
        font-size: 1.2rem;
    }

    /* 淘宝链接响应式 */
    .taobao-link {
        padding: 6px 12px;
        font-size: 0.8rem;
    }

    .link-text {
        font-size: 0.8rem;
    }

    .connection-status {
        padding: 6px 12px;
        font-size: 0.85rem;
    }

    .control-btn {
        padding: 10px 12px;
        font-size: 0.8rem;
        min-width: 50px;
    }

    .control-buttons {
        gap: 6px;
    }

    .waveform-container {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(6, 1fr);
    }

    .waveform-title,
    .channel-info {
        font-size: 0.8rem;
        top: 12px;
        left: 12px;
        right: 12px;
    }

    .channel-info {
        padding: 5px 8px;
        min-width: 70px;
    }

    .channel-value {
        font-size: 0.8rem;
    }

    .channel-count {
        font-size: 0.6rem;
    }

    .settings-panel {
        min-width: 320px;
        margin: 20px;
    }

    .settings-header {
        padding: 20px 20px 12px;
    }

    .settings-content {
        padding: 20px;
    }

    .setting-group {
        margin-bottom: 14px;
    }

    .setting-group input {
        padding: 9px 12px;
    }

    .apply-btn {
        padding: 12px;
    }
}

@media (max-width: 480px) {
    .top-bar {
        flex-direction: column;
        gap: 12px;
        padding: 12px;
    }

    .status-info {
        width: 100%;
        justify-content: space-between;
    }

    .control-buttons {
        width: 100%;
        justify-content: center;
    }

    .app-title {
        font-size: 1.1rem;
    }

    /* 淘宝链接在小屏幕上的响应式 */
    .taobao-link {
        padding: 4px 10px;
        font-size: 0.75rem;
    }

    .link-text {
        display: none;
        /* 在非常小的屏幕上隐藏文字 */
    }

    .taobao-link .link-icon {
        margin: 0;
    }

    .connection-status {
        font-size: 0.8rem;
        padding: 4px 10px;
    }

    .control-btn {
        flex: 1;
        min-width: auto;
        padding: 8px 10px;
        font-size: 0.75rem;
    }

    .waveform-title,
    .channel-info {
        font-size: 0.7rem;
        top: 8px;
        left: 8px;
        right: 8px;
    }

    .channel-info {
        padding: 4px 6px;
        min-width: 60px;
        right: 8px;
    }

    .channel-value {
        font-size: 0.75rem;
    }

    .channel-count {
        font-size: 0.55rem;
    }

    .axis-label {
        font-size: 0.6rem;
    }

    .x-axis-label {
        bottom: 6px;
        right: 8px;
    }

    .y-axis-label {
        top: 8px;
        left: 8px;
    }

    .settings-panel {
        min-width: 280px;
        width: 90vw;
    }
}

/* 设置面板遮罩 */
.settings-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    z-index: 999;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

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

/* 输入验证样式 */
.setting-group input.invalid {
    border-color: #ff453a;
    box-shadow: 0 0 0 2px rgba(255, 69, 58, 0.2);
}

.validation-message {
    font-size: 0.75rem;
    color: #ff453a;
    margin-top: 4px;
    display: none;
}

.validation-message.show {
    display: block;
}

/* 按钮加载状态 */
.control-btn.loading {
    position: relative;
    color: transparent;
}

.control-btn.loading::after {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

/* 工具提示 */
.tooltip {
    position: absolute;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 6px 10px;
    border-radius: 8px;
    font-size: 0.8rem;
    white-space: nowrap;
    z-index: 1001;
    pointer-events: none;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.tooltip.show {
    opacity: 1;
    transform: translateY(0);
}