* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Segoe UI', 'Microsoft YaHei', sans-serif;
}

body {
    background-color: #f5f3f3; /* 与Main.css保持一致 */
    color: #444;
    min-height: 100vh;
    padding: 0;
    padding-top: 80px; /* 为固定导航栏留出空间 */
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    overflow-x: hidden;
    margin: 0;
}

/* 导航栏样式 - 从Main.css提取 */
.header {
    background-color: #4a7694;
    color: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 20px;
    position: relative;
}

.logo-section {
    display: flex;
    align-items: center;
}

.logo {
    font-size: 1.4rem;
    font-weight: 400;
    margin: 0;
    color: white;
    white-space: nowrap;
}

.navbar {
    display: flex;
    align-items: center;
}

.nav-list {
    list-style: none;
    display: flex;
    gap: 15px;
    margin: 0;
    padding: 0;
}

.nav-list li a {
    color: white;
    text-decoration: none;
    padding: 8px 15px;
    border-radius: 4px;
    transition: all 0.3s;
    font-size: 0.9rem;
    font-weight: 400;
    white-space: nowrap;
}

.nav-list li a:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.nav-list li a.active {
    background-color: rgba(255, 255, 255, 0.3);
    font-weight: 500;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    width: 30px;
    height: 25px;
    justify-content: space-between;
}

.hamburger-line {
    width: 100%;
    height: 3px;
    background-color: white;
    border-radius: 2px;
    transition: all 0.3s ease;
}

.hamburger-line.active:nth-child(1) {
    transform: rotate(45deg) translate(6px, 6px);
}

.hamburger-line.active:nth-child(2) {
    opacity: 0;
}

.hamburger-line.active:nth-child(3) {
    transform: rotate(-45deg) translate(6px, -6px);
}

.nav-list.nav-active {
    display: flex !important;
    flex-direction: column;
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background-color: #4a7694;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
    z-index: 1001;
}

.nav-list.nav-active li {
    width: 100%;
    text-align: center;
}

.nav-list.nav-active li a {
    display: block;
    padding: 12px 15px;
    border-radius: 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-list.nav-active li a:hover {
    background-color: rgba(255, 255, 255, 0.15);
}

/* 返回主页链接样式 */
.home-link {
    color: white;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: 4px;
    transition: all 0.3s;
    font-size: 0.9rem;
    font-weight: 400;
    white-space: nowrap;
    border: 1px solid rgba(255, 255, 255, 0.3);
    margin-right: 15px;
}

.home-link:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateY(-1px);
}

.container {
    max-width: min(1400px, 95vw);
    margin: 0 auto;
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
    margin-top: 20px;
    margin-bottom: 20px;
    width: 100%;
    box-sizing: border-box;
}

.page-header {
    text-align: center;
    margin-bottom: 25px;
    padding-bottom: 15px;
    border-bottom: 1px solid #eaeaea;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
}

.page-header h1 {
    font-size: 2rem;
    margin-bottom: 8px;
    color: #5d8aa8;
    font-weight: 300;
    text-align: center;
    width: 100%;
}

.subtitle {
    font-size: 1rem;
    color: #888;
    font-weight: 300;
    text-align: center;
    width: 100%;
    line-height: 1.5;
}

.main-content {
    display: grid;
    grid-template-columns: 1.2fr 0.8fr;
    gap: 25px;
    width: 100%;
    box-sizing: border-box;
}

.panel {
    background: #fcfcfc;
    border-radius: 10px;
    padding: 18px;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.03);
    border: 1px solid #f0f0f0;
    width: 100%;
    box-sizing: border-box;
}

h2 {
    font-size: 1.3rem;
    margin-bottom: 12px;
    color: #5d8aa8;
    font-weight: 400;
    border-bottom: 1px solid #eaeaea;
    padding-bottom: 6px;
}

.control-panel {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 15px;
}

button {
    background: #5d8aa8;
    color: white;
    border: none;
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 400;
    transition: all 0.3s;
    flex: 1;
    min-width: 100px;
    font-size: 0.85rem;
}

button:hover {
    background: #4a7694;
    transform: translateY(-1px);
}

button.primary {
    background: #8bb4c4;
}

button.primary:hover {
    background: #79a2b2;
}

select, input {
    padding: 8px;
    border-radius: 6px;
    border: 1px solid #ddd;
    background: white;
    color: #555;
    flex: 1;
    font-size: 0.85rem;
}

