﻿/* ==========================================================================
   ざいのーと [食材レシピ管理] スマホ横画面（Landscape）専用スタイル
   ========================================================================== */


/* ==========================================================================
   スマホ横画面対応（Landscape Mode & 画面低）
   シート幅を広く使って2大カラム（基本情報＋ボタン列 / 最大8素材列）に展開
   更新・削除ボタンを左列に収め、右半分は素材8個マスとラベルだけにして
   下部フッター行を丸ごと削減（超低全高・スクロール完全ゼロ）
   ========================================================================== */
@media screen and (orientation: landscape) and (max-height: 520px),
       screen and (min-width: 600px) and (max-height: 520px) {
    /* 全体の横スクロール防止 */
    html,
    body {
        overflow-x: hidden !important;
        max-width: 100vw !important;
        width: 100% !important;
    }

    .mobile-detail-sheet {
        width: 96vw !important;
        max-width: 920px !important;
        max-height: 98vh !important;
        border-radius: 12px 12px 0 0 !important;
        bottom: env(safe-area-inset-bottom, 0px) !important;
    }

    .sheet-drag-handle {
        width: 36px !important;
        height: 3px !important;
        margin: 2px auto 1px !important;
    }

    .sheet-header {
        padding: 2px 14px 3px !important;
    }

    .sheet-title {
        font-size: 14px !important;
    }

    .sheet-no-badge {
        font-size: 11.5px !important;
        padding: 2px 6px !important;
    }

    .sheet-close-btn {
        padding: 2px 8px !important;
        font-size: 18px !important;
    }

    /* ボディ: 左右2大カラムグリッド */
    .sheet-body {
        padding: 3px 14px 4px !important;
        display: grid !important;
        grid-template-columns: 1fr 1.15fr !important;
        column-gap: 16px !important;
        row-gap: 2.5px !important;
        overflow-y: auto !important;
        align-content: start !important;
        flex: 1 1 auto !important;
    }

    /* 左列: レシピ名＆ジャンル(1) ➡ 倍率＆採用数(2) ➡ 参考アドレス/メモ(3) ➡ 最終更新(4) ➡ 更新＆削除ボタン(5) */
    .sheet-field-meta-grid {
        grid-column: 1 / 2 !important;
        grid-row: 1 !important;
        display: grid !important;
        grid-template-columns: 1.2fr 0.8fr !important;
        gap: 6px !important;
    }

    .sheet-field-number-grid {
        grid-column: 1 / 2 !important;
        grid-row: 2 !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
    }

    .sheet-field-memo {
        grid-column: 1 / 2 !important;
        grid-row: 3 !important;
    }

    .sheet-field-time,
    .sheet-meta-row {
        grid-column: 1 / 2 !important;
        grid-row: 4 !important;
        padding: 2px 6px !important;
        font-size: 11px !important;
        border-radius: 4px !important;
        margin: 0 !important;
        line-height: 1.3 !important;
    }

    .sheet-update-time {
        font-size: 11px !important;
    }

    /* 左列最下段: 更新・削除（・URL）ボタン群（フッターを左半分に吸収） */
    .sheet-footer {
        grid-column: 1 / 2 !important;
        grid-row: 5 !important;
        display: flex !important;
        flex-direction: row !important;
        gap: 5px !important;
        padding: 0 !important;
        border-top: none !important;
        background: transparent !important;
        position: static !important;
        margin: 2px 0 0 0 !important;
        z-index: auto !important;
    }

    .sheet-btn {
        height: 31px !important;
        font-size: 12.5px !important;
        padding: 0 8px !important;
        border-radius: 4px !important;
        white-space: nowrap !important;
    }

    .sheet-btn-update {
        flex: 1.4 1 auto !important;
        font-size: 13px !important;
    }

    .sheet-btn-delete {
        flex: 1 1 auto !important;
    }

    .sheet-btn-url {
        flex: 0 0 auto !important;
        padding: 0 6px !important;
    }

    .sheet-btn-lbl-full {
        display: none !important;
    }

    .sheet-btn-lbl-short {
        display: inline !important;
    }

    .sheet-field-group {
        gap: 1px !important;
    }

    .sheet-label {
        font-size: 11px !important;
        font-weight: 700 !important;
        margin-bottom: 1.5px !important;
        white-space: nowrap !important;
        line-height: 1.2 !important;
    }

    .sheet-input,
    .sheet-select {
        height: 29px !important;
        font-size: 13px !important;
        padding: 2px 7px !important;
        border-radius: 4px !important;
    }

    .sheet-name-input {
        font-size: 12px !important;
        font-weight: 700 !important;
    }

    .sheet-stepper {
        gap: 2px !important;
    }

    .sheet-step-btn {
        width: 25px !important;
        height: 28px !important;
        font-size: 14px !important;
        border-radius: 4px !important;
    }

    .sheet-num-input {
        height: 29px !important;
        font-size: 12.5px !important;
    }

    /* 右列: 素材8個マスとラベルだけ (常時8素材全表示・折りたたみボタン非表示) */
    .sheet-materials-section {
        grid-column: 2 / 3 !important;
        grid-row: 1 / 6 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 2px !important;
    }

    .sheet-material-list {
        padding: 3px 5px !important;
        gap: 2px !important;
        border-radius: 6px !important;
    }

    .sheet-mat-row {
        display: grid !important;
        grid-template-columns: 18px 1fr 54px 44px !important;
        gap: 2px !important;
        align-items: center !important;
    }

    .sheet-mat-num {
        font-size: 11px !important;
        font-weight: 700 !important;
        padding-right: 1px !important;
    }

    .sheet-mat-name,
    .sheet-mat-qty,
    .sheet-mat-unit {
        height: 23px !important;
        font-size: 11px !important;
        padding: 1px 4px !important;
        border-radius: 3px !important;
    }

    .sheet-toggle-mat-btn {
        display: none !important;
    }
}

/* デスクトップ通常時のベーススタイル */
.mobile-title-tip {
    display: none;
}

/* 強制スマホモード時のツールチップ */
body.force-mobile-mode .app-title-group {
    display: grid !important;
    grid-template-columns: auto 1fr auto !important;
    grid-template-rows: auto auto !important;
    align-items: center !important;
    width: 100% !important;
    row-gap: 2px !important;
    column-gap: 8px !important;
    position: relative !important;
}

/* 左列 (Column 1): ざいのーと アイコン (上) ＆ [アプリ名] (下) */
body.force-mobile-mode .app-title {
    grid-column: 1 / 2 !important;
    grid-row: 1 / 3 !important;
    justify-self: start !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    gap: 2px !important;
    margin: 0 !important;
    line-height: 1.15 !important;
}

body.force-mobile-mode .app-title a {
    display: flex !important;
    flex-direction: column !important;
    gap: 2px !important;
    color: inherit !important;
    text-decoration: none !important;
}

body.force-mobile-mode .app-title-main,
body.force-mobile-mode .app-title-tag {
    font-size: 17px !important;
    font-weight: 700 !important;
    white-space: nowrap !important;
    color: #ffffff !important;
    display: block !important;
}

/* スマホモード（縦・横）: tipは完全非表示 */
body.force-mobile-mode .mobile-title-tip,
body.force-mobile-mode .mobile-title-tip.active {
    display: none !important;
}
body.force-mobile-mode .tab-button.management-help-anchor.help-visible::after {
    display: none !important;
}
[data-tooltip]::before,
[data-tooltip]::after {
    display: none !important;
}

/* 中央列 (Column 2): 補足文 (上下2行エリア) */
body.force-mobile-mode .app-subtitle {
    grid-column: 2 / 3 !important;
    grid-row: 1 / 3 !important;
    justify-self: start !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center !important;
    gap: 2px !important;
    margin: 0 !important;
    width: 100% !important;
    min-width: 0 !important;
    line-height: 1.25 !important;
}

body.force-mobile-mode .subtitle-line1,
body.force-mobile-mode .subtitle-line2 {
    font-size: 11px !important;
    opacity: 0.85 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    min-width: 0 !important;
    display: block !important;
}

/* 右列 (Column 3): 1行目: 契約アイコン（プランバッジ） */
body.force-mobile-mode #zainotePlanBadge,
body.force-mobile-mode .zainote-plan-badge {
    grid-column: 3 / 4 !important;
    grid-row: 1 !important;
    justify-self: end !important;
    margin: 0 !important;
    font-size: 13px !important;
    padding: 3px 8px !important;
    white-space: nowrap !important;
}

/* 右列 (Column 3): 2行目: 画面モード切替ボタン */
body.force-mobile-mode #zainoteModeToggleBtn,
body.force-mobile-mode .zainote-mode-toggle-btn {
    grid-column: 3 / 4 !important;
    grid-row: 2 !important;
    justify-self: end !important;
    margin: 0 !important;
    font-size: 11px !important;
    padding: 3px 6px !important;
    white-space: nowrap !important;
}


/* ==========================================================================
   スマホ横画面（Landscape）ヘッダー配置:
   5ボタン（.header-links）を「説明文」と「アイコン」の間に右寄せで割り込み配置
   ========================================================================== */
