
.cartoon-note {
    display: block;
    color: #8a6f4d;
    font-size: .86rem;
    line-height: 1.45;
}

.frame-section-head {
    margin: 0 0 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}

.frame-section-head h3 {
    margin: 0;
}

.frame-section-actions {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    gap: 8px;
}

.frame-refresh-button,
.frame-overview-button {
    width: 38px;
    height: 38px;
    min-height: 38px;
    padding: 0;
    flex: 0 0 auto;
    display: grid;
    place-items: center;
    color: var(--primary);
    background: #eef5ff;
    border: 1px solid rgba(37, 111, 217, .18);
    border-radius: 999px;
    box-shadow: none;
    text-decoration: none;
}

.frame-refresh-button:hover,
.frame-overview-button:hover {
    color: #fff;
    background: var(--primary);
}

.frame-refresh-button svg,
.frame-overview-button svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.file-picker {
    position: relative;
    min-height: 46px;
    width: 100%;
    display: grid;
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    color: var(--text);
    cursor: pointer;
    overflow: hidden;
}

.file-picker:hover {
    border-color: #b8c9dd;
}

.file-picker:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37, 111, 217, 0.14);
}

.file-picker input[type="file"] {
    position: absolute;
    inset: 0;
    z-index: 2;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-picker input[type="file"]:disabled {
    cursor: wait;
}

.file-picker:has(input[type="file"]:disabled) {
    opacity: .72;
    cursor: wait;
}

.file-picker-icon {
    width: 42px;
    min-height: 44px;
    display: grid;
    place-items: center;
    color: var(--primary);
    background: #edf5ff;
    border-right: 1px solid var(--border);
}

.file-picker-icon svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.file-picker-text {
    min-width: 0;
    padding-right: 12px;
    color: #314156;
    font-weight: 650;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.upload-progress-card {
    width: 100%;
    margin: 10px 0 8px;
    padding: 10px 12px;
    display: grid;
    gap: 8px;
    border: 1px solid rgba(37, 111, 217, .22);
    border-radius: var(--radius);
    background: linear-gradient(180deg, #f8fbff, #eef5ff);
    box-shadow: 0 10px 24px rgba(30, 80, 160, .1);
}

.upload-progress-card[hidden] {
    display: none;
}

.upload-progress-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    color: #17365e;
    font-size: .9rem;
}

.upload-progress-head strong,
.upload-progress-head span {
    min-width: 0;
    font-weight: 900;
}

.upload-progress-head strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.upload-progress-head span {
    flex: 0 0 auto;
    color: var(--primary);
}

.upload-progress-track {
    position: relative;
    height: 9px;
    overflow: hidden;
    border-radius: 999px;
    background: #dce9f8;
}

.upload-progress-track i {
    width: 4%;
    height: 100%;
    display: block;
    border-radius: inherit;
    background: linear-gradient(90deg, #256fd9, #49a1ff);
    transition: width .18s ease;
}

.upload-progress-card small {
    color: #657489;
    font-size: .82rem;
    line-height: 1.35;
}

.upload-progress-card.is-indeterminate .upload-progress-track i {
    width: 42%;
    animation: uploadProgressPulse 1.05s ease-in-out infinite;
}

.upload-progress-card.is-complete {
    border-color: rgba(40, 167, 69, .28);
    background: linear-gradient(180deg, #f7fff9, #edf9f0);
}

.upload-progress-card.is-complete .upload-progress-head span {
    color: var(--success);
}

.upload-progress-card.is-complete .upload-progress-track i {
    background: linear-gradient(90deg, #28a745, #6fd987);
}

.upload-progress-card.is-error {
    border-color: rgba(211, 63, 73, .3);
    background: #fff7f7;
}

.upload-progress-card.is-error .upload-progress-head span {
    color: var(--danger);
}

.upload-progress-card.is-error .upload-progress-track i {
    background: linear-gradient(90deg, #d33f49, #ff7a83);
}

@keyframes uploadProgressPulse {
    0% {
        transform: translateX(-110%);
    }
    100% {
        transform: translateX(260%);
    }
}

.frame-upload-choice-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 66px;
    gap: 10px;
    align-items: center;
}

.camera-file-input {
    position: fixed;
    width: 1px;
    height: 1px;
    opacity: 0;
    pointer-events: none;
}

.upload-action-row,
.frame-share-upload-row {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 10px;
}

.mobile-camera-button {
    display: none;
}

.mobile-camera-button svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.frame-upload-preview {
    width: 66px;
    height: 66px;
    padding: 4px;
    display: grid;
    place-items: center;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: #fff;
    box-shadow: 0 4px 12px rgba(36, 58, 86, .08);
}

.frame-upload-preview[hidden] {
    display: none !important;
}

.frame-upload-preview img {
    max-width: 100%;
    max-height: 100%;
    display: block;
    object-fit: contain;
}

#resizeUploadForm {
    grid-template-columns: 1fr;
    align-items: stretch;
}

.resize-presets,
.resize-field {
    display: grid;
    gap: 6px;
}

.resize-presets label,
.resize-field > span {
    color: #405168;
    font-size: .86rem;
    font-weight: 750;
}

.resize-presets select,
.resize-field select {
    width: 100%;
}

.resize-dimensions {
    display: grid;
    grid-template-columns: minmax(68px, .9fr) 14px minmax(68px, .9fr) minmax(68px, .8fr) minmax(72px, .8fr) auto;
    align-items: center;
    gap: 8px;
}

.resize-dimensions input,
.resize-dimensions select,
.resize-output-settings input,
.resize-output-settings select {
    min-width: 0;
}

.resize-dimensions span,
.resize-dimensions label {
    color: var(--muted);
    font-size: .92rem;
    font-weight: 700;
    white-space: nowrap;
}

#resizeUploadForm button {
    margin: 0;
}

.resize-output-settings {
    display: grid;
    grid-template-columns: minmax(150px, .92fr) minmax(170px, 1.08fr);
    align-items: end;
    gap: 10px;
}

.resize-quality-field span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.resize-quality-field b {
    color: var(--primary);
    font-weight: 800;
}

#resizeQuality {
    width: 100%;
    accent-color: var(--primary);
}

#resizeQuality:disabled {
    cursor: not-allowed;
    opacity: .52;
}

.resize-note {
    display: block;
    margin: 0;
    color: #7a8695;
    font-size: .86rem;
    line-height: 1.45;
}

#resizeWidth,
#resizeHeight,
#resizeDpi {
    width: 100% !important;
}

