:root {
  --ink: #1c1915;
  --muted: #6d655c;
  --paper: #efeae2;
  --card: #fffdf9;
  --line: #e3d8c8;
  --green: #1b4332;
  --green-2: #2d6a4f;
  --soft: #e7f2eb;
  --bad: #9b2c2c;
  --bad-bg: #f8e8e6;
  --term: #12211b;
  --term-text: #d5eee3;
  --shadow: 0 16px 40px rgba(48, 36, 18, 0.07);
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  min-height: 100vh;
  color: var(--ink);
  background: var(--paper);
  font: 16px/1.5 "Segoe UI", "Helvetica Neue", sans-serif;
  display: grid;
  grid-template-columns: 230px 1fr;
}
body.solo { display: block; }

.side {
  background: var(--green);
  color: #f3f7f4;
  padding: 26px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}
.brand { padding: 0 10px 22px; }
.brand strong {
  display: block;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 28px;
  letter-spacing: -0.03em;
}
.brand span { color: #c9ddd2; font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; }
.side a, .side button.linkish {
  display: block;
  color: inherit;
  text-decoration: none;
  border: 0;
  background: transparent;
  width: 100%;
  text-align: left;
  font: inherit;
  padding: 10px 12px;
  border-radius: 12px;
  cursor: pointer;
}
.side a.on, .side a:hover { background: rgba(255,255,255,.12); }
.side form { margin-top: 18px; }

.wrap { padding: 28px 32px 70px; max-width: 1180px; }
h1 {
  margin: 0 0 6px;
  font-family: Georgia, "Iowan Old Style", serif;
  font-size: 36px;
  font-weight: 600;
  letter-spacing: -0.03em;
}
.lede { color: var(--muted); margin-top: 0; }
.card {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow);
  padding: 24px;
  margin-top: 16px;
}
.narrow { max-width: 440px; margin: 10vh auto; }

