:root {
  color-scheme: light;
  --bg: #f3f1ec;
  --card: #fffcf8;
  --ink: #1c1915;
  --muted: #6d655c;
  --line: #e6dfd4;
  --accent: #1f4d3a;
  --accent-ink: #f7f3ea;
  --danger: #9f2d20;
  --ok-bg: #e5f2ea;
  --ok-ink: #14532d;
  --err-bg: #fde8e4;
  --label: #3c362f;
  font-family: ui-sans-serif, system-ui, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 18px;
  line-height: 1.5;
  color: var(--ink);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: #ebe4d8;
  background-image:
    radial-gradient(ellipse 42rem 32rem at 8% -4%, rgba(255, 250, 240, 0.95), transparent 70%),
    radial-gradient(ellipse 36rem 28rem at 100% 0%, rgba(176, 204, 184, 0.55), transparent 68%),
    radial-gradient(ellipse 40rem 30rem at 78% 108%, rgba(214, 168, 122, 0.28), transparent 70%),
    radial-gradient(rgba(28, 25, 21, 0.055) 1px, transparent 1px);
  background-size: auto, auto, auto, 22px 22px;
  background-attachment: fixed;
}

.topbar,
main {
  width: min(1080px, calc(100% - 32px));
  margin: 0 auto;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  padding: 28px 0 18px;
}

.eyebrow {
  margin: 0 0 4px;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--accent);
}

h1,
h2 {
  margin: 0;
  font-weight: 650;
  letter-spacing: -0.02em;
}

h1 {
  font-size: 34px;
  line-height: 1.2;
}

h2 {
  margin-bottom: 14px;
  font-size: 22px;
  line-height: 1.3;
}

h3 {
  margin: 0 0 12px;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
  line-height: 1.3;
  text-transform: none;
  color: var(--accent);
}

.mark {
  display: inline-block;
  margin-right: 14px;
}

.panel-head {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.panel-head h2 {
  margin: 0;
}

#regenerate {
  margin-left: auto;
}

.target {
  margin: 0;
  max-width: 46ch;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-size: 16px;
  line-height: 1.4;
  color: var(--muted);
}

code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  color: var(--ink);
  word-break: break-all;
}

main,
form {
  display: grid;
  gap: 28px;
}

main {
  padding-bottom: 40px;
}

.panel {
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: 0 10px 28px rgba(28, 25, 21, 0.05);
}

.selectors,
.param-grid,
.field {
  display: grid;
  gap: 6px;
}

.selectors {
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

#fields {
  display: grid;
  gap: 16px;
}

.param-group {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #faf7f2;
}

.param-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}

.param-group .cart {
  margin: 0;
  padding: 0;
  border: 0;
  background: transparent;
}

.param-group .cart legend {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.field:has(textarea),
.cart {
  grid-column: 1 / -1;
}

label {
  display: grid;
  align-items: start;
  align-content: start;
  gap: 6px;
  font-size: 16px;
  font-weight: 650;
  line-height: 1.35;
  letter-spacing: 0;
  color: var(--label);
}

input,
select,
textarea {
  width: 100%;
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  border: 1px solid #d9d1c6;
  border-radius: 10px;
  padding: 0 12px;
  font-size: 18px;
  font-weight: 500;
  line-height: 46px;
  color: var(--ink);
  background: #fff;
}

textarea {
  height: auto;
  min-height: 96px;
  max-height: none;
  padding: 12px;
  line-height: 1.45;
}

input:focus,
select:focus,
textarea:focus {
  outline: 2px solid #c9deD2;
  border-color: var(--accent);
}

textarea {
  resize: vertical;
  word-break: break-all;
  line-height: 1.45;
}

.field:has(input[readonly]) input,
#preview {
  background: #f6f3ee;
  color: #4e4840;
}

#preview {
  min-height: 92px;
  background: #241f1a;
  color: #f6f1e8;
  border-color: #241f1a;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  font-weight: 450;
  line-height: 1.55;
}

.field small,
.cart small {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.45;
  color: #5e574e;
}

.cart {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #faf7f2;
}

.cart legend {
  padding: 0 6px;
  font-size: 16px;
  font-weight: 700;
  color: var(--label);
}

.cart-rows {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}

.cart-row {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr)) auto;
  gap: 8px;
  align-items: end;
}

.required {
  color: var(--danger);
}

.send-bar {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 16px;
  margin-top: 16px;
}

#status {
  margin: 0 auto 0 0;
  padding: 10px 14px;
  border-radius: 12px;
  background: var(--ok-bg);
  color: var(--ok-ink);
  font-size: 16px;
  font-weight: 650;
  line-height: 1.45;
}

#status:empty {
  display: none;
}

#status.error {
  background: var(--err-bg);
  color: var(--danger);
  font-weight: 600;
  white-space: pre-wrap;
}

#history dd {
  white-space: pre-wrap;
}

button {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  background: #efeae2;
  color: var(--ink);
}

button:hover {
  background: #e6dfd4;
}

button[type="submit"] {
  flex: 0 0 auto;
  min-width: 168px;
  min-height: 48px;
  padding: 12px 22px;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 17px;
  line-height: 1.2;
  box-shadow: 0 8px 18px rgba(31, 77, 58, 0.22);
}

button[type="submit"]:hover {
  background: #173d2e;
}

button[type="submit"]:focus-visible {
  outline: 3px solid #c9ded2;
  outline-offset: 3px;
}

button[type="submit"]:disabled {
  opacity: 0.55;
  cursor: progress;
}

.cart-add,
.cart-remove {
  background: transparent;
  border-color: var(--line);
}

.cart-remove {
  color: var(--danger);
}

#history {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

#history:empty::before {
  content: "📭\a0\a0\a0No sends yet.";
  color: var(--muted);
  font-size: 16px;
}

#history li {
  display: grid;
  gap: 12px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
}

.log-head {
  display: flex;
  align-items: center;
  gap: 10px;
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ok-bg);
  color: var(--ok-ink);
  font-size: 16px;
  font-weight: 700;
}

#history li.fail .badge {
  background: var(--err-bg);
  color: var(--danger);
}

.log-head time {
  color: var(--muted);
  font-size: 16px;
}

#history dl {
  display: grid;
  grid-template-columns: 128px 1fr;
  gap: 6px 12px;
  margin: 0;
}

#history dt {
  color: var(--label);
  font-size: 18px;
  font-weight: 700;
}

#history dd {
  margin: 0;
  font-size: 17px;
  line-height: 1.45;
}

#history details code {
  display: block;
  margin-top: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 15px;
  line-height: 1.5;
  word-break: break-all;
}

@media (max-width: 800px) {
  .topbar,
  .selectors,
  .param-grid,
  .cart-row {
    grid-template-columns: 1fr;
    display: grid;
  }

  .topbar,
  .panel-head,
  .send-bar {
    align-items: stretch;
  }

  .send-bar {
    flex-direction: column;
  }

  #send {
    width: 100%;
  }

  #status {
    margin: 0;
  }

  #history dl {
    grid-template-columns: 1fr;
  }
}