#frameLibrary {
    --frame-card-size: 112px;
    min-height: 0;
    margin-top: 6px;
    padding: 12px;
    max-height: calc((var(--frame-card-size) + 10px) * 6 + 90px);
    overflow-y: auto;
    overscroll-behavior: contain;
    background: var(--surface-muted);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.frame-category-title {
    margin: 14px 0 8px;
    padding: 8px 10px;
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1f5b9f;
    font-size: var(--font-size-heading);
    font-weight: 800;
    background: linear-gradient(90deg, #edf5ff, #f7fbff);
    border: 1px solid rgba(37, 111, 217, .12);
    border-radius: var(--radius);
    transition: background .18s ease, border-color .18s ease, box-shadow .18s ease;
}

.frame-category:first-child .frame-category-title {
    margin-top: 0;
}

.frame-category-title svg {
    width: 18px;
    height: 18px;
    flex: 0 0 auto;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.9;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.frame-category-title a,
.frame-category-title span {
    min-width: 0;
    color: inherit;
    text-decoration: none;
    transition: color .18s ease, transform .18s ease;
}

.frame-category-title a:hover,
.frame-category-title a:focus-visible {
    color: #174a88;
    text-decoration: none;
    transform: translateX(2px);
}

.frame-category-title:has(a:hover),
.frame-category-title:has(a:focus-visible) {
    background: linear-gradient(90deg, #e7f1ff, #f6fbff);
    border-color: rgba(37, 111, 217, .22);
    box-shadow: 0 5px 14px rgba(31, 91, 159, .08);
}

.frame-category {
    margin-bottom: 14px;
}

.frame-carousel {
    position: relative;
}

.frame-grid {
    display: grid;
    grid-template-rows: repeat(2, auto);
    grid-template-columns: repeat(4, calc((100% - 30px) / 4));
    grid-auto-columns: calc((100% - 30px) / 4);
    gap: 10px;
    margin: 0;
    overflow-x: auto;
    overflow-y: hidden;
    overscroll-behavior-inline: contain;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(37, 111, 217, .35) transparent;
}

.frame-grid::-webkit-scrollbar {
    height: 6px;
}

.frame-grid::-webkit-scrollbar-thumb {
    border-radius: 999px;
    background: rgba(37, 111, 217, .35);
}

.frame-carousel-arrow {
    width: 34px;
    height: 34px;
    min-height: 34px;
    padding: 0;
    position: absolute;
    top: calc(50% - 17px);
    z-index: 4;
    display: none;
    place-items: center;
    color: var(--primary);
    background: rgba(255, 255, 255, .94);
    border: 1px solid rgba(37, 111, 217, .2);
    border-radius: 999px;
    box-shadow: 0 8px 18px rgba(27, 57, 96, .16);
}

.frame-carousel.has-overflow .frame-carousel-arrow {
    display: grid;
}

.frame-carousel-prev {
    left: -8px;
}

.frame-carousel-next {
    right: -8px;
}

.frame-carousel-arrow svg {
    width: 19px;
    height: 19px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.4;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.frame-carousel-arrow:disabled {
    opacity: .35;
    cursor: default;
    transform: none;
}

.frame-item {
    position: relative;
    min-width: 0;
    scroll-snap-align: start;
}

.frame-thumb-shell {
    position: relative;
    aspect-ratio: 1 / 1;
}

.frame-thumb {
    width: 100%;
    height: 100%;
    aspect-ratio: 1 / 1;
    display: block;
    object-fit: contain;
    border: 1px solid #d9e3ee;
    border-radius: var(--radius);
    background: #fff;
    box-shadow: 0 4px 12px rgba(36, 58, 86, .08);
    cursor: pointer;
    transition: transform .16s ease, border-color .16s ease, box-shadow .16s ease;
}

.frame-creator-name {
    max-width: 100%;
    min-height: 18px;
    margin-top: 4px;
    display: block;
    color: var(--muted);
    font-size: 11px;
    font-weight: 750;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

.frame-use-count {
    position: absolute;
    left: 6px;
    bottom: 6px;
    z-index: 2;
    max-width: calc(100% - 46px);
    padding: 3px 6px;
    border-radius: 999px;
    color: #fff;
    background: rgba(18, 35, 57, .72);
    font-size: 10px;
    font-weight: 850;
    line-height: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
}

.frame-hover-name {
    position: absolute;
    top: 6px;
    left: 6px;
    right: 6px;
    z-index: 3;
    padding: 4px 6px;
    border-radius: 999px;
    color: #fff;
    background: rgba(30, 95, 174, .9);
    box-shadow: 0 4px 12px rgba(18, 35, 57, .16);
    font-size: 10px;
    font-weight: 850;
    line-height: 1.15;
    text-align: center;
    opacity: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    transform: translateY(-4px);
    transition: opacity .16s ease, transform .16s ease;
    pointer-events: none;
}

.frame-thumb-shell:hover .frame-hover-name,
.frame-item:focus-within .frame-hover-name {
    opacity: 1;
    transform: translateY(0);
}

.frame-thumb:hover,
.frame-thumb.active {
    border-color: var(--primary);
    box-shadow: 0 8px 18px rgba(37, 111, 217, .16);
    transform: translateY(-1px);
}

.frame-thumb.active {
    outline: 3px solid rgba(37, 111, 217, .28);
    outline-offset: 2px;
}

.frame-hover-zoom {
    position: fixed;
    z-index: 90000;
    aspect-ratio: 1 / 1;
    padding: 10px;
    display: grid;
    place-items: center;
    border: 1px solid rgba(37, 111, 217, .28);
    border-radius: var(--radius);
    background:
        linear-gradient(45deg, rgba(226, 235, 247, .5) 25%, transparent 25%),
        linear-gradient(-45deg, rgba(226, 235, 247, .5) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, rgba(226, 235, 247, .5) 75%),
        linear-gradient(-45deg, transparent 75%, rgba(226, 235, 247, .5) 75%),
        #fff;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0;
    background-size: 20px 20px;
    box-shadow: 0 18px 42px rgba(10, 24, 43, .22);
    opacity: 0;
    pointer-events: none;
    transform: scale(.92);
    transform-origin: center;
    transition: opacity .14s ease, transform .14s ease;
}

.frame-hover-zoom.is-visible {
    opacity: 1;
    transform: scale(1);
}

.frame-hover-zoom img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: contain;
}

.frame-hover-zoom-label {
    max-width: calc(100% - 18px);
    padding: 4px 8px;
    position: absolute;
    left: 9px;
    right: 9px;
    bottom: 9px;
    border-radius: 999px;
    color: #fff;
    background: rgba(18, 35, 57, .74);
    font-size: 11px;
    font-weight: 850;
    line-height: 1.1;
    text-align: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.frame-share-button {
    width: 30px;
    height: 30px;
    min-height: 30px;
    padding: 0;
    position: absolute;
    right: 6px;
    bottom: 6px;
    display: grid;
    place-items: center;
    color: var(--primary);
    background: rgba(255,255,255,.95);
    border: 1px solid rgba(37, 111, 217, .18);
    border-radius: 999px;
    box-shadow: 0 4px 12px rgba(34, 44, 58, .14);
}

.frame-share-button svg {
    width: 17px;
    height: 17px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.frame-share-button.is-copied {
    color: #fff;
    background: var(--success);
}

.copy-frame-toast {
    min-width: min(280px, calc(100vw - 20px));
    max-width: min(320px, calc(100vw - 20px));
    padding: 9px 12px;
    position: fixed;
    z-index: 100004;
    pointer-events: none;
    border: 1px solid rgba(18, 153, 106, .24);
    border-radius: var(--radius);
    color: #0f6548;
    background: #ecfff7;
    box-shadow: 0 12px 30px rgba(20, 70, 54, .18);
    font-size: .88rem;
    font-weight: 750;
    line-height: 1.35;
    opacity: 0;
    transform: translateY(4px) scale(.98);
    transition: opacity .16s ease, transform .16s ease;
}

.copy-frame-toast.is-visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.external-browser-notice {
    position: fixed;
    inset: 0;
    z-index: 100012;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 18px;
    background: rgba(16, 31, 50, .58);
    backdrop-filter: blur(5px);
}

.external-browser-notice.is-open {
    display: flex;
}

.external-browser-dialog {
    width: min(460px, 100%);
    position: relative;
    padding: 22px;
    border: 1px solid rgba(37, 111, 217, .18);
    border-radius: 12px;
    color: #172b44;
    background: #fff;
    box-shadow: 0 24px 70px rgba(15, 32, 55, .28);
}

.external-browser-dialog strong {
    display: block;
    margin: 0 42px 10px 0;
    color: #1f5f9f;
    font-family: var(--font-heading);
    font-size: 1.1rem;
}

.external-browser-dialog p,
.external-browser-dialog li {
    color: #5f6f85;
    font-size: .94rem;
    line-height: 1.55;
}

.external-browser-dialog ol {
    margin: 10px 0 0;
    padding-left: 20px;
}

.external-browser-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 34px;
    height: 34px;
    border: 0;
    border-radius: 8px;
    color: #5f6f85;
    background: #eef3f8;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
}

.external-browser-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 16px;
}

.external-browser-actions button {
    min-height: 42px;
    padding: 10px 14px;
    border-radius: 8px;
    font-weight: 800;
    cursor: pointer;
}

.external-browser-primary {
    border: 1px solid #256fd9;
    color: #fff;
    background: #256fd9;
}

.external-browser-secondary {
    border: 1px solid #d9e3ee;
    color: #1f5f9f;
    background: #f8fbff;
}

.frame-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 30px;
    height: 30px;
    border-radius: 999px;
    display: grid;
    place-items: center;
    background: rgba(255,255,255,.95);
    color: var(--danger);
    font-size: 1.25rem;
    font-weight: 800;
    line-height: 1;
    box-shadow: 0 4px 12px rgba(34, 44, 58, .14);
    cursor: pointer;
}

#photoPreview,
#resizePreview,
#cartoonPreview,
#resultPreview {
    width: 100%;
}

#resizePreview {
    min-height: 0;
    margin: 10px 0 12px !important;
    position: relative;
}

#cartoonPreview {
    min-height: 0;
    margin: 10px 0 0;
}