@media screen and (orientation: landscape) and (max-height: 600px) {
    .app-header {
        display: grid !important;
        grid-template-columns: auto minmax(0, 1fr) auto auto !important;
        grid-template-rows: auto auto !important;
        align-items: center !important;
        padding: 4px 8px !important;
        column-gap: 6px !important;
        row-gap: 2px !important;
        white-space: nowrap !important;
    }

    .app-title-group {
        display: contents !important;
    }

    /* 1. 左列: タイトル (ざいのーと アイコン / [アプリ名]) */
    .app-title {
        grid-column: 1 / 2 !important;
        grid-row: 1 / 3 !important;
        justify-self: start !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        gap: 1px !important;
        margin: 0 !important;
        line-height: 1.15 !important;
        flex-shrink: 0 !important;
    }

    .app-title-main,
    .app-title-tag {
        font-size: 13.5px !important;
        font-weight: 700 !important;
        white-space: nowrap !important;
        color: #ffffff !important;
        display: block !important;
    }

    /* 2. 中央-左: 補足説明文 (上下2行エリア - 画面幅が狭い時は柔軟に縮小しプロジェクトボタンを保護) */
    .app-subtitle {
        grid-column: 2 / 3 !important;
        grid-row: 1 / 3 !important;
        justify-self: start !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        gap: 1px !important;
        margin: 0 !important;
        min-width: 0 !important;
        max-width: 140px !important;
        line-height: 1.2 !important;
        overflow: hidden !important;
    }

    .subtitle-line1,
    .subtitle-line2 {
        font-size: 11px !important;
        opacity: 0.85 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: block !important;
    }

    /* 3. 中央-右: 5ボタン（最優先配置・絶対に追い出されないよう縮小・非表示ガード） */
    .header-links {
        grid-column: 3 / 4 !important;
        grid-row: 1 / 3 !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: flex-end !important;
        justify-self: end !important;
        align-items: center !important;
        gap: 3px !important;
        margin: 0 !important;
        margin-left: auto !important;
        padding: 0 !important;
        flex-shrink: 0 !important;
        min-width: max-content !important;
    }

    .header-links a,
    .header-links .current-app {
        font-size: 11px !important;
        padding: 2.5px 5px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        border-radius: 4px !important;
    }

    /* 4. 最右列: 契約アイコン & 画面切替ボタン */
    #zainotePlanBadge,
    .zainote-plan-badge {
        grid-column: 4 / 5 !important;
        grid-row: 1 !important;
        justify-self: end !important;
        margin: 0 !important;
        font-size: 11px !important;
        padding: 2px 6px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    #zainoteModeToggleBtn,
    .zainote-mode-toggle-btn {
        grid-column: 4 / 5 !important;
        grid-row: 2 !important;
        justify-self: end !important;
        margin: 0 !important;
        font-size: 9.5px !important;
        padding: 2px 5px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }
}

/* 横画面（実機・スマホモード共通）: 調和の取れたテーブル黄金バランス */
@media screen and (orientation: landscape) and (max-height: 600px), screen and (max-width: 768px) and (orientation: landscape) {
    #inventory,
    body.force-mobile-mode:not(.force-pc-mode) #inventory {
        width: 100% !important;
        min-width: 100% !important;
        margin-top: 0 !important;
        box-sizing: border-box !important;
        table-layout: auto !important;
    }

    #inventory th,
    #inventory td,
    body.force-mobile-mode:not(.force-pc-mode) #inventory th,
    body.force-mobile-mode:not(.force-pc-mode) #inventory td {
        padding: 4px 4px !important;
        box-sizing: border-box !important;
    }

    /* 枠線・背景・矢印を削ってテキスト化 ＆ スクロール誤タップ防止 */
    #inventory tbody td input,
    #inventory tbody td select,
    #inventory tbody td textarea,
    body.force-mobile-mode:not(.force-pc-mode) #inventory tbody td input,
    body.force-mobile-mode:not(.force-pc-mode) #inventory tbody td select,
    body.force-mobile-mode:not(.force-pc-mode) #inventory tbody td textarea {
        border: none !important;
        background: transparent !important;
        box-shadow: none !important;
        outline: none !important;
        padding: 0 !important;
        margin: 0 !important;
        pointer-events: none !important;
        user-select: none !important;
        -webkit-appearance: none !important;
        -moz-appearance: none !important;
        appearance: none !important;
        color: inherit !important;
        font-size: 13.5px !important;
        font-family: inherit !important;
        line-height: 1.3 !important;
        box-sizing: border-box !important;
    }

    #inventory tbody td textarea,
    body.force-mobile-mode:not(.force-pc-mode) #inventory tbody td textarea {
        resize: none !important;
        overflow: hidden !important;
        white-space: pre-wrap !important;
        word-break: break-all !important;
    }

    /* ＋ー（ステッパー）ボタンを削る */
    #inventory .recipe-number-stepper button,
    #inventory .recipe-step-adjust-button,
    body.force-mobile-mode:not(.force-pc-mode) #inventory .recipe-number-stepper button,
    body.force-mobile-mode:not(.force-pc-mode) #inventory .recipe-step-adjust-button {
        display: none !important;
    }

    /* 日付スピン・数値スピンボタンを非表示 */
    #inventory tbody td input::-webkit-inner-spin-button,
    #inventory tbody td input::-webkit-outer-spin-button,
    #inventory tbody td input::-webkit-calendar-picker-indicator,
    body.force-mobile-mode:not(.force-pc-mode) #inventory tbody td input::-webkit-inner-spin-button,
    body.force-mobile-mode:not(.force-pc-mode) #inventory tbody td input::-webkit-outer-spin-button,
    body.force-mobile-mode:not(.force-pc-mode) #inventory tbody td input::-webkit-calendar-picker-indicator {
        display: none !important;
        -webkit-appearance: none !important;
    }

    /* 操作列（9列目）は詳細シート側にあるため非表示 */
    #inventory th:nth-child(10),
    #inventory td:nth-child(10),
    #inventory th:last-child,
    #inventory td:last-child,
    #inventory .row-action-cell,
    #inventory .row-action-trigger,
    #inventory .row-action-menu,
    .row-action-menu,
    body.force-mobile-mode:not(.force-pc-mode) #inventory th:nth-child(10),
    body.force-mobile-mode:not(.force-pc-mode) #inventory td:nth-child(10),
    body.force-mobile-mode:not(.force-pc-mode) #inventory th:last-child,
    body.force-mobile-mode:not(.force-pc-mode) #inventory td:last-child,
    body.force-mobile-mode:not(.force-pc-mode) #inventory .row-action-cell,
    body.force-mobile-mode:not(.force-pc-mode) #inventory .row-action-trigger,
    body.force-mobile-mode:not(.force-pc-mode) #inventory .row-action-menu,
    body.force-mobile-mode:not(.force-pc-mode) .row-action-menu {
        display: none !important;
    }

    /* 1列目: No (幅26px固定・タップ案内下線) */
    #inventory th:first-child,
    #inventory td:first-child,
    body.force-mobile-mode:not(.force-pc-mode) #inventory th:first-child,
    body.force-mobile-mode:not(.force-pc-mode) #inventory td:first-child {
        min-width: 26px !important;
        max-width: 26px !important;
        width: 26px !important;
        padding-left: 2px !important;
        padding-right: 2px !important;
        text-align: center !important;
        border-bottom: 1px solid #ccc !important;
    }

    #inventory tbody tr:not(.separator-row) td:first-child,
    body.force-mobile-mode #inventory tbody td:first-child {
        cursor: pointer !important;
        font-weight: 700 !important;
        color: #0d5f3a !important;
        text-decoration: underline !important;
        text-underline-offset: 2px !important;
        border-bottom: 1px solid #ccc !important;
        pointer-events: auto !important;
        user-select: none !important;
        background: rgba(13, 95, 58, 0.05);
    }

    #inventory tbody tr:not(.separator-row) td:first-child:hover {
        background-color: #d1fae5 !important;
        color: #0d5f3a !important;
        text-decoration: underline !important;
    }

    #inventory tbody tr:not(.separator-row) td:first-child:active {
        background-color: #a7f3d0 !important;
    }

    /* 2列目: レシピ名（余白を自然に吸収して広がり、上下センタリング） */
    #inventory th:nth-child(2),
    #inventory td:nth-child(2),
    #inventory th.recipe-name,
    #inventory td.recipe-name,
    body.force-mobile-mode:not(.force-pc-mode) #inventory th:nth-child(2),
    body.force-mobile-mode:not(.force-pc-mode) #inventory td:nth-child(2),
    body.force-mobile-mode:not(.force-pc-mode) #inventory th.recipe-name,
    body.force-mobile-mode:not(.force-pc-mode) #inventory td.recipe-name {
        min-width: 130px !important;
        width: auto !important;
        vertical-align: middle !important;
    }

    #inventory textarea.recipe2,
    body.force-mobile-mode:not(.force-pc-mode) #inventory textarea.recipe2 {
        width: 100% !important;
        min-width: 120px !important;
        font-weight: 600 !important;
        padding: 2px 2px !important;
        vertical-align: middle !important;
        display: block !important;
        margin: auto 0 !important;
        line-height: 1.35 !important;
        height: auto !important;
        min-height: 34px !important;
        overflow-wrap: break-word !important;
        word-break: break-word !important;
        white-space: pre-wrap !important;
    }

    /* 3列目: 人前 (コンパクト表示) */
    #inventory th:nth-child(3),
    #inventory td:nth-child(3),
    body.force-mobile-mode:not(.force-pc-mode) #inventory th:nth-child(3),
    body.force-mobile-mode:not(.force-pc-mode) #inventory td:nth-child(3),
    #inventory td.servings-cell {
        min-width: 44px !important;
        max-width: 58px !important;
        width: 48px !important;
        text-align: center !important;
        white-space: nowrap !important;
        padding-left: 1px !important;
        padding-right: 1px !important;
    }

    /* 4列目: ジャンル（1文字分削ってコンパクトに調整） */
    #inventory th:nth-child(4),
    #inventory td:nth-child(4),
    body.force-mobile-mode:not(.force-pc-mode) #inventory th:nth-child(4),
    body.force-mobile-mode:not(.force-pc-mode) #inventory td:nth-child(4) {
        min-width: 80px !important;
        max-width: 95px !important;
        width: 88px !important;
        white-space: nowrap !important;
    }

    #inventory td:nth-child(4) select,
    body.force-mobile-mode:not(.force-pc-mode) #inventory td:nth-child(4) select {
        width: 100% !important;
        min-width: 80px !important;
        max-width: 95px !important;
        font-size: 13px !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    /* 5列目: 素材名,数量,単位（縦モードと完全に同一の狭い固定幅に統一: 素材名108px固定、2列合計376px固定） */
    #inventory th:nth-child(5),
    #inventory td:nth-child(5),
    body.force-mobile-mode:not(.force-pc-mode) #inventory th:nth-child(5),
    body.force-mobile-mode:not(.force-pc-mode) #inventory td:nth-child(5) {
        min-width: 328px !important;
        width: auto !important;
        white-space: nowrap !important;
        padding-left: 2px !important;
        padding-right: 2px !important;
    }

    #inventory .recipe-materials-grid,
    body.force-mobile-mode:not(.force-pc-mode) #inventory .recipe-materials-grid {
        display: grid !important;
        width: 100% !important;
        max-width: 100% !important;
        grid-template-columns: minmax(84px, 1fr) calc(4em - 10px) 3em minmax(84px, 1fr) calc(4em - 10px) 3em !important;
        grid-template-rows: auto !important;
        gap: 1px 2px !important;
        box-sizing: border-box !important;
    }

    #inventory .recipe-materials-grid input,
    body.force-mobile-mode:not(.force-pc-mode) #inventory .recipe-materials-grid input {
        font-size: 13px !important;
        height: 18px !important;
        line-height: 18px !important;
        padding: 0 !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
        width: 100% !important;
    }

    #inventory .material-field-group,
    #inventory .material-field-group.portrait-hide-group,
    body.force-mobile-mode:not(.force-pc-mode) #inventory .material-field-group,
    body.force-mobile-mode:not(.force-pc-mode) #inventory .material-field-group.portrait-hide-group,
    body:not(.force-pc-mode) #inventory .material-field-group,
    body:not(.force-pc-mode) #inventory .material-field-group.portrait-hide-group {
        display: contents !important;
    }

    #inventory .material-field-group[style*="display: none"],
    body.force-mobile-mode:not(.force-pc-mode) #inventory .material-field-group[style*="display: none"],
    body:not(.force-pc-mode) #inventory .material-field-group[style*="display: none"] {
        display: none !important;
    }

    #inventory .recipe-materials-grid .material-field {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    #inventory .recipe-materials-grid .quantity-field {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        text-align: right !important;
    }

    #inventory .recipe-materials-grid .unit-field {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
        text-align: left !important;
    }

    /* 7列目: 参考アドレス（余白を自然に吸収して広がる） */
    #inventory th:nth-child(7),
    #inventory td:nth-child(7),
    #inventory th.memo,
    #inventory td.memo,
    body.force-mobile-mode:not(.force-pc-mode) #inventory th:nth-child(7),
    body.force-mobile-mode:not(.force-pc-mode) #inventory td:nth-child(7),
    body.force-mobile-mode:not(.force-pc-mode) #inventory th.memo,
    body.force-mobile-mode:not(.force-pc-mode) #inventory td.memo,
    body:not(.force-pc-mode) #inventory th:nth-child(7),
    body:not(.force-pc-mode) #inventory td:nth-child(7),
    body:not(.force-pc-mode) #inventory th.memo,
    body:not(.force-pc-mode) #inventory td.memo {
        min-width: 130px !important;
        width: auto !important;
    }

    #inventory textarea.memo2,
    body.force-mobile-mode:not(.force-pc-mode) #inventory textarea.memo2,
    body:not(.force-pc-mode) #inventory textarea.memo2 {
        width: 100% !important;
        min-width: 120px !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    /* 7列目・8列目: 倍率・採用数 (各34px) */
    #inventory th.exp,
    #inventory td.exp,
    body.force-mobile-mode:not(.force-pc-mode) #inventory th.exp,
    body.force-mobile-mode:not(.force-pc-mode) #inventory td.exp {
        min-width: 34px !important;
        width: 34px !important;
        padding-left: 1px !important;
        padding-right: 1px !important;
        text-align: center !important;
    }

    #inventory td.exp input,
    body.force-mobile-mode:not(.force-pc-mode) #inventory td.exp input {
        width: 100% !important;
        min-width: 0 !important;
        font-size: 13px !important;
        text-align: center !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .app-header,
    html.force-mobile-mode:not(.force-pc-mode) .app-header {
        display: grid !important;
        grid-template-columns: auto minmax(0, 1fr) auto auto !important;
        grid-template-rows: auto auto !important;
        align-items: center !important;
        padding: 4px 8px !important;
        column-gap: 6px !important;
        row-gap: 2px !important;
        white-space: nowrap !important;
        flex-direction: row !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .app-title-group,
    html.force-mobile-mode:not(.force-pc-mode) .app-title-group {
        display: contents !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .app-title,
    html.force-mobile-mode:not(.force-pc-mode) .app-title {
        grid-column: 1 / 2 !important;
        grid-row: 1 / 3 !important;
        justify-self: start !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        gap: 1px !important;
        margin: 0 !important;
        line-height: 1.15 !important;
        flex-shrink: 0 !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .app-title-main,
    body.force-mobile-mode:not(.force-pc-mode) .app-title-tag,
    html.force-mobile-mode:not(.force-pc-mode) .app-title-main,
    html.force-mobile-mode:not(.force-pc-mode) .app-title-tag {
        font-size: 13.5px !important;
        font-weight: 700 !important;
        white-space: nowrap !important;
        color: #ffffff !important;
        display: block !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .app-subtitle,
    html.force-mobile-mode:not(.force-pc-mode) .app-subtitle {
        grid-column: 2 / 3 !important;
        grid-row: 1 / 3 !important;
        justify-self: start !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        gap: 1px !important;
        margin: 0 !important;
        min-width: 0 !important;
        max-width: 140px !important;
        line-height: 1.2 !important;
        overflow: hidden !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .subtitle-line1,
    body.force-mobile-mode:not(.force-pc-mode) .subtitle-line2,
    html.force-mobile-mode:not(.force-pc-mode) .subtitle-line1,
    html.force-mobile-mode:not(.force-pc-mode) .subtitle-line2 {
        font-size: 11px !important;
        opacity: 0.85 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        display: block !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .header-links,
    html.force-mobile-mode:not(.force-pc-mode) .header-links {
        grid-column: 3 / 4 !important;
        grid-row: 1 / 3 !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        justify-content: flex-end !important;
        justify-self: end !important;
        align-items: center !important;
        gap: 3px !important;
        margin: 0 !important;
        margin-left: auto !important;
        padding: 0 !important;
        flex-shrink: 0 !important;
        min-width: max-content !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .header-links a,
    body.force-mobile-mode:not(.force-pc-mode) .header-links .current-app,
    html.force-mobile-mode:not(.force-pc-mode) .header-links a,
    html.force-mobile-mode:not(.force-pc-mode) .header-links .current-app {
        font-size: 11px !important;
        padding: 2.5px 5px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
        border-radius: 4px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #zainotePlanBadge,
    body.force-mobile-mode:not(.force-pc-mode) .zainote-plan-badge,
    html.force-mobile-mode:not(.force-pc-mode) #zainotePlanBadge,
    html.force-mobile-mode:not(.force-pc-mode) .zainote-plan-badge {
        grid-column: 4 / 5 !important;
        grid-row: 1 !important;
        justify-self: end !important;
        margin: 0 !important;
        font-size: 11px !important;
        padding: 2px 6px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #zainoteModeToggleBtn,
    body.force-mobile-mode:not(.force-pc-mode) .zainote-mode-toggle-btn,
    html.force-mobile-mode:not(.force-pc-mode) #zainoteModeToggleBtn,
    html.force-mobile-mode:not(.force-pc-mode) .zainote-mode-toggle-btn {
        grid-column: 4 / 5 !important;
        grid-row: 2 !important;
        justify-self: end !important;
        margin: 0 !important;
        font-size: 9.5px !important;
        padding: 2px 5px !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }
}


/* ==========================================================================
   スマホ横画面（Landscape）データ管理タブ＆ソートエリア:
   - ボタン上下サイズを30pxに統一
   ========================================================================== */
@media screen and (orientation: landscape) and (max-height: 600px),
       screen and (max-width: 768px) and (orientation: landscape) {

    /* 検索タブ（横1行・4コントロール配置: 縦モードと共通） */
    #tab-panel-search td {
        display: grid !important;
        grid-template-columns: minmax(0, 1.6fr) minmax(0, 2.8fr) minmax(0, 1.2fr) minmax(0, 1.8fr) !important;
        gap: 6px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        white-space: normal !important;
        align-items: center !important;
    }

    #tab-panel-search label {
        display: none !important;
    }

    #itemGenre2,
    #searchInputNew,
    #searchButtonNew,
    #clearFilterButton {
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        box-sizing: border-box !important;
    }

    #searchButtonNew,
    #clearFilterButton {
        white-space: nowrap !important;
        text-align: center !important;
    }

    #filterStatus {
        grid-column: 1 / -1 !important;
        text-align: center !important;
        font-size: 12px !important;
        color: #64748b !important;
        margin: 4px 0 0 !important;
        display: block !important;
    }

    /* 新レシピの追加フォーム（縦モードと完全共通ベース ＋ 素材ボックス横2列配置） */
    #tab-panel-add table,
    #tab-panel-add tbody,
    #tab-panel-add tr,
    #tab-panel-add td {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
    }

    #tab-panel-add #addForm {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 3px !important;
    }

    #tab-panel-add .add-form-row {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        margin-bottom: 0 !important;
        padding: 0 !important;
    }

    #tab-panel-add label {
        font-size: 12px !important;
        font-weight: 700 !important;
        color: #0d5f3a !important;
        margin: 0 !important;
        padding: 0 !important;
        text-align: left !important;
        display: block !important;
        white-space: nowrap !important;
        width: auto !important;
        min-width: 0 !important;
        flex: none !important;
    }

    #tab-panel-add input,
    #tab-panel-add select {
        width: 100% !important;
        min-width: 0 !important;
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        font-size: 12px !important;
        padding: 0 6px !important;
        border: 1px solid #cbd5e1 !important;
        border-radius: 5px !important;
        box-sizing: border-box !important;
        background: #ffffff !important;
    }

    /* 1行目: 素材選択ブロック（4列均等配置: 分類・素材名・数量・単位） */
    #tab-panel-add .add-form-row:first-of-type {
        display: grid !important;
        grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 0.8fr) minmax(0, 0.8fr) !important;
        gap: 2px 6px !important;
        width: 100% !important;
        align-items: end !important;
    }

    #tab-panel-add .add-form-row:first-of-type label[for="itemCategory"] {
        grid-column: 1 / 2 !important;
        grid-row: 1 !important;
    }
    #tab-panel-add .add-form-row:first-of-type select#itemCategory {
        grid-column: 1 / 2 !important;
        grid-row: 2 !important;
    }

    #tab-panel-add .add-form-row:first-of-type .material-input-group {
        display: contents !important;
    }

    #tab-panel-add .add-form-row:first-of-type label[for="itemName"] {
        grid-column: 2 / 3 !important;
        grid-row: 1 !important;
    }
    #tab-panel-add .add-form-row:first-of-type select#itemName {
        grid-column: 2 / 3 !important;
        grid-row: 2 !important;
    }

    #tab-panel-add .add-form-row:first-of-type label[for="itemQuantity"] {
        grid-column: 3 / 4 !important;
        grid-row: 1 !important;
    }
    #tab-panel-add .add-form-row:first-of-type select#itemQuantity {
        grid-column: 3 / 4 !important;
        grid-row: 2 !important;
    }

    #tab-panel-add .add-form-row:first-of-type label[for="itemUnit"] {
        grid-column: 4 / 5 !important;
        grid-row: 1 !important;
    }
    #tab-panel-add .add-form-row:first-of-type select#itemUnit {
        grid-column: 4 / 5 !important;
        grid-row: 2 !important;
    }

    /* 2行目: 素材検索 ＆ 横3ボタンブロック（1行・4列パッキング） */
    #tab-panel-add .add-form-row:nth-of-type(2) {
        display: grid !important;
        grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.25fr) minmax(0, 1.25fr) minmax(0, 1.25fr) !important;
        gap: 4px 6px !important;
        width: 100% !important;
        align-items: center !important;
    }

    #tab-panel-add .add-form-row:nth-of-type(2) label[for="searchInput"] {
        display: none !important;
    }

    #tab-panel-add .add-form-row:nth-of-type(2) input#searchInput {
        grid-column: 1 / 2 !important;
        grid-row: 1 !important;
        width: 100% !important;
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        font-size: 12px !important;
        padding: 0 6px !important;
        border: 1px solid #cbd5e1 !important;
        border-radius: 5px !important;
        box-sizing: border-box !important;
        background: #ffffff !important;
    }

    #addButton {
        grid-column: 2 / 3 !important;
        grid-row: 1 !important;
        background: #0d5f3a !important;
        color: #ffffff !important;
        border: 1px solid #0a4b2e !important;
    }

    #compressButton {
        grid-column: 3 / 4 !important;
        grid-row: 1 !important;
        background: #fff1f2 !important;
        color: #be123c !important;
        border: 1px solid #fecdd3 !important;
    }

    #addButton2 {
        grid-column: 4 / 5 !important;
        grid-row: 1 !important;
        background: #ea580c !important;
        color: #ffffff !important;
        border: 1px solid #c2410c !important;
    }

    #addButton,
    #compressButton,
    #addButton2 {
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        font-size: 11px !important;
        font-weight: 700 !important;
        border-radius: 5px !important;
        box-sizing: border-box !important;
        width: 100% !important;
        white-space: nowrap !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 2px 2px !important;
        letter-spacing: -0.3px !important;
        text-align: center !important;
        cursor: pointer !important;
        margin: 0 !important;
    }

    /* 3行目: 素材ボックス（横画面は素材の01〜08を横2列配置） */
    #tab-panel-add #materialFields {
        width: 100% !important;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 3px 6px !important;
        margin-top: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #tab-panel-add .material-field-group {
        display: grid !important;
        grid-template-columns: 52px minmax(0, 1fr) 36px 30px !important;
        gap: 3px !important;
        align-items: center !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    #tab-panel-add .material-field-group[style*="display: none"] {
        display: none !important;
    }

    #tab-panel-add .material-field-group label {
        font-size: 11px !important;
        font-weight: 700 !important;
        text-align: right !important;
        padding-right: 2px !important;
        white-space: nowrap !important;
        color: #334155 !important;
        overflow: visible !important;
        letter-spacing: -0.2px !important;
    }

    #tab-panel-add .material-field-group input {
        height: 32px !important;
        font-size: 12px !important;
        padding: 2px 3px !important;
        border: 1px solid #cbd5e1 !important;
        border-radius: 5px !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }

    /* 4行目: レシピ基本情報（横1行・4項目配置: レシピ名/人前/ジャンル/Web） */
    #materialListContainer {
        width: 100% !important;
        margin-top: 3px !important;
        padding-top: 3px !important;
        border-top: 1px solid #e2e8f0 !important;
    }

    .recipe-input-group {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    .recipe-input-group .form-item {
        display: inline-flex !important;
        align-items: center !important;
        gap: 4px !important;
        white-space: nowrap !important;
        min-width: 0 !important;
    }

    .recipe-input-group label {
        font-size: 12px !important;
        font-weight: 700 !important;
        color: #0d5f3a !important;
        margin: 0 !important;
        padding: 0 !important;
        text-align: left !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    /* レシピ名（伸長） */
    .recipe-input-group .form-item-location {
        flex: 1.2 1 120px !important;
    }
    #itemLocation {
        width: 100% !important;
        min-width: 80px !important;
    }

    /* 人前（コンパクト固定幅） */
    .recipe-input-group .form-item-servings {
        flex: 0 0 auto !important;
    }
    #itemServings {
        width: 44px !important;
        min-width: 44px !important;
        max-width: 44px !important;
        text-align: center !important;
        padding: 0 4px !important;
        appearance: textfield !important;
        -moz-appearance: textfield !important;
    }

    /* ジャンル（コンパクト固定幅） */
    .recipe-input-group .form-item-genre {
        flex: 0 0 auto !important;
    }
    #itemGenre {
        width: 86px !important;
        min-width: 86px !important;
        max-width: 94px !important;
    }

    /* Web（伸長） */
    .recipe-input-group .form-item-memo {
        flex: 1 1 120px !important;
    }
    #itemMemo {
        width: 100% !important;
        min-width: 80px !important;
    }

    #itemServings::-webkit-inner-spin-button,
    #itemServings::-webkit-outer-spin-button {
        -webkit-appearance: none !important;
        margin: 0 !important;
    }

    #itemLocation,
    #itemServings,
    #itemGenre,
    #itemMemo {
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        font-size: 12px !important;
        padding: 0 4px !important;
        border-radius: 5px !important;
        box-sizing: border-box !important;
    }

    /* データ管理タブ（1行3ボタン横並び: 左タイトル108px + 右3ボタン） */
    .management-tab-content {
        width: 100% !important;
        gap: 0 !important;
        box-sizing: border-box !important;
    }

    .management-group {
        display: grid !important;
        grid-template-columns: 94px repeat(3, minmax(0, 1fr)) !important;
        gap: 4px !important;
        width: 100% !important;
        margin-bottom: 3px !important;
        align-items: stretch !important;
        box-sizing: border-box !important;
    }

    .management-group:last-child {
        margin-bottom: 1px !important;
    }

    #tab-panel-manage {
        padding-bottom: 1px !important;
    }

    body:not(.force-pc-mode) .management-group-title,
    .management-group-title {
        grid-column: 1 / 2 !important;
        grid-row: 1 !important;
        width: 94px !important;
        min-width: 94px !important;
        max-width: 94px !important;
        height: 36px !important;
        border-right: 2px solid #a7d7b8 !important;
        border-bottom: none !important;
        padding: 2px 6px !important;
        margin: 0 !important;
        font-size: 11px !important;
        font-weight: 700 !important;
        white-space: nowrap !important;
        display: inline-flex !important;
        align-items: center !important;
        box-sizing: border-box !important;
        background: transparent !important;
        color: #334155 !important;
            justify-content: flex-start !important;
        text-align: left !important;
}

    .management-tab-content .custom-button,
    .management-group .custom-button,
    .management-group a,
    .management-group button,
    .management-group label {
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        font-size: 12px !important;
        padding: 2px 4px !important;
        box-sizing: border-box !important;
        border-radius: 5px !important;
        line-height: 1.2 !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        white-space: nowrap !important;
        margin: 0 !important;
        width: 100% !important;
        min-width: 0 !important;
    }
}


