:root {
  --accent: #ff6b35;
  --bg: #f7f8fa;
  --surface: #ffffff;
  --text: #1f2328;
  --muted: #68707a;
  --line: #e8ebef;
  --shadow: 0 24px 70px rgba(31, 35, 40, 0.1);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "PingFang SC", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(360px, 440px) minmax(420px, 1fr);
  gap: 24px;
  min-height: 100vh;
  padding: 24px;
}

.panel,
.preview-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.editor-panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  border-radius: 24px;
  padding: 26px;
  align-self: start;
  position: sticky;
  top: 24px;
  max-height: calc(100vh - 48px);
  overflow: auto;
}

.brand {
  display: flex;
  gap: 15px;
  align-items: flex-start;
}

.brand-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(135deg, var(--accent), #ff8a5f);
  color: #fff;
  box-shadow: 0 12px 26px rgba(255, 107, 53, 0.22);
  flex: 0 0 auto;
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand-kicker {
  display: inline-block;
  margin: 1px 0 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
}

h1 {
  margin: 0;
  font-size: 24px;
  line-height: 1.18;
  font-weight: 700;
}

p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.5;
}

.form-grid {
  display: grid;
  gap: 15px;
}

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

.two-col.compact {
  align-items: end;
}

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

label > span,
.crop-controls span,
.switch-row strong {
  color: #3a3f45;
  font-size: 12px;
  font-weight: 650;
}

input[type="text"],
textarea {
  width: 100%;
  border: 1px solid #dce1e7;
  border-radius: 10px;
  background: #fff;
  color: var(--text);
  outline: none;
  padding: 11px 12px;
  font-size: 14px;
  line-height: 1.45;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

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

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

input.is-invalid,
textarea.is-invalid {
  border-color: #e5484d;
  box-shadow: 0 0 0 4px rgba(229, 72, 77, 0.12);
}

input[type="color"] {
  width: 100%;
  height: 42px;
  border: 1px solid #dce1e7;
  border-radius: 10px;
  padding: 4px;
  background: #fff;
}

input[type="file"] {
  width: 100%;
  color: var(--muted);
  font-size: 12px;
}

em {
  color: #98a0aa;
  font-size: 11px;
  font-style: normal;
  justify-self: end;
  margin-top: -3px;
}

.crop-controls {
  display: grid;
  gap: 13px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: #fafbfc;
}

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

.switch-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff8f5;
}

.switch-row input {
  width: 18px;
  height: 18px;
  margin: 1px 0 0;
  accent-color: var(--accent);
  flex: 0 0 auto;
}

.switch-row span {
  display: grid;
  gap: 3px;
}

.switch-row small {
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.validation-message {
  display: none;
  margin: -8px 0 0;
  padding: 10px 12px;
  border: 1px solid rgba(229, 72, 77, 0.2);
  border-radius: 12px;
  background: rgba(229, 72, 77, 0.08);
  color: #b4232a;
  font-size: 12px;
  line-height: 1.5;
}

.validation-message.is-visible {
  display: block;
}

.actions {
  display: flex;
  gap: 10px;
  margin-top: auto;
}

button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 42px;
  border: 0;
  border-radius: 12px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 650;
  transition: transform 0.16s ease, box-shadow 0.16s ease, background 0.16s ease;
}

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

button:hover {
  transform: translateY(-1px);
}

.primary {
  flex: 1;
  background: var(--accent);
  color: #fff;
  box-shadow: 0 12px 28px rgba(255, 107, 53, 0.24);
}

.secondary {
  padding: 0 14px;
  background: #f2f4f7;
  color: #3e454d;
}

.preview-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  border-radius: 24px;
  min-width: 0;
  overflow: hidden;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--line);
  padding: 15px 18px;
}

.preview-toolbar span {
  display: block;
  color: var(--text);
  font-size: 14px;
  font-weight: 700;
}

.preview-toolbar strong {
  color: var(--muted);
  font-size: 11px;
  font-weight: 500;
}

.preview-toolbar button {
  width: 38px;
  min-height: 38px;
  border-radius: 10px;
  color: #4b535c;
  background: #f5f6f8;
}

.canvas-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 22px;
  background:
    linear-gradient(45deg, rgba(224, 228, 233, 0.55) 25%, transparent 25%),
    linear-gradient(-45deg, rgba(224, 228, 233, 0.55) 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, rgba(224, 228, 233, 0.55) 75%),
    linear-gradient(-45deg, transparent 75%, rgba(224, 228, 233, 0.55) 75%);
  background-color: #f1f3f5;
  background-position: 0 0, 0 10px, 10px -10px, -10px 0;
  background-size: 20px 20px;
}

canvas {
  width: min(48vw, 430px);
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 22px;
  box-shadow: 0 22px 70px rgba(23, 26, 31, 0.18);
  background: #fff;
}

@media (max-width: 980px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .editor-panel {
    position: static;
    max-height: none;
  }

  canvas {
    width: min(calc(100vw - 32px), 460px);
  }
}

@media (max-width: 560px) {
  .app-shell {
    padding: 8px;
    gap: 10px;
  }

  .editor-panel,
  .preview-panel {
    border-radius: 18px;
  }

  .editor-panel {
    padding: 18px;
  }

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

  .actions {
    flex-direction: column;
  }

  .canvas-stage {
    padding: 4px;
  }
}
