/* ==========================================================================
   拼豆图纸转换器 · 样式表
   移动端优先，暖色系，详见 docs/04-UI设计文档.md
   ========================================================================== */


/* --------------------------------------------------------------------------
   1. 变量与重置
   -------------------------------------------------------------------------- */

:root {
    /* 主色 */
    --c-primary: #ff7a45;
    --c-primary-dark: #e85d2a;
    --c-primary-light: #fff2ec;
    --c-success: #52c41a;
    --c-warning: #faad14;
    --c-danger: #ff4d4f;
    /* 文字 */
    --c-text: #262626;
    --c-text-sub: #8c8c8c;
    --c-text-weak: #bfbfbf;
    /* 背景与边框 */
    --c-bg: #f7f7f8;
    --c-card: #ffffff;
    --c-border: #e8e8e8;
    /* 间距 */
    --sp: 8px;
    --radius-card: 12px;
    --radius-btn: 8px;
    /* 阴影 */
    --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.06);
    --shadow-topbar: 0 2px 8px rgba(0, 0, 0, 0.08);
    --shadow-primary: 0 2px 6px rgba(255, 122, 69, 0.3);
    /* 布局 */
    --max-width: 600px;
    --topbar-height: 56px;
}


/* hidden 属性必须始终生效：类选择器的 display 会覆盖 UA 默认的 [hidden] */

[hidden] {
    display: none !important;
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    -webkit-text-size-adjust: 100%;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--c-text);
    background: var(--c-bg);
    overflow-x: hidden;
}

h1,
h2,
h3,
p {
    margin: 0;
}

button {
    font-family: inherit;
    cursor: pointer;
}

input,
select {
    font-family: inherit;
}


/* 屏幕阅读器专用 */

.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}


/* --------------------------------------------------------------------------
   2. 顶部吸顶栏
   -------------------------------------------------------------------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: var(--sp);
    min-height: var(--topbar-height);
    padding: 0 16px;
    background: var(--c-card);
    box-shadow: var(--shadow-topbar);
}


/* 色卡数据来源与版本标注 */

.palette-source {
    flex-basis: 100%;
    margin: 0 0 6px;
    font-size: 11px;
    line-height: 1.4;
    color: var(--c-text-muted, #8c8c8c);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}


/* V2.3（C-1）免注册叙事：顶部提示条 */

.topbar__note {
    flex-basis: 100%;
    margin: 0 0 6px;
    font-size: 11px;
    line-height: 1.4;
    color: var(--c-text-muted, #8c8c8c);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar__title {
    font-size: 18px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.topbar__right {
    display: flex;
    align-items: center;
    gap: var(--sp);
    flex-shrink: 0;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap;
}

.badge--pro {
    color: #fff;
    background: var(--c-success);
}


/* V1.2（L2）：免费版标识 */

.badge--free {
    color: var(--c-text-sub);
    background: var(--c-bg-sub);
    border: 1px solid var(--c-border);
}


/* V1.6：本地开发主机下徽标可点击（仅 127.0.0.1 / localhost 生效） */

.badge--dev {
    cursor: pointer;
    outline: 1px dashed var(--c-primary);
    outline-offset: 1px;
}

.badge--dev:hover {
    filter: brightness(0.96);
}


/* V1.6：升级弹窗内的「本地开发」一键解锁区块 */

.dev-unlock {
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px dashed var(--c-primary);
    border-radius: var(--radius-btn);
    background: var(--c-bg-sub);
}

.dev-unlock__title {
    margin: 0 0 4px;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-primary);
}

.dev-unlock__note {
    margin: 0 0 8px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--c-text-sub);
}

.dev-unlock__row {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.palette-select select {
    appearance: none;
    -webkit-appearance: none;
    padding: 6px 26px 6px 10px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-btn);
    background: var(--c-card) url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath fill='%238c8c8c' d='M0 0l5 6 5-6z'/%3E%3C/svg%3E") no-repeat right 8px center;
    font-size: 13px;
    color: var(--c-text);
    max-width: 130px;
}


/* --------------------------------------------------------------------------
   3. 主容器
   -------------------------------------------------------------------------- */

.main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}


/* --------------------------------------------------------------------------
   4. 卡片
   -------------------------------------------------------------------------- */

.card {
    background: var(--c-card);
    border-radius: var(--radius-card);
    padding: 16px;
    box-shadow: var(--shadow-card);
}

.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--sp);
    margin-bottom: 12px;
}

.card__title {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
}

.card__head .card__title {
    margin-bottom: 0;
}