/* ==========================================================================
   全スマホモード（縦・横・強制スマホ）共通:
   - タブ余白削減 (padding: 4px 8px 3px)
   - ドロップダウン・テキストボックス: 上下サイズ30pxに圧縮
   - ソートエリア: 30px統一
   - データ管理タブボタン: 30px統一
   ========================================================================== */
@media (max-width: 768px), (max-height: 600px) and (orientation: landscape), (orientation: portrait) and (max-width: 768px) {
    #tab-panel-search,
    #tab-panel-add,
    #tab-panel-files,
    .tab-content-panel {
        padding: 4px 8px 3px !important;
        margin-bottom: 4px !important;
        min-height: 0 !important;
    }

    .file-actions .custom-button,
    .file-actions a,
    .file-actions label {
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        font-size: 12px !important;
        padding: 2px 2px !important;
        box-sizing: border-box !important;
        border-radius: 5px !important;
        line-height: 1.2 !important;
    }

    /* ソートエリア: 高さ30pxに統一 */
    .action-group .sort-select,
    .action-group .sort-execute-button,
    #finalCheckLink,
    #saveAllButton,
    .sort-select,
    .sort-execute-button {
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        box-sizing: border-box !important;
    }

    /* タブ内: ドロップダウン・テキストボックスの上下サイズを30pxに圧縮（上下余白・パディングを削減） */
    .tab-content-panel input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
    .tab-content-panel select,
    #tab-panel-search input,
    #tab-panel-search select,
    #tab-panel-add input,
    #tab-panel-add select,
    #tab-panel-add select#itemCategory,
    #tab-panel-add select#itemName,
    #tab-panel-add select#itemQuantity,
    #tab-panel-add select#itemUnit,
    #itemLocation,
    #itemGenre,
    #itemMemo,
    #itemOutput {
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        padding: 0 6px !important;
        box-sizing: border-box !important;
        font-size: 12px !important;
    }

    /* タブ内のアクションボタンも30pxで高さを揃える */
    #tab-panel-add #addButton,
    #tab-panel-add #compressButton,
    #tab-panel-add #addButton2,
    #tab-panel-search button,
    #addButton,
    #compressButton,
    #addButton2 {
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        box-sizing: border-box !important;
    }

    /* ラベルの高さ統一 */
    #tab-panel-add label,
    #addForm label,
    .add-form-row label {
        height: 16px !important;
        min-height: 16px !important;
        max-height: 16px !important;
        line-height: 16px !important;
        font-size: 13px !important;
        margin: 0 0 2px 0 !important;
        padding: 0 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        box-sizing: border-box !important;
    }
}

