/* ============================================
   app.css — 酷哥图腾
   ============================================ */
:root {
    --brand: #5b6ef5;
    --brand-2: #8a5bf5;
    --ink: #1b1f2a;
    --ink-2: #5b6273;
    --ink-3: #8d94a6;
    --line: #e8eaf0;
    --bg: #f5f6fa;
    --card: #fff;
    --ok: #16a34a;
    --bad: #e5484d;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(20, 24, 40, .04), 0 8px 24px rgba(20, 24, 40, .05);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background: var(--bg);
    color: var(--ink);
    font: 14px/1.6 -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
    -webkit-font-smoothing: antialiased;
}

a { color: var(--brand); text-decoration: none; }
a:hover { text-decoration: underline; }
.hidden { display: none !important; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12.5px; }
.muted { color: var(--ink-3); }
.hint { color: var(--ink-3); font-size: 12.5px; }

/* ---------- 顶栏 ---------- */
.topbar {
    display: flex; align-items: center; gap: 18px;
    padding: 0 20px; height: 60px;
    background: #fff; border-bottom: 1px solid var(--line);
    position: sticky; top: 0; z-index: 40;
}
.brand { display: flex; align-items: center; gap: 9px; font-weight: 700; color: var(--ink); }
.brand:hover { text-decoration: none; }
.brand-logo { font-size: 20px; }
.brand-text { font-size: 16px; letter-spacing: .3px; }
.nav { display: flex; gap: 4px; flex: 1; overflow-x: auto; }
.nav a {
    padding: 7px 13px; border-radius: 9px; color: var(--ink-2);
    font-size: 13.5px; white-space: nowrap;
}
.nav a:hover { background: #f2f3f9; text-decoration: none; }
.nav a.on { background: #eef0ff; color: var(--brand); font-weight: 600; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.user-chip { color: var(--ink-2); font-size: 13px; }
.logout { color: var(--ink-3); font-size: 13px; }

/* ---------- 布局 ---------- */
.wrap { max-width: 1080px; margin: 0 auto; padding: 22px 18px 60px; }
.page-head { margin-bottom: 18px; }
.page-head h1 { font-size: 21px; letter-spacing: .2px; }
.page-head p { color: var(--ink-3); font-size: 13px; margin-top: 3px; }

.panel {
    background: var(--card); border: 1px solid var(--line);
    border-radius: var(--radius); box-shadow: var(--shadow);
    padding: 18px 20px; margin-bottom: 18px;
}
.panel-head {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px; flex-wrap: wrap; margin-bottom: 14px;
}
.panel-head h2 { font-size: 15.5px; }
.panel-sub-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; margin-bottom: 10px;
}
.panel-sub-head h3 { font-size: 13.5px; color: var(--ink-2); font-weight: 600; }
.actions { display: flex; gap: 8px; }

/* ---------- 统计 ---------- */
.stats-row { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; margin-bottom: 18px; }
.stat {
    background: #fff; border: 1px solid var(--line); border-radius: 12px;
    padding: 13px 15px; display: flex; flex-direction: column; gap: 2px;
}
.stat .n { font-size: 19px; font-weight: 700; letter-spacing: .2px; }
.stat .l { font-size: 12px; color: var(--ink-3); }

/* ---------- 按钮 ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    border: 1px solid transparent; border-radius: 9px;
    padding: 9px 16px; font-size: 13.5px; font-weight: 500;
    cursor: pointer; background: #f2f3f9; color: var(--ink-2);
    transition: .15s; white-space: nowrap; text-decoration: none !important;
}
.btn:hover { filter: brightness(.97); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: linear-gradient(135deg, var(--brand), var(--brand-2)); color: #fff; box-shadow: 0 4px 14px rgba(91, 110, 245, .25); }
.btn-ghost { background: #fff; border-color: var(--line); color: var(--ink-2); }
.btn-danger { background: #fff1f1; color: var(--bad); border-color: #ffd7d7; }
.btn-sm { padding: 6px 11px; font-size: 12.5px; border-radius: 8px; }
.btn-block { width: 100%; padding: 12px; font-size: 15px; }

/* ---------- 上传区 ---------- */
.dropzone {
    border: 2px dashed #d6dae8; border-radius: 12px;
    padding: 30px 20px; text-align: center; cursor: pointer;
    background: #fbfcff; transition: .15s;
}
.dropzone:hover, .dropzone.over { border-color: var(--brand); background: #f2f4ff; }
.dz-icon { font-size: 26px; }
.dz-main { font-weight: 600; margin-top: 6px; }
.dz-sub { color: var(--ink-3); font-size: 12.5px; margin-top: 3px; }

.staged-wrap { margin-top: 16px; }
.staged { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 10px; }
.stage-item {
    position: relative; border-radius: 10px; overflow: hidden;
    border: 1px solid var(--line); background: #f7f8fc; aspect-ratio: 1;
}
.stage-item img { width: 100%; height: 100%; object-fit: cover; cursor: pointer; display: block; }
.stage-item.edited { border-color: #9db4ff; box-shadow: 0 0 0 2px #e8edff; }
.stage-item.done { opacity: .45; }
.stage-badge {
    position: absolute; left: 5px; bottom: 5px;
    background: rgba(16, 20, 34, .72); color: #fff;
    font-size: 10.5px; padding: 1px 6px; border-radius: 5px;
}
.stage-del {
    position: absolute; right: 4px; top: 4px;
    width: 20px; height: 20px; border-radius: 50%; border: 0;
    background: rgba(16, 20, 34, .6); color: #fff; cursor: pointer;
    font-size: 14px; line-height: 18px;
}

.progress { margin-top: 14px; display: flex; align-items: center; gap: 10px; }
.progress .bar { height: 6px; background: linear-gradient(90deg, var(--brand), var(--brand-2)); border-radius: 4px; width: 0; transition: width .2s; flex: 1; }
.progress span { font-size: 12px; color: var(--ink-3); white-space: nowrap; }

/* ---------- 结果 ---------- */
.results { display: flex; flex-direction: column; gap: 10px; }
.result-item {
    display: flex; gap: 12px; align-items: center;
    border: 1px solid var(--line); border-radius: 11px; padding: 10px;
    background: #fcfdff;
}
.result-item.error { background: #fff8f8; border-color: #ffdede; }
.result-thumb { width: 62px; height: 62px; border-radius: 8px; overflow: hidden; background: #f0f1f6; flex: none; }
.result-thumb img { width: 100%; height: 100%; object-fit: cover; }
.result-main { min-width: 0; flex: 1; }
.result-url {
    font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 12.5px;
    color: var(--ink); background: #f4f6fd; border-radius: 6px;
    padding: 4px 8px; cursor: pointer; overflow: hidden;
    text-overflow: ellipsis; white-space: nowrap;
}
.result-sub { font-size: 12px; color: var(--ink-3); margin-top: 4px; }
.result-acts { display: flex; gap: 6px; margin-top: 7px; flex-wrap: wrap; }

/* ---------- 图库 ---------- */
.gallery { display: grid; grid-template-columns: repeat(auto-fill, minmax(158px, 1fr)); gap: 13px; }
.gcard { border: 1px solid var(--line); border-radius: 11px; overflow: hidden; background: #fff; }
.gthumb { aspect-ratio: 1; background: #f2f3f8; cursor: zoom-in; }
.gthumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.gmeta { padding: 8px 9px 0; }
.gname { font-size: 12.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.gsub { font-size: 11.5px; color: var(--ink-3); }
.gacts { display: flex; gap: 5px; padding: 6px 9px 9px; flex-wrap: wrap; }
.gacts .btn { padding: 4px 8px; font-size: 11.5px; }
.gline-btns { display: grid; grid-template-columns: 1fr; gap: 5px; padding: 8px 9px 0; }
.gline-btns .btn { padding: 5px 6px; font-size: 11.5px; white-space: nowrap; text-align: center; }

.empty { text-align: center; color: var(--ink-3); padding: 34px 10px; }

/* ---------- 表格 ---------- */
.tbl-wrap { overflow-x: auto; }
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
    text-align: left; font-weight: 600; color: var(--ink-2);
    background: #fafbff; padding: 9px 10px; border-bottom: 1px solid var(--line);
    white-space: nowrap;
}
.tbl td { padding: 9px 10px; border-bottom: 1px solid #f3f4f8; vertical-align: middle; }
.tbl tr:last-child td { border-bottom: 0; }

.tag {
    display: inline-block; font-size: 11.5px; padding: 1px 8px;
    border-radius: 20px; background: #f0f1f6; color: var(--ink-2);
}
.tag.ok { background: #e9f9ef; color: #0f7b3d; }
.tag.bad { background: #fff0f0; color: var(--bad); }
.tag.brand { background: #eef0ff; color: var(--brand); }

.input {
    width: 100%; padding: 9px 11px; font-size: 13.5px;
    border: 1px solid var(--line); border-radius: 9px; background: #fff;
    font-family: inherit; color: var(--ink);
}
.input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px #eef0ff; }
.input-sm { padding: 6px 9px; font-size: 12.5px; width: auto; }
.inline-form { display: flex; gap: 8px; margin-top: 12px; flex-wrap: wrap; }
.inline-form .input { max-width: 240px; }

/* ---------- 弹窗 ---------- */
.modal {
    position: fixed; inset: 0; background: rgba(14, 18, 32, .55);
    display: flex; align-items: center; justify-content: center;
    padding: 16px; z-index: 100; backdrop-filter: blur(2px);
}
.modal-box {
    background: #fff; border-radius: 16px; width: 100%; max-width: 460px;
    max-height: 92vh; overflow-y: auto; box-shadow: 0 24px 60px rgba(10, 14, 30, .3);
}
.modal-sm { max-width: 380px; }
.modal-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 15px 18px; border-bottom: 1px solid var(--line);
}
.modal-head h3 { font-size: 15px; }
.modal-x {
    border: 0; background: transparent; font-size: 22px; line-height: 1;
    color: var(--ink-3); cursor: pointer; padding: 0 4px;
}
.modal-foot {
    display: flex; justify-content: flex-end; gap: 9px;
    padding: 13px 18px; border-top: 1px solid var(--line);
}

.crop-stage { padding: 14px; background: #eef0f6; display: flex; justify-content: center; }
#cropCanvas { display: block; border-radius: 8px; cursor: grab; touch-action: none; max-width: 100%; }
#cropCanvas:active { cursor: grabbing; }

.crop-tools { padding: 12px 18px; display: flex; flex-direction: column; gap: 10px; }
.tool-row { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.tool-label { font-size: 12.5px; color: var(--ink-3); width: 52px; flex: none; }
.tool-val { font-size: 12px; color: var(--ink-3); width: 42px; }
.tool-row input[type=range] { flex: 1; min-width: 100px; accent-color: var(--brand); }

.seg { display: inline-flex; background: #f2f3f9; border-radius: 8px; padding: 2px; gap: 2px; }
.seg button {
    border: 0; background: transparent; padding: 4px 9px; border-radius: 6px;
    font-size: 12px; color: var(--ink-2); cursor: pointer;
}
.seg button.on { background: #fff; color: var(--brand); font-weight: 600; box-shadow: 0 1px 3px rgba(0,0,0,.08); }

.qr-body { padding: 16px 18px; text-align: center; }
.qr-preview {
    max-width: 100%; max-height: 260px; border-radius: 10px;
    display: block; margin: 0 auto 10px; -webkit-touch-callout: default;
}
.qr-tip { font-size: 12px; color: var(--ink-3); margin-bottom: 12px; }
.qr-box { display: inline-block; padding: 8px; background: #fff; border: 1px solid var(--line); border-radius: 10px; }
.qr-box img, .qr-box canvas { display: block; }
.qr-url {
    margin-top: 12px; font-size: 11.5px; color: var(--ink-2);
    word-break: break-all; background: #f5f6fb; border-radius: 7px; padding: 7px 9px;
}

/* ---------- 登录页 ---------- */
.auth-body {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, #5b6ef5 0%, #8a5bf5 100%);
    padding: 20px;
}
.auth-box {
    width: 100%; max-width: 370px; background: #fff;
    border-radius: 18px; padding: 28px 26px;
    box-shadow: 0 24px 60px rgba(20, 20, 60, .28);
}
.auth-head { text-align: center; margin-bottom: 20px; }
.auth-logo { font-size: 30px; }
.auth-head h1 { font-size: 18px; margin-top: 4px; }
.auth-head p { font-size: 12.5px; color: var(--ink-3); margin-top: 3px; }
.auth-form label { display: block; margin-bottom: 12px; font-size: 12.5px; color: var(--ink-2); }
.auth-form input {
    width: 100%; margin-top: 5px; padding: 11px 12px;
    border: 1px solid var(--line); border-radius: 10px; font-size: 14px; font-family: inherit;
}
.auth-form input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px #eef0ff; }
.auth-foot { text-align: center; font-size: 12.5px; color: var(--ink-3); margin-top: 14px; }

.alert { padding: 9px 12px; border-radius: 9px; font-size: 12.5px; margin-bottom: 12px; }
.alert.bad { background: #fff1f1; color: #c0272b; border: 1px solid #ffd9d9; }
.alert.ok { background: #eefaf1; color: #0f7b3d; border: 1px solid #cfeddb; }

/* ---------- 后台 ---------- */
.kpis { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 12px; margin-bottom: 18px; }
.kpi { background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 13px 15px; }
.kpi .k { font-size: 12px; color: var(--ink-3); }
.kpi .v { font-size: 20px; font-weight: 700; margin-top: 2px; }
.kpi .v.ok { color: var(--ok); }
.kpi .v.brand { color: var(--brand); }

.tabs { display: flex; gap: 6px; margin-bottom: 14px; flex-wrap: wrap; }
.tabs a {
    padding: 7px 13px; border-radius: 9px; background: #fff;
    border: 1px solid var(--line); font-size: 13px; color: var(--ink-2);
}
.tabs a.on { background: var(--brand); color: #fff; border-color: var(--brand); }
.tabs a:hover { text-decoration: none; }

.row-actions { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }

/* ---------- 表单 ---------- */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(210px, 1fr)); gap: 12px; }
.form-grid label { display: block; font-size: 12.5px; color: var(--ink-2); }
.form-grid .input { margin-top: 5px; }

/* ---------- 代码块 ---------- */
.code {
    background: #0f172a; color: #e5e9f5;
    border-radius: 10px; padding: 13px 15px; margin: 10px 0 14px;
    overflow-x: auto; white-space: pre;
    font: 12.5px/1.65 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.doc h3 { font-size: 14px; margin: 16px 0 6px; }
.doc p { font-size: 13px; color: var(--ink-2); margin-bottom: 6px; }
.doc .endpoint {
    display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
    padding: 8px 10px; background: #fafbff; border: 1px solid var(--line);
    border-radius: 9px; margin-bottom: 6px;
}

/* ---------- 分区导航 ---------- */
.section-nav {
    display: flex; gap: 6px; flex-wrap: wrap;
    position: sticky; top: 60px; z-index: 20;
    padding: 8px 0 10px; margin: -4px 0 14px;
    background: linear-gradient(180deg, var(--bg) 78%, rgba(245, 246, 250, 0));
}
.section-nav a {
    padding: 6px 13px; border-radius: 20px; background: #fff;
    border: 1px solid var(--line); font-size: 13px; color: var(--ink-2);
}
.section-nav a:hover { border-color: var(--brand); color: var(--brand); text-decoration: none; }
section[id] { scroll-margin-top: 110px; }

/* ---------- 待上传队列 ---------- */
.staged { display: grid; grid-template-columns: repeat(auto-fill, minmax(248px, 1fr)); gap: 10px; }
.stage-card {
    display: flex; gap: 10px; align-items: flex-start;
    border: 1px solid var(--line); border-radius: 11px;
    background: #fcfdff; padding: 9px; position: relative;
}
.stage-card.ready { border-color: #c9d5ff; background: #fbfcff; }
.stage-card.uploading { border-color: var(--brand); box-shadow: 0 0 0 2px #eef0ff; }
.stage-card.error { border-color: #ffd9d9; background: #fff8f8; }
.stage-thumb {
    width: 68px; height: 68px; flex: none; border-radius: 8px;
    overflow: hidden; background: #eef0f6;
    display: flex; align-items: center; justify-content: center;
}
.stage-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.stage-wait { font-size: 11px; color: var(--ink-3); }
.stage-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.stage-title { padding: 5px 8px !important; font-size: 12.5px !important; }
.stage-title:disabled { background: #f6f7fb; color: var(--ink-3); }
.stage-line { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.stage-status { font-size: 11.5px; color: var(--ink-3); }
.stage-quote { font-size: 11.5px; color: var(--brand); font-weight: 600; white-space: nowrap; }
.stage-card.error .stage-quote { visibility: hidden; }
.stage-err { font-size: 11.5px; color: var(--bad); line-height: 1.45; word-break: break-all; }
.stage-err:empty { display: none; }
.stage-card .stage-del {
    position: absolute; right: 5px; top: 5px; width: 18px; height: 18px;
    border: 0; border-radius: 50%; background: #eceef6; color: var(--ink-3);
    cursor: pointer; font-size: 13px; line-height: 17px; padding: 0;
}
.stage-card .stage-del:hover { background: #ffe3e3; color: var(--bad); }

/* ---------- 时长与报价 ---------- */
.duration-bar {
    display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
    padding: 9px 10px; margin-bottom: 10px;
    background: #f8f9fd; border: 1px solid var(--line); border-radius: 10px;
}
.duration-bar .tool-label { width: auto; }
.duration-bar button {
    border: 1px solid var(--line); background: #fff; color: var(--ink-2);
    padding: 4px 11px; border-radius: 7px; font-size: 12.5px; cursor: pointer;
}
.duration-bar button.on { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }
.price-hint { margin-left: auto; font-size: 12.5px; color: var(--brand); font-weight: 600; }

/* ---------- 链接列表（无复制按钮） ---------- */
.link-list { display: flex; flex-direction: column; gap: 3px; margin-top: 6px; }
.link-list .mono {
    display: block; padding: 3px 7px; border-radius: 5px;
    background: #f5f6fb; color: var(--ink-2);
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
    -webkit-user-select: text; user-select: text;
}
.link-list.compact { margin: 0; padding: 0 9px; gap: 2px; }
.link-list.compact .mono { font-size: 10.5px; padding: 2px 6px; }
.result-title { font-size: 13px; font-weight: 600; }

/* ---------- 拍照弹层 ---------- */
.modal-cam { max-width: 520px; }
.cam-stage {
    position: relative; background: #0b0e17; overflow: hidden;
    aspect-ratio: 3 / 4; max-height: 62vh;
    display: flex; align-items: center; justify-content: center;
}
#camVideo { display: block; width: 100%; height: 100%; object-fit: cover; }
.cam-hint {
    position: absolute; left: 0; right: 0; bottom: 0; padding: 24px 14px 10px;
    font-size: 12.5px; color: #fff; text-align: center;
    background: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, .62));
}
.cam-actions { display: flex; justify-content: center; gap: 10px; padding: 14px 18px; }

/* ---------- 二维码弹层（只放二维码） ---------- */
.modal-qr { max-width: 600px; }
.qr-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.qr-cards.single { grid-template-columns: 1fr; }
.qr-item { display: flex; flex-direction: column; align-items: center; gap: 10px; min-width: 0; margin: 0; }
.qr-cards.single .qr-card { width: auto; max-width: 360px; max-height: 56vh; justify-self: center; }
.qr-dl { width: 100%; max-width: 360px; justify-content: center; }
.qr-card {
    width: 100%; height: auto; display: block; border-radius: 10px;
    background: #fff; border: 1px solid var(--line);
    -webkit-touch-callout: default; -webkit-user-select: auto; user-select: auto;
}
.qr-loading { grid-column: 1 / -1; padding: 26px 10px; color: var(--ink-3); font-size: 13px; }

/* ---------- 后台表格里的图腾缩略 ---------- */
.media-cell { display: flex; align-items: center; gap: 9px; min-width: 200px; }
.media-thumb {
    width: 42px; height: 42px; border-radius: 7px; object-fit: cover;
    background: #f0f1f6; flex: none; border: 1px solid var(--line);
}
.media-meta { min-width: 0; }
.media-name {
    font-size: 12.5px; max-width: 210px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

@media (max-width: 640px) {
    .topbar { height: auto; padding: 10px 14px; flex-wrap: wrap; gap: 10px; }
    .nav { order: 3; width: 100%; }
    .topbar-right { margin-left: auto; }
    .wrap { padding: 16px 12px 50px; }
    .gallery { grid-template-columns: repeat(auto-fill, minmax(132px, 1fr)); }
    .stat .n { font-size: 17px; }
    .section-nav { top: 0; }
    .staged { grid-template-columns: 1fr; }
    .qr-cards { grid-template-columns: 1fr; }
    .duration-bar .price-hint { width: 100%; margin-left: 0; }
}
