
        .crop-container {
            position: relative;
            display: none;
            margin: 24px 0;
            text-align: center;
        }

        .crop-container.active {
            display: flex;
            flex-direction: column;
        }

        .crop-preview-stage {
            flex: 0 0 auto;
        }

        .image-wrapper {
            position: relative;
            display: grid;
            grid-template-columns: minmax(0, 1fr);
            grid-template-rows: minmax(0, 1fr);
            place-items: center;
            width: 100%;
            height: 100%;
            overflow: hidden;
            border-radius: 0;
        }


        #preview-image {
            display: block;
            border-radius: 0;
        }

        .image-wrapper > .preview-media {
            grid-area: 1 / 1;
            min-width: 0;
            min-height: 0;
            place-self: center;
        }

        .crop-box {
            position: absolute;
            left: var(--crop-box-left, 0);
            top: var(--crop-box-top, 0);
            width: var(--crop-box-width, 0);
            height: var(--crop-box-height, 0);
            border: 2px solid #fff;
            cursor: move;
            box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.5);
            outline: 0;
            touch-action: none;
            user-select: none;
            -webkit-user-select: none;
        }

        .crop-box:focus-visible {
            outline: 3px solid var(--primary);
            outline-offset: 3px;
        }

        .crop-quick-toolbar {
            position: absolute;
            z-index: 5;
            display: none;
            align-items: stretch;
            flex-shrink: 0;
            gap: 8px;
            white-space: nowrap;
            word-break: keep-all;
        }

        .crop-quick-toolbar.show {
            display: flex;
        }

        .crop-quick-reset,
        .crop-quick-action {
            flex-shrink: 0;
            min-height: 37px;
            white-space: nowrap;
            word-break: keep-all;
            background: var(--container-bg);
            border: 2px solid #fff;
            border-radius: var(--radius);
            box-shadow: 0 10px 26px rgba(0, 0, 0, 0.2);
        }

        .crop-quick-reset {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 7px 10px;
            color: var(--text-muted);
            cursor: pointer;
            font: inherit;
            font-size: var(--tool-settings-control-size);
            font-weight: var(--tool-settings-control-weight);
        }

        .crop-quick-reset:hover:not(:disabled) {
            color: var(--primary-text);
            background: var(--container-bg);
        }

        .crop-quick-reset:disabled {
            cursor: not-allowed;
            opacity: 0.5;
        }

        .crop-quick-reset .material-symbols-outlined {
            font-size: 18px;
        }

        .crop-quick-action {
            position: relative;
            display: none;
            align-items: stretch;
        }

        .crop-quick-action.show {
            display: flex;
        }

        .crop-quick-format {
            position: relative;
            display: inline-flex;
            align-items: center;
        }

        .crop-quick-format-trigger {
            display: inline-flex;
            align-items: center;
            gap: 5px;
            padding: 7px 8px;
            color: var(--primary-text);
            background: var(--container-bg);
            border: 0;
            border-radius: calc(var(--radius) - 2px) 0 0 calc(var(--radius) - 2px);
            cursor: pointer;
            font: inherit;
        }

        .crop-quick-format-trigger svg {
            width: 15px;
            height: 15px;
            fill: none;
            stroke: currentColor;
            stroke-width: 2;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        .crop-quick-format-menu {
            position: absolute;
            z-index: 8;
            top: calc(100% + 7px);
            left: -2px;
            display: none;
            width: 100px;
            overflow: hidden;
            padding: 5px;
            background: var(--container-bg);
            border: 1px solid var(--border-color);
            border-radius: 10px;
            box-shadow: 0 12px 28px rgba(15, 23, 42, 0.2);
        }

        .crop-quick-format-menu.show {
            display: grid;
            gap: 2px;
        }

        .crop-quick-format-option {
            padding: 7px 9px;
            color: var(--text-color);
            background: transparent;
            border: 0;
            border-radius: 7px;
            cursor: pointer;
            font: inherit;
            font-size: var(--tool-settings-control-size);
            font-weight: var(--tool-settings-control-weight);
            text-align: left;
        }

        .crop-quick-format-option:hover,
        .crop-quick-format-option.is-selected {
            color: var(--primary-text);
            background: var(--container-bg);
        }

        .crop-quick-format-value {
            min-width: 34px;
            font-size: var(--tool-settings-control-size);
            font-weight: var(--tool-settings-control-weight);
            letter-spacing: 0.04em;
            pointer-events: none;
        }

        .crop-quick-format-trigger .material-symbols-outlined {
            margin-left: -4px;
            font-size: 15px;
            pointer-events: none;
        }

        .crop-quick-download {
            display: grid;
            width: 38px;
            place-items: center;
            padding: 0;
            color: #fff;
            background: var(--green-fill);
            border: 0;
            border-radius: 0 calc(var(--radius) - 2px) calc(var(--radius) - 2px) 0;
            cursor: pointer;
        }

        .crop-quick-download:hover {
            background: var(--green-fill-hover);
        }

        .crop-quick-download:focus-visible {
            outline: 3px solid var(--green);
            outline-offset: 2px;
        }

        .crop-quick-download:disabled {
            background: var(--green);
        }

        .crop-quick-download .material-symbols-outlined {
            font-size: 19px;
        }

        .crop-handle {
            position: absolute;
            width: 12px;
            height: 12px;
            background: #fff;
            border: 2px solid var(--primary);
            border-radius: 2px;
            touch-action: none;
        }

        .crop-handle.nw {
            top: -6px;
            left: -6px;
            cursor: nw-resize;
        }

        .crop-handle.ne {
            top: -6px;
            right: -6px;
            cursor: ne-resize;
        }

        .crop-handle.sw {
            bottom: -6px;
            left: -6px;
            cursor: sw-resize;
        }

        .crop-handle.se {
            bottom: -6px;
            right: -6px;
            cursor: se-resize;
        }

        .crop-handle.n {
            top: -6px;
            left: 50%;
            transform: translateX(-50%);
            cursor: n-resize;
        }

        .crop-handle.s {
            bottom: -6px;
            left: 50%;
            transform: translateX(-50%);
            cursor: s-resize;
        }

        .crop-handle.w {
            top: 50%;
            left: -6px;
            transform: translateY(-50%);
            cursor: w-resize;
        }

        .crop-handle.e {
            top: 50%;
            right: -6px;
            transform: translateY(-50%);
            cursor: e-resize;
        }

        @media (pointer: coarse) {
            .crop-handle {
                width: 20px;
                height: 20px;
            }

            .crop-handle.nw { top: -10px; left: -10px; }
            .crop-handle.ne { top: -10px; right: -10px; }
            .crop-handle.sw { bottom: -10px; left: -10px; }
            .crop-handle.se { bottom: -10px; right: -10px; }
            .crop-handle.n { top: -10px; }
            .crop-handle.s { bottom: -10px; }
            .crop-handle.w { left: -10px; }
            .crop-handle.e { right: -10px; }
        }

        .crop-editor-toolbar {
            display: flex;
            width: 100%;
            min-height: 24px;
            align-items: center;
            justify-content: space-between;
            gap: 6px;
            margin-bottom: 6px;
        }

        .crop-shortcuts-help {
            position: relative;
            z-index: 7;
            display: grid;
            width: 24px;
            height: 24px;
            flex: 0 0 24px;
            place-items: center;
            padding: 1px;
            color: var(--text-muted);
            background: color-mix(in srgb, var(--container-bg) 88%, transparent);
            border: 1px solid var(--border-color);
            border-radius: 7px;
            box-shadow: 0 3px 10px rgba(15, 23, 42, 0.12);
            cursor: help;
        }

        .crop-shortcuts-help svg {
            width: 20px;
            height: 20px;
            fill: none;
            stroke: currentColor;
            stroke-width: 1.8;
            stroke-linecap: round;
            stroke-linejoin: round;
        }

        .crop-shortcuts-tooltip {
            position: absolute;
            z-index: 9;
            top: calc(100% + 6px);
            right: 0;
            width: max-content;
            max-width: min(250px, calc(100vw - 48px));
            padding: 6px 8px;
            color: var(--text-color);
            background: var(--container-bg);
            border: 1px solid var(--border-color);
            border-radius: 7px;
            box-shadow: 0 8px 22px rgba(15, 23, 42, 0.18);
            font-size: 0.64rem;
            font-weight: 650;
            line-height: 1.35;
            white-space: nowrap;
            pointer-events: none;
            opacity: 0;
            transform: translateY(-3px);
            transition: opacity 0.15s ease, transform 0.15s ease;
        }

        .crop-shortcuts-help:hover .crop-shortcuts-tooltip,
        .crop-shortcuts-help:focus .crop-shortcuts-tooltip,
        .crop-shortcuts-help:focus-visible .crop-shortcuts-tooltip {
            opacity: 1;
            transform: translateY(0);
        }

        .tool-page .crop-page .crop-file-bar {
            --tool-action-soft: var(--container-bg);
            display: none;
            flex: 1 1 auto;
            align-items: center;
            gap: 5px;
            width: auto;
            min-width: 0;
            height: 24px;
            min-height: 24px;
            margin: 0;
            padding: 1px 4px 1px 6px;
            overflow: hidden;
            color: var(--orange-text);
            background: var(--container-bg);
            border: 1px solid var(--orange-mid);
            border-radius: 7px;
            font-size: 0.68rem;
            font-weight: 700;
            line-height: 1;
        }

        .tool-page .crop-page .crop-file-bar.show { display: flex; }
        .tool-page .crop-page .crop-file-bar .material-symbols-outlined { flex: 0 0 auto; font-size: 14px; }
        .tool-page .crop-page .crop-file-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
        .tool-page .crop-page .crop-file-meta { flex: 0 0 auto; color: var(--text-muted); white-space: nowrap; }
        .tool-page .crop-page .crop-file-position {
            flex: 0 0 auto;
            margin-left: auto;
            color: var(--text-muted);
            font-variant-numeric: tabular-nums;
            white-space: nowrap;
        }
        .tool-page .crop-page .crop-file-remove {
            display: inline-flex;
            align-items: center;
            justify-content: center;
            width: 20px;
            height: 20px;
            flex: 0 0 20px;
            margin-left: 0;
            padding: 0;
            color: var(--red);
            background: transparent;
            border: 0;
            border-radius: 50%;
            cursor: pointer;
        }
        .tool-page .crop-page .crop-file-remove:hover { background: var(--red-light); }

        .tool-page .crop-page {
            --tool-action-soft: var(--container-bg);
        }

        .tool-page .crop-page .tool-work-mode-switch {
            --tool-mode-soft: var(--container-bg);
        }

        .tool-page .crop-page .tool-format-options {
            --tool-format-soft: var(--container-bg);
        }

        .options-row {
            display: flex;
            gap: 16px;
            margin-top: 24px;
            flex-wrap: wrap;
            align-items: flex-end;
        }

        .opt-item {
            display: flex;
            flex-direction: column;
            gap: 8px;
        }

        .opt-item label {
            font-size: 0.75rem;
            font-weight: 700;
            color: var(--text-muted);
        }

        .preview-result {
            margin-top: 24px;
            text-align: center;
            background: var(--container-bg);
            border: 1px solid var(--border-color);
            border-radius: var(--radius-xl);
            padding: 24px;
        }

        #result-canvas {
            display: none;
            border-radius: 0;
        }

        .crop-page.is-result-preview .crop-shortcuts-help,
        .crop-page.is-result-preview #preview-image,
        .crop-page.is-result-preview .crop-box {
            display: none;
        }

        .crop-page.is-result-preview .image-wrapper {
            display: contents;
        }

        .crop-page.is-result-preview .crop-preview-stage {
            flex-direction: column;
        }

        .crop-page.is-result-preview #result-canvas {
            display: block !important;
        }

        .crop-page.is-result-preview .crop-quick-toolbar {
            position: static;
            justify-content: center;
            max-width: 100%;
            margin: 8px auto 0;
            transform: none;
            left: auto !important;
            top: auto !important;
        }

        .preview-placeholder-text {
            color: var(--text-muted);
            font-weight: 600;
            font-size: 0.9rem;
        }

        .tool-page .crop-guidance {
            margin-top: 10px;
            min-height: 0;
        }

        .tool-page .crop-guidance .preview-placeholder-text {
            margin: 0;
            color: var(--text-muted);
            font-size: 0.82rem;
            font-weight: 600;
        }

        :root:not([data-theme="dark"]) .tool-page .crop-page #crop-btn {
            background: var(--primary-fill);
            color: #fff;
            border: 1px solid var(--primary);
            box-shadow: 0 6px 16px color-mix(in srgb, var(--primary) 22%, transparent);
        }

        :root:not([data-theme="dark"]) .tool-page .crop-page #crop-btn:hover:not(:disabled) {
            background: var(--primary-fill-hover);
            border-color: var(--primary);
        }

        .action-row {
            display: flex;
            gap: 12px;
            margin-top: 24px;
            justify-content: center;
            flex-wrap: wrap;
        }

        .crop-primary-actions .btn { min-width: 0; }

        :root:not([data-theme="dark"]) .tool-page .crop-page .options-panel .opt-group {
            margin-top: 8px;
        }

        :root:not([data-theme="dark"]) .tool-page .crop-page .input-field {
            height: 40px;
        }

        :root:not([data-theme="dark"]) .tool-page .crop-page .label-sm {
            margin-bottom: 4px;
        }

        :root:not([data-theme="dark"]) .tool-page .crop-page .crop-guidance {
            margin-top: 6px;
        }

        :root:not([data-theme="dark"]) .tool-page .crop-page .crop-primary-actions {
            margin-top: 12px !important;
        }

        :root:not([data-theme="dark"]) .tool-page .crop-page .crop-primary-actions .btn {
            min-height: 40px;
            height: 40px;
        }

        [data-theme="dark"] .tool-page .crop-page .options-panel .opt-group {
            margin-top: 8px;
        }

        [data-theme="dark"] .tool-page .crop-page .input-field {
            height: 40px;
        }

        [data-theme="dark"] .tool-page .crop-page .label-sm {
            margin-bottom: 4px;
        }

        [data-theme="dark"] .tool-page .crop-page .crop-guidance {
            margin-top: 6px;
        }

        [data-theme="dark"] .tool-page .crop-page .crop-primary-actions {
            margin-top: 12px !important;
        }

        [data-theme="dark"] .tool-page .crop-page .crop-primary-actions .btn {
            min-height: 40px;
            height: 40px;
        }

        /* Crop-only compact layout experiment. Keep shared tool pages unchanged. */
        body.crop-compact-page .tool-page-summary {
            display: none;
        }

        body.crop-compact-page .site-header {
            gap: 4px;
        }

        body.crop-compact-page .header-subtitle {
            margin-top: -4px;
            margin-bottom: 4px;
            line-height: 1.25;
        }

        body.crop-compact-page .nav-pills {
            padding-block: 4px;
        }

        body.crop-compact-page .nav-pill {
            min-height: 36px;
            padding-block: 6px;
        }

        body.crop-compact-page .crop-settings-mode {
            width: 100%;
            margin: 6px 0 8px;
        }

        body.crop-compact-page .crop-settings-mode .tool-work-mode-switch {
            width: 100%;
            padding: 2px;
            gap: 3px;
            box-shadow: none;
        }

        body.crop-compact-page .crop-settings-mode .tool-work-mode-button {
            width: 100%;
            min-width: 0;
            height: 32px;
            padding: 3px 8px;
            gap: 5px;
            font-size: 0.72rem;
            white-space: nowrap;
        }

        body.crop-compact-page .crop-settings-mode .tool-work-mode-button svg {
            width: 16px;
            height: 16px;
        }

        body.crop-compact-page .crop-page .options-panel > .subtitle,
        body.crop-compact-page .crop-page .crop-guidance {
            display: none;
        }

        body.crop-compact-page .crop-page .options-panel .opt-group {
            margin-top: 7px;
        }

        body.crop-compact-page .crop-page .label-sm {
            margin-bottom: 3px;
        }

        body.crop-compact-page .crop-page .input-field,
        body.crop-compact-page .crop-page .tool-format-option {
            height: 32px;
        }

        body.crop-compact-page .crop-page .input-field {
            height: 32px !important;
            padding-block: 4px;
        }

        body.crop-compact-page .crop-page .tool-format-option {
            padding-block: 3px;
        }

        body.crop-compact-page .crop-aspect-control {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto;
            align-items: center;
            gap: 8px;
        }

        body.crop-compact-page .crop-ratio-lock {
            display: inline-flex;
            min-height: 32px;
            align-items: center;
            gap: 5px;
            padding: 0 4px;
            color: var(--text-muted);
            font-size: 0.7rem;
            font-weight: 650;
            line-height: 1;
            white-space: nowrap;
            cursor: pointer;
        }

        body.crop-compact-page .crop-ratio-lock input[type="checkbox"] {
            width: 15px;
            height: 15px;
            margin: 0;
            accent-color: var(--orange);
        }

        body.crop-compact-page .crop-ratio-lock.is-disabled {
            opacity: 0.48;
            cursor: not-allowed;
        }

        body.crop-compact-page .crop-size-fields {
            display: grid;
            grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
            align-items: center;
            gap: 6px;
        }

        body.crop-compact-page .crop-size-field {
            position: relative;
            min-width: 0;
        }

        body.crop-compact-page .crop-size-field .input-field {
            padding-inline: 8px 24px;
            text-align: right;
            font-variant-numeric: tabular-nums;
        }

        body.crop-compact-page .crop-size-unit {
            position: absolute;
            top: 50%;
            right: 8px;
            color: var(--text-muted);
            font-size: 0.62rem;
            font-weight: 700;
            pointer-events: none;
            transform: translateY(-50%);
        }

        body.crop-compact-page .crop-size-separator {
            color: var(--text-muted);
            font-size: 0.8rem;
            font-weight: 700;
        }

        body.crop-compact-page .crop-page .crop-quality-group {
            margin-top: 10px !important;
        }

        body.crop-compact-page .crop-page .crop-quality-group .tool-range-control {
            gap: 0;
        }

        body.crop-compact-page .crop-page .crop-quality-group .tool-range-header {
            min-height: 26px;
            margin-bottom: 0;
        }

        body.crop-compact-page .crop-page .crop-quality-group .tool-range-value {
            min-width: 48px;
            min-height: 26px;
            padding: 1px 7px;
            border-radius: 8px;
            font-size: 0.74rem;
        }

        body.crop-compact-page .crop-page .crop-quality-group .tool-range-track-wrap,
        body.crop-compact-page .crop-page .crop-quality-group .tool-range-input {
            height: 28px;
        }

        body.crop-compact-page .crop-page .crop-quality-group .tool-range-input::-webkit-slider-runnable-track {
            height: 6px;
        }

        body.crop-compact-page .crop-page .crop-quality-group .tool-range-input::-webkit-slider-thumb {
            width: 24px;
            height: 24px;
            margin-top: -9px;
            border-width: 2px;
        }

        body.crop-compact-page .crop-page .crop-quality-group .tool-range-input::-moz-range-track,
        body.crop-compact-page .crop-page .crop-quality-group .tool-range-input::-moz-range-progress {
            height: 6px;
        }

        body.crop-compact-page .crop-page .crop-quality-group .tool-range-input::-moz-range-thumb {
            width: 20px;
            height: 20px;
            border-width: 2px;
        }

        body.crop-compact-page .crop-page .crop-quality-group .tool-range-ticks {
            inset: 11px 0 auto;
            height: 6px;
        }

        body.crop-compact-page .crop-page .crop-quality-group .tool-range-scale {
            margin-top: 0;
            font-size: 0.64rem;
            line-height: 1;
        }

        body.crop-compact-page .crop-page .crop-primary-actions {
            margin-top: 9px !important;
        }

        body.crop-compact-page .crop-page .crop-primary-actions .btn {
            min-height: 40px !important;
            height: 40px !important;
            padding-block: 7px !important;
        }

        @media (min-width: 769px) {
            body.crop-compact-page .site-header {
                padding-top: 8px;
            }

            body.crop-compact-page .main-container {
                padding-top: 8px !important;
            }

            body.crop-compact-page .crop-page {
                --tool-workspace-height: 400px;
            }

            .tool-page .crop-page .tool-layout-grid,
            .tool-page .crop-page .tool-left,
            .tool-page .crop-page .tool-right {
                min-height: 0;
                box-sizing: border-box;
            }

            .tool-page .crop-page .tool-layout-grid {
                height: auto;
            }

            .tool-page .crop-page .tool-left {
                height: var(--tool-workspace-height);
            }

            .tool-page .crop-page .tool-right {
                height: auto;
            }

            body.crop-compact-page .crop-page .tool-right {
                gap: 0;
                padding: 14px !important;
                overflow: visible;
                position: sticky;
                top: 12px;
                align-self: start;
                background: var(--container-bg);
                border: 1px solid var(--border-color);
                border-radius: var(--radius-2xl);
                box-shadow: var(--shadow);
            }

            .tool-page .crop-page .tool-right .options-panel {
                padding: 0;
                border: 0;
                border-radius: 0;
                background: transparent;
                box-shadow: none;
            }

            .tool-page .crop-page .crop-container { margin: 0; }

            body.crop-compact-page .crop-page.is-image-loaded .tool-layout-grid,
            body.crop-compact-page .crop-page.is-image-loaded .tool-left,
            body.crop-compact-page .crop-page.is-image-loaded .tool-right {
                height: auto;
            }

            body.crop-compact-page .crop-page.is-image-loaded .tool-layout-grid {
                align-items: start;
            }

            body.crop-compact-page .crop-page.is-image-loaded .tool-left {
                min-height: var(--tool-workspace-height);
                gap: 0;
                padding: 14px !important;
                justify-content: flex-start;
            }

            body.crop-compact-page .crop-page.is-image-loaded .crop-container.active {
                flex: 0 0 auto;
                width: 100%;
                min-height: 0;
                align-items: center;
                justify-content: flex-start;
            }

            body.crop-compact-page .crop-page.is-image-loaded .image-wrapper { border-radius: 0; }
        }

        @media (max-width: 768px) {
            body.crop-compact-page .site-header {
                padding-top: 10px;
            }

            body.crop-compact-page .main-container {
                padding-top: 10px !important;
            }

            body.crop-compact-page .crop-page .tool-right {
                position: static;
            }

            body.crop-compact-page .crop-page.is-image-loaded .tool-left {
                padding: 14px !important;
            }

        }

        @media (max-width: 480px) {
            .tool-page .crop-page .crop-file-meta {
                display: none;
            }

            .tool-page .crop-page .crop-file-position {
                font-size: 0.68rem;
            }
        }

        @media (max-width: 600px) {
            .crop-primary-actions { flex-wrap: wrap !important; }
            .crop-primary-actions .btn { flex-basis: 100% !important; }
        }
