/* Brutalist treatment of the Southern View Media brand:
   cream ground, slate ink, coral accent, Fraunces italic display,
   hard borders + offset shadows, no rounded corners anywhere. */

:root {
  --cream: #FAF6EE;
  --sand: #EAE3D3;
  --coral: #F88379;
  --ink: #32373C;
  --border: 3px solid var(--ink);
  --shadow: 6px 6px 0 var(--ink);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  background: var(--cream);
  color: var(--ink);
  font-family: "Figtree", sans-serif;
  line-height: 1.45;
  padding: 0 2rem 4rem;
  max-width: 72rem;
  margin: 0 auto;
}

em, .serif { font-family: "Fraunces", serif; font-style: italic; }

h1, h2, h3 {
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: -0.02em;
  line-height: 1.05;
}
h1 { font-size: 3rem; margin: 2.5rem 0 1.5rem; }
h1 em { text-transform: none; font-weight: 500; }
h2 { font-size: 1.4rem; margin: 2.5rem 0 1rem; border-bottom: var(--border); padding-bottom: 0.4rem; }

a { color: var(--ink); text-decoration-thickness: 2px; text-underline-offset: 3px; }
a:hover { background: var(--coral); }

/* ---- chrome ---- */

.masthead {
  display: flex; justify-content: space-between; align-items: center;
  border-bottom: var(--border);
  padding: 1.2rem 0;
}
.wordmark {
  font-size: 1.6rem; font-weight: 800; text-transform: uppercase;
  text-decoration: none;
}
.wordmark:hover { background: transparent; }
.wordmark svg { height: 2.1rem; width: auto; display: block; }
.masthead nav { display: flex; align-items: center; gap: 0.5rem; }
.masthead nav form { margin: 0; }
.masthead nav a, .masthead nav button {
  font-family: "IBM Plex Mono", monospace; font-size: 0.85rem; font-weight: 400;
  text-transform: uppercase; text-decoration: none; line-height: 1.45;
  border: var(--border); padding: 0.4rem 0.9rem; margin: 0;
  background: var(--cream); color: var(--ink); box-shadow: none;
}
.masthead nav a:hover, .masthead nav button:hover {
  background: var(--coral); transform: none; box-shadow: none;
}

.colophon {
  margin-top: 5rem; border-top: var(--border); padding-top: 1rem;
  font-size: 0.9rem;
}

.flash {
  border: var(--border); box-shadow: var(--shadow);
  padding: 0.8rem 1.2rem; margin: 1.5rem 0; font-weight: 600;
  background: var(--sand);
}
.flash--alert { background: var(--coral); }

/* ---- cards, tables, badges ---- */

.card {
  border: var(--border); box-shadow: var(--shadow);
  background: #fff; padding: 1.5rem; margin-bottom: 2rem;
}
.card--sand { background: var(--sand); }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 16rem), 1fr)); gap: 1.5rem; }
.grid > * { min-width: 0; }
.grid--stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.template-grid .card { margin-bottom: 0; overflow-wrap: anywhere; }
.template-grid h2 { margin-top: 0; }
.page-heading {
  display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between;
  gap: 1rem; margin: 2rem 0;
}
.page-heading h1 { margin: 0; min-width: 0; }
.page-heading .btn { flex-shrink: 0; max-width: 100%; }
main h1, .card p { overflow-wrap: anywhere; }
.empty-state { border: var(--border); background: var(--sand); padding: 1.5rem; }
.preview-subject { margin-bottom: 1rem; overflow-wrap: anywhere; }

