@font-face {
    font-family: "Sora";
    src: url("../fonts/sora/sora-latin-400-normal.woff2") format("woff2");
    font-style: normal;
    font-weight: 400;
    font-display: swap;
}

@font-face {
    font-family: "Sora";
    src: url("../fonts/sora/sora-latin-600-normal.woff2") format("woff2");
    font-style: normal;
    font-weight: 600;
    font-display: swap;
}

@font-face {
    font-family: "Sora";
    src: url("../fonts/sora/sora-latin-700-normal.woff2") format("woff2");
    font-style: normal;
    font-weight: 700;
    font-display: swap;
}

:root {
    color-scheme: light;
    font-family: "Sora", "Microsoft YaHei", "PingFang SC", sans-serif;
    color: #1b1b1b;
    background: #f9f9f9;
    --surface: #f9f9f9;
    --surface-low: #f3f3f3;
    --surface-container: #eeeeee;
    --surface-high: #e8e8e8;
    --surface-highest: #e2e2e2;
    --white: #ffffff;
    --ink: #1b1b1b;
    --muted: #5c5758;
    --outline: #cfc4c5;
    --outline-strong: #7e7576;
    --black: #000000;
    --error: #ba1a1a;
    --success: #19723b;
    --shadow: 0 8px 28px rgba(0, 0, 0, 0.07);
    --dot-pointer-x: 50vw;
    --dot-pointer-y: 50vh;
}

* {
    box-sizing: border-box;
}

html,
body {
    min-width: 320px;
    min-height: 100%;
    margin: 0;
}

body {
    position: relative;
    min-height: 100vh;
    background:
        radial-gradient(circle at 10% 16%, rgba(0, 0, 0, 0.025), transparent 26rem),
        radial-gradient(circle at 88% 82%, rgba(0, 0, 0, 0.022), transparent 30rem),
        var(--surface);
}

/*
 * 上传首页和结果编辑页共用同一套固定点阵。背景层不接收指针事件，避免影响文件拖拽、
 * 画布缩放和贴纸操作；固定定位也能让较长的结果页滚动时保持稳定，减少视觉抖动。
 */
body::before,
body::after {
    content: "";
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    background-image: radial-gradient(circle, rgba(27, 27, 27, 0.15) 1px, transparent 1.15px);
    background-position: 12px 12px;
    background-size: 24px 24px;
}

/* 静态底层保持较低对比度，只为页面留白增加细微的空间层次。 */
body::before {
    opacity: 0.58;
}

/*
 * 高亮层使用与静态层完全一致的网格，只通过径向遮罩显露鼠标附近更深的点，
 * 因此点的位置不会发生移动。标准属性与 WebKit 前缀同时保留以兼容主流浏览器。
 */
body::after {
    background-image: radial-gradient(circle, rgba(27, 27, 27, 0.46) 1px, transparent 1.15px);
    opacity: 0;
    transition: opacity 180ms ease;
    -webkit-mask-image: radial-gradient(
        circle 180px at var(--dot-pointer-x) var(--dot-pointer-y),
        #000 0%,
        rgba(0, 0, 0, 0.78) 42%,
        transparent 100%
    );
    mask-image: radial-gradient(
        circle 180px at var(--dot-pointer-x) var(--dot-pointer-y),
        #000 0%,
        rgba(0, 0, 0, 0.78) 42%,
        transparent 100%
    );
}

body[data-dot-pointer-active="true"]::after {
    opacity: 1;
}

button,
input {
    font: inherit;
}

button {
    color: inherit;
}

button:focus-visible,
[tabindex]:focus-visible {
    outline: 2px solid #000;
    outline-offset: 3px;
}

[hidden] {
    display: none !important;
}

.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

.view {
    position: relative;
    z-index: 1;
    min-height: 100vh;
}

.site-header,
.editor-header {
    height: 76px;
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid #ebe7e7;
    backdrop-filter: blur(16px);
}

.site-header {
    position: sticky;
    top: 0;
    z-index: 50;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: var(--black);
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.035em;
    text-decoration: none;
}

button.brand {
    padding: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
}

.brand-mark {
    width: 32px;
    height: 32px;
    display: block;
    flex: 0 0 auto;
}

