:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --surface-2: #f8fafc;
  --text: #171717;
  --muted: #6b7280;
  --line: #d7dce4;
  --accent: #0f766e;
  --accent-2: #7c2d12;
  --focus: #2563eb;
  --shadow: 0 14px 34px rgba(15, 23, 42, 0.11);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
}

button,
input,
select,
textarea {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-columns: var(--sidebar-width, 380px) 8px minmax(0, 1fr);
  height: 100vh;
  min-height: 100vh;
  min-width: 0;
  overflow: hidden;
}

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  height: 100vh;
  min-height: 0;
  padding: 20px;
  background: #111827;
  color: #f9fafb;
  border-right: 1px solid #0f172a;
  overflow-y: auto;
  overflow-x: hidden;
  overscroll-behavior: contain;
  min-width: 0;
}

.panel-resizer {
  position: relative;
  width: 8px;
  min-width: 8px;
  height: 100vh;
  min-height: 0;
  padding: 0;
  border: 0;
  border-left: 1px solid #0f172a;
  border-right: 1px solid #d7dce4;
  border-radius: 0;
  background: linear-gradient(180deg, #1f2937, #334155);
  cursor: col-resize;
  touch-action: none;
}

.panel-resizer::before {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 2px;
  height: 46px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.52);
  box-shadow: 0 0 0 1px rgba(15, 23, 42, 0.35);
  transform: translate(-50%, -50%);
}

.panel-resizer:hover,
.panel-resizer:focus-visible,
body.is-resizing-panels .panel-resizer {
  background: linear-gradient(180deg, #0f766e, #115e59);
}

.panel-resizer:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.38);
  outline-offset: -3px;
}

body.is-resizing-panels {
  cursor: col-resize;
  user-select: none;
}

.brand,
.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.brand h1,
.panel-head h2 {
  margin: 0;
  font-size: 22px;
  line-height: 1.15;
  letter-spacing: 0;
}

.panel-head h2 {
  color: #0f172a;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0;
}

.sidebar .eyebrow {
  color: #9ca3af;
}

.status-pill {
  min-width: 56px;
  padding: 5px 8px;
  border: 1px solid #334155;
  border-radius: 999px;
  color: #cbd5e1;
  background: #1f2937;
  font-size: 12px;
  text-align: center;
}

.status-pill.is-on {
  border-color: #14b8a6;
  color: #ccfbf1;
}

.control-panel {
  padding: 14px;
  border: 1px solid #263244;
  border-radius: 8px;
  background: #182233;
  min-width: 0;
}

.accordion-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  min-height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: #dbeafe;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  text-align: left;
}

.accordion-arrow {
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border: 1px solid #334155;
  border-radius: 50%;
  color: #cbd5e1;
  transition: transform 0.18s ease;
}

.control-panel.is-collapsed .accordion-arrow {
  transform: rotate(-90deg);
}

.accordion-content {
  display: grid;
  gap: 10px;
  padding-top: 12px;
  min-width: 0;
}

.control-panel.is-collapsed .accordion-content {
  display: none;
}

.accordion-content > .section-title {
  display: none;
}

.section-title {
  margin-bottom: 10px;
  color: #dbeafe;
  font-size: 13px;
  font-weight: 800;
}

.field,
.toggles label {
  display: grid;
  gap: 7px;
  color: #d1d5db;
  font-size: 12px;
  font-weight: 700;
}

.field-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}

.field + .field-row,
.field-row + .field-row,
.field-row + .field,
.field + .field {
  margin-top: 10px;
}

.multi-manual-panel {
  display: grid;
  gap: 10px;
  margin-top: 10px;
  min-width: 0;
}

.multi-manual-panel[hidden],
.multi-manual-group[hidden] {
  display: none;
}

.multi-manual-group {
  display: grid;
  gap: 8px;
  min-width: 0;
  padding: 10px;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #111827;
}

.manual-title {
  color: #dbeafe;
  font-size: 12px;
  font-weight: 800;
}

.manual-list {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.manual-row {
  display: grid;
  grid-template-columns: 56px minmax(0, 1fr);
  gap: 8px;
  align-items: end;
  min-width: 0;
}

.manual-row-wide {
  grid-template-columns: 56px minmax(0, 1fr) minmax(0, 1fr);
}

.manual-index {
  align-self: center;
  color: #93c5fd;
  font-size: 11px;
  font-weight: 900;
}

.manual-field {
  min-width: 0;
}

.field-hint {
  min-height: 18px;
  margin: 6px 0 0;
  color: #9ca3af;
  font-size: 12px;
  font-weight: 700;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid #334155;
  border-radius: 7px;
  background: #0f172a;
  color: #f9fafb;
  outline: none;
}

input,
select {
  min-height: 38px;
  padding: 8px 10px;
}

.sidebar-textarea {
  min-height: 150px;
  padding: 10px;
  resize: vertical;
  font-family: "Courier New", Courier, monospace;
  font-size: 12px;
  line-height: 1.45;
}

.preview-action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-width: 0;
  margin-top: 10px;
}

.preview-action-row .primary-button,
.preview-action-row .ghost-button {
  flex: 1 1 96px;
  min-height: 38px;
}

input[type="color"] {
  min-height: 40px;
  padding: 3px;
  cursor: pointer;
}

input[type="file"] {
  padding: 8px;
}

input:focus,
select:focus,
textarea:focus,
button:focus-visible {
  border-color: var(--focus);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.18);
}

.option-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 8px;
  min-width: 0;
}

.option-button,
.swatch-button,
.ghost-button,
.primary-button {
  min-height: 38px;
  border: 1px solid transparent;
  border-radius: 7px;
  cursor: pointer;
}

