/* 图片转拼豆 · 暖橙奶油色系，移动端优先 */
:root {
  --bg: #fdf1e3;
  --card: #fffaf3;
  --ink: #43302a;
  --ink-soft: #8a6f63;
  --accent: #e07856;
  --accent-deep: #c65a3d;
  --accent-soft: #fbe3d3;
  --gold: #f4a950;
  --line: #f0ddc9;
  --danger: #c0392b;
  --radius: 16px;
  --shadow: 0 2px 10px rgba(160, 100, 60, 0.08);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; padding: 0; }
body {
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Microsoft YaHei", "Segoe UI", sans-serif;
  font-size: 15px;
  line-height: 1.55;
}
#app { max-width: 560px; margin: 0 auto; padding: 14px 14px 96px; }
.boot { text-align: center; padding: 90px 0; color: var(--ink-soft); }
.boot-mark { font-size: 46px; }

h1 { font-size: 24px; margin: 6px 0 2px; }
h2 { font-size: 18px; margin: 0 0 8px; }
.sub { color: var(--ink-soft); margin: 0 0 12px; font-size: 14px; }

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 14px;
}
.card h2 { display: flex; align-items: center; gap: 6px; }

label.f { display: block; margin: 10px 0; font-size: 14px; color: var(--ink-soft); }
label.f > span { display: block; margin-bottom: 4px; }
input[type="text"], input[type="password"], input[type="number"] {
  width: 100%;
  padding: 11px 12px;
  border: 1.5px solid var(--line);
  border-radius: 12px;
  background: #fff;
  font-size: 16px;
  color: var(--ink);
  outline: none;
}
input:focus { border-color: var(--accent); }
input[type="range"] { width: 100%; accent-color: var(--accent); }

