:root {
  --bg: #eef2f7;
  --surface: #ffffff;
  --surface-2: #f4f7fb;
  --border: #d4dbe8;
  --text: #1d2430;
  --text-muted: #627086;
  --primary: #2f6fd6;
  --primary-contrast: #ffffff;
  --danger: #b3261e;
  --danger-contrast: #ffffff;
  --shadow-1: 0 1px 2px rgba(17, 26, 43, 0.05), 0 8px 22px rgba(17, 26, 43, 0.08);
  --focus: #1a73e8;
}

:root[data-theme="dark"] {
  --bg: #12141a;
  --surface: #1b1f28;
  --surface-2: #232937;
  --border: #353c4f;
  --text: #ecf0f7;
  --text-muted: #b2bdd1;
  --primary: #8fa4ff;
  --primary-contrast: #111522;
  --danger: #ff5f57;
  --danger-contrast: #220707;
  --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.32), 0 12px 28px rgba(0, 0, 0, 0.3);
  --focus: #9ec3ff;
}

:root[data-theme="system"] {
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root[data-theme="system"] {
    --bg: #12141a;
    --surface: #1b1f28;
    --surface-2: #232937;
    --border: #353c4f;
    --text: #ecf0f7;
    --text-muted: #b2bdd1;
    --primary: #8fa4ff;
    --primary-contrast: #111522;
    --danger: #ffb4ab;
    --shadow-1: 0 1px 2px rgba(0, 0, 0, 0.32), 0 12px 28px rgba(0, 0, 0, 0.3);
    --focus: #9ec3ff;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  font-family: "JetBrains Mono", "Segoe UI", monospace;
  background: var(--bg);
  position: relative;
  isolation: isolate;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: -1;
}

body::before {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='1600' height='1000' viewBox='0 0 1600 1000'%3E%3Cpath d='M0 780 C220 700 320 900 560 820 C760 760 840 640 1040 660 C1230 680 1320 820 1600 760 L1600 1000 L0 1000 Z' fill='%23dbe7ff' fill-opacity='0.65'/%3E%3Cpath d='M0 220 C260 180 360 360 620 320 C860 280 980 120 1240 150 C1400 170 1490 260 1600 240 L1600 0 L0 0 Z' fill='%23e6f7f8' fill-opacity='0.62'/%3E%3C/svg%3E");
  background-size: cover;
  background-position: center;
}

body::after {
  background-image:
    radial-gradient(1200px 520px at 4% -8%, rgba(46, 117, 220, 0.11), transparent 60%),
    radial-gradient(900px 460px at 96% 108%, rgba(43, 184, 186, 0.1), transparent 62%);
}

.bg-noise {
  display: none;
}

.app-header {
  position: sticky;
  top: 0;
  z-index: 120;
  width: 100%;
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 2px 12px rgba(20, 30, 55, 0.09);
  backdrop-filter: blur(8px);
}

.header-shell {
  width: min(1380px, 96vw);
  margin: 0 auto;
  padding: 10px 0 8px;
}

.app-shell {
  width: min(1380px, 96vw);
  margin: 12px auto 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 12px;
  min-width: 0;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
  box-shadow: var(--shadow-1);
}

.controls,
.editor-panel {
  padding: 16px;
}

h1,
h2,
h3 {
  margin: 0;
  font-family: "JetBrains Mono", "Segoe UI", monospace;
  font-weight: 600;
  letter-spacing: 0.01em;
}

h1 {
  font-size: 1.4rem;
}

h2 {
  font-size: 1.25rem;
}

h3 {
  font-size: 1rem;
}

.subtitle {
  margin: 6px 0 0;
  color: var(--text-muted);
}

.brand-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.22);
}

.header-main {
  display: grid;
  grid-template-columns: minmax(220px, 1fr) auto minmax(220px, 1fr);
  align-items: center;
  gap: 16px;
  min-height: 56px;
}

.header-title {
  display: flex;
  align-items: center;
  justify-self: start;
}

