:root {
  --ink: #111827;
  --muted: #667085;
  --line: #d9dee8;
  --soft: #f4f6fa;
  --panel: #ffffff;
  --violet: #3014b8;
  --lime: #d6e87d;
  --danger: #b42318;
  --success: #067647;
  --sidebar: #12172b;
  --sidebar-soft: #1f2742;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--ink);
  background: var(--soft);
  font-family: "Segoe UI", Arial, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

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

.loading-screen {
  min-height: 100vh;
  display: grid;
  place-items: center;
  align-content: center;
  gap: 16px;
  color: var(--muted);
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--line);
  border-top-color: var(--violet);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1.1fr 0.9fr;
  background: #0f1428;
}

.login-visual {
  position: relative;
  padding: 64px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  color: #fff;
  background:
    linear-gradient(180deg, rgba(10, 14, 34, 0.25), rgba(10, 14, 34, 0.88)),
    url("/assets/images/PW-home-top-placeholder-for-video.webp") center / cover;
}

.login-visual img {
  width: 167px;
}

.login-visual h1 {
  max-width: 640px;
  margin: 0;
  font-size: 46px;
  line-height: 1.14;
}

.login-panel {
  padding: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #f7f8fb;
}

.login-form {
  width: min(420px, 100%);
  padding: 36px;
  border-radius: 12px;
  background: var(--panel);
  box-shadow: 0 28px 70px rgba(15, 20, 40, 0.14);
}

.login-form h2 {
  margin: 0 0 8px;
  font-size: 28px;
}

.login-form > p {
  margin: 0 0 28px;
  color: var(--muted);
}

.app-layout {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 260px minmax(0, 1fr);
}

.sidebar {
  position: sticky;
  top: 0;
  height: 100vh;
  padding: 26px 18px;
  display: flex;
  flex-direction: column;
  color: #fff;
  background: var(--sidebar);
}

.sidebar__brand {
  padding: 0 12px 28px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
}

.sidebar__brand img {
  width: 140px;
}

.sidebar__label {
  margin: 22px 12px 8px;
  color: #9ba4bd;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-nav {
  display: grid;
  gap: 4px;
}

.sidebar-nav button {
  width: 100%;
  min-height: 42px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 10px;
  color: #dfe4f2;
  background: transparent;
  cursor: pointer;
  text-align: left;
}

.sidebar-nav button:hover,
.sidebar-nav button.is-active {
  color: #fff;
  background: var(--sidebar-soft);
}

.sidebar-nav .icon,
.topbar .icon,
.button .icon,
.mini-button .icon {
  width: 17px;
  height: 17px;
}

.sidebar__footer {
  margin-top: auto;
  padding: 18px 12px 0;
  border-top: 1px solid rgba(255, 255, 255, 0.12);
  display: grid;
  gap: 10px;
}

.sidebar__user {
  color: #9ba4bd;
  font-size: 12px;
}

.sidebar-action {
  border: 0;
  padding: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--lime);
  background: transparent;
  cursor: pointer;
}

.main {
  min-width: 0;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  min-height: 72px;
  padding: 0 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(12px);
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
}

.topbar__actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.content {
  width: min(1180px, 100%);
  padding: 28px;
}

.page-heading {
  margin-bottom: 24px;
}

.page-heading h2 {
  margin: 0 0 6px;
  font-size: 26px;
}

.page-heading p {
  margin: 0;
  color: var(--muted);
}

.panel {
  margin-bottom: 22px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--panel);
}

