/* 图片拼接 /tools/image-stitcher —— class 前缀 ist-，沿用站点主题变量自动适配深/浅色
   复刻 tools.ai225.com/tools/image-stitcher 的交互与视觉：上传区 / 设置面板 / 顺序列表 / 预览 */
.ist {
    width: 100%;
    box-sizing: border-box;
    padding: 22px 24px 40px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

/* ===== 头部 ===== */
.ist-hero { display: flex; align-items: center; gap: 14px; }
.ist-hero-ico {
    width: 46px; height: 46px; flex: 0 0 46px; border-radius: 14px; display: flex; align-items: center; justify-content: center;
    font-size: 24px; line-height: 1; background: color-mix(in srgb, var(--accent) 12%, transparent);
    border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent);
}
.ist-hero-txt { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.ist-title { margin: 0; font-size: 22px; font-weight: 800; color: var(--text-primary); }
.ist-sub { margin: 0; font-size: 13.5px; line-height: 1.7; color: var(--text-secondary); }

/* ===== 主体两栏 ===== */
.ist-main {
    display: grid; gap: 16px; align-items: start;
    grid-template-columns: minmax(0, 1fr) 340px;
}
.ist-col { display: flex; flex-direction: column; gap: 14px; min-width: 0; }

/* ===== 卡片 ===== */
.ist-card {
    background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 14px;
    padding: 14px 15px; display: flex; flex-direction: column; gap: 12px; min-width: 0;
}
.ist-card-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.ist-card-title { margin: 0; font-size: 14.5px; font-weight: 800; color: var(--text-primary); flex: 1 1 auto; }
.ist-card-sub { font-size: 12.5px; color: var(--text-secondary); font-weight: 500; }

/* ===== 通用控件 ===== */
.ist-btn {
    padding: 8px 14px; font-size: 13.5px; font-weight: 600; font-family: inherit; border-radius: 10px;
    border: 1px solid var(--border-color); background: var(--bg-primary); color: var(--text-primary);
    cursor: pointer; transition: all .15s;
}
.ist-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
.ist-btn:disabled { opacity: .45; cursor: not-allowed; }
.ist-btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 8px; }
.ist-btn-go { background: var(--accent); border-color: var(--accent); color: #fff; width: 100%; }
.ist-btn-go:hover:not(:disabled) { color: #fff; filter: brightness(1.08); }
.ist-btn-danger { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.ist-btn-danger:hover:not(:disabled) { border-color: var(--danger); color: var(--danger); }

.ist-input, .ist-select {
    padding: 7px 10px; font-size: 13.5px; font-family: inherit; border-radius: 9px;
    border: 1px solid var(--border-color); background: var(--bg-secondary); color: var(--text-primary);
    min-width: 0; box-sizing: border-box;
}
.ist-input:focus, .ist-select:focus { outline: none; border-color: var(--accent); }
.ist-input:disabled, .ist-select:disabled { opacity: .5; cursor: not-allowed; }
.ist-input-sm { width: 88px; }
.ist-select { flex: 1 1 auto; }

/* 分段按钮（参考站同款三选一） */
.ist-seg {
    display: flex; gap: 4px; padding: 3px; border-radius: 10px;
    background: var(--bg-secondary); border: 1px solid var(--border-color);
}
.ist-seg-btn {
    flex: 1 1 0; min-width: 0; padding: 6px 4px; font-size: 12.5px; font-weight: 600; font-family: inherit;
    border: 0; border-radius: 7px; background: transparent; color: var(--text-secondary); cursor: pointer;
    display: flex; align-items: center; justify-content: center; gap: 4px; transition: all .15s;
}
.ist-seg-btn.is-on {
    background: var(--bg-primary); color: var(--text-primary);
    box-shadow: 0 1px 3px rgba(0, 0, 0, .12);
}
.ist-seg-btn:disabled { opacity: .45; cursor: not-allowed; }

/* ===== 设置行 ===== */
.ist-row { display: flex; flex-direction: column; gap: 6px; }
.ist-row.is-inline { flex-direction: row; align-items: center; justify-content: space-between; gap: 10px; }
.ist-label { font-size: 12.5px; font-weight: 600; color: var(--text-secondary); }
.ist-check { display: flex; align-items: center; gap: 7px; cursor: pointer; font-size: 13px; color: var(--text-primary); }
.ist-check input { width: 16px; height: 16px; accent-color: var(--accent); flex: 0 0 auto; }
.ist-check.is-disabled { opacity: .55; cursor: not-allowed; }
.ist-hint { font-size: 11.5px; color: var(--text-secondary); line-height: 1.5; }

.ist-color { display: flex; align-items: center; gap: 8px; }
.ist-color input[type="color"] {
    width: 46px; height: 32px; padding: 2px; border-radius: 8px; cursor: pointer;
    border: 1px solid var(--border-color); background: var(--bg-secondary);
}
.ist-color input[type="color"]:disabled { opacity: .5; cursor: not-allowed; }
.ist-color-code {
    font-size: 12.5px; font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    color: var(--text-secondary); text-transform: uppercase;
}

.ist-range { display: flex; align-items: center; gap: 10px; }
.ist-range input[type="range"] { flex: 1 1 auto; min-width: 0; accent-color: var(--accent); }
.ist-range-val {
    font-size: 12.5px; font-weight: 700; color: var(--text-primary); min-width: 42px; text-align: right;
    font-variant-numeric: tabular-nums;
}

/* ===== 预览区 ===== */
.ist-prev {
    border: 1px solid var(--border-color); border-radius: 12px; background: var(--bg-secondary);
    min-height: 260px; padding: 14px; display: flex; align-items: center; justify-content: center; overflow: auto;
    /* 透明背景时用棋盘格提示透明区 */
    background-image:
        linear-gradient(45deg, color-mix(in srgb, var(--text-primary) 6%, transparent) 25%, transparent 25%),
        linear-gradient(-45deg, color-mix(in srgb, var(--text-primary) 6%, transparent) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, color-mix(in srgb, var(--text-primary) 6%, transparent) 75%),
        linear-gradient(-45deg, transparent 75%, color-mix(in srgb, var(--text-primary) 6%, transparent) 75%);
    background-size: 18px 18px;
    background-position: 0 0, 0 9px, 9px -9px, -9px 0;
}
.ist-prev-canvas { max-width: 100%; height: auto; display: block; border-radius: 6px; box-shadow: 0 4px 18px rgba(0, 0, 0, .14); }
.ist-prev-canvas[hidden] { display: none !important; }
.ist-empty { display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.ist-empty[hidden] { display: none !important; }
.ist-empty-ico { font-size: 42px; line-height: 1; opacity: .55; }
.ist-empty-tx { margin: 0; font-size: 13.5px; color: var(--text-secondary); }
.ist-prev.is-over { border-color: var(--accent); }
/* 空态里的按钮不铺满整行 */
.ist-empty-btn { width: auto; padding: 8px 22px; }

/* [hidden] 兜底：站点里部分元素声明了 display，会覆盖原生 hidden */
.ist [hidden] { display: none !important; }

.ist-meta {
    display: flex; flex-wrap: wrap; gap: 8px 14px; font-size: 12.5px; color: var(--text-secondary);
}
.ist-meta b { color: var(--text-primary); font-variant-numeric: tabular-nums; }

/* ===== 图片顺序列表 ===== */
.ist-list {
    display: grid; grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); gap: 10px;
}
.ist-list[hidden] { display: none !important; }
.ist-item {
    border: 1px solid var(--border-color); border-radius: 11px; background: var(--bg-secondary);
    padding: 8px; display: flex; flex-direction: column; gap: 7px; position: relative;
    cursor: grab; content-visibility: auto; contain-intrinsic-size: auto 150px;
}
.ist-item.is-drag { opacity: .45; }
.ist-item.is-over { border-color: var(--accent); border-style: dashed; }
.ist-thumb {
    width: 100%; height: 78px; border-radius: 8px; overflow: hidden; background: var(--bg-primary);
    display: flex; align-items: center; justify-content: center;
}
.ist-thumb img { max-width: 100%; max-height: 100%; object-fit: contain; display: block; }
.ist-item-name {
    font-size: 12px; color: var(--text-primary); line-height: 1.4; word-break: break-all;
    display: -webkit-box; -webkit-line-clamp: 1; -webkit-box-orient: vertical; overflow: hidden;
}
.ist-item-meta { font-size: 11px; color: var(--text-secondary); font-variant-numeric: tabular-nums; }
.ist-item-ops { display: flex; gap: 5px; }
.ist-item-ops button {
    flex: 1 1 0; padding: 4px 0; font-size: 12px; line-height: 1.4; font-family: inherit; cursor: pointer;
    border: 1px solid var(--border-color); border-radius: 7px; background: var(--bg-primary); color: var(--text-secondary);
}
.ist-item-ops button:hover:not(:disabled) { color: var(--accent); border-color: var(--accent); }
.ist-item-ops button:disabled { opacity: .4; cursor: not-allowed; }
.ist-item-del:hover:not(:disabled) { color: var(--danger) !important; border-color: var(--danger) !important; }
.ist-item-idx {
    position: absolute; top: 6px; left: 6px; min-width: 20px; height: 20px; padding: 0 5px; border-radius: 6px;
    background: rgba(0, 0, 0, .62); color: #fff; font-size: 11px; font-weight: 700; line-height: 20px; text-align: center;
}

/* ===== 提示条 ===== */
.ist-note {
    margin: 0; padding: 9px 13px; border-radius: 11px; font-size: 13px; line-height: 1.6;
    border: 1px solid var(--border-color); background: var(--bg-secondary); color: var(--text-secondary);
}
.ist-note[hidden] { display: none !important; }
.ist-note.is-err { color: var(--danger); border-color: color-mix(in srgb, var(--danger) 45%, transparent); }
.ist-note.is-ok { color: #15803d; border-color: #86efac; }

/* ===== 说明区 ===== */
.ist-info {
    background: var(--bg-primary); border: 1px solid var(--border-color); border-radius: 14px; padding: 16px 18px;
}
.ist-info h2 { margin: 0 0 8px; font-size: 15px; font-weight: 800; color: var(--text-primary); }
.ist-info p { margin: 0 0 12px; font-size: 13.5px; line-height: 1.8; color: var(--text-secondary); }
.ist-info h3 { margin: 0 0 8px; font-size: 13.5px; font-weight: 800; color: var(--text-primary); }
.ist-info ul { margin: 0; padding: 0; list-style: none; display: grid; gap: 6px; }
.ist-info li { font-size: 13px; line-height: 1.7; color: var(--text-secondary); }

/* ===== 响应式 ===== */
@media (max-width: 1099px) {
    .ist-main { grid-template-columns: minmax(0, 1fr); }
}
@media (max-width: 767px) {
    .ist { padding: 16px 14px 34px; }
    .ist-hero-ico { width: 40px; height: 40px; flex-basis: 40px; font-size: 21px; }
    .ist-title { font-size: 19px; }
    .ist-main { gap: 12px; }
    .ist-card { padding: 12px; }
    .ist-prev { min-height: 200px; padding: 10px; }
    .ist-list { grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
    /* iOS 聚焦缩放防护 */
    .ist-input, .ist-select { font-size: 16px; }
    .ist-seg-btn { font-size: 13px; padding: 8px 4px; }
    .ist-btn-sm { padding: 7px 11px; }
}
@media (max-width: 420px) {
    .ist-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .ist-hero { gap: 10px; }
}
