* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0d0d0d;
  --panel: #16181c;
  --border: #2f3336;
  --text: #e7e9ea;
  --muted: #71767b;
  --accent: #1d9bf0;
  --input-bg: #000;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.app {
  display: grid;
  grid-template-columns: 400px 1fr;
  min-height: 100vh;
}

/* ---------- Editor (left) ---------- */
.editor {
  padding: 28px 24px 40px;
  background: var(--panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  max-height: 100vh;
}

.editor header { margin-bottom: 22px; }
.editor h1 { font-size: 22px; font-weight: 800; letter-spacing: -0.01em; }
.subtitle { color: var(--muted); font-size: 12px; margin-top: 4px; }

.field { margin-bottom: 18px; }
.field > label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-bottom: 6px;
}
.field.checkbox > label {
  display: flex;
  align-items: center;
  gap: 10px;
  text-transform: none;
  font-size: 14px;
  font-weight: 500;
  color: var(--text);
  letter-spacing: 0;
  cursor: pointer;
}
.field.checkbox input { width: 16px; height: 16px; accent-color: var(--accent); }

.field input[type="text"],
.field textarea,
.field input[type="file"] {
  width: 100%;
  padding: 11px 12px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  font: inherit;
  font-size: 14px;
  transition: border-color 0.15s;
}
.field input[type="file"] { padding: 8px; font-size: 13px; cursor: pointer; }
.field textarea { resize: vertical; min-height: 120px; line-height: 1.4; }
.field input:focus, .field textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.hint { margin-top: 6px; font-size: 11px; color: var(--muted); }
.hint code { background: var(--input-bg); border: 1px solid var(--border); padding: 1px 5px; border-radius: 4px; font-size: 10px; }

.text-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}
.text-toolbar button {
  width: 32px; height: 32px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
  font-size: 14px;
  display: inline-flex; align-items: center; justify-content: center;
  transition: all 0.12s;
}
.text-toolbar button:hover { border-color: var(--accent); color: var(--accent); }
.text-toolbar button:active { transform: scale(0.95); }
.toolbar-hint { font-size: 11px; color: var(--muted); }
.toolbar-hint kbd {
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 3px;
  padding: 1px 5px;
  font-size: 10px;
  font-family: inherit;
}

.theme-toggle {
  display: flex;
  gap: 6px;
  padding: 4px;
  background: var(--input-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
}
.theme-toggle button {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: none;
  color: var(--muted);
  border-radius: 7px;
  cursor: pointer;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  transition: all 0.15s;
}
.theme-toggle button:hover { color: var(--text); }
.theme-toggle button.active {
  background: var(--accent);
  color: #fff;
}

button.primary {
  width: 100%;
  padding: 14px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-size: 15px;
  font-weight: 700;
  margin-top: 4px;
  transition: background 0.15s, transform 0.05s;
}
button.primary:hover { background: #1a8cd8; }
button.primary:active { transform: scale(0.99); }

.footnote {
  margin-top: 12px;
  text-align: center;
  font-size: 11px;
  color: var(--muted);
}

/* ---------- Preview (right) ---------- */
.preview-area {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(circle at 30% 20%, rgba(29, 155, 240, 0.06), transparent 50%),
    var(--bg);
}

.canvas-wrap {
  max-width: 100%;
  max-height: calc(100vh - 48px);
  aspect-ratio: 4 / 5;
}

#canvas {
  display: block;
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: calc(100vh - 48px);
  border-radius: 16px;
  box-shadow:
    0 12px 48px rgba(0, 0, 0, 0.6),
    0 2px 6px rgba(0, 0, 0, 0.3);
}

/* ---------- Responsive ---------- */
@media (max-width: 900px) {
  .app { grid-template-columns: 1fr; }
  .editor {
    max-height: none;
    border-right: none;
    border-bottom: 1px solid var(--border);
    order: 2;
  }
  .preview-area {
    order: 1;
    padding: 16px;
  }
  #canvas { max-height: 70vh; }
}
