/* 短视频素材分发系统 - 全局与手机 H5 样式
   核心桌面样式位于 index.html，本文件负责跨端补充和移动端覆盖。 */

* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.35) transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.35); border-radius: 8px; }
*::-webkit-scrollbar-track { background: transparent; }

html { height: 100%; }
body { min-height: 100vh; min-height: 100dvh; }
img, video { max-width: 100%; }
a { text-decoration: none; }
button, a, input, select, textarea { touch-action: manipulation; }
button:disabled { cursor: not-allowed; opacity: .55; }
button, a { -webkit-tap-highlight-color: transparent; }
button:focus-visible, a:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid rgba(255,255,255,.85);
    outline-offset: 3px;
}

select { -webkit-appearance: none; appearance: none; cursor: pointer; }
select option { color: #1a1a2e; background: #fff; }
input[type="file"] { line-height: 1.4; }
input[type="file"]::file-selector-button {
    margin-right: 12px;
    padding: 9px 14px;
    border: 0;
    border-radius: 10px;
    background: rgba(255,255,255,.9);
    color: #4f46e5;
    font: inherit;
    font-weight: 650;
    cursor: pointer;
}

#appMain, #authScreen, .main-content, .card, .mat-card, .history-item,
.form-group, .info-item, .hero-section, .wd-record { min-width: 0; }
.info-value, .his-title, .his-meta, .ann-title, .ann-content, .mat-title,
.mat-desc, .wd-meta, .page-header, .form-group, .msg-box {
    overflow-wrap: anywhere;
    word-break: break-word;
}
.ann-content { white-space: pre-wrap; }

/* 手机验证码输入行 */
.code-input-row { display: flex; align-items: flex-start; gap: 10px; }
.code-input-row .form-input { flex: 1 1 auto; min-width: 0; margin: 0; }
.code-input-row .code-send-btn {
    flex: 0 0 auto;
    width: auto;
    min-height: 54px;
    margin: 0;
    padding: 12px 16px;
    white-space: nowrap;
}
/* 图片核对码 */
.code-input-row .captcha-canvas {
    flex: 0 0 auto;
    display: block;
    width: 110px;
    height: 46px;
    border-radius: 8px;
    border: 1px solid rgba(255,255,255,.35);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
@media (max-width: 360px) {
    .code-input-row .captcha-canvas { width: 100px; height: 44px; }
}

/* 弹层与 Toast */
.modal-open { overflow: hidden; }
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: max(20px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(20px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left));
    background: rgba(0,0,0,.48);
    backdrop-filter: blur(5px);
    -webkit-backdrop-filter: blur(5px);
}
.modal-card {
    width: 100%;
    max-width: 540px;
    max-height: min(86vh, 86dvh);
    margin: 0;
    overflow: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.modal-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 16px; }
.modal-header h2 { min-width: 0; margin: 0; color: #fff; font-size: 1.2em; overflow-wrap: anywhere; }
.modal-header .btn { flex: 0 0 auto; min-width: 64px; min-height: 44px; }
.modal-card .form-actions .btn, .modal-card .btn-primary { min-height: 48px; }
.toast-fixed { pointer-events: none; }
.toast-fixed .msg-box { margin: 0; }
.toast-fixed .msg-box span { min-width: 0; }

/* 链接按钮与普通按钮保持一致 */
#appMain a.btn, .modal-card a.btn, .auth-wrapper a.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: rgba(255,255,255,.94);
    color: #4f46e5;
    font-size: .93em;
    font-weight: 650;
    line-height: 1.2;
    min-height: 44px;
    text-decoration: none;
    box-shadow: 0 6px 20px rgba(0,0,0,.15);
}
#appMain a.btn.btn-outline, .modal-card a.btn.btn-outline {
    border-color: rgba(255,255,255,.6);
    background: transparent;
    color: #fff;
}

/* 通用触控尺寸 */
.auth-tab, .btn-primary, #appMain .btn, #appMain button,
#authScreen .btn, #authScreen button { min-height: 44px; }
.stats-pill { min-height: 42px; cursor: pointer; }
.stats-pill.active { background: rgba(255,255,255,.4); box-shadow: 0 4px 16px rgba(0,0,0,.12); }

@media (hover: none) {
    .card:hover, .mat-card:hover, .quick-item:hover, .stat-card:hover,
    .hero-actions .btn:hover, button.btn:hover, .btn-primary:hover { transform: none; }
}