.header-actions,
.editor-export-group,
.editor-brand-group {
    display: flex;
    align-items: center;
}

.header-actions,
.editor-export-group {
    gap: 14px;
}

.model-status {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    min-height: 34px;
    padding: 0 13px;
    color: var(--muted);
    background: var(--surface-low);
    border: 1px solid var(--outline);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.model-status::before {
    content: "";
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #9b9697;
}

.model-status[data-state="ready"]::before {
    background: var(--success);
}

.model-status[data-state="error"]::before {
    background: var(--error);
}

.language-button,
.icon-button {
    min-width: 42px;
    height: 38px;
    padding: 0 10px;
    border: 1px solid var(--outline);
    border-radius: 999px;
    background: #fff;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: 150ms ease;
}

/*
 * 语言入口使用真实链接而不是脚本按钮，便于搜索引擎发现另一语言页面。
 * 显式声明对齐与文本样式，确保链接形态和原按钮在两套页面中保持一致。
 */
.language-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: inherit;
    text-decoration: none;
}

.language-button:hover,
.icon-button:hover {
    border-color: #000;
    transform: translateY(-1px);
}

.upload-view {
    min-height: 100vh;
    min-height: 100dvh;
    display: flex;
    flex-direction: column;
}

.upload-main {
    width: min(1180px, calc(100% - 48px));
    margin: 0 auto;
    padding: clamp(22px, 4.4vh, 48px) 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.hero {
    max-width: 920px;
    margin: 0 auto clamp(18px, 3.8vh, 42px);
    flex: 0 0 auto;
    text-align: center;
}

.privacy-chip {
    width: fit-content;
    min-height: 32px;
    margin: 0 auto 24px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    gap: 11px;
    color: #646060;
    background: rgba(238, 238, 238, 0.78);
    border: 1px solid var(--outline);
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.chip-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    background: #171717;
}

.hero h1 {
    max-width: 900px;
    margin: 0 auto 20px;
    font-size: clamp(38px, 4vw, 58px);
    line-height: 1.08;
    letter-spacing: -0.055em;
    font-weight: 400;
}

.hero p {
    max-width: 760px;
    margin: 0 auto;
    color: var(--muted);
    font-size: 17px;
    line-height: 1.55;
}

.drop-zone {
    --scan-frame-inset: 22px;
    --scan-frame-size: 36px;
    --scan-line-gap: 16px;
    --scan-band-opacity: 0.52;
    position: relative;
    isolation: isolate;
    width: min(920px, 100%);
    min-height: 300px;
    max-height: 430px;
    margin: 0 auto;
    padding: 44px 36px 36px;
    flex: 0 1 430px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    background: rgba(232, 232, 232, 0.82);
    border: 1px solid transparent;
    border-radius: 24px;
    box-shadow: 0 12px 36px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    transition: 180ms ease;
}

/*
 * 上传框的静态装饰层由八段短线组成四角取景框，并在下层铺设横向扫描纹理。
 * 中央径向底色会柔化文案与按钮背后的线条，保证装饰增加层次但不影响信息阅读。
 */
.drop-zone::before {
    content: "";
    position: absolute;
    inset: var(--scan-frame-inset);
    z-index: 0;
    pointer-events: none;
    background:
        linear-gradient(rgba(27, 27, 27, 0.34) 0 0) left top / var(--scan-frame-size) 1px no-repeat,
        linear-gradient(rgba(27, 27, 27, 0.34) 0 0) left top / 1px var(--scan-frame-size) no-repeat,
        linear-gradient(rgba(27, 27, 27, 0.34) 0 0) right top / var(--scan-frame-size) 1px no-repeat,
        linear-gradient(rgba(27, 27, 27, 0.34) 0 0) right top / 1px var(--scan-frame-size) no-repeat,
        linear-gradient(rgba(27, 27, 27, 0.34) 0 0) left bottom / var(--scan-frame-size) 1px no-repeat,
        linear-gradient(rgba(27, 27, 27, 0.34) 0 0) left bottom / 1px var(--scan-frame-size) no-repeat,
        linear-gradient(rgba(27, 27, 27, 0.34) 0 0) right bottom / var(--scan-frame-size) 1px no-repeat,
        linear-gradient(rgba(27, 27, 27, 0.34) 0 0) right bottom / 1px var(--scan-frame-size) no-repeat,
        radial-gradient(ellipse 44% 68% at center, rgba(232, 232, 232, 0.96) 0 48%, rgba(232, 232, 232, 0.58) 67%, transparent 88%),
        /* 使用清爽的天蓝色增强静态扫描纹理，在浅灰背景上保持清晰且不过分刺眼。 */
        repeating-linear-gradient(to bottom, rgba(56, 189, 248, 0.18) 0 1px, transparent 1px var(--scan-line-gap));
    opacity: 0.64;
    transition: opacity 180ms ease;
}

/*
 * 光带本身覆盖完整的内部区域，只移动一张 72px 高的渐变背景，因此无需新增 DOM。
 * 伪元素始终忽略指针事件，文件拖拽、按钮点击和键盘焦点都由原控件正常接收。
 */
.drop-zone::after {
    content: "";
    position: absolute;
    inset: var(--scan-frame-inset);
    z-index: 1;
    pointer-events: none;
    background:
        linear-gradient(
            to bottom,
            transparent 0%,
            rgba(125, 211, 252, 0.26) 40%,
            rgba(56, 189, 248, 0.48) 49%,
            rgba(186, 230, 253, 0.32) 52%,
            transparent 100%
        ) center -72px / 100% 72px no-repeat;
    animation: drop-zone-scan 5.8s ease-in-out infinite;
}

/* 原有内容统一置于两层装饰之上，避免伪元素建立后改变任何控件的命中区域。 */
.drop-zone > * {
    position: relative;
    z-index: 2;
}

@keyframes drop-zone-scan {
    0%,
    12% {
        background-position: center -72px;
        opacity: 0;
    }

    22%,
    78% {
        opacity: var(--scan-band-opacity);
    }

    88%,
    100% {
        background-position: center calc(100% + 72px);
        opacity: 0;
    }
}

.drop-zone[data-active="true"] {
    border-color: #000;
    background: #ededed;
    transform: scale(1.005);
}

/* 文件进入拖拽区域后加快扫描并增强取景框，让接收状态更明确。 */
.drop-zone[data-active="true"]::before {
    opacity: 0.88;
}

.drop-zone[data-active="true"]::after {
    animation-duration: 1.9s;
    filter: contrast(1.45);
}

.upload-symbol {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    display: grid;
    place-items: center;
    color: #686465;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(126, 117, 118, 0.45);
    border-radius: 16px;
}

.upload-symbol img {
    width: 38px;
    height: 38px;
    display: block;
    opacity: 0.72;
}

.drop-zone h2 {
    margin: 0 0 10px;
    font-size: clamp(22px, 2vw, 28px);
    line-height: 1.2;
    font-weight: 400;
    letter-spacing: -0.035em;
}

.drop-zone > p:not(.upload-status) {
    max-width: 650px;
    margin: 0 0 24px;
    color: var(--muted);
    font-size: 14px;
    line-height: 1.55;
}

.split-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    width: min(360px, 100%);
    border: 2px solid #000;
    border-radius: 999px;
    overflow: hidden;
    background: #fff;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.09);
}

