:root {
  --bg: #071120;
  --panel: #0d1a30;
  --panel-soft: #12233f;
  --panel-border: rgba(148, 163, 184, 0.16);
  --text: #e5eefc;
  --muted: #8ca3c7;
  --blue: #1d4ed8;
  --blue-strong: #2563eb;
  --danger: #ef4444;
  --canvas-bg: linear-gradient(180deg, #0d1a30 0%, #0a1427 100%);
  --shadow: 0 24px 50px rgba(2, 8, 23, 0.35);
  --radius: 18px;
  --font: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background:
    radial-gradient(circle at top, rgba(37, 99, 235, 0.18), transparent 34%),
    linear-gradient(180deg, #040b17, #091224 42%, #060d1b);
  color: var(--text);
}

body {
  min-height: 100vh;
}

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

button {
  cursor: pointer;
}

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(7, 17, 32, 0.9);
  backdrop-filter: blur(18px);
}

.brand-row {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
  object-fit: contain;
  box-shadow: 0 14px 28px rgba(29, 78, 216, 0.24);
}

.app-title {
  margin: 0;
  font-size: 18px;
}

.app-subtitle {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--muted);
}

.toolbar-center,
.toolbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.toolbar-label {
  font-size: 13px;
  color: var(--muted);
}

.toolbar-select,
.field select,
.field input,
.field textarea {
  width: 100%;
  border: 1px solid var(--panel-border);
  background: rgba(13, 26, 48, 0.9);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  outline: none;
}

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

.toolbar-select {
  min-width: 180px;
}

.primary-button,
.ghost-button,
.danger-button,
.secondary-button {
  border-radius: 12px;
  padding: 10px 14px;
  border: 1px solid transparent;
  transition: 0.18s ease;
}

.primary-button {
  background: linear-gradient(135deg, var(--blue), var(--blue-strong));
  color: white;
  box-shadow: 0 14px 28px rgba(29, 78, 216, 0.25);
}

.ghost-button,
.secondary-button {
  background: rgba(18, 35, 63, 0.92);
  color: var(--text);
  border-color: var(--panel-border);
}

.ghost-button:hover,
.secondary-button:hover,
.primary-button:hover,
.danger-button:hover {
  transform: translateY(-1px);
}

.danger-button {
  background: rgba(239, 68, 68, 0.14);
  color: #fecaca;
  border-color: rgba(239, 68, 68, 0.2);
}

.device-switcher {
  display: inline-flex;
  gap: 6px;
  padding: 4px;
  border-radius: 14px;
  background: rgba(13, 26, 48, 0.95);
  border: 1px solid var(--panel-border);
}

.device-button {
  background: transparent;
  border: 0;
  color: var(--muted);
  padding: 8px 12px;
  border-radius: 10px;
}

.device-button.is-active {
  background: linear-gradient(135deg, var(--blue), var(--blue-strong));
  color: white;
}

.editor-shell {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: 270px minmax(0, 1fr) 320px;
}

.panel {
  min-height: 0;
  overflow: auto;
  background: rgba(9, 18, 36, 0.92);
}

.left-panel {
  border-right: 1px solid var(--panel-border);
}

.right-panel {
  border-left: 1px solid var(--panel-border);
}

.panel-heading {
  position: sticky;
  top: 0;
  z-index: 2;
  padding: 18px;
  border-bottom: 1px solid var(--panel-border);
  background: rgba(9, 18, 36, 0.96);
  backdrop-filter: blur(14px);
}

.panel-heading h2 {
  margin: 0;
  font-size: 15px;
}

.panel-heading p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.block-library,
.properties-panel {
  padding: 18px;
}

.block-library {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.block-card {
  text-align: left;
  border: 1px solid var(--panel-border);
  background: linear-gradient(180deg, rgba(18, 35, 63, 0.95), rgba(13, 26, 48, 0.95));
  color: var(--text);
  border-radius: 16px;
  padding: 14px;
}

.block-card strong {
  display: block;
  margin-bottom: 6px;
}

.block-card span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.45;
}

.canvas-shell {
  min-width: 0;
  overflow: auto;
  background: var(--canvas-bg);
}

.canvas-stage {
  min-height: 100%;
  display: flex;
  justify-content: center;
  padding: 30px;
}

.canvas-frame {
  width: min(100%, 1180px);
  background: white;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: width 0.18s ease;
}

.canvas-frame.canvas-tablet {
  width: min(100%, 820px);
}

.canvas-frame.canvas-mobile {
  width: min(100%, 420px);
}

