:root {
  --bg: #ffffff;
  --panel: #ffffff;
  --muted: #6b7280; /* gray-500 */
  --text: #111827;  /* gray-900 */
  --accent: #2563eb; /* blue-600 */
  --accent-2: #1d4ed8; /* blue-700 */
  --border: #e5e7eb; /* gray-200 */
  --danger: #ef4444;
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  background: var(--bg);
  color: var(--text);
}

.app-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(0,0,0,0.02), transparent);
}
.app-header h1 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
}

.container {
  display: grid;
  grid-template-columns: 380px 1fr;
  gap: 20px;
  padding: 20px;
}

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

.controls {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
}

.field { margin-bottom: 14px; }
.field.small { width: 100%; }
.row { display: grid; grid-template-columns: 1fr 1fr auto; gap: 10px; }
.actions { margin-top: 6px; grid-template-columns: auto 1fr; align-items: center; }

label { display: block; font-size: 13px; margin-bottom: 6px; color: var(--muted); }
textarea, input[type="number"], input[type="text"] {
  width: 100%;
  color: var(--text);
  background: #ffffff;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 12px;
}
textarea { height: 140px; resize: vertical; }

button {
  appearance: none;
  border: 1px solid var(--border);
  background: #ffffff;
  color: var(--text);
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  text-decoration: none;
  text-align: center;
}

button.primary {
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-color: transparent;
  color: #ffffff;
}

button:disabled { opacity: 0.6; cursor: not-allowed; }

.note {
  margin-top: 8px;
  border: 1px dashed var(--border);
  border-radius: 8px;
  padding: 8px 12px;
}
.note summary { cursor: pointer; color: var(--muted); }
.note ul { margin: 8px 0 0; padding-left: 16px; }
.note li { margin: 6px 0; color: var(--muted); }

.preview-section {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px;
  min-height: 300px;
}

.preview-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; }
.muted { color: var(--muted); font-size: 12px; margin-left: 8px; }

.preview-wrap {
  position: relative;
  border: none;
  border-radius: 8px;
  background: #ffffff;
  padding: 8px;
  overflow: auto;
  min-height: 180px;
}

.preview-wrap.grid-bg {
  background-image: linear-gradient(#e5e7eb 1px, transparent 1px), linear-gradient(90deg, #e5e7eb 1px, transparent 1px);
  background-size: 16px 16px, 16px 16px;
}

.iframe-shell {
  background: #ffffff;
  border-radius: 4px;
  overflow: hidden;
  outline: none;
}

.iframe-shell .info-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  background: #f8fafc; /* light header */
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-size: 12px;
}

.iframe-shell iframe { display: block; border: 0; }

.warn { color: var(--danger); font-size: 12px; margin-left: 8px; }

@media print {
  body { background: #fff; color: #000; }
  .app-header, .controls { display: none; }
  .preview-section { border: none; padding: 0; }
  .preview-wrap { border: none; padding: 0; }
}
