:root {
  --page: #eef1f4;
  --panel: #ffffff;
  --panel-soft: #f7f9fa;
  --ink: #172027;
  --muted: #66727c;
  --line: #d7dde3;
  --line-strong: #aeb8c1;
  --rail: #111820;
  --rail-2: #18232e;
  --cut: #d63f3f;
  --crease: #2368d8;
  --mark: #222222;
  --accent: #0d6f80;
  --accent-dark: #084a56;
  --accent-warm: #b37a2d;
  --shadow: 0 18px 46px rgba(18, 26, 34, 0.12);
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: var(--page);
  color: var(--ink);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  letter-spacing: 0;
}

button,
input,
select {
  font: inherit;
}

button {
  min-height: 34px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 0 12px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  background: #ffffff;
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.16s ease, background 0.16s ease, color 0.16s ease, box-shadow 0.16s ease;
}

button:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  background: #fbfcfc;
}

button:active {
  transform: translateY(1px);
}

button svg {
  width: 17px;
  height: 17px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Home */
.home-screen {
  height: 100%;
  display: grid;
  grid-template-columns: minmax(280px, 340px) minmax(0, 1fr);
  background: var(--page);
}

.home-rail {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 28px;
  padding: 30px;
  color: #e8edf1;
  background: linear-gradient(180deg, var(--rail), var(--rail-2));
  border-right: 1px solid #0b1117;
}

.home-brand {
  min-width: 0;
  display: grid;
  grid-template-columns: 46px minmax(0, 1fr);
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 46px;
  height: 46px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 255, 255, 0.22);
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
  font-size: 15px;
  font-weight: 700;
}

.home-brand h1,
.brand h1 {
  margin: 0;
  font-size: 18px;
  line-height: 1.2;
  font-weight: 700;
}

.home-brand p,
.brand p {
  margin: 5px 0 0;
  color: var(--muted);
  font-size: 12px;
}

.home-brand p {
  color: #8f9ca7;
}

.home-intro {
  align-self: center;
  display: grid;
  gap: 12px;
}

.home-intro span {
  width: 42px;
  height: 28px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(179, 122, 45, 0.7);
  color: #f2c985;
  font-size: 12px;
  font-weight: 700;
}

.home-intro h2 {
  margin: 0;
  font-size: 30px;
  line-height: 1.18;
  letter-spacing: 0;
}

.home-intro p {
  max-width: 250px;
  margin: 0;
  color: #aab5bd;
  font-size: 13px;
  line-height: 1.75;
}

.home-flow {
  margin: 0;
  padding: 18px 0 0;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  list-style: none;
}

.home-flow li {
  color: #9aa6af;
  font-size: 12px;
  text-align: center;
}

.home-flow li::before {
  content: "";
  display: block;
  width: 100%;
  height: 2px;
  margin-bottom: 8px;
  background: rgba(255, 255, 255, 0.18);
}

.home-flow li:first-child::before {
  background: var(--accent-warm);
}

.home-main {
  min-width: 0;
  min-height: 0;
  overflow: auto;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
}

.home-header {
  min-width: 0;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  padding: 28px 34px 22px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.home-header span {
  color: var(--accent-warm);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.home-header h2 {
  margin: 4px 0 0;
  font-size: 24px;
  line-height: 1.2;
}

.home-header p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.home-box-grid {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 32px 34px 48px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  align-content: start;
  gap: 16px;
}

.home-box-card {
  min-width: 0;
  min-height: 228px;
  padding: 16px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 14px;
  border: 1px solid var(--line);
  border-left: 4px solid transparent;
  border-radius: 2px;
  background: #ffffff;
  box-shadow: none;
}

.home-box-card:hover {
  border-color: #b8c1c9;
  border-left-color: var(--accent-warm);
  color: var(--accent-dark);
  box-shadow: 0 16px 34px rgba(18, 26, 34, 0.08);
}

.home-box-card .type-card-art {
  width: 100%;
  max-width: none;
  height: 154px;
}

.home-box-card-title {
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}

.home-box-card-title strong {
  min-width: 0;
  font-size: 17px;
  line-height: 1.25;
}

.home-box-card-title span {
  flex: 0 0 auto;
  color: var(--muted);
  font-size: 12px;
}

.home-subtype-overlay {
  position: fixed;
  inset: 0;
  z-index: 10;
  padding: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(11, 16, 21, 0.52);
}

.home-subtype-dialog {
  width: min(1080px, 100%);
  max-height: min(780px, calc(100vh - 60px));
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  border: 1px solid #2a3742;
  border-radius: 2px;
  overflow: hidden;
  background: #ffffff;
  box-shadow: 0 30px 90px rgba(10, 15, 20, 0.34);
}

.home-subtype-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--line);
  background: #f7f9fa;
}