.split-actions button {
    min-height: 44px;
    padding: 7px 14px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 9px;
    border: 0;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
}

.primary-action {
    color: #fff;
    background: #000;
}

.secondary-action {
    color: #000;
    background: #fff;
}

.split-actions button:hover {
    filter: brightness(0.92);
}

.button-icon {
    width: 16px;
    height: 16px;
    display: block;
    flex: 0 0 16px;
}

.primary-action .button-icon {
    filter: invert(1);
}

.upload-status {
    min-height: 18px;
    margin: 14px 0 0 !important;
    color: var(--error) !important;
    font-size: 12px !important;
    font-weight: 600;
}

.seo-content {
    width: min(1040px, 100%);
    margin: 80px auto 32px;
    color: var(--ink);
}

.seo-intro {
    max-width: 800px;
    margin-bottom: 34px;
}

.section-eyebrow {
    margin: 0 0 10px;
    color: var(--muted);
    font-size: 12px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
}

.seo-content h2 {
    margin: 0 0 14px;
    font-size: clamp(26px, 3vw, 38px);
    line-height: 1.2;
    letter-spacing: -0.04em;
}

.seo-intro > p:last-child,
.feature-grid p,
.how-to li,
.faq p {
    color: var(--muted);
    font-size: 15px;
    line-height: 1.75;
}