.btn {
  display: inline-block;
  border: none;
  cursor: pointer;
  background: var(--accent);
  color: #fff;
  font-size: 16px;
  font-weight: 600;
  padding: 12px 20px;
  border-radius: 999px;
  width: 100%;
  text-align: center;
}
.btn:active { background: var(--accent-deep); }
.btn.ghost { background: var(--accent-soft); color: var(--accent-deep); }
.btn.small { width: auto; padding: 8px 16px; font-size: 14px; }
.btn.danger { background: #f6ddd8; color: var(--danger); }
.btn[disabled] { opacity: 0.5; }
.link { color: var(--accent-deep); background: none; border: none; font-size: 14px; cursor: pointer; padding: 4px; }
.row { display: flex; gap: 10px; align-items: center; }
.row > * { flex: 1; }
.mt { margin-top: 10px; }
.small { font-size: 13px; color: var(--ink-soft); }
.err { color: var(--danger); font-size: 14px; min-height: 20px; }

.tabs { display: flex; gap: 8px; margin-bottom: 12px; }
.tabs button {
  flex: 1; padding: 9px 0; border-radius: 999px; border: 1.5px solid var(--line);
  background: #fff; font-size: 15px; color: var(--ink-soft); cursor: pointer;
}
.tabs button.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* 底部导航 */
.nav {
  position: fixed; left: 0; right: 0; bottom: 0;
  background: rgba(255, 250, 243, 0.96);
  border-top: 1px solid var(--line);
  display: flex; z-index: 20;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav button {
  flex: 1; background: none; border: none; padding: 9px 0 7px;
  font-size: 12px; color: var(--ink-soft); cursor: pointer;
}
.nav button .ico { display: block; font-size: 21px; line-height: 1.2; }
.nav button.on { color: var(--accent-deep); font-weight: 700; }

.topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.topbar .who { font-size: 14px; color: var(--ink-soft); }

/* 上传区 */
.drop {
  border: 2px dashed var(--gold);
  border-radius: var(--radius);
  padding: 22px 12px;
  text-align: center;
  color: var(--ink-soft);
  background: #fff;
  cursor: pointer;
}
.drop.over { background: var(--accent-soft); }
.drop .big { font-size: 30px; display: block; margin-bottom: 4px; }
.thumb-preview { max-width: 100%; max-height: 180px; border-radius: 12px; display: block; margin: 0 auto; }

.switch { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--ink); }
.switch input { width: 20px; height: 20px; accent-color: var(--accent); }

canvas.pattern {
  display: block; margin: 0 auto; max-width: 100%;
  background:
    repeating-conic-gradient(#f3e6d4 0% 25%, #fffaf3 0% 50%) 0 0 / 16px 16px;
  border-radius: 8px;
}

/* 材料清单 */
.mat-total {
  font-size: 17px; font-weight: 700; color: var(--accent-deep);
  background: var(--accent-soft); border-radius: 12px; padding: 10px 14px; margin-bottom: 10px;
}
table.mat { width: 100%; border-collapse: collapse; font-size: 14px; }
table.mat td, table.mat th { padding: 7px 6px; border-bottom: 1px solid var(--line); text-align: left; }
table.mat td.n, table.mat th.n { text-align: right; font-variant-numeric: tabular-nums; }
.sw { display: inline-block; width: 18px; height: 18px; border-radius: 5px; border: 1px solid rgba(0,0,0,0.15); vertical-align: -4px; margin-right: 6px; }

/* 我的图纸 */
.pat-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.pat-item { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 10px; }
.pat-item img { width: 100%; border-radius: 8px; background: #f7ecdc; display: block; }
.pat-item .t { font-weight: 600; margin: 8px 0 2px; font-size: 14px; word-break: break-all; }
.pat-item .ops { display: flex; gap: 6px; margin-top: 8px; }
.pat-item .ops button { flex: 1; padding: 7px 0; font-size: 13px; }

/* 照片转动漫：原图/结果对比 */
.cmp { display: flex; gap: 12px; flex-wrap: wrap; }
.cmp figure { flex: 1 1 210px; margin: 0; }
.cmp figcaption { text-align: center; margin-top: 6px; }
.cmp-img { display: block; width: 100%; height: auto; border-radius: 12px; background: #f7ecdc; }

.demo-wrap { text-align: center; }
.demo-wrap canvas { max-width: 240px; width: 100%; }

.invite-code {
  font-size: 22px; font-weight: 700; letter-spacing: 3px; text-align: center;
  background: #fff; border: 1.5px dashed var(--gold); border-radius: 12px; padding: 12px;
  color: var(--accent-deep);
}

.toast-wrap { position: fixed; top: 14px; left: 0; right: 0; z-index: 50; display: flex; flex-direction: column; align-items: center; gap: 8px; pointer-events: none; }
.toast { background: rgba(67, 48, 42, 0.92); color: #fff; padding: 10px 18px; border-radius: 999px; font-size: 14px; max-width: 86%; }

/* 打印专用区：屏幕上永远不显示，只在打印时由 @media print 接管 */
#print-area { display: none; }

@page { size: A4 portrait; margin: 12mm; }

@media print {
  .nav, .toast-wrap, .no-print { display: none !important; }
  #app { padding-bottom: 0; }
  body { background: #fff; }
  .card { box-shadow: none; break-inside: avoid; }
  /* 颜色照实打（清单里的色块小方块靠它，不然打印出来是空白） */
  * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
  /* 有图纸可打时（JS 给 body 加了 has-print）：屏幕页面整体让位，只打打印区 */
  body.has-print #app { display: none; }
  body.has-print #print-area { display: block; }
  .print-title { font-size: 18px; margin: 0 0 10px; break-after: avoid; }
  /* 图纸是一张完整的图：等比缩放适配纸面，限高保证整张落在一页里不被切开 */
  .print-pat { text-align: center; break-inside: avoid; margin-bottom: 16px; }
  #print-img { max-width: 100%; max-height: 232mm; }
  .print-mat { break-inside: auto; }
}
