/* mobile.css: スマホ用の上書きCSS（専用）
 *
 * 方針:
 * - 既存のPC向けCSSはなるべく触らない
 * - このファイルで「幅が狭いときだけ」上書きしてレイアウト崩れを防ぐ
 * - できるだけタップしやすいサイズにする（16px以上・44px程度のタップ領域）
 */

@media (max-width: 768px) {
    /* ---- ベース ---- */
    body {
        background-attachment: scroll; /* モバイルは fixed が重いことがある */
    }

    header,
    footer {
        height: auto;
        padding: 8px 0;
        flex-direction: column;
        gap: 8px;
    }

    h1 {
        margin-left: 0 !important;
        font-size: 22px;
        letter-spacing: 0.04em;
        text-align: center;
    }

    h2 {
        font-size: 18px;
    }

    h3 {
        font-size: 16px;
    }

    /* iOSの入力ズーム回避（16px以上） */
    input,
    select,
    textarea,
    button {
        font-size: 16px;
    }

    /* 言語スイッチ（inline style の上書きが必要） */
    header form {
        width: auto !important;
        margin-left: 0 !important;
        gap: 8px !important;
        flex-wrap: wrap;
        justify-content: center;
    }

    .language-toggle {
        padding: 10px 14px;
        font-size: 14px;
    }

    /* ---- 全体レイアウト（3分割→縦積み） ---- */
    .main-panel {
        padding: 12px;
        overflow-y: auto; /* スマホは外側をスクロールさせる */
        -webkit-overflow-scrolling: touch;
    }

    .container {
        flex-direction: column;
        height: auto;
    }

    .section-a {
        width: 100%;
    }

    .section-a-top,
    .section-a-bottom {
        width: auto;
        margin: 0;
        padding: 8px;
    }

    /* メニューを横スクロールなしで常時見える形に */
    .section-a nav ul {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        overflow: visible;
        gap: 6px;
        padding: 6px;
    }

    .section-a nav ul li {
        flex: none;
        height: auto;
        min-width: 0;
    }

    .section-a nav ul li a {
        min-height: 40px;
        white-space: normal;
        overflow-wrap: anywhere;
        padding: 8px 6px;
        font-size: 13px;
        line-height: 1.2;
        border-radius: 0;
    }

    .section-b {
        margin-left: 0;
        margin-right: 0;
        overflow: visible;
    }

    .section-b.section-b-note {
        overflow-y: auto;
        overflow-x: hidden;
        justify-content: flex-start;
        padding: 0 12px 12px;
    }

    .section-b-top,
    .section-b-middle,
    .section-b-bottom {
        margin-left: 0;
        margin-right: 0;
    }

    .section-b-top {
        flex: 0 0 auto;
        overflow: visible;
    }

    .section-b-middle {
        flex-direction: column;
        gap: 8px;
    }

    .price-layout-middle {
        border: none;
        width: 100%;
        align-items: stretch;
    }

    .section-b-bottom {
        flex: 0 0 auto;
        border: none;
    }

    /* ---- Sample / Preset: カード ---- */
    .card-container,
    .preset-card-container {
        padding: 8px;
        gap: 10px;
        overflow: visible;
    }

    .card {
        width: 48%;
        min-width: 160px;
        max-width: none;
    }

    .preset-card {
        width: 48%;
        min-width: 160px;
    }

    .card-content,
    .preset-card-content {
        padding: 10px;
    }

    .card-content p,
    .preset-card-content p {
        margin-left: 0;
    }

    .card-content .kv-grid,
    .preset-card-content .kv-grid {
        margin-left: 0;
    }

    .card-actions,
    .preset-card-actions {
        gap: 8px;
    }

    .edit-button,
    .delete-button,
    .preset-edit-button,
    .toggle-public-button {
        width: auto;
        height: auto;
        padding: 10px 12px;
        min-height: 44px;
        font-size: 14px;
    }

    /* ---- フィルター ---- */
    .filter-drawer {
        margin-left: 0;
        margin-right: 0;
    }

    .samplefilter {
        height: auto;
        flex-wrap: wrap;
    }

    .samplefilter-group {
        flex-wrap: wrap;
        gap: 10px;
        padding: 8px;
    }

    .toggle-button-filter,
    .samplefilter-group-preset .toggle-button-filter-preset {
        width: 44px;
        height: 44px;
    }

    .samplefilter-group-middle {
        height: auto;
        flex-wrap: wrap;
        gap: 8px;
        padding: 8px 0;
    }

    .samplefilter-group-middle select {
        font-size: 16px;
        padding: 8px 10px;
    }

    #filterPose {
        min-width: 160px;
        padding-right: 36px;
    }

    #resetButton,
    #resetButtonPreset {
        padding: 10px 16px;
        font-size: 14px;
    }

    /* ---- Price ---- */
    .price-layout-top {
        padding: 14px 0 10px;
        gap: 10px;
    }

    .price-section-title {
        white-space: normal;
        padding-inline: 16px;
        text-align: center;
    }

    #commission-form,
    #commission-form-price {
        height: auto;
        display: flex;
        flex-wrap: wrap;
        gap: 10px;
        font-size: 14px;
        min-width: 0;
    }

    #commission-form .spinbox,
    #commission-form-price .price-formula-group,
    #commission-form-price .price-formula-cell {
        width: 110px;
        min-width: 110px;
    }

    #commission-form-price .price-formula-cell {
        padding-top: 0;
        box-sizing: border-box;
    }

    #commission-form-price .price-formula-operator {
        left: 14px;
        top: calc(
            (1em * var(--price-formula-line-height))
            + var(--price-formula-row-gap)
            + ((1em * var(--price-formula-line-height)) / 2)
        );
        width: 28px;
    }

    #commission-form .spinbox label,
    .commission-price-options .price-control label {
        font-size: 12px;
    }

    .commission-price-options {
        display: flex;
        width: 100%;
        min-width: 0;
        margin: 0;
        flex-direction: column;
        align-items: stretch;
        justify-content: stretch;
        gap: 10px;
    }

    .price-option-title {
        justify-content: center;
        padding-bottom: 0;
        padding-right: 0;
        text-align: center;
        min-height: 0;
    }

    .commission-price-options .price-control-title {
        width: 100%;
        align-items: center;
        min-height: 0;
        padding-top: 0;
    }

    .price-option-title-spacer {
        display: none;
    }

    .commission-price-options .price-control {
        width: min(220px, 100%);
        min-width: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .commission-price-options .price-control select {
        min-height: 0;
    }

    .price-layout-middle {
        justify-content: center;
    }

    .price-options-summary-row {
        flex-direction: column;
        align-items: center;
        gap: 12px;
        padding-right: 0;
    }

    #totalPriceContainer,
    #totalPriceYenContainer {
        margin-left: auto;
        margin-right: auto;
        justify-content: center;
        flex-wrap: wrap;
    }

    #uniqueCopyButtonContainer button {
        margin-left: 0;
        margin-right: 0;
    }

    .price-layout-bottom .custom-price-gallery {
        height: auto;
        flex-wrap: wrap;
        gap: 12px 10px;
        padding: 8px 0;
    }

    .custom-price-item {
        flex: 0 1 calc((100% - 10px) / 2);
        max-width: calc((100% - 10px) / 2);
    }

    .custom-price-thumb {
        width: min(100%, 156px);
    }

    /* ---- Progress ---- */
    .progress-main-card {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* ---- 管理パネル（横スライドのドロワー化） ---- */
    #toggle-panel {
        position: fixed;
        top: 12px;
        right: 12px;
        transform: none;
        z-index: 1200;
        background: rgba(0, 0, 0, 0.35);
        border-radius: 999px;
        padding: 6px;
    }

    #toggle-panel img {
        width: 28px;
        height: auto;
    }

    #control-panel {
        position: fixed;
        inset: 0;
        width: 100% !important;
        min-width: 100% !important;
        transform: translateX(100%);
        transition: transform 0.3s ease;
        z-index: 1100;
        background-color: rgba(11, 0, 0, 0.95);
        padding: 16px;
    }

    #control-panel.active {
        transform: translateX(0);
    }

    .button-container {
        flex-wrap: wrap;
        gap: 8px;
    }

    .toggle-button {
        font-size: 14px;
        padding: 10px;
        min-height: 44px;
    }

    #form-content.room-workspace-active {
        position: fixed;
        inset: 72px 10px 10px;
        width: auto;
        max-height: none;
        padding-right: 0;
    }

    .room-tool-view {
        padding: 14px;
        border-radius: 16px;
    }

    .room-tool-title {
        font-size: 24px;
    }

    .room-section-board,
    .room-form-grid-auto {
        grid-template-columns: 1fr;
    }

    .form-group {
        flex-direction: column;
        align-items: stretch;
        padding: 8px 0;
    }

    .form-group label {
        text-align: left;
        margin: 0 0 6px 0;
        font-size: 14px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100%;
    }

    /* 更新モーダル（Sample/Preset） */
    #control-panel.active #login-form {
        min-height: auto;
    }

    #login-form {
        padding-bottom: 10px;
    }

    .user-info {
        position: static;
        margin-top: 12px;
        align-items: flex-end;
    }

    .room-slot-list .slot-item,
    .room-slot-list .slot-details {
        grid-template-columns: 1fr;
    }

    .room-slot-list .slot-item {
        padding: 12px;
    }

    .room-slot-list .slot-add-card {
        min-height: 72px;
    }

    .room-progress-shell .progress-slot-form > div:first-of-type {
        flex-direction: column;
        align-items: flex-start !important;
    }

    .room-progress-shell .progress-slot-form > div:first-of-type > div {
        width: 100%;
        justify-content: flex-start !important;
    }

    .room-progress-shell .progress-items {
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
    }

    .modal-sample-update,
    .modal-preset-update {
        align-items: stretch;
        padding: 14px 10px;
    }

    .modal-sample-update-content,
    .modal-preset-update-content {
        width: 100%;
        max-height: calc(100vh - 28px);
        border-radius: 16px;
        padding-right: 8px;
    }

    .modal-sample-update-content form,
    .modal-preset-update-content form {
        padding: 56px 10px 18px 16px;
    }

    .modal-sample-form {
        gap: 12px;
    }

    .modal-form-section {
        padding: 12px;
        border-radius: 12px;
    }

    .modal-form-row,
    .modal-form-row--notes,
    .modal-form-grid--files,
    .modal-form-grid--pricing,
    .modal-form-grid--commerce,
    .modal-form-grid--ownership,
    .modal-form-grid--notes,
    .modal-form-grid--meta {
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .modal-sample-update .close,
    .modal-preset-update-content .close {
        top: 10px;
        right: 10px;
        width: 34px;
        height: 34px;
        font-size: 24px;
    }

    /* トースト */
    .toast {
        min-width: min(92vw, 420px);
        padding: 12px;
        font-size: 14px;
    }

    /* ---- Layout-specific overrides ---- */
    html,
    body {
        overflow-x: hidden;
    }

    body {
        min-height: 100dvh;
    }

    .main-panel {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        left: auto;
        margin: 10px;
        min-height: calc(100dvh - 20px);
        height: auto;
        display: flex;
        flex-direction: column;
        gap: 12px;
        overflow: visible;
    }

    .container {
        flex: 1 1 auto;
        min-height: 0;
        gap: 12px;
    }

    .section-a,
    .section-b {
        width: 100% !important;
        min-width: 0 !important;
    }

    .section-a {
        gap: 12px;
        align-items: stretch;
        position: sticky;
        top: 0;
        z-index: 900;
        background-color: rgba(11, 0, 0, 0.94);
        border-radius: 0;
    }

    .section-a nav,
    .section-a-top,
    .section-a-bottom,
    #pose-selection {
        width: 100%;
        box-sizing: border-box;
    }

    .section-a nav ul {
        scrollbar-width: none;
    }

    .section-a nav ul::-webkit-scrollbar {
        display: none;
    }

    .profile-square {
        width: min(220px, 72vw);
        height: min(220px, 72vw);
    }

    #content-about,
    #content-process,
    #content-sample,
    #content-price,
    #content-presetPose,
    #content-progress,
    #content-questions {
        width: 100%;
        box-sizing: border-box;
    }

    .content-about {
        margin: 0;
        padding: 14px 12px;
    }

    #content-about h2 {
        font-size: 20px;
    }

    #content-about h3 {
        font-size: 16px;
    }

    #content-about p,
    .content-about li,
    .content-about-bottom li {
        font-size: 14px;
    }

    .content-about-bottom,
    .often-dual-box,
    .about-single-box {
        flex-direction: column;
        gap: 12px;
    }

    .content-about-often,
    .content-about-likes,
    .content-about-notgood {
        margin: 0;
        padding: 12px;
    }

    .description {
        width: min(92vw, 320px);
    }

    #process-main-container {
        flex-direction: column;
        height: auto;
        overflow: visible;
        gap: 8px;
        padding: 8px 10px 0;
        box-sizing: border-box;
    }

    .step {
        width: 100%;
        min-width: 0;
        margin: 0;
        padding: 12px;
        box-sizing: border-box;
        border-radius: 10px;
    }

    .step h3 {
        margin-bottom: 10px;
    }

    .arrow {
        width: 100%;
        justify-content: center;
        margin: 2px 0;
    }

    .arrow img {
        width: 18px;
        transform: rotate(90deg);
    }

    .card-container,
    .preset-card-container {
        justify-content: space-between;
        align-items: stretch;
    }

    .card,
    .preset-card {
        width: calc(50% - 6px);
        min-width: 0;
        max-width: none;
        max-height: none;
        height: auto;
    }

    .card img,
    .preset-card img,
    .preset-popup-image {
        width: 100%;
        height: auto;
        max-height: none;
        aspect-ratio: 1 / 1;
        object-fit: contain;
    }

    .sample-card-identifier p,
    .preset-card-identifier p {
        font-size: 12px;
        line-height: 1.4;
    }

    .card-content,
    .preset-card-content {
        gap: 8px;
    }

    .card-content .kv-grid,
    .preset-card-content .kv-grid {
        font-size: 13px;
        row-gap: 4px;
    }

    .card-content a {
        font-size: 13px;
    }

    .card-actions,
    .preset-card-actions {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(96px, 1fr));
        width: 100%;
    }

    .edit-button,
    .delete-button,
    .preset-edit-button,
    .toggle-public-button {
        width: 100%;
    }

    .filter-content {
        padding: 10px;
    }

    .samplefilter,
    .samplefilter-group-preset,
    .samplefilter-group-pose {
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .samplefilter-group {
        width: 100%;
    }

    .samplefilter-group-middle {
        width: 100%;
        flex-direction: column;
        align-items: stretch;
    }

    .samplefilter-group-middle label {
        width: 100%;
        text-align: left;
    }

    .samplefilter-group-middle select,
    #sortOrder,
    #filterPose {
        width: 100%;
        min-width: 0;
    }

    .samplefilter-bottom {
        width: 100%;
        padding-top: 6px;
    }

    #resetButton,
    #resetButtonPreset {
        width: 100%;
        max-width: none;
    }

    .price-layout-top,
    .price-layout-middle,
    .price-layout-bottom {
        width: 100%;
    }

    #commission-form,
    #commission-form-price {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 10px 8px;
        justify-content: stretch;
    }

    #commission-form .price-control-group-characters,
    #commission-form .price-control,
    #commission-form .spinbox,
    #commission-form-price .price-formula-group,
    #commission-form-price .price-formula-cell,
    .commission-price-options .price-control {
        width: 100% !important;
        min-width: 0 !important;
    }

    .commission-price-options {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
        margin: 0;
        gap: 10px;
        justify-content: stretch;
    }

    .commission-price-options .price-control-title {
        grid-column: 1 / -1;
    }

    .price-layout-middle {
        padding: 12px 10px;
    }

    .price-options-summary-row {
        width: 100%;
    }

    #totalPriceContainer label,
    #totalPriceYenContainer label {
        margin-left: 0;
    }

    #uniqueCopyButtonContainer {
        width: 100%;
        display: flex;
        justify-content: center;
    }

    #uniqueCopyButtonContainer button {
        width: min(280px, 100%);
    }

    #progress-main-container {
        height: auto;
        align-items: stretch;
        gap: 12px;
    }

    .progress-list {
        width: 100%;
        padding: 0;
        overflow: visible;
    }

    .progress-row {
        margin: 0;
        padding: 12px 10px;
    }

    .progress-slot-form > div:first-of-type {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }

    .progress-slot-form > div:first-of-type > div {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        justify-content: flex-start !important;
        gap: 8px;
    }

    .progress-items {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px 8px;
        width: 100%;
    }

    .progress-update-item {
        width: auto;
        min-width: 0;
        margin: 0;
    }

    .progress-update {
        width: 100%;
        gap: 6px;
    }

    .progress-row p {
        font-size: 12px;
    }

    .progress-row h3 {
        font-size: 15px;
    }

    .progress-row button {
        min-height: 36px;
        padding: 8px 10px;
        font-size: 12px;
    }

    .reorder-btn-up,
    .reorder-btn-down,
    .progress-btn-minus,
    .progress-btn-plus,
    .progress-btn-max {
        min-width: 36px;
    }

    progress {
        height: 6px;
    }

    #control-panel.active {
        overflow-y: auto;
    }

    .button-container {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        width: 100%;
    }

    .toggle-button {
        width: 100%;
        margin: 0;
    }

    .user-info {
        width: 100%;
        text-align: center;
        align-items: center;
    }

    .note-board-toolbar {
        flex-direction: column;
        gap: 8px;
    }

    .note-column {
        flex-basis: min(84vw, 320px);
    }
}

