.resize-page {
    flex: 1 0 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.tool-intro {
    padding: 34px 24px 12px;
    text-align: center;
}

.tool-intro h1 {
    margin: 0 0 10px;
    font-size: clamp(28px, 3vw, 38px);
    letter-spacing: 0.01em;
}

.tool-intro p {
    margin: 0;
    color: #7a5c66;
    line-height: 1.7;
}

.upload-start {
    width: min(760px, calc(100% - 32px));
    margin: 18px auto 90px;
}

.drop-zone {
    min-height: 330px;
    padding: 44px 28px;
    border: 2px dashed #e8bcc9;
    border-radius: 20px;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    outline: none;
    transition: 0.16s ease;
}

.drop-zone:hover,
.drop-zone:focus,
.drop-zone.is-dragover {
    border-color: var(--primary);
    background: #fff5f7;
    box-shadow: 0 12px 32px rgba(159, 18, 57, 0.12);
}

.drop-zone__icon {
    width: 54px;
    height: 54px;
    margin-bottom: 18px;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: #ffe5ec;
    color: var(--primary);
    font-size: 34px;
    font-weight: 300;
}

.drop-zone p {
    margin: 14px 0 8px;
    color: #7a5c66;
}

.drop-zone small {
    color: #9a7682;
    line-height: 1.6;
}

.tool-unavailable {
    width: min(680px, calc(100% - 32px));
    margin: 34px auto 90px;
    padding: 42px;
    text-align: center;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 16px;
}

.editor-layout {
    position: relative;
    width: min(1600px, 100%);
    margin: 8px auto;
    /*
     * header / footer の実寸をCSS計算で決め打ちせず、
     * main の残り高さをそのまま使う。
     * 画像が少ない状態では不要な縦スクロールを出さない。
     */
    flex: 1 0 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    align-items: stretch;
    border-top: 1px solid var(--border);
    border-left: 1px solid var(--border);
    border-right: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
    background: var(--page-bg);
}

/*
 * オプション領域の白背景と境界線を、内容量に関係なく
 * editor-layout の最下部まで確実に伸ばす。
 */
.editor-layout::before {
    content: "";
    position: absolute;
    z-index: 0;
    top: 0;
    bottom: 0;
    left: 0;
    width: 320px;
    background: #ffffff;
    border-right: 1px solid var(--border);
    pointer-events: none;
}

.options-panel,
.image-workspace {
    position: relative;
    z-index: 1;
}

.options-panel {
    align-self: stretch;
    background: transparent;
}

.options-panel__sticky {
    position: sticky;
    top: var(--header-height);
    max-height: calc(100vh - var(--header-height));
    overflow-y: auto;
    padding-bottom: 22px;
}

.options-panel h2 {
    margin: 0;
    padding: 22px 20px;
    text-align: center;
    font-size: 20px;
    border-bottom: 1px solid var(--border);
}

.mode-tabs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    border-bottom: 1px solid var(--border);
}

.mode-tab {
    position: relative;
    min-height: 92px;
    border: 0;
    background: #ffffff;
    color: #8a93a2;
    cursor: pointer;
    font-weight: 700;
}

.mode-tab + .mode-tab {
    border-left: 1px solid var(--border);
}

.mode-tab.is-active {
    color: #3b1020;
    background: #fff5f7;
}

.mode-tab.is-active::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    bottom: -1px;
    height: 3px;
    background: var(--primary);
}

.mode-tab__icon {
    display: block;
    margin-bottom: 5px;
    font-size: 25px;
    color: inherit;
}

.option-section {
    background: #ffffff;
}

.option-heading {
    padding: 17px 16px 12px;
    font-size: 13px;
    font-weight: 800;
    color: #6f4955;
    border-bottom: 1px solid var(--border);
}

.field-row {
    min-height: 68px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
}

.field-row input[type="number"] {
    width: 112px;
    height: 40px;
    padding: 0 10px;
    text-align: right;
    border: 1px solid #d7a2b0;
    border-radius: 7px;
    outline: none;
}

.field-row input[type="number"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(159, 18, 57, 0.14);
}

.check-row {
    min-height: 60px;
    padding: 13px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    cursor: pointer;
    border-bottom: 1px solid var(--border);
}

.check-row input {
    width: 20px;
    height: 20px;
    accent-color: var(--primary);
}

.check-row--bordered {
    border-bottom: 1px solid var(--border);
}

.ratio-presets {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    border-bottom: 1px solid var(--border);
}

.ratio-button {
    height: 56px;
    border: 0;
    background: #ffffff;
    color: var(--primary);
    cursor: pointer;
    font-weight: 700;
}

.ratio-button + .ratio-button {
    border-left: 1px solid #f6dde5;
}

.ratio-button.is-active {
    color: #ffffff;
    background: var(--primary);
}

.ratio-input-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

