/* Self-hosted styles. System CJK font stack, no web fonts or external assets. */
:root {
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #1c2026;
  --muted: #687280;
  --line: #dde1e6;
  --accent: #2f3d47;
  --accent-ink: #ffffff;
  --ok: #1f7a4d;
  --warn: #9a5b00;
  --error: #b42318;
  --info: #2457a6;
  --radius: 10px;
  --font: -apple-system, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans CJK SC",
          "Source Han Sans SC", "Segoe UI", Roboto, sans-serif;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--text); font: 15px/1.55 var(--font); }
a { color: var(--info); }
h1 { font-size: 22px; margin: 0 0 12px; }
h2 { font-size: 16px; margin: 0 0 10px; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 13px; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.inline { display: inline; }
.row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }

/* top bar */
.topbar { display: flex; align-items: center; gap: 20px; padding: 10px 20px; background: var(--surface);
  border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.brand { font-weight: 700; color: var(--text); text-decoration: none; letter-spacing: .02em; }
.brand span { font-weight: 400; color: var(--muted); }
.nav { display: flex; gap: 4px; }
.nav a, .subnav a { color: var(--text); text-decoration: none; padding: 6px 10px; border-radius: 8px; }
.nav a[aria-current], .subnav a[aria-current] { background: var(--bg); font-weight: 600; }
.who { margin-left: auto; display: flex; gap: 12px; align-items: center; font-size: 14px; }
.who a { text-decoration: none; }
.subnav { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 16px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }

/* layout */
.page { max-width: 1200px; margin: 0 auto; padding: 20px; }
.page.wide { max-width: 1600px; }
.auth { display: grid; place-items: start center; padding: 8vh 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.narrow { width: 100%; max-width: 420px; }
.card.narrow-left { max-width: 560px; }
.card.highlight { border-color: #e8c27a; background: #fffaf0; }
.two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.page-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; }

/* forms */
.stack { display: grid; gap: 12px; }
label { display: grid; gap: 4px; font-size: 14px; color: var(--muted); }
input[type=text], input[type=email], input[type=password], input[type=number], input[type=datetime-local], select, textarea {
  font: inherit; color: var(--text); background: #fff; border: 1px solid var(--line); border-radius: 8px; padding: 8px 10px; width: 100%; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus, button:focus-visible, .button:focus-visible { outline: 2px solid var(--info); outline-offset: 1px; }
button, .button { font: inherit; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 8px 14px; border-radius: 8px; border: 1px solid var(--line); background: #fff; color: var(--text);
  cursor: pointer; text-decoration: none; white-space: nowrap; }
button:hover, .button:hover { border-color: #b9c0c8; }
button.primary, .button.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
button.danger { color: var(--error); }
button:disabled { opacity: .5; cursor: not-allowed; }
button.link { border: 0; background: none; padding: 0; color: var(--info); }
button.link.danger { color: var(--error); }
.alert { color: var(--error); background: #fdecea; border-radius: 8px; padding: 8px 12px; }
.ok { color: var(--ok); background: #e8f5ee; border-radius: 8px; padding: 8px 12px; }
.badge { display: inline-block; white-space: nowrap; font-size: 12px; padding: 2px 8px; border-radius: 999px; background: var(--bg); color: var(--muted); }
.badge[data-kind=ok] { background: #e8f5ee; color: var(--ok); }
.badge[data-kind=warn] { background: #fff4e0; color: var(--warn); }
.badge[data-kind=info] { background: #e8effa; color: var(--info); }

/* configurator */
.config { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
.stage { min-width: 0; }
.viewport { position: relative; aspect-ratio: 2400 / 991; background: linear-gradient(#f6f7f9, #e2e5e9);
  border: 1px solid var(--line); border-radius: var(--radius); overflow: hidden; }
.viewport img { width: 100%; height: 100%; object-fit: contain; display: block; }
.placeholder { position: absolute; inset: 0; display: grid; place-content: center; text-align: center; padding: 20px; }
.placeholder p { margin: 4px 0; }
.overlay { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; gap: 10px;
  background: rgba(246, 247, 249, .78); backdrop-filter: blur(2px); }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid #c9ced4; border-top-color: var(--accent);
  animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 3s; } }
.stage-bar { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-top: 12px; flex-wrap: wrap; }
.status { font-size: 14px; min-height: 1.5em; }
.status[data-kind=error] { color: var(--error); }
.status[data-kind=warn] { color: var(--warn); }
.status[data-kind=ok] { color: var(--ok); }
.buttons { display: flex; gap: 8px; }
.notice { font-size: 13px; color: var(--warn); margin: 10px 0 0; }
.menu { position: relative; }
.menu summary { list-style: none; }
.menu summary::-webkit-details-marker { display: none; }
.menu summary[aria-disabled] { opacity: .5; }
.menu-list { position: absolute; right: 0; top: calc(100% + 4px); background: #fff; border: 1px solid var(--line);
  border-radius: 8px; box-shadow: 0 8px 24px rgba(0,0,0,.08); display: grid; min-width: 200px; z-index: 5; }
.menu-list a { padding: 10px 14px; color: var(--text); text-decoration: none; }
.menu-list a:hover { background: var(--bg); }

.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px;
  position: sticky; top: 72px; max-height: calc(100vh - 92px); overflow: auto; }
.scheme-head { display: flex; gap: 8px; align-items: center; margin-bottom: 10px; }
.scheme-head input { font-weight: 600; }
.campaign { font-size: 13px; color: var(--warn); margin: 0 0 8px; }
.parts { list-style: none; margin: 0; padding: 0; }
.part { border-top: 1px solid var(--line); padding: 10px 0; }
.part:first-child { border-top: 0; }
.part-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.part-name { font-weight: 600; }
.chip { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--muted); }
.chip.locked { color: var(--muted); }
.chip.locked::before { content: ""; width: 10px; height: 10px; border: 2px solid currentColor; border-radius: 2px; }
.dot { width: 14px; height: 14px; border-radius: 50%; background: var(--c); border: 1px solid rgba(0,0,0,.2); display: inline-block; }
.swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.swatch { flex-direction: column; gap: 4px; padding: 4px; min-width: 64px; border-radius: 8px; }
.swatch::before { content: ""; width: 100%; height: 26px; border-radius: 5px; background: var(--c); border: 1px solid rgba(0,0,0,.15); }
.swatch[aria-checked=true] { border-color: var(--accent); box-shadow: 0 0 0 2px var(--accent); }
.swatch-label { font-size: 12px; }
.part-note { font-size: 12px; color: var(--muted); margin: 6px 0 0; }
.panel-actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; border-top: 1px solid var(--line); padding-top: 14px; }
.panel-actions .file { position: relative; }

/* schemes */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 16px; }
.scheme-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px;
  display: grid; gap: 10px; align-content: start; }
.scheme-card img { width: 100%; border-radius: 6px; background: #eef0f3; display: block; }
.thumb-empty { aspect-ratio: 2400 / 991; display: grid; place-items: center; background: var(--bg); border-radius: 6px; color: var(--muted); font-size: 13px; }
.scheme-meta h2 { margin: 0 0 4px; }
.scheme-meta p { margin: 4px 0 0; }
.codes { margin: 6px 0 0; padding-left: 18px; color: var(--muted); }

/* admin */
.stats { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; margin-bottom: 16px; }
.stat { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px; display: grid; color: var(--muted); font-size: 13px; }
.stat span { font-size: 24px; font-weight: 700; color: var(--text); }
.table-wrap { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { color: var(--muted); font-weight: 600; white-space: nowrap; }
td .row form { display: inline; }

@media (max-width: 960px) {
  .config { grid-template-columns: 1fr; }
  .panel { position: static; max-height: none; }
  .two-col { grid-template-columns: 1fr; }
}
@media (max-width: 600px) {
  .page { padding: 12px; }
  .topbar { flex-wrap: wrap; gap: 8px 14px; padding: 8px 12px; }
  .who { margin-left: 0; width: 100%; justify-content: flex-end; }
  .viewport { aspect-ratio: 2400 / 1100; }
  .stage-bar { flex-direction: column; align-items: stretch; }
  .buttons { justify-content: stretch; }
  .buttons > * { flex: 1; }
  .menu summary { width: 100%; }
}
input.short { width: 150px; padding: 4px 8px; }
.grow { flex: 1; min-width: 220px; }

/* colour picker */
.part-head .change { margin-left: 8px; font-size: 13px; }
.part-head .chip { margin-left: auto; }
.picker { margin-top: 8px; background: var(--bg); border-radius: 8px; padding: 10px; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.tab { padding: 4px 10px; font-size: 13px; background: transparent; border-color: transparent; }
.tab[aria-selected=true] { background: #fff; border-color: var(--line); font-weight: 600; }
.picker-search { margin-bottom: 8px; }
.picker .swatch { min-width: 92px; }
/* watermark notice + share */
.wm-notice { max-width: 1600px; margin: 0 auto 16px; background: #fffaf0; border: 1px solid #e8c27a; border-radius: var(--radius); padding: 14px 18px; }
.wm-notice p { margin: 0 0 8px; }
.share-box { margin-top: 12px; background: var(--bg); border-radius: 8px; padding: 10px; }
.share-box p { margin: 0 0 8px; }
.section-title { margin-top: 28px; }
.small-cards { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); }
.small-cards p { margin: 0; }
.codes { list-style: none; padding-left: 0; }
.codes li { display: flex; align-items: center; gap: 6px; }
.dot.big { width: 22px; height: 22px; }
tr.highlight-row td { background: #f0faf4; }
.ref-box { margin-top: 8px; }
.ref-box input { font-size: 13px; }
.ref-box .part-note { color: var(--warn); }
.custom-row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.custom-row input[type=color] { width: 44px; height: 36px; padding: 2px; border: 1px solid var(--line); border-radius: 8px; background: #fff; }
.custom-row input[type=text] { width: 120px; }
.chip .ref { font-size: 12px; color: var(--warn); }
