/* Editor UI styles (never exported). Colours follow docs/designs.html. */

:root {
  --ed-bg: #F4F5F7;
  --ed-surface: #FFFFFF;
  --ed-ink: #16181D;
  --ed-ink-2: #3E4450;
  --ed-muted: #5B6270;
  --ed-faint: #9AA1AD;
  --ed-line: #E1E4EA;
  --ed-line-2: #D5D9E0;
  --ed-primary: #2446D8;
  --ed-primary-hover: #1A33A3;
  --ed-primary-soft: #EEF1FD;
  --ed-danger: #B4371F;
  --ed-heading: 'Space Grotesk', system-ui, sans-serif;
  --ed-body: Inter, system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body { background: var(--ed-bg); color: var(--ed-ink); font: 14px/1.4 var(--ed-body); }
body.is-previewing { overflow: hidden; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
:focus-visible { outline: 2px solid var(--ed-primary); outline-offset: 2px; }
[hidden] { display: none !important; }

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

/* ---------- top bar */
.topbar {
  display: flex; flex-wrap: wrap; align-items: center; gap: 16px;
  padding: 12px 24px; background: var(--ed-surface); border-bottom: 1px solid var(--ed-line);
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand__logo { display: flex; }
.brand__name { font-family: var(--ed-heading); font-weight: 700; font-size: 18px; }
.topbar__deck { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--ed-muted); }
.topbar__title {
  height: 36px; padding: 0 10px; width: 220px; border: 1px solid var(--ed-line); border-radius: 8px;
  font-size: 14px; color: var(--ed-ink); background: var(--ed-surface);
}
.topbar__spacer { flex-grow: 1; }
.topbar__actions { display: flex; flex-wrap: wrap; gap: 8px; }

.btn {
  height: 44px; padding: 0 16px; border: 1px solid var(--ed-line-2); background: var(--ed-surface);
  border-radius: 10px; font-size: 14px; font-weight: 500; color: var(--ed-ink);
  display: inline-flex; align-items: center; gap: 8px;
}
.btn:hover { background: #F7F8FA; }
.btn--primary { border: 0; background: var(--ed-primary); color: #FFFFFF; font-weight: 600; padding: 0 18px; }
.btn--primary:hover { background: var(--ed-primary-hover); }

.icon-btn {
  width: 44px; height: 44px; border: 0; background: transparent; border-radius: 8px; color: var(--ed-ink-2);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.icon-btn:hover { background: rgba(22, 24, 29, 0.06); }
.icon-btn--danger { color: var(--ed-danger); }

.link-btn { border: 0; background: none; padding: 4px 0; color: var(--ed-primary); font-weight: 600; font-size: 14px; }
.link-btn:hover { color: var(--ed-primary-hover); text-decoration: underline; }

.banner {
  display: flex; align-items: center; gap: 10px; padding: 10px 24px;
  background: #FDF0E1; color: #7A3A0E; border-bottom: 1px solid #F3D6B5; font-size: 13px;
}

/* ---------- layout */
.workspace { display: flex; flex-wrap: wrap; flex-grow: 1; }

.sidebar {
  flex: 1 1 280px; max-width: 320px; background: var(--ed-surface); border-right: 1px solid var(--ed-line);
  padding: 16px; display: flex; flex-direction: column; gap: 8px;
}
.sidebar__head { display: flex; justify-content: space-between; align-items: center; padding: 4px 4px 8px; }
.sidebar__count { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; color: var(--ed-muted); }
.sidebar__hint { font-size: 12px; color: var(--ed-muted); }

.slide-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.slide-row {
  position: relative; display: flex; align-items: center; gap: 8px; padding: 8px; min-height: 56px;
  border-radius: 10px; background: var(--ed-surface); cursor: pointer; user-select: none;
}
.slide-row:hover { background: #F7F8FA; }
.slide-row.is-selected { background: var(--ed-primary-soft); outline: 2px solid var(--ed-primary); outline-offset: -2px; }
.slide-row.is-dragging { opacity: 0.4; }
.slide-row.drop-before::before, .slide-row.drop-after::after {
  content: ''; position: absolute; left: 4px; right: 4px; height: 3px; border-radius: 2px; background: var(--ed-primary);
}
.slide-row.drop-before::before { top: -6px; }
.slide-row.drop-after::after { bottom: -6px; }
.slide-row__grip { flex-shrink: 0; fill: var(--ed-faint); cursor: grab; }
.slide-row__num { width: 22px; font-size: 13px; color: var(--ed-muted); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.slide-row__text { display: flex; flex-direction: column; gap: 2px; min-width: 0; flex-grow: 1; }
.slide-row__type { font-size: 11px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.slide-row.is-unknown .slide-row__type { color: var(--ed-danger) !important; }
.slide-row__title { font-size: 14px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.slide-row__actions { display: flex; gap: 2px; }

.add-slide {
  margin-top: 8px; height: 48px; border: 1.5px dashed #B9C0CC; border-radius: 10px; background: transparent;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  font-size: 14px; font-weight: 600; color: var(--ed-primary);
}
.add-slide:hover { background: var(--ed-primary-soft); border-color: var(--ed-primary); }

.main {
  flex: 999 1 560px; min-width: 0; padding: 32px; display: flex; flex-direction: column; gap: 24px;
}
.main__head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 12px; }
.type-badge {
  font-size: 12px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase;
  padding: 4px 8px; border-radius: 6px;
}
.main__title {
  margin: 0; font-family: var(--ed-heading); font-size: 28px; font-weight: 600;
  min-width: 0; overflow-wrap: anywhere;
}
.main__meta { font-size: 13px; color: var(--ed-muted); }
.main__grid { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }

.card {
  flex: 1 1 360px; background: var(--ed-surface); border: 1px solid var(--ed-line); border-radius: 14px;
  padding: 24px; display: flex; flex-direction: column; gap: 20px;
}
.card__title { margin: 0; font-family: var(--ed-heading); font-size: 18px; font-weight: 600; }
.notice { margin: 0; font-size: 14px; color: var(--ed-ink-2); line-height: 1.5; }

.preview { flex: 1 1 420px; display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.preview__head { display: flex; justify-content: space-between; align-items: center; }
.preview-frame { aspect-ratio: 16 / 9; border-radius: 14px; overflow: hidden; background: #12141C; }
.preview__note { margin: 0; font-size: 13px; color: var(--ed-muted); }

.empty {
  margin: 64px auto; max-width: 420px; text-align: center; display: flex; flex-direction: column;
  align-items: center; gap: 12px;
}
.empty__title { margin: 0; font-family: var(--ed-heading); font-size: 28px; font-weight: 600; }
.empty__text { margin: 0 0 8px; color: var(--ed-muted); }

/* ---------- forms */
.form { display: flex; flex-direction: column; gap: 20px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field__label { font-size: 14px; font-weight: 600; }
.field__optional { font-weight: 400; color: var(--ed-muted); }
.field__input {
  height: 44px; padding: 0 12px; border: 1px solid var(--ed-line-2); border-radius: 8px;
  font-size: 15px; background: var(--ed-surface); width: 100%;
}
.field__input[type="number"] { width: 120px; }
.field__input--area { height: auto; padding: 10px 12px; line-height: 1.5; resize: vertical; }
.field__input:focus { border-color: var(--ed-primary); outline: 2px solid var(--ed-primary-soft); outline-offset: 0; }
.field__help { font-size: 12px; color: var(--ed-muted); }
/* Text field with suggestions (e.g. group names) */
.combo { position: relative; }
.combo__input { padding-right: 44px; }
.combo__toggle {
  position: absolute; right: 4px; top: 4px; width: 36px; height: 36px; border: 0; border-radius: 6px;
  background: transparent; color: var(--ed-muted); display: flex; align-items: center; justify-content: center;
}
.combo__toggle:hover { background: rgba(22, 24, 29, 0.06); color: var(--ed-ink); }
.combo.is-open .combo__toggle svg { transform: rotate(180deg); }
.combo__list {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 20; margin: 0; padding: 6px;
  list-style: none; background: var(--ed-surface); border: 1px solid var(--ed-line); border-radius: 10px;
  box-shadow: 0 12px 32px rgba(22, 24, 29, 0.14), 0 2px 6px rgba(22, 24, 29, 0.06);
  max-height: 240px; overflow-y: auto;
}
.combo__option {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 10px 12px; border-radius: 7px; font-size: 15px; color: var(--ed-ink); cursor: pointer;
}
.combo__option.is-active { background: var(--ed-primary-soft); color: var(--ed-primary); }
.combo__option.is-current { font-weight: 600; }
.combo__tick { display: flex; color: var(--ed-primary); }

.field__toggle { display: flex; align-items: center; gap: 10px; min-height: 44px; font-size: 14px; font-weight: 600; cursor: pointer; }
.field__check { width: 20px; height: 20px; margin: 0; accent-color: var(--ed-primary); cursor: pointer; flex-shrink: 0; }
.field__help--toggle { margin-left: 30px; margin-top: -8px; }

.list-field { display: flex; flex-direction: column; gap: 8px; }
.list-field__rows { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list-field__row {
  display: flex; align-items: center; gap: 6px; padding: 4px 4px 4px 8px;
  border: 1px solid transparent; border-radius: 10px;
}
.list-field__row.is-marked { background: #E8F6F0; border-color: #9FD8C0; }
.list-field__mark { width: 20px; height: 20px; margin: 0 4px 0 0; accent-color: #0F7A5C; flex-shrink: 0; cursor: pointer; }
.list-field__letter {
  width: 28px; height: 28px; border-radius: 8px; background: #EEF0F3; color: var(--ed-ink-2);
  display: flex; align-items: center; justify-content: center; font-weight: 600; font-size: 13px; flex-shrink: 0;
}
.list-field__row.is-marked .list-field__letter { background: #0F7A5C; color: #FFFFFF; }
.list-field__input { flex: 1 1 auto; min-width: 0; }
.list-field__btn {
  width: 36px; height: 36px; border: 0; background: transparent; border-radius: 8px; color: var(--ed-ink-2);
  display: inline-flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.list-field__btn:hover:not(:disabled) { background: rgba(22, 24, 29, 0.06); }
.list-field__btn:disabled { opacity: 0.3; cursor: default; }
.list-field__add {
  align-self: flex-start; height: 40px; padding: 0 14px; border: 1px dashed #B9C0CC; border-radius: 8px;
  background: transparent; color: var(--ed-primary); font-weight: 600; font-size: 14px;
}
.list-field__add:hover:not(:disabled) { background: var(--ed-primary-soft); border-color: var(--ed-primary); }
.list-field__add:disabled { opacity: 0.4; cursor: default; }

/* ---------- add-slide dialog */
.modal-backdrop {
  position: fixed; inset: 0; z-index: 50; background: rgba(18, 20, 28, 0.55);
  display: flex; align-items: flex-start; justify-content: center; padding: 72px 24px; overflow: auto;
}
.modal {
  width: 100%; max-width: 760px; background: var(--ed-surface); border-radius: 18px; padding: 28px;
  display: flex; flex-direction: column; gap: 20px; box-shadow: 0 24px 60px rgba(0, 0, 0, 0.25);
}
.modal__head { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.modal__title { margin: 0 0 6px; font-family: var(--ed-heading); font-size: 26px; font-weight: 600; }
.modal__sub { margin: 0; font-size: 14px; color: var(--ed-muted); }
.type-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; }
.type-card {
  display: flex; gap: 14px; align-items: flex-start; padding: 16px; min-height: 96px; text-align: left;
  border: 1px solid var(--ed-line); border-radius: 14px; background: var(--ed-surface);
}
.type-card:hover { border-color: var(--ed-primary); background: #FAFBFF; }
.type-card__icon {
  width: 48px; height: 48px; border-radius: 12px; display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.type-card__text { display: flex; flex-direction: column; gap: 4px; }
.type-card__label { font-size: 16px; font-weight: 600; color: var(--ed-ink); }
.type-card__desc { font-size: 13px; color: var(--ed-muted); line-height: 1.4; }
.modal__note {
  display: flex; align-items: center; gap: 10px; padding: 12px 14px; background: var(--ed-bg);
  border-radius: 10px; font-size: 13px; color: var(--ed-ink-2);
}
.modal__note svg { flex-shrink: 0; }

/* ---------- preview overlay */
.player-overlay { position: fixed; inset: 0; z-index: 100; background: #0A0B10; }
.player-overlay:focus { outline: none; }

/* ---------- toasts */
.toasts {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 200;
  display: flex; flex-direction: column; gap: 8px; align-items: center; width: max-content; max-width: calc(100vw - 32px);
}
.toast {
  display: flex; align-items: center; gap: 12px; padding: 6px 6px 6px 16px; border-radius: 12px;
  background: #16181D; color: #FFFFFF; font-size: 14px; box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.toast--error { background: #7A1F0E; }
.toast__action { border: 0; background: transparent; color: #9DB2FF; font-weight: 600; padding: 8px; border-radius: 8px; }
.toast__close {
  border: 0; background: transparent; color: #FFFFFF; opacity: 0.7; width: 36px; height: 36px;
  display: flex; align-items: center; justify-content: center; border-radius: 8px;
}
.toast__close:hover, .toast__action:hover { background: rgba(255, 255, 255, 0.1); opacity: 1; }

@media (max-width: 640px) {
  .topbar { padding: 12px 16px; }
  .main { padding: 16px; }
  .sidebar { max-width: none; border-right: 0; border-bottom: 1px solid var(--ed-line); }
}

/* ---------- Slides / Style switch */
.topbar__nav { display: flex; gap: 4px; }
.nav-tab {
  padding: 10px 14px; border: 0; border-radius: 8px; background: transparent;
  color: var(--ed-ink-2); font-weight: 500; font-size: 14px;
}
.nav-tab:hover { background: #F2F3F6; }
.nav-tab.is-active { background: var(--ed-primary-soft); color: var(--ed-primary); font-weight: 600; }

.btn--small { height: 40px; padding: 0 14px; border-radius: 8px; }
.btn--danger { color: var(--ed-danger); }

/* ---------- image thumbnails (style page and slide background) */
.image-thumb {
  width: 160px; height: 90px; border-radius: 8px; background: #2A2F3D center / cover no-repeat;
  border: 1px solid var(--ed-line); flex-shrink: 0;
}
.image-thumb--empty {
  display: flex; align-items: center; justify-content: center; color: #C9CED8; font-size: 12px;
}

.slide-bg { border-top: 1px solid var(--ed-line); padding-top: 20px; display: flex; flex-direction: column; gap: 12px; }
.slide-bg__body:empty { display: none; }
.slide-bg__body { display: flex; flex-wrap: wrap; align-items: center; gap: 16px; }
.slide-bg__actions { display: flex; flex-direction: column; gap: 8px; align-items: flex-start; }

/* ---------- Style page */
.main.main--style { max-width: 1360px; width: 100%; margin: 0 auto; }
.style-page { display: flex; flex-direction: column; gap: 24px; }
.style-page__head { display: flex; flex-direction: column; gap: 6px; }
.style-page__head .empty__text { margin: 0; font-size: 14px; }
.style-page__grid { display: flex; flex-wrap: wrap; gap: 24px; align-items: flex-start; }
.style-page__form { flex: 1 1 420px; display: flex; flex-direction: column; gap: 16px; min-width: 0; }
.style-card {
  margin: 0; min-width: 0; background: var(--ed-surface); border: 1px solid var(--ed-line); border-radius: 14px;
  padding: 20px 24px 24px; display: flex; flex-direction: column; gap: 16px;
}
.style-card__title { font-family: var(--ed-heading); font-size: 18px; font-weight: 600; padding: 0 6px; }
.style-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; }
.style-grid--colors { gap: 14px 16px; }
.style-row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px; }
.style-row--image { gap: 16px; }
.field__select { appearance: auto; padding: 0 10px; }

.font-uploads { display: flex; flex-direction: column; gap: 6px; }
.font-uploads:empty { display: none; }
.font-upload {
  display: flex; align-items: center; gap: 12px; padding: 4px 4px 4px 12px;
  border: 1px solid var(--ed-line); border-radius: 10px;
}
.font-upload__name { flex-grow: 1; font-size: 16px; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.font-upload__size { font-size: 12px; color: var(--ed-muted); }

.color-field { display: flex; align-items: center; gap: 10px; min-height: 44px; }
.color-field__text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.swatch {
  width: 40px; height: 40px; padding: 0; border: 1px solid var(--ed-line-2); border-radius: 8px;
  background: none; cursor: pointer; flex-shrink: 0; -webkit-appearance: none; appearance: none;
}
.swatch::-webkit-color-swatch-wrapper { padding: 0; }
.swatch::-webkit-color-swatch { border: 0; border-radius: 7px; }
.swatch::-moz-color-swatch { border: 0; border-radius: 7px; }
.hex-input {
  height: 32px; width: 110px; padding: 0 8px; border-radius: 6px; font-size: 13px;
  font-family: ui-monospace, Menlo, Consolas, monospace;
}
.hex-input.is-invalid { border-color: var(--ed-danger); outline-color: #FBE3DD; }

.range__head { display: flex; justify-content: space-between; align-items: baseline; }
.range__value { font-size: 14px; font-weight: 500; color: var(--ed-ink-2); font-variant-numeric: tabular-nums; }
.range { width: 100%; height: 28px; accent-color: var(--ed-primary); margin: 0; }

.style-preview { flex: 1 1 480px; min-width: 0; display: flex; flex-direction: column; gap: 12px; position: sticky; top: 24px; }
.style-preview__nav { display: flex; align-items: center; gap: 4px; }
.style-preview__which { font-size: 13px; color: var(--ed-muted); min-width: 92px; text-align: center; font-variant-numeric: tabular-nums; }
.icon-btn:disabled { opacity: 0.35; cursor: default; background: transparent; }

@media (max-width: 640px) {
  .style-grid { grid-template-columns: minmax(0, 1fr); }
  .style-preview { position: static; }
}
.slide-bg__effects { display: flex; flex-direction: column; gap: 14px; margin: -4px 0 0 30px; }
.slide-bg__effects:empty { display: none; }