/* --------------------------------------------------------------------------
   5. 按钮
   -------------------------------------------------------------------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    min-height: 44px;
    padding: 10px 16px;
    border: 1px solid transparent;
    border-radius: var(--radius-btn);
    font-size: 15px;
    font-weight: 500;
    line-height: 1.2;
    transition: opacity 0.15s, background-color 0.15s, transform 0.1s;
    user-select: none;
}

.btn:active:not(:disabled) {
    transform: scale(0.98);
}

.btn:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.btn--block {
    display: flex;
    width: 100%;
}

.btn--primary {
    color: #fff;
    background: var(--c-primary);
    box-shadow: var(--shadow-primary);
}

.btn--primary:active:not(:disabled) {
    background: var(--c-primary-dark);
}

.btn--outline {
    color: var(--c-primary);
    background: var(--c-card);
    border-color: var(--c-primary);
}

.btn--outline:active:not(:disabled) {
    background: var(--c-primary-light);
}

.btn--ghost {
    color: var(--c-text-sub);
    background: var(--c-card);
    border-color: var(--c-border);
}

.btn--text {
    color: var(--c-text-sub);
    background: transparent;
    font-size: 13px;
    min-height: 40px;
}

.btn--text:active:not(:disabled) {
    color: var(--c-primary);
}

.btn--sm {
    min-height: 34px;
    padding: 6px 12px;
    font-size: 13px;
}

.btn--upload {
    min-height: 52px;
    font-size: 16px;
    font-weight: 600;
}

.btn__icon {
    font-size: 18px;
}

.btn-row {
    display: flex;
    gap: var(--sp);
}

.btn-row .btn {
    flex: 1;
}


/* --------------------------------------------------------------------------
   6. 提示文字
   -------------------------------------------------------------------------- */

.hint {
    margin-top: 8px;
    font-size: 12px;
    color: var(--c-text-sub);
    line-height: 1.5;
}

.hint--center {
    text-align: center;
}


/* 注：T-32 已删除 .hint--warn —— 全站 HTML/JS 均未引用（页面级警示统一用 .page-note--warn） */


/* --------------------------------------------------------------------------
   7. 控件组
   -------------------------------------------------------------------------- */

.control-group {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}


/* V2.3 P3（U-1）：高级选项折叠组（默认收起，降低首屏认知负担） */

.adv-group {
    border: 1px solid var(--c-border);
    border-radius: var(--radius-btn);
    background: var(--c-bg);
    overflow: hidden;
}

.adv-group__summary {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    cursor: pointer;
    list-style: none;
    user-select: none;
    font-size: 14px;
    font-weight: 500;
    color: var(--c-text-sub);
}

.adv-group__summary::-webkit-details-marker {
    display: none;
}

.adv-group__title {
    flex: 0 0 auto;
    color: var(--c-text);
}

.adv-group__hint {
    flex: 1 1 auto;
    font-size: 12px;
    font-weight: 400;
    color: var(--c-text-weak);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.adv-group__arrow {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--c-text-weak);
    transition: transform 0.15s;
}

.adv-group[open] .adv-group__arrow {
    transform: rotate(180deg);
}

.adv-group__body {
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 4px 12px 14px;
    border-top: 1px solid var(--c-border);
}

.slider-row__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 6px;
}

.slider-row__head label {
    font-size: 14px;
    font-weight: 500;
}

.slider-row__value {
    font-size: 13px;
    color: var(--c-text-sub);
}

.slider-row__value b {
    color: var(--c-primary);
    font-size: 15px;
}

.slider-row__scale {
    display: flex;
    justify-content: space-between;
    margin-top: 2px;
    font-size: 11px;
    color: var(--c-text-weak);
}


/* 滑块 */

input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 24px;
    background: transparent;
    margin: 0;
}

input[type="range"]::-webkit-slider-runnable-track {
    height: 6px;
    border-radius: 3px;
    background: var(--c-border);
}

input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 22px;
    height: 22px;
    margin-top: -8px;
    border-radius: 50%;
    background: var(--c-primary);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}

input[type="range"]::-moz-range-track {
    height: 6px;
    border-radius: 3px;
    background: var(--c-border);
}

input[type="range"]::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--c-primary);
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}


/* 开关 */

.switch-row {
    display: flex;
    align-items: center;
}

.switch-row--split {
    justify-content: space-between;
}

.switch {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    /* V2.4（T-25）：保证触摸目标 ≥44px */
    min-height: 44px;
    cursor: pointer;
    user-select: none;
}

.switch input {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.switch__track {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    border-radius: 13px;
    background: #d9d9d9;
    transition: background-color 0.2s;
    flex-shrink: 0;
}

.switch__thumb {
    position: absolute;
    top: 3px;
    left: 3px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s;
}

.switch input:checked+.switch__track {
    background: var(--c-primary);
}

.switch input:checked+.switch__track .switch__thumb {
    transform: translateX(20px);
}

.switch input:focus-visible+.switch__track {
    outline: 2px solid var(--c-primary);
    outline-offset: 2px;
}

.switch__label {
    font-size: 14px;
}


/* 输入框 */

.input {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-btn);
    font-size: 15px;
    color: var(--c-text);
    background: var(--c-card);
    outline: none;
}