#photoPreview {
    min-height: 0;
    margin: 10px 0 4px;
    display: flex;
    align-items: center;
    gap: 10px;
}

#photoPreview img,
#resizePreview img,
#cartoonPreview img,
#resultPreview img {
    max-width: 100%;
    height: auto;
    margin-top: 8px;
    border-radius: var(--radius);
    background: #fff;
    box-shadow: 0 8px 24px rgba(30, 80, 160, 0.12);
}

#resultPreview img {
    width: auto;
    max-width: min(92%, 620px);
    max-height: min(66vh, 620px);
    object-fit: contain;
    border-radius: var(--radius) !important;
}

#photoPreview img {
    width: 82px !important;
    max-width: 82px !important;
    aspect-ratio: 1 / 1;
    object-fit: cover;
    border-radius: 14px !important;
    cursor: zoom-in;
    position: relative;
    z-index: 2;
    transition: transform .18s ease, box-shadow .18s ease;
    transform-origin: left center;
}

#photoPreview img:hover {
    z-index: 80;
    transform: scale(2.35);
    box-shadow: 0 18px 42px rgba(15, 32, 54, .28);
}

.resize-preview-card {
    position: relative;
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    align-items: center;
    gap: 10px;
    padding: 8px;
    border: 1px solid rgba(220, 229, 239, .96);
    border-radius: var(--radius);
    background: #f8fbff;
    box-shadow: 0 8px 20px rgba(30, 80, 160, .08);
}