.seo-intro > p:last-child {
    margin: 0;
}

.feature-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
}

.feature-grid article {
    padding: 24px;
    background: rgba(255, 255, 255, 0.86);
    border: 1px solid var(--outline);
    border-radius: 18px;
}

.feature-grid h3 {
    margin: 0 0 9px;
    font-size: 18px;
}

.feature-grid p {
    margin: 0;
}

.how-to,
.faq {
    margin-top: 56px;
}

.how-to ol {
    margin: 22px 0 0;
    padding: 0;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 16px;
    list-style-position: inside;
}

.how-to li {
    padding: 22px;
    background: var(--surface-low);
    border-radius: 16px;
}

.how-to strong {
    color: var(--ink);
}

.faq-list {
    border-top: 1px solid var(--outline);
}

.faq details {
    border-bottom: 1px solid var(--outline);
}

.faq summary {
    padding: 20px 42px 20px 0;
    position: relative;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
}

.faq summary::after {
    content: "+";
    position: absolute;
    top: 50%;
    right: 10px;
    font-size: 22px;
    font-weight: 400;
    transform: translateY(-50%);
}

.faq details[open] summary::after {
    content: "−";
}

.faq p {
    max-width: 820px;
    margin: -4px 0 20px;
}

.site-footer,
.editor-footer {
    min-height: 72px;
    padding: 18px 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 24px;
    color: #625d5e;
    background: rgba(249, 249, 249, 0.88);
    border-top: 1px solid var(--outline);
    font-size: 13px;
}

.site-header,
.site-footer {
    flex: 0 0 auto;
}

.site-footer > div,
.editor-footer > span {
    display: flex;
    align-items: center;
    gap: 12px;
}

.footer-divider {
    width: 1px;
    height: 24px;
    background: var(--outline);
}

.icp-link {
    color: inherit;
    text-decoration: none;
    white-space: nowrap;
}

.icp-link:hover {
    color: var(--text);
}

/* 编辑器严格沿用参考结果页的横向工具栏、棋盘画布和底部贴纸面板。 */
.editor-view {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    /* 结果页透出公共点阵；棋盘画布和各功能面板仍由自身实体背景完整遮挡。 */
    background: transparent;
}

.editor-header {
    position: sticky;
    top: 0;
    z-index: 50;
    height: 72px;
    padding: 0 24px;
}

.editor-brand {
    font-size: 23px;
}

.header-separator {
    width: 1px;
    height: 30px;
    margin: 0 20px;
    background: var(--outline);
}

.editor-version {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.13em;
    text-transform: uppercase;
}

.text-action {
    padding: 8px 0;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    border: 0;
    background: transparent;
    font-size: 13px;
    cursor: pointer;
}

