*{
    box-sizing:border-box;
}

html,
body{
    margin:0;
    min-height:100%;
    font-family:system-ui,-apple-system,BlinkMacSystemFont,"Yu Gothic",sans-serif;
    background:#eef1f5;
    color:#20242a;
}

button,
input{
    font:inherit;
}

button{
    border:0;
    border-radius:9px;
    padding:11px 15px;
    cursor:pointer;
    background:#16181c;
    color:#fff;
    font-weight:700;
}

button:disabled{
    opacity:.4;
    cursor:not-allowed;
}

.secondary{
    background:#eef0f3;
    color:#262a30;
    border:1px solid #d9dde3;
}

.primary{
    background:#111827;
}

.danger{
    background:#b42318;
}

.danger-ghost{
    background:#fff4f2;
    color:#b42318;
    border:1px solid #f3b5ad;
}

.danger-text{
    color:#b42318;
}

.app{
    min-height:100vh;
}


/* =========================================================
   HEADER
========================================================= */

.topbar{
    height:68px;
    background:#fff;
    border-bottom:1px solid #dfe3e8;
    display:flex;
    align-items:center;
    justify-content:space-between;
    padding:0 22px;
    position:relative;
    z-index:20;
}

.brand-block{
    display:flex;
    align-items:center;
    gap:14px;
}

.brand-block strong{
    font-size:20px;
}

.design-id{
    font-size:14px;
    color:#68707b;
    background:#f2f4f7;
    padding:5px 8px;
    border-radius:6px;
}

.top-actions{
    display:flex;
    align-items:center;
    gap:8px;
}

.history-actions{
    display:flex;
    align-items:center;
    gap:8px;
}


/* =========================================================
   WORKSPACE
========================================================= */

.workspace{
    display:grid;
    grid-template-columns:285px minmax(520px,1fr) 330px;
    height:calc(100vh - 68px);
    min-height:650px;
}

.sidebar{
    background:#fff;
    padding:22px;
    border-color:#dfe3e8;
    overflow:auto;
}

.left-sidebar{
    border-right:1px solid #dfe3e8;
    display:flex;
    flex-direction:column;
    padding-bottom:16px;
}

.left-content{
    flex:1;
}

.right-sidebar{
    border-left:1px solid #dfe3e8;
}


/* =========================================================
   PANELS
========================================================= */

.panel-section{
    padding-bottom:22px;
    margin-bottom:22px;
    border-bottom:1px solid #edf0f3;
}

.panel-section:last-child{
    border-bottom:0;
}

.panel-section h2{
    font-size:19px;
    margin:0 0 14px;
}

.section-heading{
    display:flex;
    align-items:center;
    justify-content:space-between;
}

.badge{
    font-size:13px;
    background:#edf2ff;
    color:#3157a4;
    padding:4px 7px;
    border-radius:99px;
}

.upload-button{
    display:block;
    text-align:center;
    background:#111827;
    color:#fff;
    padding:13px;
    border-radius:9px;
    font-weight:700;
    cursor:pointer;
    font-size:16px;
}

.visually-hidden{
    position:absolute!important;
    width:1px;
    height:1px;
    overflow:hidden;
    clip:rect(0,0,0,0);
}

.help,
.format-note{
    font-size:14px;
    line-height:1.65;
    color:#6b7280;
}

.format-note{
    background:#f8fafc;
    border:1px solid #e5e7eb;
    padding:8px 10px;
    border-radius:8px;
}

.button-grid{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:8px;
}

.button-grid button:last-child{
    grid-column:1/-1;
}


/* =========================================================
   PRODUCT INFO
========================================================= */

.product-info dl{
    margin:0;
}

.product-info dl div{
    display:flex;
    justify-content:space-between;
    gap:10px;
    padding:7px 0;
    font-size:14px;
}

.product-info dt{
    color:#737b86;
}

.product-info dd{
    margin:0;
    font-weight:700;
    text-align:right;
}

.status{
    padding:11px;
    background:#f4f6f8;
    border-radius:8px;
    font-size:14px;
    line-height:1.5;
}

.reset-zone{
    position:sticky;
    bottom:0;
    background:#fff;
    padding-top:12px;
    border-top:1px solid #edf0f3;
}

