:root {
  --canvas: #07110f;
  --surface: #101715;
  --surface-2: #17211e;
  --surface-3: #22302b;
  --panel: #fbfaf7;
  --panel-2: #eef1ee;
  --ink: #111827;
  --ink-soft: #52615d;
  --ink-on-dark: #f7fbf8;
  --muted-on-dark: #a9b7b1;
  --line: #d9e0dc;
  --line-dark: #2a3833;
  --brand: #0f766e;
  --brand-dark: #0b5d56;
  --brand-soft: #dcefeb;
  --accent: #c9974a;
  --accent-soft: #f7ecd8;
  --warning: #b56f16;
  --warning-bg: #fff4df;
  --danger: #bc3327;
  --danger-bg: #fff0ee;
  --ok: #1a8f45;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

.hidden {
  display: none !important;
}

html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--canvas);
  font-family: Inter, "SF Pro Text", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 0;
}

.app-shell {
  height: 100vh;
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  background: var(--canvas);
  overflow: hidden;
}

.topbar {
  min-height: 68px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 14px 18px;
  color: var(--ink-on-dark);
  background: linear-gradient(90deg, #050b0a 0%, #10201c 56%, #18231e 100%);
  border-bottom: 1px solid var(--line-dark);
}

.brand-block {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  object-fit: contain;
  filter: drop-shadow(0 4px 9px rgba(0, 0, 0, 0.24));
}

.brand-block h1 {
  margin: 0 0 3px;
  font-size: 21px;
  line-height: 1.15;
}

.brand-block p {
  margin: 0;
  color: var(--muted-on-dark);
  font-size: 13px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.system-pill {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  padding: 0 11px;
  border: 1px solid rgba(201, 151, 74, 0.58);
  border-radius: 2px;
  color: #f2c97f;
  background: rgba(201, 151, 74, 0.1);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.vip-status-button {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(201, 151, 74, 0.58);
  border-radius: 4px;
  color: #f7fbf8;
  background: var(--brand);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.vip-status-button.vip-active {
  color: #07110f;
  background: var(--accent);
}

.wechat-mask {
  position: fixed;
  inset: 0;
  z-index: 3000;
  display: grid;
  place-items: center;
  padding: 28px;
  color: #fff;
  background: #030706;
  text-align: center;
}

.wechat-mask > div {
  max-width: 420px;
}

.wechat-mask strong {
  display: block;
  margin-bottom: 12px;
  font-size: 24px;
}

.wechat-mask p {
  margin: 0;
  color: #cbd5d1;
  font-size: 15px;
  line-height: 1.7;
}

.status-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  border-bottom: 1px solid var(--line-dark);
  background: #0b1412;
}

.status-strip div {
  min-width: 0;
  padding: 10px 14px;
  border-right: 1px solid var(--line-dark);
}

.status-strip div:last-child {
  border-right: 0;
}

.status-strip span {
  display: block;
  margin-bottom: 3px;
  color: var(--muted-on-dark);
  font-size: 11px;
}

.status-strip strong {
  display: block;
  overflow: hidden;
  color: var(--ink-on-dark);
  font-size: 16px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.workspace {
  min-height: 0;
  overflow: hidden;
  display: grid;
  grid-template-columns: 390px minmax(0, 1fr);
}

.control-rail {
  min-height: 0;
  height: 100%;
  overflow-y: auto;
  padding: 12px 12px 0;
  background: var(--panel-2);
  border-right: 1px solid var(--line);
}

.panel {
  margin-bottom: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel);
}

.panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
}

.panel-title h2 {
  margin: 0;
  font-size: 15px;
  line-height: 1.2;
}

.step {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 22px;
  border-radius: 2px;
  color: #f7fbf8;
  background: linear-gradient(135deg, var(--brand), #14857b);
  font-size: 12px;
  font-weight: 800;
}

.split-title {
  justify-content: space-between;
}

.split-title > div:first-child {
  display: flex;
  align-items: center;
  gap: 8px;
}

.upload-zone {
  position: relative;
  min-height: 112px;
  display: grid;
  place-items: center;
  padding: 16px;
  border: 1px dashed #98aaa4;
  border-radius: 4px;
  background: #f7faf8;
  text-align: center;
  cursor: pointer;
}

.upload-zone.drag {
  border-color: var(--brand);
  background: var(--brand-soft);
}

.upload-zone input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border-radius: 2px;
  color: #f7fbf8;
  background: linear-gradient(135deg, var(--brand), var(--accent));
  font-size: 24px;
  font-weight: 800;
}

.upload-zone strong {
  display: block;
  margin-top: 6px;
  color: var(--ink);
  font-size: 15px;
}

.upload-zone small {
  color: var(--ink-soft);
  font-size: 12px;
  line-height: 1.45;
}

.field {
  display: block;
  color: var(--ink-soft);
  font-size: 12px;
}

.field + .field,
.field-grid + .field,
.field + .field-grid {
  margin-top: 8px;
}

.field span {
  display: block;
  margin-bottom: 4px;
}

.field-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  align-items: start;
}

.field-grid > .field + .field {
  margin-top: 0;
}

.field-grid.compact {
  margin-top: 8px;
}

input[type="number"],
input[type="text"],
select {
  width: 100%;
  height: 36px;
  padding: 0 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus,
select:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.range-row {
  display: grid;
  grid-template-columns: 1fr 48px;
  gap: 8px;
  align-items: center;
}

.range-row input {
  width: 100%;
  accent-color: var(--brand);
}

.range-row output {
  padding: 5px 7px;
  border-radius: 2px;
  color: var(--brand-dark);
  background: var(--brand-soft);
  text-align: center;
  font-size: 12px;
  font-weight: 800;
}

.toggle-row {
  min-height: 34px;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 7px 8px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
  font-size: 12px;
}

.toggle-row input {
  margin: 0;
  accent-color: var(--brand);
}

.note {
  margin: 9px 0 0;
  padding: 8px 9px;
  border-radius: 4px;
  color: #765100;
  background: var(--warning-bg);
  font-size: 12px;
  line-height: 1.45;
}

.palette-actions,
.button-grid,
.tool-segment,
.view-controls,
.preview-toggles,
.zoom-controls {
  display: flex;
  align-items: center;
  gap: 7px;
}

.palette-actions span {
  min-width: 44px;
  color: var(--ink-soft);
  font-size: 12px;
  text-align: center;
}

.mini-button,
.icon-button {
  width: 32px;
  height: 32px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
  font-size: 17px;
  font-weight: 800;
  cursor: pointer;
}

.icon-button {
  border-color: var(--line-dark);
  color: var(--ink-on-dark);
  background: var(--surface-2);
}

.mini-button:hover,
.icon-button:hover {
  border-color: var(--brand);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.palette-list {
  display: grid;
  gap: 6px;
  max-height: 196px;
  overflow: auto;
  padding-right: 2px;
}

.palette-row {
  display: grid;
  grid-template-columns: 30px 38px repeat(3, minmax(0, 1fr));
  gap: 5px;
  align-items: center;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.palette-row.selected {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.16);
}

.palette-swatch {
  width: 30px;
  height: 30px;
  border: 2px solid #fff;
  border-radius: 3px;
  box-shadow: 0 0 0 1px var(--line);
}

.palette-row input[type="color"] {
  width: 38px;
  height: 30px;
  padding: 2px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
}

.palette-row input[type="number"] {
  height: 30px;
  padding: 0 4px;
  text-align: center;
}

.button-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  margin-top: 8px;
}

.compact-buttons {
  margin: 0 0 8px;
}

.preset-buttons {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.preset-buttons .secondary-button {
  position: relative;
  min-height: 54px;
  border-width: 2px;
  font-size: 15px;
}

.preset-buttons .secondary-button.preset-active {
  color: #fff;
  border-color: var(--brand);
  background: var(--brand);
}

button,
.secondary-button {
  min-height: 36px;
  padding: 0 12px;
  border-radius: 4px;
  color: #f7fbf8;
  background: var(--brand);
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
}

button:hover {
  background: #14857b;
}

.secondary-button {
  border: 1px solid var(--line);
  color: var(--ink);
  background: #fff;
}

.secondary-button:hover {
  border-color: var(--brand);
  background: #f4fbf8;
}

.danger-button {
  color: #7f1d1d;
  border: 1px solid rgba(188, 51, 39, 0.28);
  background: #fff7f6;
}

.danger-button:hover {
  color: #fff;
  background: var(--danger);
}

.full-button {
  width: 100%;
  margin-top: 8px;
}

.color-usage {
  margin-top: 9px;
  border: 1px solid var(--line);
  border-radius: 4px;
  overflow: hidden;
  background: #fff;
}

.usage-title,
.usage-row,
.usage-total {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  align-items: center;
  gap: 7px;
  padding: 6px 8px;
  font-size: 12px;
}

.usage-title {
  display: block;
  color: var(--ink-soft);
  background: #f0f5ed;
  font-weight: 800;
}

.usage-row,
.usage-total {
  border-top: 1px solid var(--line);
}

.usage-dot {
  width: 17px;
  height: 17px;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 3px;
}

.usage-row strong,
.usage-total strong {
  font-size: 12px;
}

.usage-total {
  grid-template-columns: 1fr auto;
  color: var(--brand-dark);
  background: var(--brand-soft);
}

.sticky-actions {
  position: sticky;
  bottom: 0;
  margin-bottom: 0;
  padding-bottom: 16px;
  box-shadow: 0 -10px 24px rgba(8, 12, 9, 0.08);
}

.tool-segment {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.tool-segment button {
  min-height: 34px;
  color: var(--ink);
  border: 1px solid var(--line);
  background: #fff;
}

.tool-segment button.active {
  color: #f7fbf8;
  border-color: var(--brand);
  background: var(--brand);
}

.export-button {
  width: 100%;
  margin-top: 8px;
  color: var(--ink-on-dark);
  background: linear-gradient(135deg, #0f766e, #15231f);
  border: 1px solid rgba(201, 151, 74, 0.62);
}

.export-button:hover {
  color: #07110f;
  background: var(--accent);
}

.stage {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 12px;
  background: var(--surface);
}

.canvas-toolbar {
  min-height: 46px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  color: var(--ink-on-dark);
  background: #0b1412;
}

.view-controls,
.preview-mode-controls,
.preview-toggles,
.zoom-controls {
  min-width: 0;
}

.preview-mode-controls {
  display: flex;
  align-items: center;
  gap: 7px;
}

.view-button {
  min-height: 32px;
  padding: 0 10px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  color: var(--ink-on-dark);
  background: var(--surface-2);
  font-size: 12px;
  font-weight: 800;
}

.view-button.active {
  color: #f7fbf8;
  border-color: var(--brand);
  background: var(--brand);
}

.preview-toggles label {
  min-height: 32px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 0 9px;
  border: 1px solid var(--line-dark);
  border-radius: 4px;
  color: var(--ink-on-dark);
  background: #101710;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.preview-toggles input {
  margin: 0;
  accent-color: var(--brand);
}

.mode-readout span {
  display: block;
  margin-bottom: 2px;
  color: var(--muted-on-dark);
  font-size: 11px;
}

.mode-readout strong {
  font-size: 14px;
}

.zoom-controls span {
  min-width: 48px;
  color: var(--ink-on-dark);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
}

.preview-3d {
  position: relative;
  min-height: 0;
  overflow: hidden;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  background: #eef3f1;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 460px;
  cursor: crosshair;
}

canvas.is-panning {
  cursor: grab;
}

.preview-3d {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.single-preview {
  min-height: 0;
  height: 100%;
}

.three-viewport {
  min-height: 0;
  height: 100%;
  background: #eef3f1;
}

.three-viewport.hidden {
  display: none;
}

.three-viewport canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  cursor: grab;
  touch-action: none;
}

.three-viewport canvas:active {
  cursor: grabbing;
}

.edit-canvas {
  display: block;
  width: 100%;
  height: 100%;
  min-height: 0;
  background: #edf2f6;
  cursor: crosshair;
  touch-action: none;
}

.edit-canvas.hidden {
  display: none;
}

.edit-canvas.is-panning {
  cursor: grab;
}

.edit-canvas.is-panning:active {
  cursor: grabbing;
}

.viewport-title {
  z-index: 2;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 8px 10px;
  color: var(--ink-on-dark);
  background: rgba(0, 0, 0, 0.64);
  border-bottom: 1px solid var(--line-dark);
}

.viewport-title span {
  color: var(--muted-on-dark);
  font-size: 12px;
}

.viewport-title strong {
  color: var(--brand);
  font-size: 12px;
}

.dimension-overlay {
  position: absolute;
  right: 10px;
  bottom: 10px;
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(3, auto);
  gap: 7px;
  pointer-events: none;
}

.dimension-overlay span {
  padding: 7px 9px;
  border: 1px solid rgba(201, 151, 74, 0.48);
  border-radius: 4px;
  color: #d8f5ef;
  background: rgba(0, 0, 0, 0.7);
  font-size: 12px;
  font-weight: 800;
  white-space: nowrap;
}

.dimension-overlay.hidden {
  display: none;
}

.canvas-hint {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 2;
  max-width: calc(100% - 20px);
  padding: 7px 9px;
  border: 1px solid rgba(15, 118, 110, 0.32);
  border-radius: 4px;
  color: #dfe9d5;
  background: rgba(0, 0, 0, 0.62);
  font-size: 12px;
  pointer-events: none;
}

.inspection-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.status,
.print-check {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line-dark);
  border-radius: 6px;
  color: var(--muted-on-dark);
  background: #0b1412;
  font-size: 13px;
  line-height: 1.45;
}

.status.warning,
.print-check.warning {
  color: #ffd27b;
  border-color: rgba(197, 122, 0, 0.6);
  background: rgba(197, 122, 0, 0.12);
}

.status.error {
  color: #ffb7b1;
  border-color: rgba(188, 51, 39, 0.65);
  background: rgba(188, 51, 39, 0.13);
}

.print-check {
  min-width: 280px;
}

.print-check strong,
.print-check span {
  display: block;
}

.print-check strong {
  margin-bottom: 3px;
  color: var(--ink-on-dark);
}

.print-check em {
  display: block;
  margin-top: 4px;
  color: var(--muted-on-dark);
  font-size: 12px;
  font-style: normal;
}

.print-check.ok span {
  color: #bde899;
}

.print-check.idle span {
  color: var(--muted-on-dark);
}

.auth-modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 1200;
  background: rgba(4, 11, 10, 0.66);
  backdrop-filter: blur(8px);
}

.auth-modal {
  position: fixed;
  left: 50%;
  top: 50%;
  z-index: 1201;
  width: min(420px, calc(100vw - 32px));
  transform: translate(-50%, -50%);
  padding: 22px;
  border: 1px solid rgba(201, 151, 74, 0.28);
  border-radius: 8px;
  color: var(--ink);
  background: var(--panel);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.34);
}

.auth-modal-wide {
  width: min(640px, calc(100vw - 32px));
}

.redeem-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 12px;
}

.redeem-col-divider {
  padding-left: 20px;
  border-left: 1px solid var(--line);
}

.redeem-col h3 {
  margin: 0 0 6px;
  font-size: 15px;
  color: var(--ink);
}

.alipay-qr-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-top: 12px;
}

