:root {
  --ink: #1d2733;
  --muted: #6c7480;
  --line: #e5e1d8;
  --paper: #fbfaf7;
  --card: #ffffff;
  --accent: #2f5d50;
  --accent-soft: #e7efe9;
  --danger: #a63f32;
  --shadow: 0 1px 2px rgba(29, 39, 51, .04), 0 18px 40px -30px rgba(29, 39, 51, .35);
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Noto Sans CJK SC", "Microsoft YaHei", sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 20px; }
h2 { font-size: 19px; }
h3 { font-size: 15px; }
p { margin: 0; }
button, input, textarea, select { font: inherit; color: inherit; }

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 18px 28px;
  max-width: 1280px;
  margin: 0 auto;
}

.brand { display: flex; align-items: center; gap: 14px; }
.brand-mark {
  width: 42px; height: 42px; border-radius: 12px;
  display: grid; place-items: center;
  background: var(--ink); color: #fff;
  font-size: 22px; font-family: "Songti SC", serif;
}
.brand p { color: var(--muted); font-size: 12.5px; }
.topbar-right { display: flex; gap: 8px; align-items: center; }

.shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 28px 80px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: 26px;
}

.welcome {
  display: grid;
  grid-template-columns: minmax(0, 1.5fr) minmax(280px, .9fr);
  gap: 40px;
  margin-top: 8px;
}
.welcome-copy h2 { font-size: 28px; line-height: 1.3; margin-bottom: 12px; }
.welcome-copy p { color: var(--muted); max-width: 58ch; }
.welcome-side { border-left: 1px solid var(--line); padding-left: 28px; }
.welcome-side h3 { margin-bottom: 10px; }
.project-list { display: flex; flex-direction: column; gap: 6px; }
.project-item {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  padding: 9px 12px; border-radius: 10px; border: 1px solid transparent;
  background: #f6f4ef; cursor: pointer;
}
.project-item:hover { border-color: var(--line); background: #f1eee7; }
.project-item .meta { font-size: 12px; color: var(--muted); }

.step { display: flex; flex-direction: column; gap: 18px; }
.step-head { display: flex; gap: 16px; align-items: flex-start; }
.step-head > div:nth-child(2) { flex: 1; }
.step-no {
  flex: 0 0 30px; width: 30px; height: 30px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--ink); color: #fff; font-size: 13px; font-weight: 600;
  margin-top: 1px;
}
.step-head .muted { margin-top: 3px; font-size: 13.5px; }