@media (max-width: 420px) {
    /* さらに小さい端末は1列表示 */
    .card,
    .preset-card {
        width: 100%;
        min-width: 0;
    }

    #commission-form,
    #commission-form-price,
    .commission-price-options,
    .progress-items,
    .button-container {
        grid-template-columns: 1fr !important;
    }
}

@media (max-width: 600px) {
    /* ---- Price (bottom gallery) ---- */
    .custom-price-gallery {
        height: auto;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        column-gap: 8px;
        row-gap: 12px;
        padding: 8px 0;
    }

    .custom-price-item {
        flex: 0 0 calc((100% - 8px) / 2);
        max-width: calc((100% - 8px) / 2);
    }

    .custom-price-item span {
        line-height: 1.2;
    }

    .custom-price-thumb {
        width: 100%;
        max-width: 100%;
    }

    /* コンテナクエリ非対応ブラウザ向けのフォールバック */
    @supports not (container-type: inline-size) {
        .custom-price-item span {
            font-size: 12px;
        }
    }
}

@media (max-width: 960px) and (max-height: 520px) and (orientation: landscape) {
    html,
    body {
        overflow-x: hidden;
    }

    .main-panel {
        position: relative;
        top: auto;
        right: auto;
        bottom: auto;
        left: auto;
        margin: 10px;
        min-height: calc(100dvh - 20px);
        height: auto;
        display: flex;
        flex-direction: column;
        gap: 12px;
        overflow: visible;
    }

    .container {
        flex-direction: column;
        height: auto;
        gap: 12px;
    }

    .section-a,
    .section-b {
        width: 100% !important;
        min-width: 0 !important;
    }

    .section-a {
        gap: 12px;
        align-items: stretch;
        position: sticky;
        top: 0;
        z-index: 900;
        background-color: rgba(11, 0, 0, 0.94);
        border-radius: 0;
    }

    .section-a nav,
    .section-a-top,
    .section-a-bottom,
    #pose-selection {
        width: 100%;
        box-sizing: border-box;
    }

    .section-a nav ul {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        overflow: visible;
        gap: 6px;
        padding: 6px;
    }

    .section-a nav ul li {
        flex: none;
        height: auto;
        min-width: 0;
    }

    .section-a nav ul li a {
        min-height: 40px;
        white-space: normal;
        overflow-wrap: anywhere;
        padding: 8px 6px;
        font-size: 13px;
        line-height: 1.2;
        border-radius: 0;
    }
}

