/*
 * responsive.css — 手机 / 平板 / WebView 适配
 * 桌面端布局不变，小屏启用抽屉导航与编辑器面板切换
 */

:root {
    --sg-nav-height: 68px;
    --sg-editor-header-height: 56px;
    --sg-mobile-dock-height: 52px;
    --sg-safe-top: env(safe-area-inset-top, 0px);
    --sg-safe-bottom: env(safe-area-inset-bottom, 0px);
    --sg-safe-left: env(safe-area-inset-left, 0px);
    --sg-safe-right: env(safe-area-inset-right, 0px);
    --sg-app-height: 100dvh;
}

@supports not (height: 100dvh) {
    :root {
        --sg-app-height: 100vh;
    }
}

html {
    -webkit-text-size-adjust: 100%;
    text-size-adjust: 100%;
}

body {
    -webkit-tap-highlight-color: transparent;
}

button,
a,
.sg-nav-toggle,
.sg-mobile-editor-dock button {
    touch-action: manipulation;
}

/* ── 移动端导航：汉堡 + 侧滑菜单 ── */
.sg-nav-toggle {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    margin-right: 4px;
    padding: 0;
    border: 1px solid rgba(255, 255, 255, 0.14);
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    color: #fff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    flex-shrink: 0;
}

.sg-nav-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10040;
    background: rgba(0, 0, 0, 0.45);
    opacity: 0;
    transition: opacity 0.25s ease;
    pointer-events: none;
}

.sg-nav.is-open .sg-nav-backdrop,
body.sg-nav-open .sg-nav-backdrop {
    opacity: 1;
    pointer-events: auto;
}

.sg-nav-menu-placeholder {
    display: none !important;
}

/* 导航内去掉月亮/长辈模式切换 */
.sg-nav .sg-mode-toggle {
    display: none !important;
}

@media (min-width: 769px) and (max-width: 1024px) {
    /* 平板：保持横向导航，不用侧滑抽屉 */
    .sg-nav-inner {
        padding-left: max(16px, var(--sg-safe-left));
        padding-right: max(16px, var(--sg-safe-right));
        height: calc(var(--sg-nav-height) + var(--sg-safe-top));
        padding-top: var(--sg-safe-top);
        gap: 8px;
    }

    .sg-nav-toggle {
        display: none !important;
    }

    .sg-nav-backdrop {
        display: none !important;
    }

    .sg-nav-menu {
        display: flex !important;
        flex-direction: row !important;
        position: static !important;
        transform: none !important;
        width: auto !important;
        flex: 1 1 auto;
        justify-content: center;
        gap: 6px !important;
        margin: 0;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        box-shadow: none !important;
        overflow: visible;
    }

    .sg-nav-menu li {
        width: auto;
    }

    .sg-nav-menu a {
        display: inline-block;
        padding: 6px 10px !important;
        font-size: 13px !important;
        border-radius: 8px;
        border-left: none !important;
        white-space: nowrap;
    }

    /* 覆盖 home.css 内页 17px 导航字，避免挤掉注册按钮 */
    .sg-library-body .sg-nav-menu a,
    .sg-member-body .sg-nav-menu a,
    .sg-audio-body .sg-nav-menu a,
    .sg-img-editor-page .sg-nav-menu a,
    .sg-player-body .sg-nav-menu a {
        font-size: 13px !important;
        padding: 5px 8px !important;
    }

    .sg-nav-menu a.active {
        background: rgba(64, 158, 255, 0.16);
        border-left: none !important;
    }

    .sg-nav-menu a.active::after {
        display: block !important;
    }

    .sg-nav.is-open .sg-nav-menu {
        transform: none !important;
    }

    .sg-nav-actions {
        flex-shrink: 0;
        gap: 8px;
    }

    .sg-nav-logo .sg-logo-text {
        font-size: 15px;
    }

    .sg-nav-logo .sg-logo-sub {
        display: none;
    }

    .sg-nav-user {
        display: none !important;
    }

    .sg-nav-link {
        font-size: 13px;
        padding: 6px 8px;
        white-space: nowrap;
    }

    .sg-nav-btn {
        padding: 6px 12px;
        font-size: 13px;
    }
}