/* 強制スマホモード（PCでの検証用） */
body.force-mobile-mode #tab-panel-search,
body.force-mobile-mode #tab-panel-add,
body.force-mobile-mode #tab-panel-files,
body.force-mobile-mode .tab-content-panel {
    padding: 4px 8px 3px !important;
    margin-bottom: 4px !important;
    min-height: 0 !important;
}

body.force-mobile-mode .file-actions .custom-button,
body.force-mobile-mode .file-actions a,
body.force-mobile-mode .file-actions label,
body.force-mobile-mode .action-group .sort-select,
body.force-mobile-mode .action-group .sort-execute-button,
body.force-mobile-mode #finalCheckLink,
body.force-mobile-mode #saveAllButton,
body.force-mobile-mode .tab-content-panel input:not([type="checkbox"]):not([type="radio"]):not([type="file"]),
body.force-mobile-mode .tab-content-panel select,
body.force-mobile-mode #addButton,
body.force-mobile-mode #compressButton,
body.force-mobile-mode #addButton2 {
    height: 30px !important;
    min-height: 30px !important;
    max-height: 30px !important;
    box-sizing: border-box !important;
}


/* ==========================================================================
   PCでの強制スマホモード（横長モニタ環境）:
   画面解像度（max-width/max-height）に縛られず、横長時は確実に横モードレイアウトを適用
   ========================================================================== */