.input:focus {
    border-color: var(--c-primary);
}

.input--search {
    min-height: 38px;
    font-size: 14px;
}


/* --------------------------------------------------------------------------
   8. 画布区
   -------------------------------------------------------------------------- */

.canvas-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    padding: 8px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-btn);
    background: #fafafa;
    overflow: auto;
}

.canvas {
    display: block;
    max-width: 100%;
    background: #fff;
    border-radius: 2px;
    cursor: crosshair;
    touch-action: none;
}


/* 空状态 */

.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 40px 16px;
    text-align: center;
}

.empty-state__icon {
    font-size: 40px;
    line-height: 1;
}

.empty-state__text {
    font-size: 15px;
    color: var(--c-text-sub);
}

.empty-state__sub {
    font-size: 12px;
    color: var(--c-text-weak);
}


/* V2.3 P3（U-5）：新手引导——示例图入口 */

.empty-state__demo {
    margin-top: 10px;
}


/* 工具栏 */

.toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 12px;
    padding-bottom: 4px;
}


/* V2.3 P3（U-6）：窄屏下工具栏横向滚动，避免 13 个按钮溢出换行挤压 */

@media (max-width: 480px) {
    .toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        padding-bottom: 8px;
    }
    .tool {
        flex: 0 0 auto;
    }
}

.tool {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    flex: 0 1 auto;
    min-width: 52px;
    min-height: 52px;
    padding: 6px 8px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-btn);
    background: var(--c-card);
    color: var(--c-text-sub);
    transition: all 0.15s;
}

.tool__icon {
    font-size: 18px;
    line-height: 1;
}

.tool__label {
    font-size: 11px;
    line-height: 1;
}

.tool.is-active {
    color: #fff;
    background: var(--c-primary);
    border-color: var(--c-primary);
}

.tool:disabled {
    opacity: 0.35;
    cursor: not-allowed;
}

.tool--danger.is-active,
.tool--danger:active:not(:disabled) {
    color: #fff;
    background: var(--c-danger);
    border-color: var(--c-danger);
}


/* 色板面板 */

.palette-panel {
    margin-top: 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-btn);
    overflow: hidden;
}

.palette-panel__head {
    display: flex;
    align-items: center;
    gap: var(--sp);
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: none;
    background: #fafafa;
    font-size: 14px;
    font-weight: 500;
    color: var(--c-text);
    text-align: left;
}

.palette-panel__current {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    font-size: 12px;
    color: var(--c-text-sub);
}

.palette-panel__arrow {
    font-size: 12px;
    color: var(--c-text-sub);
    transition: transform 0.2s;
}

.palette-panel.is-collapsed .palette-panel__arrow {
    transform: rotate(-90deg);
}

.palette-panel.is-collapsed .palette-panel__body {
    display: none;
}

.palette-panel__body {
    padding: 12px;
    border-top: 1px solid var(--c-border);
}

.swatch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(34px, 1fr));
    gap: 6px;
    margin-top: 10px;
    max-height: 240px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.swatch {
    display: inline-block;
    width: 32px;
    height: 32px;
    border-radius: 6px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #fff;
    padding: 0;
    transition: transform 0.1s, box-shadow 0.1s;
}

.swatch--sm {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    vertical-align: middle;
}

.swatch.is-active {
    border: 2px solid var(--c-primary);
    box-shadow: 0 0 0 2px var(--c-primary-light);
    transform: scale(1.08);
}

.swatch-grid__empty {
    grid-column: 1 / -1;
    padding: 16px;
    text-align: center;
    font-size: 13px;
    color: var(--c-text-weak);
}


/* V1.9（W1）：画笔 / 橡皮尺寸 */

.brush-size-row {
    display: flex;
    align-items: center;
    gap: var(--sp);
    margin-top: 8px;
}

.brush-size-row__label {
    flex: 0 0 auto;
    font-size: 12px;
    color: var(--c-text-sub);
}

.brush-size-row__btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.brush-size {
    min-width: 46px;
    min-height: 32px;
    padding: 4px 10px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-btn);
    background: var(--c-card);
    color: var(--c-text-sub);
    font-size: 12px;
    line-height: 1;
    transition: all 0.15s;
}

.brush-size.is-active {
    color: #fff;
    background: var(--c-primary);
    border-color: var(--c-primary);
}


/* V1.9（W2）：色系筛选 */

.hue-filter-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

