:root {
  color-scheme: light;
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --app-bg: #f4f6f9;
  --surface: #ffffff;
  --surface-muted: #f0f2f5;
  --border: #dde1e7;
  --text: #15171a;
  --muted: #737982;
  --accent: #168acd;
  --accent-strong: #087abb;
  --shadow: 0 20px 60px rgb(23 35 49 / 12%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
}

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

button {
  cursor: pointer;
}

.app-page {
  min-width: 320px;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at 20% -10%, rgb(22 138 205 / 12%), transparent 38rem),
    var(--app-bg);
  padding-bottom: 92px;
}

.app-header {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  padding: 28px 0 22px;
  display: flex;
  align-items: end;
  justify-content: space-between;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
}

h1,
h2 {
  margin: 0;
  letter-spacing: -0.035em;
}

h1 {
  font-size: clamp(28px, 4vw, 42px);
}

h2 {
  font-size: 20px;
}

.draft-badge,
.live-dot {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: rgb(255 255 255 / 70%);
  padding: 7px 11px;
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
}

.workspace {
  width: min(1180px, calc(100% - 40px));
  margin: 0 auto;
  display: grid;
  grid-template-columns: minmax(360px, 0.9fr) minmax(420px, 1.1fr);
  gap: 20px;
  align-items: start;
}

.editor,
.preview-panel {
  border: 1px solid rgb(221 225 231 / 88%);
  border-radius: 24px;
  background: rgb(255 255 255 / 86%);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.editor {
  padding: 24px;
}

.preview-panel {
  position: sticky;
  top: 20px;
  overflow: hidden;
}

.field-group + .field-group,
.device-status-fields,
.profile-fields,
.avatar-upload,
.messages-heading {
  margin-top: 20px;
}

.field-label {
  display: block;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.02em;
}

.segmented {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  border-radius: 12px;
  background: var(--surface-muted);
  padding: 4px;
}

.platform-options {
  grid-template-columns: repeat(3, 1fr);
}

.segment {
  border: 0;
  border-radius: 9px;
  background: transparent;
  padding: 10px 12px;
  color: var(--muted);
  font-weight: 700;
}

.segment.active {
  color: var(--text);
  background: var(--surface);
  box-shadow: 0 2px 8px rgb(20 28 38 / 8%);
}

.profile-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.device-status-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.field input,
.field select,
.message-card textarea,
.message-card input,
.sender-select {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 11px;
  color: var(--text);
  background: var(--surface);
  outline: none;
}

[hidden] {
  display: none !important;
}

.field input,
.field select,
.sender-select,
.message-card input {
  min-height: 42px;
  padding: 0 12px;
}

.field input:focus,
.field select:focus,
.message-card textarea:focus,
.message-card input:focus,
.sender-select:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgb(22 138 205 / 12%);
}

.avatar-upload {
  display: flex;
  align-items: center;
  gap: 12px;
  border: 1px dashed #b7c0cb;
  border-radius: 14px;
  padding: 13px;
  cursor: pointer;
}

.avatar-upload:hover {
  border-color: var(--accent);
}