.alipay-qr-box img {
  width: 200px;
  height: 200px;
  object-fit: contain;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #fff;
  padding: 6px;
}

.alipay-qr-box .auth-feedback {
  text-align: center;
}

.auth-modal h2 {
  margin: 0 0 8px;
  font-size: 20px;
}

.auth-modal p {
  margin: 0 0 14px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
}

.auth-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
  font-size: 20px;
}

.auth-field {
  display: grid;
  gap: 6px;
  margin: 14px 0 10px;
  color: var(--ink-soft);
  font-size: 12px;
}

.auth-field input {
  width: 100%;
  height: 42px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--ink);
  background: #fff;
  font-size: 15px;
  outline: none;
}

.auth-field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(15, 118, 110, 0.16);
}

.auth-tip {
  padding: 9px 10px;
  border-radius: 4px;
  color: #805900 !important;
  background: var(--warning-bg);
}

.auth-feedback {
  min-height: 18px;
  margin: 8px 0 12px !important;
  color: var(--brand-dark) !important;
}

.auth-feedback.error {
  color: var(--danger) !important;
}

.auth-primary-button {
  width: 100%;
  min-height: 42px;
}

.post-export-modal {
  width: min(520px, calc(100vw - 32px));
  text-align: center;
}

.post-export-modal h2 {
  margin-right: 24px;
  color: #0f766e;
  font-size: 24px;
}