.reset-all{
    width:100%;
    padding:12px;
}


/* =========================================================
   STAGE
========================================================= */

.stage-column{
    min-width:0;
    display:flex;
    flex-direction:column;
    overflow:hidden;
}

.stage-toolbar{
    height:48px;
    display:flex;
    align-items:center;
    padding:0 18px;
    background:#f8f9fb;
    border-bottom:1px solid #dfe3e8;
}

.guide-legend{
    display:flex;
    gap:16px;
    font-size:14px;
    color:#606874;
}

.guide-legend span{
    display:flex;
    align-items:center;
    gap:6px;
}

.guide-legend i{
    width:18px;
    height:0;
    border-top:2px solid #59616d;
}

.guide-legend .legend-bleed{
    border-color:#dc2626;
}

.guide-legend .legend-finish{
    border-color:#374151;
}

.guide-legend .legend-safe{
    border-top-style:dotted;
    border-color:#2563eb;
}


/* =========================================================
   CANVAS
========================================================= */

.canvas-viewport{
    position:relative;
    flex:1;
    overflow:auto;
    background:#f1f3f5;
    display:flex;
    align-items:center;
    justify-content:center;
    min-height:0;
}

.canvas-shell{
    flex:0 0 auto;
    transform-origin:center center;
    transition:transform .08s linear;
    filter:drop-shadow(0 12px 38px rgba(20,25,35,.16));
}

.canvas-shell canvas{
    display:block;
    touch-action:none;
}

.stage-note{
    font-size:13px;
    color:#69717d;
    background:#f8f9fb;
    border-top:1px solid #dfe3e8;
    padding:8px 16px;
    text-align:center;
}


/* =========================================================
   ZOOM
========================================================= */

.floating-zoom{
    position:absolute;
    right:18px;
    bottom:18px;
    z-index:8;
    display:flex;
    align-items:center;
    gap:5px;
    padding:6px;
    background:rgba(255,255,255,.95);
    border:1px solid #d8dde4;
    border-radius:11px;
    box-shadow:0 4px 16px rgba(0,0,0,.12);
}

.mini-btn{
    width:38px;
    height:36px;
    padding:0;
    font-size:20px;
}

.zoom-label{
    min-width:66px;
    height:36px;
    padding:0 10px;
    position:relative;
}

.zoom-picker{
    position:relative;
}

.zoom-menu{
    position:absolute;
    left:50%;
    bottom:46px;
    transform:translateX(-50%);
    min-width:82px;
    padding:6px;
    background:#fff;
    border:1px solid #d8dde4;
    border-radius:10px;
    box-shadow:0 8px 24px rgba(0,0,0,.16);
    z-index:12;
}

.zoom-menu[hidden]{
    display:none;
}

.zoom-menu button{
    display:block;
    width:100%;
    padding:8px 10px;
    border-radius:7px;
    background:#fff;
    color:#252a31;
    text-align:center;
    font-weight:700;
    font-size:15px;
}

.zoom-menu button:hover,
.zoom-menu button.is-active{
    background:#eef2f7;
    color:#1d4ed8;
}

.mobile-zoom-option{
    display:none!important;
}


/* =========================================================
   DROP
========================================================= */

.drop-overlay{
    position:absolute;
    inset:18px;
    z-index:7;
    border:3px dashed #2563eb;
    background:rgba(239,246,255,.88);
    border-radius:18px;
    align-items:center;
    justify-content:center;
    pointer-events:none;
}

.drop-overlay:not([hidden]){
    display:flex;
}

.drop-overlay div{
    text-align:center;
    color:#1d4ed8;
}

.drop-overlay strong{
    display:block;
    font-size:22px;
}

.drop-overlay span{
    display:block;
    margin-top:6px;
    font-size:13px;
}


/* =========================================================
   OBJECT SETTINGS
========================================================= */

.object-panel{
    border-bottom:0;
}

.object-panel h2{
    font-size:21px;
}

.empty-panel{
    padding:18px;
    background:#f6f7f9;
    border-radius:10px;
    color:#727985;
    font-size:15px;
}