label, .check { display: grid; gap: 6px; font-size: 14px; }
.grid { display: grid; gap: 14px; }
.two { grid-template-columns: 1fr 1fr; }
.three { grid-template-columns: 1.2fr 1fr auto; align-items: end; }
input, textarea, select {
  width: 100%;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 12px;
  padding: 11px 12px;
  font: inherit;
}
textarea { resize: vertical; }
button, .btn {
  border: 0;
  background: var(--green);
  color: #f4f7f4;
  border-radius: 999px;
  padding: 10px 16px;
  font: inherit;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
button.ghost, .btn.ghost { background: transparent; color: var(--ink); border: 1px solid var(--line); }
button.bad { background: var(--bad); }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.flash { border-radius: 12px; padding: 12px 14px; }
.flash.ok { background: var(--soft); color: var(--green); }
.flash.bad { background: var(--bad-bg); color: var(--bad); }

.toolbar { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.toolbar button {
  background: #fff;
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 7px 10px;
  font-size: 14px;
}
.toolbar button:hover { border-color: var(--green-2); }
.editor-grid { display: grid; grid-template-columns: 1fr; gap: 14px; }
.pane { border: 1px solid var(--line); border-radius: 14px; background: #fff; max-width: 100%; overflow: visible; }
.pane h2 { margin: 0; padding: 10px 12px; font-size: 13px; letter-spacing: .08em; text-transform: uppercase; color: var(--muted); border-bottom: 1px solid var(--line); }
#visual, #preview {
  padding: 18px 16px 28px;
  min-height: 280px;
  height: auto;
  max-height: none;
  overflow: visible;
  outline: none;
}
#visual img, #preview img { max-width: 100%; height: auto; }
#visual.html-locked { background: #f7f4ef; color: var(--muted); }
#preview.raw { padding: 0; }
#preview iframe { width: 100%; height: 70vh; min-height: 520px; border: 0; background: #fff; display: block; }
#visual:empty:before { content: "Write the message here. Bold, links, and buttons work in this view."; color: #9a9186; }
#visual p, #preview p { margin: 0 0 12px; }
#visual a, #preview a { color: #1b4332; }
#visual hr, #preview hr { border: 0; border-top: 1px solid var(--line); margin: 16px 0; }
#source {
  min-height: 220px;
  max-height: none;
  overflow: hidden;
  resize: vertical;
  font-family: Consolas, ui-monospace, monospace;
  font-size: 13px;
  line-height: 1.45;
}
details { margin-top: 10px; }
summary { cursor: pointer; color: var(--muted); }

.checks { display: flex; flex-wrap: wrap; gap: 8px; }
.check {
  grid-template-columns: auto 1fr;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 10px;
  background: #fff;
}
.check small { display: block; color: var(--muted); }

table { width: 100%; border-collapse: collapse; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.card { overflow-x: auto; }
table { min-width: 720px; }
th { color: var(--muted); font-size: 13px; font-weight: 600; }
.stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 10px; }
.stat, a.stat { background: #fff; border: 1px solid var(--line); border-radius: 14px; padding: 12px; color: inherit; text-decoration: none; display: block; }
a.stat:hover { border-color: var(--green); }
.stat b { display: block; font-size: 26px; font-family: Georgia, serif; }
.stat span { color: var(--muted); font-size: 13px; }
.bar { height: 8px; background: #e7e0d6; border-radius: 99px; overflow: hidden; margin: 8px 0 14px; }
.bar i { display: block; height: 100%; background: var(--green-2); width: 0; }

.term {
  background: var(--term);
  color: var(--term-text);
  border-radius: 16px;
  padding: 14px 16px;
  min-height: 160px;
  max-height: 280px;
  overflow: auto;
  margin: 0 0 14px;
  font: 13px/1.55 Consolas, ui-monospace, monospace;
}
.term div.ok { color: #8ee0b2; }
.term div.bad { color: #ffb4b4; }
.term div.miss { color: #f0c36a; }
.term b { color: #9fd7c6; font-weight: 700; }
.domains { display: flex; flex-wrap: wrap; gap: 8px; margin: 12px 0; }
.domains span, .domains strong { border-radius: 999px; padding: 6px 10px; font-size: 13px; background: #fff; border: 1px solid var(--line); }
.domains .best { border-color: #2d6a4f; color: #1b4332; }
.domains .reject { border-color: #9b2c2c; color: #9b2c2c; }
.toasts { position: fixed; right: 16px; bottom: 16px; z-index: 30; display: grid; gap: 8px; max-width: min(360px, calc(100vw - 32px)); }
.toast { background: var(--green); color: #f4f7f4; border-radius: 14px; padding: 12px 14px; box-shadow: var(--shadow); }
.toast.bad { background: var(--bad); }
.pill { border-radius: 99px; padding: 2px 8px; font-size: 12px; }
.pill.ok { background: var(--soft); color: var(--green); }
.pill.bad { background: var(--bad-bg); color: var(--bad); }
.pill.wait { background: #f3efe7; color: var(--muted); }
.muted { color: var(--muted); }
.split-list { display: grid; grid-template-columns: 240px 1fr; gap: 16px; }
.list-nav a { display: block; padding: 8px 0; color: inherit; text-decoration: none; border-bottom: 1px solid var(--line); }
.list-nav a.on { color: var(--green); font-weight: 600; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.chip, a.chip {
  flex: 0 0 auto;
  border: 1px solid var(--line);
  background: #fff;
  color: var(--ink);
  border-radius: 999px;
  padding: 8px 12px;
  text-decoration: none;
  font-size: 14px;
}
.chip.on, a.chip.on { background: var(--green); color: #f4f7f4; border-color: var(--green); }
.chart-wrap svg { width: 100%; height: auto; display: block; }
.legend-row { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 8px; }
.legend { display: flex; align-items: center; gap: 6px; color: var(--muted); font-size: 13px; }
.legend i { width: 18px; height: 3px; border-radius: 99px; display: block; }
.camp h2 { margin: 0; font-size: 22px; }
.wrap { max-width: 1180px; }
h1 { margin-right: auto; }

@media (max-width: 860px) {
  body { display: block; }
  .side {
    position: sticky;
    top: 0;
    z-index: 20;
    height: auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px;
    padding: 10px 10px 8px;
    box-shadow: 0 8px 18px rgba(0, 0, 0, .16);
  }
  .brand { padding: 0 8px 0 4px; margin-right: auto; }
  .brand strong { font-size: 22px; }
  .side a, .side button.linkish { width: auto; padding: 8px 10px; font-size: 15px; }
  .side form { margin: 0; }
  .wrap { padding: 16px 12px 64px; max-width: none; }
  h1 { font-size: 28px; }
  .card { padding: 14px; border-radius: 16px; }
  .two, .three, .stats, .split-list { grid-template-columns: 1fr; }
  .toolbar button, button, .btn { min-height: 42px; }
  .check { width: 100%; }
  table { min-width: 520px; }
  .narrow { margin: 28px 12px; }
  .stat b { font-size: 22px; }
  .camp h2 { font-size: 20px; }
  input, textarea, select { font-size: 16px; }
  .term { max-height: none; min-height: 120px; }
  .pane { overflow-x: auto; -webkit-overflow-scrolling: touch; }
}
