:root {
  --page: #f3f5f7;
  --panel: #ffffff;
  --ink: #162033;
  --muted: #657083;
  --line: #dce2ea;
  --accent: #176bff;
  --accent-dark: #0d45b7;
  --danger: #a33848;
  --shadow: 0 18px 50px rgba(22, 32, 51, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  overflow: hidden;
  min-height: 100vh;
  color: var(--ink);
  background: var(--page);
  font-family: Inter, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}

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

.sidebar {
  height: 100vh;
  background: var(--panel);
  border-right: 1px solid var(--line);
  padding: 28px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.sidebar::-webkit-scrollbar {
  width: 10px;
}

.sidebar::-webkit-scrollbar-track {
  background: #eef2f6;
}

.sidebar::-webkit-scrollbar-thumb {
  border: 2px solid #eef2f6;
  border-radius: 999px;
  background: #b8c3d1;
}

.brand {
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.brand p,
.toolbar p {
  margin: 0 0 7px;
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

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

h1 {
  font-size: 27px;
  line-height: 1.18;
}

.section {
  padding: 22px 0;
  border-bottom: 1px solid var(--line);
}

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

.section-title span {
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e8f0ff;
  color: var(--accent-dark);
  font-size: 12px;
  font-weight: 800;
}

.section-title h2,
.toolbar h2 {
  font-size: 19px;
  line-height: 1.25;
}

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

.field span {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 7px;
  color: #344056;
  font-size: 13px;
  font-weight: 700;
}

.field em {
  color: var(--muted);
  font-style: normal;
  font-weight: 600;
}

.field-note {
  align-self: end;
  margin: 0 0 14px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

input,
textarea,
select,
button {
  font: inherit;
}

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

input[type="text"]:focus,
input[type="url"]:focus,
textarea:focus,
select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(23, 107, 255, 0.12);
}

textarea {
  resize: vertical;
  min-height: 82px;
}

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

input[type="color"] {
  width: 100%;
  height: 43px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 5px;
}

.dropzone {
  display: grid;
  gap: 5px;
  margin-bottom: 14px;
  padding: 18px;
  border: 1px dashed #aeb8c7;
  border-radius: 8px;
  background: #f8fafc;
  cursor: pointer;
}

.dropzone input {
  width: 100%;
}

.dropzone strong {
  font-size: 15px;
}

.dropzone small,
.status {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.dropzone.compact {
  padding: 14px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 88px minmax(0, 1fr);
  gap: 12px;
}

.color-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
}

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

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

.tune-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8fafc;
  padding: 12px;
}

.tune-card h3 {
  margin: 0 0 10px;
  color: #263348;
  font-size: 14px;
  line-height: 1.25;
}

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

.axis-grid .field {
  margin-bottom: 0;
}

.axis-grid .field span {
  margin-bottom: 4px;
  font-size: 12px;
}

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

button {
  min-height: 42px;
  border: 1px solid #c7d1df;
  border-radius: 8px;
  background: #fff;
  color: #263348;
  cursor: pointer;
  font-weight: 800;
}

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

button.muted {
  background: #f1f4f8;
  color: #516073;
}

.status {
  min-height: 18px;
  margin: 12px 0 0;
  color: var(--danger);
}

.workspace {
  min-width: 0;
  height: 100vh;
  overflow: hidden;
  padding: 28px;
}

.toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.size-switch {
  display: inline-flex;
  padding: 4px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #fff;
}

.size-switch button {
  min-width: 64px;
  min-height: 34px;
  border: 0;
  background: transparent;
}

.size-switch button.active {
  background: var(--ink);
  color: #fff;
}

.canvas-wrap {
  display: grid;
  place-items: center;
  height: calc(100vh - 120px);
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background:
    linear-gradient(45deg, #e7ebf0 25%, transparent 25%),
    linear-gradient(-45deg, #e7ebf0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #e7ebf0 75%),
    linear-gradient(-45deg, transparent 75%, #e7ebf0 75%);
  background-color: #f8fafc;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  padding: 24px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
  box-shadow: var(--shadow);
  cursor: grab;
  touch-action: none;
  user-select: none;
}

canvas.dragging {
  cursor: grabbing;
}

.canvas-stage {
  position: relative;
  width: min(100%, 720px);
}

.logo-gif-overlay,
.button-gif-overlay {
  position: absolute;
  display: none;
  transform: translate(-50%, -50%);
  pointer-events: none;
  z-index: 2;
}

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

  .app {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
  }

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

  .workspace {
    height: auto;
    overflow: visible;
    padding: 20px;
  }

  .canvas-wrap {
    min-height: auto;
  }
}

@media (max-width: 560px) {
  .sidebar,
  .workspace {
    padding: 16px;
  }

  .grid-2,
  .color-grid,
  .font-grid,
  .axis-grid,
  .button-row {
    grid-template-columns: 1fr;
  }

  .toolbar {
    align-items: flex-start;
    flex-direction: column;
  }
}