.canvas-empty {
  min-height: 520px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 30px;
  color: #475569;
}

.canvas-empty h3 {
  margin: 0 0 8px;
  color: #0f172a;
}

.builder-page {
  min-height: 520px;
}

.builder-block {
  position: relative;
  cursor: pointer;
}

.builder-block.is-selected {
  box-shadow: inset 0 0 0 3px rgba(29, 78, 216, 0.65);
}

.block-tag {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 10;
  padding: 8px 10px;
  border-bottom-right-radius: 14px;
  background: rgba(29, 78, 216, 0.96);
  color: white;
  font-size: 12px;
  font-weight: 700;
}

.block-actions {
  position: absolute;
  right: 10px;
  top: 10px;
  z-index: 10;
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 18px 40px rgba(15, 23, 42, 0.14);
}

.icon-button {
  border: 0;
  border-radius: 10px;
  padding: 6px 10px;
  background: #eff6ff;
  color: #1e3a8a;
}

.icon-button.delete {
  background: #fee2e2;
  color: #991b1b;
}

.properties-panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.field-group,
.section-card,
.list-item {
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: rgba(18, 35, 63, 0.72);
}

.section-card {
  padding: 16px;
}

.field-group {
  padding: 16px;
}

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

.field + .field {
  margin-top: 14px;
}

.field label,
.fieldset-label {
  font-size: 12px;
  font-weight: 700;
  color: #bfd1ec;
  letter-spacing: 0.02em;
}

.field-help {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.45;
}

.inline-row {
  display: flex;
  gap: 10px;
}

.inline-row > * {
  flex: 1;
}

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

.color-row input[type="color"] {
  width: 52px;
  padding: 4px;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: rgba(13, 26, 48, 0.9);
}

.list-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-height: 420px;
  overflow: auto;
}

.list-item {
  padding: 14px;
}

.list-item-header,
.page-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

.list-label {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.page-stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.page-card {
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  background: rgba(9, 18, 36, 0.9);
  padding: 14px;
}

.page-state {
  font-size: 12px;
  color: var(--muted);
}

.page-state.is-active {
  color: #bfdbfe;
}

.preview-dialog {
  border: 0;
  padding: 0;
  background: transparent;
  width: min(1180px, calc(100vw - 28px));
}

.preview-dialog::backdrop {
  background: rgba(3, 7, 18, 0.72);
  backdrop-filter: blur(8px);
}

.preview-dialog-card {
  border-radius: 22px;
  overflow: hidden;
  border: 1px solid rgba(148, 163, 184, 0.18);
  background: #0b1220;
  box-shadow: var(--shadow);
}

.export-dialog-card {
  display: flex;
  flex-direction: column;
  max-height: min(88vh, 900px);
}

.preview-dialog-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px;
  border-bottom: 1px solid rgba(148, 163, 184, 0.16);
}

.preview-dialog-header h2 {
  margin: 0;
}

.preview-dialog-header p {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 13px;
}

#previewFrame {
  width: 100%;
  height: 76vh;
  border: 0;
  background: white;
}

.export-dialog-body {
  overflow-y: auto;
  padding: 20px 18px 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.export-download-card,
.export-step {
  border: 1px solid var(--panel-border);
  border-radius: 18px;
  background: rgba(18, 35, 63, 0.72);
  padding: 18px;
}

.export-download-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
}

.export-download-card h3,
.export-step h3 {
  margin: 0 0 6px;
  font-size: 17px;
}

.export-download-card p,
.export-step p {
  margin: 0;
  color: var(--muted);
  line-height: 1.55;
  font-size: 14px;
}

.app-footer {
  border-top: 1px solid var(--panel-border);
  background: rgba(7, 17, 32, 0.92);
  padding: 14px 18px;
  text-align: center;
  color: var(--muted);
  font-size: 13px;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

@media (max-width: 1180px) {
  .editor-shell {
    grid-template-columns: 240px minmax(0, 1fr);
  }

  .right-panel {
    grid-column: 1 / -1;
    border-left: 0;
    border-top: 1px solid var(--panel-border);
  }
}

@media (max-width: 860px) {
  .app-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .toolbar-center,
  .toolbar-actions {
    flex-wrap: wrap;
  }

  .editor-shell {
    grid-template-columns: 1fr;
  }

  .left-panel,
  .right-panel {
    border: 0;
    border-top: 1px solid var(--panel-border);
  }

  .canvas-stage {
    padding: 18px;
  }

  .export-download-card {
    flex-direction: column;
    align-items: stretch;
  }
}
