:root {
  --bg: #0b1020;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-border: rgba(148, 163, 184, 0.25);
  --surface: #ffffff;
  --text: #111827;
  --muted: #64748b;
  --line: #e2e8f0;
  --primary: #e43027;
  --primary-dark: #c5251d;
  --shadow: 0 12px 30px rgba(15, 23, 42, 0.1);
  --radius-xl: 28px;
  --radius-lg: 20px;
  --radius-md: 14px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', Arial, sans-serif;
  color: var(--text);
}

button,
input,
textarea {
  font: inherit;
}

.page-shell {
  width: min(1600px, calc(100% - 40px));
  margin: 24px auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  align-items: flex-start;
  margin-bottom: 24px;
  padding: 28px 32px;
}

.eyebrow {
  margin: 0 0 10px;
  color: rgba(255, 255, 255, 0.7);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.topbar h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.04;
    color: black;
}

.lead {
  margin: 12px 0 0;
  max-width: 760px;
  color: rgba(255, 255, 255, 0.72);
  font-size: 15px;
  line-height: 1.65;
}

.topbar-badge {
  white-space: nowrap;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: rgba(255, 255, 255, 0.88);
  font-size: 13px;
  font-weight: 600;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(580px, 1fr);
  gap: 24px;
}

.layout-full {
  grid-column: 1 / -1;
}

.panel {
  min-width: 0;
  border-radius: var(--radius-xl);
  border: 1px solid var(--panel-border);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.instruction-card.layout-full {
    box-shadow: var(--shadow);
}

.panel-form {
  padding: 28px;
}

.panel-preview {
  padding: 28px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: flex-start;
  margin-bottom: 22px;
}

.panel-header h2,
.code-header h3,
.section-title h3 {
  margin: 0;
  font-size: 20px;
}

.panel-header p,
.code-header p,
.section-title p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.55;
}

.panel-header-stacked {
  flex-direction: column;
}

.status-badge {
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(16, 185, 129, 0.12);
  color: #047857;
  font-size: 13px;
  font-weight: 700;
}

.status-badge.is-working {
  background: rgba(59, 130, 246, 0.12);
  color: #1d4ed8;
}

.status-badge.is-error {
  background: rgba(239, 68, 68, 0.12);
  color: #b91c1c;
}

.editor-form {
  display: flex;
  flex-direction: column;
  gap: 22px;
}

.form-section {
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: rgba(255, 255, 255, 0.72);
}

.section-title {
  margin-bottom: 18px;
}

.field-grid {
  display: grid;
  gap: 14px;
}

.panel-form .field-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.two-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.three-columns {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.field {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.field > span {
  font-size: 13px;
  font-weight: 700;
  color: #334155;
}

.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: white;
  padding: 13px 14px;
  color: var(--text);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.field textarea {
  min-height: 120px;
  resize: vertical;
}

.field input:focus,
.field textarea:focus {
  outline: none;
  border-color: rgba(228, 48, 39, 0.6);
  box-shadow: 0 0 0 4px rgba(228, 48, 39, 0.12);
}

.file-field input {
  padding: 11px 12px;
}

.upload-hints {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 14px;
}

.upload-pill {
  padding: 10px 12px;
  border-radius: 999px;
  background: #f8fafc;
  color: #475569;
  font-size: 12px;
  border: 1px solid #e2e8f0;
}

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

.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  padding: 12px 16px;
  border-radius: 14px;
  font-weight: 700;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.18s ease;
}

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

.btn-primary {
  background: var(--primary);
  color: white;
  box-shadow: 0 12px 24px rgba(228, 48, 39, 0.2);
}

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

.btn-secondary {
  background: #111827;
  color: white;
}

.btn-ghost {
  background: #f8fafc;
  color: #0f172a;
  border: 1px solid #e2e8f0;
}

.preview-card,
.code-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: white;
  overflow: hidden;
}

.instruction-card {
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  background: white;
  padding: 20px;
}

.instruction-header {
  margin-bottom: 18px;
}

.instruction-header h2 {
  margin: 0;
  font-size: 20px;
}

.instruction-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.instruction-item {
  padding: 16px 18px;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  background: #f8fafc;
}

.instruction-item h3 {
  margin: 0 0 10px;
  font-size: 16px;
}

.instruction-item ol {
  margin: 0;
  padding-left: 20px;
  color: #334155;
  font-size: 14px;
  line-height: 1.65;
}

.instruction-item li + li {
  margin-top: 6px;
}

.preview-toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.preview-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: #cbd5e1;
}

.preview-toolbar p {
  margin: 0 0 0 6px;
  color: #475569;
  font-size: 13px;
  font-weight: 700;
}

#previewFrame {
  display: block;
  width: 100%;
  min-height: 550px;
  border: none;
  background: white;
}

.code-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: #f8fafc;
}

.code-copy {
  border: 1px solid #dbe2ea;
  border-radius: 12px;
  background: white;
  padding: 10px 12px;
  font-weight: 700;
  cursor: pointer;
}

.html-output {
  display: block;
  width: 100%;
  min-height: 300px;
  border: none;
  padding: 18px;
  resize: vertical;
  font-family: 'SFMono-Regular', ui-monospace, Menlo, Consolas, monospace;
  font-size: 12px;
  line-height: 1.6;
  color: #0f172a;
}

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

@media (max-width: 860px) {
  .page-shell {
    width: min(100% - 24px, 1600px);
    margin: 12px auto 24px;
  }

  .topbar,
  .panel-form,
  .panel-preview {
    padding: 20px;
  }

  .topbar {
    flex-direction: column;
  }

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

  .instruction-list {
    grid-template-columns: 1fr;
  }

  .actions {
    width: 100%;
  }

  .actions .btn {
    flex: 1 1 calc(50% - 10px);
  }

  #previewFrame {
    min-height: 620px;
  }
}