.stat { border: var(--border); background: #fff; padding: 1rem; }
.stat b { display: block; font-size: 2.2rem; font-weight: 800; }
.stat span {
  font-family: "IBM Plex Mono", monospace; font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.08em;
}
.stat .meter { height: 10px; border: 2px solid var(--ink); background: var(--sand); margin-top: 0.6rem; }
.stat .meter i { display: block; height: 100%; background: var(--ink); }

.table-scroll { overflow-x: auto; border: var(--border); background: #fff; position: relative; }
table { border-collapse: collapse; width: 100%; }
th {
  font-family: "IBM Plex Mono", monospace; font-size: 0.75rem;
  text-transform: uppercase; letter-spacing: 0.08em; text-align: left;
  background: var(--ink); color: var(--cream); padding: 0.6rem 0.9rem;
}
td { padding: 0.6rem 0.9rem; border-top: 2px solid var(--sand); }
tr:hover td { background: var(--cream); }

.badge {
  font-family: "IBM Plex Mono", monospace; font-size: 0.7rem;
  text-transform: uppercase; border: 2px solid var(--ink);
  padding: 0.1rem 0.45rem; white-space: nowrap;
}
.badge--good { background: #b8d8b8; }
.badge--warn { background: var(--sand); }
.badge--bad  { background: var(--coral); }

/* ---- forms & buttons ---- */

.btn, button, input[type="submit"] {
  display: inline-block;
  font-family: "IBM Plex Mono", monospace; font-size: 0.9rem; font-weight: 600;
  text-transform: uppercase; text-decoration: none; cursor: pointer;
  border: var(--border); box-shadow: var(--shadow);
  background: var(--coral); color: var(--ink);
  padding: 0.7rem 1.4rem;
}
.btn:hover, button:hover, input[type="submit"]:hover {
  transform: translate(2px, 2px); box-shadow: 4px 4px 0 var(--ink);
  background: var(--coral);
}
.btn--ghost { background: var(--cream); }
.btn--ghost:hover { background: var(--sand); }
/* Destructive actions: quiet until hovered, so they never read as the main action. */
.btn--danger { background: var(--cream); box-shadow: none; border-style: dashed; }
.btn--danger:hover { background: var(--coral); box-shadow: none; transform: none; }
.btn::after { content: " \2192"; }
.btn--noarrow::after { content: ""; }

form.stacked label {
  display: block; margin: 1.2rem 0 0.3rem;
  font-family: "IBM Plex Mono", monospace; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
form.stacked input[type="text"], form.stacked input[type="email"],
form.stacked input[type="password"],
form.stacked textarea, form.stacked select, form.stacked input[type="file"] {
  width: 100%; border: var(--border); background: #fff;
  font-family: "Figtree", sans-serif; font-size: 1rem; padding: 0.6rem 0.8rem;
}
form.stacked textarea.code { font-family: "IBM Plex Mono", monospace; font-size: 0.85rem; }
form.stacked .check { display: flex; gap: 0.7rem; align-items: flex-start; margin: 1.2rem 0; }
form.stacked .check input { width: 1.4rem; height: 1.4rem; accent-color: var(--coral); margin-top: 0.2rem; }
form.stacked .hint { font-size: 0.85rem; margin-top: 0.3rem; }
form.stacked input[type="submit"] { margin-top: 1.6rem; }
form.stacked fieldset { margin-top: 1.5rem; padding: 1rem; border: var(--border); }
form.stacked legend { padding: 0 0.4rem; font-weight: 600; }
form.stacked fieldset label.check { margin: 0.6rem 0; text-transform: none; letter-spacing: normal; }
form.stacked .check input { flex-shrink: 0; }

.errors {
  border: var(--border); background: var(--coral);
  padding: 1rem 1.2rem; margin: 1.5rem 0; font-weight: 600;
}
.errors ul { margin-left: 1.2rem; }

.meta {
  font-family: "IBM Plex Mono", monospace; font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.05em;
}
.toolbar { display: flex; gap: 1rem; flex-wrap: wrap; align-items: center; margin: 1.5rem 0; }
.toolbar > form { margin: 0; }
.toolbar .spacer { flex: 1; }
/* Inline inputs inside toolbars (schedule, test send, delivery filter). */
.toolbar input[type="email"], .toolbar input[type="datetime-local"], .toolbar select {
  border: var(--border); background: #fff; font: inherit; padding: 0.6rem 0.8rem; min-height: 3rem;
}
.toolbar label { font-family: "IBM Plex Mono", monospace; font-size: 0.8rem; text-transform: uppercase; font-weight: 600; }
.action-panel { border: var(--border); background: #fff; padding: 0 1.2rem; margin: 1.5rem 0; }
.action-panel .toolbar { margin: 1.2rem 0; }
.action-panel .schedule-form { border-top: 2px solid var(--sand); padding-top: 1.2rem; }
.grid--spaced, .grid:has(+ .table-scroll) { margin-bottom: 1.5rem; }
.share-link { margin: 0.8rem 0 1rem; }
.share-link label { display: block; font-size: 0.85rem; margin-bottom: 0.3rem; }
.share-link input { width: 100%; border: var(--border); background: var(--sand); font-family: "IBM Plex Mono", monospace; font-size: 0.85rem; padding: 0.5rem 0.7rem; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.row-actions { display: flex; gap: 0.6rem; align-items: center; justify-content: flex-end; white-space: nowrap; }
.row-actions form { margin: 0; }
.row-actions a, .row-actions button {
  font-family: "IBM Plex Mono", monospace; font-size: 0.75rem; text-transform: uppercase;
  border: 2px solid var(--ink); background: var(--cream); box-shadow: none; padding: 0.2rem 0.55rem; text-decoration: none;
}
.row-actions a:hover, .row-actions button:hover { background: var(--coral); transform: none; box-shadow: none; }
.backbar { margin: 1rem 0 -1.2rem; }
.backbar a { font-family: "IBM Plex Mono", monospace; font-size: 0.8rem; text-transform: uppercase; font-weight: 600; text-decoration: none; }
.backbar + main > .meta:first-child { margin-top: 1.6rem; }
.filter-bar { align-items: flex-end; }
.filter-field { flex: 1 1 14rem; min-width: 0; }
.filter-field label { display: block; margin-bottom: 0.4rem; font-weight: 600; }
.filter-field input, .filter-field select {
  width: 100%; min-width: 0; border: var(--border); background: #fff;
  font: inherit; padding: 0.7rem 0.8rem;
}
.filter-bar input[type="submit"] { min-height: 3rem; }
:is(a, button, input, select, textarea):focus-visible { outline: 3px solid var(--ink); outline-offset: 4px; }

iframe.preview {
  width: 100%; height: 28rem; border: var(--border); background: #fff;
  box-shadow: var(--shadow); display: block; margin-bottom: 2rem;
}

/* ---- small screens ---- */
@media (max-width: 700px) {
  body { padding: 0 1rem 3rem; }
  h1 { font-size: 2.1rem; margin: 1.6rem 0 1.2rem; }
  h2 { font-size: 1.2rem; }

  .masthead { flex-wrap: wrap; row-gap: 0.8rem; padding: 1rem 0; }
  .masthead nav { flex-wrap: wrap; }
  .masthead nav a, .masthead nav button { font-size: 0.72rem; padding: 0.3rem 0.6rem; }
  .wordmark { font-size: 1.25rem; }
  .wordmark svg { height: 1.6rem; }

  .card { padding: 1rem; }
  .grid { gap: 1rem; }
  .grid:has(.stat) { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .grid.grid--stats { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .page-heading { align-items: flex-start; margin: 1.6rem 0; }
  .filter-field { flex-basis: 100%; }
  .stat { padding: 0.7rem; }
  .stat b { font-size: 1.5rem; }
  .stat span { font-size: 0.62rem; letter-spacing: 0.03em; }

  th, td { padding: 0.5rem 0.6rem 0.5rem 0.6rem; }
  iframe.preview { height: 20rem; }
  .flash { padding: 0.7rem 0.9rem; }
  .btn, button, input[type="submit"] { padding: 0.6rem 1rem; font-size: 0.85rem; }
}