.hue-filter {
    min-height: 30px;
    padding: 4px 10px;
    border: 1px solid var(--c-border);
    border-radius: 999px;
    background: var(--c-card);
    color: var(--c-text-sub);
    font-size: 12px;
    line-height: 1;
    transition: all 0.15s;
}

.hue-filter.is-active {
    color: #fff;
    background: var(--c-primary);
    border-color: var(--c-primary);
}


/* --------------------------------------------------------------------------
   8.5 V1.9（W4）文字转像素字面板
   -------------------------------------------------------------------------- */

.text-pixel-panel {
    margin-top: 10px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-btn);
    background: var(--c-card);
    overflow: hidden;
}

.text-pixel-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text);
    background: var(--c-bg-soft, #f7f7f7);
    border-bottom: 1px solid var(--c-border);
}

.text-pixel-panel__close {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: var(--c-text-sub);
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
}

.text-pixel-panel__body {
    padding: 12px;
}

.text-pixel-preview {
    display: grid;
    gap: 1px;
    justify-content: center;
    margin: 10px 0;
    padding: 8px;
    border: 1px dashed var(--c-border);
    border-radius: var(--radius-btn);
    background: var(--c-bg-soft, #fafafa);
    overflow: auto;
    max-height: 220px;
}

.text-pixel-preview__cell {
    width: 8px;
    height: 8px;
    border-radius: 1px;
    background: transparent;
}

.text-pixel-preview__cell.is-on {
    background: var(--c-primary);
}

.text-pixel-hint {
    margin: 6px 0 10px;
    font-size: 12px;
    line-height: 1.5;
    color: var(--c-text-sub);
}


/* --------------------------------------------------------------------------
   9. 统计区
   -------------------------------------------------------------------------- */

.stats-summary {
    font-size: 13px;
    color: var(--c-text-sub);
    margin-bottom: 12px;
}

.stats-list {
    max-height: 320px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-btn);
}

.stats-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.stats-table thead th {
    position: sticky;
    top: 0;
    z-index: 1;
    padding: 10px 12px;
    background: #fafafa;
    border-bottom: 1px solid var(--c-border);
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text-sub);
    text-align: left;
}

.stats-table tbody td {
    padding: 10px 12px;
    border-bottom: 1px solid #f5f5f5;
    vertical-align: middle;
}

.stats-table tbody tr:last-child td {
    border-bottom: none;
}

.stats-table tbody tr {
    cursor: pointer;
    transition: background-color 0.15s;
}

.stats-table tbody tr:active {
    background: var(--c-primary-light);
}

.col-code {
    width: 70px;
}

.col-swatch {
    width: 48px;
}

.col-count {
    width: 80px;
    text-align: right !important;
}

.stats-table .col-count {
    text-align: right;
    font-weight: 600;
    color: var(--c-primary);
    white-space: nowrap;
}

.stats-table .cell-code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px;
    color: var(--c-text-sub);
}

.stats-table .cell-swatch {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    vertical-align: middle;
}


/* --------------------------------------------------------------------------
   10. 导出区
   -------------------------------------------------------------------------- */

.export-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
}


/* V1.2（L2）：高级版导出面板对免费用户可见但置灰 */

.export-actions--pro.is-locked {
    opacity: 0.62;
}

.export-actions--pro.is-locked .btn,
.export-actions--pro.is-locked select,
.export-actions--pro.is-locked input {
    cursor: not-allowed;
}

.pro-lock-hint {
    margin: 0;
    padding: 10px 12px;
    border: 1px dashed var(--c-primary);
    border-radius: var(--radius-sm);
    background: rgba(255, 122, 69, 0.06);
    font-size: 13px;
    line-height: 1.6;
    color: var(--c-text);
}

.pro-lock-hint a {
    color: var(--c-primary);
    font-weight: 600;
}


/* 注：T-32 已删除 .pro-lock-hint__sep ——
   T-30 把 #pro-lock-hint 改为纯说明文字后，js/main.js 不再动态创建
   <span class="pro-lock-hint__sep">，index.html 中亦无该元素，属死代码。 */


/* V1.2（K1）：导出元素勾选面板 */

.export-options {
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    background: var(--c-bg-sub);
    overflow: hidden;
}

.export-options__head {
    padding: 10px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text);
    cursor: pointer;
    user-select: none;
    list-style: none;
}

.export-options__head::-webkit-details-marker {
    display: none;
}

.export-options__head::before {
    content: '▸';
    display: inline-block;
    margin-right: 6px;
    transition: transform 0.15s ease;
}

.export-options[open] .export-options__head::before {
    transform: rotate(90deg);
}

.export-options__body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 4px 12px 12px;
    border-top: 1px solid var(--c-border);
}

.check-row {
    display: flex;
    align-items: center;
    gap: 8px;
    /* V2.4（T-25）：保证触摸目标 ≥44px */
    min-height: 44px;
    font-size: 13px;
    color: var(--c-text);
    cursor: pointer;
    line-height: 1.5;
}

