@font-face {
  font-family: "WenQuanYi Zen Hei";
  src: url("../fonts/WenQuanYi-Zen-Hei-0.woff") format("woff");
  font-style: normal;
  font-weight: 400 800;
  font-display: swap;
}

:root {
  --bg: #06101f;
  --bg-deep: #030a14;
  --panel: #0a1729;
  --panel-raised: #0e1d32;
  --panel-muted: #0b1423;
  --line: rgba(151, 174, 205, 0.17);
  --line-strong: rgba(224, 170, 50, 0.42);
  --text: #f5f0e6;
  --text-muted: #afbdd0;
  --text-soft: #71829a;
  --gold: #e2aa32;
  --gold-bright: #f6d579;
  --gold-dark: #9c620e;
  --blue: #2377e8;
  --blue-bright: #47a4ff;
  --danger: #e58b76;
  --success: #88d7b1;
  --shadow-panel: 0 18px 48px rgba(0, 0, 0, 0.3);
  --shadow-gold: 0 8px 24px rgba(226, 170, 50, 0.16);
  --radius: 8px;
  --radius-sm: 5px;
  --duration: 160ms;
  --ease: cubic-bezier(0.22, 0.61, 0.36, 1);
}

* { box-sizing: border-box; }

html { min-height: 100%; background: var(--bg-deep); }

body {
  margin: 0;
  min-height: 100vh;
  font-family: "WenQuanYi Zen Hei", "Microsoft YaHei", "PingFang SC", sans-serif;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(33, 89, 151, 0.13), transparent 22rem),
    var(--bg);
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.24;
  background-image:
    linear-gradient(rgba(101, 143, 196, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(101, 143, 196, 0.08) 1px, transparent 1px);
  background-size: 40px 40px;
  mask-image: linear-gradient(180deg, black, transparent 72%);
}

button, input, select, textarea, canvas { font: inherit; }
button, input, select, textarea { outline: none; }
[hidden] { display: none !important; }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
  box-shadow: 0 0 0 3px rgba(71, 164, 255, 0.25);
  border-color: var(--blue-bright);
}

.app-shell {
  position: relative;
  z-index: 1;
  width: min(1820px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 18px 22px 14px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  min-height: 68px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-bottom-color: rgba(226, 170, 50, 0.3);
  border-radius: var(--radius);
  background: rgba(7, 18, 33, 0.94);
  box-shadow: var(--shadow-panel);
}

.brand-lockup, .topbar-meta, .section-title-row, .section-heading, .section-heading__label, .action-row, .size-row, .quick-controls, .editor-action-row {
  display: flex;
  align-items: center;
}

.brand-lockup { gap: 12px; }

.brand-mark {
  display: grid;
  place-items: center;
  width: 56px;
  height: 42px;
  color: #11151a;
  font-size: 1.02rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  border: 1px solid rgba(246, 213, 121, 0.66);
  border-radius: 5px;
  background: linear-gradient(155deg, #f6d579, #c78a31 58%, #9c620e);
  box-shadow: var(--shadow-gold), inset 0 1px 0 rgba(255, 255, 255, 0.56);
}

.brand-copy { display: grid; gap: 4px; }
.brand-eyebrow, .panel-kicker, .template-current__label, .field-help, .footer-note, .template-group__eyebrow {
  color: var(--text-soft);
}
.brand-eyebrow, .panel-kicker {
  margin: 0;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.18em;
}
.brand-name {
  margin: 0;
  font-size: clamp(1.2rem, 2vw, 1.56rem);
  line-height: 1;
  letter-spacing: 0.01em;
}
.topbar-meta { gap: 8px; flex-wrap: wrap; justify-content: flex-end; }

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 11px;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--text-muted);
  background: rgba(17, 34, 56, 0.64);
  font-size: 0.78rem;
  font-weight: 700;
  white-space: nowrap;
}
.status-pill svg, .btn svg, .section-heading__label svg, .upload-zone svg { width: 15px; height: 15px; stroke-width: 1.8; }
.mode-toggle { cursor: pointer; transition: border-color var(--duration) var(--ease), color var(--duration) var(--ease), background-color var(--duration) var(--ease); }
.mode-toggle:hover { color: var(--gold-bright); border-color: var(--line-strong); background: rgba(226, 170, 50, 0.08); }
body.editor-mode .mode-toggle { color: #16140f; border-color: transparent; background: linear-gradient(155deg, #f6d579, #c78a31); }

.workspace {
  display: grid;
  grid-template-columns: 254px minmax(0, 1fr) 330px;
  gap: 14px;
  height: calc(100vh - 118px);
  min-height: 650px;
  margin-top: 14px;
}

.panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, rgba(35, 91, 148, 0.06), transparent 28%), var(--panel);
  box-shadow: var(--shadow-panel);
  overflow: hidden;
}
.template-rail, .inspector, .preview-column { min-height: 0; }
.template-rail, .inspector { display: flex; flex-direction: column; }
.inspector { overflow-y: auto; scrollbar-color: rgba(226, 170, 50, 0.4) transparent; }
.preview-column { display: flex; }
.panel-section { padding: 16px; }
.panel-section + .panel-section { border-top: 1px solid rgba(151, 174, 205, 0.12); }
.panel-section--tight { padding: 16px 14px 12px; }
.panel-title { margin: 0; color: var(--text); font-size: 1.08rem; font-weight: 700; }
.panel-copy { margin: 8px 0 0; color: var(--text-muted); font-size: 0.76rem; line-height: 1.55; }
.section-title-row { justify-content: space-between; gap: 10px; }
.count-badge, .mode-dot { display: inline-flex; align-items: center; justify-content: center; }
.count-badge { min-width: 27px; height: 22px; padding: 0 7px; color: var(--gold-bright); border: 1px solid rgba(226, 170, 50, 0.28); border-radius: 4px; background: rgba(226, 170, 50, 0.08); font-size: 0.7rem; font-weight: 800; }
.mode-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--success); box-shadow: 0 0 0 4px rgba(136, 215, 177, 0.1); }