/* 手机：汉堡 + 侧滑抽屉 */
@media (max-width: 768px) {
    .sg-home-page,
    .sg-home-page #form1,
    .sg-library-body,
    .sg-member-body,
    .sg-audio-body,
    .sg-img-editor-page,
    .sg-player-body {
        overflow-x: visible;
    }

    /* backdrop-filter 会把 fixed 菜单限制在导航条高度内，手机端关闭 */
    .sg-nav {
        overflow: visible;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
        background: rgba(10, 22, 40, 0.97);
    }

    .sg-nav.scrolled {
        background: rgba(10, 22, 40, 0.99);
    }

    .sg-nav-inner {
        position: relative;
        z-index: 10051;
        padding-left: max(12px, var(--sg-safe-left));
        padding-right: max(12px, var(--sg-safe-right));
        height: calc(var(--sg-nav-height) + var(--sg-safe-top));
        padding-top: var(--sg-safe-top);
        justify-content: flex-start;
        gap: 6px;
        min-width: 0;
    }

    .sg-nav-logo {
        flex: 1 1 auto;
        min-width: 0;
        overflow: hidden;
    }

    .sg-nav-logo .sg-logo-icon {
        width: 30px;
        height: 30px;
        font-size: 15px;
        flex-shrink: 0;
    }

    .sg-nav-toggle {
        display: inline-flex;
        position: relative;
        z-index: 10052;
        width: 38px;
        height: 38px;
        font-size: 18px;
        margin-right: 0;
        flex-shrink: 0;
    }

    .sg-nav-menu,
    .sg-nav-menu.sg-nav-menu-drawer {
        display: flex !important;
        flex-direction: column;
        gap: 0;
        position: fixed;
        top: calc(var(--sg-nav-height) + var(--sg-safe-top));
        left: 0;
        bottom: 0;
        width: min(82vw, 300px);
        margin: 0;
        padding: 12px 0 calc(16px + var(--sg-safe-bottom));
        background: rgba(10, 22, 40, 0.98);
        border-right: 1px solid rgba(255, 255, 255, 0.08);
        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.35);
        transform: translateX(-105%);
        transition: transform 0.28s ease, visibility 0.28s ease;
        z-index: 10050;
        visibility: hidden;
        pointer-events: none;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        list-style: none;
    }

    .sg-nav-menu li {
        width: 100%;
    }

    .sg-nav-menu a {
        display: block;
        padding: 12px 18px;
        font-size: 14px !important;
        border-radius: 0;
    }

    .sg-library-body .sg-nav-menu a,
    .sg-member-body .sg-nav-menu a,
    .sg-audio-body .sg-nav-menu a,
    .sg-img-editor-page .sg-nav-menu a,
    .sg-player-body .sg-nav-menu a {
        font-size: 14px !important;
    }

    .sg-nav-menu a.active::after {
        display: none;
    }

    .sg-nav-menu a.active {
        background: rgba(64, 158, 255, 0.14);
        border-left: 3px solid #409eff;
    }

    .sg-nav.is-open .sg-nav-menu,
    body.sg-nav-open .sg-nav-menu,
    body.sg-nav-open .sg-nav-menu-drawer {
        transform: translateX(0);
        visibility: visible;
        pointer-events: auto;
    }

    .sg-nav-backdrop {
        display: block;
    }

    .sg-nav-actions {
        gap: 4px;
        flex-shrink: 0;
        margin-left: auto;
    }

    .sg-nav-user {
        display: none !important;
    }

    /* 侧滑菜单里已有「会员中心」，右侧不再重复显示 */
    .sg-nav-actions .sg-nav-link[href*="Member.aspx"] {
        display: none !important;
    }

    .sg-nav-link {
        font-size: 12px;
        padding: 6px 8px;
        white-space: nowrap;
    }

    .sg-nav-btn {
        font-size: 12px;
        padding: 6px 10px;
        border-radius: 8px;
        white-space: nowrap;
        flex-shrink: 0;
    }

    .sg-nav-logo .sg-logo-text {
        font-size: 13px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sg-nav-logo .sg-logo-sub {
        display: none;
    }

    /* 长辈模式：顶栏仍保持紧凑，避免字号撑破布局 */
    body.elder-mode .sg-nav-link,
    body.elder-mode .sg-nav-btn,
    body.elder-mode .sg-nav-logo .sg-logo-text {
        font-size: 12px !important;
    }

    body.elder-mode .sg-nav-menu a {
        font-size: 14px !important;
    }
}

