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

:root {
  --bg: #f4f1ec;
  --panel: #ffffff;
  --ink: #2b2b2b;
  --accent: #b4552d;
  --line: #ddd6cc;
}

body { font-family: "Hiragino Sans", "Yu Gothic", sans-serif; color: var(--ink); background: var(--bg); }

#app { display: flex; flex-direction: column; height: 100vh; }

#topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
}
#topbar h1 { font-size: 18px; font-weight: 600; }
#topbar .brand { color: var(--accent); font-weight: 700; margin-left: 4px; }
.topbar-right { display: flex; align-items: center; gap: 12px; }
#page-estimate { font-size: 12px; color: #777; }

button {
  font: inherit; font-size: 13px; padding: 6px 14px; border-radius: 6px;
  border: 1px solid var(--line); background: #fff; cursor: pointer;
}
button:hover { background: #f7f4ef; }
button.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
button.primary:hover { background: #9c4826; }
button.danger { color: #b03030; }

#main { display: flex; flex: 1; min-height: 0; }

#panel {
  width: 300px; overflow-y: auto; padding: 12px; background: var(--bg);
  border-right: 1px solid var(--line); flex-shrink: 0;
}
.box {
  background: var(--panel); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px; margin-bottom: 12px;
}
.box h2 { font-size: 13px; font-weight: 600; margin-bottom: 10px; color: #555; }
.row { margin-bottom: 8px; }
.row:last-child { margin-bottom: 0; }
.row label { display: block; font-size: 12px; color: #444; }
.row input[type="number"], .row input[type="text"], .row select {
  width: 100%; margin-top: 3px; padding: 5px 8px; font: inherit; font-size: 13px;
  border: 1px solid var(--line); border-radius: 5px;
}
.row.btns { display: flex; gap: 8px; }
.row.btns button { flex: 1; }
.hint { font-size: 11px; color: #999; margin-top: 5px; line-height: 1.5; }

.seg { display: flex; gap: 0; margin-top: 4px; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; }
.seg label { flex: 1; display: block; }
.seg input { display: none; }
.seg span { display: block; text-align: center; padding: 5px 4px; font-size: 12px; cursor: pointer; background: #fff; }
.seg input:checked + span { background: var(--accent); color: #fff; }

.design-select { display: flex; flex-direction: column; gap: 6px; }
.design-item { display: flex; align-items: center; gap: 8px; font-size: 13px; padding: 7px 10px; border: 1px solid var(--line); border-radius: 6px; cursor: pointer; background: #fff; }
.design-item:has(input:checked) { border-color: var(--accent); background: #fdf3ee; }
.design-item.disabled { opacity: 0.45; cursor: not-allowed; }

.slider-row { display: flex; align-items: center; gap: 8px; margin-top: 6px; }
.slider-row input[type="range"] { flex: 1; }
#stretch-val { font-size: 12px; width: 42px; text-align: right; color: var(--accent); font-weight: 600; }

.color-row { display: flex; gap: 14px; }
.color-row label { display: flex; align-items: center; gap: 6px; }
.color-row input[type="color"] { width: 36px; height: 26px; border: 1px solid var(--line); border-radius: 4px; padding: 1px; background: #fff; }

#stage { flex: 1; display: flex; flex-direction: column; min-width: 0; }
#tabs { display: flex; gap: 4px; padding: 8px 12px 0; background: var(--bg); }
.tab {
  border: 1px solid var(--line); border-bottom: none; border-radius: 8px 8px 0 0;
  padding: 7px 18px; background: #ece7df; color: #777;
}
.tab.active { background: #fff; color: var(--ink); font-weight: 600; }
.view { display: none; flex: 1; background: #fff; overflow: auto; position: relative; }
.view.active { display: block; }

#view-pattern svg { display: block; width: 100%; height: 100%; }
#view-wear { display: none; }
#view-wear.active { display: flex; align-items: center; justify-content: center; }
#view-wear svg { max-width: 90%; max-height: 90%; }

#view-pieces { padding: 20px; }
#view-pieces table { border-collapse: collapse; font-size: 13px; }
#view-pieces th, #view-pieces td { border: 1px solid var(--line); padding: 6px 12px; text-align: left; }
#view-pieces th { background: #f7f4ef; }
#view-pieces .note { font-size: 12px; color: #777; margin-top: 12px; line-height: 1.7; }

/* ---- 印刷 ---- */
#print-root { display: none; }

@media print {
  #app { display: none; }
  #print-root { display: block; }
  body { background: #fff; }
  .p-page {
    position: relative; overflow: hidden;
    page-break-after: always; break-after: page;
  }
  .p-page:last-child { page-break-after: auto; break-after: auto; }
}

.p-header { font-family: "Hiragino Sans", sans-serif; }