.post-export-subtitle {
  margin-bottom: 18px !important;
  color: #42514d !important;
  font-size: 15px !important;
}

.post-export-actions {
  display: grid;
  gap: 12px;
}

.post-export-primary {
  width: 100%;
  min-height: 52px;
  padding: 12px 16px;
  border: 1px solid rgba(15, 118, 110, 0.72);
  border-radius: 6px;
  color: #f7fbf8;
  background: linear-gradient(135deg, #0f766e, #159447);
  box-shadow: 0 12px 24px rgba(15, 118, 110, 0.18);
  font-size: 15px;
  font-weight: 900;
  line-height: 1.35;
  white-space: normal;
}

.post-export-primary:hover {
  filter: brightness(1.04);
  transform: translateY(-1px);
}

.post-export-link {
  justify-self: center;
  min-height: 34px;
  padding: 4px 6px;
  border: 0;
  color: #66736f;
  background: transparent;
  font-size: 13px;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 4px;
  white-space: normal;
}

.post-export-link:hover {
  color: var(--brand);
}

.service-entry {
  min-height: 32px;
  padding: 0 12px;
  border: 1px solid rgba(201, 151, 74, 0.58);
  border-radius: 4px;
  color: #f2c97f;
  background: rgba(201, 151, 74, 0.1);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
}

.service-entry:hover {
  color: #07110f;
  background: var(--accent);
  border-color: var(--accent);
}

.service-qr {
  display: flex;
  justify-content: center;
  margin: 14px 0 6px;
}

.service-qr img {
  width: 200px;
  height: 200px;
  object-fit: contain;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: #fff;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 28px;
  background: rgba(4, 11, 10, 0.62);
  backdrop-filter: blur(10px);
}

.modal-overlay.hidden {
  display: none;
}

.library-modal {
  width: min(860px, 100%);
  max-height: min(720px, calc(100vh - 56px));
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border: 1px solid rgba(201, 151, 74, 0.28);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 26px 70px rgba(0, 0, 0, 0.36);
}

.library-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 18px 14px;
  color: var(--ink-on-dark);
  background: linear-gradient(90deg, #07110f, #13221e);
  border-bottom: 1px solid var(--line-dark);
}

.library-header h2 {
  margin: 0 0 4px;
  font-size: 19px;
}

.library-header p {
  margin: 0;
  color: var(--muted-on-dark);
  font-size: 13px;
  line-height: 1.5;
}

.library-header .icon-button {
  flex: 0 0 auto;
}

.library-meta {
  padding: 10px 18px;
  color: var(--ink-soft);
  background: #f4f7f5;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  font-weight: 700;
}

.project-library-list {
  min-height: 0;
  overflow: auto;
  padding: 12px;
}

.library-empty {
  padding: 28px 12px;
  border: 1px dashed var(--line);
  border-radius: 6px;
  color: var(--ink-soft);
  background: #fff;
  text-align: center;
  font-size: 13px;
}

.library-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 14px;
  align-items: center;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.library-item + .library-item {
  margin-top: 8px;
}

.library-item.active {
  border-color: var(--brand);
  box-shadow: 0 0 0 2px rgba(15, 118, 110, 0.14);
}

.library-item-main {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.library-item-main strong,
.library-item-main span,
.library-item-main small {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.library-item-main strong {
  color: var(--ink);
  font-size: 14px;
}

.library-item-main span {
  color: var(--ink-soft);
  font-size: 12px;
}

.library-item-main small {
  color: #7b8783;
  font-size: 11px;
}

.library-item-actions {
  display: flex;
  align-items: center;
  gap: 7px;
}

.library-item-actions button {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

@media (max-width: 1180px) {
  .workspace {
    grid-template-columns: 350px minmax(0, 1fr);
  }
}

@media (max-width: 900px) {
  .app-shell {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .workspace {
    display: block;
    overflow: visible;
  }

  .control-rail {
    max-height: none;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .stage {
    min-height: 760px;
    height: auto;
    overflow: visible;
  }

  .status-strip {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .topbar,
  .canvas-toolbar,
  .inspection-panel {
    align-items: stretch;
    flex-direction: column;
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .top-actions,
  .view-controls,
  .preview-toggles,
  .zoom-controls {
    justify-content: space-between;
    flex-wrap: wrap;
  }

  .field-grid,
  .button-grid,
  .tool-segment {
    grid-template-columns: 1fr;
  }

  .status-strip {
    grid-template-columns: 1fr;
  }

  .dimension-overlay {
    right: auto;
    left: 10px;
    bottom: 44px;
    grid-template-columns: 1fr;
  }

  .single-preview {
    min-height: 430px;
  }

  .modal-overlay {
    padding: 12px;
  }

  .library-item {
    grid-template-columns: 1fr;
  }

  .library-item-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