@media screen and (orientation: landscape) and (max-height: 600px), screen and (max-width: 768px) and (orientation: landscape) {
    /* 1. グローバルアクションバー（横1行フラット集約配置: zaiko同様） */
    #sortControlsTable,
    .global-action-bar,
    .inventory-content > .global-action-bar,
    body.force-mobile-mode:not(.force-pc-mode) #sortControlsTable,
    body.force-mobile-mode:not(.force-pc-mode) .global-action-bar,
    body.force-mobile-mode:not(.force-pc-mode) .inventory-content > .global-action-bar {
        display: flex !important;
        flex-direction: row !important;
        align-items: flex-end !important;
        justify-content: flex-start !important;
        flex-wrap: nowrap !important;
        gap: 14px !important;
        padding: 4px 10px !important;
        background: #f8fafc !important;
        border: 1px solid #e2e8f0 !important;
        border-radius: 6px !important;
        box-sizing: border-box !important;
        width: 100% !important;
        min-width: 0 !important;
        max-width: 100% !important;
        overflow: visible !important;
        overflow-x: visible !important;
        overflow-y: visible !important;
        scrollbar-width: none !important;
        position: static !important;
        height: auto !important;
    }

    /* 一括保存ボタン・ソートボタン・保存ラベルを完全非表示 */
    #saveAllButton,
    #sortExecuteButton,
    .save-group-label,
    body.force-mobile-mode:not(.force-pc-mode) #saveAllButton,
    body.force-mobile-mode:not(.force-pc-mode) #sortExecuteButton,
    body.force-mobile-mode:not(.force-pc-mode) .save-group-label {
        display: none !important;
    }

    /* 1. ソートブロック: 上ラベル + 下セレクト */
    .action-group.sort-action-group,
    body.force-mobile-mode:not(.force-pc-mode) .action-group.sort-action-group {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        flex: 0 0 auto !important;
        gap: 0 !important;
        min-width: 0 !important;
        width: auto !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    .action-bar-item-label,
    .sort-group-label,
    .color-priority-label,
    body.force-mobile-mode:not(.force-pc-mode) .action-bar-item-label,
    body.force-mobile-mode:not(.force-pc-mode) .sort-group-label,
    body.force-mobile-mode:not(.force-pc-mode) .color-priority-label {
        display: block !important;
        height: 16px !important;
        min-height: 16px !important;
        max-height: 16px !important;
        line-height: 16px !important;
        font-size: 13px !important;
        color: #475569 !important;
        font-weight: 500 !important;
        margin: 0 0 2px 0 !important;
        padding: 0 !important;
        white-space: nowrap !important;
        box-sizing: border-box !important;
    }

    .action-group .sort-select,
    body.force-mobile-mode:not(.force-pc-mode) .action-group .sort-select {
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        font-size: 12.5px !important;
        padding: 0 6px !important;
        border: 1px solid #cbd5e1 !important;
        border-radius: 5px !important;
        background: #ffffff !important;
        box-sizing: border-box !important;
        width: auto !important;
        min-width: 175px !important;
        max-width: 215px !important;
        margin: 0 !important;
    }

    /* 2. 文字色ブロック: 上ラベル + 下ボタン */
    .color-priority-control,
    body.force-mobile-mode:not(.force-pc-mode) .color-priority-control {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        flex: 0 0 auto !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        gap: 0 !important;
        width: auto !important;
    }

    .color-priority-buttons,
    body.force-mobile-mode:not(.force-pc-mode) .color-priority-buttons {
        display: flex !important;
        align-items: center !important;
        gap: 4px !important;
        height: 30px !important;
    }

    .color-priority-buttons button,
    .color-priority-control button,
    body.force-mobile-mode:not(.force-pc-mode) .color-priority-buttons button,
    body.force-mobile-mode:not(.force-pc-mode) .color-priority-control button {
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        font-size: 12px !important;
        padding: 0 10px !important;
        box-sizing: border-box !important;
        border-radius: 5px !important;
        border: 1px solid #cbd5e1 !important;
        background: #ffffff !important;
        color: #334155 !important;
        cursor: pointer;
        transition: background-color 0.15s, border-color 0.15s;
    }

    .color-priority-buttons button[aria-pressed="true"],
    .color-priority-control button[aria-pressed="true"],
    .color-priority-control button.active,
    body.force-mobile-mode:not(.force-pc-mode) .color-priority-buttons button[aria-pressed="true"],
    body.force-mobile-mode:not(.force-pc-mode) .color-priority-control button[aria-pressed="true"],
    body.force-mobile-mode:not(.force-pc-mode) .color-priority-control button.active {
        background: #0d5f3a !important;
        color: #ffffff !important;
        border-color: #0d5f3a !important;
    }

    /* 3. メタ情報ブロック: 最新保存時刻 ＋ 購入計算リンク */
    .meta-info-control,
    body.force-mobile-mode:not(.force-pc-mode) .meta-info-control {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        flex: 0 0 auto !important;
        margin-left: auto !important;
        gap: 12px !important;
        height: 30px !important;
        box-sizing: border-box !important;
        border: none !important;
        padding: 0 !important;
    }

    #saveTimeDisplay,
    body.force-mobile-mode:not(.force-pc-mode) #saveTimeDisplay {
        font-size: 11px !important;
        color: #64748b !important;
        display: inline-flex !important;
        align-items: center !important;
        white-space: nowrap !important;
        line-height: 1.2 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #finalCheckLink,
    body.force-mobile-mode:not(.force-pc-mode) #finalCheckLink {
        font-size: 12px !important;
        font-weight: 600 !important;
        height: 28px !important;
        line-height: 28px !important;
        padding: 0 10px !important;
        border-radius: 4px !important;
        background: #0d5f3a !important;
        color: #ffffff !important;
        text-decoration: none !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        box-sizing: border-box !important;
    }
}

