/* ============================================
古琴智能调音器 Pro - 样式文件
============================================ */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

body {
    -webkit-touch-callout: none;
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    color: #e8e8e8;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 15px;
    overflow-x: hidden;
}

/* 登录状态栏 */
.auth-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: rgba(0,0,0,0.8);
    color: #f5d76e;
    padding: 8px 15px;
    font-size: 0.85em;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 9998;
    backdrop-filter: blur(5px);
    border-bottom: 1px solid rgba(245, 215, 110, 0.3);
}

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

.btn-small {
    padding: 4px 8px;
    background: rgba(245, 215, 110, 0.2);
    border: 1px solid #f5d76e;
    color: #f5d76e;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8em;
}

.btn-small:hover {
    background: rgba(245, 215, 110, 0.3);
}

/* 正式版标识 */
.version-badge {
    position: fixed;
    top: 45px;
    right: 10px;
    background: linear-gradient(135deg, #f5d76e 0%, #e8b54e 100%);
    color: #1a1a2e;
    padding: 4px 8px;
    border-radius: 6px;
    font-size: 10px;
    font-weight: 700;
    z-index: 9999;
    pointer-events: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
    letter-spacing: 0.5px;
}

.copyright-notice {
    position: fixed;
    bottom: 5px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.6);
    color: #a0a0a0;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 9px;
    z-index: 9999;
    pointer-events: none;
    backdrop-filter: blur(2px);
}

/* 主容器 */
.container {
    width: 100%;
    max-width: 500px;
    background: rgba(255, 255, 255, 0.05);
    backdrop-filter: blur(10px);
    border-radius: 15px;
    padding: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 50px;
    margin-bottom: 30px;
}

h1 {
    font-size: 1.5em;
    color: #f5d76e;
    text-align: center;
    margin-bottom: 15px;
    font-weight: 300;
    letter-spacing: 1px;
}

/* 提示框 */
.warning, .success, .lock-indicator, .tips {
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.8em;
    display: none;
    line-height: 1.5;
}

.warning {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid #ef4444;
    color: #fca5a5;
}

.success {
    background: rgba(74, 222, 128, 0.15);
    border: 1px solid #4ade80;
    color: #a7f3d0;
}

.tips {
    background: rgba(100, 181, 246, 0.1);
    border: 1px solid #64b5f6;
    color: #90caf9;
}

.lock-indicator {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid #10b981;
    color: #10b981;
    text-align: center;
}

