:root {
  --accent: #f07828;
  --accent-soft: #ffeadb;
  --ink: #0e1621;
  --ink-soft: #3a4656;
  --muted: #7a8796;
  --paper: #f3f5f9;
  --surface: #ffffff;
  --line: #e2e7ef;
  --radius: 14px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
  font-size: 14px;
  line-height: 1.55;
}

button, input, select { font: inherit; color: inherit; }
button { cursor: pointer; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: rgba(255, 255, 255, .92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
.logo {
  width: 34px; height: 34px; border-radius: 10px; flex: 0 0 auto;
  background:
    linear-gradient(90deg, transparent 45%, #fff 45%, #fff 55%, transparent 55%),
    linear-gradient(0deg, transparent 45%, #fff 45%, #fff 55%, transparent 55%),
    var(--accent);
  background-size: 12px 12px;
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 16px; letter-spacing: .3px; }
.brand-text .sub { color: var(--muted); font-size: 12px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

.tabs { display: flex; gap: 6px; background: var(--paper); padding: 4px; border-radius: 999px; }
.tab {
  border: 0; background: transparent; padding: 7px 16px; border-radius: 999px;
  color: var(--ink-soft); font-weight: 600;
}
.tab.on { background: var(--ink); color: #fff; }

main { max-width: 1440px; margin: 0 auto; padding: 20px; }
.view { display: none; }
.view.on { display: block; }

.view-head { margin-bottom: 16px; }
.view-head h2 { margin: 0 0 4px; font-size: 22px; }
.row { display: flex; align-items: center; }
.row.between { justify-content: space-between; }
.row.gap { gap: 10px; flex-wrap: wrap; margin-top: 12px; }
.cap { color: var(--muted); font-size: 12px; margin: 0; }

.primary, .ghost-btn {
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 10px; padding: 9px 16px; font-weight: 600;
  border: 1px solid transparent; text-decoration: none;
  transition: transform .06s ease, box-shadow .15s ease;
}
.primary { background: var(--ink); color: #fff; }
.primary.accent { background: var(--accent); }
.primary:active, .ghost-btn:active { transform: translateY(1px); }
.ghost-btn { background: #fff; border-color: var(--line); color: var(--ink-soft); }
.ghost-btn:hover { border-color: #c9d2df; }

.input {
  width: 100%; padding: 10px 12px; border-radius: 10px;
  border: 1px solid var(--line); background: #fff; outline: none;
}
.input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ---------- gallery ---------- */
.gallery-tools { display: flex; flex-direction: column; gap: 12px; margin-bottom: 16px; }
.cats { display: flex; gap: 8px; flex-wrap: wrap; }
.cat {
  border: 1px solid var(--line); background: #fff; border-radius: 999px;
  padding: 6px 14px; font-size: 13px; color: var(--ink-soft);
}
.cat.on { background: var(--ink); border-color: var(--ink); color: #fff; }

.g-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 12px;
}
.g-card {
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  overflow: hidden; cursor: pointer; transition: box-shadow .15s ease;
}
.g-card:hover { box-shadow: 0 8px 22px rgba(14, 22, 33, .10); }
.g-thumb { position: relative; aspect-ratio: 1/1; background: var(--paper); }
.g-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.g-thumb .ph { position: absolute; inset: 0; display: grid; place-items: center; color: var(--muted); font-size: 12px; }
.g-meta { padding: 8px 10px; display: flex; justify-content: space-between; gap: 6px; align-items: center; }
.g-title { font-weight: 600; font-size: 13px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.g-tag { font-size: 11px; color: var(--muted); flex: 0 0 auto; }
.g-more { text-align: center; margin: 20px 0 8px; }

/* ---------- make ---------- */
.make-layout { display: grid; grid-template-columns: 360px 1fr; gap: 16px; align-items: start; }
@media (max-width: 980px) { .make-layout { grid-template-columns: 1fr; } }

.panel {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 16px;
}
.panel + .panel { margin-top: 16px; }
.panel.grow { min-width: 0; }

.drop {
  position: relative; border: 2px dashed #cfd8e5; border-radius: 12px;
  background: #fafbfd; min-height: 170px; display: grid; place-items: center;
  overflow: hidden; transition: border-color .15s ease, background .15s ease;
}
.drop.over { border-color: var(--accent); background: var(--accent-soft); }
.drop-inner { text-align: center; padding: 24px; }
.drop-ico { font-size: 34px; color: var(--accent); line-height: 1; }
.drop-t { font-weight: 700; margin: 8px 0 6px; }
.src-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: contain; background: #fff; }

.field { margin-top: 16px; }
.field-top { display: flex; justify-content: space-between; align-items: baseline; margin-bottom: 6px; }
.label { font-weight: 700; font-size: 13px; }
.value { color: var(--accent); font-weight: 700; font-size: 13px; }
input[type="range"] { width: 100%; accent-color: var(--accent); }
.checks { display: flex; flex-direction: column; gap: 8px; }
.check { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ink-soft); }
.check input { accent-color: var(--accent); }
.tip { margin-top: 10px; }

.result-head { display: flex; justify-content: space-between; align-items: baseline; margin: 4px 0 10px; }
.canvas-wrap {
  position: relative; min-height: 320px; border-radius: 12px;
  background: #fff; border: 1px solid var(--line); padding: 10px;
  display: grid; place-items: center; overflow: auto;
}
#preview { max-width: 100%; height: auto; display: none; }
#preview.on { display: block; }
.empty { color: var(--muted); font-size: 13px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px; }
.lg {
  display: flex; align-items: center; gap: 8px; border: 1px solid var(--line);
  border-radius: 999px; padding: 4px 10px 4px 4px; background: #fff;
}
.lg .sw { width: 22px; height: 22px; border-radius: 50%; border: 1px solid rgba(0,0,0,.12); }
.lg .code { font-weight: 700; font-size: 12px; }
.lg .n { color: var(--muted); font-size: 11px; }

/* ---------- mine ---------- */
.hist { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; margin-top: 12px; }
.hist-card { border: 1px solid var(--line); border-radius: 12px; overflow: hidden; background: #fff; cursor: pointer; }
.hist-card img { width: 100%; aspect-ratio: 1/1; object-fit: contain; background: #fff; display: block; }
.hist-card .hm { padding: 6px 8px; font-size: 11px; color: var(--muted); display: flex; justify-content: space-between; }
.hist-empty { color: var(--muted); font-size: 13px; padding: 16px 0; }

.stock-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(52px, 1fr)); gap: 6px; margin-top: 12px; max-height: 420px; overflow: auto; }
.st {
  border: 2px solid transparent; border-radius: 8px; padding: 3px;
  display: flex; flex-direction: column; align-items: center; gap: 2px; background: #fff;
}
.st .sw { width: 100%; aspect-ratio: 1/1; border-radius: 5px; border: 1px solid rgba(0,0,0,.12); }
.st .cd { font-size: 9px; color: var(--muted); }
.st.on { border-color: var(--accent); background: var(--accent-soft); }
.st.on .cd { color: var(--ink); font-weight: 700; }

/* ---------- modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 50; background: rgba(10, 16, 26, .56);
  display: grid; place-items: center; padding: 20px;
}
.modal[hidden] { display: none; }
.modal-card {
  background: #fff; border-radius: 16px; width: min(920px, 100%);
  max-height: calc(100vh - 40px); display: flex; flex-direction: column; overflow: hidden;
  box-shadow: 0 24px 60px rgba(0,0,0,.28);
}
.modal-card.small { width: min(400px, 100%); }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); font-weight: 700; }
.modal-head .x { border: 0; background: transparent; font-size: 22px; line-height: 1; color: var(--muted); }
.modal-body { padding: 16px; overflow: auto; display: grid; place-items: center; }
.modal-body img { max-width: 100%; max-height: 64vh; display: block; }
.modal-foot { padding: 12px 16px; border-top: 1px solid var(--line); display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; }
.modal-foot.right { justify-content: flex-end; }
.gate-body { display: flex; flex-direction: column; gap: 10px; align-items: stretch; }
.err { color: #a33b32; font-size: 12px; min-height: 16px; }

.toast {
  position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%);
  background: var(--ink); color: #fff; padding: 10px 18px; border-radius: 999px;
  font-size: 13px; z-index: 80; box-shadow: 0 8px 24px rgba(0,0,0,.22);
}
.toast[hidden] { display: none; }