.brand-block {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.brand-copy {
  display: grid;
  gap: 1px;
  line-height: 1;
}

.brand-name {
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.brand-product {
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  color: var(--text);
}

.project-header-center {
  display: flex;
  align-items: center;
  justify-content: center;
  justify-self: center;
  min-width: 0;
  position: relative;
}

.project-title-row {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-width: 0;
}

.project-title-btn {
  border: 0;
  background: transparent;
  color: var(--text);
  font-size: clamp(1rem, 1.2vw, 1.28rem);
  font-weight: 700;
  letter-spacing: 0.01em;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
  max-width: min(620px, 60vw);
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

.project-title-btn:hover {
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
}

#projectTitleText {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.project-edit-icon {
  font-size: 1rem;
  color: var(--text-muted);
  transform: rotate(-18deg);
}

.project-edit-icon i {
  font-size: 0.92rem;
}

.header-save-icon {
  border: 0;
  background: transparent;
  color: var(--text-muted);
  width: 30px;
  height: 30px;
  padding: 0;
  cursor: pointer;
  border-radius: 8px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.header-save-icon:hover {
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  color: var(--text);
}

.project-status {
  margin: 0;
  font-size: 0.9rem;
  white-space: nowrap;
}

.ratio-inline {
  display: inline-flex;
  align-items: center;
  min-height: 30px;
  padding: 0 10px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: color-mix(in srgb, var(--surface-2) 70%, transparent);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  white-space: nowrap;
}

.theme-icon-switcher {
  display: inline-flex;
  gap: 6px;
  align-items: center;
}

.header-right-tools {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  justify-self: end;
}

.header-divider {
  color: var(--border);
  font-weight: 700;
  line-height: 1;
  font-size: 1.05rem;
  user-select: none;
}

.save-tools {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.header-save-btn {
  width: 36px;
  height: 36px;
}

.header-save-btn span {
  font-size: 0.95rem;
}

.header-save-btn i,
.theme-icon-switcher i,
.icon-btn i {
  font-size: 0.95rem;
  line-height: 1;
}

.save-status-dot {
  width: 10px;
  height: 10px;
  border-radius: 999px;
  display: inline-block;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.16);
}

.save-status-dot.is-saved {
  background: #2e7d32;
}

.save-status-dot.is-pending {
  background: #ef6c00;
}

.save-status-dot.is-error {
  background: #c62828;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.theme-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.theme-btn.active {
  border-color: var(--primary);
  color: var(--primary);
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  box-shadow: inset 0 0 0 1px var(--primary);
}

.controls-layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 14px;
}

.general-controls-block {
  padding: 14px;
}

.general-controls-block > h3 {
  font-size: 1.38rem;
  margin-bottom: 12px;
}

.general-subsection {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 86%, var(--surface-2));
  padding: 12px;
}

.general-subsection + .general-subsection,
.general-subsection + .background-settings,
.background-settings + .general-subsection {
  margin-top: 10px;
}

.subsection-head {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-bottom: 0;
}

.general-subsection h4 {
  margin: 0;
  font-size: 1.36rem;
  line-height: 1.2;
  font-weight: 700;
  color: var(--text);
}

.controls-block {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  background: var(--surface-2);
}

.controls-block h3 {
  margin-bottom: 12px;
}

.background-settings {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 86%, var(--surface-2));
  padding: 12px;
}

.background-settings h4 {
  margin: 0;
  font-size: 1.36rem;
  line-height: 1.2;
  font-weight: 700;
  color: var(--text);
}

.section-body {
  margin-top: 12px;
  overflow: hidden;
  height: auto;
  opacity: 1;
  transition: height 220ms ease, opacity 180ms ease, margin-top 220ms ease;
}

.collapsible-section.is-collapsed {
  padding-bottom: 10px;
}

.collapsible-section.is-collapsed .section-body {
  margin-top: 0;
  height: 0;
  opacity: 0;
  pointer-events: none;
}

.section-toggle-btn {
  border: 0;
  background: transparent;
  color: var(--text);
  padding: 0;
  cursor: pointer;
}

.section-toggle-title {
  width: 100%;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-align: left;
}

.section-toggle-label {
  font-size: 1.36rem;
  line-height: 1.2;
  font-weight: 700;
  color: var(--text);
}

.section-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2em;
  height: 1.2em;
  color: var(--text-muted);
  transform: rotate(90deg);
  transition: transform 180ms ease, color 160ms ease;
  flex: 0 0 auto;
}

.section-toggle-icon i {
  font-size: 0.9em;
  line-height: 1;
}

.section-toggle-btn[aria-expanded="false"] .section-toggle-icon {
  transform: rotate(0deg);
}

.section-toggle-title:hover .section-toggle-icon,
.section-toggle-title:focus-visible .section-toggle-icon,
.section-toggle-title:hover .section-toggle-label,
.section-toggle-title:focus-visible .section-toggle-label {
  color: var(--primary);
}

.theme-selection-grid {
  grid-template-columns: 1fr;
}

.font-settings-grid {
  grid-template-columns: 1fr;
  align-items: end;
  gap: 14px 12px;
}

.font-global-group {
  grid-column: 1 / -1;
}

