:root {
  color-scheme: light;
  --bg: #f6f4ef;
  --panel: #fffdfa;
  --ink: #24211d;
  --muted: #766f66;
  --line: #ddd6cc;
  --accent: #1f7a66;
  --accent-strong: #125846;
  --rose: #d85f77;
  --shadow: 0 24px 70px rgba(53, 43, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(216, 95, 119, 0.16), transparent 34%),
    linear-gradient(315deg, rgba(31, 122, 102, 0.18), transparent 38%),
    var(--bg);
  font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.login-page {
  display: grid;
  place-items: center;
  padding: 18px;
}

.login-card {
  width: min(420px, 100%);
  padding: 28px;
  background: rgba(255, 253, 250, 0.92);
  border: 1px solid rgba(221, 214, 204, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

button,
input,
textarea {
  font: inherit;
}

.shell {
  display: grid;
  grid-template-columns: minmax(360px, 1fr) minmax(320px, 440px);
  gap: 28px;
  width: min(1180px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.composer,
.preview {
  background: rgba(255, 253, 250, 0.88);
  border: 1px solid rgba(221, 214, 204, 0.9);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.composer {
  padding: 28px;
}

.preview {
  display: grid;
  min-height: calc(100vh - 64px);
  place-items: center;
  padding: 26px;
}

.topbar,
.settings header,
.actions,
.phone-head {
  display: flex;
  align-items: center;
}

.topbar-actions {
  display: flex;
  gap: 8px;
}

.topbar,
.settings header {
  justify-content: space-between;
  gap: 16px;
}

.eyebrow {
  margin: 0 0 4px;
  color: var(--accent);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

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

h1 {
  font-size: clamp(34px, 6vw, 62px);
  line-height: 0.96;
}

h2 {
  font-size: 26px;
}

h3 {
  margin: 0 0 12px;
  color: var(--accent-strong);
  font-size: 16px;
  letter-spacing: 0;
}

.icon-button {
  display: grid;
  width: 42px;
  height: 42px;
  place-items: center;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
}

.platforms {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 26px 0 20px;
}

.platforms label {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  gap: 8px;
  padding: 8px 13px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-weight: 700;
}

.field {
  display: grid;
  gap: 8px;
  margin: 16px 0;
}

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 750;
}

textarea,
input {
  width: 100%;
  color: var(--ink);
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
  outline: none;
}

textarea {
  min-height: 220px;
  resize: vertical;
  padding: 16px;
  line-height: 1.45;
}

input {
  min-height: 44px;
  padding: 10px 12px;
}

textarea:focus,
input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(31, 122, 102, 0.15);
}

.dropzone {
  display: grid;
  min-height: 96px;
  place-items: center;
  margin: 16px 0;
  color: var(--accent-strong);
  background: rgba(31, 122, 102, 0.08);
  border: 1px dashed rgba(31, 122, 102, 0.5);
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
  text-align: center;
}

.dropzone input {
  display: none;
}

.instagram-url {
  display: none;
}

.instagram-url.is-visible {
  display: grid;
}

.actions {
  gap: 12px;
  margin-top: 22px;
}

.editor-tools {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 12px;
  margin-top: -8px;
  color: var(--muted);
  font-size: 13px;
}

.editor-tools span {
  margin-left: auto;
}

.field-hint {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.emoji-panel {
  display: grid;
  gap: 6px;
  margin: 12px 0 0;
  padding: 10px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.emoji-panel[hidden] {
  display: none;
}

.emoji-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.emoji-tab {
  min-height: 32px;
  padding: 0 10px;
  color: var(--ink);
  background: #fffdfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
}

.emoji-tab.is-active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
  gap: 6px;
}

.emoji-button {
  display: grid;
  min-width: 38px;
  min-height: 38px;
  place-items: center;
  background: #fffdfa;
  border: 1px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  font-size: 22px;
}

.emoji-button:hover {
  border-color: rgba(31, 122, 102, 0.35);
  background: rgba(31, 122, 102, 0.08);
}

.primary,
.secondary {
  min-height: 46px;
  padding: 0 18px;
  border-radius: 8px;
  cursor: pointer;
  font-weight: 800;
}

.primary {
  color: white;
  background: var(--accent);
  border: 1px solid var(--accent);
}

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

.primary:disabled {
  cursor: wait;
  opacity: 0.68;
}

.secondary {
  color: var(--ink);
  background: white;
  border: 1px solid var(--line);
}

.small {
  min-height: 34px;
  padding: 0 12px;
  font-size: 13px;
}

.status {
  display: block;
  min-height: 24px;
  margin-top: 18px;
  color: var(--muted);
  font-size: 14px;
}

.status.is-error {
  color: #9b263d;
}

.status.is-success {
  color: var(--accent-strong);
}

.phone {
  width: min(100%, 360px);
  min-height: 620px;
  overflow: hidden;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 28px;
  box-shadow: 0 20px 50px rgba(42, 32, 20, 0.14);
}

.preview-tabs {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 4px;
  padding: 10px 10px 0;
}

.preview-tab,
.library-tab {
  min-height: 34px;
  color: var(--muted);
  background: #fffdfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 850;
}

.preview-tab.is-active,
.library-tab.is-active {
  color: #ffffff;
  background: var(--accent);
  border-color: var(--accent);
}

.phone-head {
  gap: 12px;
  padding: 18px;
}

.avatar {
  display: grid;
  width: 44px;
  height: 44px;
  place-items: center;
  color: #ffffff;
  background: var(--rose);
  border-radius: 50%;
  font-weight: 900;
}

.phone-head small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
}

.media-preview {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  min-height: 310px;
  gap: 2px;
  background: linear-gradient(135deg, rgba(216, 95, 119, 0.18), rgba(31, 122, 102, 0.15));
}

.media-preview:empty::before {
  content: "Медиа";
  grid-column: 1 / -1;
  place-self: center;
  color: rgba(36, 33, 29, 0.45);
  font-weight: 800;
}

.media-preview img,
.media-preview video {
  width: 100%;
  height: 180px;
  object-fit: cover;
}

.media-preview.has-one {
  grid-template-columns: 1fr;
}

.media-preview.has-one img,
.media-preview.has-one video {
  height: 360px;
}

.text-preview {
  min-height: 120px;
  margin: 0;
  padding: 18px;
  color: var(--ink);
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.text-preview a {
  color: var(--accent-strong);
  font-weight: 750;
  text-decoration: underline;
  text-underline-offset: 3px;
}

dialog {
  width: min(560px, calc(100vw - 24px));
  padding: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(36, 33, 29, 0.38);
}

.settings {
  padding: 22px;
}

.settings-group {
  margin: 18px 0;
  padding: 16px;
  background: rgba(31, 122, 102, 0.05);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.settings-group .field:last-child {
  margin-bottom: 0;
}

.library {
  margin-top: 24px;
  padding-top: 18px;
  border-top: 1px solid var(--line);
}

.library-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}

.library-tab {
  padding: 0 12px;
  font-size: 13px;
}

.library-list {
  display: grid;
  gap: 10px;
}

.library-empty,
.library-item {
  padding: 12px;
  background: #ffffff;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.library-empty {
  color: var(--muted);
  font-size: 14px;
}

.library-item {
  display: grid;
  gap: 8px;
}

.library-item strong {
  font-size: 14px;
}

.library-item p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.library-meta {
  color: var(--muted);
  font-size: 12px;
}

.library-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.library-actions button {
  min-height: 32px;
  padding: 0 10px;
  background: #fffdfa;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 800;
}

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

  .preview {
    min-height: auto;
  }
}

@media (max-width: 520px) {
  .shell {
    width: min(100vw - 18px, 1180px);
    padding: 9px 0;
  }

  .composer,
  .preview {
    padding: 16px;
  }

  .actions {
    align-items: stretch;
    flex-direction: column;
  }

  .editor-tools {
    align-items: stretch;
    flex-direction: column;
  }
}
