:root {
  --bg: #f4f4f6; --card: #fff; --text: #16161a; --sub: #6b6b73; --line: #e6e6eb; --accent: #1d4ed8; --accent-bg: #eef2ff;
  --ok: #15803d; --warn: #b45309; --bad: #b91c1c; --radius: 14px; --nav-h: 58px;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Noto Sans CJK SC", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
body { margin: 0; background: var(--bg); color: var(--text); font-size: 15px; line-height: 1.5; }
a { color: var(--accent); text-decoration: none; }
button, .btn { font: inherit; border: 1px solid var(--line); background: #fff; color: var(--text); border-radius: 10px;
  padding: 8px 14px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 38px; }
button.primary, .btn.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
button.ghost, .btn.ghost { background: var(--accent-bg); color: var(--accent); border-color: transparent; }
button:disabled { opacity: .5; cursor: default; }
button.link { border: 0; background: none; color: var(--sub); padding: 4px 8px; min-height: 0; }
button.danger, .danger { color: var(--bad); }
button.small, .btn.small { padding: 4px 10px; min-height: 30px; font-size: 13px; }
.block { display: flex; width: 100%; }
input[type=text], input[type=password], input[type=email], input[type=tel], input[type=number], input[type=date], input[type=search],
select, textarea { font: inherit; font-size: 16px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 10px; background: #fff;
  width: 100%; color: var(--text); }
textarea { min-height: 90px; resize: vertical; line-height: 1.45; }
label.f { display: block; font-size: 13px; color: var(--sub); margin: 10px 0 4px; }
.hidden { display: none !important; }
.muted { color: var(--sub); }
.small { font-size: 13px; }
.pad { padding: 16px; }
.grow { flex: 1; min-width: 0; }
.nowrap { white-space: nowrap; }
.ell { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pre { white-space: pre-wrap; word-break: break-word; }

/* top bar + bottom navigation (phone first) */
.top { display: flex; align-items: center; gap: 8px; padding: 8px 12px; padding-top: calc(8px + env(safe-area-inset-top));
  background: rgba(255,255,255,.96); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 8; min-height: 50px;
  backdrop-filter: saturate(1.4) blur(8px); }
.top .ttl { font-weight: 700; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.top .back { font-size: 28px; line-height: 1; padding: 0 6px 2px 0; color: var(--text); }
.badge { background: #fef3c7; color: #92400e; border-radius: 99px; padding: 2px 10px; font-size: 12px; white-space: nowrap; }
.nav { position: fixed; left: 0; right: 0; bottom: 0; z-index: 9; display: flex; background: rgba(255,255,255,.97);
  border-top: 1px solid var(--line); padding-bottom: env(safe-area-inset-bottom); backdrop-filter: saturate(1.4) blur(8px); }
.nav a { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 7px 0 5px; font-size: 11px;
  color: var(--sub); position: relative; }
.nav a svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.nav a.on { color: var(--accent); font-weight: 600; }
.nav a .dot { position: absolute; top: 4px; left: calc(50% + 8px); min-width: 16px; height: 16px; border-radius: 99px; background: var(--bad);
  color: #fff; font-size: 10px; line-height: 16px; padding: 0 4px; font-weight: 600; }
main { max-width: 960px; margin: 0 auto; padding: 12px 12px calc(var(--nav-h) + 84px + env(safe-area-inset-bottom)); }
@media (min-width: 900px) {
  .nav { position: sticky; top: 50px; bottom: auto; justify-content: center; border-top: 0; border-bottom: 1px solid var(--line); padding: 0; }
  .nav a { flex: 0 0 auto; flex-direction: row; gap: 6px; padding: 10px 18px; font-size: 14px; }
  .nav a svg { width: 18px; height: 18px; }
  .nav a .dot { position: static; }
  main { padding: 18px 16px 40px; }
}

h1 { font-size: 20px; margin: 4px 0 12px; line-height: 1.3; }
h2 { font-size: 16px; margin: 0 0 8px; }
h3 { font-size: 15px; margin: 12px 0 6px; }
.card { background: var(--card); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; box-shadow: 0 1px 2px rgba(0,0,0,.04); }
.card > h2:first-child { margin-top: 0; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.tight { gap: 4px; }
.stack > * + * { margin-top: 8px; }
.sec { display: flex; align-items: center; gap: 8px; margin: 18px 4px 8px; }
.sec h2 { margin: 0; flex: 1; }
.list .item { display: flex; gap: 12px; align-items: center; padding: 12px 2px; border-top: 1px solid var(--line); color: var(--text); }
.list .item:first-child { border-top: 0; }
.list .item .t { font-weight: 600; }
.list.flush { padding-top: 2px; padding-bottom: 2px; }
.chev::after { content: '›'; color: #b4b4bc; font-size: 22px; margin-left: 2px; }
.pill { font-size: 12px; border-radius: 99px; padding: 1px 8px; background: #eef; color: #334; white-space: nowrap; display: inline-block; }
.pill.done, .pill.good, .pill.ready, .pill.won { background: #dcfce7; color: var(--ok); }
.pill.running, .pill.queued, .pill.ok, .pill.sent, .pill.fu1, .pill.fu2 { background: #fef3c7; color: var(--warn); }
.pill.failed, .pill.poor, .pill.lost { background: #fee2e2; color: var(--bad); }
.pill.draft, .pill.new { background: var(--accent-bg); color: #3730a3; }
.pill.replied, .pill.sample, .pill.quote { background: #dcfce7; color: var(--ok); font-weight: 600; }
.pill.A { background: #fee2e2; color: var(--bad); font-weight: 700; }
.pill.B { background: #fef3c7; color: var(--warn); font-weight: 700; }
.pill.C { background: #eef; color: #556; font-weight: 700; }
.chips { display: flex; gap: 6px; overflow-x: auto; padding: 2px 0 10px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chips a, .chips button { flex: none; padding: 5px 12px; border-radius: 99px; background: #fff; border: 1px solid var(--line); color: var(--text);
  font-size: 14px; min-height: 0; }
.chips .on { background: var(--text); color: #fff; border-color: var(--text); }
.seg { display: flex; background: #e7e7ec; border-radius: 11px; padding: 3px; gap: 2px; margin-bottom: 12px; }
.seg a { flex: 1; text-align: center; padding: 6px 4px; border-radius: 9px; color: var(--text); font-size: 14px; white-space: nowrap; }
.seg a.on { background: #fff; box-shadow: 0 1px 2px rgba(0,0,0,.1); font-weight: 600; }
.kpis { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 12px; }
.kpi { background: #fff; border-radius: 12px; padding: 10px; text-align: center; color: var(--text); }
.kpi b { display: block; font-size: 22px; line-height: 1.2; }
.kpi span { font-size: 12px; color: var(--sub); }
.todo { display: flex; gap: 10px; align-items: center; padding: 11px 2px; border-top: 1px solid var(--line); color: var(--text); }
.todo:first-of-type { border-top: 0; }
.todo .ic { width: 34px; height: 34px; border-radius: 10px; display: flex; align-items: center; justify-content: center; flex: none;
  background: var(--accent-bg); color: var(--accent); font-size: 16px; }
.empty { text-align: center; color: var(--sub); padding: 18px 8px; }
.fab { position: fixed; right: 16px; bottom: calc(var(--nav-h) + 16px + env(safe-area-inset-bottom)); z-index: 7; border-radius: 99px;
  padding: 12px 18px; box-shadow: 0 6px 16px rgba(29,78,216,.35); }
@media (min-width: 900px) { .fab { bottom: 24px; } }
.timeline .ev { padding: 8px 0 8px 14px; border-left: 2px solid var(--line); margin-left: 4px; position: relative; }
.timeline .ev::before { content: ''; position: absolute; left: -6px; top: 13px; width: 10px; height: 10px; border-radius: 99px; background: #c7c7d1; }
.timeline .ev.k-email1::before, .timeline .ev.k-email4::before, .timeline .ev.k-email10::before { background: var(--accent); }
.timeline .ev.k-reply::before { background: var(--ok); }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 6px 12px; font-size: 14px; }
.kv > div:nth-child(odd) { color: var(--sub); white-space: nowrap; }
.kv > div { min-width: 0; overflow-wrap: anywhere; }
.contact { display: flex; gap: 10px; align-items: center; padding: 9px 0; border-top: 1px solid var(--line); }
.contact:first-child { border-top: 0; }
.contact .grow { overflow-wrap: anywhere; }
.msgs .msg { padding: 8px 12px; border-radius: 14px; margin: 6px 0; max-width: 86%; white-space: pre-wrap; word-break: break-word; }
.msgs .msg.us { background: var(--accent-bg); margin-left: auto; }
.msgs .msg.factory { background: #dcfce7; }
.msgs .msg .small { display: block; }
.share { display: flex; gap: 6px; align-items: center; background: #f6f6f9; border-radius: 10px; padding: 8px 10px; font-size: 13px; }
.share code { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* 吸塑 pages (unchanged look) */
.steps { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 12px; }
.steps .card { margin: 0; }
.steps .n { font-size: 13px; color: var(--sub); }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
.grid .ph { position: relative; background: #ddd; border-radius: 8px; overflow: hidden; aspect-ratio: 3/4; }
.grid .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid .ph .cap { position: absolute; left: 0; right: 0; bottom: 0; font-size: 11px; color: #fff; background: rgba(0,0,0,.5); padding: 2px 6px; }
.grid .ph .x { position: absolute; top: 4px; right: 4px; background: rgba(0,0,0,.55); color: #fff; border: 0; border-radius: 99px;
  width: 26px; height: 26px; min-height: 0; padding: 0; line-height: 24px; }
.drop { display: block; border: 2px dashed #c7c7d1; border-radius: var(--radius); padding: 18px; text-align: center; color: var(--sub); cursor: pointer; }
.drop.on { border-color: var(--accent); background: var(--accent-bg); }
.bar { height: 8px; background: #e5e7eb; border-radius: 99px; overflow: hidden; }
.bar > i { display: block; height: 100%; background: var(--accent); width: 0; transition: width .4s; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 7px 8px; border-top: 1px solid var(--line); white-space: nowrap; }
th { color: var(--sub); font-weight: 500; }
.tablewrap { overflow-x: auto; }
img.full { width: 100%; height: auto; border-radius: 8px; display: block; background: #fff; }
.views { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 12px; }
.views .v { border: 1px solid var(--line); border-radius: 10px; padding: 10px; background: #fff; }
.views .v img { width: 100%; height: 150px; object-fit: contain; background: #f3f4f6; border-radius: 6px; }

/* videos */
.vgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.vcard { background: #fff; border-radius: 12px; overflow: hidden; color: var(--text); display: block; }
.vcard .pv { position: relative; aspect-ratio: 9/12; background: #222 center/cover no-repeat; }
.vcard .pv .d { position: absolute; right: 6px; bottom: 6px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; border-radius: 6px; padding: 1px 6px; }
.vcard .pv .st { position: absolute; left: 6px; top: 6px; }
.vcard .tt { padding: 7px 9px; font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
video.player { width: 100%; max-height: 72vh; background: #000; border-radius: 12px; display: block; }
.scene { display: flex; gap: 10px; padding: 10px 0; border-top: 1px solid var(--line); }
.scene:first-child { border-top: 0; }
.scene .th { width: 76px; height: 76px; border-radius: 10px; background: #ddd center/cover no-repeat; flex: none; position: relative; }
.scene .th .n { position: absolute; left: 4px; top: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 11px; border-radius: 6px; padding: 0 5px; }
.scene .th .vd { position: absolute; right: 4px; bottom: 4px; background: rgba(0,0,0,.6); color: #fff; font-size: 10px; border-radius: 6px; padding: 0 4px; }
.scene input { padding: 7px 9px; }
.opts { display: flex; gap: 6px; flex-wrap: wrap; }
.opts label { border: 1px solid var(--line); border-radius: 99px; padding: 5px 12px; font-size: 14px; background: #fff; cursor: pointer; }
.opts input { display: none; }
.opts label.on { background: var(--text); color: #fff; border-color: var(--text); }

/* toast, 3D modal, bottom sheet */
.toast { position: fixed; left: 50%; bottom: calc(var(--nav-h) + 20px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  background: #111827; color: #fff; padding: 10px 16px; border-radius: 12px; z-index: 40; max-width: 90vw; text-align: center; }
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); z-index: 30; display: flex; align-items: center; justify-content: center; }
.modal-box { background: #fff; border-radius: 14px; width: min(1100px, 96vw); height: min(820px, 92vh); position: relative; overflow: hidden;
  display: flex; flex-direction: column; }
.modal-x { position: absolute; right: 8px; top: 6px; z-index: 2; font-size: 22px; border: 0; background: none; }
#modalbody { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.viewer { flex: 1; min-height: 0; background: linear-gradient(#f4f5f7, #dfe2e7); }
.viewer canvas { display: block; width: 100%; height: 100%; touch-action: none; }
.vbar { padding: 10px 44px 10px 14px; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; border-bottom: 1px solid var(--line); }
.sheet { position: fixed; inset: 0; background: rgba(0,0,0,.4); z-index: 35; display: flex; align-items: flex-end; justify-content: center; }
.sheet-box { background: #fff; width: 100%; max-width: 720px; max-height: 92vh; overflow: auto; border-radius: 18px 18px 0 0;
  padding: 14px 16px calc(16px + env(safe-area-inset-bottom)); animation: up .18s ease-out; }
.sheet-box .grab { width: 40px; height: 5px; border-radius: 99px; background: #d4d4da; margin: 0 auto 10px; }
@keyframes up { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }
@media (min-width: 900px) { .sheet { align-items: center; } .sheet-box { border-radius: 18px; } }
.login { max-width: 360px; margin: 14vh auto; }
details summary { cursor: pointer; color: var(--sub); }
pre.log { background: #0f172a; color: #e2e8f0; padding: 10px; border-radius: 8px; font-size: 12px; max-height: 320px; overflow: auto; white-space: pre-wrap; }
.warnbox { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; border-radius: 12px; padding: 10px 12px; font-size: 14px; margin-bottom: 12px; }
.ph-tpl { background: #fde68a; border-radius: 4px; padding: 0 2px; }