.font-columns-grid {
  display: grid;
  grid-template-columns: minmax(170px, 1fr) minmax(170px, 1fr) minmax(170px, 1fr) minmax(260px, 1.45fr);
  gap: 12px;
  align-items: stretch;
}

.font-column-card {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: color-mix(in srgb, var(--surface) 88%, var(--surface-2));
  padding: 12px;
  display: grid;
  gap: 10px;
  align-content: start;
}

.font-column-card h5 {
  margin: 0;
  font-size: 0.86rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.font-column-card .control-group {
  display: grid;
  gap: 6px;
}

.margins-compact-group {
  gap: 7px;
}

.margins-compact-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.margins-compact-row input {
  min-height: 36px;
  padding: 8px;
  text-align: center;
}

.font-column-card-content {
  min-width: 0;
}

.font-column-card-content .content-layout-group {
  min-width: 0;
}

.font-column-card-content .content-layout-group select,
.font-column-card-content .content-layout-group input,
.font-column-card input,
.font-column-card select {
  width: 100%;
}

.font-column-card .btn.secondary {
  margin-top: 2px;
}

.font-tools-actions {
  display: grid;
  grid-template-columns: repeat(2, minmax(220px, 1fr));
  gap: 10px;
}

.compact-template-group {
  grid-column: auto;
}

.theme-inline-controls {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(180px, 0.72fr) minmax(220px, 0.95fr);
  gap: 12px;
  align-items: end;
}

.theme-select-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: end;
}

.theme-inline-controls > .control-group,
.background-grid > .control-group,
.text-settings-grid > .control-group {
  display: flex;
  flex-direction: column;
}

.inline-ratio-group {
  margin-bottom: 0;
}

.inline-theme-actions {
  min-width: 0;
}

.inline-theme-actions .btn {
  width: 100%;
  white-space: nowrap;
}

.inline-theme-actions .btn i {
  margin-right: 6px;
}

.background-grid {
  grid-template-columns: minmax(280px, 1.1fr) minmax(180px, 0.68fr) minmax(204px, 0.72fr);
  align-items: start;
  gap: 14px 12px;
}

.text-settings-grid {
  grid-template-columns: minmax(170px, 0.7fr) minmax(250px, 1.05fr) minmax(210px, 0.9fr);
  grid-template-areas:
    "count align ."
    "eyebrow badge footer"
    "title title title";
  align-items: end;
  gap: 14px 12px;
}

.text-slides-count-group {
  grid-area: count;
}

.text-slides-align-group {
  grid-area: align;
}

.text-slides-title-group {
  grid-area: title;
}

.text-slides-footer-group {
  grid-area: footer;
}

.text-slides-eyebrow-group {
  grid-area: eyebrow;
}

.text-slides-badge-group {
  grid-area: badge;
}

.text-slides-count-group .row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.bg-upload-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.bg-upload-group {
  min-width: 0;
}

.file-input-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