.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.split { display: grid; grid-template-columns: minmax(0, 1.55fr) minmax(280px, .85fr); gap: 22px; }
.upload-row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  height: 38px; padding: 0 15px;
  border-radius: 10px; border: 1px solid var(--line);
  background: #fff; cursor: pointer;
  font-size: 14px; font-weight: 550;
  transition: .15s ease;
  white-space: nowrap;
}
.btn:hover:not(:disabled) { border-color: #c9c4b8; transform: translateY(-1px); }
.btn:active:not(:disabled) { transform: none; }
.btn:disabled { opacity: .45; cursor: not-allowed; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover:not(:disabled) { background: #274d42; border-color: #274d42; }
.btn.ghost { background: #f7f5f0; }
.btn.danger { color: var(--danger); border-color: #e6cfca; background: #fdf7f5; }
.btn.big { height: 44px; padding: 0 22px; }
.btn.tiny { height: 30px; padding: 0 10px; font-size: 12.5px; }
.file-btn input { display: none; }

input[type=text], input[type=number], textarea, select {
  border: 1px solid var(--line); background: #fff;
  border-radius: 10px; padding: 9px 11px; outline: none;
}
input[type=text]:focus, input[type=number]:focus, textarea:focus, select:focus {
  border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft);
}
#project-name { width: 240px; }
#text-input {
  width: 100%; resize: vertical; min-height: 110px;
  font-size: 15.5px; line-height: 1.8;
}

.pill {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 10px; border-radius: 999px;
  font-size: 12px; color: var(--muted);
  background: #f3f1eb; border: 1px solid var(--line);
  white-space: nowrap;
}
.pill.subtle { background: #faf8f4; }
.pill.ok { color: var(--accent); background: var(--accent-soft); border-color: #cfe0d5; }
.pill.bad { color: var(--danger); background: #fbf1ee; border-color: #ecd4cd; }
.pill.link { text-decoration: none; }
.muted { color: var(--muted); }
.small { font-size: 12.5px; }
.count {
  display: inline-grid; place-items: center; min-width: 22px; height: 22px;
  padding: 0 6px; border-radius: 999px; background: #f1eee7;
  font-size: 12px; color: var(--muted);
}

/* canvas */
.canvas-panel {
  background: #f4f2ec;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  min-height: 320px;
  display: flex; flex-direction: column; gap: 10px;
}
.empty {
  flex: 1; min-height: 280px; display: grid; place-content: center; gap: 4px;
  text-align: center; color: var(--muted); border: 1px dashed #d8d2c6; border-radius: 10px;
  background: repeating-linear-gradient(45deg, #faf9f5, #faf9f5 8px, #f6f4ee 8px, #f6f4ee 16px);
}
#canvas { width: 100%; height: auto; display: block; border-radius: 8px; touch-action: none; cursor: crosshair; }
.canvas-tools { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
.panel-head { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 10px; }
.samples-panel { min-width: 0; }
.sample-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px; max-height: 360px; overflow: auto; padding-right: 4px;
}
.sample {
  position: relative; border: 1px solid var(--line); border-radius: 10px;
  background: #fff; padding: 6px; display: flex; flex-direction: column; gap: 4px;
}
.sample.disabled { opacity: .4; }
.sample img {
  width: 100%; aspect-ratio: 1; object-fit: contain;
  image-rendering: auto; background: #fafafa; border-radius: 6px; cursor: zoom-in;
}
.sample input {
  width: 100%; border: none; border-top: 1px dashed var(--line);
  border-radius: 0; padding: 2px 0; text-align: center; font-size: 13px;
}
.sample .toggle { position: absolute; top: 3px; right: 4px; }
.sample .toggle input { width: 14px; height: 14px; }

/* style */
.style-grid { display: grid; grid-template-columns: repeat(auto-fill, 56px); gap: 8px; }
.style-grid img {
  width: 56px; height: 56px; object-fit: contain;
  border: 1px solid var(--line); border-radius: 8px; background: #fff; padding: 3px;
}
.note {
  font-size: 13px; color: #5b5346; background: #fbf7ec;
  border: 1px solid #ece2c9; border-radius: 10px; padding: 10px 12px;
}
.warnings { display: flex; flex-direction: column; gap: 6px; }
.warn {
  font-size: 13px; color: #7b4a3f; background: #fdf6f3;
  border: 1px solid #f0d9d1; border-radius: 9px; padding: 8px 11px;
}

/* settings */
.settings { border-top: 1px solid var(--line); padding-top: 12px; }
.settings summary { cursor: pointer; font-size: 13.5px; color: var(--muted); }
.settings-grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 12px; margin-top: 14px;
}
.settings-grid label { display: flex; flex-direction: column; gap: 4px; font-size: 12.5px; color: var(--muted); }
.settings-grid input, .settings-grid select { width: 100%; }

/* jobs */
.job {
  border: 1px solid var(--line); border-radius: 12px; padding: 14px;
  display: grid; gap: 8px; background: #fcfbf8;
}
.job-line { display: flex; justify-content: space-between; gap: 12px; font-size: 13.5px; }
.bar { height: 7px; border-radius: 999px; background: #ece9e1; overflow: hidden; }
#job-bar { height: 100%; width: 0%; background: var(--accent); transition: width .3s ease; }
.error {
  color: var(--danger); background: #fdf3f0; border: 1px solid #efd6cf;
  border-radius: 10px; padding: 10px 12px; font-size: 13.5px; white-space: pre-wrap;
}

/* results */
.pages { display: flex; flex-direction: column; gap: 18px; align-items: center; }
.pages figure {
  margin: 0; width: min(100%, 680px);
  border: 1px solid var(--line); border-radius: 10px; overflow: hidden;
  box-shadow: 0 20px 45px -32px rgba(0,0,0,.5); background: #fff;
}
.pages img { width: 100%; display: block; cursor: zoom-in; }
.pages figcaption { font-size: 12px; color: var(--muted); padding: 7px 10px; border-top: 1px solid var(--line); }
.export-row { border-top: 1px solid var(--line); padding-top: 16px; }
.check { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }
.export-list { display: flex; flex-direction: column; gap: 6px; }
.export-item {
  display: flex; justify-content: space-between; gap: 12px; align-items: center;
  border: 1px solid var(--line); border-radius: 10px; padding: 9px 12px; font-size: 13.5px;
}
.export-item a { color: var(--accent); font-weight: 600; text-decoration: none; }

/* overlays */
.lightbox {
  position: fixed; inset: 0; z-index: 50; background: rgba(20, 24, 28, .82);
  display: grid; place-items: center; padding: 30px; cursor: zoom-out;
}
.lightbox img { max-width: 96vw; max-height: 92vh; border-radius: 6px; background: #fff; }
.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13.5px; z-index: 60; box-shadow: 0 10px 30px -10px rgba(0,0,0,.5);
}
.hidden { display: none !important; }

@media (max-width: 980px) {
  .welcome { grid-template-columns: 1fr; gap: 24px; }
  .welcome-side { border-left: none; padding-left: 0; border-top: 1px solid var(--line); padding-top: 20px; }
  .split { grid-template-columns: 1fr; }
  .topbar { padding: 16px 18px; }
  .shell { padding: 0 18px 60px; }
  .card { padding: 20px; }
}
