* {
  box-sizing: border-box;
}

:root {
  --bg: #f3f4f6;
  --panel: #ffffff;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #2563eb;
  --accent-dark: #1d4ed8;
  --radius: 18px;
  --shadow: 0 18px 50px rgba(15, 23, 42, 0.08);
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
  background: var(--bg);
}

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

button {
  cursor: pointer;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  padding: 18px 22px;
  background: rgba(243, 244, 246, 0.92);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
  font-weight: 800;
}

h1 {
  margin: 0;
  font-size: clamp(1.35rem, 3vw, 2rem);
}

h2 {
  margin: 0 0 14px;
  font-size: 1rem;
}

.topbar-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.primary-btn,
.secondary-btn,
.device-btn,
.upload-btn {
  border: 0;
  border-radius: 999px;
  padding: 10px 15px;
  font-weight: 800;
}

.primary-btn {
  color: #fff;
  background: var(--accent);
}

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

.secondary-btn,
.device-btn,
.upload-btn {
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
}

.device-btn.active {
  color: #fff;
  background: var(--text);
  border-color: var(--text);
}

.layout {
  display: grid;
  grid-template-columns: minmax(310px, 390px) 1fr;
  gap: 18px;
  padding: 18px;
  min-height: calc(100vh - 85px);
}

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

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 18px;
}

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

.field span {
  font-size: 0.82rem;
  color: var(--muted);
  font-weight: 800;
}

input,
textarea,
select {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 11px 12px;
  background: #fff;
  color: var(--text);
}

textarea {
  resize: vertical;
}

input[type="color"] {
  min-height: 44px;
  padding: 4px;
}

.two-cols {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.check {
  display: flex;
  gap: 10px;
  align-items: center;
  margin: 10px 0;
  font-weight: 700;
}

.check input {
  width: auto;
}

.full,
.upload-btn {
  width: 100%;
  display: block;
  text-align: center;
  margin-bottom: 10px;
}

.upload-btn input {
  display: none;
}

.small-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.85rem;
}

.preview-shell {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.preview-toolbar {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid var(--line);
}

#previewFrame {
  width: 100%;
  height: 100%;
  min-height: 720px;
  border: 0;
  background: #fff;
  margin: 0 auto;
  transition: width 180ms ease;
}

.preview-shell[data-device="tablet"] #previewFrame {
  width: 768px;
  max-width: 100%;
}

.preview-shell[data-device="mobile"] #previewFrame {
  width: 390px;
  max-width: 100%;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: #111827;
  color: #fff;
  padding: 12px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
  font-weight: 800;
  z-index: 100;
}

.toast.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

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

  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    justify-content: flex-start;
  }

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