.upload-name {
  margin: 8px 0 0;
  font-size: 0.82rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bg-image-preview {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 4px;
}

.background-preview-rail {
  grid-column: 3;
  grid-row: 1;
  justify-self: stretch;
  align-self: start;
  display: grid;
  grid-template-columns: repeat(2, minmax(96px, 1fr));
  gap: 10px;
}

.bg-preview-label {
  display: block;
  margin: 0 0 6px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.bg-image-preview.hidden {
  display: none;
}

.bg-image-preview img {
  width: 100%;
  display: block;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  border-radius: 7px;
}

.overlay-opacity-row {
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  gap: 8px;
}

.overlay-opacity-topline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.opacity-number-input {
  width: 84px;
  text-align: right;
}

.overlay-opacity-row input[type="range"] {
  accent-color: var(--primary);
  padding: 0;
}

.overlay-color-row {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.overlay-color-row input[type="color"] {
  width: 44px;
  height: 36px;
  border-radius: 10px;
  padding: 2px;
  border: 1px solid var(--border);
  background: var(--surface);
  cursor: pointer;
}

.color-chip-label {
  color: var(--text-muted);
  font-size: 0.88rem;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}

.control-group {
  margin-bottom: 0;
}

.controls-grid {
  display: grid;
  gap: 14px 12px;
  align-items: end;
}

.controls-grid .control-group,
.controls-grid .actions {
  margin-bottom: 0;
}

.content-grid {
  grid-template-columns: 1fr 1fr;
}

.compact-general-grid {
  grid-template-columns: repeat(4, minmax(180px, 1fr));
  gap: 12px;
}

.template-group {
  grid-column: 1 / -1;
}

label {
  display: block;
  margin-bottom: 7px;
  font-weight: 600;
  font-size: 0.93rem;
}

.template-label-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.inline-check {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.92rem;
  color: var(--text-muted);
  margin-bottom: 0;
}

.inline-check input {
  margin: 0;
}

.inline-template-check {
  min-height: 42px;
  padding: 0 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  white-space: nowrap;
  align-self: end;
  margin-bottom: 0 !important;
}

.inline-template-check input {
  width: 16px;
  height: 16px;
}

.inline-check-card {
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--surface);
  gap: 10px;
  color: var(--text);
  font-weight: 500;
  line-height: 1.25;
}

.inline-check-card input {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.inline-check-card:hover {
  border-color: color-mix(in srgb, var(--primary) 38%, var(--border));
  background: color-mix(in srgb, var(--surface-2) 72%, var(--surface));
}

.inline-check-card:focus-within {
  outline: 2px solid color-mix(in srgb, var(--focus) 62%, transparent);
  outline-offset: 2px;
}

.template-thumbs {
  display: grid;
  grid-template-columns: repeat(var(--template-visible, 4), minmax(0, 1fr));
  gap: 12px;
}

.template-carousel {
  margin-top: 12px;
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 8px;
}

.template-carousel-viewport {
  overflow: hidden;
  padding: 4px;
  margin: -4px;
}

.template-carousel-nav {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.template-carousel-nav i {
  font-size: 0.92rem;
}

.template-carousel-dots {
  margin-top: 10px;
  display: flex;
  justify-content: center;
  gap: 8px;
}

.template-page-dot {
  width: 9px;
  height: 9px;
  border-radius: 999px;
  border: 0;
  background: color-mix(in srgb, var(--text-muted) 58%, transparent);
  cursor: pointer;
}

.template-page-dot.active {
  background: var(--primary);
  box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--surface) 70%, transparent);
  transform: scale(1.08);
}

.template-thumb {
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--surface);
  padding: 6px;
  cursor: pointer;
  text-align: left;
  position: relative;
  transition: border-color 140ms ease, transform 140ms ease, background-color 140ms ease;
}

.template-thumb img {
  width: 100%;
  display: block;
  aspect-ratio: var(--template-preview-aspect, 4 / 5);
  border-radius: 7px;
  object-fit: cover;
}

.template-thumb span {
  display: block;
  margin-top: 6px;
  font-size: 0.79rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.template-thumb.active {
  border-color: var(--primary);
  background: color-mix(in srgb, var(--primary) 9%, var(--surface));
  box-shadow: inset 0 0 0 2px var(--primary);
  transform: translateY(-1px);
}

.template-thumb.active::after {
  content: "";
  position: absolute;
  top: 8px;
  right: 8px;
  width: 10px;
  height: 10px;
  border-radius: 999px;
  background: var(--primary);
  border: 2px solid var(--surface);
}

.template-thumb.active span {
  color: var(--text);
  font-weight: 700;
}

@media (max-width: 680px) {
  .template-carousel-nav {
    width: 30px;
    height: 30px;
  }
}

.row {
  display: flex;
  gap: 8px;
  align-items: center;
}

input,
select,
textarea,
button {
  font: inherit;
}

input[type="checkbox"],
input[type="radio"] {
  width: 16px;
  min-height: 16px;
  height: 16px;
  padding: 0;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  color: var(--text);
  min-height: 40px;
  padding: 9px 11px;
}

select {
  appearance: none;
  background-image:
    linear-gradient(45deg, transparent 50%, var(--text-muted) 50%),
    linear-gradient(135deg, var(--text-muted) 50%, transparent 50%);
  background-position:
    calc(100% - 22px) calc(50% - 3px),
    calc(100% - 16px) calc(50% - 3px);
  background-size: 6px 6px, 6px 6px;
  background-repeat: no-repeat;
  padding-right: 38px;
}

input[type="number"] {
  padding-right: 10px;
}

textarea {
  min-height: 88px;
  resize: vertical;
}

input[type="file"] {
  min-width: 0;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.btn {
  border: 1px solid var(--primary);
  background: var(--primary);
  color: var(--primary-contrast);
  border-radius: 6px;
  min-height: 40px;
  padding: 9px 13px;
  font-weight: 600;
  cursor: pointer;
}

.btn.secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}

.btn.accent {
  background: var(--primary);
  color: var(--primary-contrast);
}

.btn.danger {
  background: var(--danger);
  border-color: var(--danger);
  color: var(--danger-contrast);
}

.btn.danger:hover {
  filter: brightness(0.95);
}

.btn:disabled {
  opacity: 0.6;
  cursor: default;
}

.hint {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.slides-editor {
  display: grid;
  gap: 10px;
  max-height: 72vh;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0;
}

.slides-editor-host {
  background: transparent;
  border: 0;
  box-shadow: none;
}

.slides-editor-actions {
  display: flex;
  justify-content: center;
  width: 100%;
  margin-top: 8px;
}

#addSlideAtEndBtn {
  width: 100%;
  justify-content: center;
}

.slides-editor--carousel + .slides-editor-actions {
  display: none;
}

.slides-editor--carousel {
  gap: 8px;
}

.slides-carousel-controls {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  gap: 10px;
  padding: 4px 0;
}

.slides-carousel-main-controls {
  grid-column: 2;
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.slides-carousel-nav-btn {
  min-width: 36px;
  width: 36px;
  min-height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.slides-carousel-add-btn {
  grid-column: 3;
  min-width: 36px;
  width: 36px;
  min-height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  justify-self: end;
}

.slides-carousel-counter {
  min-width: 70px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.86rem;
}

.slides-carousel-dots {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.slides-carousel-dot {
  width: 9px;
  height: 9px;
  border: 0;
  border-radius: 999px;
  background: color-mix(in srgb, var(--text-muted) 35%, transparent);
  cursor: pointer;
  padding: 0;
}

.slides-carousel-dot.is-active {
  background: var(--primary);
}

.slides-editor--carousel .slide-row.is-carousel-hidden {
  display: none;
}

.slide-row {
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 10px 12px;
  min-width: 0;
}

.slide-row-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.slide-row-actions {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.slide-title-sync-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

.slide-title-sync-btn {
  min-width: 42px;
  width: 42px;
  min-height: 42px;
  height: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.slide-title-sync-btn i {
  font-size: 0.9rem;
  line-height: 1;
}

.slide-title-sync-btn.is-synced {
  border-color: color-mix(in srgb, #2e7d32 46%, var(--border));
  background: color-mix(in srgb, #2e7d32 12%, var(--surface));
  color: color-mix(in srgb, #2e7d32 78%, var(--text));
}

.slide-overlimit-warning {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--danger);
  background: color-mix(in srgb, var(--danger) 16%, transparent);
  border: 1px solid color-mix(in srgb, var(--danger) 42%, transparent);
  opacity: 0;
  transform: scale(0.86);
  pointer-events: none;
  transition: opacity 160ms ease, transform 160ms ease;
}

.slide-overlimit-warning i {
  font-size: 0.8rem;
  line-height: 1;
}

.slide-overlimit-warning.is-visible {
  opacity: 1;
  transform: scale(1);
}

.slide-row-head .section-toggle-label {
  font-size: 1.2rem;
}

.slide-delete-btn {
  min-width: 36px;
  width: 36px;
  min-height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.slide-move-btn {
  min-width: 36px;
  width: 36px;
  min-height: 36px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.slide-move-btn i {
  font-size: 0.82rem;
  line-height: 1;
}

.text-title-sync-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
}

#syncAllTitlesBtn {
  min-width: 42px;
  width: 42px;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.slide-delete-btn i {
  font-size: 0.96rem;
  line-height: 1;
}

.slide-row-body {
  display: grid;
  grid-template-columns: minmax(380px, 1fr) minmax(260px, 420px);
  gap: 12px;
  min-width: 0;
}

.slide-form {
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  background: var(--surface);
  min-width: 0;
}

.slide-form h3 {
  margin-bottom: 10px;
  font-size: 1.38rem;
  font-weight: 700;
}

.slide-form label {
  margin-top: 10px;
  margin-bottom: 5px;
  font-size: 0.95rem;
}

.field-limit-hint {
  margin: 6px 0 0;
  font-size: 0.78rem;
  color: var(--text-muted);
}

.field-limit-hint.is-overlimit {
  color: var(--danger);
  font-weight: 700;
}

.slide-form input,
.slide-form textarea,
.slide-form select {
  padding: 12px 13px;
}

.slide-form input.is-overlimit,
.slide-form textarea.is-overlimit {
  border-color: var(--danger);
  box-shadow: 0 0 0 2px color-mix(in srgb, var(--danger) 22%, transparent);
}

.slide-form textarea {
  min-height: 120px;
  line-height: 1.45;
}

.slide-preview {
  border: 1px solid var(--border);
  border-radius: 14px;
  overflow: hidden;
  background: var(--surface);
  position: relative;
}

.slide-preview img {
  width: 100%;
  display: block;
  aspect-ratio: var(--slide-aspect, 4 / 5);
  object-fit: cover;
}

.preview-meta {
  display: flex;
  justify-content: space-between;
  padding: 8px 10px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.preview-loading-mask {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--surface) 78%, transparent);
  backdrop-filter: blur(2px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 140ms ease;
}

.preview-loading-mask span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 30px;
  padding: 0 12px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  font-size: 0.8rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.slide-preview.is-loading .preview-loading-mask {
  opacity: 1;
}

.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  place-items: center;
  padding: 20px;
}

body.modal-open {
  overflow: hidden;
}

body.modal-open .app-header,
body.modal-open .app-shell {
  pointer-events: none;
  user-select: none;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  pointer-events: auto;
}

.modal-card {
  position: relative;
  width: min(980px, 92vw);
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  box-shadow: var(--shadow-1);
  padding: 16px;
  pointer-events: auto;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-subtitle {
  margin: 8px 0 12px;
  color: var(--text-muted);
}

.icon-btn {
  width: 34px;
  height: 34px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.ig-viewer {
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface-2);
  padding: 10px;
}

.ig-topbar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 4px 10px;
}

.ig-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(130deg, #f58529, #dd2a7b 40%, #8134af 70%, #515bd4);
}

.ig-name {
  font-size: 0.92rem;
  color: var(--text);
}

.ig-slide-wrap {
  position: relative;
  border-radius: 6px;
  overflow: hidden;
  background: #0f1217;
}

.ig-slide-wrap img {
  width: 100%;
  max-height: 70vh;
  display: block;
  aspect-ratio: var(--slide-aspect, 4 / 5);
  object-fit: contain;
}

.slide-preview-modal-card {
  width: min(1240px, 96vw);
}

.slide-preview-modal-card.is-export-mode .slide-preview-export-panel {
  display: flex;
  flex-wrap: wrap;
  gap: 12px 16px;
  margin: 0 56px 14px;
}

.slide-preview-export-panel {
  display: none;
  width: auto;
  padding: 14px;
  border-radius: 6px;
  background: var(--surface-2);
  align-items: flex-start;
  justify-content: center;
  margin-bottom: 0;
  border: 1px solid var(--border);
}

.slide-preview-export-panel .control-group {
  flex: 1 1 320px;
  min-width: 0;
  margin-bottom: 0;
}

.slide-preview-export-panel .export-file-preview-field {
  flex: 1 1 260px;
  min-width: 0;
}

.slide-preview-export-panel input[readonly] {
  color: var(--text-muted);
  background: color-mix(in srgb, var(--surface) 84%, #ffffff 16%);
}

@media (max-width: 720px) {
  .slide-preview-modal-card.is-export-mode .slide-preview-export-panel {
    display: block;
    margin: 0 0 14px;
  }

  .slide-preview-export-panel .control-group,
  .slide-preview-export-panel .export-file-preview-field {
    width: 100%;
  }
}

.slide-preview-modal-card .hidden {
  display: none !important;
}

.slide-preview-modal-viewport {
  position: relative;
  padding: 0 56px;
}

.slide-preview-modal-frame {
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
  background: #0f1217;
  width: 100%;
  min-height: min(76vh, 760px);
  display: grid;
  place-items: center;
}

.slide-preview-modal-frame img {
  width: 100%;
  max-height: min(76vh, 760px);
  display: block;
  object-fit: contain;
  aspect-ratio: var(--slide-aspect, 4 / 5);
}

.slide-preview-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 42px;
  height: 42px;
  z-index: 2;
}

.slide-preview-nav-btn:first-of-type {
  left: 0;
}

.slide-preview-nav-btn:last-of-type {
  right: 0;
}

.slide-preview-modal-card .modal-subtitle {
  margin-bottom: 14px;
}

.nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 36px;
  height: 36px;
  border-radius: 999px;
  border: 0;
  background: rgba(255, 255, 255, 0.84);
  color: #273043;
  font-size: 1.2rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.nav-btn i {
  font-size: 0.9rem;
  line-height: 1;
}

#previewPrevBtn {
  left: 10px;
}

#previewNextBtn {
  right: 10px;
}

.ig-dots {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 10px 0 4px;
}

.ig-dots span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #b9c2d6;
}

.ig-dots span.active {
  background: var(--primary);
}

.ig-counter {
  margin: 0;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.modal-actions {
  margin-top: 12px;
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.modal-action-note {
  margin: 0 auto 0 0;
  color: var(--text-muted);
  font-size: 0.88rem;
}

.export-modal-card {
  width: min(1120px, 94vw);
}

.export-modal-grid {
  display: grid;
  grid-template-columns: minmax(260px, 320px) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
}

.export-config-panel {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--surface-2);
  padding: 14px;
}

.export-file-preview {
  margin-top: 12px;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: var(--surface);
}

.export-file-label {
  display: block;
  margin-bottom: 6px;
  font-size: 0.78rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.export-hint {
  margin: 12px 0 0;
}

.project-modal-card {
  width: min(760px, 92vw);
}

.template-gallery-modal-card {
  width: min(1180px, 95vw);
}

.template-gallery-scroll {
  max-height: min(72vh, 820px);
  overflow: auto;
  padding: 4px;
  margin: -4px;
}

.template-gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 14px;
  align-items: start;
}

.delete-confirm-card {
  width: min(520px, 92vw);
  background: linear-gradient(
      180deg,
      color-mix(in srgb, var(--danger) 9%, var(--surface)) 0%,
      var(--surface) 44%
    );
}

.delete-confirm-card .modal-header h3 {
  color: var(--text);
}

.modal-project-grid {
  margin-top: 12px;
}

.modal-project-grid .project-actions {
  grid-column: 1 / -1;
  width: 100%;
  display: grid;
  grid-template-columns: repeat(3, minmax(120px, 1fr));
  gap: 10px;
  align-items: center;
}

.modal-project-grid .project-actions .btn {
  width: 100%;
}

:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

@media (max-width: 1080px) {
  .header-main {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    align-items: center;
    gap: 10px;
  }

  .header-title,
  .project-header-center,
  .header-right-tools {
    justify-self: stretch;
  }

  .header-title {
    justify-content: flex-start;
  }

  .project-header-center {
    justify-content: flex-start;
  }

  .project-title-row {
    width: 100%;
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    justify-items: start;
    gap: 6px;
  }

  .project-title-btn {
    width: 100%;
    max-width: none;
    justify-content: space-between;
    padding-inline: 0;
  }

  .ratio-inline {
    min-height: 26px;
    font-size: 0.74rem;
  }

  .header-right-tools {
    width: 100%;
    justify-content: space-between;
    flex-wrap: wrap;
    row-gap: 8px;
  }

  .theme-icon-switcher,
  .save-tools {
    flex-wrap: wrap;
  }

  .header-divider,
  .brand-copy {
    display: none;
  }

  .font-tools-actions {
    grid-template-columns: 1fr;
  }

  .controls-layout,
  .content-grid,

  .modal-project-grid,
  .project-grid {
    grid-template-columns: 1fr;
  }
  .compact-general-grid {
    grid-template-columns: 1fr;
  }

  .subsection-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .theme-inline-controls,
  .font-settings-grid,
  .background-grid,
  .text-settings-grid {
    grid-template-columns: 1fr;
  }

  .text-settings-grid {
    grid-template-columns: repeat(2, minmax(220px, 1fr));
    grid-template-areas:
      "count align"
      "eyebrow badge"
      "footer footer"
      "title title";
  }

  .font-columns-grid {
    grid-template-columns: 1fr;
  }

  .theme-select-row {
    grid-template-columns: 1fr;
  }

  .font-global-group {
    grid-column: auto;
  }

  .bg-upload-group {
    grid-template-columns: 1fr;
  }

  .background-preview-rail {
    grid-column: auto;
    grid-row: auto;
    justify-self: start;
    grid-template-columns: repeat(2, minmax(92px, 110px));
  }

  .background-grid {
    grid-template-columns: 1fr;
  }

  .export-modal-grid {
    grid-template-columns: 1fr;
  }

  .slide-preview-modal-viewport {
    padding: 0;
  }

  .slide-preview-modal-frame {
    min-height: auto;
  }

  .template-group {
    grid-column: auto;
  }

  .template-label-row {
    flex-wrap: wrap;
  }

  .theme-inline-controls {
    grid-template-columns: 1fr;
  }

  .template-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  }

  .template-thumbs {
    grid-template-columns: repeat(4, minmax(76px, 1fr));
  }

  .slide-row {
    padding: 12px;
  }

  .slide-row-head {
    align-items: flex-start;
    flex-direction: column;
  }

  .slide-overlimit-warning {
    margin-left: 4px;
  }

  .slide-delete-btn {
    width: 36px;
    min-width: 36px;
    min-height: 36px;
  }

  .slide-row-body {
    grid-template-columns: 1fr;
  }

  .slides-editor {
    max-height: none;
  }
}

@media (max-width: 680px) {
  .header-shell,
  .app-shell {
    width: min(1380px, 94vw);
  }

  .controls,
  .editor-panel,
  .general-controls-block,
  .general-subsection,
  .background-settings,
  .controls-block {
    padding: 10px;
  }

  .actions,
  .modal-project-grid .project-actions {
    grid-template-columns: 1fr;
  }

  .slide-row-actions {
    flex-wrap: wrap;
  }

  .slides-carousel-main-controls {
    gap: 8px;
  }

  .slides-carousel-counter {
    min-width: 58px;
    font-size: 0.8rem;
  }

  .slide-preview-modal-card {
    width: min(1240px, 94vw);
  }

  .modal {
    padding: 10px;
  }

  .modal-card {
    padding: 12px;
  }

  .modal-actions {
    flex-wrap: wrap;
  }

  .modal-action-note {
    width: 100%;
    margin: 0;
  }

  .text-settings-grid {
    grid-template-columns: 1fr;
    grid-template-areas:
      "count"
      "align"
      "eyebrow"
      "badge"
      "footer"
      "title";
  }

  .inline-check-card {
    min-height: 44px;
  }
}

@media (max-width: 560px) {
  .header-shell,
  .app-shell {
    width: calc(100vw - 16px);
  }

  .header-shell {
    padding: 8px 0 6px;
  }

  .app-shell {
    margin: 8px auto 12px;
    gap: 8px;
  }

  .header-main {
    gap: 8px;
    min-height: 0;
  }

  .project-title-btn {
    font-size: 1rem;
    padding: 4px 0;
  }

  .project-status {
    white-space: normal;
    font-size: 0.82rem;
    line-height: 1.3;
  }

  .header-right-tools {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
    gap: 6px;
    width: 100%;
  }

  .theme-icon-switcher,
  .save-tools {
    display: inline-flex;
    align-items: center;
    flex-wrap: nowrap;
    gap: 6px;
    width: auto;
  }

  .save-tools .btn,
  .theme-icon-switcher .btn,
  .theme-icon-switcher .icon-btn {
    min-height: 38px;
  }

  .save-tools .btn,
  .theme-icon-switcher .btn,
  .theme-icon-switcher .icon-btn,
  .save-tools .icon-btn {
    width: 38px;
    min-width: 38px;
    height: 38px;
  }

  .header-divider,
  .ratio-inline {
    display: none;
  }

  .controls,
  .editor-panel,
  .general-controls-block,
  .general-subsection,
  .background-settings,
  .controls-block {
    padding: 9px;
  }

  h1 {
    font-size: 1.2rem;
  }

  h2 {
    font-size: 1.08rem;
  }

  .section-toggle-label,
  .general-subsection h4,
  .background-settings h4 {
    font-size: 1.08rem;
  }

  .slide-row {
    padding: 10px;
  }

  .slide-row-actions {
    display: grid;
    grid-template-columns: auto auto 1fr auto;
    width: 100%;
    justify-content: stretch;
    align-items: center;
    gap: 6px;
  }

  .slide-row-actions .slide-delete-btn {
    justify-self: end;
  }

  .slide-title-sync-row,
  .text-title-sync-row,
  .theme-select-row,
  .bg-upload-row {
    grid-template-columns: 1fr;
  }

  .slide-title-sync-btn,
  #syncAllTitlesBtn {
    width: 100%;
    min-width: 0;
  }

  .slides-carousel-controls {
    gap: 8px;
  }

  .slides-carousel-main-controls {
    gap: 7px;
  }

  .slides-carousel-counter {
    min-width: 50px;
    font-size: 0.78rem;
  }

  .slide-preview-modal-card {
    width: calc(100vw - 12px);
  }

  .modal {
    padding: 6px;
  }

  .modal-card {
    max-height: calc(100vh - 12px);
    overflow: auto;
    padding: 10px;
  }

  .slide-preview-nav-btn {
    width: 36px;
    height: 36px;
  }

  .modal-actions {
    gap: 6px;
  }

  .modal-actions .btn {
    width: 100%;
  }
}

@media (max-width: 400px) {
  .brand-icon {
    width: 32px;
    height: 32px;
  }

  .brand-product {
    font-size: 0.92rem;
  }

  .header-save-btn,
  .theme-btn,
  .icon-btn,
  .slide-delete-btn,
  .slide-move-btn,
  .slides-carousel-nav-btn,
  .slides-carousel-add-btn {
    min-width: 34px;
    width: 34px;
    min-height: 34px;
    height: 34px;
  }

  .slides-carousel-main-controls {
    gap: 6px;
  }

  .slides-carousel-counter {
    min-width: 46px;
    font-size: 0.76rem;
  }

  .field-limit-hint {
    font-size: 0.74rem;
  }
}