.object-controls.is-disabled{
    display:none;
}

.setting-title{
    font-size:15px;
    font-weight:800;
    margin:6px 0 9px;
}

.field-row{
    display:grid;
    gap:10px;
    margin-bottom:18px;
}

.two-col{
    grid-template-columns:1fr 1fr;
}

.field-row label,
.large-number{
    font-size:15px;
    font-weight:700;
    color:#4d5560;
}

.field-row input,
.large-number input{
    width:100%;
    height:46px;
    margin-top:7px;
    border:1px solid #cfd5dd;
    border-radius:9px;
    padding:0 12px;
    background:#fff;
    font-size:18px;
}

.control-label{
    display:block;
    margin:20px 0;
}

.control-label>span{
    display:flex;
    justify-content:space-between;
    font-size:16px;
    font-weight:800;
    margin-bottom:10px;
}

.control-label output{
    font-size:18px;
    color:#1d4ed8;
}

.control-label input[type=range]{
    width:100%;
    height:24px;
}

.large-number{
    display:block;
    margin:-7px 0 22px;
}

.large-number input{
    font-size:20px;
    font-weight:700;
}


/* =========================================================
   TEXT SIZE
========================================================= */

.text-size-setting{
    margin-bottom:12px;
    padding-bottom:12px;
    border-bottom:1px solid #edf0f3;
}

.text-size-title{
    display:block;
    margin-bottom:8px;
    font-size:14px;
    font-weight:800;
    color:#606874;
}

.text-size-options{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:7px;
}

.text-size-btn{
    padding:10px 8px;
    font-size:15px;
}

.text-size-btn.is-active{
    background:#111827;
    color:#fff;
    border-color:#111827;
}


/* =========================================================
   LARGE TEXT
========================================================= */

body.ui-text-large{
    font-size:21px;
}

body.ui-text-large .panel-section h2{
    font-size:22px;
}

body.ui-text-large .help,
body.ui-text-large .format-note{
    font-size:16px;
}

body.ui-text-large .product-info dl div{
    font-size:16px;
}

body.ui-text-large .status{
    font-size:16px;
}

body.ui-text-large button,
body.ui-text-large .upload-button{
    font-size:18px;
}


/* =========================================================
   PRODUCT PICKER
========================================================= */

.product-picker{
    position:relative;
}

.product-picker-btn{
    display:flex;
    align-items:center;
    gap:9px;
    min-width:138px;
    justify-content:space-between;
    padding:7px 10px;
    font-size:13px;
}

.product-picker-caret{
    font-size:11px;
    color:#69717d;
}

.product-picker-menu{
    position:absolute;
    top:calc(100% + 8px);
    left:0;
    width:250px;
    padding:7px;
    background:#fff;
    border:1px solid #d8dde4;
    border-radius:11px;
    box-shadow:0 10px 30px rgba(0,0,0,.16);
    z-index:40;
}

.product-picker-menu[hidden]{
    display:none;
}

.product-picker-menu button{
    display:flex;
    width:100%;
    align-items:center;
    justify-content:space-between;
    gap:12px;
    padding:10px 11px;
    border-radius:8px;
    background:#fff;
    color:#252a31;
    text-align:left;
    font-size:13px;
}

.product-picker-menu button:hover,
.product-picker-menu button.is-active{
    background:#eef2f7;
    color:#1d4ed8;
}

.product-picker-menu small{
    font-size:11px;
    color:#7a828e;
    font-weight:600;
    white-space:nowrap;
}


/* =========================================================
   MODAL
========================================================= */

.modal-backdrop{
    position:fixed;
    inset:0;
    background:rgba(17,24,39,.5);
    z-index:100;
    display:flex;
    align-items:center;
    justify-content:center;
    padding:20px;
}

.modal-backdrop[hidden]{
    display:none;
}

.modal{
    width:min(480px,100%);
    background:#fff;
    border-radius:16px;
    padding:26px;
    box-shadow:0 24px 70px rgba(0,0,0,.25);
}

.modal h2{
    margin:0 0 12px;
    font-size:20px;
}

.modal p{
    color:#5f6670;
    line-height:1.7;
}