.home-subtype-header span {
  color: var(--accent-warm);
  font-size: 12px;
  font-weight: 700;
}

.home-subtype-header h2 {
  margin: 4px 0 0;
  font-size: 20px;
  line-height: 1.2;
}

.home-subtype-grid {
  min-height: 0;
  overflow: auto;
  padding: 18px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  align-content: start;
  gap: 14px;
}

.home-subtype-card {
  min-width: 0;
  min-height: 176px;
  padding: 12px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #ffffff;
}

.home-subtype-card:hover {
  border-color: var(--accent);
  color: var(--accent-dark);
  box-shadow: 0 10px 24px rgba(18, 26, 34, 0.08);
}

.home-subtype-card .type-card-art {
  width: 100%;
  max-width: none;
  height: 112px;
}

.home-subtype-card strong {
  min-width: 0;
  color: var(--ink);
  font-size: 15px;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
}

/* Editor */
.app-shell {
  height: 100%;
  display: grid;
  grid-template-columns: 360px minmax(0, 1fr);
  background: var(--page);
}

.sidebar {
  min-width: 0;
  height: 100%;
  overflow: auto;
  background: #f7f9fa;
  border-right: 1px solid var(--line);
}

.brand {
  position: sticky;
  top: 0;
  z-index: 2;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px;
  color: #ffffff;
  background: var(--rail);
  border-bottom: 1px solid #0b1117;
}

.brand p {
  color: #94a2ad;
}

.icon-button {
  width: 34px;
  padding: 0;
  flex: 0 0 auto;
}

.brand .icon-button {
  border-color: rgba(255, 255, 255, 0.24);
  color: #dce5ea;
  background: rgba(255, 255, 255, 0.06);
}

.control-stack {
  display: grid;
  gap: 10px;
  padding: 12px;
}

.workflow-panel {
  gap: 9px;
  background: #f8fafb;
}

.workflow-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.mode-switch {
  display: grid;
  grid-template-columns: 1fr 1fr;
  width: 116px;
  border: 1px solid var(--line-strong);
  border-radius: 3px;
  overflow: hidden;
  background: #ffffff;
}

.mode-switch button {
  min-height: 28px;
  padding: 0 8px;
  border: 0;
  border-radius: 0;
  color: var(--muted);
  background: transparent;
  font-size: 12px;
}

.mode-switch button + button {
  border-left: 1px solid var(--line-strong);
}

.mode-switch button.is-active {
  color: #ffffff;
  background: var(--accent-dark);
}

.workflow-actions {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.35fr) 34px;
  gap: 6px;
}

.workflow-actions button {
  min-width: 0;
  min-height: 31px;
  padding: 0 8px;
  font-size: 12px;
  white-space: nowrap;
}

.workflow-actions.project-actions {
  grid-template-columns: 1fr 1fr;
}

.editor-mode-basic .advanced-only,
.editor-mode-basic .advanced-panel {
  display: none;
}

.quality-panel {
  gap: 8px;
}

.quality-panel .panel-summary {
  justify-content: flex-start;
}

.quality-panel .panel-summary::after {
  margin-left: auto;
}

.quality-badge {
  min-height: 22px;
  display: inline-flex;
  align-items: center;
  padding: 0 7px;
  border: 1px solid #b7d5c1;
  border-radius: 2px;
  color: #24633b;
  background: #eef8f1;
  font-size: 11px;
  font-weight: 700;
}

.quality-panel[data-level="warning"] .quality-badge {
  border-color: #e2c58f;
  color: #79520e;
  background: #fff8e8;
}

.quality-panel[data-level="error"] .quality-badge {
  border-color: #e2aaaa;
  color: #912f2f;
  background: #fff1f1;
}

.quality-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  list-style: none;
}

