:root {
  color-scheme: light;
  --primary: #8f7265;
  --secondary: #c5a880;
  --surface: #faf8f5;
  --surface-container: #f6f4f0;
  --on-surface: #2e2926;
  --on-surface-variant: #776a65;
  --outline: #d7ccc8;
  --danger: #b3261e;
  --shadow: 0 24px 70px rgba(46, 41, 38, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    linear-gradient(135deg, rgba(197, 168, 128, 0.18), transparent 32%),
    linear-gradient(225deg, rgba(143, 114, 101, 0.14), transparent 36%),
    var(--surface);
  color: var(--on-surface);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

.page-shell {
  width: min(100%, 1040px);
  min-height: 100vh;
  margin: 0 auto;
  padding: 32px 18px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 22px;
}

.tool-panel,
.history-panel {
  width: 100%;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid rgba(197, 168, 128, 0.28);
  border-radius: 18px;
  box-shadow: var(--shadow);
  padding: clamp(24px, 4vw, 44px);
}

.heading {
  max-width: 720px;
  margin-bottom: 30px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 5vw, 56px);
  line-height: 1;
  letter-spacing: 0;
}

.intro {
  margin: 16px 0 0;
  color: var(--on-surface-variant);
  line-height: 1.7;
}

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

.field {
  display: grid;
  gap: 8px;
}

.field span,
.preview span {
  color: var(--primary);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.wide {
  grid-column: 1 / -1;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--outline);
  border-radius: 12px;
  background: var(--surface);
  color: var(--on-surface);
  padding: 14px 16px;
  outline: none;
  transition: border-color 160ms ease, box-shadow 160ms ease;
}

textarea {
  min-height: 168px;
  resize: vertical;
  line-height: 1.6;
}

input:focus,
textarea:focus {
  border-color: var(--secondary);
  box-shadow: 0 0 0 4px rgba(197, 168, 128, 0.18);
}

.preview {
  border: 1px solid rgba(197, 168, 128, 0.32);
  border-radius: 14px;
  background: var(--surface-container);
  padding: 18px;
}

.preview p {
  margin: 10px 0 0;
  color: var(--on-surface);
  line-height: 1.7;
  white-space: pre-wrap;
}

.error {
  display: none;
  margin: -4px 0 0;
  color: var(--danger);
  font-weight: 700;
}

.error.is-visible {
  display: block;
}

.status {
  display: none;
  margin: -4px 0 0;
  color: var(--primary);
  font-weight: 700;
}

.status.is-visible {
  display: block;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  padding: 0 22px;
  cursor: pointer;
  font-weight: 800;
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: wait;
  opacity: 0.7;
  transform: none;
}

.primary-button {
  background: var(--on-surface);
  color: white;
  box-shadow: 0 14px 30px rgba(46, 41, 38, 0.22);
}

.primary-button:hover {
  background: var(--primary);
}

.secondary-button {
  background: var(--surface-container);
  color: var(--on-surface);
  border: 1px solid var(--outline);
}

.history-heading {
  margin-bottom: 14px;
}

.history h2 {
  margin: 0;
  font-size: 22px;
}

.history p {
  margin: 8px 0 0;
  color: var(--on-surface-variant);
}

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--outline);
  border-radius: 14px;
  background: white;
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 820px;
}

th,
td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--surface-container);
  text-align: left;
}

th {
  color: var(--primary);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

td {
  color: var(--on-surface);
}

tr:last-child td {
  border-bottom: 0;
}

.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 999px;
  padding: 5px 10px;
  font-size: 12px;
  font-weight: 800;
}

.badge.sent {
  background: #e8f5e9;
  color: #1b5e20;
}

.badge.failed {
  background: #ffebee;
  color: var(--danger);
}

.empty-state {
  display: none;
  padding: 16px;
}

.empty-state.is-visible {
  display: block;
}

@media (max-width: 720px) {
  .form-grid {
    grid-template-columns: 1fr;
  }

  .actions {
    justify-content: stretch;
  }

  button {
    width: 100%;
  }
}