.option-button {
  padding: 8px 9px;
  background: #0f172a;
  color: #e5e7eb;
  text-align: left;
  font-size: 12px;
  font-weight: 800;
}

.option-button.is-selected,
.swatch-button.is-selected {
  border-color: #5eead4;
  box-shadow: 0 0 0 2px rgba(20, 184, 166, 0.22);
}

.swatch-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  min-width: 0;
}

.color-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  min-width: 0;
}

.color-field {
  grid-template-columns: 1fr 48px;
  align-items: center;
}

.color-field input {
  width: 48px;
}

.swatch-button {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  align-items: center;
  gap: 6px;
  min-width: 0;
  padding: 7px 6px;
  overflow: hidden;
  background: #0f172a;
  color: #e5e7eb;
  font-size: 10.5px;
  font-weight: 800;
  line-height: 1.15;
  text-align: left;
}

.swatch-dot {
  width: 16px;
  height: 16px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  border-radius: 50%;
  justify-self: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.28);
}

.swatch-dot.is-flag {
  width: 22px;
  height: 15px;
  border-radius: 3px;
  background-size: cover;
  background-position: center;
}

.swatch-button span:last-child {
  display: -webkit-box;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  overflow-wrap: anywhere;
  white-space: normal;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.toggles {
  display: grid;
  gap: 10px;
}

.toggles label {
  grid-template-columns: 18px 1fr;
  align-items: center;
}

.toggles input {
  width: 18px;
  min-height: 18px;
  accent-color: var(--accent);
}

.workspace {
  display: grid;
  grid-template-rows: minmax(260px, 40vh) minmax(0, 1fr);
  gap: 18px;
  height: 100vh;
  min-height: 0;
  padding: 22px;
  min-width: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.workspace.code-collapsed {
  grid-template-rows: minmax(360px, 1fr) auto;
}

.preview-panel,
.code-panel {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.preview-panel {
  display: grid;
  grid-template-rows: auto 1fr;
  overflow: hidden;
}

.code-panel {
  display: grid;
  grid-template-rows: auto minmax(280px, 1fr);
  overflow: hidden;
}

.code-panel.is-collapsed {
  grid-template-rows: auto;
}

.code-panel.is-collapsed #codeOutput {
  display: none;
}

.code-panel.is-collapsed .accordion-arrow {
  transform: rotate(-90deg);
}

.panel-head {
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
}

.preview-stage {
  display: grid;
  place-items: center;
  min-height: 220px;
  padding: 28px;
  background:
    linear-gradient(90deg, rgba(15, 23, 42, 0.06) 1px, transparent 1px),
    linear-gradient(0deg, rgba(15, 23, 42, 0.06) 1px, transparent 1px),
    #f8fafc;
  background-size: 24px 24px;
  overflow: auto;
}

.preview-stage.is-html-paste-preview {
  place-items: stretch;
  padding: 0;
}

.html-paste-preview-frame {
  display: block;
  width: 100%;
  min-width: 0;
  height: 100%;
  min-height: 220px;
  border: 0;
  background: transparent;
}

.primary-button,
.ghost-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 8px 12px;
  font-weight: 800;
}

.panel-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-button {
  display: inline-grid;
  place-items: center;
  width: 38px;
  min-width: 38px;
  min-height: 38px;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: #ffffff;
  color: #334155;
  cursor: pointer;
}

.full-button {
  width: 100%;
  margin-top: 12px;
}

.primary-button {
  background: var(--accent);
  color: #ffffff;
  border-color: #0f766e;
}

.ghost-button {
  background: #ffffff;
  color: #334155;
  border-color: var(--line);
}

.copy-mark {
  position: relative;
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-radius: 3px;
}

.copy-mark::before {
  content: "";
  position: absolute;
  width: 10px;
  height: 10px;
  border: 2px solid currentColor;
  border-radius: 3px;
  left: -6px;
  top: 3px;
  opacity: 0.55;
}

#codeOutput {
  min-height: 0;
  padding: 18px;
  border: 0;
  border-radius: 0;
  resize: none;
  background: #0b1120;
  color: #d1fae5;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  line-height: 1.55;
}

@media (max-width: 920px), (hover: none) and (pointer: coarse) {
  html {
    height: auto;
    min-height: 100%;
    overflow-x: hidden;
    overflow-y: auto;
  }

  body {
    height: auto;
    min-height: 100dvh;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .app-shell {
    display: block;
    grid-template-columns: 1fr;
    height: auto;
    min-height: 100dvh;
    overflow: visible;
  }

  .panel-resizer {
    display: none;
  }

  .sidebar {
    height: auto;
    max-height: none;
    overflow: visible;
    overscroll-behavior: auto;
    border-right: 0;
    border-bottom: 1px solid #0f172a;
  }

  .workspace {
    grid-template-rows: auto auto;
    height: auto;
    min-height: 0;
    overflow: visible;
    overscroll-behavior: auto;
    padding: 14px;
  }

  .workspace.code-collapsed {
    grid-template-rows: auto auto;
  }

  .preview-panel,
  .code-panel {
    overflow: visible;
  }

  .preview-panel {
    grid-template-rows: auto auto;
  }

  .preview-stage {
    min-height: 240px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }

  .code-panel {
    grid-template-rows: auto minmax(320px, auto);
  }

  #codeOutput {
    min-height: 320px;
    max-height: 70vh;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 520px) {
  .sidebar {
    padding: 14px;
  }

  .field-row,
  .manual-row,
  .manual-row-wide,
  .option-grid,
  .swatch-grid,
  .color-grid {
    grid-template-columns: 1fr;
  }

  .brand,
  .panel-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .primary-button,
  .ghost-button {
    width: 100%;
  }
}
