/* 图片工具箱 · 证件照/裁剪/格式转换 页面样式
   浅色卡片风，与 stats 看板同一套视觉语言 */

:root {
    --bg: #f4f7fc;
    --card: #ffffff;
    --line: #e6ecf5;
    --line-soft: #eef3fa;
    --text: #1c2434;
    --text-2: #56617a;
    --muted: #8e98ab;
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --brand-soft: #eef4ff;
    --ok: #0d9f6e;
    --danger: #e5484d;
    --danger-soft: #fef1f1;
    --radius: 16px;
    --radius-s: 10px;
    --shadow: 0 1px 2px rgba(20, 30, 55, .04), 0 12px 32px -18px rgba(20, 30, 55, .18);
}

* { box-sizing: border-box; }

/* hidden 属性必须能压住后面的 display 声明 */
[hidden] { display: none !important; }

html, body {
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
        "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -webkit-text-size-adjust: 100%;
}

img { max-width: 100%; }

/* ---------------- 顶部栏 ---------------- */

.topbar {
    position: sticky;
    top: 0;
    z-index: 20;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: saturate(180%) blur(10px);
    border-bottom: 1px solid var(--line);
}

.tb-in {
    max-width: 1200px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.brand {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text);
}

.brand-mark {
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: #fff;
    font-size: 16px;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px -4px rgba(37, 99, 235, .6);
}

.brand-txt { font-size: 15px; font-weight: 600; letter-spacing: .2px; }

.tb-nav { display: flex; align-items: center; gap: 12px; }

.crumb {
    font-size: 13px;
    color: var(--muted);
    display: none;
}

.ghost-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: #fff;
    color: var(--text-2);
    font-size: 13px;
    text-decoration: none;
    transition: all .16s ease;
    white-space: nowrap;
}

.ghost-btn:hover {
    color: var(--brand);
    border-color: #c8daf8;
    background: var(--brand-soft);
    text-decoration: none;
}

/* ---------------- 页面骨架 ---------------- */

.wrap {
    max-width: 1200px;
    margin: 0 auto;
    padding: 28px 20px 56px;
}

.page-head { margin-bottom: 22px; }

.page-head h1 {
    margin: 0 0 6px;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -.2px;
}

.page-head p {
    margin: 0;
    font-size: 13.5px;
    color: var(--text-2);
    max-width: 680px;
}

.grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
    align-items: stretch;
}

/* ---------------- 卡片 ---------------- */

.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.card > form {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
}

.card-hd {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 18px 18px 14px;
    border-bottom: 1px solid var(--line-soft);
}

.card-hd h2 {
    margin: 0 0 2px;
    font-size: 16px;
    font-weight: 650;
}

.card-hd p {
    margin: 0;
    font-size: 12.5px;
    color: var(--muted);
    line-height: 1.45;
}