.quality-item {
  position: relative;
  padding-left: 13px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.quality-item::before {
  content: "";
  width: 5px;
  height: 5px;
  position: absolute;
  left: 0;
  top: 6px;
  background: #5d9a70;
}

.quality-item.is-warning::before {
  background: #bd8121;
}

.quality-item.is-error::before {
  background: #c43d3d;
}

.panel {
  display: grid;
  gap: 10px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #ffffff;
  box-shadow: none;
}

.panel-title {
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.panel-subtitle {
  margin-top: 4px;
  padding-top: 8px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.type-panel {
  gap: 11px;
}

.style-tabs {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.style-tab {
  width: 100%;
  min-width: 0;
  min-height: 32px;
  padding: 0 6px;
  border-color: var(--line);
  border-radius: 2px;
  color: var(--muted);
  background: #ffffff;
  font-size: 13px;
}

.style-tab:hover {
  background: #f5f8f9;
}

.style-tab.is-active {
  color: #ffffff;
  border-color: var(--accent);
  background: var(--accent);
  font-weight: 700;
}

.picker-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.current-preview {
  min-height: 92px;
  padding: 8px;
  display: grid;
  grid-template-columns: 118px minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 2px;
  background: #f7f9fa;
}

.active-preview-art {
  min-width: 0;
  height: 74px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #ffffff;
}

.active-preview-art .type-card-art {
  width: 100%;
  max-width: none;
  height: 68px;
}

.preview-meta {
  min-width: 0;
  display: grid;
  gap: 4px;
}

.preview-meta strong {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.preview-meta span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.type-card-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.type-card {
  width: 100%;
  min-width: 0;
  min-height: 104px;
  padding: 8px 7px 7px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  align-items: center;
  justify-items: center;
  gap: 5px;
  border-color: var(--line);
  background: #ffffff;
}

.type-card:hover,
.type-card.is-active {
  border-color: var(--accent);
  background: #f7fbfc;
}

.type-card-grid.compact .type-card {
  min-height: 86px;
}

.type-card-art {
  width: 100%;
  max-width: 122px;
  height: 58px;
  display: block;
}

.type-card-grid.compact .type-card-art {
  height: 43px;
}

.type-card-name {
  width: 100%;
  color: var(--accent-dark);
  font-size: 12px;
  line-height: 1.25;
  text-align: center;
  overflow-wrap: anywhere;
}

.mini-cut,
.mini-crease,
.mini-mark,
.thumb-cut,
.thumb-crease,
.thumb-mark {
  fill: none;
  stroke-linecap: butt;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
}

.mini-cut,
.thumb-cut {
  stroke: var(--cut);
  stroke-width: 1.2;
}

.mini-crease,
.thumb-crease {
  stroke: var(--crease);
  stroke-width: 1;
  stroke-dasharray: 4 2;
}

.mini-mark,
.thumb-mark {
  stroke: #24a148;
  stroke-width: 0.9;
}

.native-pickers {
  display: none;
}

details.panel {
  align-content: start;
}

.panel-summary {
  min-height: 30px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
}

.panel-summary::-webkit-details-marker {
  display: none;
}

.panel-summary::after {
  content: "+";
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  color: var(--muted);
  background: #ffffff;
}

details[open] > .panel-summary::after {
  content: "-";
}

.compact-panel > .panel-title {
  display: none;
}

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

.option-panel .panel-title {
  grid-column: 1 / -1;
}

.grid-2 {
  grid-template-columns: 1fr 1fr;
}

.wide {
  grid-column: 1 / -1;
}

label {
  min-width: 0;
  display: grid;
  gap: 5px;
}

label span {
  color: var(--muted);
  font-size: 12px;
}

input,
select {
  width: 100%;
  min-width: 0;
  height: 34px;
  padding: 0 9px;
  border: 1px solid var(--line-strong);
  border-radius: 2px;
  background: #ffffff;
  color: var(--ink);
}

input:focus,
select:focus,
button:focus-visible {
  outline: 2px solid rgba(13, 111, 128, 0.18);
  outline-offset: 1px;
}

.check-row {
  display: flex;
  align-items: center;
  gap: 9px;
  min-height: 26px;
}

.check-row input {
  width: 16px;
  height: 16px;
  min-width: 16px;
  accent-color: var(--accent);
}

.check-row span {
  font-size: 13px;
  color: var(--ink);
}

.workspace {
  min-width: 0;
  height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
}

.toolbar {
  height: 62px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: #ffffff;
}

.status {
  min-width: 0;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 2px 10px;
}

.status strong {
  font-size: 16px;
}

.status span {
  grid-column: 2;
  color: var(--muted);
  font-size: 12px;
}

.home-return {
  grid-row: 1 / span 2;
  min-height: 30px;
  padding: 0 10px;
  color: var(--accent-dark);
}

.actions,
.view-tools {
  display: flex;
  align-items: center;
  gap: 8px;
}

html.is-cep-plugin #exportSvgBtn,
html.is-cep-plugin #exportPdfBtn,
body.is-cep-plugin #exportSvgBtn,
body.is-cep-plugin #exportPdfBtn {
  display: none !important;
}

html.is-web-browser #generateBtn,
body.is-web-browser #generateBtn,
html.is-web-browser #updateCurrentBtn,
body.is-web-browser #updateCurrentBtn,
html.is-web-browser #restoreCurrentBtn,
body.is-web-browser #restoreCurrentBtn {
  display: none !important;
}

.view-tools {
  margin-left: auto;
  white-space: nowrap;
}

.view-tools button {
  min-height: 30px;
  padding: 0 9px;
}

.view-tools .icon-button {
  width: 30px;
  font-size: 18px;
  line-height: 1;
}

#zoomLevel {
  min-width: 52px;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.primary-button {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.primary-button:hover {
  color: #ffffff;
  background: var(--accent-dark);
  border-color: var(--accent-dark);
}

.canvas-band {
  min-height: 0;
  overflow: hidden;
  padding: 14px;
  background: #e8edf1;
}

.svg-frame {
  height: 100%;
  min-height: 240px;
  overflow: auto;
  position: relative;
  border: 1px solid var(--line);
  border-radius: 2px;
  background:
    linear-gradient(#e8ecef 1px, transparent 1px),
    linear-gradient(90deg, #e8ecef 1px, transparent 1px),
    #ffffff;
  background-size: 20px 20px;
  box-shadow: 0 14px 34px rgba(18, 26, 34, 0.09);
}

.svg-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

#dielineSvg {
  display: block;
  flex: 0 0 auto;
  max-width: none;
  max-height: none;
}

.legend {
  min-height: 42px;
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 8px 16px;
  color: var(--muted);
  font-size: 12px;
  background: #ffffff;
  border-top: 1px solid var(--line);
  white-space: nowrap;
  overflow: hidden;
}

.legend span {
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.legend span:last-child {
  margin-left: auto;
  overflow: hidden;
  text-overflow: ellipsis;
}

.legend i {
  width: 22px;
  height: 0;
  border-top: 2px solid currentColor;
}

.legend .cut {
  color: var(--cut);
}

.legend .crease {
  color: var(--crease);
  border-top-style: dashed;
}

.legend .mark {
  color: var(--mark);
}

@media (max-width: 900px) {
  body {
    overflow: auto;
  }

  .home-screen,
  .app-shell {
    min-height: 100%;
    grid-template-columns: 1fr;
  }

  .home-rail {
    min-height: auto;
    gap: 18px;
    padding: 22px;
  }

  .home-intro {
    align-self: start;
  }

  .home-intro h2 {
    font-size: 24px;
  }

  .home-header {
    align-items: flex-start;
    flex-direction: column;
    padding: 20px;
  }

  .home-box-grid {
    grid-template-columns: 1fr;
    padding: 20px;
  }

  .home-subtype-overlay {
    padding: 12px;
    align-items: stretch;
  }

  .home-subtype-dialog {
    max-height: calc(100vh - 24px);
  }

  .home-subtype-grid {
    grid-template-columns: 1fr;
    padding: 12px;
  }

  .sidebar {
    height: auto;
    border-right: 0;
    border-bottom: 1px solid var(--line);
  }

  .workspace {
    min-height: 72vh;
  }

  .toolbar {
    height: auto;
    align-items: stretch;
    flex-direction: column;
  }

  .actions,
  .view-tools {
    flex-wrap: wrap;
  }

  .view-tools {
    margin-left: 0;
  }

  .actions button {
    flex: 1 1 92px;
  }

  .grid-2 {
    grid-template-columns: 1fr;
  }
}
