/* ========================================
   古筝调音器 - 样式
   极简国风 · 护眼浅色模式 · 移动端专属
   ======================================== */

/* ========================================
   调音器模态框
   ======================================== */

#tuner-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
}

#tuner-modal.hidden {
    display: none;
}

#tunerOverlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(5px);
}

.tuner-modal-content {
    position: relative;
    width: 92%;
    max-width: 520px;
    max-height: 90vh;
    background: linear-gradient(160deg, #fdf6e3 0%, #f5f0dc 50%, #ede4c8 100%);
    border-radius: 20px;
    border: 2px solid rgba(201, 166, 107, 0.5);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255,255,255,0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: tunerIn 0.3s ease-out;
    color: #3a2a1a;
}

@keyframes tunerIn {
    from { opacity: 0; transform: scale(0.92) translateY(30px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* 顶部标题栏 */
.tuner-header {
    padding: 18px 20px 12px;
    text-align: center;
    border-bottom: 1px solid rgba(201, 166, 107, 0.3);
    background: linear-gradient(180deg, rgba(201,166,107,0.1) 0%, transparent 100%);
    flex-shrink: 0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.tuner-header h2 {
    font-size: 22px;
    font-weight: 700;
    color: #8b6914;
    letter-spacing: 4px;
    margin: 0;
    flex: 1;
    text-align: center;
}

/* 退出按钮 */
.tuner-exit-btn {
    width: 36px;
    height: 36px;
    background: rgba(201, 166, 107, 0.2);
    border: none;
    border-radius: 50%;
    color: #8b6914;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tuner-exit-btn:hover {
    background: rgba(231, 76, 60, 0.7);
    color: #fff;
    transform: rotate(90deg);
}

.tuner-exit-btn:active {
    transform: rotate(90deg) scale(0.95);
}

/* 关闭按钮 */
.tuner-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 50%;
    background: rgba(201, 166, 107, 0.2);
    color: #8b6914;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s ease;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tuner-close:hover {
    background: rgba(231, 76, 60, 0.7);
    color: #fff;
    transform: rotate(90deg);
}

/* 主体内容区 */
.tuner-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

/* 滚动条样式 */
.tuner-body::-webkit-scrollbar {
    width: 6px;
}
.tuner-body::-webkit-scrollbar-track {
    background: rgba(201, 166, 107, 0.1);
    border-radius: 3px;
}
.tuner-body::-webkit-scrollbar-thumb {
    background: rgba(201, 166, 107, 0.4);
    border-radius: 3px;
}

/* ========================================
   顶部状态区
   ======================================== */
.tuner-status-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 14px;
    background: rgba(201, 166, 107, 0.12);
    border-radius: 12px;
    border: 1px solid rgba(201, 166, 107, 0.2);
    flex-shrink: 0;
}

.tuner-status-left {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tuner-status-label {
    font-size: 12px;
    color: #8b7355;
}

.tuner-current-note {
    font-size: 28px;
    font-weight: 800;
    color: #8b6914;
    letter-spacing: 2px;
    line-height: 1.1;
}

.tuner-current-freq {
    font-size: 13px;
    color: #a08050;
}

.tuner-status-right {
    text-align: right;
}

.tuner-permission-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    margin-bottom: 6px;
}

.tuner-permission-badge.granted {
    background: rgba(46, 204, 113, 0.2);
    color: #1a8f3f;
    border: 1px solid rgba(46, 204, 113, 0.4);
}

.tuner-permission-badge.denied {
    background: rgba(231, 76, 60, 0.2);
    color: #c0392b;
    border: 1px solid rgba(231, 76, 60, 0.4);
}

#tunerStatusText {
    font-size: 13px;
    font-weight: 500;
    color: #8b7355;
    margin: 0;
    min-height: 1.4em;
}

/* ========================================
   音量指示器
   ======================================== */
.tuner-volume-section {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    background: rgba(139, 105, 20, 0.04);
    border: 1px solid rgba(201, 166, 107, 0.2);
    border-radius: 10px;
    margin-bottom: 8px;
}

.tuner-volume-led {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #e0d5c1;
    border: 2px solid rgba(139, 105, 20, 0.3);
    flex-shrink: 0;
    transition: background 0.1s ease;
    box-shadow: inset 0 1px 2px rgba(255,255,255,0.5);
}

.tuner-volume-led.active {
    box-shadow: 0 0 8px currentColor, inset 0 1px 2px rgba(255,255,255,0.5);
}

.tuner-volume-bar-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
    min-width: 0;
}

.tuner-volume-bar-bg {
    width: 100%;
    height: 8px;
    background: rgba(0,0,0,0.08);
    border-radius: 4px;
    overflow: hidden;
}

.tuner-volume-bar {
    height: 100%;
    background: linear-gradient(90deg, #2ecc71 0%, #f1c40f 70%, #e74c3c 100%);
    border-radius: 4px;
    transition: width 0.05s linear;
    width: 0%;
}

.tuner-volume-text {
    font-size: 11px;
    color: #8b7355;
    font-weight: 500;
}

.tuner-volume-label {
    font-size: 12px;
    color: #8b7355;
    font-weight: 600;
    flex-shrink: 0;
}

/* ========================================
   核心调音仪表盘
   ======================================== */
.tuner-gauge-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.tuner-gauge {
    position: relative;
    width: 220px;
    height: 130px;
    overflow: hidden;
}

.tuner-gauge-bg {
    position: absolute;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    background: conic-gradient(
        from 270deg,
        #e74c3c 0deg,
        #e74c3c 60deg,
        #f1c40f 60deg,
        #2ecc71 90deg,
        #f1c40f 120deg,
        #e74c3c 180deg,
        transparent 180deg
    );
    top: 0;
    left: 0;
    opacity: 0.15;
    transition: background 0.3s ease;
}

.tuner-gauge-bg.in-tune {
    background: radial-gradient(circle, rgba(46,204,113,0.35) 0%, transparent 70%);
}
.tuner-gauge-bg.flat {
    background: radial-gradient(circle, rgba(231,76,60,0.35) 0%, transparent 70%);
}
.tuner-gauge-bg.sharp {
    background: radial-gradient(circle, rgba(241,196,15,0.35) 0%, transparent 70%);
}

.tuner-gauge-face {
    position: absolute;
    width: 190px;
    height: 190px;
    border-radius: 50%;
    background: linear-gradient(145deg, #fff8e8 0%, #f0e6cc 100%);
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    box-shadow: inset 0 2px 8px rgba(0,0,0,0.08), 0 -2px 8px rgba(0,0,0,0.05);
    border: 2px solid rgba(201, 166, 107, 0.4);
}

/* 刻度标记 */
.tuner-gauge-ticks {
    position: absolute;
    width: 190px;
    height: 190px;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.tuner-tick {
    position: absolute;
    width: 2px;
    height: 10px;
    background: rgba(139, 105, 20, 0.4);
    top: 6px;
    left: 50%;
    transform-origin: 50% 89px;
}

.tuner-tick.major {
    height: 16px;
    width: 3px;
    background: rgba(139, 105, 20, 0.6);
}

.tuner-tick-center {
    position: absolute;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: #8b6914;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
}

/* 指针 */
.tuner-needle {
    position: absolute;
    width: 4px;
    height: 80px;
    background: linear-gradient(to top, #c0392b 0%, #e74c3c 60%, #fff 100%);
    bottom: 8px;
    left: 50%;
    transform-origin: 50% 0%;
    transform: translateX(-50%) rotate(0deg);
    transition: transform 0.15s ease-out;
    border-radius: 2px 2px 0 0;
    z-index: 3;
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.4);
}

.tuner-needle.in-tune {
    background: linear-gradient(to top, #1a8f3f 0%, #2ecc71 60%, #fff 100%);
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.6);
}

/* 仪表盘下方数据 */
.tuner-gauge-data {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.tuner-data-item {
    text-align: center;
    min-width: 80px;
}

.tuner-data-label {
    font-size: 11px;
    color: #8b7355;
    margin-bottom: 2px;
}

.tuner-data-value {
    font-size: 20px;
    font-weight: 700;
    color: #3a2a1a;
    font-family: 'Consolas', 'Monaco', monospace;
}

.tuner-data-value.in-tune { color: #1a8f3f; }
.tuner-data-value.flat { color: #c0392b; }
.tuner-data-value.sharp { color: #d48806; }

/* ========================================
   21弦选择网格
   ======================================== */
.tuner-string-section {
    flex-shrink: 0;
}

.tuner-section-title {
    font-size: 13px;
    color: #8b7355;
    margin-bottom: 8px;
    text-align: center;
    letter-spacing: 1px;
}

#tunerStringGrid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 6px;
}

.tuner-string-btn {
    aspect-ratio: 1;
    border: 2px solid rgba(201, 166, 107, 0.35);
    border-radius: 10px;
    background: linear-gradient(145deg, #fff8e8, #f0e6cc);
    color: #8b6914;
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.15s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}

.tuner-string-btn:hover {
    border-color: #c9a66b;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}

.tuner-string-btn.active {
    background: linear-gradient(145deg, #8b6914, #c9a66b);
    color: #fff;
    border-color: #8b6914;
    box-shadow: 0 2px 8px rgba(201, 166, 107, 0.5);
}

.tuner-string-btn.in-range {
    border-color: #2ecc71;
    box-shadow: 0 0 8px rgba(46, 204, 113, 0.3);
}

.tuner-string-btn.flat-range {
    border-color: #e74c3c;
    box-shadow: 0 0 8px rgba(231, 76, 60, 0.3);
}

.tuner-string-btn.sharp-range {
    border-color: #f1c40f;
    box-shadow: 0 0 8px rgba(241, 196, 15, 0.3);
}

/* ========================================
   功能按钮区
   ======================================== */
.tuner-controls {
    display: flex;
    gap: 8px;
    justify-content: center;
    flex-wrap: wrap;
    flex-shrink: 0;
}

.tuner-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
    letter-spacing: 1px;
}

.tuner-btn:active {
    transform: scale(0.96);
}

#tunerStartBtn {
    background: linear-gradient(135deg, #2ecc71 0%, #1a8f3f 100%);
    color: #fff;
}

#tunerStartBtn:hover {
    box-shadow: 0 4px 14px rgba(46, 204, 113, 0.4);
}

#tunerStartBtn.active {
    background: linear-gradient(135deg, #27ae60 0%, #1a7a35 100%);
}

#tunerStopBtn {
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: #fff;
}

#tunerStopBtn:hover {
    box-shadow: 0 4px 14px rgba(231, 76, 60, 0.4);
}

#tunerRefBtn {
    background: linear-gradient(135deg, #c9a66b 0%, #8b6914 100%);
    color: #fff;
}

#tunerRefBtn:hover {
    box-shadow: 0 4px 14px rgba(201, 166, 107, 0.4);
}

/* 灵敏度调节 */
.tuner-sensitivity-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 14px;
    background: rgba(201, 166, 107, 0.08);
    border-radius: 10px;
    border: 1px solid rgba(201, 166, 107, 0.15);
}

.tuner-sensitivity-label {
    font-size: 12px;
    color: #8b7355;
    white-space: nowrap;
}

#tunerSensitivity {
    flex: 1;
    height: 6px;
    -webkit-appearance: none;
    appearance: none;
    background: rgba(201, 166, 107, 0.3);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

#tunerSensitivity::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c9a66b, #8b6914);
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#tunerSensitivity::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: linear-gradient(135deg, #c9a66b, #8b6914);
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#tunerSensitivityVal {
    font-size: 12px;
    color: #8b7355;
    min-width: 30px;
    text-align: right;
    font-family: monospace;
}

/* ========================================
   提示信息
   ======================================== */
.tuner-tip {
    text-align: center;
    font-size: 12px;
    color: #a08050;
    padding: 8px;
    line-height: 1.6;
    flex-shrink: 0;
}

.tuner-tip strong {
    color: #8b6914;
}

/* ========================================
   走马灯
   ======================================== */
.tuner-marquee-wrap {
    overflow: hidden;
    background: rgba(139, 105, 20, 0.06);
    border: 1px solid rgba(201, 166, 107, 0.25);
    border-radius: 10px;
    padding: 8px 12px;
    min-height: 36px;
    display: flex;
    align-items: center;
}

.tuner-marquee {
    font-size: 14px;
    font-weight: 600;
    color: #8b7355;
    white-space: nowrap;
    letter-spacing: 1px;
    transition: color 0.3s ease;
}

.tuner-marquee.in-tune { color: #1a8f3f; }
.tuner-marquee.flat { color: #e74c3c; }
.tuner-marquee.sharp { color: #d48806; }

/* ========================================
   响应式适配
   ======================================== */

/* 平板 */
@media (max-width: 1024px) {
    .tuner-modal-content {
        max-width: 480px;
    }
    .tuner-gauge {
        width: 200px;
        height: 120px;
    }
    .tuner-gauge-bg {
        width: 200px;
        height: 200px;
    }
    .tuner-gauge-face {
        width: 172px;
        height: 172px;
    }
    .tuner-gauge-ticks {
        width: 172px;
        height: 172px;
    }
    .tuner-tick {
        transform-origin: 50% 79px;
    }
    .tuner-needle {
        height: 72px;
    }
}

/* 手机竖屏 */
@media (max-width: 768px) {
    .tuner-modal-content {
        width: 96%;
        max-height: 92vh;
        border-radius: 16px;
    }

    .tuner-header {
        padding: 14px 16px 10px;
    }

    .tuner-header h2 {
        font-size: 18px;
        letter-spacing: 3px;
    }

    .tuner-body {
        padding: 12px;
        gap: 10px;
    }

    .tuner-gauge {
        width: 180px;
        height: 110px;
    }

    .tuner-gauge-bg {
        width: 180px;
        height: 180px;
    }

    .tuner-gauge-face {
        width: 154px;
        height: 154px;
    }

    .tuner-gauge-ticks {
        width: 154px;
        height: 154px;
    }

    .tuner-tick {
        transform-origin: 50% 71px;
    }

    .tuner-needle {
        height: 64px;
    }

    .tuner-current-note {
        font-size: 24px;
    }

    .tuner-data-value {
        font-size: 18px;
    }

    #tunerStringGrid {
        grid-template-columns: repeat(7, 1fr);
        gap: 5px;
    }

    .tuner-string-btn {
        font-size: 14px;
        border-radius: 8px;
    }

    .tuner-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
}

/* 小屏手机 */
@media (max-width: 480px) {
    .tuner-modal-content {
        width: 98%;
        max-height: 95vh;
    }

    .tuner-header h2 {
        font-size: 16px;
        letter-spacing: 2px;
    }

    .tuner-gauge {
        width: 160px;
        height: 100px;
    }

    .tuner-gauge-bg {
        width: 160px;
        height: 160px;
    }

    .tuner-gauge-face {
        width: 136px;
        height: 136px;
    }

    .tuner-gauge-ticks {
        width: 136px;
        height: 136px;
    }

    .tuner-tick {
        transform-origin: 50% 63px;
    }

    .tuner-needle {
        height: 56px;
    }

    .tuner-current-note {
        font-size: 22px;
    }

    .tuner-data-value {
        font-size: 16px;
    }

    .tuner-data-item {
        min-width: 70px;
    }

    #tunerStringGrid {
        grid-template-columns: repeat(7, 1fr);
        gap: 4px;
    }

    .tuner-string-btn {
        font-size: 13px;
        border-radius: 6px;
    }

    .tuner-btn {
        padding: 7px 14px;
        font-size: 12px;
    }

    .tuner-status-bar {
        padding: 8px 10px;
    }

    .tuner-section-title {
        font-size: 11px;
    }
}

/* 移动端横屏 */
@media (max-width: 768px) and (orientation: landscape) {
    .tuner-modal-content {
        max-width: 600px;
        max-height: 90vh;
    }

    .tuner-body {
        flex-direction: row;
        flex-wrap: wrap;
        align-content: flex-start;
    }

    .tuner-gauge-container {
        flex: 1;
        min-width: 180px;
    }

    .tuner-string-section {
        flex: 1;
        min-width: 180px;
    }

    #tunerStringGrid {
        grid-template-columns: repeat(7, 1fr);
    }

    .tuner-controls {
        width: 100%;
    }
}