.avatar-preview {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  color: white;
  background: linear-gradient(145deg, #25a9e8, #6c62e8);
  font-weight: 800;
}

.avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-upload strong,
.avatar-upload small {
  display: block;
}

.avatar-upload strong {
  font-size: 14px;
}

.avatar-upload small,
.messages-heading small {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.avatar-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.messages-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
}

.messages-heading .field-label {
  margin-bottom: 0;
  color: var(--text);
  font-size: 15px;
}

.secondary-button {
  border: 1px solid var(--border);
  border-radius: 10px;
  color: var(--text);
  background: var(--surface);
  padding: 8px 11px;
  font-size: 12px;
  font-weight: 750;
}

.message-editor-list {
  display: grid;
  gap: 10px;
  margin-top: 12px;
}

.message-card {
  border: 1px solid var(--border);
  border-radius: 14px;
  background: #fafbfc;
  padding: 12px;
}

.message-card-top,
.message-card-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.comment-editor-title {
  font-size: 13px;
}

.comment-author-fields {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 9px;
}

.comment-author-fields input {
  min-height: 38px;
  font-size: 12px;
}

.comment-avatar-upload {
  width: fit-content;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 9px;
  color: var(--muted);
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
}

.comment-avatar-preview {
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  color: white;
  background: linear-gradient(145deg, #25a9e8, #6c62e8);
}

.comment-avatar-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.comment-avatar-upload input {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.sender-select {
  width: auto;
  min-height: 34px;
  padding-right: 32px;
  font-size: 12px;
  font-weight: 700;
}

.message-controls {
  display: flex;
  gap: 4px;
}

.message-controls button {
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  color: var(--muted);
  background: var(--surface-muted);
}

.message-controls button:hover {
  color: var(--text);
  background: #e7eaf0;
}

.message-card textarea {
  min-height: 60px;
  margin: 9px 0;
  padding: 10px 11px;
  resize: vertical;
  line-height: 1.4;
}

.message-card input[data-field="time"] {
  width: 112px;
  min-height: 34px;
  font-size: 12px;
}

.delivery-control {
  color: var(--muted);
  font-size: 12px;
}

.delivery-control input {
  width: auto;
  min-height: auto;
}

.preview-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 22px;
}

.live-dot {
  border-color: #cdebd9;
  color: #238a4f;
  background: #effaf3;
}

.device-stage {
  min-width: 0;
  min-height: 680px;
  display: grid;
  place-items: start center;
  overflow: auto;
  border-top: 1px solid var(--border);
  background:
    linear-gradient(45deg, #edf0f4 25%, transparent 25%),
    linear-gradient(-45deg, #edf0f4 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #edf0f4 75%),
    linear-gradient(-45deg, transparent 75%, #edf0f4 75%),
    #f7f8fa;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
  background-size: 16px 16px;
  padding: 30px;
}

#preview-root {
  width: 100%;
  max-width: 430px;
  min-width: 0;
  filter: drop-shadow(0 24px 32px rgb(22 31 42 / 22%));
}

.action-bar {
  position: fixed;
  z-index: 50;
  right: 0;
  bottom: 0;
  left: 0;
  min-height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  border-top: 1px solid rgb(221 225 231 / 90%);
  background: rgb(255 255 255 / 88%);
  backdrop-filter: blur(20px);
  padding: 12px max(20px, calc((100% - 1180px) / 2));
}

.action-bar p {
  margin: 0;
  color: var(--muted);
  font-size: 13px;
}

.primary-button {
  min-width: 160px;
  border: 0;
  border-radius: 12px;
  color: white;
  background: var(--accent);
  padding: 13px 20px;
  font-weight: 800;
  box-shadow: 0 10px 24px rgb(22 138 205 / 24%);
}

.primary-button:hover {
  background: var(--accent-strong);
}

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

.mockup {
  --header-bg: #ffffff;
  --chat-bg: #dbe8ef;
  --chat-text: #111418;
  --incoming-bg: #ffffff;
  --outgoing-bg: #d5f7bf;
  --meta: #73808a;
  width: 100%;
  max-width: 430px;
  aspect-ratio: 430 / 932;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid rgb(0 0 0 / 8%);
  border-radius: 24px;
  color: var(--chat-text);
  background: var(--chat-bg);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Arial, sans-serif;
}

.phone-status-bar {
  min-height: 44px;
  flex: 0 0 44px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--chat-text);
  background: var(--header-bg);
  padding: 4px 38px 0 54px;
}

.phone-status-time {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.phone-status-indicators {
  display: flex;
  align-items: center;
  gap: 8px;
}

.phone-status-icon {
  display: block;
  flex: 0 0 auto;
  object-fit: contain;
}

.theme-light .phone-status-icon {
  filter: brightness(0);
}

.status-cellular {
  width: 20px;
  height: 15px;
}

.status-wifi {
  width: 20px;
  height: 15px;
}

.status-battery {
  width: 30px;
  height: 16px;
}

.phone-status-lte {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.mockup.theme-dark {
  --header-bg: #17212b;
  --chat-bg: #0e1621;
  --chat-text: #f4f6f8;
  --incoming-bg: #182533;
  --outgoing-bg: #2b5278;
  --meta: #91a0ad;
  border-color: rgb(255 255 255 / 10%);
}

.mockup.platform-instagram {
  --chat-bg: #ffffff;
  --incoming-bg: #efefef;
  --outgoing-bg: #3797f0;
  --meta: #8e8e8e;
  border-radius: 24px;
}

.mockup.platform-instagram.theme-dark {
  --header-bg: #000000;
  --chat-bg: #000000;
  --incoming-bg: #262626;
  --outgoing-bg: #3797f0;
  --meta: #a8a8a8;
}

.mockup.platform-telegram_comments {
  --header-bg: #ffffff;
  --chat-bg: #f1f2f4;
  --chat-text: #171717;
  --incoming-bg: #ffffff;
  --meta: #89909a;
  --comment-name: #309d36;
}

.mockup.platform-telegram_comments.theme-dark {
  --header-bg: #1c1c1e;
  --chat-bg: #202020;
  --chat-text: #f3f3f3;
  --incoming-bg: #353535;
  --meta: #a9b0bc;
  --comment-name: #55bd4b;
}

.mockup-header {
  min-height: 72px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid rgb(127 139 150 / 15%);
  background: var(--header-bg);
  padding: 10px 12px;
}

.header-back {
  width: 22px;
  color: #168acd;
  font-size: 38px;
  font-weight: 300;
  line-height: 0.8;
}

.platform-instagram .header-back {
  color: var(--chat-text);
}

.chat-avatar {
  width: 48px;
  height: 48px;
  flex: 0 0 48px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  color: white;
  background: linear-gradient(145deg, #16a7e0, #6757d9);
  font-weight: 800;
}

.platform-instagram .chat-avatar {
  width: 44px;
  height: 44px;
  flex-basis: 44px;
  outline: 2px solid #d62976;
  outline-offset: 2px;
}

.avatar-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.chat-identity {
  min-width: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chat-name {
  overflow: hidden;
  font-size: 16px;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-status {
  overflow: hidden;
  color: #168acd;
  font-size: 12px;
  line-height: 1.4;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.platform-instagram .chat-status {
  color: var(--meta);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  color: #168acd;
}

.platform-instagram .header-actions {
  color: var(--chat-text);
}

.header-action {
  font-size: 22px;
}

.mockup-messages {
  position: relative;
  min-height: 0;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--chat-bg) url("assets/telegram-wallpaper-light.png") center / cover no-repeat;
  overflow: hidden;
  padding: 16px 10px 42px;
}

.theme-dark .mockup-messages {
  background-image: url("assets/telegram-wallpaper-dark.png");
}

.platform-instagram .mockup-messages {
  min-height: 0;
  gap: 8px;
  background: var(--chat-bg);
  padding: 18px 12px 42px;
}

.platform-telegram_comments .mockup-messages {
  min-height: 0;
  gap: 12px;
  background: var(--chat-bg);
  padding: 18px 12px 48px;
}

.date-pill {
  align-self: center;
  border-radius: 999px;
  color: white;
  background: rgb(82 105 119 / 62%);
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 650;
  margin-bottom: 8px;
}

.platform-instagram .date-pill {
  color: var(--meta);
  background: transparent;
  font-weight: 500;
}

.message-row {
  display: flex;
}

.message-row.self {
  justify-content: flex-end;
}

.message-row.other {
  justify-content: flex-start;
}

.message-bubble {
  min-width: 0;
  max-width: 82%;
  border-radius: 16px;
  color: var(--chat-text);
  background: var(--incoming-bg);
  padding: 7px 9px 5px;
  box-shadow: 0 1px 1px rgb(0 0 0 / 8%);
}

.message-row.self .message-bubble {
  background: var(--outgoing-bg);
}

.platform-telegram .message-row.other .message-bubble {
  border-bottom-left-radius: 5px;
}

.platform-telegram .message-row.self .message-bubble {
  border-bottom-right-radius: 5px;
}

.platform-instagram .message-bubble {
  border-radius: 20px;
  padding: 10px 13px;
  box-shadow: none;
}

.platform-instagram .message-row.self .message-bubble {
  color: white;
}

.message-text {
  min-width: 0;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.34;
}

.message-meta {
  min-height: 13px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 3px;
  color: var(--meta);
  margin: 1px 0 0 12px;
  font-size: 9px;
}

.platform-instagram .message-meta {
  display: none;
}

.theme-light.platform-telegram .message-row.self .message-meta {
  color: #599344;
}

.delivery {
  letter-spacing: -3px;
  padding-right: 3px;
}

.comment-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
}

.comment-avatar {
  width: 44px;
  height: 44px;
  flex: 0 0 44px;
  display: grid;
  place-items: center;
  overflow: hidden;
  border-radius: 50%;
  color: white;
  background: linear-gradient(145deg, #16a7e0, #6757d9);
  font-size: 13px;
  font-weight: 800;
}

.comment-bubble {
  position: relative;
  min-width: 0;
  max-width: calc(100% - 54px);
  border-radius: 19px;
  border-bottom-left-radius: 6px;
  color: var(--chat-text);
  background: var(--incoming-bg);
  padding: 9px 12px 8px;
  box-shadow: 0 1px 1px rgb(0 0 0 / 10%);
}

.comment-bubble::before {
  position: absolute;
  bottom: 0;
  left: -8px;
  width: 14px;
  height: 14px;
  background: var(--incoming-bg);
  clip-path: polygon(100% 0, 100% 100%, 0 100%);
  content: "";
}

.comment-author {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 2px;
}

.comment-author-name {
  min-width: 0;
  overflow: hidden;
  color: var(--comment-name);
  font-size: 15px;
  line-height: 1.2;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.comment-author-badge,
.fake-badge {
  flex: 0 0 auto;
  border-radius: 999px;
  padding: 3px 7px;
  font-size: 9px;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.04em;
}

.comment-author-badge {
  color: var(--comment-name);
  background: color-mix(in srgb, var(--comment-name) 20%, transparent);
}



.comment-body {
  min-width: 0;
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.comment-text {
  min-width: 0;
  flex: 1;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 15px;
  line-height: 1.3;
}

.comment-time {
  flex: 0 0 auto;
  color: var(--meta);
  font-size: 11px;
  line-height: 1.3;
}


.mockup-composer {
  min-height: 60px;
  display: flex;
  align-items: center;
  gap: 9px;
  border-top: 1px solid rgb(127 139 150 / 15%);
  background: var(--header-bg);
  padding: 9px 12px;
}

.composer-input {
  min-height: 38px;
  flex: 1;
  display: flex;
  align-items: center;
  border: 1px solid rgb(127 139 150 / 30%);
  border-radius: 20px;
  color: var(--meta);
  padding: 0 14px;
  font-size: 14px;
}

.composer-icon {
  color: #168acd;
  font-size: 21px;
}

.platform-instagram .composer-icon {
  color: var(--chat-text);
}

.render-page {
  width: max-content;
  min-width: 430px;
  min-height: 100vh;
  background: transparent;
  padding: 0;
}

#export-root {
  width: 430px;
}

.render-page .mockup {
  border: 0;
  border-radius: 0;
}

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

  .preview-panel {
    position: static;
    order: -1;
  }

  .device-stage {
    min-height: auto;
    max-height: 640px;
  }
}

@media (max-width: 560px) {
  .app-header,
  .workspace {
    width: min(100% - 24px, 1180px);
  }

  .app-header {
    padding-top: 18px;
  }

  .editor {
    padding: 16px;
  }

  .editor,
  .preview-panel {
    border-radius: 18px;
  }

  .profile-fields,
  .device-status-fields {
    grid-template-columns: 1fr;
  }

  .platform-options .segment {
    padding-inline: 6px;
    font-size: 12px;
  }

  .comment-author-fields {
    grid-template-columns: 1fr;
  }

  .device-stage {
    padding: 14px;
  }

  .mockup {
    border-radius: 18px;
  }

  .action-bar {
    padding: 10px 12px max(10px, env(safe-area-inset-bottom));
  }

  .action-bar p {
    display: none;
  }

  .primary-button {
    width: 100%;
  }
}