.check-row input[type='checkbox'] {
    flex: 0 0 auto;
    width: 16px;
    height: 16px;
    accent-color: var(--c-primary);
    cursor: pointer;
}

.check-row>span:first-of-type {
    flex: 1 1 auto;
}

.check-row__tag {
    flex: 0 0 auto;
    padding: 1px 6px;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.6;
    color: #fff;
    background: var(--c-primary);
}

.check-row__tag--free {
    background: var(--c-success, #2E9E5B);
}

.check-row--disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.field-row--inline {
    margin-top: 2px;
}


/* --------------------------------------------------------------------------
   11. 页脚
   -------------------------------------------------------------------------- */

.footer {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 24px 16px 40px;
    text-align: center;
    font-size: 12px;
    color: var(--c-text-sub);
    line-height: 1.8;
}

.footer__sub {
    color: var(--c-text-weak);
}


/* --------------------------------------------------------------------------
   12. Toast
   -------------------------------------------------------------------------- */

.toast-container {
    position: fixed;
    left: 50%;
    bottom: 80px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    transform: translateX(-50%);
    pointer-events: none;
    width: max-content;
    max-width: 90vw;
}

.toast {
    padding: 10px 18px;
    border-radius: 20px;
    font-size: 14px;
    color: #fff;
    background: rgba(0, 0, 0, 0.78);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    animation: toast-in 0.2s ease-out;
    word-break: break-word;
}

.toast--success {
    background: rgba(82, 196, 26, 0.95);
}

.toast--warning {
    background: rgba(250, 173, 20, 0.95);
}

.toast--error {
    background: rgba(255, 77, 79, 0.95);
}

.toast.is-leaving {
    animation: toast-out 0.2s ease-in forwards;
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes toast-out {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(10px);
    }
}


/* --------------------------------------------------------------------------
   13. 模态框
   -------------------------------------------------------------------------- */

.modal-container {
    position: fixed;
    inset: 0;
    z-index: 1100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, 0.45);
    animation: fade-in 0.15s ease-out;
}

@keyframes fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal {
    width: 100%;
    max-width: 340px;
    max-height: 80vh;
    overflow-y: auto;
    padding: 20px;
    border-radius: var(--radius-card);
    background: var(--c-card);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    animation: modal-in 0.2s ease-out;
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.94);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.modal__title {
    font-size: 17px;
    font-weight: 600;
    margin-bottom: 10px;
}

.modal__body {
    font-size: 14px;
    color: var(--c-text-sub);
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.modal__body b {
    color: var(--c-text);
}

.modal__input {
    margin-top: 14px;
}

.modal__checkbox {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 14px;
    font-size: 13px;
    color: var(--c-text-sub);
    cursor: pointer;
}

.modal__checkbox input {
    width: 16px;
    height: 16px;
    accent-color: var(--c-primary);
}

.modal__actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal__actions .btn {
    flex: 1;
}

.modal__error {
    margin-top: 10px;
    font-size: 13px;
    color: var(--c-danger);
    min-height: 18px;
}


/* V1.2（K4）：导出前成品预览 */

.export-preview {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.export-preview__img {
    display: block;
    width: 100%;
    max-height: 52vh;
    object-fit: contain;
    border: 1px solid var(--c-border);
    border-radius: 8px;
    background: #ffffff;
}

.export-preview__tip {
    margin: 0;
    font-size: 13px;
    line-height: 1.6;
    color: var(--c-text-sub);
}


/* 注：T-32 已删除 .color-picker-list / .color-picker-item / .is-active ——
   清除颜色弹窗实际使用 .swatch-grid / .swatch（见 js/main.js handleClearColor），
   上述三条规则全站无任何引用，属死代码。 */


/* --------------------------------------------------------------------------
   14. 加载遮罩
   -------------------------------------------------------------------------- */

.loading-overlay {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.82);
    backdrop-filter: blur(2px);
}

.loading-box {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
    padding: 24px 32px;
    border-radius: var(--radius-card);
    background: var(--c-card);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
}

.spinner {
    width: 34px;
    height: 34px;
    border: 3px solid var(--c-primary-light);
    border-top-color: var(--c-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.loading-text {
    font-size: 14px;
    color: var(--c-text-sub);
    white-space: pre-line;
    text-align: center;
}


/* --------------------------------------------------------------------------
   14.5 V1.1 阶段 E：付费方案选择 + 支持者滚屏
   -------------------------------------------------------------------------- */


/* 付费方案列表（弹窗内） */

.plan-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin: 12px 0;
}

.plan-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px;
    border: 1.5px solid var(--c-border);
    border-radius: 10px;
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}

.plan-item.is-active {
    border-color: var(--c-primary);
    background: var(--c-primary-light);
}

.plan-item__radio {
    margin-top: 3px;
    accent-color: var(--c-primary);
    flex-shrink: 0;
}

.plan-item__main {
    flex: 1;
    min-width: 0;
}

.plan-item__head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 8px;
}