@media (max-width: 768px) {
    body { font-size: 15px; }
    .bg-orb { filter: blur(72px); animation: none; }

    /* 登录与注册 */
    #authScreen {
        min-height: 100vh;
        min-height: 100dvh;
        align-items: flex-start;
        padding: calc(76px + env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) calc(24px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
    }
    #authScreen .auth-container { margin: auto; }
    #authScreen .auth-brand { margin-bottom: 20px; }
    #authScreen .auth-brand-icon { width: 64px; height: 64px; margin-bottom: 12px; border-radius: 20px; animation: none; }
    #authScreen .auth-brand h1 { font-size: 1.55rem; }
    #authScreen .auth-card { padding: 26px 22px; border-radius: 22px; backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
    #authScreen .auth-tabs { margin-bottom: 22px; }
    #authScreen .auth-tab { padding: 11px 6px; }
    #authScreen .form-group { margin-bottom: 16px; }
    #authScreen .input-icon-wrap i { left: 17px; }
    #authScreen .input-icon-wrap input { padding-left: 52px !important; }
    #authScreen .form-input, #appMain input, #appMain select, #appMain textarea,
    .modal-card input, .modal-card select, .modal-card textarea { font-size: 16px; }
    #authScreen .auth-footer { margin-top: 18px; }
    .theme-toggle {
        top: calc(12px + env(safe-area-inset-top));
        right: max(14px, env(safe-area-inset-right));
        width: 44px;
        height: 44px;
    }

    /* 顶部栏 */
    #appMain .navbar {
        height: calc(60px + env(safe-area-inset-top));
        padding: env(safe-area-inset-top) max(14px, env(safe-area-inset-right)) 0 max(14px, env(safe-area-inset-left));
    }
    #appMain .navbar-brand { gap: 9px; font-size: 1rem; min-width: 0; }
    #appMain .navbar-brand span {
        display: inline;
        max-width: 52vw;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }
    #appMain .navbar-right { gap: 8px; }
    #appMain .navbar-user { display: none; }
    #appMain .theme-toggle-nav { width: 44px; height: 44px; }
    #appMain .main-content {
        width: 100%;
        margin-top: calc(74px + env(safe-area-inset-top));
        padding: 0 max(14px, env(safe-area-inset-right)) calc(90px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
    }

    /* 底部导航 */
    #appMain .mobile-tab {
        height: calc(64px + env(safe-area-inset-bottom));
        padding: 0 max(4px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(4px, env(safe-area-inset-left));
        background: rgba(70,55,150,.88);
    }
    #appMain .mobile-tab a {
        flex: 1 1 20%;
        justify-content: center;
        min-width: 0;
        min-height: 56px;
        padding: 7px 2px;
        font-size: 11px;
    }
    #appMain .mobile-tab a i { font-size: 18px; }
    #appMain .mobile-tab a.active::before { top: 0; }

    .hero-section { padding: 30px 20px; border-radius: 22px; }
    .hero-section h1 { font-size: 1.5rem; line-height: 1.4; }
    .hero-section p { margin-bottom: 22px; font-size: .96rem; }
    .hero-actions { gap: 12px; }
    .quick-grid { grid-template-columns: repeat(4, minmax(0,1fr)); gap: 10px; }
    .quick-item { min-height: 94px; padding: 16px 6px; gap: 9px; border-radius: 16px; font-size: 12px; }
    .quick-item i { font-size: 1.65em; }
    .stat-cards { grid-template-columns: repeat(2, minmax(0,1fr)); gap: 10px; }
    .stat-card { padding: 18px 10px; border-radius: 18px; }
    .stat-icon { width: 46px; height: 46px; margin-bottom: 10px; border-radius: 14px; }
    .stat-value { font-size: 1.45rem; }
    .stat-label { font-size: 12px; }

    .card { padding: 18px; border-radius: 18px; background: rgba(255,255,255,.24); }
    .card:hover { transform: none; }
    #appMain .text-muted { color: rgba(255,255,255,.9) !important; }
    .mat-desc, .his-meta, .ann-content, .wd-meta { color: rgba(255,255,255,.86); }
    .info-label, .mat-time, .ann-time { color: rgba(255,255,255,.8); }
    #appMain .info-item { background: rgba(255,255,255,.2); border-color: rgba(255,255,255,.28); }
    .page-header { margin-bottom: 18px; padding-bottom: 12px; }
    .page-header h2 { font-size: 1.22rem; }
    .material-grid { grid-template-columns: repeat(auto-fill,minmax(min(100%,250px),1fr)); gap: 14px; }
    .mat-card { min-height: 0; padding: 14px; border-radius: 18px; cursor: default; }
    .mat-thumb { height: auto; aspect-ratio: 16 / 9; margin-bottom: 12px; }
    .mat-footer { gap: 10px; }
    .mat-time { font-size: 11px; }
    .claim-btn { min-width: 76px; }

    /* 分类手机端单行滑动，避免挤压换行 */
    #appMain .stats-bar {
        flex-wrap: nowrap;
        justify-content: flex-start;
        gap: 9px;
        margin: 0 -14px 16px;
        padding: 2px 14px 8px;
        overflow-x: auto;
        overscroll-behavior-x: contain;
        scroll-snap-type: x proximity;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    #appMain .stats-bar::-webkit-scrollbar { display: none; }
    #appMain .stats-pill { flex: 0 0 auto; min-height: 44px; padding: 9px 17px; scroll-snap-align: start; }

    .form-row { flex-direction: column; gap: 0; }
    .form-row > .form-group { width: 100%; min-width: 0; }
    .form-stack { gap: 12px; }
    .form-actions { gap: 10px; }
    .form-actions .btn, .form-actions .btn-primary { flex: 1 1 160px; min-height: 48px; }
    #appMain input, #appMain select, #appMain textarea,
    .modal-card input, .modal-card select, .modal-card textarea {
        min-height: 50px;
        margin-top: 4px;
        border-color: rgba(255,255,255,.46);
        background: rgba(255,255,255,.2);
    }
    #appMain textarea, .modal-card textarea { min-height: 110px; }
    #appMain input[type="file"], .modal-card input[type="file"] { padding: 10px; }
    .info-grid { grid-template-columns: 1fr; gap: 10px; }
    .info-item { padding: 13px 14px; }
    .history-item { padding: 14px 0; }
    .history-item .his-meta { gap: 7px 12px; line-height: 1.7; }
    .history-item .backfill-btn { width: 100%; min-height: 46px; }
    .history-item:last-child .divider, .announcement-card:last-child .divider { display: none; }
    .announcement-card { padding-left: 14px; }
    .wd-record { flex-wrap: nowrap; gap: 10px; }
    .wd-left { min-width: 0; }
    .wd-record .badge { flex: 0 0 auto; }
    .pagination { gap: 8px; margin: 24px 0; }
    .pagination .page-info { padding: 0 6px; font-size: 13px; }
    .empty-state { padding: 44px 18px; }

    /* 手机弹层：底部卡片，兼容全面屏和键盘 */
    .modal-overlay { align-items: flex-end; padding: 16px 0 0; }
    .modal-card {
        max-width: none;
        max-height: 88vh;
        max-height: 88dvh;
        padding: 20px max(16px, env(safe-area-inset-right)) calc(20px + env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
        border-radius: 22px 22px 0 0;
    }
    .modal-card .form-actions { position: sticky; bottom: 0; padding-top: 8px; }
    .toast-fixed {
        top: calc(12px + env(safe-area-inset-top));
        right: max(12px, env(safe-area-inset-right));
        left: max(12px, env(safe-area-inset-left));
        min-width: 0;
        max-width: none;
    }
}