@media (max-width: 768px), (max-width: 960px) and (max-height: 520px) and (orientation: landscape) {
    #content-price {
        overflow-x: hidden;
    }

    .price-layout-top,
    .price-layout-middle,
    .price-layout-bottom {
        width: 100%;
        box-sizing: border-box;
    }

    .price-layout-top {
        gap: 14px;
        padding: 14px 10px;
        overflow: visible;
    }

    .price-section-title {
        white-space: normal;
        padding-inline: 4px;
        text-align: center;
        font-size: 18px;
        line-height: 1.25;
    }

    #commission-form,
    #commission-form-price,
    .commission-price-options {
        width: 100%;
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr));
        gap: 10px;
        justify-content: stretch;
        align-items: stretch;
        font-size: 14px;
    }

    #commission-form .price-control--grid {
        grid-column: auto !important;
        grid-row: auto !important;
    }

    #commission-form .price-control-group-characters,
    #commission-form .price-control,
    #commission-form .spinbox,
    .commission-price-options .price-control {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }

    #commission-form .price-control,
    .commission-price-options .price-control {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
        padding: 10px;
        border: 1px solid rgba(255, 153, 95, 0.28);
        background: rgba(0, 0, 0, 0.16);
        box-sizing: border-box;
    }

    #commission-form .price-control label,
    .commission-price-options .price-control label {
        min-height: 0;
        margin: 0;
        font-size: 13px;
        line-height: 1.25;
        white-space: normal;
        overflow-wrap: anywhere;
        text-align: left;
    }

    #commission-form .price-control select,
    .commission-price-options .price-control select {
        width: 100%;
        min-height: 40px;
        font-size: 16px;
        line-height: 1.35;
        box-sizing: border-box;
    }

    #commission-form-price {
        display: none;
    }

    .mobile-price-factor {
        display: grid;
        grid-template-columns: auto auto 1fr auto;
        align-items: center;
        gap: 6px;
        min-height: 34px;
        padding: 6px 8px;
        border: 1px solid rgba(255, 153, 95, 0.34);
        background: rgba(255, 153, 95, 0.08);
        color: #ffd9bf;
        font-size: 13px;
        line-height: 1.25;
        box-sizing: border-box;
    }

    .mobile-price-factor[hidden] {
        display: none;
    }

    .mobile-price-factor.is-neutral {
        color: rgba(255, 217, 191, 0.68);
        border-color: rgba(255, 153, 95, 0.18);
        background: rgba(255, 153, 95, 0.04);
    }

    .mobile-price-factor-label {
        grid-column: 1;
        color: rgba(240, 240, 240, 0.74);
        font-weight: bold;
    }

    .mobile-price-factor-operator,
    .mobile-price-factor-suffix {
        white-space: nowrap;
    }

    .mobile-price-factor-operator {
        grid-column: 2;
    }

    .mobile-price-factor-value {
        grid-column: 3;
        min-width: 0;
        overflow-wrap: anywhere;
        text-align: right;
        font-weight: bold;
    }

    .mobile-price-factor-suffix {
        grid-column: 4;
    }

    .commission-price-options .price-control-title {
        grid-column: 1 / -1;
        width: 100%;
        min-height: 42px;
        padding: 8px 10px;
        align-items: stretch;
        justify-content: center;
    }

    .price-option-title {
        display: flex;
        align-items: center;
        justify-content: flex-start;
        min-height: 100%;
        padding: 0;
        font-size: 14px;
        line-height: 1.25;
        text-align: left;
        white-space: normal;
    }

    #commission-form-price {
        grid-template-columns: repeat(auto-fit, minmax(min(100%, 112px), 1fr));
        font-size: 13px;
    }

    #commission-form-price .price-formula-group,
    #commission-form-price .price-formula-cell {
        width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
        border: 1px solid rgba(255, 153, 95, 0.28);
        background: rgba(0, 0, 0, 0.18);
    }

    #commission-form-price .price-formula-group {
        padding: 8px;
        white-space: normal;
        gap: 4px;
    }

    #commission-form-price .price-formula-cell {
        min-height: 38px;
        align-items: center;
        justify-content: center;
        padding: 8px 8px 8px 24px;
        white-space: normal;
    }

    #commission-form-price .price-formula-operator {
        left: 10px;
        top: 50%;
        width: auto;
        transform: translateY(-50%);
        font-size: 13px;
    }

    #commission-form-price .price-formula-value,
    #commission-form-price .price-formula-suffix {
        font-size: 13px;
        line-height: 1.25;
        white-space: normal;
        overflow-wrap: anywhere;
    }

    .price-layout-middle {
        padding: 12px 10px;
        justify-content: center;
    }

    .price-options-summary-row {
        width: 100%;
        flex-direction: column;
        align-items: center;
        gap: 12px;
        padding-right: 0;
    }

    #totalPriceContainer,
    #totalPriceYenContainer {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto auto;
        align-items: baseline;
        width: 100%;
        max-width: 360px;
        margin-left: auto;
        margin-right: auto;
        justify-content: stretch;
        gap: 8px;
        font-size: 16px;
        line-height: 1.25;
    }

    #totalPriceContainer label,
    #totalPriceYenContainer label {
        min-width: 0;
        margin-left: 0;
        color: #f0f0f0;
        font-size: 16px;
        line-height: 1.25;
        overflow-wrap: anywhere;
        white-space: normal;
    }

    #totalPriceInteger,
    #totalPriceYenInteger {
        margin-left: 0;
        font-size: 22px;
        line-height: 1;
    }

    #totalPriceDecimal,
    #totalPriceYenDecimal {
        align-self: start;
        padding-top: 2px;
        font-size: 13px;
        line-height: 1;
    }

    #uniqueCopyButtonContainer {
        grid-column: 1 / -1;
        width: 100%;
        display: flex;
        justify-content: center;
    }

    #uniqueCopyButtonContainer button {
        width: min(280px, 100%);
        min-height: 40px;
        margin-left: 0;
        margin-right: 0;
        font-size: 14px;
    }
}

@media (max-width: 420px) {
    #commission-form,
    #commission-form-price,
    .commission-price-options {
        grid-template-columns: 1fr !important;
    }
}