.modal-actions{
    display:flex;
    justify-content:flex-end;
    gap:9px;
    margin-top:22px;
}


/* =========================================================
   MOBILE SLOT
========================================================= */

.mobile-only-slot{
    display:none;
}


/* =========================================================
   TABLET
========================================================= */

@media(max-width:1050px) and (min-width:851px){

    .workspace{
        grid-template-columns:245px minmax(480px,1fr) 285px;
    }

    .sidebar{
        padding:16px;
    }

}


/* =========================================================
   SMARTPHONE
========================================================= */

@media(max-width:850px){

    html,
    body{
        width:100%;
        max-width:100%;
        overflow-x:hidden;
    }

    body{
        background:#eef1f5;
    }

    .app{
        width:100%;
        max-width:100%;
        overflow-x:hidden;
    }


    /* ---------- Header ---------- */

    .topbar{
        width:100%;
        height:auto;
        min-height:56px;
        padding:12px;
        display:block;
    }

    .brand-block{
        width:100%;
    }

    .brand-block strong{
        font-size:16px;
    }

    .design-id,
    .product-picker{
        display:none;
    }

    .top-actions{
        display:none;
    }


    /* ---------- Mobile slots ---------- */

    .mobile-only-slot{
        display:block;
        width:100%;
    }


    /* ---------- Upload ---------- */

    .mobile-upload-slot{
        background:#fff;
        padding:10px 12px;
        border-bottom:1px solid #dfe3e8;
    }

    .mobile-upload-slot #imagePanel{
        margin:0;
        padding:0;
        border:0;
    }

    .mobile-upload-slot #imagePanel .section-heading,
    .mobile-upload-slot #imagePanel .help,
    .mobile-upload-slot #imagePanel .format-note{
        display:none;
    }

    .mobile-upload-slot .upload-button{
        width:100%;
        padding:14px;
    }


    /* ---------- Main order ---------- */

    .workspace{
        display:flex;
        flex-direction:column;
        width:100%;
        height:auto;
        min-height:0;
    }

    .stage-column{
        order:1;
        width:100%;
        height:auto;
        min-height:0;
        overflow:visible;
    }

    .right-sidebar{
        order:2;
        width:100%;
        padding:16px;
        overflow:visible;
        border:0;
        border-top:1px solid #dfe3e8;
    }

    .left-sidebar{
        order:3;
        width:100%;
        padding:16px;
        overflow:visible;
        border:0;
        border-top:1px solid #dfe3e8;
    }


    /* ---------- Guide ---------- */

    .stage-toolbar{
        width:100%;
        height:auto;
        min-height:38px;
        padding:7px 10px;
        overflow-x:auto;
        overflow-y:hidden;
    }

    .guide-legend{
        width:max-content;
        min-width:max-content;
        gap:12px;
        font-size:11px;
        white-space:nowrap;
    }

    .guide-legend span{
        flex:none;
    }


    /* ---------- Canvas ---------- */

    .canvas-viewport{
        position:relative;
        display:flex;
        align-items:center;
        justify-content:center;

        width:100%;
        height:320px;
        min-height:320px;
        max-height:320px;

        flex:none;

        overflow:hidden;
    }

    .canvas-shell{
        flex:none;
        transform-origin:center center;
    }

    .canvas-shell canvas{
        display:block;
        max-width:none;
        max-height:none;
    }

    .stage-note{
        padding:7px 10px;
        font-size:11px;
        line-height:1.5;
    }


    /* ---------- Zoom ---------- */

    .floating-zoom{
        right:8px;
        bottom:8px;
        padding:4px;
        gap:3px;
    }

    .mini-btn{
        width:38px;
        height:38px;
    }

    .zoom-label{
        min-width:62px;
        height:38px;
        padding:0 7px;
    }

    .mobile-zoom-option{
        display:block!important;
    }


    /* ---------- Quick ---------- */

    .mobile-quick-slot{
        padding:12px 12px 4px;
        background:#fff;
    }

    .mobile-quick-slot #quickPanel{
        margin:0;
        padding:0;
        border:0;
    }

    .mobile-quick-slot #quickPanel>h2{
        display:none;
    }

    .mobile-quick-slot .button-grid{
        display:grid;
        grid-template-columns:minmax(0,1fr) minmax(0,1fr);
        gap:8px;
    }

    .mobile-quick-slot .button-grid button{
        width:100%;
        min-width:0;
        min-height:46px;
        padding:10px 6px;
        font-size:14px;
    }

    .mobile-quick-slot #deleteImageBtn{
        grid-column:1/-1;
    }


    /* =====================================================
       UNDO / REDO
       親要素 historyActions ごと移動するので
       必ず横並び
    ===================================================== */

    .mobile-history-slot{
        padding:4px 12px 12px;
        background:#fff;
        border-bottom:1px solid #dfe3e8;
    }

    .mobile-history-slot .history-actions{
        display:flex!important;
        flex-direction:row!important;
        flex-wrap:nowrap!important;
        align-items:stretch!important;

        width:100%!important;

        gap:8px!important;
    }

    .mobile-history-slot .history-actions #undoBtn,
    .mobile-history-slot .history-actions #redoBtn{
        display:block!important;

        flex:1 1 0!important;

        width:0!important;
        min-width:0!important;
        max-width:none!important;

        min-height:46px;

        margin:0!important;

        padding:10px 6px!important;

        font-size:14px;

        white-space:nowrap;
    }


    /* ---------- Object ---------- */

    .right-sidebar .object-panel{
        margin:0;
        padding:0;
        border:0;
    }

    .object-panel h2{
        font-size:20px;
        margin:0 0 14px;
    }

    .field-row.two-col{
        grid-template-columns:minmax(0,1fr) minmax(0,1fr);
    }


    /* ---------- Product info ---------- */

    .left-content{
        flex:none;
    }

    .product-info{
        margin-top:0;
    }

    .product-info dl div{
        display:grid;
        grid-template-columns:minmax(100px,.8fr) minmax(0,1.4fr);
        gap:12px;
        font-size:14px;
    }

    .product-info dd{
        overflow-wrap:anywhere;
    }

    .reset-zone{
        position:static;
    }


    /* ---------- Confirm ---------- */

    .mobile-confirm-slot{
        padding:12px;
        background:#fff;
        border-top:1px solid #dfe3e8;
    }

    .mobile-confirm-slot #confirmBtn{
        position:static!important;
        display:block;
        width:100%;
        min-height:50px;
        margin:0;
        transform:none!important;
        font-size:16px;
    }


    /* ---------- Modal ---------- */

    .modal-backdrop{
        padding:12px;
    }

    .modal{
        width:100%;
        padding:20px;
    }

}