@media (max-width: 480px) {
    #authScreen { padding-right: 12px; padding-left: 12px; }
    #authScreen .auth-card { padding: 22px 17px; }
    #authScreen .auth-brand h1 { font-size: 1.4rem; }
    #authScreen .auth-brand p { font-size: .9rem; }
    .code-input-row { gap: 8px; }
    .code-input-row .code-send-btn { padding: 11px 12px; font-size: 13px; }
    #appMain .main-content { padding-right: 12px; padding-left: 12px; }
    #appMain .navbar-brand span { max-width: 62vw; }
    .hero-section { padding: 26px 16px; }
    .hero-section h1 { font-size: 1.35rem; }
    .hero-actions { flex-direction: column; align-items: stretch; }
    .hero-actions .btn { width: 100%; max-width: none; min-height: 48px; }
    .quick-grid { grid-template-columns: repeat(4,minmax(0,1fr)); gap: 8px; }
    .quick-item { min-height: 86px; padding: 14px 3px; }
    .material-grid { grid-template-columns: 1fr; }
    .mat-footer { align-items: flex-end; }
    .mat-time { max-width: 58%; }
    .form-actions .btn, .form-actions .btn-primary { flex-basis: 100%; width: 100%; }
}

@media (max-width: 340px) {
    #appMain .navbar-brand span { max-width: 56vw; font-size: 14px; }
    #authScreen .auth-card { padding-right: 14px; padding-left: 14px; }
    .code-input-row { flex-direction: column; }
    .code-input-row .form-input, .code-input-row .code-send-btn { width: 100%; }
    .quick-item { font-size: 11px; }
    .stat-card { padding-right: 6px; padding-left: 6px; }
}

@media (max-height: 500px) and (orientation: landscape) {
    #authScreen { padding-top: calc(62px + env(safe-area-inset-top)); }
    #authScreen .auth-brand { margin-bottom: 12px; }
    #authScreen .auth-brand-icon { display: none; }
    .modal-card { max-height: 94dvh; }
}

@media (prefers-reduced-motion: reduce) {
    html { scroll-behavior: auto; }
    *, *::before, *::after {
        animation-duration: .01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: .01ms !important;
        scroll-behavior: auto !important;
    }
}
