:root {
  --yellow: #f2bd2d;
  --yellow-soft: #ffdb70;
  --yellow-dark: #2d2408;
  --surface: #171a19;
  --surface-strong: #202321;
  --border: #41443d;
  --muted: #9ca29e;
  --text: #f5f5f3;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
}

body {
  margin: 0;
  overflow: hidden;
  background: #000;
  color: var(--text);
  font: 14px Inter, Arial, sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button {
  color: inherit;
}

[hidden] {
  display: none !important;
}

.app {
  display: grid;
  grid-template-rows: 66px minmax(0, 1fr);
  width: 100%;
  height: 100%;
  background: #000;
}

.bar {
  position: relative;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 0;
  padding: 10px 18px;
  background: #000;
}

.collection-filters {
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: calc(100% - 36px);
  height: 42px;
  padding: 3px;
  overflow-x: auto;
  border: 1px solid #45422f;
  border-radius: 12px;
  background: #222624;
  scrollbar-width: none;
}

.collection-filters::-webkit-scrollbar {
  display: none;
}

.collection-button {
  flex: 0 0 auto;
  height: 34px;
  padding: 0 15px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: #aeb3b0;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.55px;
  white-space: nowrap;
  cursor: pointer;
  transition: color 0.18s, background 0.18s, box-shadow 0.18s;
}

.collection-button:hover {
  color: #fff;
}

.collection-button.active {
  background: var(--yellow);
  color: #171409;
  box-shadow: 0 4px 14px #0005;
}

.collection-button:focus-visible,
.button:focus-visible,
.back-button:focus-visible,
.email-card:focus-visible,
.search-box:focus-within {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

.editor-actions {
  position: absolute;
  right: 18px;
  display: flex;
  align-items: center;
  gap: 9px;
}

.button {
  height: 40px;
  padding: 0 13px;
  border: 1px solid #45422f;
  border-radius: 10px;
  background: #242826;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
  transition: filter 0.18s, color 0.18s, background 0.18s;
}

.button:hover {
  filter: brightness(1.14);
}

.button.primary {
  border-color: var(--yellow);
  background: var(--yellow);
  color: #18150a;
}

.view-button {
  display: grid;
  place-items: center;
  width: 42px;
  padding: 0;
  color: #aeb3b0;
}

.view-button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.view-button.active {
  border-color: var(--yellow);
  background: var(--yellow);
  color: #171409;
}

.content {
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
}

.email-library {
  height: 100%;
  padding: 18px 30px 56px;
  overflow: auto;
  background: #000;
}

.library-inner {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.library-toolbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 26px;
  padding: 6px 0 14px;
  background: linear-gradient(#000 72%, transparent);
}

.search-box {
  display: flex;
  align-items: center;
  width: min(460px, 100%);
  height: 44px;
  padding: 0 14px;
  border: 1px solid #343832;
  border-radius: 13px;
  background: #151817;
  color: #7f867f;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.search-box:focus-within {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px #f2bd2d16;
}

.search-box svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-right: 10px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
}

.search-box input {
  width: 100%;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: 0;
  background: transparent;
  color: #f3f4f2;
}

.search-box input::placeholder {
  color: #6f756f;
}

.search-box input::-webkit-search-cancel-button {
  filter: invert(0.75);
}

.library-count {
  flex: 0 0 auto;
  color: #747a75;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.7px;
  text-transform: uppercase;
}

.email-groups {
  display: grid;
  gap: 34px;
}

.email-group {
  min-width: 0;
}

.email-group__header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 0 0 13px;
}

.email-group__header h2 {
  margin: 0;
  color: #dfe2df;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.95px;
  text-transform: uppercase;
}

.email-group__count {
  display: inline-grid;
  place-items: center;
  min-width: 24px;
  height: 22px;
  padding: 0 7px;
  border: 1px solid #353932;
  border-radius: 999px;
  background: #141715;
  color: #777d78;
  font-size: 10px;
  font-weight: 900;
}

.email-group__line {
  height: 1px;
  flex: 1;
  background: linear-gradient(90deg, #33372f, transparent);
}

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

.email-card {
  position: relative;
  display: grid;
  grid-template-columns: 112px minmax(0, 1fr) 32px;
  align-items: center;
  gap: 20px;
  min-width: 0;
  min-height: 192px;
  padding: 19px;
  overflow: hidden;
  border: 1px solid #494736;
  border-radius: 18px;
  background: linear-gradient(145deg, #252823, #191c1a);
  color: #fff;
  text-align: left;
  cursor: pointer;
  box-shadow: 0 16px 40px #0003;
  transition: transform 0.18s, border-color 0.18s, box-shadow 0.18s;
}

.email-card:hover {
  transform: translateY(-4px);
  border-color: var(--yellow);
  box-shadow: 0 20px 48px #0007;
}

.card-preview {
  position: relative;
  display: block;
  width: 112px;
  height: 154px;
  overflow: hidden;
  border: 1px solid #44483f;
  border-radius: 10px;
  background: #090a0a;
  box-shadow: 0 7px 22px #0007;
}

.card-preview::after {
  position: absolute;
  inset: 0;
  border-radius: 9px;
  box-shadow: inset 0 0 0 1px #ffffff0d;
  content: "";
  pointer-events: none;
}

.card-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  background: radial-gradient(circle at 50% 35%, #25291f, #080909 74%);
}

.card-preview img[data-contain="true"] {
  padding: 16px;
  object-fit: contain;
}

.card-preview iframe {
  display: block;
  width: 700px;
  height: 962px;
  border: 0;
  background: #050606;
  pointer-events: none;
  transform: scale(0.16);
  transform-origin: top left;
}

.card-preview__loading,
.card-preview__error {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 12px;
  color: #747a74;
  font-size: 10px;
  font-weight: 800;
  line-height: 1.4;
  text-align: center;
}

.card-preview__loading::before {
  width: 22px;
  height: 22px;
  border: 2px solid #353a34;
  border-top-color: var(--yellow);
  border-radius: 50%;
  content: "";
  animation: spin 0.8s linear infinite;
}

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

.card-content {
  min-width: 0;
}

.card-eyebrow {
  display: block;
  margin-bottom: 7px;
  overflow: hidden;
  color: var(--yellow-soft);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1.05px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.email-card h3 {
  display: -webkit-box;
  margin: 0 0 8px;
  overflow: hidden;
  color: #f8f8f6;
  font: 700 23px/1.12 Arial, Helvetica, sans-serif;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.email-card p {
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: #aeb3af;
  font-size: 12px;
  line-height: 1.5;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.card-footer {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 11px;
  overflow: hidden;
}

.card-tag,
.selected-template__tags span,
.template-variables__list code {
  max-width: 100%;
  padding: 5px 7px;
  overflow: hidden;
  border: 1px solid #3b403a;
  border-radius: 999px;
  background: #171a18;
  color: #8e958f;
  font-size: 9px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.card-tag.imported {
  border-color: #54481e;
  background: #241f10;
  color: #d9bc65;
}

.card-arrow {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #32352e;
  color: var(--yellow);
  font-size: 20px;
  transition: color 0.18s, background 0.18s, transform 0.18s;
}

.email-card:hover .card-arrow {
  background: var(--yellow);
  color: #171409;
  transform: translateX(3px);
}

.empty-state {
  display: grid;
  place-items: center;
  min-height: 360px;
  border: 1px dashed #32362f;
  border-radius: 18px;
  color: #707670;
  text-align: center;
}

.empty-state__icon {
  margin-bottom: 10px;
  color: var(--yellow);
  font-size: 24px;
}

.empty-state strong {
  margin-bottom: 6px;
  color: #dfe2df;
  font-size: 16px;
}

.empty-state span:last-child {
  font-size: 12px;
}

.workspace {
  display: grid;
  grid-template-columns: 320px minmax(420px, 1fr);
  width: 100%;
  height: 100%;
  min-height: 0;
}

.side {
  min-height: 0;
  padding: 18px;
  overflow: auto;
  border-right: 1px solid #373b35;
  background: #141716;
}

.back-button {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  height: 40px;
  margin: 0 0 17px;
  padding: 0 12px;
  border: 1px solid #454a45;
  border-radius: 10px;
  background: #222624;
  color: #d1d4d1;
  font-weight: 800;
  cursor: pointer;
}

.back-button:hover {
  border-color: var(--yellow);
  color: var(--yellow-soft);
}

.selected-template {
  margin-bottom: 17px;
  padding: 0 2px;
}

.selected-template__eyebrow {
  display: block;
  margin-bottom: 7px;
  color: var(--yellow-soft);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1.05px;
}

.selected-template h1 {
  margin: 0;
  color: #f3f4f2;
  font: 700 23px/1.16 Arial, Helvetica, sans-serif;
}

.selected-template__tags {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.message-meta,
.editing-guide,
.template-variables {
  margin: 0 0 16px;
  padding: 14px;
  border: 1px solid #454a45;
  border-radius: 14px;
  background: linear-gradient(145deg, #20231f, #191c1a);
  box-shadow: 0 14px 32px #0003;
}

.message-meta {
  border-color: #4b4630;
}

.message-meta__head,
.field-label,
.variant-choice {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.message-meta__head {
  margin: 0 0 14px;
}

.message-meta__kicker,
.template-variables__label {
  color: var(--yellow-soft);
  font-size: 9px;
  font-weight: 900;
  letter-spacing: 1.15px;
}

.ab-switch {
  position: relative;
  display: flex;
  align-items: center;
  gap: 7px;
  color: #d4d7d3;
  font-size: 9px;
  font-weight: 800;
  white-space: nowrap;
  cursor: pointer;
}

.ab-switch input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.ab-switch__track {
  position: relative;
  width: 30px;
  height: 17px;
  border: 1px solid #565b56;
  border-radius: 99px;
  background: #303431;
  transition: 0.18s;
}

.ab-switch__track::after {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: #9ba09b;
  content: "";
  transition: 0.18s;
}

.ab-switch input:checked + .ab-switch__track {
  border-color: var(--yellow);
  background: #5a4710;
}

.ab-switch input:checked + .ab-switch__track::after {
  left: 15px;
  background: var(--yellow);
}

.ab-switch input:focus-visible + .ab-switch__track {
  outline: 2px solid var(--yellow);
  outline-offset: 2px;
}

.meta-field {
  display: block;
  margin: 0 0 12px;
}

.field-label {
  margin: 0 0 6px;
  color: #d7dad7;
  font-size: 10px;
  font-weight: 800;
}

.field-count {
  color: #7f857f;
  font-size: 9px;
  font-weight: 600;
}

.meta-input,
.meta-textarea {
  display: block;
  width: 100%;
  padding: 10px 11px;
  border: 1px solid #484d49;
  border-radius: 9px;
  outline: 0;
  background: #111413;
  color: #fff;
  font: 600 12px/1.3 Inter, Arial, sans-serif;
  transition: border-color 0.18s, box-shadow 0.18s;
}

.meta-input:focus,
.meta-textarea:focus {
  border-color: var(--yellow);
  box-shadow: 0 0 0 3px #f2bd2d1c;
}

.meta-textarea {
  min-height: 58px;
  resize: vertical;
  font-weight: 500;
}

.variant-choice {
  margin: 0 0 12px;
  padding: 8px 10px;
  border: 1px solid #3f443f;
  border-radius: 9px;
  background: #141715;
}

.variant-choice .field-label {
  margin: 0;
}

.variant-switch {
  display: flex;
  padding: 2px;
  border-radius: 7px;
  background: #343834;
}

.variant-button {
  width: 25px;
  height: 21px;
  border: 0;
  border-radius: 5px;
  background: transparent;
  color: #9da29d;
  font-size: 9px;
  font-weight: 900;
  cursor: pointer;
}

.variant-button.active {
  background: var(--yellow);
  color: #171409;
}

.meta-help {
  margin: -2px 0 0;
  color: #8e948f;
  font-size: 9px;
  line-height: 1.35;
}

.template-variables__list {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 10px;
}

.template-variables__list code {
  border-color: #3d423d;
  color: #b6bdb7;
  font-family: Consolas, monospace;
  font-weight: 600;
}

.editing-guide .pill {
  display: inline-block;
  margin: 0 0 11px;
}

.editing-guide h2 {
  margin: 0 0 8px;
  font-size: 18px;
}

.editing-guide p {
  margin: 0;
  color: #aeb4b0;
  font-size: 12px;
  line-height: 1.55;
}

.pill {
  padding: 6px 9px;
  border-radius: 99px;
  background: var(--yellow-dark);
  color: var(--yellow-soft);
  font-size: 9px;
  font-weight: 900;
}

.status {
  padding: 0 2px 12px;
  color: #999f99;
  font-size: 11px;
  line-height: 1.45;
}

.stage {
  min-width: 0;
  overflow: auto;
  padding: 10px 0;
  background:
    repeating-linear-gradient(
      45deg,
      #24231e,
      #24231e 12px,
      #20201c 12px,
      #20201c 24px
    );
}

.canvas {
  width: min(100%, 715px);
  min-height: 0;
  margin: 0 auto;
  overflow: hidden;
  border-radius: 8px;
  background: #050606;
  box-shadow: 0 20px 60px #0008;
  transition: width 0.25s;
}

.canvas iframe {
  display: block;
  width: 100%;
  height: calc(100vh - 122px);
  border: 0;
  background: #050606;
}

.phone .canvas {
  width: 390px;
}

.is-editing .collection-filters {
  max-width: calc(100% - 500px);
}

@media (max-width: 1100px) {
  .collection-button {
    padding: 0 10px;
    font-size: 10px;
  }

  .email-cards {
    grid-template-columns: 1fr;
  }

  .library-inner {
    width: min(700px, 100%);
  }

  .is-editing .collection-filters {
    justify-content: flex-start;
    max-width: calc(100% - 460px);
  }
}

@media (max-width: 820px) {
  .app {
    grid-template-rows: auto minmax(0, 1fr);
  }

  .bar {
    min-height: 64px;
    padding-right: 10px;
    padding-left: 10px;
  }

  .collection-filters {
    justify-content: flex-start;
    width: 100%;
  }

  .is-editing .collection-filters {
    display: none;
  }

  .editor-actions {
    position: static;
    margin: 0 auto;
  }

  .workspace {
    grid-template-columns: minmax(250px, 300px) minmax(390px, 1fr);
  }

  .email-library {
    padding-right: 16px;
    padding-left: 16px;
  }
}

@media (max-width: 620px) {
  .library-toolbar {
    align-items: stretch;
    flex-direction: column;
    gap: 10px;
  }

  .library-count {
    padding-left: 2px;
  }

  .email-card {
    grid-template-columns: 88px minmax(0, 1fr) 26px;
    gap: 14px;
    min-height: 156px;
    padding: 14px;
  }

  .card-preview {
    width: 88px;
    height: 126px;
  }

  .card-preview iframe {
    transform: scale(0.13);
  }

  .email-card h3 {
    font-size: 19px;
  }

  .card-arrow {
    width: 26px;
    height: 26px;
  }
}
