@import url("https://fonts.googleapis.com/css2?family=Noto+Sans+SC:wght@400;600;700;800;900&display=swap");

:root {
  color-scheme: light;
  font-family: "Noto Sans SC", "Source Han Sans SC", sans-serif;
  --bg: #eef1f4;
  --text: #17202a;
  --muted: #66717f;
  --line: #d7dde4;
  --panel: #ffffff;
  --accent: #cf2e2e;
  --accent-dark: #961f1f;
  --shadow: 0 16px 42px rgba(32, 42, 54, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  height: 100vh;
  background: var(--bg);
  color: var(--text);
  overflow: hidden;
}

button,
input,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-shell {
  height: 100vh;
  padding: 14px;
  overflow: hidden;
}

.workspace {
  display: grid;
  grid-template-columns: 640px minmax(0, 1fr);
  gap: 14px;
  max-width: none;
  width: 100%;
  height: calc(100vh - 28px);
  margin: 0 auto;
  min-height: 0;
}

.panel,
.preview-zone {
  background: var(--panel);
  border: 1px solid rgba(23, 32, 42, 0.08);
  box-shadow: var(--shadow);
}

.panel {
  border-radius: 8px;
  padding: 16px;
  max-height: calc(100vh - 28px);
  overflow: auto;
  scrollbar-gutter: stable;
}

.preview-zone {
  border-radius: 8px;
  min-height: 0;
  height: calc(100vh - 28px);
  padding: 16px;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto auto;
  gap: 10px;
  overflow: hidden;
}

.brand-row,
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2 {
  margin: 0;
  letter-spacing: 0;
}

h1 {
  font-size: 26px;
  line-height: 1.15;
}

.version-tag {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  vertical-align: middle;
}

.product-note {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

h2 {
  font-size: 20px;
}

.icon-button {
  width: 42px;
  height: 42px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: #f7f9fb;
  color: var(--text);
  font-size: 22px;
}

.field {
  display: grid;
  gap: 6px;
  margin-top: 10px;
}

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

label {
  color: #2c3744;
  font-size: 14px;
  font-weight: 700;
}

input[type="text"],
input[type="date"],
input[type="file"],
input[type="color"],
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: var(--text);
  padding: 11px 12px;
  outline: none;
}

input[type="color"] {
  height: 44px;
  padding: 5px;
}

input[type="range"] {
  accent-color: var(--accent);
}

select {
  height: 44px;
}

textarea {
  resize: vertical;
  min-height: 70px;
  line-height: 1.45;
}

.textarea-wrap {
  position: relative;
}

.textarea-wrap textarea {
  padding-bottom: 28px;
}

.counter {
  position: absolute;
  right: 10px;
  bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  pointer-events: none;
}

.counter.over {
  color: var(--accent);
}

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(207, 46, 46, 0.12);
}

.two-col {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.control-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 88px 110px;
  gap: 8px;
  align-items: end;
}

.control-row .field {
  margin-top: 8px;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #f7f9fb;
}

.segmented.two {
  grid-template-columns: repeat(2, 1fr);
}

.segmented button {
  min-height: 40px;
  border: 0;
  border-right: 1px solid var(--line);
  background: transparent;
  color: #344050;
  font-size: 13px;
  font-weight: 700;
}

.segmented button:last-child {
  border-right: 0;
}

.segmented button.active {
  background: var(--text);
  color: #fff;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}

.template {
  min-height: 46px;
  display: flex;
  align-items: center;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcfd;
  color: #26313d;
  font-weight: 700;
}

.template.active {
  border-color: var(--accent);
  background: #fff5f5;
}

.swatch {
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

.red {
  background: #d92d20;
}

.gold {
  background: #c79024;
}

.cyan {
  background: #168aad;
}

.ink {
  background: #1e293b;
}

.switch-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0;
}

.switch-row label {
  display: flex;
  align-items: center;
  gap: 9px;
  color: #425061;
}

.primary-button {
  width: 100%;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.primary-button:hover {
  background: var(--accent-dark);
}

.secondary-button {
  width: 100%;
  min-height: 40px;
  margin-top: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f7f9fb;
  color: #2f3b49;
  font-weight: 800;
}

.secondary-button:hover {
  background: #eef2f6;
}

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

.zoom-control {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 210px;
}

.zoom-control input {
  width: 140px;
}

.canvas-wrap {
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 8px;
  background:
    linear-gradient(45deg, #dce2e8 25%, transparent 25%),
    linear-gradient(-45deg, #dce2e8 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #dce2e8 75%),
    linear-gradient(-45deg, transparent 75%, #dce2e8 75%);
  background-size: 28px 28px;
  background-position: 0 0, 0 14px, 14px -14px, -14px 0;
  padding: 14px;
  min-height: 0;
}

canvas {
  display: block;
  max-width: 100%;
  max-height: 100%;
  box-shadow: 0 18px 48px rgba(20, 28, 38, 0.26);
  cursor: grab;
  touch-action: none;
}

canvas.dragging {
  cursor: grabbing;
}

.canvas-hint {
  margin: -2px 0 0;
  color: var(--muted);
  font-size: 13px;
  text-align: center;
  line-height: 1.5;
}

.canvas-hint.ownership {
  margin-top: -8px;
  font-weight: 800;
  font-size: 12px;
}

@media (max-width: 980px) {
  body {
    height: auto;
    min-height: 100vh;
    overflow: auto;
  }

  .app-shell {
    height: auto;
    min-height: 100vh;
    padding: 12px;
    overflow: visible;
  }

  .workspace {
    grid-template-columns: 1fr;
    height: auto;
  }

  .preview-zone {
    height: 620px;
    min-height: 620px;
  }

  .panel {
    order: 2;
    max-height: none;
  }

  .preview-zone {
    order: 1;
  }
}

@media (max-width: 560px) {
  .panel,
  .preview-zone {
    padding: 16px;
  }

  .topbar,
  .brand-row {
    align-items: flex-start;
  }

  .topbar {
    flex-direction: column;
  }

  .two-col,
  .control-row,
  .template-grid {
    grid-template-columns: 1fr;
  }

  .segmented {
    grid-template-columns: repeat(3, 1fr);
  }

  .zoom-control {
    width: 100%;
    min-width: 0;
  }

  .zoom-control input {
    width: 100%;
  }
}