.cartoon-preview-card {
    background: #fffdf8;
    border-color: rgba(244, 223, 197, .96);
}

.resize-preview-thumb {
    width: 76px;
    height: 58px;
    overflow: hidden;
    border-radius: 7px;
    background: #fff;
    box-shadow: inset 0 0 0 1px rgba(220, 229, 239, .9);
}

#resizePreview .resize-preview-thumb img,
#cartoonPreview .resize-preview-thumb img {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    object-fit: cover;
    border-radius: 7px !important;
    box-shadow: none;
}

.resize-preview-meta {
    min-width: 0;
    display: grid;
    gap: 2px;
    color: #5e6c7e;
    font-size: .86rem;
    line-height: 1.32;
}

.resize-preview-meta strong {
    color: #25364c;
    font-size: .94rem;
    font-weight: 800;
}

.resize-preview-meta span {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.resize-hover-preview {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    z-index: 90;
    width: min(340px, calc(100vw - 48px));
    padding: 8px;
    border: 1px solid rgba(185, 202, 222, .95);
    border-radius: var(--radius);
    background: rgba(255, 255, 255, .98);
    box-shadow: 0 18px 42px rgba(15, 32, 54, .24);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(4px) scale(.98);
    transform-origin: bottom right;
    transition: opacity .16s ease, transform .16s ease, visibility .16s ease;
}