.template-current { margin: 0 14px 10px; padding: 10px 11px; border: 1px solid rgba(226, 170, 50, 0.18); border-radius: 5px; background: rgba(226, 170, 50, 0.05); }
.template-current__label { display: block; margin-bottom: 4px; font-size: 0.62rem; letter-spacing: 0.14em; text-transform: uppercase; }
.template-current__value { display: block; color: var(--gold-bright); font-size: 0.86rem; }
.template-groups { flex: 1; min-height: 0; padding: 0 14px 14px; overflow-y: auto; }
.language-bar { display: flex; gap: 6px; margin-bottom: 10px; }
.language-bar__item { display: inline-flex; align-items: center; gap: 7px; min-height: 32px; padding: 0 10px; color: var(--text-muted); border: 1px solid var(--line); border-radius: 5px; background: rgba(21, 40, 63, 0.5); font-size: 0.76rem; font-weight: 700; cursor: pointer; }
.language-bar__item:hover, .language-bar__item.is-active { color: var(--gold-bright); border-color: rgba(226, 170, 50, 0.42); background: rgba(226, 170, 50, 0.08); }
.language-bar__flag { display: inline-grid; place-items: center; width: 20px; height: 18px; color: var(--gold); border: 1px solid rgba(226, 170, 50, 0.32); border-radius: 3px; font-size: 0.56rem; letter-spacing: 0.04em; }
.template-chip-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 6px; }
.template-chip { min-height: 34px; padding: 0 6px; color: var(--text-muted); border: 1px solid var(--line); border-radius: 5px; background: rgba(18, 35, 56, 0.46); font-size: 0.76rem; font-weight: 700; cursor: pointer; transition: border-color var(--duration) var(--ease), background-color var(--duration) var(--ease), color var(--duration) var(--ease), transform var(--duration) var(--ease); }
.template-chip:hover { transform: translateY(-1px); color: var(--text); border-color: rgba(71, 164, 255, 0.56); background: rgba(35, 119, 232, 0.12); }
.template-chip.is-active { color: #17140e; border-color: transparent; background: linear-gradient(155deg, #f6d579, #c78a31); box-shadow: 0 5px 16px rgba(226, 170, 50, 0.18); }

.preview-panel { display: flex; flex: 1; min-height: 0; flex-direction: column; padding: 16px; }
.panel-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 14px; margin-bottom: 12px; flex-shrink: 0; }
.action-row { gap: 7px; flex-wrap: wrap; justify-content: flex-end; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; min-height: 37px; padding: 0 12px; border: 1px solid transparent; border-radius: 5px; font-size: 0.77rem; font-weight: 800; cursor: pointer; transition: transform var(--duration) var(--ease), border-color var(--duration) var(--ease), background-color var(--duration) var(--ease), color var(--duration) var(--ease); }
.btn:hover { transform: translateY(-1px); }
.btn--primary { color: #17140e; background: linear-gradient(155deg, #f6d579, #c78a31); box-shadow: 0 6px 17px rgba(226, 170, 50, 0.16); }
.btn--secondary { color: var(--text-muted); border-color: var(--line); background: rgba(18, 36, 59, 0.68); }
.btn--secondary:hover { color: var(--gold-bright); border-color: rgba(226, 170, 50, 0.42); background: rgba(226, 170, 50, 0.08); }
.btn--small { min-height: 32px; padding: 0 9px; font-size: 0.72rem; }
.btn--block { width: 100%; }

.canvas-frame { position: relative; display: flex; flex: 1; min-height: 0; align-items: center; justify-content: center; overflow: auto; padding: 18px; border: 1px solid rgba(71, 164, 255, 0.14); border-radius: 6px; background: #030a14; }
.canvas-frame::before { content: "1024 × 1536 / JPG"; position: absolute; top: 9px; left: 10px; z-index: 1; padding: 3px 6px; color: rgba(175, 189, 208, 0.62); border: 1px solid rgba(151, 174, 205, 0.16); border-radius: 3px; background: rgba(3, 10, 20, 0.78); font-size: 0.6rem; letter-spacing: 0.08em; pointer-events: none; }
.canvas-frame canvas { display: block; width: auto; height: min(78vh, 780px); max-width: 100%; object-fit: contain; border: 1px solid rgba(226, 170, 50, 0.18); box-shadow: 0 18px 38px rgba(0, 0, 0, 0.35); }
.canvas-frame.is-transitioning { animation: canvasPulse 260ms var(--ease); }
@keyframes canvasPulse { from { opacity: 0.7; transform: scale(0.995); } to { opacity: 1; transform: scale(1); } }
.canvas-overlay { position: absolute; inset: 0; display: none; place-items: center; background: rgba(3, 10, 20, 0.74); }
.canvas-overlay.is-visible { display: grid; }
.loading-card { min-width: 210px; padding: 18px; text-align: center; border: 1px solid var(--line); border-radius: 6px; background: rgba(8, 23, 41, 0.97); box-shadow: var(--shadow-panel); }
.loading-card p { margin: 0; color: var(--text-muted); font-size: 0.78rem; }
.loading-card--error p { margin-bottom: 12px; color: var(--danger); }
.spinner { width: 24px; height: 24px; margin: 0 auto 10px; border: 2px solid rgba(226, 170, 50, 0.16); border-top-color: var(--gold-bright); border-radius: 50%; animation: spin 800ms linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.status-strip { margin-top: 10px; padding: 9px 11px; color: var(--gold-bright); border: 1px solid rgba(226, 170, 50, 0.2); border-radius: 5px; background: rgba(226, 170, 50, 0.07); font-size: 0.74rem; }

.section-heading { justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.section-heading__label { gap: 7px; }
.section-heading__label svg { color: var(--gold); }
.section-heading h3 { margin: 0; font-size: 0.88rem; }
.mini-badge { display: inline-flex; align-items: center; min-height: 21px; padding: 0 6px; color: var(--text-soft); border: 1px solid var(--line); border-radius: 4px; background: rgba(151, 174, 205, 0.07); font-size: 0.6rem; font-weight: 800; letter-spacing: 0.08em; }
.mini-badge--live { color: #18140a; border-color: transparent; background: linear-gradient(155deg, #f6d579, #c78a31); }
.control-group { display: grid; gap: 10px; }
.field-label { margin: 0; color: var(--text-muted); font-size: 0.73rem; font-weight: 800; }
.field-help { margin: 0; font-size: 0.68rem; line-height: 1.45; }
.upload-zone { display: grid; place-items: center; gap: 5px; min-height: 76px; padding: 11px; color: var(--text-muted); border: 1px dashed rgba(71, 164, 255, 0.42); border-radius: 5px; background: rgba(35, 119, 232, 0.06); cursor: pointer; transition: border-color var(--duration) var(--ease), color var(--duration) var(--ease), background-color var(--duration) var(--ease); }
.upload-zone:hover { color: var(--gold-bright); border-color: rgba(226, 170, 50, 0.56); background: rgba(226, 170, 50, 0.07); }
.upload-zone svg { color: var(--blue-bright); }
.upload-zone span { font-size: 0.74rem; font-weight: 700; }
.upload-zone small { color: var(--text-soft); font-size: 0.63rem; }
.file-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.text-input, .field-inline input, .field-inline select { width: 100%; min-height: 37px; padding: 0 10px; color: var(--text); border: 1px solid var(--line); border-radius: 5px; background: rgba(8, 22, 39, 0.92); font-size: 0.78rem; }
.text-input::placeholder { color: rgba(175, 189, 208, 0.45); }
.text-input--area { min-height: 62px; padding: 8px 10px; resize: vertical; line-height: 1.5; }
.compact-control { display: grid; gap: 8px; }
.quick-controls { align-items: flex-end; justify-content: space-between; gap: 10px; }
.nudge-grid { display: grid; grid-template-columns: repeat(3, 32px); grid-template-rows: repeat(2, 30px); gap: 4px; }
.nudge-btn { display: grid; place-items: center; padding: 0; color: var(--text-muted); border: 1px solid var(--line); border-radius: 4px; background: rgba(18, 36, 59, 0.68); cursor: pointer; }
.nudge-btn:hover { color: var(--gold-bright); border-color: rgba(226, 170, 50, 0.45); background: rgba(226, 170, 50, 0.09); }
.nudge-btn svg { width: 14px; height: 14px; }
.nudge-btn--up { grid-column: 2; grid-row: 1; }
.nudge-btn--left { grid-column: 1; grid-row: 2; }
.nudge-btn--right { grid-column: 3; grid-row: 2; }
.nudge-btn--down { grid-column: 2; grid-row: 2; }
.size-row { gap: 5px; flex-wrap: wrap; }
.editor-stack { display: grid; gap: 15px; }
.segmented-control { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 4px; }
.segment { min-height: 32px; padding: 0 5px; color: var(--text-muted); border: 1px solid var(--line); border-radius: 4px; background: rgba(18, 36, 59, 0.64); font-size: 0.68rem; font-weight: 800; cursor: pointer; }
.segment.is-active { color: #19150e; border-color: transparent; background: linear-gradient(155deg, #f6d579, #c78a31); }
.field-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin-top: 8px; }
.field-inline { display: grid; gap: 4px; }
.field-inline span { color: var(--text-soft); font-size: 0.64rem; font-weight: 800; }
.coords-box { max-height: 300px; margin: 0; padding: 10px; overflow: auto; color: var(--text-muted); border: 1px solid var(--line); border-radius: 5px; background: var(--panel-muted); font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 0.64rem; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.footer-note { display: flex; justify-content: center; gap: 8px; padding: 11px 0 0; font-size: 0.64rem; }
.footer-separator { color: rgba(226, 170, 50, 0.56); }
.toast { position: fixed; right: 20px; bottom: 20px; z-index: 20; min-width: 210px; padding: 10px 12px; color: var(--text); border: 1px solid var(--line-strong); border-radius: 5px; background: rgba(8, 23, 41, 0.97); box-shadow: var(--shadow-panel); opacity: 0; transform: translateY(8px); pointer-events: none; transition: opacity var(--duration) var(--ease), transform var(--duration) var(--ease); font-size: 0.76rem; }
.toast.is-visible { opacity: 1; transform: translateY(0); }
.toast[data-tone="error"] { color: #ffd4cb; border-color: rgba(229, 139, 118, 0.42); }

@media (max-width: 1280px) {
  .workspace { grid-template-columns: 220px minmax(0, 1fr) 300px; }
  .app-shell { padding-inline: 14px; }
}

@media (max-width: 980px) {
  .workspace { grid-template-columns: 1fr; height: auto; min-height: 0; }
  .template-rail, .inspector, .preview-column { min-height: 0; overflow: visible; }
  .template-groups { overflow: visible; }
  .template-chip-grid { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .canvas-frame { min-height: 680px; }
  .canvas-frame canvas { height: min(78vh, 760px); }
}

@media (max-width: 640px) {
  .app-shell { padding: 10px; }
  .topbar, .panel-head { align-items: flex-start; flex-direction: column; }
  .topbar { gap: 12px; }
  .topbar-meta, .action-row { width: 100%; justify-content: flex-start; }
  .workspace { gap: 10px; margin-top: 10px; }
  .template-chip-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .canvas-frame { min-height: 500px; padding: 10px; }
  .canvas-frame canvas { height: auto; width: min(100%, 420px); }
  .quick-controls { align-items: flex-start; flex-direction: column; }
  .footer-note { flex-wrap: wrap; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: 1ms !important; transition-duration: 1ms !important; }
}
