* {
  box-sizing: border-box;
}

:root {
  --black: #050505;
  --white: #ffffff;
  --gray-100: #f5f5f5;
  --gray-200: #e8e8e8;
  --gray-300: #d5d5d5;
  --gray-500: #777777;
  --gray-700: #333333;
  --border: #dedede;
}

html,
body {
  margin: 0;
  padding: 0;
  background: #fff;
  color: #080808;
  font-family: Arial, Helvetica, sans-serif;
}

body {
  min-height: 100vh;
}

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

button {
  cursor: pointer;
}


/* SIDEBAR */

.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: 230px;
  height: 100vh;
  background: #050505;
  color: #fff;
  border-right: 1px solid #202020;
  z-index: 1000;
  display: flex;
  flex-direction: column;
}

.brand {
  padding: 30px 25px 28px;
  border-bottom: 1px solid #202020;
}

.brand-name {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.brand-subtitle {
  margin-top: 5px;
  font-size: 9px;
  letter-spacing: 0.22em;
  color: #777;
}

.nav {
  padding-top: 15px;
}

.nav a {
  position: relative;
  display: block;
  padding: 13px 25px;
  color: #888;
  text-decoration: none;
  font-size: 13px;
  transition: color 0.2s ease;
}

.nav a:hover {
  color: #fff;
}

.nav a.active {
  color: #fff;
}

.nav a.active::before {
  content: "";
  position: absolute;
  left: 0;
  top: 8px;
  bottom: 8px;
  width: 2px;
  background: #fff;
}

.signout {
  margin: auto 25px 25px;
  padding: 12px 0;
  background: transparent;
  border: 1px solid #333;
  color: #aaa;
  text-align: left;
  padding-left: 15px;
}

.signout:hover {
  color: #fff;
  border-color: #666;
}


/* MOBILE HEADER */

.mobile-header {
  display: none;
}


/* MAIN */

.main {
  margin-left: 230px;
  min-height: 100vh;
  padding: 45px 55px 70px;
  max-width: 1450px;
}


/* HEADER */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 30px;
  padding-bottom: 32px;
  border-bottom: 1px solid var(--border);
}

.back-link {
  display: inline-block;
  margin-bottom: 20px;
  color: #777;
  text-decoration: none;
  font-size: 12px;
}

.back-link:hover {
  color: #000;
}

.page-header h1 {
  margin: 0;
  font-size: 32px;
  font-weight: 500;
  letter-spacing: -0.04em;
}

.page-header p {
  margin: 10px 0 0;
  color: #777;
  font-size: 13px;
}

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


/* BUTTONS */

.primary-button,
.secondary-button {
  min-height: 42px;
  padding: 0 18px;
  border-radius: 0;
  font-size: 12px;
  border: 1px solid #111;
}

.primary-button {
  background: #050505;
  color: #fff;
}

.primary-button:hover {
  background: #222;
}

.secondary-button {
  background: #fff;
  color: #111;
  border-color: #ccc;
}

.secondary-button:hover {
  border-color: #111;
}

.small-button {
  min-height: 34px;
  padding: 0 12px;
}


/* SECTION */

.section {
  padding: 42px 0;
  border-bottom: 1px solid var(--border);
}

.section-heading {
  display: flex;
  gap: 20px;
  margin-bottom: 30px;
}

.section-number {
  font-size: 11px;
  color: #999;
  padding-top: 4px;
  min-width: 24px;
}

.section-heading h2 {
  margin: 0;
  font-size: 19px;
  font-weight: 500;
  letter-spacing: -0.02em;
}

.section-heading p {
  margin: 7px 0 0;
  color: #777;
  font-size: 12px;
  line-height: 1.6;
}


/* FIELDS */

.field {
  margin-bottom: 24px;
}

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

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

.field label {
  display: block;
  margin-bottom: 9px;
  font-size: 11px;
  color: #444;
  letter-spacing: 0.04em;
}

.field input,
.field textarea,
.field select {
  width: 100%;
  border: 1px solid #ccc;
  background: #fff;
  color: #111;
  border-radius: 0;
  outline: none;
}

.field input,
.field select {
  height: 45px;
  padding: 0 13px;
}

.field textarea {
  padding: 13px;
  resize: vertical;
  line-height: 1.6;
}

.field input:focus,
.field textarea:focus,
.field select:focus {
  border-color: #111;
}

.field small {
  display: block;
  margin-top: 7px;
  color: #888;
  font-size: 11px;
  line-height: 1.5;
}


/* DELIVERY */

.delivery-switch {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  border-top: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
}

.delivery-option {
  position: relative;
  min-height: 90px;
  padding: 18px;
  text-align: left;
  background: #fff;
  border: 0;
  border-right: 1px solid #ccc;
}

.delivery-option:last-child {
  border-right: 0;
}

.delivery-option:hover {
  background: #fafafa;
}

.delivery-option.active {
  background: #050505;
  color: #fff;
}

.delivery-option.active::after {
  content: "";
  position: absolute;
  left: 18px;
  right: 18px;
  bottom: 0;
  height: 2px;
  background: #fff;
}

.delivery-title {
  display: block;
  font-size: 13px;
  font-weight: 600;
}

