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

.is-hidden { display: none !important; }

.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 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;
    flex: 1 0 auto;
    min-height: 0;
    display: grid;
    grid-template-columns: 320px minmax(0, 1fr);
    align-items: stretch;
    border: 1px solid var(--border);
    background: var(--page-bg);
}
.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);
}
.option-section { background: #ffffff; }
.option-body.is-disabled { opacity: 0.55; }
.option-heading {
    padding: 17px 16px 12px;
    font-size: 13px;
    font-weight: 800;
    color: #6f4955;
    border-bottom: 1px solid var(--border);
}
.option-heading--with-check { padding: 0; }
.section-check {
    min-height: 58px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 800;
    color: #5f4250;
}
.section-check input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.section-check__mark,
.check-option__mark {
    width: 20px;
    height: 20px;
    border-radius: 6px;
    border: 1px solid #d7a2b0;
    background: #ffffff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
.section-check input:checked + .section-check__mark,
.check-option input:checked + .check-option__mark {
    border-color: var(--primary);
    background: var(--primary);
}
.section-check input:checked + .section-check__mark::after,
.check-option input:checked + .check-option__mark::after {
    content: "";
    width: 8px;
    height: 4px;
    border-left: 2px solid #ffffff;
    border-bottom: 2px solid #ffffff;
    transform: rotate(-45deg) translateY(-1px);
}
.option-section--notice {
    padding: 14px 16px 16px;
    border-top: 1px solid var(--border);
    border-bottom: 1px solid var(--border);
}
.notice-box {
    padding: 14px 14px;
    border-radius: 8px;
    background: #f8e7ec;
    color: #6c3144;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    line-height: 1.6;
}
.field-stack {
    padding: 14px 16px;
    border-bottom: 1px solid var(--border);
}
.field-label {
    display: block;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #6f4955;
}
.field-stack textarea,
.field-row input[type="number"],
.field-row input[type="text"],
.field-row select,
.preview-toolbar__select select {
    width: 100%;
    min-height: 40px;
    padding: 0 10px;
    border: 1px solid #d7a2b0;
    border-radius: 7px;
    outline: none;
    background: #ffffff;
    font-size: 14px;
}
.field-stack textarea {
    min-height: 92px;
    padding: 10px 12px;
    resize: vertical;
    font-family: inherit;
    line-height: 1.5;
}
.field-stack textarea:focus,
.field-row input[type="number"]:focus,
.field-row input[type="text"]:focus,
.field-row select:focus,
.preview-toolbar__select select:focus,
.color-input-wrap input[type="color"]:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(159, 18, 57, 0.14);
}
.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 > label:first-child {
    flex: 0 0 90px;
    font-weight: 700;
    color: #5f4250;
}
.field-row > select { width: 150px; }
.field-inline {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 150px;
}
.field-inline input[type="number"] { text-align: right; }
.field-inline span { color: #7e616b; font-size: 13px; white-space: nowrap; }
.color-input-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
}
.color-input-wrap input[type="color"] {
    width: 44px;
    min-width: 44px;
    height: 40px;
    padding: 3px;
    border: 1px solid #d7a2b0;
    border-radius: 8px;
    background: #ffffff;
    cursor: pointer;
}
.color-input-wrap input[type="text"] {
    width: 96px;
    text-align: left;
    text-transform: uppercase;
}
.check-option {
    min-height: 58px;
    padding: 0 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    cursor: pointer;
}
.watermark-picker__hint { margin: 10px 0 0; color: #8a6a75; font-size: 12px; }
.secondary-button--small { padding: 10px 14px; font-size: 13px; }
.watermark-preview {
    margin-top: 12px;
    padding: 12px;
    border: 1px solid #e6c0cc;
    border-radius: 12px;
    background: #fff8fa;
}
.watermark-preview img {
    width: 100%;
    max-height: 120px;
    object-fit: contain;
    display: block;
    border-radius: 8px;
    background:
        linear-gradient(45deg, #f2dee4 25%, transparent 25%, transparent 75%, #f2dee4 75%),
        linear-gradient(45deg, #f2dee4 25%, transparent 25%, transparent 75%, #f2dee4 75%),
        #ffffff;
    background-position: 0 0, 10px 10px;
    background-size: 20px 20px;
}
.watermark-preview__meta { margin-top: 10px; line-height: 1.5; }
.watermark-preview__name { font-size: 13px; font-weight: 700; color: #5f4250; word-break: break-all; }
.watermark-preview__size { font-size: 12px; color: #866a73; }
.watermark-preview__remove { margin-top: 10px; }
.process-button { width: calc(100% - 32px); margin: 18px 16px 0; }

.image-workspace {
    min-width: 0;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}
.workspace-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 2px 2px 0;
}
.workspace-toolbar strong { font-size: 18px; color: #402530; }
.file-count { margin-left: 8px; font-size: 13px; font-weight: 700; color: #7f5b68; }
.workspace-toolbar__actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.upload-progress,
.upload-feedback,
.process-message {
    border-radius: 12px;
    padding: 12px 14px;
    background: #ffffff;
    border: 1px solid #e7cad3;
}
.upload-progress__bar {
    height: 10px;
    border-radius: 999px;
    background: #f4dbe3;
    overflow: hidden;
}
.upload-progress__bar span {
    display: block;
    width: 0;
    height: 100%;
    border-radius: inherit;
    background: linear-gradient(90deg, #b01443 0%, #e14a7f 100%);
    transition: width 0.2s ease;
}
.upload-progress__text { margin-top: 8px; color: #6d4753; font-size: 13px; }
.upload-feedback,
.process-message { white-space: pre-line; color: #8f183f; background: #fff6f8; }
.upload-feedback.is-success,
.process-message.is-success { color: #155724; background: #f1fbf4; border-color: #b9e1c2; }

.preview-shell {
    background: #ffffff;
    border: 1px solid #ead2da;
    border-radius: 20px;
    padding: 18px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}
.preview-toolbar {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 14px;
    flex-wrap: wrap;
}
.preview-toolbar__nav {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.preview-nav-button {
    min-height: 40px;
    padding: 0 14px;
    border: 1px solid #dcb4c3;
    border-radius: 10px;
    background: #ffffff;
    color: #6e3347;
    font-weight: 700;
    cursor: pointer;
}
.preview-nav-button:disabled { cursor: default; opacity: 0.45; }
.preview-toolbar__select {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #6f4955;
    font-size: 13px;
    font-weight: 700;
}
.preview-toolbar__select select { min-width: 280px; }
.preview-toolbar__meta { color: #7d5f69; font-size: 13px; line-height: 1.5; }
.preview-stage {
    min-height: 540px;
    padding: 20px;
    border-radius: 18px;
    border: 1px dashed #e9c5d2;
    background: #fbf3f6;
    display: flex;
    align-items: center;
    justify-content: center;
}
.preview-canvas-wrap {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px;
    border-radius: 18px;
    background:
        linear-gradient(45deg, #f2dde5 25%, transparent 25%, transparent 75%, #f2dde5 75%),
        linear-gradient(45deg, #f2dde5 25%, transparent 25%, transparent 75%, #f2dde5 75%),
        #ffffff;
    background-position: 0 0, 12px 12px;
    background-size: 24px 24px;
    box-shadow: inset 0 0 0 1px rgba(159, 18, 57, 0.06);
}
.preview-canvas-stage {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 68vh;
}
#previewCanvas {
    display: block;
    max-width: 100%;
    max-height: 68vh;
    width: auto;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 18px 36px rgba(95, 66, 80, 0.12);
}
.overlay-editor {
    position: absolute;
    inset: 0;
    z-index: 2;
    pointer-events: none;
}
.overlay-editor__box {
    position: absolute;
    box-sizing: border-box;
    min-width: 26px;
    min-height: 26px;
    border: 2px dashed #cf5379;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.06);
    box-shadow: 0 0 0 1px rgba(255,255,255,0.45), 0 10px 22px rgba(90,45,62,0.10);
    cursor: move;
    pointer-events: auto;
    touch-action: none;
    user-select: none;
    transition: box-shadow 0.12s ease, border-color 0.12s ease;
}
.overlay-editor__box--text { border-color: #cf5379; }
.overlay-editor__box--watermark { border-color: #4d8edb; }
.overlay-editor__box.is-active {
    box-shadow: 0 0 0 2px rgba(255,255,255,0.7), 0 0 0 4px rgba(207,83,121,0.18), 0 12px 24px rgba(90,45,62,0.16);
}
.overlay-editor__box--watermark.is-active {
    box-shadow: 0 0 0 2px rgba(255,255,255,0.7), 0 0 0 4px rgba(77,142,219,0.18), 0 12px 24px rgba(50,78,120,0.15);
}
.overlay-editor__label {
    position: absolute;
    left: 8px;
    top: -34px;
    padding: 6px 10px;
    border-radius: 999px;
    background: rgba(111, 39, 68, 0.92);
    color: #ffffff;
    font-size: 12px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
    pointer-events: none;
}
.overlay-editor__box--watermark .overlay-editor__label { background: rgba(42, 97, 160, 0.92); }
.overlay-editor__handle {
    position: absolute;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid #ffffff;
    background: #cf5379;
    box-shadow: 0 2px 6px rgba(95,66,80,0.18);
    pointer-events: auto;
    touch-action: none;
}
.overlay-editor__box--watermark .overlay-editor__handle { background: #4d8edb; }
.overlay-editor__handle--nw { left: -8px; top: -8px; cursor: nwse-resize; }
.overlay-editor__handle--ne { right: -8px; top: -8px; cursor: nesw-resize; }
.overlay-editor__handle--sw { left: -8px; bottom: -8px; cursor: nesw-resize; }
.overlay-editor__handle--se { right: -8px; bottom: -8px; cursor: nwse-resize; }
.preview-empty { color: #886874; font-size: 15px; text-align: center; }
.preview-caption { color: #85636f; font-size: 13px; line-height: 1.5; text-align: center; }
.thumbnail-heading { padding: 2px 2px 0; font-size: 14px; font-weight: 800; color: #6f4955; }
.image-grid--thumbs {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 14px;
}
.image-card {
    position: relative;
    background: #ffffff;
    border: 1px solid #ead1da;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 18px rgba(90, 45, 62, 0.05);
}
.image-card.is-current {
    border-color: #cf5379;
    box-shadow: 0 0 0 2px rgba(207,83,121,0.15), 0 12px 22px rgba(90,45,62,0.10);
}
.image-card__main {
    width: 100%;
    padding: 0;
    border: 0;
    background: transparent;
    text-align: left;
    cursor: pointer;
}
.image-card__main:disabled { cursor: default; }
.image-card__preview {
    aspect-ratio: 1 / 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    background:
        linear-gradient(45deg, #f2dde5 25%, transparent 25%, transparent 75%, #f2dde5 75%),
        linear-gradient(45deg, #f2dde5 25%, transparent 25%, transparent 75%, #f2dde5 75%),
        #ffffff;
    background-position: 0 0, 10px 10px;
    background-size: 20px 20px;
}
.image-card__preview img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.image-card__meta { padding: 10px 12px 12px; }
.image-card__order { margin-bottom: 4px; font-size: 11px; font-weight: 800; color: #a1506d; }
.image-card__name,
.image-card__output-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.image-card__name { color: #4d2f3b; font-size: 13px; font-weight: 700; }
.image-card__output-name { margin-top: 3px; color: #80616b; font-size: 12px; }
.image-card__sizes {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    margin-top: 10px;
}
.size-badge {
    display: inline-flex;
    align-items: center;
    min-height: 24px;
    padding: 0 8px;
    border-radius: 999px;
    background: #f8e7ec;
    color: #7a4254;
    font-size: 11px;
    font-weight: 700;
}
.size-badge--after { background: #f7eef0; }
.image-card__remove {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 28px;
    height: 28px;
    border: 0;
    border-radius: 999px;
    background: rgba(73,43,55,0.72);
    color: #ffffff;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.image-card__remove:disabled { cursor: default; opacity: 0.45; }

@media (max-width: 1200px) {
    .preview-stage { min-height: 460px; }
    .preview-toolbar__select select { min-width: 220px; }
}
@media (max-width: 1040px) {
    .editor-layout { grid-template-columns: 1fr; }
    .editor-layout::before { display: none; }
    .options-panel { border-bottom: 1px solid var(--border); }
    .options-panel__sticky { position: static; max-height: none; overflow: visible; }
}
@media (max-width: 640px) {
    .upload-start { width: min(100%, calc(100% - 24px)); margin-bottom: 64px; }
    .drop-zone { min-height: 280px; padding: 34px 18px; }
    .image-workspace { padding: 16px; }
    .workspace-toolbar,
    .preview-toolbar { flex-direction: column; align-items: stretch; }
    .preview-toolbar__nav { flex-direction: column; align-items: stretch; }
    .preview-toolbar__select { flex-direction: column; align-items: stretch; }
    .preview-toolbar__select select { min-width: 0; }
    .preview-stage { min-height: 320px; padding: 12px; }
    .preview-canvas-wrap { padding: 10px; }
    .field-row { flex-direction: column; align-items: stretch; }
    .field-row > label:first-child,
    .field-row > select,
    .field-inline { width: 100%; flex-basis: auto; }
    .color-input-wrap { width: 100%; }
    .color-input-wrap input[type="text"] { flex: 1 1 auto; }
    .image-grid--thumbs { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); }
}