/* =========================================================
   SMALL SMARTPHONE
========================================================= */

@media(max-width:480px){

    .canvas-viewport{
        height:300px;
        min-height:300px;
        max-height:300px;
    }

    .right-sidebar,
    .left-sidebar{
        padding:14px;
    }

}/* =========================================================
   Mobile Status + Text Size
========================================================= */

@media(max-width:850px){

    .mobile-info-slot{
        display:block;
        width:100%;
        padding:10px 12px;
        background:#fff;
        border-bottom:1px solid #dfe3e8;
    }


    /* 現在の状態 */

    .mobile-info-slot #status{
        display:block;
        width:100%;

        margin:0 0 10px 0;
        padding:10px 12px;

        background:#f4f6f8;
        border:1px solid #e2e6eb;
        border-radius:8px;

        font-size:13px;
        line-height:1.5;
    }


    /* 文字サイズ */

    .mobile-info-slot .text-size-setting{
        display:flex;
        align-items:center;

        width:100%;

        margin:0;
        padding:0;

        border:0;
    }


    .mobile-info-slot .text-size-title{
        display:block;

        flex:0 0 auto;

        margin:0 12px 0 0;

        font-size:13px;
        font-weight:700;
        color:#606874;
    }


    .mobile-info-slot .text-size-options{
        display:grid;

        flex:1;

        grid-template-columns:
            minmax(0,1fr)
            minmax(0,1fr);

        gap:6px;
    }


    .mobile-info-slot .text-size-btn{
        width:100%;
        min-width:0;

        padding:8px 6px;

        font-size:13px;
    }

}