/* 区块 */
.section {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
    padding: 12px;
    margin-bottom: 12px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.section-title {
    color: #f5d76e;
    font-size: 0.95em;
    margin-bottom: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 5px;
}

.input-group {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

/*表单控件 */
select, input[type="number"], input[type="text"], input[type="password"], input[type="email"] {
    padding: 8px 10px;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    flex: 1;
    min-width: 100px;
    transition: all 0.3s;
    max-width: 100%;
    width: 100%;
}

select:disabled, input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

select:focus, input:focus {
    outline: none;
    border-color: #f5d76e;
    background: rgba(255, 255, 255, 0.12);
}

/* 按钮 */
.btn {
    padding: 8px 12px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.3s;
    white-space: nowrap;
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.btn-primary {
    background: linear-gradient(135deg, #f5d76e 0%, #e8b54e 100%);
    color: #1a1a2e;
    border: none;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

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

/* 状态栏 */
.status {
    background: rgba(0, 0, 0, 0.3);
    padding: 10px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 0.85em;
    border-left: 3px solid #f5d76e;
    min-height: 40px;
    display: flex;
    align-items: center;
}

/* 显示区 */
.display {
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 18px;
    text-align: center;
    margin-bottom: 12px;
    min-height: 150px;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.string-name {
    font-size: 2em;
    color: #f5d76e;
    min-height: 42px;
    font-weight: 300;
    letter-spacing: 2px;
    transition: all 0.3s;
}

.frequency {
    font-size: 1.3em;
    color: #fff;
    margin: 5px 0;
    font-variant-numeric: tabular-nums;
}

.offset {
    font-size: 1em;
    font-weight: 600;
    min-height: 24px;
    transition: all 0.3s;
}

.offset.excellent { color: #10b981; }
.offset.good { color: #f5d76e; }
.offset.bad { color: #ef4444; }
.offset.neutral { color: #a0a0a0; }

/* 振动状态 */
.vibration-status {
    background: rgba(255, 255, 255, 0.05);
    padding: 8px;
    border-radius: 6px;
    margin-top: 8px;
    font-size: 0.75em;
    color: #a0a0a0;
    text-align: center;
    display: none;
}

.vibration-status .bar {
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius:  5px;
}

.vibration-status .bar-fill {
    height: 100%;
    background: #f5d76e;
    width: 0%;
    transition: width 0.1s linear;
}

/* 操作按钮 */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-bottom: 12px;
}

/* 弦列表 */
.string-list {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 6px;
    font-size: 0.78em;
}

.string-item {
    background: rgba(255, 255, 255, 0.05);
    padding: 6px 4px;
    border-radius: 6px;
    text-align: center;
    border: 1px solid transparent;
    transition: all 0.3s;
}

.string-item.active {
    background: rgba(245, 215, 110, 0.2);
    border-color: #f5d76e;
    color: #f5d76e;
    transform: scale(1.05);
}

.string-item.locked {
    background: rgba(16, 185, 129, 0.2);
    border-color: #10b981;
    color: #10b981;
}

.string-item.accurate {
    background: rgba(16, 185, 129, 0.4);
    border-color: #10b981;
    color: #12px;
    overflow: hidden;
    margin-top:0b981;
    font-weight: bold;
}

.string-item .name {
    font-weight: 600;
    display: block;
    font-size: 0.95em;
    margin-bottom: 2px;
}

.string-item .freq {
    font-size: 0.85em;
    color: #a0a0a0;
}

/* 容差说明 */
.tolerance-info {
    background: rgba(0, 0, 0, 0.2);
    padding: 8px;
    border-radius: 6px;
    margin-top: 8px;
    font-size: 0.75em;
    color: #a0a0a0;
}

.tolerance-info .legend {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 5px;
}

.tolerance-info .legend span {
    display: flex;
    align-items: center;
    gap: 3px;
}

.tolerance-info .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot.green { background: #10b981; }
.dot.yellow { background: #f5d76e; }
.dot.red { background: #ef4444; }

/* 加载中 */
.loading {
    display: none;
    text-align: center;
    padding: 12px;
    color: #f5d76e;
}

.spinner {
    border: 3px solid rgba(245, 215, 110, 0.2);
    border-top: 3px solid #f5d76e;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    animation: spin 1s linear infinite;
    margin: 0 auto 6px;
}

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

/* 标签页 */
.tabs {
    display: flex;
    gap: 5px;
    margin-bottom: 10px;
    background: rgba(0,0,0,0.2);
    padding: 4px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
}

.tab {
    flex: 1;
    padding: 10px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #a0a0a0;
    font-size: 13px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    font-weight: 500;
}

.tab:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.tab.active {
    background: linear-gradient(135deg, #f5d76e 0%, #e8b54e 100%);
    color: #1a1a2e;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(245, 215, 110, 0.3);
}

.tab:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 琴曲搜索 */
.song-search-container {
    position: relative;
    margin-bottom: 8px;
}

.search-box {
    width: 100%;
    padding: 10px 12px;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    transition: all 0.3s;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.search-box::placeholder {
    color: #a0a0a0;
}

.search-box:focus {
    outline: none;
    border-color: #f5d76e;
    background: rgba(255,255,255,0.12);
    box-shadow: 0 0 0 3px rgba(245, 215, 110, 0.1);
}

.search-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #a0a0a0;
    pointer-events: none;
}

/* 折叠容器 */
.song-collapsible {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.4s ease-out, opacity 0.4s ease-out;
    opacity: 0;
}

.song-collapsible.expanded {
    max-height: 280px;
    opacity: 1;
    margin-top: 8px;
}

/* 琴曲列表 */
.song-list {
    background: rgba(0,0,0,0.15);
    border-radius: 8px;
    padding: 6px;
    border: 1px solid rgba(255,255,255,0.05);
    max-height: 220px;
    overflow-y: auto;
}

.song-list::-webkit-scrollbar {
    width: 6px;
}

.song-list::-webkit-scrollbar-thumb {
    background: rgba(245, 215, 110, 0.3);
    border-radius: 3px;
}

.song-list::-webkit-scrollbar-thumb:hover {
    background: rgba(245, 215, 110, 0.5);
}

.group-title {
    color: #f5d76e;
    font-size: 0.8em;
    margin: 8px 4px 4px;
    padding: 6px 8px;
    background: rgba(245, 215, 110, 0.1);
    border-radius: 6px;
    font-weight: 600;
    letter-spacing: 0.5px;
    border-left: 2px solid #f5d76e;
}

.song-item {
    padding: 8px 10px;
    margin: 3px 2px;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.85em;
    transition: all 0.2s;
    border: 1px solid transparent;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.song-item:hover {
    background: rgba(245, 215, 110, 0.15);
    border-color: rgba(245, 215, 110, 0.3);
    transform: translateX(2px);
}

.song-item.selected {
    background: rgba(245, 215, 110, 0.25);
    border-color: #f5d76e;
    color: #f5d76e;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(245, 215, 110, 0.2);
}

.song-item .mode-tag {
    font-size: 0.7em;
    color: #a0a0a0;
    background: rgba(255,255,255,0.1);
    padding: 2px 6px;
    border-radius: 4px;
    margin-left: 8px;
}

.song-item.selected .mode-tag {
    background: rgba(26, 26, 46, 0.5);
    color: #f5d76e;
}

/* 弹窗 */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.85);
    z-index: 1000;
    justify-content: center;
    align-items: center;
    padding: 15px;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: #1a1a2e;
    border: 1px solid #f5d76e;
    border-radius: 12px;
    padding: 0;
    max-width: 500px;
    width: 100%;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: 0 20px 50px rgba(0,0,0,0.5);
}

.modal-header {
    background: linear-gradient(135deg, #f5d76e 0%, #e8b54e 100%);
    color: #1a1a2e;
    font-size: 1.1em;
    padding: 15px 20px;
    font-weight: 700;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-body {
    padding: 15px 20px;
    max-height: 60vh;
    overflow-y: auto;
    font-size: 0.9em;
    line-height: 1.6;
    -webkit-user-select: text;
    user-select: text;
}

.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #f5d76e;
    border-radius: 3px;
}

.mode-detail {
    margin-bottom: 12px;
    padding: 10px;
    background: rgba(255,255,255,0.03);
    border-radius: 8px;
    border-left: 3px solid #f5d76e;
}

.mode-detail strong {
    color: #f5d76e;
    display: block;
    margin-bottom: 6px;
    font-size: 1.05em;
}

.mode-detail .info-row {
    margin: 4px 0;
    color: #d0d0d0;
}

.mode-detail .info-row em {
    color: #a0a0a0;
    font-style: normal;
}

.modal-close {
    background: #ef4444;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 0 0 10px 10px;
    cursor: pointer;
    width: 100%;
    font-weight: 600;
    transition: all 0.3s;
}

.modal-close:hover {
    background: #dc2626;
}

/* 认证弹窗特殊样式 */
.auth-input {
    width: 100%;
    padding: 10px;
    margin: 6px 0;
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.2);
    border-radius: 6px;
    color: #fff;
    font-size: 14px;
}

.auth-input:focus {
    outline: none;
    border-color: #f5d76e;
    background: rgba(255,255,255,0.12);
}

#toggleAuth {
    text-decoration: none;
    font-size: 0.9em;
}

#toggleAuth:hover {
    text-decoration: underline;
}

/* 搜索提示 */
.search-hint {
    font-size: 0.75em;
    color: #a0a0a0;
    text-align: center;
    margin-top: 5px;
    padding: 8px;
    background: rgba(255,255,255,0.05);
    border-radius: 6px;
    border: 1px dashed rgba(255,255,255,0.2);
}

.search-hint.hidden {
    display: none;
}

/* 响应式调整 */
@media (max-width: 480px) {
    .container {
        padding: 15px;
        border-radius: 12px;
        margin-top: 60px;
    }

    h1 {
        font-size: 1.3em;
    }

    .string-name {
        font-size: 1.7em;
    }

    .frequency {
        font-size: 1.1em;
    }

    .offset {
        font-size: 0.95em;
    }

    .string-list {
        grid-template-columns: 1fr 1fr;
    }

    .section {
        padding: 10px;
    }

    .tab {
        font-size: 12px;
        padding: 8px;
    }

    .song-item {
        font-size: 0.8em;
        padding: 6px 8px;
    }

    .modal-content {
        margin: 10px;
    }

    .search-box {
        font-size: 13px;
        padding: 8px 10px;
    }

    .auth-bar {
        font-size: 0.75em;
        padding: 6px 10px;
    }

    .version-badge {
        top: 42px;
        font-size: 9px;
    }
}

/* 禁用状态 */
button:disabled, input:disabled, select:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 隐藏滚动条但保持功能 */
.song-list, .modal-body {
    scrollbar-width: thin;
    scrollbar-color: rgba(245, 215, 110, 0.5) rgba(255,255,255,0.05);
}

/* 曲目预览样式 */
.song-preview {
    font-style: italic;
    color: #f5d76e;
}

/* 查看全部按钮 */
.btn-show-all-songs {
    margin-top: 8px;
    padding: 4px 12px;
    background: #64b5f6;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.btn-show-all-songs:hover {
    background: #42a5f5;
}

/* 完整曲目列表 */
.song-full-list {
    margin-top: 10px;
    max-height: 300px;
    overflow-y: auto;
    padding: 10px;
    background: #2a2a3e;
    border-radius: 4px;
}

.song-item-full {
    padding: 6px 8px;
    border-bottom: 1px solid #3a3a4e;
    font-size: 14px;
}

.song-item-full:last-child {
    border-bottom: none;
}

.song-item-full:hover {
    background: rgba(100, 181, 246, 0.1);
}

/* 微信浏览器兼容样式 */
@media screen and (-webkit-min-device-pixel-ratio:0) {
    /* 针对微信浏览器的特殊样式 */
    .string-item.locked-string {
        background: rgba(16, 185, 129, 0.25) !important;
        border-left: 4px solid #10b981 !important;
        opacity: 1 !important;
    }

    .string-item.locked-string .name {
        color: #10b981 !important;
        font-weight: bold !important;
    }

    .string-item.current-string.locked {
        background: rgba(16, 185, 129, 0.4) !important;
        border-left: 6px solid #10b981 !important;
        transform: scale(1.02) !important;
    }

    .string-item.current-string.adjusting {
        background: rgba(245, 215, 110, 0.3) !important;
        border-left: 6px solid #f5d76e !important;
        transform: scale(1.02) !important;
    }

    .string-item.current-string.active {
        background: rgba(100, 181, 246, 0.3) !important;
        border-left: 6px solid #64b5f6 !important;
        transform: scale(1.02) !important;
    }
}

/* 强制微信浏览器重绘 */
.string-item {
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
}