.delivery-description {
  display: block;
  margin-top: 8px;
  color: #888;
  font-size: 11px;
  line-height: 1.5;
}

.delivery-option.active .delivery-description {
  color: #aaa;
}


/* EDITOR */

.editor-label-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.editor-label-row select {
  width: 130px;
  height: 32px;
  font-size: 11px;
  margin-bottom: 9px;
}

.message-editor {
  min-height: 270px;
  font-family: "Courier New", monospace;
  font-size: 12px;
}


/* PREVIEW */

.email-preview-area {
  border-top: 1px solid #eee;
  padding-top: 20px;
}

.email-preview {
  margin-top: 20px;
  border: 1px solid #ddd;
  padding: 30px;
  background: #fafafa;
  min-height: 150px;
  overflow: auto;
}

.hidden {
  display: none !important;
}


/* RULE BUILDER */

.rule-builder {
  border-top: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
}

.rule-row {
  display: grid;
  grid-template-columns: 40px 1fr 1fr;
  gap: 20px;
  padding: 25px 0;
  border-bottom: 1px solid #eee;
}

.rule-index {
  font-size: 11px;
  color: #999;
  padding-top: 30px;
}

.conditions-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 25px 0 15px;
}

.conditions-header h3 {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
}

.conditions-header p {
  margin: 5px 0 0;
  font-size: 11px;
  color: #888;
}

.condition-row {
  display: grid;
  grid-template-columns: 1fr 150px 1fr 35px;
  gap: 10px;
  align-items: end;
  padding: 10px 0;
}

.condition-row select,
.condition-row input {
  height: 42px;
  width: 100%;
  border: 1px solid #ccc;
  background: #fff;
  padding: 0 10px;
  border-radius: 0;
  outline: none;
  font-size: 12px;
}

.remove-condition {
  width: 35px;
  height: 42px;
  border: 1px solid #ccc;
  background: #fff;
  color: #777;
}

.remove-condition:hover {
  color: #000;
  border-color: #111;
}

.rule-divider {
  margin: 25px 0;
  border-top: 1px solid #eee;
}


/* TIMING */

.timing-block {
  margin-top: 30px;
  padding-top: 25px;
  border-top: 1px solid #eee;
}

.timing-title {
  font-size: 12px;
  margin-bottom: 15px;
}

.timing-options {
  display: flex;
  gap: 25px;
  flex-wrap: wrap;
}

.timing-option {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #444;
}

.timing-option input {
  accent-color: #000;
}

.delay-fields {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  max-width: 360px;
}

.delay-fields input,
.delay-fields select {
  height: 42px;
  border: 1px solid #ccc;
  border-radius: 0;
  background: #fff;
  padding: 0 12px;
}

.delay-fields input {
  width: 120px;
}

.delay-fields select {
  flex: 1;
}

.timing-note {
  color: #888;
  font-size: 11px;
  margin-top: 12px;
}


/* BOTTOM */

.bottom-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 35px;
}


/* TOAST */

.toast {
  position: fixed;
  right: 25px;
  bottom: 25px;
  background: #050505;
  color: #fff;
  padding: 14px 18px;
  font-size: 12px;
  z-index: 3000;
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px);
  transition: 0.2s ease;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}


/* RESPONSIVE */

@media (max-width: 900px) {

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s ease;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .mobile-header {
    position: fixed;
    display: flex;
    align-items: center;
    width: 100%;
    height: 62px;
    top: 0;
    left: 0;
    background: #050505;
    color: #fff;
    z-index: 900;
    border-bottom: 1px solid #222;
  }

  .menu-button {
    width: 62px;
    height: 62px;
    border: 0;
    border-right: 1px solid #222;
    background: transparent;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 5px;
  }

  .menu-button span {
    width: 18px;
    height: 1px;
    background: #fff;
  }

  .mobile-title {
    padding-left: 18px;
    font-size: 11px;
    letter-spacing: 0.15em;
  }

  .overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 950;
    display: none;
  }

  .overlay.show {
    display: block;
  }

  .main {
    margin-left: 0;
    padding: 100px 25px 60px;
  }

  .page-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .header-actions {
    width: 100%;
  }

  .header-actions button {
    flex: 1;
  }

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

  .delivery-switch {
    grid-template-columns: 1fr;
  }

  .delivery-option {
    border-right: 0;
    border-bottom: 1px solid #ccc;
  }

  .delivery-option:last-child {
    border-bottom: 0;
  }

  .rule-row {
    grid-template-columns: 30px 1fr;
  }

  .rule-row .field:last-child {
    grid-column: 2;
  }

  .condition-row {
    grid-template-columns: 1fr;
  }

  .remove-condition {
    width: 100%;
  }

  .bottom-actions {
    flex-direction: column;
  }

  .bottom-actions button {
    width: 100%;
  }
}


@media (max-width: 520px) {

  .main {
    padding-left: 18px;
    padding-right: 18px;
  }

  .page-header h1 {
    font-size: 26px;
  }

  .section {
    padding: 32px 0;
  }

  .section-heading {
    gap: 12px;
  }

  .section-number {
    min-width: 20px;
  }

  .timing-options {
    flex-direction: column;
    gap: 14px;
  }

}