/* ============================================================
   纹理隐形文字 texture-text — 样式自包含（tt- 前缀）
   设计语言与全站一致：白卡、#eff2f8 底、品牌蓝 #4f6ef7
   工具本体保持浅色纸张
   ============================================================ */

.tt-wrap { max-width: 1100px; margin: 0 auto; }

/* ---------- 两栏布局 ---------- */
.tt-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 344px;
    gap: 14px;
    align-items: start;
}
@media (max-width: 900px) {
    .tt-layout { grid-template-columns: minmax(0, 1fr); }
}

/* ---------- 卡片 ---------- */
.tt-card {
    background: #fff;
    border: 1px solid var(--z-line, #e2e8f0);
    border-radius: 14px;
    padding: 16px;
    margin-bottom: 14px;
}
.tt-card-title {
    display: flex; align-items: center; gap: 8px;
    font-size: 14px; font-weight: 700; color: #0f172a;
    margin: 0 0 12px;
}
.tt-card-title .svg-icon { color: #4f6ef7; flex: none; }
.tt-card-title .tt-title-hint {
    margin-left: auto; font-weight: 400; font-size: 12px; color: #94a3b8;
}

/* ---------- 预览台 ---------- */
.tt-stage-card { padding: 14px; }
.tt-stage-head {
    display: flex; align-items: center; gap: 10px; margin-bottom: 12px;
    flex-wrap: wrap;
}
.tt-stage-head > b { font-size: 14px; color: #0f172a; }

.tt-ratios { display: flex; gap: 5px; margin-left: auto; }
.tt-ratios button {
    min-width: 44px; height: 28px; padding: 0 9px;
    border: 1px solid #e2e8f0; border-radius: 8px;
    background: #fff; color: #475569;
    font-size: 12px; font-weight: 600; cursor: pointer;
    transition: all .15s;
}
.tt-ratios button:hover { border-color: #c7d2fe; color: #4f6ef7; }
.tt-ratios button.is-on {
    background: #4f6ef7; border-color: #4f6ef7; color: #fff;
    box-shadow: 0 2px 6px rgba(79, 110, 247, .28);
}

.tt-canvas-box {
    position: relative;
    display: flex; align-items: center; justify-content: center;
    /* 输出是不透明 PNG，不用棋盘格（否则会让人以为图有透明区域） */
    background: #f4f7fb;
    border: 1px solid #eef2f7;
    border-radius: 12px;
    padding: 14px;
    min-height: 240px;
    overflow: hidden;
}
.tt-canvas-box canvas {
    display: block;
    max-width: 100%;
    max-height: 62vh;
    width: auto; height: auto;
    border-radius: 4px;
    box-shadow: 0 2px 12px rgba(15, 23, 42, .1);
    background: #fff;
}
.tt-canvas-box.is-holding canvas { box-shadow: 0 0 0 2px #4f6ef7; }

.tt-size {
    font-size: 12px; color: #94a3b8;
    font-variant-numeric: tabular-nums;
}
.tt-stage-foot {
    display: flex; align-items: center; gap: 10px;
    margin-top: 12px; flex-wrap: wrap;
}
.tt-stage-actions { display: flex; gap: 8px; margin-left: auto; flex-wrap: wrap; }
@media (max-width: 560px) {
    .tt-stage-actions { margin-left: 0; width: 100%; }
    .tt-stage-actions .tt-btn { flex: 1 1 auto; }
    /* 「按住看嵌入位置」文案长，让它独占一行，另两个并排更整齐 */
    .tt-stage-actions .tt-btn:first-child { flex: 1 1 100%; }
    .tt-canvas-box canvas { max-height: 42vh; }
}

/* ---------- 按钮 ---------- */
.tt-btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    height: 34px; padding: 0 14px;
    border-radius: 9px; border: 1px solid transparent;
    font-size: 13px; font-weight: 600;
    cursor: pointer; white-space: nowrap;
    transition: transform .12s, box-shadow .15s, background .15s, border-color .15s;
    user-select: none;
}
.tt-btn:active { transform: translateY(1px); }
.tt-btn-primary {
    background: #4f6ef7; color: #fff;
    box-shadow: 0 2px 8px rgba(79, 110, 247, .26);
}
.tt-btn-primary:hover { background: #4360e8; }
.tt-btn-outline {
    background: #fff; color: #334155; border-color: #dbe2ea;
}
.tt-btn-outline:hover { border-color: #b9c6d8; background: #f8fafc; }
.tt-btn-ghost {
    background: #f1f5f9; color: #475569; border-color: transparent;
}
.tt-btn-ghost:hover { background: #e6ecf4; }
.tt-btn-ghost.is-holding { background: #4f6ef7; color: #fff; }
.tt-btn[disabled] { opacity: .55; cursor: not-allowed; transform: none; }

/* ---------- 纹理选择 ---------- */
.tt-textures {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
}
.tt-tex {
    display: flex; flex-direction: column; align-items: center; gap: 6px;
    padding: 9px 4px 8px;
    border: 1px solid #e6ecf4; border-radius: 10px;
    background: #fff; cursor: pointer;
    transition: all .15s;
}
.tt-tex:hover { border-color: #c7d2fe; background: #f8faff; }
.tt-tex.is-on {
    border-color: #4f6ef7;
    background: #f2f5ff;
    box-shadow: 0 0 0 1px #4f6ef7 inset;
}
.tt-tex-swatch {
    width: 38px; height: 26px; border-radius: 5px;
    background-color: #fff;
    border: 1px solid #eef2f7;
}
.tt-tex-name { font-size: 11px; color: #64748b; font-weight: 600; line-height: 1; }
.tt-tex.is-on .tt-tex-name { color: #4f6ef7; }

/* 纹理小样（纯 CSS 图案，不额外加载图片） */
.sw-zig {
    background-image:
        repeating-linear-gradient(115deg, #b6c2d4 0 1px, transparent 1px 5px),
        repeating-linear-gradient(65deg, #b6c2d4 0 1px, transparent 1px 5px);
}
.sw-dot {
    background-image: radial-gradient(#b6c2d4 1.1px, transparent 1.3px);
    background-size: 6px 6px;
}
.sw-line {
    background-image: repeating-linear-gradient(45deg, #b6c2d4 0 1px, transparent 1px 6px);
}
.sw-grid {
    background-image:
        repeating-linear-gradient(0deg, #b6c2d4 0 1px, transparent 1px 6px),
        repeating-linear-gradient(90deg, #b6c2d4 0 1px, transparent 1px 6px);
}
.sw-cross {
    background-image:
        radial-gradient(circle at 3px 3px, #b6c2d4 0 0.9px, transparent 1.1px),
        repeating-linear-gradient(0deg, #dbe3ee 0 1px, transparent 1px 6px),
        repeating-linear-gradient(90deg, #dbe3ee 0 1px, transparent 1px 6px);
}
.sw-wave {
    background-image: repeating-linear-gradient(0deg, #b6c2d4 0 1px, transparent 1px 6px);
    background-size: 100% 6px;
    position: relative;
}

/* ---------- 表单 ---------- */
.tt-field { margin-bottom: 13px; }
.tt-field > label {
    display: flex; align-items: baseline; gap: 6px;
    font-size: 13px; font-weight: 600; color: #334155;
    margin-bottom: 7px;
}
.tt-sub { font-weight: 400; font-size: 11px; color: #94a3b8; }
.tt-val {
    margin-left: auto; font-size: 12px; font-weight: 700; color: #4f6ef7;
    font-variant-numeric: tabular-nums;
    background: #f2f5ff; padding: 1px 7px; border-radius: 5px;
}

.tt-textarea {
    width: 100%; box-sizing: border-box;
    min-height: 66px; resize: vertical;
    padding: 9px 11px;
    border: 1px solid #dfe6ee; border-radius: 9px;
    font-size: 13.5px; line-height: 1.55; color: #0f172a;
    font-family: inherit;
    background: #fcfdff;
    transition: border-color .15s, box-shadow .15s;
}
.tt-textarea:focus {
    outline: none; border-color: #4f6ef7;
    box-shadow: 0 0 0 3px rgba(79, 110, 247, .12);
    background: #fff;
}
.tt-count {
    text-align: right; font-size: 11px; color: #94a3b8;
    margin-top: 4px; font-variant-numeric: tabular-nums;
}

.tt-range {
    -webkit-appearance: none; appearance: none;
    width: 100%; height: 4px; border-radius: 3px;
    background: #e6ecf4; outline: none; margin: 0;
    cursor: pointer;
}
.tt-range::-webkit-slider-thumb {
    -webkit-appearance: none; appearance: none;
    width: 16px; height: 16px; border-radius: 50%;
    background: #fff; border: 2px solid #4f6ef7;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .18);
    cursor: pointer;
}
.tt-range::-moz-range-thumb {
    width: 14px; height: 14px; border-radius: 50%;
    background: #fff; border: 2px solid #4f6ef7;
    box-shadow: 0 1px 3px rgba(15, 23, 42, .18);
    cursor: pointer;
}
.tt-range:focus-visible { outline: 2px solid #4f6ef7; outline-offset: 4px; }

.tt-scale-hint {
    display: flex; justify-content: space-between;
    font-size: 11px; color: #a8b3c4; margin-top: 5px;
}

/* 颜色行 */
.tt-colors { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.tt-color-item { display: flex; align-items: center; gap: 8px; }
.tt-color-item input[type="color"] {
    -webkit-appearance: none; appearance: none;
    width: 36px; height: 30px; padding: 0;
    border: 1px solid #dfe6ee; border-radius: 7px;
    background: #fff; cursor: pointer;
}
.tt-color-item input[type="color"]::-webkit-color-swatch-wrapper { padding: 3px; }
.tt-color-item input[type="color"]::-webkit-color-swatch { border: none; border-radius: 4px; }
.tt-color-item span { font-size: 12px; color: #64748b; }

/* 输出尺寸 */
.tt-select {
    width: 100%; height: 34px; padding: 0 10px;
    border: 1px solid #dfe6ee; border-radius: 9px;
    background: #fff; color: #0f172a;
    font-size: 13px; font-family: inherit; cursor: pointer;
}
.tt-select:focus { outline: none; border-color: #4f6ef7; box-shadow: 0 0 0 3px rgba(79, 110, 247, .12); }

/* ---------- 说明 ---------- */
.tt-note {
    font-size: 12.5px; line-height: 1.75; color: #64748b;
    background: #f8fafc; border: 1px solid #eef2f7;
    border-radius: 10px; padding: 12px 14px;
}
.tt-note b { color: #334155; }
.tt-note code {
    background: #eef2f7; padding: 1px 5px; border-radius: 4px;
    font-size: 11.5px; color: #4f6ef7;
}

/* 生成中遮罩 */
.tt-stage-card.is-busy .tt-canvas-box::after {
    content: "";
    position: absolute; inset: 0;
    background: rgba(255, 255, 255, .45);
    pointer-events: none;
}

/* ---------- 桌面端：预览吸顶 ---------- */
@media (min-width: 901px) {
    .tt-stage-card { position: sticky; top: 74px; }
}

/* ---------- 移动端：预览吸顶 ---------- */
@media (max-width: 900px) {
    .tt-stage-card {
        position: sticky;
        top: 54px;
        z-index: 6;
        margin-bottom: 10px;
        box-shadow: 0 6px 20px rgba(15, 23, 42, .08);
    }
    .tt-canvas-box { padding: 10px; min-height: 0; }
    .tt-canvas-box canvas { max-height: 30vh; }
    .tt-stage-card .tt-stage-foot { margin-top: 9px; }
}
@media (max-width: 900px) and (max-height: 700px) {
    .tt-canvas-box canvas { max-height: 24vh; }
}

/* ---------- 暗色外壳适配（工具本体仍浅色，只调外围） ---------- */
html.dark .tt-card { background: #161a22; border-color: #262c38; }
html.dark .tt-card-title, html.dark .tt-stage-head > b { color: #e2e8f0; }
html.dark .tt-textarea, html.dark .tt-select {
    background: #1c222c; border-color: #2c3442; color: #e2e8f0;
}
html.dark .tt-textarea:focus { background: #1c222c; }
html.dark .tt-range { background: #2c3442; }
html.dark .tt-btn-outline { background: #1c222c; color: #cbd5e1; border-color: #2c3442; }
html.dark .tt-btn-outline:hover { background: #232a36; }
html.dark .tt-btn-ghost { background: #232a36; color: #cbd5e1; }
html.dark .tt-tex { background: #1c222c; border-color: #2c3442; }
html.dark .tt-tex:hover { background: #232a36; border-color: #3b4a63; }
html.dark .tt-tex.is-on { background: #1e2740; border-color: #4f6ef7; }
html.dark .tt-tex-name { color: #94a3b8; }
html.dark .tt-ratios button { background: #1c222c; border-color: #2c3442; color: #cbd5e1; }
html.dark .tt-note { background: #1a1f29; border-color: #262c38; color: #94a3b8; }
html.dark .tt-note b { color: #cbd5e1; }
html.dark .tt-note code { background: #232a36; }
html.dark .tt-canvas-box { border-color: #262c38; background: #12161d; }
html.dark .tt-field > label { color: #cbd5e1; }
html.dark .tt-color-item span { color: #94a3b8; }
