:root {
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: #16312f;
  background: #eef3f2;
  font-synthesis: none;
  --ink: #16312f;
  --muted: #637775;
  --line: #d8e3e1;
  --paper: #ffffff;
  --primary: #087f75;
  --primary-dark: #05645d;
  --soft: #e6f3f1;
  --warning: #a85c00;
  --danger: #b42318;
  --shadow: 0 10px 30px rgba(23, 58, 55, 0.08);
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: #eef3f2; }
button, input, textarea { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .48; }
h1, h2, h3, p { margin-top: 0; }
h1 { font-size: clamp(1.65rem, 2.2vw, 2.35rem); line-height: 1.12; margin-bottom: .5rem; }
h2 { font-size: 1.1rem; margin-bottom: 0; }
h3 { font-size: .95rem; }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); white-space: nowrap; border: 0; }
.muted { color: var(--muted); }
.eyebrow { margin: 0 0 .35rem; color: var(--primary); font-size: .72rem; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; }

.topbar {
  position: sticky; top: 0; z-index: 10; min-height: 70px; display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; color: white; background: #0d3733; border-bottom: 1px solid rgba(255,255,255,.12);
}
.brand { display: flex; align-items: center; gap: 11px; font-weight: 780; letter-spacing: -.015em; }
.brand--large { color: var(--ink); font-size: 1.05rem; }
.brand-mark { display: grid; place-items: center; width: 34px; height: 34px; border-radius: 10px; color: white; background: #10a295; font-family: Georgia, serif; font-size: 1.45rem; font-weight: 800; }
.topbar__actions { display: flex; align-items: center; gap: 10px; }
.safety-badge, .demo-badge { padding: 7px 10px; border: 1px solid rgba(255,255,255,.22); border-radius: 999px; font-size: .75rem; font-weight: 750; }
.demo-badge { color: #fff3d0; background: rgba(255,185,73,.15); }

.workspace { display: grid; grid-template-columns: 310px minmax(0, 1fr); min-height: calc(100vh - 70px); }
.campaigns-panel { position: sticky; top: 70px; height: calc(100vh - 70px); overflow: auto; padding: 24px 18px; background: #f8fbfa; border-right: 1px solid var(--line); }
.panel-heading, .section-heading, .editor-header { display: flex; justify-content: space-between; align-items: flex-start; gap: 16px; }
.count-badge { min-width: 30px; padding: 5px 8px; text-align: center; border-radius: 999px; color: var(--primary-dark); background: var(--soft); font-size: .78rem; font-weight: 800; }
.search-field input, label input, textarea { width: 100%; border: 1px solid #cbd9d7; border-radius: 9px; background: white; color: var(--ink); outline: none; }
.search-field input { margin: 18px 0 12px; padding: 11px 12px; }
input:focus, textarea:focus, .visual-editor:focus { border-color: #0b8f83; box-shadow: 0 0 0 3px rgba(11,143,131,.14); }
.campaign-list { display: grid; gap: 8px; }
.campaign-row { display: grid; gap: 5px; width: 100%; padding: 13px; text-align: left; border: 1px solid transparent; border-radius: 11px; color: inherit; background: transparent; }
.campaign-row:hover { background: #edf5f3; }
.campaign-row--selected { background: white; border-color: #bad6d2; box-shadow: 0 4px 18px rgba(24,63,59,.08); }
.campaign-row__title { font-weight: 760; }
.campaign-row__subject { overflow: hidden; color: var(--muted); font-size: .82rem; text-overflow: ellipsis; white-space: nowrap; }
.campaign-row__meta { display: flex; justify-content: space-between; align-items: center; color: #7a8b89; font-size: .72rem; }

.editor-panel { min-width: 0; padding: 28px; }
.campaign-form { display: grid; gap: 20px; max-width: 1500px; margin: 0 auto; }
.editor-header { align-items: center; }
.editor-header__meta { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; color: var(--muted); font-size: .8rem; }
.editor-header__actions { display: flex; gap: 8px; }
.status-pill { display: inline-flex; padding: 4px 8px; border-radius: 999px; font-size: .7rem; font-weight: 800; text-transform: uppercase; }
.status-pill--draft { color: #77500a; background: #fff0c2; }
.status-pill--finished { color: #2f6661; background: #dfeceb; }
.status-pill--running { color: white; background: var(--primary); }
.button--full { width: 100%; margin-bottom: 12px; }

.button { border: 1px solid transparent; border-radius: 9px; padding: 10px 14px; font-weight: 760; }
.button--primary { color: white; background: var(--primary); }
.button--primary:hover { background: var(--primary-dark); }
.button--secondary { color: var(--primary-dark); background: white; border-color: #bdd3d0; }
.button--quiet { color: inherit; background: transparent; border-color: currentColor; }
.topbar .button--quiet { color: white; border-color: rgba(255,255,255,.28); }
.button--warning { color: white; background: #a85c00; }

.summary-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 12px; }
.summary-card, .card { background: var(--paper); border: 1px solid var(--line); box-shadow: var(--shadow); }
.summary-card { display: grid; gap: 4px; padding: 18px; border-radius: 13px; }
.summary-card span { color: var(--muted); font-size: .78rem; }
.summary-card strong { font-size: 1.4rem; }
.summary-card small { overflow: hidden; color: #728380; text-overflow: ellipsis; white-space: nowrap; }
.card { border-radius: 14px; }

.form-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 16px; padding: 20px; }
label, legend { color: #425a57; font-size: .78rem; font-weight: 750; }
label input, textarea { display: block; margin-top: 7px; padding: 11px 12px; font-weight: 500; }
.lists-field { grid-column: 1 / -1; margin: 0; padding: 0; border: 0; }
.list-options { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.check-row { display: flex; align-items: center; gap: 8px; padding: 9px 11px; border: 1px solid var(--line); border-radius: 9px; background: #f9fbfb; }
.check-row input { width: auto; margin: 0; }

.content-layout { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(380px, .9fr); align-items: start; gap: 18px; }
.composer-card, .preview-card { padding: 20px; }
.design-assistant { margin: 18px 0 12px; padding: 16px; border: 1px solid #cfe0dd; border-radius: 12px; background: linear-gradient(135deg,#f5faf9,#eef6f5); }
.design-assistant__header { display: flex; justify-content: space-between; align-items: flex-start; gap: 20px; margin-bottom: 14px; }
.design-assistant__header h3 { margin: 0; color: var(--ink); }
.design-assistant__header > p { max-width: 360px; margin: 0; color: var(--muted); font-size: .76rem; line-height: 1.5; }
.design-group { display: grid; grid-template-columns: 118px minmax(0,1fr); align-items: start; gap: 10px; padding: 9px 0; border-top: 1px solid rgba(124,157,152,.18); }
.design-label { padding-top: 7px; color: #506764; font-size: .72rem; font-weight: 800; text-transform: uppercase; letter-spacing: .04em; }
.design-options { display: flex; flex-wrap: wrap; gap: 7px; }
.design-chip { min-height: 34px; padding: 7px 10px; border: 1px solid #bdd3d0; border-radius: 8px; color: #244945; background: white; font-size: .78rem; font-weight: 700; }
.design-chip:hover { border-color: var(--primary); color: var(--primary-dark); box-shadow: 0 3px 12px rgba(8,127,117,.1); }
.color-chip { display: grid; place-items: center; width: 35px; height: 35px; padding: 4px; border: 2px solid transparent; border-radius: 50%; background: white; }
.color-chip span { display: block; width: 23px; height: 23px; border-radius: 50%; }
.color-chip.active { border-color: var(--ink); }
.toolbar { display: flex; flex-wrap: wrap; gap: 5px; margin: 18px 0 10px; padding: 7px; border: 1px solid var(--line); border-radius: 10px; background: #f4f8f7; }
.toolbar button, .preview-switch button { min-height: 32px; padding: 5px 9px; border: 1px solid transparent; border-radius: 7px; color: #31514e; background: transparent; }
.toolbar button:hover, .preview-switch button:hover, .preview-switch button.active { background: white; border-color: #c8d9d6; }
.visual-editor { min-height: 410px; padding: 26px; overflow: auto; border: 1px solid #cbd9d7; border-radius: 10px; background: white; outline: none; font: 15px/1.65 Arial, sans-serif; }
.visual-editor h1 { font-size: 2rem; }
.visual-editor h2 { font-size: 1.45rem; }
.visual-editor a { color: var(--primary); }
.visual-editor img { max-width: 100%; height: auto; }
.visual-editor table { width: 100%; max-width: 100%; }
.visual-editor figure { margin-left: 0; margin-right: 0; }
.visual-editor .email-button { display: inline-block; padding: 11px 17px; border-radius: 8px; color: white; background: var(--primary); text-decoration: none; font-weight: 760; }
.plain-text-panel { margin-top: 14px; border: 1px solid var(--line); border-radius: 10px; }
.plain-text-panel summary { padding: 13px; cursor: pointer; font-weight: 750; }
.plain-text-panel textarea { margin: 0; border: 0; border-top: 1px solid var(--line); border-radius: 0 0 10px 10px; font: 13px/1.5 ui-monospace, SFMono-Regular, Consolas, monospace; }
.plain-text-actions { padding: 0 12px 10px; }

.preview-switch { display: flex; padding: 3px; border: 1px solid var(--line); border-radius: 9px; }
.preview-frame-wrap { max-width: 100%; margin: 18px auto; transition: max-width .2s ease; }
.preview-frame-wrap--mobile { max-width: 390px; }
.preview-frame { width: 100%; height: 570px; border: 1px solid var(--line); border-radius: 11px; background: #f3f6f6; }
.validation-box { padding: 14px; border: 1px solid var(--line); border-radius: 10px; background: #f8fbfa; }
.validation-box p { margin: 7px 0 0; font-size: .82rem; }
.validation-error { color: var(--danger); }
.validation-warning { color: var(--warning); }
.validation-ok { color: var(--primary-dark); }
.validation-box--error { border-color: #e4b4ae; background: #fff8f7; }

.test-panel { margin-top: 14px; padding: 16px; border: 1px solid #e1c69a; border-radius: 10px; background: #fffaf0; }
.test-panel p { color: #76561f; font-size: .82rem; }
.test-row { display: grid; grid-template-columns: minmax(0,1fr) auto; gap: 8px; }
.test-row input { padding: 11px; border: 1px solid #d8c29d; border-radius: 9px; }

.send-review { border: 2px solid #e0a63d; background: #fffaf0; }
.send-review__warning { margin: 0 0 18px; padding: 14px 16px; border-radius: 10px; background: #fff0cf; color: #6a4310; font-weight: 700; }
.review-facts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1px; margin: 0 0 20px; overflow: hidden; border: 1px solid #ded7c7; border-radius: 10px; background: #ded7c7; }
.review-facts div { padding: 13px 15px; background: #fff; }
.review-facts dt { margin-bottom: 4px; color: #647776; font-size: 12px; font-weight: 700; text-transform: uppercase; }
.review-facts dd { margin: 0; overflow-wrap: anywhere; }
.review-ok { color: #087f75; font-weight: 700; }
.review-blocked { color: #a33a2b; font-weight: 700; }
.send-confirmation { display: grid; gap: 14px; }
.send-confirmation > label:first-child { display: flex; align-items: flex-start; gap: 9px; }
.send-confirmation > label:first-child input { width: auto; margin-top: 3px; }
.button--danger { background: #a52f22; color: #fff; }
.button--danger:disabled { background: #c9b9b6; color: #fff; }

.notice { max-width: 1500px; margin: 12px auto 0; padding: 11px 14px; border: 1px solid; border-radius: 9px; }
.notice--info { color: #174d61; background: #e9f5fa; border-color: #badde9; }
.notice--success { color: #1b5b48; background: #eaf7f1; border-color: #bce0d2; }
.notice--warning { color: #764f13; background: #fff8e8; border-color: #e8cf9d; }
.notice--error { color: #8b251d; background: #fff0ee; border-color: #e7b2ad; }

.empty-state { display: grid; place-items: center; min-height: 65vh; text-align: center; color: var(--muted); }
.empty-state h1 { color: var(--ink); }
.empty-state__icon { display: grid; place-items: center; width: 64px; height: 64px; margin-bottom: 14px; border-radius: 18px; color: var(--primary); background: white; box-shadow: var(--shadow); font-size: 1.8rem; }
.empty { padding: 20px; color: var(--muted); text-align: center; }

.login-shell { display: grid; place-items: center; min-height: 100vh; padding: 24px; background: radial-gradient(circle at 20% 10%, #d9eeeb, transparent 32%), #eef3f2; }
.login-card { width: min(430px, 100%); padding: 34px; border: 1px solid var(--line); border-radius: 18px; background: white; box-shadow: 0 22px 70px rgba(20,60,56,.13); }
.login-card .eyebrow { margin-top: 28px; }
.stack { display: grid; gap: 15px; margin-top: 24px; }

@media (max-width: 1100px) {
  .workspace { grid-template-columns: 250px minmax(0,1fr); }
  .content-layout { grid-template-columns: 1fr; }
  .preview-card { min-width: 0; }
}

@media (max-width: 760px) {
  .topbar { padding: 0 14px; }
  .topbar .brand span:last-child { display: none; }
  .safety-badge { display: none; }
  .workspace { display: block; }
  .campaigns-panel { position: static; height: auto; padding: 16px; border-right: 0; border-bottom: 1px solid var(--line); }
  .campaign-list { grid-template-columns: repeat(2, minmax(0,1fr)); }
  .editor-panel { padding: 16px; }
  .editor-header { align-items: flex-start; flex-direction: column; }
  .editor-header__actions { width: 100%; }
  .editor-header__actions .button { flex: 1; }
  .summary-grid, .form-grid { grid-template-columns: 1fr; }
  .lists-field { grid-column: auto; }
  .test-row { grid-template-columns: 1fr; }
  .review-facts { grid-template-columns: 1fr; }
  .design-assistant__header { display: block; }
  .design-assistant__header > p { margin-top: 8px; }
  .design-group { grid-template-columns: 1fr; }
  .design-label { padding-top: 0; }
}

@media (max-width: 480px) {
  .campaign-list { grid-template-columns: 1fr; }
  .summary-grid { grid-template-columns: 1fr; }
  .composer-card, .preview-card, .form-grid { padding: 14px; }
  .visual-editor { min-height: 330px; padding: 18px; }
}