@media (max-width: 380px) {
    .sg-nav-logo .sg-logo-text {
        font-size: 12px;
    }

    .sg-nav-link {
        padding: 6px 6px;
    }

    .sg-nav-btn {
        padding: 6px 8px;
        font-size: 11px;
    }
}

@media (max-width: 992px) {
    .sg-player-body .player-page,
    .player-page {
        padding-top: 0;
        min-height: var(--sg-app-height);
    }

    .sg-player-body .player-wrapper,
    .player-wrapper {
        height: calc(var(--sg-app-height) - var(--sg-nav-height) - var(--sg-safe-top));
        min-height: 320px;
    }

    .sg-hero-wrap {
        padding-top: calc(var(--sg-nav-height) + var(--sg-safe-top));
    }
}

/* ── 编辑器：平板 / 手机（抽屉面板） ── */
@media (max-width: 992px) {
    .sg-img-editor-page .sg-editor-header-center .sg-zoom-display {
        display: none;
    }

    .sg-img-editor-page .sg-editor-header-center {
        display: flex !important;
        flex-wrap: nowrap;
        gap: 6px;
    }

    .sg-img-editor-page .sg-editor-header-center #btnZoomIn,
    .sg-img-editor-page .sg-editor-header-center #btnZoomOut {
        display: none;
    }

    .sg-img-editor-body {
        position: relative;
        padding-bottom: calc(var(--sg-mobile-dock-height) + var(--sg-safe-bottom));
    }

    .sg-img-editor-sidebar {
        position: fixed;
        top: calc(var(--sg-nav-height) + var(--sg-safe-top) + var(--sg-editor-header-height) + 8px);
        bottom: calc(var(--sg-mobile-dock-height) + var(--sg-safe-bottom));
        width: min(90vw, 320px) !important;
        max-width: 320px;
        z-index: 850;
        box-shadow: 0 8px 40px rgba(15, 23, 42, 0.22);
        transition: transform 0.28s ease;
    }

    .sg-img-editor-sidebar-left {
        left: 0;
        transform: translateX(-105%);
        border-right: 1px solid #dde3eb;
    }

    .sg-img-editor-sidebar-right {
        display: flex !important;
        right: 0;
        left: auto;
        transform: translateX(105%);
        border-left: 1px solid #dde3eb;
    }

    body.sg-mobile-panel-left-open .sg-img-editor-sidebar-left {
        transform: translateX(0);
    }

    body.sg-mobile-panel-right-open .sg-img-editor-sidebar-right {
        transform: translateX(0);
    }

    .sg-mobile-panel-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 840;
        background: rgba(15, 23, 42, 0.38);
    }

    body.sg-mobile-panel-left-open .sg-mobile-panel-backdrop,
    body.sg-mobile-panel-right-open .sg-mobile-panel-backdrop {
        display: block;
    }

    .sg-mobile-editor-dock {
        display: flex;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 860;
        height: calc(var(--sg-mobile-dock-height) + var(--sg-safe-bottom));
        padding-bottom: var(--sg-safe-bottom);
        background: rgba(255, 255, 255, 0.96);
        backdrop-filter: blur(12px);
        -webkit-backdrop-filter: blur(12px);
        border-top: 1px solid #e4e9f0;
        box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.08);
    }

    .sg-mobile-editor-dock button {
        flex: 1;
        border: none;
        background: transparent;
        color: #606266;
        font-size: 14px;
        font-weight: 600;
        cursor: pointer;
        min-height: var(--sg-mobile-dock-height);
    }

    .sg-mobile-editor-dock button[data-action] {
        flex: 0.88;
        color: #409eff;
    }

    .sg-mobile-editor-dock button[data-panel="canvas"] {
        flex: 1.05;
    }

    .sg-mobile-editor-dock button.active {
        color: #409eff;
        background: rgba(64, 158, 255, 0.08);
    }

    .sg-img-editor-canvas-wrap {
        touch-action: none;
        -ms-touch-action: none;
    }

    .sg-img-editor-canvas-wrap .sg-img-overlay {
        touch-action: none;
    }
}

@media (min-width: 993px) {
    .sg-mobile-editor-dock,
    .sg-mobile-panel-backdrop {
        display: none !important;
    }
}