.panel__header {
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.panel__header h2,
.panel__header h3 {
  margin: 0;
}

.panel__header p {
  margin: 5px 0 0;
  color: var(--muted);
}

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

.form-grid--three {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.field {
  min-width: 0;
  display: grid;
  gap: 7px;
}

.field--wide {
  grid-column: 1 / -1;
}

.field label,
.field-label {
  color: #344054;
  font-size: 13px;
  font-weight: 600;
}

.field small {
  color: var(--muted);
  font-size: 12px;
}

input,
textarea,
select {
  width: 100%;
  min-height: 42px;
  padding: 10px 12px;
  border: 1px solid #cfd6e3;
  border-radius: 7px;
  color: var(--ink);
  background: #fff;
  outline: none;
}

input:focus,
textarea:focus,
select:focus {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(48, 20, 184, 0.1);
}

textarea {
  min-height: 108px;
  resize: vertical;
}

textarea.tall {
  min-height: 180px;
}

.button,
.mini-button {
  border: 1px solid transparent;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
}

.button {
  min-height: 40px;
  padding: 0 14px;
  font-weight: 600;
}

.button--primary {
  color: #fff;
  background: var(--violet);
}

.button--dark {
  color: #fff;
  background: var(--ink);
}

.button--secondary {
  color: var(--ink);
  border-color: var(--line);
  background: #fff;
}

.button--danger {
  color: var(--danger);
  border-color: #f3c5c1;
  background: #fff9f8;
}

.button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.mini-button {
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--muted);
  border-color: var(--line);
  background: #fff;
}

.mini-button:hover {
  color: var(--ink);
  border-color: #9aa4b6;
}

.mini-button--danger:hover {
  color: var(--danger);
  border-color: #e4a7a1;
}

.section-stack {
  display: grid;
  gap: 18px;
}

.section-card {
  border: 1px solid var(--line);
  border-radius: 9px;
  background: #fbfcfe;
}

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

.section-card__title {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 10px;
}

.drag-handle {
  color: #98a2b3;
}

.section-card__title strong {
  display: block;
}

.section-card__title small {
  color: var(--muted);
}

.section-card__actions {
  display: flex;
  gap: 6px;
}

.section-card__body {
  padding: 18px;
}

.repeater {
  display: grid;
  gap: 12px;
}

.repeater-item {
  padding: 14px;
  border: 1px solid #e0e5ee;
  border-radius: 8px;
  background: #fff;
}

.repeater-item__header {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.repeater-item__header strong {
  font-size: 13px;
}

.split-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.page-list {
  display: grid;
  gap: 8px;
}

.page-row {
  min-height: 58px;
  padding: 10px 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  background: #fff;
}

.page-row strong,
.page-row span {
  display: block;
}

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

.page-row.is-active {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(48, 20, 184, 0.08);
}

.page-row__actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.badge {
  padding: 3px 8px;
  border-radius: 999px;
  color: #344054;
  background: #eef1f6;
  font-size: 11px;
}

.media-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
}

.media-card {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.media-card img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  background: var(--soft);
}

.media-card__body {
  padding: 10px;
}

.media-card code {
  display: block;
  overflow: hidden;
  color: var(--muted);
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.upload-zone {
  min-height: 130px;
  padding: 24px;
  border: 1px dashed #aeb7c7;
  border-radius: 9px;
  display: grid;
  place-items: center;
  text-align: center;
  background: #fbfcfe;
}

.upload-zone input {
  width: auto;
  min-height: 0;
  padding: 0;
  border: 0;
  box-shadow: none;
}

.toast-stack {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 100;
  display: grid;
  gap: 10px;
}

.toast {
  width: min(360px, calc(100vw - 44px));
  padding: 13px 15px;
  border-radius: 8px;
  color: #fff;
  background: #101828;
  box-shadow: 0 18px 50px rgba(15, 20, 40, 0.22);
}

.toast--success {
  background: var(--success);
}

.toast--error {
  background: var(--danger);
}

.empty-state {
  padding: 36px;
  border: 1px dashed #c7cfdb;
  border-radius: 9px;
  color: var(--muted);
  text-align: center;
  background: #fbfcfe;
}

.workspace-grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr) minmax(340px, 420px);
  gap: 18px;
  align-items: start;
}

.editor-pane {
  min-width: 0;
}

.preview-panel {
  position: sticky;
  top: 90px;
  padding: 14px;
}

.preview-panel iframe {
  width: 100%;
  height: calc(100vh - 220px);
  min-height: 620px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.preview-hint {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 12px;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  padding: 28px;
  display: grid;
  place-items: center;
  background: rgba(15, 20, 40, 0.58);
  backdrop-filter: blur(4px);
}

.edit-modal {
  width: min(980px, 100%);
  max-height: calc(100vh - 56px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 12px;
  background: #fff;
  box-shadow: 0 28px 80px rgba(15, 20, 40, 0.28);
}

.edit-modal__header,
.edit-modal__footer {
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid var(--line);
}

.edit-modal__footer {
  justify-content: flex-end;
  border-top: 1px solid var(--line);
  border-bottom: 0;
}

.edit-modal__header h2 {
  margin: 5px 0 0;
  font-size: 19px;
}

.edit-modal__body {
  padding: 20px;
  overflow: auto;
}

.edit-modal__preview {
  width: 100%;
  max-height: 320px;
  margin-bottom: 18px;
  border-radius: 8px;
  object-fit: contain;
  background: var(--soft);
}

.media-picker {
  max-height: 360px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 10px;
  overflow: auto;
}

.media-picker button {
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: #fff;
  cursor: pointer;
  text-align: left;
}

.media-picker button.is-selected {
  border-color: var(--violet);
  box-shadow: 0 0 0 3px rgba(48, 20, 184, 0.1);
}

.media-picker img {
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: cover;
  border-radius: 5px;
}

.media-picker span {
  margin-top: 6px;
  display: block;
  overflow: hidden;
  font-size: 11px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@media (max-width: 1280px) {
  .workspace-grid {
    grid-template-columns: 220px minmax(0, 1fr);
  }

  .preview-panel {
    position: fixed;
    top: 88px;
    right: 16px;
    z-index: 80;
    width: min(430px, calc(100vw - 32px));
    height: calc(100vh - 104px);
    overflow: auto;
    box-shadow: 0 24px 70px rgba(15, 20, 40, 0.24);
  }

  .preview-panel iframe {
    height: calc(100% - 86px);
    min-height: 0;
  }
}

@media (max-width: 980px) {
  .login-page {
    grid-template-columns: 1fr;
  }

  .login-visual {
    min-height: 320px;
    padding: 36px;
  }

  .login-visual h1 {
    font-size: 34px;
  }

  .login-panel {
    padding: 36px 18px;
  }

  .app-layout {
    grid-template-columns: 1fr;
  }

  .sidebar {
    position: static;
    height: auto;
  }

  .sidebar-nav {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .topbar {
    position: static;
    padding: 14px 18px;
    align-items: flex-start;
    flex-direction: column;
  }

  .content {
    padding: 18px;
  }

  .workspace-grid {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    grid-column: auto;
  }
}

@media (max-width: 680px) {
  .form-grid,
  .form-grid--three {
    grid-template-columns: 1fr;
  }

  .panel {
    padding: 18px;
  }

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