.piano-container {
    margin-top: 15px;
    overflow-x: auto;
    padding: 12px;
    background: #f7f9fa;
    border-radius: 8px;
    width: 100%;
    box-sizing: border-box;
    -webkit-overflow-scrolling: touch;
}

.piano {
    display: flex;
    position: relative;
    height: 140px;
    min-width: 800px;
}

.key {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 0 0 5px 5px;
    cursor: pointer;
    z-index: 1;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 8px;
    font-size: 0.7rem;
    color: rgba(0, 0, 0, 0.6);
}

.white {
    background: white;
    width: 35px;
    height: 100%;
    margin-right: -1px;
}

.black {
    background: #333;
    width: 22px;
    height: 60%;
    margin-left: -11px;
    margin-right: -11px;
    z-index: 2;
    color: rgba(255, 255, 255, 0.8);
}

.active {
    background: #8bb4c4;
}

.visualizer {
    height: 100px;
    margin: 15px 0;
    background: #f7f9fa;
    border-radius: 8px;
    position: relative;
    overflow: hidden;
    border: 1px solid #eaeaea;
}

.pitch-display {
    text-align: center;
    font-size: 1.6rem;
    margin: 10px 0;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5d8aa8;
    background: #f7f9fa;
    border-radius: 8px;
}

.midi-editor {
    margin-top: 15px;
    background: #f7f9fa;
    border-radius: 8px;
    padding: 12px;
    border: 1px solid #eaeaea;
    width: 100%;
    box-sizing: border-box;
}