/* ── 编辑器：手机（顶栏与音频条） ── */
@media (max-width: 768px) {
    .sg-img-editor-page {
        height: var(--sg-app-height);
        overflow: hidden;
    }

    .sg-img-editor-page .sg-editor-header {
        margin-top: calc(var(--sg-nav-height) + var(--sg-safe-top));
        padding: 0 10px;
        height: 48px;
        min-height: 48px;
        flex-wrap: nowrap;
        align-items: center;
        gap: 8px;
    }

    .sg-img-editor-page .sg-back-btn,
    .sg-img-editor-page .sg-editor-divider {
        display: none;
    }

    .sg-img-editor-page .sg-editor-header-left {
        flex: 1 1 auto;
        min-width: 0;
        gap: 8px;
        order: 1;
    }

    .sg-img-editor-page .sg-editor-title-input {
        min-width: 0;
        flex: 1;
        font-size: 15px;
        padding: 6px 8px;
    }

    .sg-img-editor-page .sg-editor-version {
        flex-shrink: 0;
        font-size: 11px;
        padding: 2px 6px;
    }

    .sg-img-editor-page .sg-editor-header-center {
        display: none !important;
    }

    .sg-img-editor-page .sg-editor-header-right {
        flex: 0 0 auto;
        order: 2;
        margin-left: 0;
        gap: 6px;
        flex-wrap: nowrap;
    }

    .sg-img-editor-page .sg-header-btn {
        padding: 7px 10px;
        font-size: 12px;
        white-space: nowrap;
    }

    .sg-img-editor-page .sg-header-btn-preview {
        padding: 7px 11px;
    }

    .sg-img-editor-page .sg-save-btn {
        padding: 7px 12px;
    }

    .sg-img-editor-page .sg-img-audio-bar {
        margin: 0 8px;
        padding: 10px 12px;
        gap: 10px;
        border-radius: 10px;
    }

    .sg-img-editor-page .sg-img-audio-playback {
        display: grid;
        grid-template-columns: auto minmax(44px, auto) 1fr minmax(44px, auto);
        grid-template-rows: auto auto;
        gap: 6px 8px;
        align-items: center;
    }

    .sg-img-editor-page .sg-img-audio-play {
        grid-column: 1;
        grid-row: 1 / 3;
        align-self: center;
        width: 44px;
        height: 44px;
        font-size: 16px;
    }

    .sg-img-editor-page .sg-img-audio-playback #audioTimeCurrent {
        grid-column: 2;
        grid-row: 1;
        font-size: 12px;
        min-width: 0;
    }

    .sg-img-editor-page .sg-img-audio-playback #audioTimeTotal {
        grid-column: 4;
        grid-row: 1;
        text-align: right;
        font-size: 12px;
        min-width: 0;
    }

    .sg-img-editor-page .sg-img-audio-seek-wrap {
        grid-column: 2 / 5;
        grid-row: 2;
        min-width: 0;
        padding: 0;
    }

    .sg-img-editor-page .sg-img-audio-sync {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .sg-img-editor-page .sg-img-audio-actions {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        width: 100%;
    }

    .sg-img-editor-page .sg-img-audio-actions .sg-img-audio-btn {
        width: 100%;
        min-height: 40px;
        min-width: 0;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        font-size: 13px;
        font-weight: 600;
    }

    .sg-img-editor-page .sg-img-sync-hint {
        width: 100%;
        max-width: none;
        font-size: 12px;
        text-align: center;
        padding: 8px 10px;
    }

    .sg-img-editor-page .sg-img-statusbar {
        margin: 6px 8px 8px;
        font-size: 11px;
    }
}

@media (min-width: 769px) and (max-width: 992px) {
    .sg-img-editor-page .sg-editor-header {
        margin-top: calc(var(--sg-nav-height) + var(--sg-safe-top));
    }
}

/* ── 播放器手机 ── */
@media (max-width: 768px) {
    .player-control-bar {
        flex-wrap: wrap;
        height: auto !important;
        min-height: 72px;
        padding: 8px 10px calc(8px + var(--sg-safe-bottom));
        gap: 8px;
    }

    .player-controls-left,
    .player-controls-right {
        flex-wrap: wrap;
        gap: 6px;
    }

    .player-progress-section {
        flex: 1 1 100%;
        min-width: 0 !important;
        order: 3;
    }

    .player-knob-group {
        flex-wrap: nowrap;
    }

    .player-knob-value,
    .player-knob-label {
        font-size: 12px;
    }

    .score-info-bar {
        flex-wrap: wrap;
        gap: 8px;
        padding: 10px 12px;
    }

    .score-info-bar .score-meta {
        flex-wrap: wrap;
        gap: 8px;
        font-size: 12px;
    }

    .side-panel {
        width: 100% !important;
        max-width: none;
    }

    .player-page--cinema .player-control-bar {
        padding-bottom: calc(10px + var(--sg-safe-bottom));
    }
}