.plan-item__title {
    font-size: 15px;
    font-weight: 600;
    color: var(--c-text);
}

.plan-item__price {
    font-size: 16px;
    font-weight: 700;
    color: var(--c-primary);
    flex-shrink: 0;
}

.plan-item__desc {
    margin: 4px 0 0;
    font-size: 13px;
    color: var(--c-text-sub);
}

.plan-item__note {
    margin: 4px 0 0;
    font-size: 12px;
    color: var(--c-text-muted, #999);
    line-height: 1.5;
}


/* 弹窗底部提示（V1.8：优惠券抵扣提示） */

.modal__tip {
    margin: 12px 0 0;
    font-size: 12px;
    line-height: 1.6;
    color: var(--c-text-sub);
}


/* 注：T-32 已删除 .modal__tip--coupon —— V2.1 纯公益化后优惠券抵扣提示已下线，
   全站无任何元素使用该修饰类，属死代码。 */


/* 支持者滚屏
   注：T-32 起 .welfare__roll 容器样式统一收敛到 §16.4（纵向列表滚动），
   此处只保留 js/roll.js 实际渲染的 chip 样式，避免同名选择器重复定义。 */

.welfare__chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    flex-shrink: 0;
    padding: 5px 10px;
    border-radius: 999px;
    background: var(--c-primary-light);
    font-size: 13px;
    white-space: nowrap;
}

.welfare__chip-heart {
    font-size: 12px;
}

.welfare__chip-name {
    color: var(--c-text);
    max-width: 8em;
    overflow: hidden;
    text-overflow: ellipsis;
}

.welfare__chip-amount {
    color: var(--c-primary);
    font-weight: 600;
}


/* .welfare__empty 样式统一在 §16.4 定义（T-32 去重） */


/* --------------------------------------------------------------------------
   14.6 V1.1 阶段 F-批1：工程管理 + 描边/换色弹窗
   -------------------------------------------------------------------------- */


/* 工程面板主体（折叠区） */

.project-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}


/* 工程列表 */

.project-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 260px;
    overflow-y: auto;
}

.project-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    background: var(--c-bg-sub);
    transition: border-color 0.15s, background 0.15s;
}

.project-item:hover {
    border-color: var(--c-primary);
    background: var(--c-primary-light);
}

.project-item__info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.project-item__name {
    font-size: 14px;
    font-weight: 600;
    color: var(--c-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.project-item__meta {
    font-size: 12px;
    color: var(--c-text-sub);
}

.project-item__actions {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0;
}

.project-empty {
    font-size: 13px;
    color: var(--c-text-sub);
    text-align: center;
    padding: 12px 0;
}


/* 描边 / 换色弹窗表单 */

.outline-form,
.replace-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
}


/* 注：T-32 已删除 .outline-form__row / __label / __select / __tip 与
   .replace-form__row / __label / __select ——
   两个弹窗实际使用 .field-row / .field-row__label / .input--select / .replace-form__tip
   （见 js/main.js handleOutline / handleReplaceColor），上述规则全站无引用，属死代码。
   仅保留 .replace-form__tip（js/main.js:2494 真实使用）。 */

.replace-form__tip {
    font-size: 12px;
    color: var(--c-text-sub);
    line-height: 1.6;
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--c-bg-sub);
}


/* 危险操作文字按钮（删除工程等） */

.btn--danger-text {
    background: transparent;
    border: none;
    color: var(--c-danger, #E5484D);
    font-size: 13px;
    padding: 4px 6px;
    cursor: pointer;
    border-radius: var(--radius-sm);
    transition: background 0.15s;
}

.btn--danger-text:hover {
    background: rgba(229, 72, 77, 0.1);
}


/* --------------------------------------------------------------------------
   14.7 V1.1 阶段 F-批2：分块拆分 + 豆子库存
   -------------------------------------------------------------------------- */


/* 分块拆分面板 */

.split-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.split-size {
    display: flex;
    align-items: center;
    gap: 6px;
}

.split-size__x {
    color: var(--c-text-sub);
    font-size: 13px;
}

.input--num {
    width: 68px;
    text-align: center;
}

.split-info {
    font-size: 13px;
    color: var(--c-text-sub);
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    background: var(--c-bg-sub);
}

.split-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
    gap: 6px;
    max-height: 240px;
    overflow-y: auto;
    padding: 8px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    background: var(--c-bg-sub);
}