.global-action-bar::-webkit-scrollbar,
.inventory-content > .global-action-bar::-webkit-scrollbar {
    display: none !important;
}


    /* 2. 検索タブ（横1行・4コントロール配置: 縦モードと共通） */
    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-search td {
        display: grid !important;
        grid-template-columns: minmax(0, 1.6fr) minmax(0, 2.8fr) minmax(0, 1.2fr) minmax(0, 1.8fr) !important;
        gap: 6px !important;
        width: 100% !important;
        box-sizing: border-box !important;
        white-space: normal !important;
        align-items: center !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-search label {
        display: none !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #itemGenre2,
    body.force-mobile-mode:not(.force-pc-mode) #searchInputNew,
    body.force-mobile-mode:not(.force-pc-mode) #searchButtonNew,
    body.force-mobile-mode:not(.force-pc-mode) #clearFilterButton {
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        box-sizing: border-box !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #searchButtonNew,
    body.force-mobile-mode:not(.force-pc-mode) #clearFilterButton {
        white-space: nowrap !important;
        text-align: center !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #filterStatus {
        grid-column: 1 / -1 !important;
        text-align: center !important;
        font-size: 12px !important;
        color: #64748b !important;
        margin: 4px 0 0 !important;
        display: block !important;
    }

    /* 3. 新レシピの追加フォーム（縦モードと完全共通ベース ＋ 素材ボックス横2列配置） */
    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add table,
    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add tbody,
    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add tr,
    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add td {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
        border: none !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add #addForm {
        width: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 3px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .add-form-row {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        margin-bottom: 0 !important;
        padding: 0 !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add label {
        font-size: 12px !important;
        font-weight: 700 !important;
        color: #0d5f3a !important;
        margin: 0 !important;
        padding: 0 !important;
        text-align: left !important;
        display: block !important;
        white-space: nowrap !important;
        width: auto !important;
        min-width: 0 !important;
        flex: none !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add input,
    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add select {
        width: 100% !important;
        min-width: 0 !important;
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        font-size: 12px !important;
        padding: 0 6px !important;
        border: 1px solid #cbd5e1 !important;
        border-radius: 5px !important;
        box-sizing: border-box !important;
        background: #ffffff !important;
    }

    /* 1行目: 素材選択ブロック（4列均等配置: 分類・素材名・数量・単位） */
    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .add-form-row:first-of-type {
        display: grid !important;
        grid-template-columns: minmax(0, 1.2fr) minmax(0, 1.2fr) minmax(0, 0.8fr) minmax(0, 0.8fr) !important;
        gap: 4px 6px !important;
        width: 100% !important;
        align-items: end !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .add-form-row:first-of-type label[for="itemCategory"] {
        grid-column: 1 / 2 !important;
        grid-row: 1 !important;
    }
    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .add-form-row:first-of-type select#itemCategory {
        grid-column: 1 / 2 !important;
        grid-row: 2 !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .add-form-row:first-of-type .material-input-group {
        display: contents !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .add-form-row:first-of-type label[for="itemName"] {
        grid-column: 2 / 3 !important;
        grid-row: 1 !important;
    }
    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .add-form-row:first-of-type select#itemName {
        grid-column: 2 / 3 !important;
        grid-row: 2 !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .add-form-row:first-of-type label[for="itemQuantity"] {
        grid-column: 3 / 4 !important;
        grid-row: 1 !important;
    }
    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .add-form-row:first-of-type select#itemQuantity {
        grid-column: 3 / 4 !important;
        grid-row: 2 !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .add-form-row:first-of-type label[for="itemUnit"] {
        grid-column: 4 / 5 !important;
        grid-row: 1 !important;
    }
    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .add-form-row:first-of-type select#itemUnit {
        grid-column: 4 / 5 !important;
        grid-row: 2 !important;
    }

    /* 2行目: 素材検索 ＆ 横3ボタンブロック（1行・4列パッキング） */
    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .add-form-row:nth-of-type(2) {
        display: grid !important;
        grid-template-columns: minmax(0, 1.25fr) minmax(0, 1.25fr) minmax(0, 1.25fr) minmax(0, 1.25fr) !important;
        gap: 4px 6px !important;
        width: 100% !important;
        align-items: center !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .add-form-row:nth-of-type(2) label[for="searchInput"] {
        display: none !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .add-form-row:nth-of-type(2) input#searchInput {
        grid-column: 1 / 2 !important;
        grid-row: 1 !important;
        width: 100% !important;
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        font-size: 12px !important;
        padding: 0 6px !important;
        border: 1px solid #cbd5e1 !important;
        border-radius: 5px !important;
        box-sizing: border-box !important;
        background: #ffffff !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #addButton {
        grid-column: 2 / 3 !important;
        grid-row: 1 !important;
        background: #0d5f3a !important;
        color: #ffffff !important;
        border: 1px solid #0a4b2e !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #compressButton {
        grid-column: 3 / 4 !important;
        grid-row: 1 !important;
        background: #fff1f2 !important;
        color: #be123c !important;
        border: 1px solid #fecdd3 !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #addButton2 {
        grid-column: 4 / 5 !important;
        grid-row: 1 !important;
        background: #ea580c !important;
        color: #ffffff !important;
        border: 1px solid #c2410c !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #addButton,
    body.force-mobile-mode:not(.force-pc-mode) #compressButton,
    body.force-mobile-mode:not(.force-pc-mode) #addButton2 {
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        font-size: 11px !important;
        font-weight: 700 !important;
        border-radius: 5px !important;
        box-sizing: border-box !important;
        width: 100% !important;
        white-space: nowrap !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        padding: 2px 2px !important;
        letter-spacing: -0.3px !important;
        text-align: center !important;
        cursor: pointer !important;
        margin: 0 !important;
    }

    /* 3行目: 素材ボックス（横画面は素材の01〜08を横2列配置） */
    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add #materialFields {
        width: 100% !important;
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 3px 6px !important;
        margin-top: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .material-field-group {
        display: grid !important;
        grid-template-columns: 52px minmax(0, 1fr) 36px 30px !important;
        gap: 3px !important;
        align-items: center !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .material-field-group[style*="display: none"] {
        display: none !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .material-field-group label {
        font-size: 11px !important;
        font-weight: 700 !important;
        text-align: right !important;
        padding-right: 2px !important;
        white-space: nowrap !important;
        color: #334155 !important;
        overflow: visible !important;
        letter-spacing: -0.2px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add .material-field-group input {
        height: 32px !important;
        font-size: 12px !important;
        padding: 2px 3px !important;
        border: 1px solid #cbd5e1 !important;
        border-radius: 5px !important;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }

    /* 4行目: レシピ基本情報（横1行・4項目配置: レシピ名/人前/ジャンル/Web） */
    body.force-mobile-mode:not(.force-pc-mode) #materialListContainer {
        width: 100% !important;
        margin-top: 3px !important;
        padding-top: 3px !important;
        border-top: 1px solid #e2e8f0 !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .recipe-input-group {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-sizing: border-box !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .recipe-input-group .form-item {
        display: inline-flex !important;
        align-items: center !important;
        gap: 4px !important;
        white-space: nowrap !important;
        min-width: 0 !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .recipe-input-group label {
        font-size: 12px !important;
        font-weight: 700 !important;
        color: #0d5f3a !important;
        margin: 0 !important;
        padding: 0 !important;
        text-align: left !important;
        white-space: nowrap !important;
        flex-shrink: 0 !important;
    }

    /* レシピ名（伸長） */
    body.force-mobile-mode:not(.force-pc-mode) .recipe-input-group .form-item-location {
        flex: 1.2 1 120px !important;
    }
    body.force-mobile-mode:not(.force-pc-mode) #itemLocation {
        width: 100% !important;
        min-width: 80px !important;
    }

    /* 人前（コンパクト固定幅） */
    body.force-mobile-mode:not(.force-pc-mode) .recipe-input-group .form-item-servings {
        flex: 0 0 auto !important;
    }
    body.force-mobile-mode:not(.force-pc-mode) #itemServings {
        width: 44px !important;
        min-width: 44px !important;
        max-width: 44px !important;
        text-align: center !important;
        padding: 0 4px !important;
        appearance: textfield !important;
        -moz-appearance: textfield !important;
    }

    /* ジャンル（コンパクト固定幅） */
    body.force-mobile-mode:not(.force-pc-mode) .recipe-input-group .form-item-genre {
        flex: 0 0 auto !important;
    }
    body.force-mobile-mode:not(.force-pc-mode) #itemGenre {
        width: 86px !important;
        min-width: 86px !important;
        max-width: 94px !important;
    }

    /* Web（伸長） */
    body.force-mobile-mode:not(.force-pc-mode) .recipe-input-group .form-item-memo {
        flex: 1 1 120px !important;
    }
    body.force-mobile-mode:not(.force-pc-mode) #itemMemo {
        width: 100% !important;
        min-width: 80px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #itemServings::-webkit-inner-spin-button,
    body.force-mobile-mode:not(.force-pc-mode) #itemServings::-webkit-outer-spin-button {
        -webkit-appearance: none !important;
        margin: 0 !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #itemLocation,
    body.force-mobile-mode:not(.force-pc-mode) #itemServings,
    body.force-mobile-mode:not(.force-pc-mode) #itemGenre,
    body.force-mobile-mode:not(.force-pc-mode) #itemMemo {
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        line-height: 28px !important;
        font-size: 12px !important;
        padding: 0 4px !important;
        border-radius: 5px !important;
        box-sizing: border-box !important;
    }

    /* 4. データ管理タブ（1行3ボタン横並び: 左タイトル108px + 右3ボタン） */
    body.force-mobile-mode:not(.force-pc-mode) .management-tab-content {
        width: 100% !important;
        gap: 0 !important;
        box-sizing: border-box !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .management-group {
        display: grid !important;
        grid-template-columns: 94px repeat(3, minmax(0, 1fr)) !important;
        gap: 4px !important;
        width: 100% !important;
        margin-bottom: 3px !important;
        align-items: stretch !important;
        box-sizing: border-box !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .management-group:last-child {
        margin-bottom: 1px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) #tab-panel-manage {
        padding-bottom: 1px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) body:not(.force-pc-mode) .management-group-title,
 .management-group-title {
        grid-column: 1 / 2 !important;
        grid-row: 1 !important;
        width: 94px !important;
        min-width: 94px !important;
        max-width: 94px !important;
        height: 36px !important;
        border-right: 2px solid #a7d7b8 !important;
        border-bottom: none !important;
        padding: 2px 6px !important;
        margin: 0 !important;
        font-size: 11px !important;
        font-weight: 700 !important;
        white-space: nowrap !important;
        display: inline-flex !important;
        align-items: center !important;
        box-sizing: border-box !important;
        background: transparent !important;
        color: #334155 !important;
            justify-content: flex-start !important;
        text-align: left !important;
}

    /* 5. 詳細シート（横画面用・2大カラム・素材8マス展開） */
    body.force-mobile-mode:not(.force-pc-mode) .mobile-detail-sheet {
        width: 96vw !important;
        max-width: 940px !important;
        max-height: 98vh !important;
        border-radius: 12px 12px 0 0 !important;
        bottom: env(safe-area-inset-bottom, 0px) !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-drag-handle {
        width: 36px !important;
        height: 3px !important;
        margin: 2px auto 1px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-header {
        padding: 2px 14px 3px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-title {
        font-size: 14px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-no-badge {
        font-size: 11.5px !important;
        padding: 2px 6px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-close-btn {
        padding: 2px 8px !important;
        font-size: 18px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-body {
        padding: 3px 14px 4px !important;
        display: grid !important;
        grid-template-columns: 1fr 1.15fr !important;
        column-gap: 16px !important;
        row-gap: 2.5px !important;
        overflow-y: auto !important;
        align-content: start !important;
        flex: 1 1 auto !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-field-meta-grid {
        grid-column: 1 / 2 !important;
        grid-row: 1 !important;
        display: grid !important;
        grid-template-columns: 1.2fr 0.8fr !important;
        gap: 6px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-field-number-grid {
        grid-column: 1 / 2 !important;
        grid-row: 2 !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 6px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-field-memo {
        grid-column: 1 / 2 !important;
        grid-row: 3 !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-field-time,
    body.force-mobile-mode:not(.force-pc-mode) .sheet-meta-row {
        grid-column: 1 / 2 !important;
        grid-row: 4 !important;
        padding: 2px 6px !important;
        font-size: 11px !important;
        border-radius: 4px !important;
        margin: 0 !important;
        line-height: 1.3 !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-update-time {
        font-size: 11px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-footer {
        grid-column: 1 / 2 !important;
        grid-row: 5 !important;
        display: flex !important;
        flex-direction: row !important;
        gap: 5px !important;
        padding: 0 !important;
        border-top: none !important;
        background: transparent !important;
        position: static !important;
        margin: 2px 0 0 0 !important;
        z-index: auto !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-btn {
        height: 31px !important;
        font-size: 12.5px !important;
        padding: 0 8px !important;
        border-radius: 4px !important;
        white-space: nowrap !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-btn-update {
        flex: 1.4 1 auto !important;
        font-size: 13px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-btn-delete {
        flex: 1 1 auto !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-btn-url {
        flex: 0 0 auto !important;
        padding: 0 6px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-btn-lbl-full {
        display: none !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-btn-lbl-short {
        display: inline !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-field-group {
        gap: 1px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-label {
        font-size: 11px !important;
        font-weight: 700 !important;
        margin-bottom: 1.5px !important;
        white-space: nowrap !important;
        line-height: 1.2 !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-input,
    body.force-mobile-mode:not(.force-pc-mode) .sheet-select {
        height: 29px !important;
        font-size: 12.5px !important;
        padding: 1px 5px !important;
        border-radius: 4px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-name-input {
        font-size: 12px !important;
        font-weight: 700 !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-stepper {
        gap: 2px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-step-btn {
        width: 25px !important;
        height: 28px !important;
        font-size: 14px !important;
        border-radius: 4px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-num-input {
        height: 29px !important;
        font-size: 12.5px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-materials-section {
        grid-column: 2 / 3 !important;
        grid-row: 1 / 6 !important;
        display: flex !important;
        flex-direction: column !important;
        gap: 2px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-material-list {
        padding: 3px 5px !important;
        gap: 2px !important;
        border-radius: 6px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-mat-row {
        display: grid !important;
        grid-template-columns: 18px 1fr 54px 44px !important;
        gap: 2px !important;
        align-items: center !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-mat-num {
        font-size: 11px !important;
        font-weight: 700 !important;
        padding-right: 1px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-mat-name,
    body.force-mobile-mode:not(.force-pc-mode) .sheet-mat-qty,
    body.force-mobile-mode:not(.force-pc-mode) .sheet-mat-unit {
        height: 23px !important;
        font-size: 11px !important;
        padding: 1px 4px !important;
        border-radius: 3px !important;
    }

    body.force-mobile-mode:not(.force-pc-mode) .sheet-toggle-mat-btn {
        display: none !important;
    }
}


/* ==========================================================================
   スマホモード専用: 参考アドレス（td.memo）設定
   PCではマウスオンのチップを使用し、スマホ時のみ右下角に🌐地球アイコンボタンを表示
   ========================================================================== */
#inventory td.memo,
.recipe-table td.memo,
body.force-mobile-mode:not(.force-pc-mode) #inventory td.memo,
body.force-mobile-mode:not(.force-pc-mode) .recipe-table td.memo {
    position: relative !important;
}

#inventory .memo-wrapper,
.recipe-table .memo-wrapper,
body.force-mobile-mode:not(.force-pc-mode) #inventory .memo-wrapper,
body.force-mobile-mode:not(.force-pc-mode) .recipe-table .memo-wrapper {
    position: relative !important;
    width: 100% !important;
    height: 100% !important;
    display: block !important;
}

#inventory .url-open-btn,
.recipe-table .url-open-btn,
body.force-mobile-mode:not(.force-pc-mode) #inventory .url-open-btn,
body.force-mobile-mode:not(.force-pc-mode) .recipe-table .url-open-btn {
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    position: absolute !important;
    right: 2px !important;
    bottom: 3px !important;
    width: 19px !important;
    height: 19px !important;
    padding: 0 !important;
    margin: 0 !important;
    font-size: 13.5px !important;
    line-height: 1 !important;
    background: rgba(255, 255, 255, 0.9) !important;
    border: 1px solid rgba(0, 0, 0, 0.22) !important;
    border-radius: 3px !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.15) !important;
    cursor: pointer !important;
    z-index: 5 !important;
    touch-action: manipulation !important;
}

#inventory .memo-wrapper.has-scrollbar .url-open-btn,
.recipe-table .memo-wrapper.has-scrollbar .url-open-btn,
body.force-mobile-mode:not(.force-pc-mode) #inventory .memo-wrapper.has-scrollbar .url-open-btn,
body.force-mobile-mode:not(.force-pc-mode) .recipe-table .memo-wrapper.has-scrollbar .url-open-btn {
    right: 18px !important;
}

#inventory .url-open-btn:active,
.recipe-table .url-open-btn:active,
body.force-mobile-mode:not(.force-pc-mode) #inventory .url-open-btn:active,
body.force-mobile-mode:not(.force-pc-mode) .recipe-table .url-open-btn:active {
    background: #cbd5e1 !important;
    transform: scale(0.92) !important;
}

@media screen and (min-width: 1025px) {
    body:not(.force-mobile-mode) #inventory .url-open-btn,
    body:not(.force-mobile-mode) .recipe-table .url-open-btn,
    body:not(.force-mobile-mode) .memo-wrapper .url-open-btn {
        display: none !important;
    }
}


/* ========================================================
   final_check 画面の表ごと個別横スクロール (スマホ横)
   ======================================================== */
.finalcheck-table-scroll,
#inventorySectionsContainer,
#recipeSectionsContainer .finalcheck-table-scroll {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch !important;
    box-sizing: border-box !important;
    margin-bottom: 20px !important;
    border: none !important;
    border-radius: 0 !important;
    background: transparent !important;
    scrollbar-width: thin !important;
    display: block !important;
}

#recipeSectionsContainer {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0 !important;
    box-sizing: border-box !important;
}

.finalcheck-table-scroll::-webkit-scrollbar,
#inventorySectionsContainer::-webkit-scrollbar {
    height: 7px !important;
}

.finalcheck-table-scroll::-webkit-scrollbar-thumb,
#inventorySectionsContainer::-webkit-scrollbar-thumb {
    background: #a7f3d0 !important;
    border-radius: 4px !important;
}

.finalcheck-table-scroll::-webkit-scrollbar-track,
#inventorySectionsContainer::-webkit-scrollbar-track {
    background: #f1f5f9 !important;
}

#inventorySectionsContainer table,
.finalcheck-table-scroll .inventory-table,
#purchaseListTable {
    min-width: 780px !important;
    width: max-content !important;
    border-collapse: collapse !important;
}

#recipeSectionsContainer table,
.finalcheck-table-scroll .recipe-summary-table {
    min-width: 580px !important;
    width: max-content !important;
    border-collapse: collapse !important;
}

#inventorySectionsContainer th,
#inventorySectionsContainer td,
#recipeSectionsContainer th,
#recipeSectionsContainer td,
#purchaseListTable th,
#purchaseListTable td {
    white-space: nowrap !important;
}

/* ==========================================================================
   スマホ横画面（Landscape）ではアイコンを通常表示に復元し、元のボタン幅・高さを維持
   ========================================================================== */
@media screen and (orientation: landscape) and (max-height: 600px) {
    .header-links .nav-icon {
        display: inline !important;
    }
    .header-links {
        width: auto !important;
        justify-content: flex-end !important;
    }
    .header-links a,
    .header-links .current-app {
        flex: 0 0 auto !important;
    }
}

@media screen and (orientation: landscape) {
    body.force-mobile-mode:not(.force-pc-mode) .header-links .nav-icon,
    html.force-mobile-mode:not(.force-pc-mode) .header-links .nav-icon {
        display: inline !important;
    }
    body.force-mobile-mode:not(.force-pc-mode) .header-links,
    html.force-mobile-mode:not(.force-pc-mode) .header-links {
        width: auto !important;
        justify-content: flex-end !important;
    }
    body.force-mobile-mode:not(.force-pc-mode) .header-links a,
    body.force-mobile-mode:not(.force-pc-mode) .header-links .current-app,
    html.force-mobile-mode:not(.force-pc-mode) .header-links a,
    html.force-mobile-mode:not(.force-pc-mode) .header-links .current-app {
        flex: 0 0 auto !important;
    }
}

/* ==========================================================================
   強制スマホモード時（PCデスクトップでのスマホプレビュー等）のテーブル非入力化 (Landscape)
   ========================================================================== */
body.force-mobile-mode:not(.force-pc-mode) #inventory tbody td input,
body.force-mobile-mode:not(.force-pc-mode) #inventory tbody td select,
body.force-mobile-mode:not(.force-pc-mode) #inventory tbody td textarea {
    border: none !important;
    background: transparent !important;
    box-shadow: none !important;
    outline: none !important;
    padding: 0 !important;
    margin: 0 !important;
    pointer-events: none !important;
    user-select: none !important;
    -webkit-appearance: none !important;
    -moz-appearance: none !important;
    appearance: none !important;
    color: inherit !important;
    font-size: 13.5px !important;
    font-family: inherit !important;
    line-height: 1.3 !important;
    box-sizing: border-box !important;
}

body.force-mobile-mode:not(.force-pc-mode) #inventory tbody td textarea {
    resize: none !important;
    overflow: hidden !important;
    white-space: pre-wrap !important;
    word-break: break-all !important;
}

body.force-mobile-mode:not(.force-pc-mode) #inventory tbody td input::-webkit-inner-spin-button,
body.force-mobile-mode:not(.force-pc-mode) #inventory tbody td input::-webkit-outer-spin-button,
body.force-mobile-mode:not(.force-pc-mode) #inventory tbody td input::-webkit-calendar-picker-indicator {
    display: none !important;
    -webkit-appearance: none !important;
}

    body.force-mobile-mode:not(.force-pc-mode) #inventory th:nth-child(10),
    body.force-mobile-mode:not(.force-pc-mode) #inventory td:nth-child(10),
body.force-mobile-mode:not(.force-pc-mode) #inventory th:last-child,
body.force-mobile-mode:not(.force-pc-mode) #inventory td:last-child,
body.force-mobile-mode:not(.force-pc-mode) #inventory .row-action-cell,
body.force-mobile-mode:not(.force-pc-mode) #inventory .row-action-trigger,
body.force-mobile-mode:not(.force-pc-mode) #inventory .row-action-menu,
body.force-mobile-mode:not(.force-pc-mode) .row-action-menu {
    display: none !important;
}

body.force-mobile-mode:not(.force-pc-mode) #inventory .recipe-number-stepper button,
body.force-mobile-mode:not(.force-pc-mode) #inventory .recipe-step-adjust-button {
    display: none !important;
}

body.force-mobile-mode:not(.force-pc-mode) #inventory th:nth-child(2),
body.force-mobile-mode:not(.force-pc-mode) #inventory td:nth-child(2),
body.force-mobile-mode:not(.force-pc-mode) #inventory th.recipe-name,
body.force-mobile-mode:not(.force-pc-mode) #inventory td.recipe-name {
    vertical-align: middle !important;
}

body.force-mobile-mode:not(.force-pc-mode) #inventory textarea.recipe2 {
    vertical-align: middle !important;
    display: block !important;
    margin: auto 0 !important;
    line-height: 1.35 !important;
}




/* スマホ横: 保存アクションブロック完全非表示 */
@media screen and (max-width: 900px) and (orientation: landscape), screen and (max-height: 520px) and (orientation: landscape) {
    body:not(.force-pc-mode) .save-action-group,
    body:not(.force-pc-mode) .save-action-group * {
        display: none !important;
    }
}
body.force-mobile-mode:not(.force-pc-mode) .save-action-group,
body.force-mobile-mode:not(.force-pc-mode) .save-action-group * {
    display: none !important;
}

/* スマホ横: ヘッダー統一 (zaiko基準 height:24px, font-size:10px) */
@media screen and (orientation: landscape) and (max-height: 600px),
       screen and (max-width: 900px) and (orientation: landscape) {
    #inventory thead th,
    #inventory th {
        height: 24px !important;
        max-height: 24px !important;
        box-sizing: border-box !important;
        font-size: 10px !important;
        line-height: 1.2 !important;
        text-align: center !important;
        vertical-align: middle !important;
        padding: 4px 2px !important;
        white-space: nowrap !important;
    }
}
body.force-mobile-mode:not(.force-pc-mode) #inventory thead th,
body.force-mobile-mode:not(.force-pc-mode) #inventory th {
    height: 24px !important;
    max-height: 24px !important;
    box-sizing: border-box !important;
    font-size: 10px !important;
    line-height: 1.2 !important;
    text-align: center !important;
    vertical-align: middle !important;
    padding: 4px 2px !important;
    white-space: nowrap !important;
}

/* ==========================================================================
   【スマホモード統一】タブエリア（タブナビゲーション＋タブパネル内）ボタン統一スタイル
   ※タブの外（アクションバー・ヘッダー・テーブル等）には干渉しないようタブ内に完全限定
   ========================================================================== */

/* 1. タブナビゲーションボタン（フォント11px・太さ600・システムフォント統一） */
body.force-mobile-mode:not(.force-pc-mode) .tab-navigation .tab-button,
body.force-mobile-mode:not(.force-pc-mode) .tab-navigation .tab-manual-btn,
body.force-mobile-mode:not(.force-pc-mode) .tab-button,
body.force-mobile-mode:not(.force-pc-mode) .tab-manual-btn {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", sans-serif !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    line-height: normal !important;
}

/* 2. タブパネル内の全ボタン（データ管理・追加・検索パネル内：高さ30px・フォント12px・太さ600統一） */
body.force-mobile-mode:not(.force-pc-mode) .tab-content-panel button,
body.force-mobile-mode:not(.force-pc-mode) .tab-content-panel .custom-button,
body.force-mobile-mode:not(.force-pc-mode) .tab-content-panel a.custom-button,
body.force-mobile-mode:not(.force-pc-mode) .tab-content-panel input[type="button"],
body.force-mobile-mode:not(.force-pc-mode) .tab-content-panel input[type="submit"],
body.force-mobile-mode:not(.force-pc-mode) .management-tab-content .custom-button,
body.force-mobile-mode:not(.force-pc-mode) .management-group .custom-button,
body.force-mobile-mode:not(.force-pc-mode) .management-group a,
body.force-mobile-mode:not(.force-pc-mode) .management-group button,
body.force-mobile-mode:not(.force-pc-mode) .management-group label,
body.force-mobile-mode:not(.force-pc-mode) .search-tab-content button,
body.force-mobile-mode:not(.force-pc-mode) .search-tab-content .custom-button,
body.force-mobile-mode:not(.force-pc-mode) .search-tab-content #searchButton,
body.force-mobile-mode:not(.force-pc-mode) .search-tab-content #outOfStockButton,
body.force-mobile-mode:not(.force-pc-mode) .search-tab-content #clearFilterButton,
body.force-mobile-mode:not(.force-pc-mode) #tab-panel-search button,
body.force-mobile-mode:not(.force-pc-mode) #tab-panel-search #searchButton,
body.force-mobile-mode:not(.force-pc-mode) #tab-panel-search #outOfStockButton,
body.force-mobile-mode:not(.force-pc-mode) #tab-panel-search #clearFilterButton,
body.force-mobile-mode:not(.force-pc-mode) #tab-panel-add button,
body.force-mobile-mode:not(.force-pc-mode) #tab-panel-manage button,
body.force-mobile-mode:not(.force-pc-mode) #tab-search button,
body.force-mobile-mode:not(.force-pc-mode) #tab-add button,
body.force-mobile-mode:not(.force-pc-mode) #tab-manage button,
body.force-mobile-mode:not(.force-pc-mode) .form-section button,
body.force-mobile-mode:not(.force-pc-mode) .add-form-row .custom-button,
body.force-mobile-mode:not(.force-pc-mode) #addButton,
body.force-mobile-mode:not(.force-pc-mode) #scanButton,
body.force-mobile-mode:not(.force-pc-mode) #addButton2,
body.force-mobile-mode:not(.force-pc-mode) #compressButton,
body.force-mobile-mode:not(.force-pc-mode) #addPriceSubmitBtn,
body.force-mobile-mode:not(.force-pc-mode) #addWalletSubmitBtn,
body.force-mobile-mode:not(.force-pc-mode) #submit-record-button,
body.force-mobile-mode:not(.force-pc-mode) #searchButton,
body.force-mobile-mode:not(.force-pc-mode) #searchButtonNew,
body.force-mobile-mode:not(.force-pc-mode) #tabSearchButton,
body.force-mobile-mode:not(.force-pc-mode) #search-button,
body.force-mobile-mode:not(.force-pc-mode) #clearFilterButton,
body.force-mobile-mode:not(.force-pc-mode) #clearFilterButtonNew,
body.force-mobile-mode:not(.force-pc-mode) #tabClearFilterButton,
body.force-mobile-mode:not(.force-pc-mode) #clear-filters-button,
body.force-mobile-mode:not(.force-pc-mode) #outOfStockButton,
body.force-mobile-mode:not(.force-pc-mode) #tabExpiringButton {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", sans-serif !important;
    height: 30px !important;
    min-height: 30px !important;
    line-height: 28px !important;
    font-size: 12px !important;
    font-weight: 600 !important;
    box-sizing: border-box !important;
}

/* レスポンシブ (max-width: 768px) 用ルール */
@media (max-width: 768px), (max-height: 500px) and (orientation: landscape) {
    body:not(.force-pc-mode) .tab-navigation .tab-button,
    body:not(.force-pc-mode) .tab-navigation .tab-manual-btn,
    body:not(.force-pc-mode) .tab-button,
    body:not(.force-pc-mode) .tab-manual-btn {
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", sans-serif !important;
        font-size: 11px !important;
        font-weight: 600 !important;
        line-height: normal !important;
    }

    body:not(.force-pc-mode) .tab-content-panel button,
    body:not(.force-pc-mode) .tab-content-panel .custom-button,
    body:not(.force-pc-mode) .tab-content-panel a.custom-button,
    body:not(.force-pc-mode) .tab-content-panel input[type="button"],
    body:not(.force-pc-mode) .tab-content-panel input[type="submit"],
    body:not(.force-pc-mode) .management-tab-content .custom-button,
    body:not(.force-pc-mode) .management-group .custom-button,
    body:not(.force-pc-mode) .management-group a,
    body:not(.force-pc-mode) .management-group button,
    body:not(.force-pc-mode) .management-group label,
    body:not(.force-pc-mode) .search-tab-content button,
    body:not(.force-pc-mode) .search-tab-content .custom-button,
    body:not(.force-pc-mode) .search-tab-content #searchButton,
    body:not(.force-pc-mode) .search-tab-content #outOfStockButton,
    body:not(.force-pc-mode) .search-tab-content #clearFilterButton,
    body:not(.force-pc-mode) #tab-panel-search button,
    body:not(.force-pc-mode) #tab-panel-search #searchButton,
    body:not(.force-pc-mode) #tab-panel-search #outOfStockButton,
    body:not(.force-pc-mode) #tab-panel-search #clearFilterButton,
    body:not(.force-pc-mode) #tab-panel-add button,
    body:not(.force-pc-mode) #tab-panel-manage button,
    body:not(.force-pc-mode) #tab-search button,
    body:not(.force-pc-mode) #tab-add button,
    body:not(.force-pc-mode) #tab-manage button,
    body:not(.force-pc-mode) .form-section button,
    body:not(.force-pc-mode) .add-form-row .custom-button,
    body:not(.force-pc-mode) #addButton,
    body:not(.force-pc-mode) #scanButton,
    body:not(.force-pc-mode) #addButton2,
    body:not(.force-pc-mode) #compressButton,
    body:not(.force-pc-mode) #addPriceSubmitBtn,
    body:not(.force-pc-mode) #addWalletSubmitBtn,
    body:not(.force-pc-mode) #submit-record-button,
    body:not(.force-pc-mode) #searchButton,
    body:not(.force-pc-mode) #searchButtonNew,
    body:not(.force-pc-mode) #tabSearchButton,
    body:not(.force-pc-mode) #search-button,
    body:not(.force-pc-mode) #clearFilterButton,
    body:not(.force-pc-mode) #clearFilterButtonNew,
    body:not(.force-pc-mode) #tabClearFilterButton,
    body:not(.force-pc-mode) #clear-filters-button,
    body:not(.force-pc-mode) #outOfStockButton,
    body:not(.force-pc-mode) #tabExpiringButton {
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans JP", sans-serif !important;
        height: 30px !important;
        min-height: 30px !important;
        line-height: 28px !important;
        font-size: 12px !important;
        font-weight: 600 !important;
        box-sizing: border-box !important;
    }
}

/* スマホモード（縦画面・横画面・強制スマホモード）: ソート実行ボタンを完全非表示 */
@media screen and (max-width: 1024px) {
    body:not(.force-pc-mode) #sortExecuteButton,
    body:not(.force-pc-mode) .sort-execute-button,
    body:not(.force-pc-mode) .action-group .sort-execute-button,
    body:not(.force-pc-mode) .sort-control-wrap .sort-execute-button {
        display: none !important;
    }
}
@media screen and (orientation: landscape) and (max-height: 600px) {
    body:not(.force-pc-mode) #sortExecuteButton,
    body:not(.force-pc-mode) .sort-execute-button,
    body:not(.force-pc-mode) .action-group .sort-execute-button,
    body:not(.force-pc-mode) .sort-control-wrap .sort-execute-button {
        display: none !important;
    }
}
body.force-mobile-mode:not(.force-pc-mode) #sortExecuteButton,
body.force-mobile-mode:not(.force-pc-mode) .sort-execute-button,
body.force-mobile-mode:not(.force-pc-mode) .action-group .sort-execute-button,
body.force-mobile-mode:not(.force-pc-mode) .sort-control-wrap .sort-execute-button {
    display: none !important;
}
