:root {
  --bg: #f5f7fb;
  --panel: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --line: #dbe3ee;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --secondary: #e5e7eb;
  --secondary-hover: #d1d5db;
  --shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  --radius: 14px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: Arial, Helvetica, sans-serif;
  color: var(--text);
  background: var(--bg);
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  background: #111827;
  color: #fff;
}

.brand {
  font-weight: 700;
  letter-spacing: 0.2px;
}

.help-btn {
  border: 0;
  background: #374151;
  color: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.help-btn:hover {
  background: #4b5563;
}

.container {
  width: 100%;
  max-width: 1400px;
  margin: 0 auto;
  padding: 20px;
  flex: 1;
}

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

.panel {
  min-width: 0;
}

.controls h1 {
  margin-top: 0;
  margin-bottom: 8px;
}

.controls p {
  margin-top: 0;
  color: var(--muted);
}

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  box-shadow: var(--shadow);
}

.form-row {
  margin-top: 14px;
}

.form-row label {
  display: block;
  margin-bottom: 8px;
  font-weight: 600;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 14px;
}

.color-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.color-row input[type="color"] {
  width: 56px;
  height: 40px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: white;
}

input[type="text"],
input[type="file"],
input[type="range"] {
  width: 100%;
}

input[type="text"],
input[type="file"] {
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 10px 12px;
  background: #fff;
}

input[type="checkbox"] {
  margin-right: 8px;
}

.value {
  color: var(--primary);
  font-weight: 700;
}

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

button,
a.primary,
a.secondary {
  appearance: none;
  border: 0;
  border-radius: 10px;
  padding: 10px 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease, transform 0.05s ease;
}

button:active,
a.primary:active,
a.secondary:active {
  transform: translateY(1px);
}

.primary {
  background: var(--primary);
  color: white;
}

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

.secondary {
  background: var(--secondary);
  color: var(--text);
}

.secondary:hover {
  background: var(--secondary-hover);
}

.disabled {
  opacity: 0.5;
  pointer-events: none;
}

.status {
  min-height: 20px;
  margin-top: 12px;
  color: var(--muted);
}

.preview {
  display: flex;
  flex-direction: column;
}

.preview-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  font-weight: 700;
}

.zoom {
  display: flex;
  gap: 8px;
}

.zoom button {
  background: white;
  border: 1px solid var(--line);
  color: var(--text);
  min-width: 52px;
}

.zoom button:hover {
  background: #f3f4f6;
}

.preview-wrap {
  flex: 1;
  min-height: 70vh;
  overflow: auto;
  background: white;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
}

.preview-canvas {
  transform-origin: top left;
  display: inline-block;
}

.preview-canvas svg {
  max-width: none;
  height: auto;
  display: block;
}

footer {
  padding: 16px 20px 24px;
  text-align: center;
  color: var(--muted);
}

footer a {
  color: var(--primary);
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 24, 39, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 1000;
}

.hidden {
  display: none;
}

.modal {
  position: relative;
  width: min(720px, 100%);
  background: white;
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow);
}

.modal h2 {
  margin-top: 0;
}

.modal code {
  background: #f3f4f6;
  padding: 2px 6px;
  border-radius: 6px;
}

.close {
  position: absolute;
  top: 10px;
  right: 12px;
  border: 0;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: #374151;
}

.close:hover {
  color: #111827;
}

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

  .preview-wrap {
    min-height: 50vh;
  }
}

@media (max-width: 640px) {
  .grid-2 {
    grid-template-columns: 1fr;
  }

  .actions {
    flex-direction: column;
  }

  .actions > * {
    width: 100%;
    text-align: center;
  }
}