.option-message {
    min-height: 42px;
    padding: 12px 16px 4px;
    color: var(--danger);
    font-size: 13px;
    line-height: 1.5;
}

.option-message.is-success {
    color: #0f766e;
}

.process-button {
    width: calc(100% - 28px);
    min-height: 60px;
    margin: 14px;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    font-size: 17px;
}

.image-workspace {
    min-width: 0;
    padding: 20px 24px 50px;
    background: var(--page-bg);
}

.workspace-toolbar {
    min-height: 50px;
    margin-bottom: 14px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 14px;
}

.workspace-toolbar strong {
    font-size: 18px;
}

.workspace-toolbar__actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.clear-all-button {
    padding: 10px 16px;
    border: 1px solid #dbcbd0;
    border-radius: 10px;
    background: #ffffff;
    color: #765964;
    cursor: pointer;
    font-weight: 700;
    transition: 0.15s ease;
}

.clear-all-button:hover:not(:disabled) {
    border-color: #c58a9b;
    background: #fff7f9;
    color: var(--primary);
}

.clear-all-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.file-count {
    margin-left: 10px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 600;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: 10px;
}

.image-card {
    position: relative;
    min-width: 0;
    overflow: hidden;
    background: #ffffff;
    border: 1px solid #e4e8ef;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(24, 35, 58, 0.035);
}

.image-card__preview {
    position: relative;
    height: 205px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
    background-image:
        linear-gradient(45deg, #f1f2f5 25%, transparent 25%),
        linear-gradient(-45deg, #f1f2f5 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #f1f2f5 75%),
        linear-gradient(-45deg, transparent 75%, #f1f2f5 75%);
    background-size: 18px 18px;
    background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}

.image-card__preview img {
    display: block;
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.08));
}

.image-card__remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 30px;
    height: 30px;
    border: 0;
    border-radius: 50%;
    color: #ffffff;
    background: rgba(24, 31, 43, 0.72);
    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

.image-card__remove:hover {
    background: #c43d3d;
}

.image-card__meta {
    padding: 10px 11px 12px;
}

.image-card__name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
    font-size: 12px;
    color: #485261;
}

.image-card__sizes {
    margin-top: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    font-size: 11px;
}

.size-badge {
    padding: 3px 6px;
    border-radius: 4px;
    color: #ffffff;
    background: #969dac;
    font-weight: 700;
}

.size-badge--after {
    background: var(--primary);
}

.size-arrow {
    color: #7f8795;
}

.image-card__error {
    margin-top: 7px;
    color: var(--danger);
    font-size: 11px;
    text-align: center;
}

.upload-progress {
    margin-bottom: 15px;
    padding: 11px 13px;
    background: #ffffff;
    border: 1px solid var(--border);
    border-radius: 8px;
}

.upload-progress__bar {
    height: 6px;
    overflow: hidden;
    border-radius: 999px;
    background: #e9eef7;
}

.upload-progress__bar span {
    display: block;
    width: 0;
    height: 100%;
    background: var(--primary);
    transition: width 0.15s ease;
}

.upload-progress__text {
    margin-top: 6px;
    color: var(--muted);
    font-size: 12px;
}

@media (max-width: 980px) {
    .editor-layout {
        display: flex;
        flex-direction: column;
        border-left: 0;
        border-right: 0;
    }

    .editor-layout::before {
        display: none;
    }

    .image-workspace {
        order: 1;
    }

    .options-panel {
        order: 2;
        background: #ffffff;
        border-top: 1px solid var(--border);
    }

    .options-panel__sticky {
        position: static;
        max-height: none;
    }

    .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .image-card__preview {
        height: 170px;
    }
}

@media (max-width: 620px) {
    .tool-intro {
        padding: 24px 16px 8px;
    }

    .tool-intro p br {
        display: none;
    }

    .drop-zone {
        min-height: 285px;
        padding: 30px 16px;
    }

    .primary-button--large {
        min-width: 230px;
    }

    .image-workspace {
        padding: 14px 10px 34px;
    }

    .workspace-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .image-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
    }

    .image-card__preview {
        height: 155px;
    }
}


.initial-feedback,
.upload-feedback {
    width: min(760px, calc(100% - 32px));
    margin: 14px auto 0;
    border-radius: 14px;
    border: 1px solid #f2b5c5;
    background: #fff7f9;
    color: var(--danger);
    padding: 14px 16px;
    white-space: pre-line;
    line-height: 1.6;
}

.upload-feedback.is-success {
    border-color: #99d1c8;
    color: #0f766e;
    background: #f3fbf9;
}

@media (max-width: 620px) {
    .workspace-toolbar {
        align-items: flex-start;
        flex-direction: column;
    }

    .workspace-toolbar__actions {
        width: 100%;
    }

    .workspace-toolbar__actions .secondary-button,
    .workspace-toolbar__actions .clear-all-button {
        flex: 1;
    }
}