.ic {
    flex: 0 0 auto;
    width: 38px;
    height: 38px;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ic svg { width: 20px; height: 20px; }

.ic-crop { background: #eef4ff; color: #2563eb; }
.ic-id { background: #eafaf3; color: #0d9f6e; }
.ic-fmt { background: #fdf3e8; color: #d97706; }

.card-bd {
    padding: 18px;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
}

/* ---------------- 表单块 ---------------- */

.field { margin-bottom: 16px; }

.field-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-2);
    margin-bottom: 8px;
}

/* 分段选择器 */

.seg {
    display: flex;
    gap: 4px;
    background: #f1f5fb;
    border-radius: var(--radius-s);
    padding: 4px;
}

.seg-btn {
    flex: 1 1 0;
    min-width: 0;
    border: 0;
    background: transparent;
    color: var(--text-2);
    font-size: 12.5px;
    font-weight: 500;
    padding: 8px 6px;
    border-radius: 7px;
    cursor: pointer;
    transition: all .16s ease;
    white-space: nowrap;
    font-family: inherit;
}

.seg-btn:hover { color: var(--brand); }

.seg-btn.is-on {
    background: #fff;
    color: var(--brand);
    font-weight: 650;
    box-shadow: 0 1px 3px rgba(20, 30, 55, .12);
}

/* 背景色色卡 */

.colors { display: flex; gap: 8px; }

.color-chip {
    flex: 1 1 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 6px;
    border: 1.5px solid var(--line);
    border-radius: var(--radius-s);
    background: #fff;
    color: var(--text-2);
    font-size: 12.5px;
    font-family: inherit;
    cursor: pointer;
    transition: all .16s ease;
}

.color-chip i {
    width: 13px;
    height: 13px;
    border-radius: 50%;
    display: inline-block;
    flex: 0 0 auto;
}

.color-chip:hover { border-color: #c8daf8; }

.color-chip.is-on {
    border-color: var(--brand);
    background: var(--brand-soft);
    color: var(--brand);
    font-weight: 650;
}

/* 拖拽上传区 */

.drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    padding: 18px 12px;
    border: 1.5px dashed #cfdaea;
    border-radius: 12px;
    background: #fafcff;
    cursor: pointer;
    text-align: center;
    transition: all .16s ease;
    margin: 0;
}

.drop:hover,
.drop.is-over {
    border-color: var(--brand);
    background: var(--brand-soft);
}

.drop svg {
    width: 22px;
    height: 22px;
    color: var(--brand);
    margin-bottom: 3px;
}

.drop-main { font-size: 13px; font-weight: 600; color: var(--text); }
.drop-sub { font-size: 11.5px; color: var(--muted); }

/* 已选文件信息条 */

.file-chip {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 9px 11px;
    border: 1px solid var(--line);
    border-radius: var(--radius-s);
    background: #fbfcfe;
}

.file-chip img {
    width: 38px;
    height: 38px;
    object-fit: cover;
    border-radius: 7px;
    border: 1px solid var(--line);
    flex: 0 0 auto;
}

.file-chip .fc-txt {
    min-width: 0;
    flex: 1 1 auto;
}

.file-chip .fc-name {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-chip .fc-size { font-size: 11.5px; color: var(--muted); }

/* ---------------- 按钮 ---------------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    border: 1px solid transparent;
    border-radius: var(--radius-s);
    font-family: inherit;
    font-size: 13.5px;
    font-weight: 600;
    padding: 11px 16px;
    cursor: pointer;
    text-decoration: none;
    transition: all .16s ease;
    -webkit-appearance: none;
}

.btn:disabled { opacity: .62; cursor: not-allowed; }

.btn-main {
    background: var(--brand);
    color: #fff;
    box-shadow: 0 6px 14px -8px rgba(37, 99, 235, .9);
}

.btn-main:hover:not(:disabled),
.btn-main:focus { background: var(--brand-dark); color: #fff; text-decoration: none; }

.btn-soft {
    background: #f1f5fb;
    color: var(--text-2);
}

.btn-soft:hover:not(:disabled) { background: #e7eefa; color: var(--brand); text-decoration: none; }

.btn-block { width: 100%; }

.row-btns { display: flex; gap: 8px; margin-top: 12px; }
.row-btns .btn { flex: 1 1 0; }
.row-btns .btn-soft { flex: 0 0 auto; }

.spin {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    border: 2px solid rgba(255, 255, 255, .45);
    border-top-color: #fff;
    animation: sp .7s linear infinite;
}

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

/* ---------------- 裁剪舞台 ---------------- */

.crop-stage {
    position: relative;
    margin-top: 12px;
    height: 268px;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: #f7f9fd;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.crop-stage img {
    display: block;
    max-width: 100%;
    max-height: 100%;
}

/* ---------------- 结果区 ---------------- */

.out-box { margin-top: auto; padding-top: 14px; }

.out-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 76px;
    padding: 14px;
    border: 1.5px dashed var(--line);
    border-radius: 12px;
    background: #fbfcfe;
    color: var(--muted);
    font-size: 12.5px;
    text-align: center;
}

.out-img {
    display: block;
    margin: 0 auto;
    max-height: 320px;
    border-radius: 10px;
    border: 1px solid var(--line);
    background: #fff;
}

.out-actions { margin-top: 10px; display: flex; }
.out-actions .btn { flex: 1 1 auto; }

/* ---------------- 提示条 ---------------- */

.alert-err,
.tip {
    border-radius: var(--radius-s);
    padding: 9px 12px;
    font-size: 12.5px;
    line-height: 1.5;
    margin: 0 0 14px;
}

.alert-err {
    background: var(--danger-soft);
    color: #b4302f;
    border: 1px solid #f8d5d5;
}

.tip {
    background: #f3f7ff;
    color: #40598f;
    border: 1px solid #e0e9fa;
}

.tip strong { color: var(--brand); }

/* ---------------- 页脚 ---------------- */

.foot {
    max-width: 1200px;
    margin: 8px auto 0;
    padding: 0 20px 40px;
    text-align: center;
    color: var(--muted);
    font-size: 12.5px;
}

.foot a { color: var(--text-2); text-decoration: none; }
.foot a:hover { color: var(--brand); }

/* ---------------- 响应式 ---------------- */

@media (max-width: 1020px) {
    .grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .grid > .card:first-child { grid-column: 1 / -1; }
    .crop-stage { height: 320px; }
}

@media (max-width: 720px) {
    .grid { grid-template-columns: minmax(0, 1fr); gap: 16px; }
    .grid > .card:first-child { grid-column: auto; }
    .wrap { padding: 20px 14px 48px; }
    .tb-in { padding: 10px 14px; }
    .page-head h1 { font-size: 21px; }
    .card-bd { padding: 15px; }
    .card-hd { padding: 15px 15px 12px; }
    .crop-stage { height: 260px; }
    .crumb { display: none; }
    .btn { padding: 10px 14px; }
    .out-img { max-height: 260px; }
}

@media (min-width: 721px) and (max-width: 1020px) {
    .crumb { display: inline; }
}