/* ── 会员 / 曲库 / 首页 ── */
@media (max-width: 768px) {
    .sg-member-page-wrap,
    .sg-library-page-wrap {
        padding-left: max(12px, var(--sg-safe-left));
        padding-right: max(12px, var(--sg-safe-right));
    }

    .sg-hero {
        padding-left: max(16px, var(--sg-safe-left));
        padding-right: max(16px, var(--sg-safe-right));
    }
}

/* ── 登录注册 ── */
@media (max-width: 480px) {
    .auth-card {
        margin: 16px max(12px, var(--sg-safe-left));
        width: auto;
    }
}

/* ── WebView：禁止横向溢出 ── */
@media (max-width: 992px) {
    body {
        overflow-x: hidden;
    }

    img,
    video,
    canvas {
        max-width: 100%;
    }
}

/* body 锁滚动（菜单/面板打开） */
body.sg-nav-open,
body.sg-mobile-panel-left-open,
body.sg-mobile-panel-right-open {
    overflow: hidden;
}

/* ── 手机 / 平板：全站字号紧凑（相对桌面约缩小 12%～15%） ── */
@media (max-width: 992px) {
    :root {
        --font-xs: 11px;
        --font-sm: 12px;
        --font-base: 13px;
        --font-md: 14px;
        --font-lg: 15px;
        --font-xl: 17px;
        --font-2xl: 20px;
        --font-3xl: 26px;
        --sg-nav-height: 56px;
    }

    body {
        font-size: 13px;
    }

    .sg-nav-logo .sg-logo-text {
        font-size: 14px;
    }

    .sg-nav-link,
    .sg-nav-btn {
        font-size: 12px;
    }

    .sg-footer,
    .sg-footer a,
    .sg-footer p {
        font-size: 12px;
    }

    /* 首页 / 曲库 / 会员 */
    .sg-hero-title,
    .sg-home-page .sg-hero-title--lg {
        font-size: clamp(30px, 6.5vw, 44px) !important;
    }

    .sg-hero-desc {
        font-size: 14px;
        line-height: 1.7;
    }

    .sg-hero-btn,
    .sg-cap-btn,
    .sg-cta-btn {
        font-size: 14px;
        padding: 11px 20px;
    }

    .sg-section-header h2 {
        font-size: clamp(22px, 4.5vw, 28px);
    }

    .sg-section-header p {
        font-size: 13px;
    }

    .sg-feature-card h3 {
        font-size: 16px;
    }

    .sg-feature-card p {
        font-size: 13px;
    }

    .sg-auth-modal-head h3 {
        font-size: 18px;
    }

    .sg-auth-modal-head p,
    .sg-auth-btn {
        font-size: 14px;
    }

    /* 会员中心 */
    .sg-member-page-title h1 {
        font-size: 20px;
    }

    .sg-member-body .sg-quick-action-card strong {
        font-size: 14px;
    }

    .sg-member-body .sg-quick-action-card span:last-child {
        font-size: 12px;
    }

    .sg-member-body .sg-my-score-info strong {
        font-size: 14px;
    }

    .sg-member-body .sg-my-score-info span {
        font-size: 12px;
    }
}

@media (max-width: 768px) {
    :root {
        --sg-nav-height: 52px;
    }

    .sg-hero-title,
    .sg-home-page .sg-hero-title--lg {
        font-size: clamp(26px, 7.5vw, 34px) !important;
    }

    .sg-hero-desc {
        font-size: 13px;
        margin-bottom: 24px;
    }

    .sg-hero-btn,
    .sg-cap-btn,
    .sg-cta-btn {
        font-size: 13px;
        padding: 10px 18px;
    }

    .sg-section-header h2 {
        font-size: clamp(20px, 5.5vw, 24px);
    }

    .sg-home-hot-title-row .sg-section-header h2 {
        font-size: 20px;
    }

    .sg-cap-card h3,
    .sg-editor-workflow-item h3 {
        font-size: 15px;
    }

    .sg-cap-card p,
    .sg-editor-workflow-item p {
        font-size: 12px;
    }
}