.split-preview__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    padding: 6px 4px;
    border-radius: var(--radius-sm);
    background: var(--c-bg);
    border: 1px solid var(--c-border);
    font-size: 11px;
    color: var(--c-text-sub);
    text-align: center;
}

.split-preview__item b {
    font-size: 12px;
    color: var(--c-text);
}

.split-preview__item--empty {
    opacity: 0.45;
}


/* 豆子库存面板 */

.stock-body {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.stock-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
}

.stock-toolbar .input--search {
    flex: 1;
    min-width: 120px;
}

.stock-shortage {
    font-size: 13px;
    line-height: 1.7;
    color: var(--c-text);
    padding: 10px 12px;
    border-radius: var(--radius-sm);
    background: rgba(229, 72, 77, 0.08);
    border-left: 3px solid var(--c-danger, #E5484D);
    white-space: pre-wrap;
}

.stock-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 6px;
    max-height: 320px;
    overflow-y: auto;
}

.stock-item {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    background: var(--c-bg-sub);
}

.stock-item__code {
    font-size: 12px;
    font-weight: 600;
    color: var(--c-text);
    flex-shrink: 0;
}

.stock-item__input {
    flex: 1;
    min-width: 0;
    width: 100%;
    padding: 3px 6px;
    font-size: 12px;
    text-align: center;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-sm);
    background: var(--c-bg);
    color: var(--c-text);
}

.stock-item__input:focus {
    outline: none;
    border-color: var(--c-primary);
}

.stock-empty {
    grid-column: 1 / -1;
    font-size: 13px;
    color: var(--c-text-sub);
    text-align: center;
    padding: 12px 0;
}


/* --------------------------------------------------------------------------
   15. 响应式
   -------------------------------------------------------------------------- */


/* 小屏手机 */

@media (max-width: 374px) {
    body {
        font-size: 13px;
    }
    .main {
        padding: 12px;
        gap: 12px;
    }
    .card {
        padding: 12px;
    }
    .topbar {
        padding: 0 12px;
    }
    .topbar__title {
        font-size: 16px;
    }
    .tool {
        flex: 1 1 calc(25% - 6px);
        min-width: 46px;
        min-height: 46px;
    }
}


/* 桌面端 */

@media (min-width: 768px) {
    .main {
        padding: 24px 16px;
    }
    .canvas-wrap {
        min-height: 320px;
    }
    .stats-list {
        max-height: 400px;
    }
}


/* V2.4（T-25）：平板竖屏（768~1023px）
   13 个工具按钮在平板竖屏下换行会挤压画布，改为横向滚动 */

@media (min-width: 768px) and (max-width: 1023px) {
    .toolbar {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        padding-bottom: 8px;
    }
    .tool {
        flex: 0 0 auto;
    }
    .canvas-wrap {
        min-height: 360px;
    }
}


/* V2.4（T-25）：平板横屏 / 小桌面（1024~1365px）
   放宽主内容宽度，给画布更多可视空间 */

@media (min-width: 1024px) and (max-width: 1365px) {
    .main {
        max-width: 900px;
    }
    .canvas-wrap {
        min-height: 420px;
    }
}


/* V2.4（T-25）：横屏（高度受限）
   手机 / 平板横屏时纵向空间紧张，压缩留白优先保证画布可视高度 */

@media (orientation: landscape) and (max-height: 500px) {
    .topbar {
        padding: 0 12px;
    }
    .main {
        padding: 8px;
        gap: 8px;
    }
    .card {
        padding: 10px;
    }
    .canvas-wrap {
        min-height: 180px;
    }
}


/* 减少动画偏好 */

@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}


/* --------------------------------------------------------------------------
   16. V1.1 新增：尺寸预设 / 底图控制 / 导出模式 / 公益公示 / 页脚合规
   -------------------------------------------------------------------------- */


/* --- 16.1 尺寸快捷预设按钮组（B2） --- */

.preset-row {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 12px;
}

.preset-row__label {
    font-size: 13px;
    color: var(--c-text-sub);
}

.preset-row__btns {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.preset-btn {
    flex: 1 1 auto;
    min-width: 56px;
    /* V2.4（T-25）：保证触摸目标 ≥44px */
    min-height: 44px;
    padding: 6px 8px;
    font-size: 12px;
    font-family: inherit;
    color: var(--c-text);
    background: var(--c-bg-sub);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-btn);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}

.preset-btn:hover {
    border-color: var(--c-primary);
    color: var(--c-primary);
}

.preset-btn:active {
    background: var(--c-primary-light);
}

.preset-btn.is-active {
    background: var(--c-primary-light);
    border-color: var(--c-primary);
    color: var(--c-primary);
    font-weight: 600;
}


/* --- 16.2 底图显隐与透明度（B3） --- */