.editor-controls {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.editor-container {
    display: flex;
    overflow-x: auto;
}

.note-labels {
    display: flex;
    flex-direction: column-reverse; /* 音符从低到高排列 */
    width: 60px;
    margin-right: 5px;
}

.note-label {
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    color: #5d8aa8;
    background: #e6f2f5;
    border-radius: 4px;
    margin-bottom: 2px;
}

.editor-grid {
    display: grid;
    grid-template-rows: repeat(16, 30px); /* 16个音符行，每行30px */
    grid-template-columns: repeat(24, 30px); /* 24个时间单位，每列30px */
    gap: 1px;
    height: auto; /* 让高度自适应内容 */
    border: 2px solid #a0c0d0;
    border-radius: 6px;
    padding: 2px;
    background-color: #e6f2f5; /* 网格背景色 */
    overflow-x: auto; /* 允许水平滚动 */
    overflow-y: hidden; /* 隐藏垂直滚动 */
    width: fit-content; /* 宽度适应内容 */
    min-width: 100%; /* 确保至少占满父容器宽度 */
}

.grid-cell {
    background: white;
    width: 30px; /* 固定宽度 */
    height: 30px; /* 固定高度 */
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
    border: 1px solid #e0e0e0; /* 单元格边框 */
}

.grid-cell.active {
    background: #8bb4c4;
}

.grid-cell:hover {
    background: #e6f2f5;
}

/* 八度分界线 - 在B和C音符之间 */
.grid-cell[data-note="C4"],
.grid-cell[data-note="C5"] {
    border-top: 2px solid #a0c0d0;
}

/* 小节分界线 - 每4个时间单位（一个小节） */
.editor-grid .grid-cell:nth-child(24n) {
    border-right: none;
}
.editor-grid .grid-cell:nth-child(4n):not(:nth-child(24n)) {
    border-right: 2px solid #a0c0d0;
}


/* 加深左侧#号音符背景色 */
.note-label[data-note*="#"] {
    background: #d1e3ea; /* 加深#号音符背景色 */
    font-weight: 600; /* 加粗#号音符字体 */
}

.collapsible-section {
    margin-top: 12px;
}

.collapse-toggle {
    width: 100%;
    text-align: left;
    background: #f0f0f0;
    color: #555;
    margin-bottom: 8px;
}

.collapse-toggle:hover {
    background: #e0e0e0;
    transform: none;
}

.preset-list {
    max-height: 0;
    overflow-y: auto;
    background: #f7f9fa;
    border-radius: 8px;
    padding: 0 8px;
    border: 1px solid transparent;
    transition: all 0.3s ease;
    opacity: 0;
}

.preset-list.expanded {
    max-height: 220px;
    padding: 8px;
    border-color: #eaeaea;
    opacity: 1;
}

.preset-item {
    padding: 8px;
    margin: 4px 0;
    background: white;
    border-radius: 5px;
    cursor: pointer;
    transition: background 0.3s;
    border: 1px solid #eaeaea;
    font-size: 0.85rem;
}

.preset-item:hover {
    background: #e6f2f5;
}

.preset-item.active {
    background: #8bb4c4;
    color: white;
}

.note-display {
    font-size: 1.4rem;
    text-align: center;
    margin: 12px 0;
    height: 45px;
    background: #f7f9fa;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #5d8aa8;
}

.progress-bar {
    width: 100%;
    height: 6px;
    background: #eaeaea;
    border-radius: 4px;
    margin: 12px 0;
    overflow: hidden;
}

.progress {
    height: 100%;
    background: #8bb4c4;
    width: 0%;
    transition: width 0.1s;
    border-radius: 4px;
}

.status {
    text-align: center;
    margin: 8px 0;
    color: #5d8aa8;
    font-weight: 500;
    font-size: 0.85rem;
}

@media (max-width: 1100px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .container {
        padding: 20px;
    }
    
    .panel {
        padding: 18px;
    }
}

/* 移动端导航栏改进 */
@media (max-width: 768px) {
    body {
        padding-top: 70px; /* 调整为与header高度一致 */
    }
    
    .header-container {
        padding: 10px 15px; /* 调整内边距 */
        height: 70px; /* 调整为与首页一致的高度 */
    }

    .logo-section {
        flex-grow: 1; /* 允许logo部分占据更多空间 */
        justify-content: flex-start;
    }

    .home-link {
        font-size: 0.8rem;
        padding: 6px 10px;
        margin-right: 10px;
        border: 1px solid rgba(255, 255, 255, 0.5);
    }
    
    .logo {
        font-size: 1.1rem;
        margin: 0;
        line-height: 1.2;
        padding: 0;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 120px;
    }

    .navbar {
        flex-grow: 0; /* 不让navbar占据额外空间 */
    }
    
    .nav-toggle {
        display: flex; /* 确保汉堡菜单显示 */
        flex-direction: column;
        background: none;
        border: 1px solid rgba(255, 255, 255, 0.3);
        border-radius: 4px;
        cursor: pointer;
        justify-content: center;
        align-items: center;
        padding: 6px 10px; /* 减小内边距 */
        width: 40px; /* 固定宽度 */
        height: 35px; /* 固定高度 */
    }
    
    .hamburger-line {
        width: 18px; /* 调整汉堡线宽度 */
        height: 2px; /* 调整汉堡线高度 */
        background: white;
        margin: 2px 0; /* 调整汉堡线间距 */
        transition: all 0.3s ease;
    }
    
    .hamburger-line.active:nth-child(1) {
        transform: rotate(45deg) translate(5px, 5px); /* 调整旋转中心 */
    }
    
    .hamburger-line.active:nth-child(2) {
        opacity: 0;
    }
    
    .hamburger-line.active:nth-child(3) {
        transform: rotate(-45deg) translate(5px, -5px); /* 调整旋转中心 */
    }
    
    .nav-list {
        visibility: hidden;
        opacity: 0;
        flex-direction: column;
        position: absolute;
        top: 70px; /* 从导航栏下方展开 */
        right: 0;
        width: 180px; /* 调整菜单宽度 */
        background-color: #4a7694;
        box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
        z-index: 1001;
        border-radius: 0 0 8px 8px;
        transform: translateX(100%); /* 默认隐藏在右侧 */
        transition: transform 0.3s ease-out, opacity 0.3s ease-out, visibility 0.3s ease-out;
    }

    .nav-list.nav-active {
        display: flex;
        visibility: visible;
        opacity: 1;
        transform: translateX(0); /* 激活时滑入 */
    }
    
    .nav-list li {
        width: 100%;
        text-align: center;
    }
    
    .nav-list li a {
        display: block;
        padding: 12px 15px;
        border-radius: 0;
        border-bottom: 1px solid rgba(255, 255, 255, 0.1);
        color: white;
        text-align: center;
        font-size: 0.9rem;
    }
    
    .nav-list li a:hover {
        background-color: rgba(255, 255, 255, 0.15);
        color: white;
    }
    
    .container {
        padding: 15px;
        margin: 10px;
        width: calc(100% - 20px);
    }
    
    .page-header {
        text-align: center;
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 1px solid #eaeaea;
        width: 100%;
        margin-left: 0;
        margin-right: 0;
        padding-left: 0;
        padding-right: 0;
    }
    
    .page-header h1 {
        font-size: 1.1rem;
        margin-bottom: 4px;
        color: #5d8aa8;
        font-weight: 300;
        width: 100%;
        line-height: 1.2;
    }
    
    .subtitle {
        font-size: 0.7rem;
        color: #888;
        font-weight: 300;
        width: 100%;
        line-height: 1.2;
    }
    
    .control-panel {
        flex-direction: column;
        gap: 5px;
        margin-bottom: 10px;
    }
    
    button, select, input {
        width: 100%;
        min-width: auto;
        font-size: 0.7rem;
        padding: 6px 8px;
    }
    
    .piano-container {
        padding: 5px;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        width: 100%;
        margin-top: 8px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .piano {
        height: 80px;
    }
    
    .white {
        width: 18px;
        flex-shrink: 0;
    }
    
    .black {
        width: 12px;
        margin-left: -6px;
        margin-right: -6px;
        flex-shrink: 0;
    }
    
    .key {
        font-size: 0.4rem;
        padding-bottom: 2px;
    }
    
    .midi-editor {
        padding: 5px;
        width: 100%;
        overflow-x: hidden;
        margin-top: 8px;
        box-sizing: border-box;
    }
    
    .editor-controls {
        flex-direction: column;
        gap: 4px;
        margin-bottom: 6px;
    }
    
    .editor-container {
        overflow-x: auto;
        width: 100%;
        position: relative;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .editor-grid {
        height: 300px;
        grid-template-columns: repeat(16, 1fr);
    }

    .grid-cell {
        width: 100%;
        height: 100%;
        min-width: 2px;
        min-height: 3px;
        box-sizing: border-box;
    }

    .note-label {
        height: 100%;
        font-size: 0.1rem;
        margin-bottom: 1px;
        padding: 0 1px;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .note-labels {
        height: 64px;
        width: 16px; /* 进一步减小标签宽度 */
        box-sizing: border-box;
    }
    
    .note-display {
        font-size: 0.9rem;
        height: 30px;
        margin: 5px 0;
        font-size: 0.8rem;
    }
    
    .pitch-display {
        font-size: 1rem;
        height: 30px;
        font-size: 0.8rem;
    }
    
    .visualizer {
        height: 50px;
        margin: 8px 0;
    }
    
    .progress-bar {
        margin: 5px 0;
    }
    
    .preset-item {
        padding: 4px;
        font-size: 0.7rem;
    }
    
    h2 {
        font-size: 0.95rem;
        margin-bottom: 6px;
    }
    
    h3 {
        font-size: 0.85rem;
        margin-bottom: 5px;
    }
    
    .panel {
        padding: 8px;
        margin-bottom: 8px;
    }
    
    .main-content {
        gap: 12px;
    }
    
    .collapsible-section {
        margin-top: 6px;
    }
    
    .collapse-toggle {
        margin-bottom: 5px;
        padding: 5px 6px;
        font-size: 0.75rem;
    }
    
    .preset-list.expanded {
        max-height: 160px;
        padding: 5px;
    }
    
    .status {
        margin: 5px 0;
        font-size: 0.75rem;
    }
}

/* 小屏幕移动设备适配 */
@media (max-width: 480px) {
    html {
        overflow-x: hidden;
        width: 100%;
    }
    
    body {
        padding-top: 65px;
        overflow-x: hidden;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        width: 100%;
        position: relative;
        max-width: 100vw;
    }
    
    .header {
        padding: 6px 10px;
        height: 70px; /* 调整导航栏高度 */
        max-width: 100vw;
    }
    
    .nav-brand h1 {
        font-size: 1rem; /* 进一步减小标题大小 */
        margin-bottom: 5px;
        max-width: 100px;
    }
    
    .container {
        padding: 8px;
        margin-top: 5px;
        margin-bottom: 5px;
        border-radius: 6px;
        width: calc(100% - 10px);
        max-width: 100%;
        box-sizing: border-box;
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .page-header {
        margin-bottom: 10px;
    }
    
    .page-header h1 {
        font-size: 1rem; /* 调整页面标题大小 */
    }
    
    .subtitle {
        font-size: 0.7rem; /* 调整副标题大小 */
    }
    
    .panel {
        padding: 8px;
    }
    
    .piano {
        height: 70px;
        min-width: auto;
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    .white {
        width: 16px;
        flex-shrink: 0;
    }
    
    .black {
        width: 10px;
        margin-left: -5px;
        margin-right: -5px;
        flex-shrink: 0;
    }
    
    .key {
        font-size: 0.35rem;
        padding-bottom: 2px;
    }
    
    .editor-grid {
        grid-template-columns: repeat(16, minmax(2px, 1fr)); /* 统一减少到16列 */
        grid-template-rows: repeat(16, minmax(2px, 1fr)); /* 使用弹性高度 */
        height: 48px; /* 进一步减小总高度 */
        gap: 1px;
        border: 1px solid #8bb4c4;
        padding: 1px;
        width: 100%;
        min-width: 0;
        max-width: 100vw;
        font-size: 0;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    .grid-cell {
        width: 100%;
        height: 100%;
        min-width: 1px;
        min-height: 2px;
        box-sizing: border-box;
    }
    
    .note-label {
        height: 100%;
        font-size: 0.1rem;
        margin-bottom: 1px;
        padding: 0 1px;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .note-labels {
        height: 48px;
        width: 14px; /* 进一步减小标签宽度 */
        box-sizing: border-box;
    }
    
    .note-display {
        font-size: 0.8rem;
        height: 28px;
        margin: 4px 0;
    }
    
    .pitch-display {
        font-size: 0.9rem;
        height: 28px;
    }
    
    .visualizer {
        height: 45px;
        margin: 6px 0;
    }
    
    .control-panel {
        gap: 4px;
        margin-bottom: 8px;
    }
    
    button, select, input {
        padding: 6px;
        font-size: 0.65rem;
    }
    
    .editor-container {
        overflow-x: auto;
        width: 100%;
        position: relative;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .midi-editor {
        padding: 4px;
        width: 100%;
        overflow-x: hidden;
        margin-top: 6px;
        box-sizing: border-box;
    }
    
    .editor-controls {
        flex-direction: column;
        gap: 3px;
        margin-bottom: 5px;
    }
    
    h2 {
        font-size: 0.9rem;
        margin-bottom: 5px;
    }
    
    h3 {
        font-size: 0.8rem;
        margin-bottom: 4px;
    }
    
    .main-content {
        gap: 10px;
    }
    
    .collapsible-section {
        margin-top: 5px;
    }
    
    .collapse-toggle {
        margin-bottom: 4px;
        padding: 4px 5px;
        font-size: 0.7rem;
    }
    
    .preset-list.expanded {
        max-height: 140px;
        padding: 4px;
    }
    
    .status {
        margin: 4px 0;
        font-size: 0.7rem;
    }
    
    .progress-bar {
        margin: 4px 0;
    }
    
    .preset-item {
        padding: 3px;
        font-size: 0.65rem;
    }
}

/* 超小屏幕设备适配 */
@media (max-width: 360px) {
    html {
        overflow-x: hidden;
        width: 100%;
    }
    
    body {
        padding-top: 60px;
        overflow-x: hidden;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        width: 100%;
        position: relative;
        max-width: 100vw;
    }
    
    .header {
        padding: 5px 8px;
        height: 65px; /* 进一步调整导航栏高度 */
        max-width: 100vw;
    }
    
    .nav-brand h1 {
        font-size: 0.85rem; /* 在超小屏幕上进一步减小标题 */
        max-width: 100px;
    }
    
    .container {
        padding: 6px;
        margin-top: 4px;
        margin-bottom: 4px;
        width: calc(100% - 12px);
        max-width: 100%;
        box-sizing: border-box;
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .page-header h1 {
        font-size: 0.95rem; /* 在超小屏幕上调整页面标题 */
    }
    
    .subtitle {
        font-size: 0.65rem;
    }
    
    .piano {
        height: 70px;
        min-width: auto;
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    .white {
        width: 14px;
        flex-shrink: 0;
    }
    
    .black {
        width: 8px;
        margin-left: -4px;
        margin-right: -4px;
        flex-shrink: 0;
    }
    
    .key {
        font-size: 0.3rem;
        padding-bottom: 1px;
    }
    
    .editor-grid {
        grid-template-columns: repeat(16, minmax(2px, 1fr)); /* 统一减少到16列 */
        grid-template-rows: repeat(16, minmax(2px, 1fr)); /* 使用弹性高度 */
        height: 48px; /* 增加高度以保持可操作性 */
        gap: 1px;
        border: 1px solid #8bb4c4;
        padding: 1px;
        width: 100%;
        min-width: 0;
        max-width: 100vw;
        font-size: 0;
        box-sizing: border-box;
        overflow: hidden;
    }
    
    .grid-cell {
        width: 100%;
        height: 100%;
        min-width: 1px;
        min-height: 1px;
        box-sizing: border-box;
    }
    
    .note-label {
        height: 100%;
        font-size: 0.08rem;
        margin-bottom: 0.5px;
        padding: 0 0.5px;
        box-sizing: border-box;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .note-labels {
        height: 40px;
        width: 12px; /* 进一步减小标签宽度 */
        box-sizing: border-box;
    }
    
    .note-display {
        font-size: 0.75rem;
        height: 24px;
        margin: 3px 0;
    }
    
    .pitch-display {
        font-size: 0.8rem;
        height: 24px;
    }
    
    .visualizer {
        height: 40px;
        margin: 5px 0;
    }
    
    .control-panel {
        gap: 3px;
        margin-bottom: 6px;
    }
    
    button, select, input {
        padding: 5px;
        font-size: 0.6rem;
    }
    
    .preset-item {
        padding: 3px;
        font-size: 0.65rem;
    }
    
    h2 {
        font-size: 0.85rem;
        margin-bottom: 4px;
    }
    
    h3 {
        font-size: 0.75rem;
        margin-bottom: 3px;
    }
    
    .panel {
        padding: 6px;
        margin-bottom: 6px;
    }
    
    .editor-container {
        overflow-x: auto;
        width: 100%;
        max-width: 100%;
        position: relative;
        box-sizing: border-box;
    }
    
    .midi-editor {
        padding: 4px;
        width: 100%;
        overflow-x: hidden;
        margin-top: 6px;
        max-width: 100%;
        box-sizing: border-box;
    }
    
    .main-content {
        gap: 8px;
    }
    
    .collapsible-section {
        margin-top: 4px;
    }
    
    .collapse-toggle {
        margin-bottom: 3px;
        padding: 3px 4px;
        font-size: 0.65rem;
    }
    
    .preset-list.expanded {
        max-height: 120px;
        padding: 3px;
    }
    
    .status {
        margin: 3px 0;
        font-size: 0.65rem;
    }
    
    .progress-bar {
        margin: 3px 0;
    }
}

/* 触摸设备优化 */
@media (hover: none) and (pointer: coarse) {
    button, .key, .grid-cell, .preset-item {
        min-height: 44px; /* 苹果推荐的最小触摸目标尺寸 */
    }
    
    .key {
        padding-bottom: 8px; /* 增加触摸区域 */
    }
    
    .grid-cell {
        min-height: 30px;
    }
    
    .dropdown-toggle {
        padding: 10px 15px; /* 增加触摸区域 */
    }
}

/* 横屏模式优化 */
@media (max-width: 768px) and (orientation: landscape) {
    .piano {
        height: 80px;
        min-width: 400px;
    }
    
    .editor-grid {
        height: 200px;
    }
    
    .header {
        padding: 6px 10px;
    }
    
    .nav-brand {
        margin-bottom: 5px;
    }
    
    .nav-brand h1 {
        font-size: 1rem;
    }
}

/* 极窄屏幕设备适配 - 减少网格列数以适应屏幕 */
@media (max-width: 320px) {
    html {
        overflow-x: hidden;
        width: 100%;
    }
    
    body {
        padding-top: 55px;
        overflow-x: hidden;
        min-height: 100vh;
        display: flex;
        flex-direction: column;
        width: 100%;
        position: relative;
        max-width: 100vw;
    }
    
    .header {
        padding: 4px 6px;
        height: 60px;
        max-width: 100vw;
    }
    
    .nav-brand h1 {
        font-size: 0.8rem;
        max-width: 100px;
    }
    
    .container {
        padding: 4px;
        margin-top: 3px;
        margin-bottom: 3px;
        width: calc(100% - 8px);
        max-width: 100%;
        box-sizing: border-box;
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
    }
    
    .page-header h1 {
        font-size: 0.9rem;
    }
    
    .subtitle {
        font-size: 0.6rem;
    }
    
    .piano {
        height: 60px;
        min-width: auto;
        width: 100%;
        display: flex;
        justify-content: center;
    }
    
    .white {
        width: 14px;
        flex-shrink: 0;
    }
    
    .black {
        width: 8px;
        margin-left: -4px;
        margin-right: -4px;
        flex-shrink: 0;
    }
    
    .key {
        font-size: 0.3rem;
        padding-bottom: 1px;
    }
    
}