.text-action:disabled,
.nav-button:disabled,
.apply-all-button:disabled,
.export-menu button:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.auto-mask-control {
    display: inline-grid;
    grid-template-rows: 34px 16px;
    align-items: center;
    /* 每个网格项分别水平居中，避免较窄的开关轨道贴在较宽标签列的左侧。 */
    justify-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

.auto-mask-control input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

/* 开关下方只保留当前模式标签，并预留稳定行高，切换中英文时操作栏不会上下跳动。 */
.mask-mode-label {
    min-width: 76px;
    color: var(--ink);
    line-height: 16px;
    text-align: center;
    white-space: nowrap;
}

/* 开关轨道放入与批量操作图标等高的槽位中，轨道本身仍保持原来的紧凑尺寸。 */
.toggle-slot {
    width: 46px;
    height: 34px;
    display: grid;
    place-items: center;
}

.toggle-track {
    position: relative;
    width: 46px;
    height: 26px;
    background: #ddd;
    border-radius: 999px;
    transition: 160ms ease;
}

.toggle-track::after {
    content: "";
    position: absolute;
    top: 4px;
    left: 4px;
    width: 18px;
    height: 18px;
    background: #fff;
    border-radius: 50%;
    box-shadow: 0 1px 5px rgba(0, 0, 0, 0.24);
    transition: 160ms ease;
}

.auto-mask-control input:checked ~ .toggle-slot .toggle-track {
    background: #000;
}

.auto-mask-control input:checked ~ .toggle-slot .toggle-track::after {
    transform: translateX(20px);
}

/* 隐藏原生复选框后，将键盘焦点轮廓转移到可见轨道，确保 Tab 操作时仍能明确识别当前位置。 */
.auto-mask-control input:focus-visible ~ .toggle-slot .toggle-track {
    outline: 2px solid #000;
    outline-offset: 3px;
}

.export-button {
    min-width: 112px;
    height: 42px;
    padding: 0 18px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    color: #fff;
    background: linear-gradient(135deg, #000 0 56%, #444 56% 100%);
    border: 0;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 700;
    cursor: pointer;
}

.export-menu-wrap {
    position: relative;
}

.export-menu {
    position: absolute;
    top: calc(100% + 10px);
    right: 0;
    z-index: 80;
    width: 210px;
    padding: 8px;
    background: #fff;
    border: 1px solid var(--outline);
    border-radius: 12px;
    box-shadow: var(--shadow);
}

.export-menu button {
    width: 100%;
    padding: 12px 14px;
    border: 0;
    border-radius: 8px;
    background: transparent;
    text-align: left;
    font-size: 13px;
    cursor: pointer;
}

.export-menu button:hover:not(:disabled) {
    background: var(--surface-low);
}

.editor-main {
    width: min(1400px, calc(100% - 40px));
    margin: 0 auto;
    padding: 18px 0;
    flex: 1;
}

.batch-bar {
    min-height: 56px;
    margin-bottom: 12px;
    padding: 6px 8px;
    display: grid;
    grid-template-columns: auto minmax(180px, 260px) 1fr auto;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid var(--outline);
    border-radius: 15px;
}

.nav-button {
    width: 38px;
    height: 38px;
    border: 1px solid var(--outline);
    border-radius: 50%;
    background: #fff;
    font-size: 18px;
    cursor: pointer;
}

.batch-copy {
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.batch-copy strong {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 13px;
}

.batch-copy span {
    color: var(--muted);
    font-size: 11px;
}

.thumbnail-strip {
    min-width: 0;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: thin;
}

.thumbnail-button {
    position: relative;
    flex: 0 0 40px;
    width: 40px;
    height: 40px;
    padding: 2px;
    overflow: hidden;
    border: 2px solid transparent;
    border-radius: 9px;
    background: var(--surface-container);
    cursor: pointer;
}

.thumbnail-button[aria-selected="true"] {
    border-color: #000;
}

.thumbnail-button img {
    width: 100%;
    height: 100%;
    display: block;
    object-fit: cover;
    border-radius: 5px;
}

.thumbnail-state {
    position: absolute;
    right: 2px;
    bottom: 2px;
    width: 10px;
    height: 10px;
    border: 2px solid #fff;
    border-radius: 50%;
    background: #999;
}

.thumbnail-state[data-state="ready"] {
    background: var(--success);
}

.thumbnail-state[data-state="detecting"] {
    background: #d69b00;
}

.thumbnail-state[data-state="error"] {
    background: var(--error);
}

.canvas-shell {
    position: relative;
    min-height: min(58vh, 650px);
    padding: 4px;
    display: flex;
    align-items: stretch;
    background-color: #fff;
    background-image:
        linear-gradient(45deg, #ececec 25%, transparent 25%),
        linear-gradient(-45deg, #ececec 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, #ececec 75%),
        linear-gradient(-45deg, transparent 75%, #ececec 75%);
    background-size: 24px 24px;
    background-position: 0 0, 0 12px, 12px -12px, -12px 0;
    border: 1px solid var(--outline);
    border-radius: 20px;
    overflow: hidden;
}

.canvas-viewport {
    position: relative;
    width: 100%;
    min-height: inherit;
    padding: 18px 84px 18px 18px;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: auto;
    overscroll-behavior: contain;
}

.canvas-viewport .canvas-container {
    flex: 0 0 auto;
    /* Fabric 容器仅负责裁切内部内容，视觉边框统一由外层棋盘画布提供。 */
    background: transparent;
    overflow: hidden;
}

/* 图片切换时隐藏 Fabric 的中间状态，只展示完成居中和适配后的最终画面。 */
.canvas-viewport.is-switching-image .canvas-container {
    visibility: hidden;
}

.canvas-loading {
    position: absolute;
    inset: 0;
    z-index: 12;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    color: var(--muted);
    /*
     * 切换图片时只保留加载提示，不再覆盖半透明白底或模糊画布区域。
     * 这样画布容器短暂隐藏时会直接露出原有棋盘背景，避免产生明显的整块白色闪烁。
     */
    background: transparent;
    font-size: 13px;
    font-weight: 600;
    backdrop-filter: none;
}

.spinner {
    width: 20px;
    height: 20px;
    border: 2px solid #ccc;
    border-top-color: #000;
    border-radius: 50%;
    animation: spin 700ms linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.canvas-toolbar {
    position: absolute;
    top: 50%;
    right: 18px;
    z-index: 20;
    /* 桌面端为英文工具名称预留足够空间，避免 Undo、Zoom out 等文本被省略。 */
    width: 112px;
    padding: 7px 6px;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    background: rgba(255, 255, 255, 0.94);
    border: 1px solid var(--outline);
    border-radius: 13px;
    box-shadow: var(--shadow);
    transform: translateY(-50%);
}

.canvas-toolbar button {
    width: 100%;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 0 7px;
    border: 0;
    border-radius: 10px;
    background: transparent;
    font-size: 17px;
    text-align: left;
    cursor: pointer;
}

.canvas-toolbar button:hover {
    color: #fff;
    background: #000;
}

.canvas-toolbar button:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.canvas-toolbar button:disabled:hover {
    color: inherit;
    background: transparent;
}

.toolbar-icon {
    width: 18px;
    height: 18px;
    display: block;
}

.toolbar-label {
    min-width: 0;
    flex: 1 1 auto;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
    white-space: nowrap;
}

.canvas-toolbar button:hover:not(:disabled) .toolbar-icon {
    filter: invert(1);
}

.toolbar-divider {
    width: calc(100% - 12px);
    height: 1px;
    align-self: center;
    background: var(--outline);
}

.canvas-toolbar output {
    width: 100%;
    margin-top: 4px;
    padding: 0 7px;
    color: var(--muted);
    font-size: 10px;
    font-weight: 700;
    /* 缩放比例与工具按钮内容使用同一左侧内边距，便于纵向扫视。 */
    text-align: left;
}

.detection-status {
    position: absolute;
    left: 20px;
    bottom: 18px;
    z-index: 20;
    min-height: 34px;
    padding: 8px 13px;
    color: #fff;
    background: rgba(0, 0, 0, 0.78);
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    backdrop-filter: blur(8px);
}

.detection-status[data-state="error"] {
    background: rgba(142, 15, 15, 0.9);
}

.sticker-panel {
    min-height: 94px;
    margin-top: 14px;
    padding: 12px 16px;
    display: grid;
    grid-template-columns: 150px 1fr 1px auto;
    align-items: center;
    gap: 14px;
    background: #fff;
    border: 1px solid var(--outline);
    border-radius: 17px;
    box-shadow: 0 5px 14px rgba(0, 0, 0, 0.08);
}

.sticker-heading-wrap {
    padding-right: 18px;
    border-right: 1px solid var(--outline);
}

.eyebrow {
    display: block;
    margin-bottom: 0;
    color: inherit;
    font-size: 15px;
    font-weight: 700;
    line-height: 1.2;
    letter-spacing: normal;
    text-transform: none;
}

.sticker-list {
    min-width: 0;
    display: flex;
    gap: 9px;
    overflow-x: auto;
    padding: 4px 0;
    scrollbar-width: thin;
}

.sticker-button {
    flex: 0 0 50px;
    width: 50px;
    height: 50px;
    padding: 8px;
    display: grid;
    place-items: center;
    background: var(--surface-container);
    border: 1px solid var(--outline);
    border-radius: 11px;
    /* 特殊比例贴纸可在按钮内放大预览，超出部分仅裁切透明画布，不影响真实贴纸尺寸。 */
    overflow: hidden;
    cursor: pointer;
    transition: 140ms ease;
}

.sticker-button:hover,
.sticker-button[aria-pressed="true"] {
    border-color: #000;
    background: #fff;
    transform: translateY(-2px);
}

.sticker-button img {
    width: 34px;
    height: 34px;
    display: block;
    transform: scale(var(--sticker-preview-scale, 1));
}

.sticker-divider {
    align-self: stretch;
    background: var(--outline);
}

/*
 * 贴纸操作栏把“应用方式”和“批量应用”收拢为一个完整功能组。
 * 桌面端保持横向紧凑排列；分隔线由组内承担，避免开关从页头移入后与贴纸选择区混在一起。
 */
.sticker-operation-bar {
    min-width: 244px;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 14px;
}

.sticker-operation-bar .auto-mask-control {
    padding: 8px 14px 8px 0;
    border-right: 1px solid var(--outline);
}

.apply-all-button {
    min-width: 126px;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    border: 0;
    background: transparent;
    font-size: 11px;
    font-weight: 600;
    cursor: pointer;
}

/* 两个操作项的标签使用相同文字行高，与上方统一的 34px 图标槽共同锁定基线。 */
.apply-all-button > span:last-child {
    line-height: 16px;
    white-space: nowrap;
}

.apply-all-icon-wrap {
    width: 34px;
    height: 34px;
    display: grid;
    place-items: center;
    border: 1px solid var(--outline);
    border-radius: 50%;
}

.apply-all-icon {
    width: 17px;
    height: 17px;
    display: block;
}

.editor-message {
    min-height: 22px;
    margin: 14px 6px 0;
    color: var(--muted);
    font-size: 12px;
    text-align: center;
}

.toast {
    position: fixed;
    left: 50%;
    bottom: 30px;
    z-index: 200;
    max-width: min(520px, calc(100% - 32px));
    padding: 13px 18px;
    color: #fff;
    background: rgba(0, 0, 0, 0.9);
    border-radius: 10px;
    box-shadow: var(--shadow);
    font-size: 13px;
    transform: translateX(-50%);
}

@media (max-width: 1100px) {
    .editor-header {
        height: auto;
        min-height: 76px;
        padding: 12px 18px;
        flex-wrap: wrap;
    }

    .editor-main {
        width: min(100% - 28px, 1000px);
    }

    .canvas-shell {
        min-height: 540px;
    }

    .sticker-panel {
        grid-template-columns: 150px 1fr;
    }

    .sticker-divider {
        display: none;
    }

    /* 中等宽度下把完整操作组换到下一行，避免压缩可横向滚动的贴纸列表。 */
    .sticker-operation-bar {
        grid-column: 1 / -1;
        justify-content: center;
        border-top: 1px solid #eee;
        padding-top: 14px;
    }
}

@media (max-width: 720px) {
    .site-header {
        height: 68px;
        padding: 0 16px;
    }

    .brand {
        gap: 9px;
        font-size: 21px;
    }

    .brand-mark {
        width: 28px;
        height: 28px;
    }

    .model-status {
        max-width: 130px;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .upload-main {
        width: calc(100% - 32px);
        padding: clamp(14px, 2.6vh, 26px) 0;
    }

    .hero {
        margin-bottom: clamp(12px, 2.2vh, 22px);
    }

    .privacy-chip {
        margin-bottom: 24px;
        padding: 0 14px;
        font-size: 10px;
    }

    .hero h1 {
        margin-bottom: 16px;
        font-size: 36px;
    }

    .hero p {
        font-size: 14px;
    }

    .drop-zone {
        --scan-frame-inset: 12px;
        --scan-frame-size: 24px;
        --scan-line-gap: 20px;
        --scan-band-opacity: 0.34;
        min-height: 300px;
        max-height: none;
        padding: 22px 20px 18px;
        border-radius: 22px;
    }

    .seo-content {
        margin-top: 56px;
    }

    .feature-grid,
    .how-to ol {
        grid-template-columns: 1fr;
    }

    .feature-grid article,
    .how-to li {
        padding: 20px;
    }

    .how-to,
    .faq {
        margin-top: 44px;
    }

    /* 窄屏内容更密集，降低静态纹理强度以免扫描线穿过堆叠按钮后显得拥挤。 */
    .drop-zone::before {
        opacity: 0.44;
    }

    .drop-zone h2 {
        font-size: 22px;
    }

    .drop-zone > p:not(.upload-status) {
        margin-bottom: 30px;
        font-size: 13px;
    }

    .split-actions {
        grid-template-columns: 1fr;
        border-radius: 20px;
    }

    .split-actions button {
        min-height: 42px;
    }

    .site-footer,
    .editor-footer {
        padding: 18px;
        flex-direction: column;
        align-items: flex-start;
    }

    .editor-header {
        position: static;
        padding: 14px;
        gap: 14px;
    }

    .editor-brand-group {
        min-width: 0;
    }

    .editor-brand {
        font-size: 20px;
    }

    .editor-version,
    .header-separator {
        display: none;
    }

    .editor-export-group {
        margin-left: auto;
        gap: 8px;
    }

    .export-button {
        min-width: 94px;
        height: 44px;
        padding: 0 15px;
        font-size: 13px;
    }

    .text-action,
    .auto-mask-control {
        flex: 0 0 auto;
        font-size: 11px;
    }

    .action-separator {
        display: block;
        height: 30px;
        margin: 0 5px;
    }

    .editor-main {
        width: calc(100% - 20px);
        padding: 12px 0 20px;
    }

    .batch-bar {
        grid-template-columns: auto 1fr auto;
    }

    .thumbnail-strip {
        grid-column: 1 / -1;
        grid-row: 2;
        order: 5;
    }

    .canvas-shell {
        min-height: 430px;
    }

    .canvas-viewport {
        padding: 16px 16px 92px;
        align-items: center;
    }

    .canvas-toolbar {
        top: auto;
        right: 50%;
        bottom: 14px;
        width: auto;
        padding: 6px 10px;
        flex-direction: row;
        transform: translateX(50%);
    }

    .canvas-toolbar button {
        width: 38px;
        height: 38px;
        gap: 0;
        padding: 0;
        text-align: center;
    }

    /* 手机端横向空间有限，仅隐藏可见说明；ARIA 标签仍会随语言切换。 */
    .toolbar-label {
        display: none;
    }

    .toolbar-divider,
    .canvas-toolbar output {
        display: none;
    }

    .detection-status {
        left: 12px;
        bottom: 70px;
        max-width: calc(100% - 24px);
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .sticker-panel {
        margin-top: 14px;
        padding: 14px;
        grid-template-columns: 1fr;
        gap: 12px;
    }

    .sticker-heading-wrap {
        padding: 0 0 10px;
        border-right: 0;
        border-bottom: 1px solid #eee;
    }

    .sticker-list {
        width: 100%;
    }

    .sticker-button {
        flex-basis: 48px;
        width: 48px;
        height: 48px;
    }

    /* 手机端纵向分组，保证两个模式标签和批量按钮均有稳定的点击与阅读空间。 */
    .sticker-operation-bar {
        grid-column: auto;
        min-width: 0;
        flex-direction: column;
        align-items: stretch;
        gap: 10px;
    }

    .sticker-operation-bar .auto-mask-control {
        justify-content: center;
        padding: 0 0 12px;
        border-right: 0;
        border-bottom: 1px solid #eee;
    }

    .apply-all-button {
        flex-direction: row;
        justify-content: center;
    }
}

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }

    /* 尊重系统的减少动态效果设置，仅保留静态点阵。 */
    body::after {
        display: none;
    }

    /* 上传框保留静态扫描纹理和取景框，但不再播放循环光带。 */
    .drop-zone::after {
        display: none;
    }
}

/* 触屏或不具备精确指针的设备不启用跟随高亮，并适当降低静态点阵的存在感。 */
@media (hover: none), (pointer: coarse) {
    body::before {
        opacity: 0.44;
    }

    body::after {
        display: none;
    }
}