/* 底图透明度滑块行：复用 .slider-row，仅补充隐藏态 */

#base-image-opacity-row[hidden] {
    display: none;
}


/* --- 16.3 导出模式选择（B7） --- */

.field-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    margin-bottom: 12px;
}

.field-row__label {
    flex: 0 0 auto;
    font-size: 13px;
    color: var(--c-text-sub);
}

.input--select {
    flex: 1 1 auto;
    min-width: 0;
    padding: 8px 10px;
    font-size: 13px;
    font-family: inherit;
    color: var(--c-text);
    background: var(--c-bg-sub);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-btn);
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: linear-gradient(45deg, transparent 50%, var(--c-text-sub) 50%), linear-gradient(135deg, var(--c-text-sub) 50%, transparent 50%);
    background-position: calc(100% - 16px) 50%, calc(100% - 11px) 50%;
    background-size: 5px 5px, 5px 5px;
    background-repeat: no-repeat;
    padding-right: 30px;
}

.input--select:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 2px var(--c-primary-light);
}


/* --- 16.3.1 支持项目卡片（T-29 → T-31 已合并） ---
   T-29 曾新建 #support-panel（.card--support）把打赏入口移出导出区；
   T-31 发现它与 #welfare-panel 的合规声明、打赏按钮完全重复，
   已删除该卡片，打赏入口并入 #welfare-panel。
   故 .card--support / .support-actions 样式一并移除，避免死代码。 */


/* --- 16.4 公益公示区（B8） ---
   注：T-31 起本区同时承载「打赏入口 + 合规声明」，是全站唯一的支持入口。 */

.card--welfare {
    border: 1px solid var(--c-primary-light);
    background: linear-gradient(180deg, var(--c-primary-light) 0%, var(--c-bg) 60%);
}

.welfare__desc {
    margin: 0 0 10px;
    font-size: 13px;
    line-height: 1.7;
    color: var(--c-text-sub);
}

.welfare__roll {
    max-height: 168px;
    overflow-y: auto;
    padding: 8px 10px;
    background: var(--c-bg-sub);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-btn);
    font-size: 13px;
    line-height: 1.9;
    color: var(--c-text);
    -webkit-overflow-scrolling: touch;
}


/* 注：T-32 已删除 .welfare__roll-item / -name / -meta ——
   js/roll.js 实际渲染的是 .welfare__chip / -heart / -name / -amount，
   上述三条规则全站无任何引用，属死代码。 */

.welfare__empty {
    padding: 12px 0;
    text-align: center;
    font-size: 13px;
    color: var(--c-text-sub);
}

.welfare__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
}

.welfare__actions .btn {
    flex: 1 1 auto;
}


/* --- 16.5 页脚合规链接（B8） --- */

.footer__links {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: center;
    gap: 4px 8px;
    margin-bottom: 8px;
}

.footer__links .link {
    font-size: 12px;
    color: var(--c-text-sub);
    text-decoration: none;
    transition: color 0.15s;
}

.footer__links .link:hover {
    color: var(--c-primary);
    text-decoration: underline;
}

.footer__sep {
    font-size: 12px;
    color: var(--c-border);
    user-select: none;
}

.footer__sub {
    margin: 4px 0 0;
    font-size: 12px;
    line-height: 1.7;
    color: var(--c-text-sub);
    text-align: center;
}

.footer__sub .link {
    color: var(--c-text-sub);
    text-decoration: none;
}

.footer__sub .link:hover {
    color: var(--c-primary);
    text-decoration: underline;
}


/* --- 16.6 V1.1 响应式补充 --- */

@media (max-width: 374px) {
    .preset-btn {
        min-width: 48px;
        font-size: 11px;
        padding: 5px 6px;
    }
    .field-row {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }
    .input--select {
        width: 100%;
    }
}


/* --- 17. V1.1（F4）拼豆进度打勾 --- */

.progress-bar {
    margin-top: 12px;
    padding: 12px;
    border-radius: var(--radius-sm);
    background: var(--c-bg-sub);
    border: 1px solid var(--c-border);
}

.progress-bar__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.progress-bar__label {
    font-size: 13px;
    font-weight: 600;
    color: var(--c-text);
}

.progress-bar__value {
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    color: var(--c-text-sub);
}

.progress-bar__track {
    height: 10px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.08);
    overflow: hidden;
}

.progress-bar__fill {
    height: 100%;
    width: 0;
    border-radius: 999px;
    background: linear-gradient(90deg, #2E9E5B, #4CC97A);
    transition: width 0.25s ease;
}

.progress-bar__actions {
    display: flex;
    justify-content: flex-end;
    margin-top: 10px;
}


/* 进度模式下画布光标提示「可点选」 */

.canvas-wrap.is-progress-mode #canvas {
    cursor: pointer;
}