@import url("https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=DM+Serif+Display&display=swap");

:root {
  color-scheme: light;
  --ink: #242923;
  --muted: #858b83;
  --line: #e8ebe5;
  --paper: #fff;
  --canvas: #f6f7f5;
  --green: #526e50;
  --green-dark: #40583e;
  --green-soft: #edf2eb;
  --red: #a64e43;
  font-family: "DM Sans", sans-serif;
  font-synthesis: none;
  text-rendering: optimizeLegibility;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-width: 320px;
  background: var(--canvas);
  color: var(--ink);
}

button, input, textarea { font: inherit; }
button { cursor: pointer; }

.shell { max-width: 1440px; margin: 0 auto; padding: 0 30px 48px; }
.topbar { height: 74px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #e8ebe5; }
.brand { display: inline-flex; align-items: center; gap: 9px; color: var(--ink); text-decoration: none; font-size: 17px; font-weight: 700; letter-spacing: -.6px; }
.brand-mark { width: 30px; height: 30px; display: grid; place-items: center; color: #fff; background: var(--green); border-radius: 9px; }
.brand-mark svg { width: 18px; height: 18px; }
.topbar-note { display: flex; align-items: center; gap: 8px; color: #777e75; font-size: 12px; }
.topbar-actions { display: flex; align-items: center; gap: 18px; }
.session-timer { color: #858b83; font-size: 10px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.session-timer.expiring { color: var(--red); }
.logout-button { padding: 6px 10px; color: #687064; background: transparent; border: 1px solid #e1e6de; border-radius: 6px; font-size: 11px; }
.logout-button:hover { color: var(--green-dark); background: #fff; }
.online-dot { width: 7px; height: 7px; border-radius: 50%; background: #75a074; }

.intro { padding: 45px 0 28px; }
.eyebrow, .step-label { display: flex; align-items: center; gap: 9px; color: var(--green); font-size: 10px; font-weight: 700; letter-spacing: 1.3px; }
.eyebrow-line { display: inline-block; width: 20px; height: 1px; background: #8ca187; }
h1 { margin: 12px 0 5px; font: 400 42px/1.15 "DM Serif Display", Georgia, serif; letter-spacing: -.7px; }
.intro p { margin: 0; color: #737a71; font-size: 14px; }

.panel { min-width: 0; padding: 26px 28px; background: var(--paper); border: 1px solid #e8ebe5; border-radius: 12px; box-shadow: 0 3px 14px rgb(34 43 31 / 3%); }
.workspace-grid { display: grid; grid-template-columns: minmax(0, 3fr) minmax(0, 7fr); align-items: start; gap: 16px; }
.composer-panel { margin-top: 0; }
.section-heading { display: flex; align-items: center; justify-content: space-between; margin-bottom: 22px; }
.step-label { gap: 8px; font-size: 9px; letter-spacing: 1.1px; }
.step-label span { color: #9a9f97; }
h2 { margin: 7px 0 0; font: 400 21px/1.25 "DM Serif Display", Georgia, serif; letter-spacing: -.2px; }
.section-icon { width: 34px; height: 34px; display: grid; place-items: center; border-radius: 10px; color: var(--green); background: var(--green-soft); }
.section-icon svg { width: 19px; height: 19px; }

.upload-row { display: flex; align-items: center; flex-wrap: wrap; gap: 10px; }
.button { display: inline-flex; align-items: center; justify-content: center; gap: 9px; min-height: 42px; padding: 0 16px; border: 0; border-radius: 7px; font-size: 12px; font-weight: 600; transition: background .15s, transform .15s; }
.button:active:not(:disabled) { transform: translateY(1px); }
.button-dark { color: #fff; background: #292f28; }
.button-dark:hover { background: #414940; }
.button-dark svg { width: 17px; height: 17px; }
.button:disabled { cursor: not-allowed; opacity: .48; }
.upload-status { color: #858b83; font-size: 12px; }
.upload-status.success { color: var(--green); font-weight: 600; }
.spinner { width: 15px; height: 15px; display: inline-block; flex: 0 0 15px; border: 2px solid #dfe7dc; border-top-color: var(--green); border-radius: 50%; animation: spinner-rotate .7s linear infinite; vertical-align: middle; }
.spinner[hidden] { display: none; }
.spinner-light { border-color: rgb(255 255 255 / 35%); border-top-color: #fff; }
@keyframes spinner-rotate { to { transform: rotate(360deg); } }
.helper-text { margin: 10px 0 0; color: #92978f; font-size: 11px; }
code { color: var(--green); font-family: "DM Sans", sans-serif; font-size: .95em; background: #f0f3ee; border-radius: 3px; padding: 1px 4px; }
.inline-error { margin-top: 11px; color: var(--red); font-size: 12px; }

.recipient-area { margin-top: 23px; border-top: 1px solid var(--line); padding-top: 16px; }
.list-toolbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 10px; font-size: 12px; }
.selection-count { margin-left: 7px; color: #91968e; font-size: 11px; }
.select-all { display: inline-flex; align-items: center; gap: 7px; color: #757c72; font-size: 11px; cursor: pointer; }
input[type="checkbox"] { width: 14px; height: 14px; margin: 0; accent-color: var(--green); cursor: pointer; }
.recipient-list { max-height: min(56vh, 620px); min-height: 150px; overflow: auto; border: 1px solid #edf0eb; border-radius: 7px; }
.recipient-columns, .recipient-row { display: grid; grid-template-columns: 14px minmax(0, .8fr) minmax(0, 1.2fr) 26px; align-items: center; column-gap: 7px; }
.recipient-columns { padding: 0 12px 8px; color: #92978f; font-size: 10px; font-weight: 600; }
.recipient-columns span:first-child { grid-column: 2; }
.recipient-columns span:last-child { grid-column: 3; }
.recipient-row { min-height: 45px; padding: 7px 12px; border-bottom: 1px solid #f0f2ee; cursor: pointer; }
.recipient-row:last-child { border-bottom: 0; }
.recipient-row:hover { background: #fafbf9; }
.recipient-name, .recipient-email { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.recipient-name { color: #343a33; font-size: 12px; font-weight: 600; }
.recipient-email { overflow: hidden; color: #8c928a; font-size: 11px; text-overflow: ellipsis; white-space: nowrap; }
.recipient-avatar { width: 30px; height: 30px; display: grid; flex: 0 0 30px; place-items: center; margin-left: auto; border-radius: 50%; color: #637860; background: #eff3ed; font-size: 10px; font-weight: 600; }
.search-wrap { display: flex; align-items: center; gap: 8px; height: 36px; margin-bottom: 10px; padding: 0 10px; border: 1px solid #e8ebe5; border-radius: 6px; color: #92978f; }
.search-wrap svg { width: 16px; height: 16px; flex: 0 0 16px; }
.search-wrap input { width: 100%; border: 0; outline: 0; color: var(--ink); background: transparent; font-size: 11px; }
.search-wrap input::placeholder { color: #a7aca4; }
.pagination { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-top: 11px; }
.page-status { color: #92978f; font-size: 10px; }
.page-actions { display: flex; gap: 6px; }
.page-button { min-height: 29px; padding: 0 9px; color: #5e675b; background: #fff; border: 1px solid #e5e9e2; border-radius: 5px; font-size: 10px; }
.page-button:disabled { cursor: not-allowed; opacity: .45; }

.field-label { display: block; margin-bottom: 8px; color: #596057; font-size: 11px; font-weight: 600; }
.text-input, .message-input { width: 100%; color: var(--ink); background: #fff; border: 1px solid #e4e8e1; border-radius: 6px; outline: none; transition: border .15s, box-shadow .15s; }
.text-input { height: 42px; padding: 0 12px; font-size: 12px; }
.template-tools { display: grid; grid-template-columns: minmax(130px, 1fr) auto minmax(130px, 1fr) auto auto; align-items: end; gap: 8px; margin-bottom: 5px; }
.template-field { display: block; min-width: 0; }
.template-field .field-label { margin-bottom: 6px; }
.template-tools .text-input { height: 36px; }
.template-tools .page-button { min-height: 36px; }
.template-tools select { padding: 0 8px; }
.template-save { color: #fff; background: var(--green); border-color: var(--green); }
.template-save:hover { background: var(--green-dark); }
.template-delete { color: var(--red); }
.template-status { margin: 0 0 17px; color: #92978f; font-size: 10px; }
.template-status.error { color: var(--red); }
.message-label-row { display: flex; justify-content: space-between; align-items: center; margin-top: 17px; }
.message-label-row .field-label { margin-bottom: 8px; }
.merge-hint { margin-bottom: 8px; color: #92978f; font-size: 10px; }
.markdown-toolbar { display: flex; align-items: center; gap: 5px; padding: 5px; border: 1px solid #e4e8e1; border-bottom: 0; border-radius: 6px 6px 0 0; background: #f8f9f7; }
.markdown-toolbar span { margin-left: auto; padding: 0 6px; color: #92978f; font-size: 10px; }
.markdown-tab { min-height: 27px; padding: 0 9px; color: #737a71; background: transparent; border: 0; border-radius: 4px; font-size: 10px; }
.markdown-tab.active { color: var(--green-dark); background: #fff; box-shadow: 0 1px 3px rgb(34 43 31 / 10%); }
.message-input { display: block; min-height: 150px; padding: 12px; resize: vertical; font-size: 12px; line-height: 1.7; }
.message-input[hidden], .message-preview[hidden] { display: none; }
.markdown-toolbar + .message-input { border-top-left-radius: 0; border-top-right-radius: 0; }
.message-preview { min-height: 150px; padding: 12px; color: var(--ink); background: #fff; border: 1px solid #e4e8e1; border-radius: 0 0 6px 6px; font-size: 12px; line-height: 1.7; overflow-wrap: anywhere; }
.message-preview p:first-child { margin-top: 0; }
.message-preview p:last-child { margin-bottom: 0; }
.message-preview img { max-width: 100%; }
.message-preview pre { overflow: auto; padding: 10px; background: #f6f7f5; border-radius: 4px; }
.message-preview blockquote { margin-left: 0; padding-left: 12px; color: #737a71; border-left: 3px solid #e4e8e1; }
.text-input::placeholder, .message-input::placeholder { color: #b0b5ad; }
.text-input:focus, .message-input:focus { border-color: #9eaf99; box-shadow: 0 0 0 3px rgb(82 110 80 / 9%); }
.send-result { margin-top: 12px; padding: 10px 12px; border-radius: 6px; color: var(--green-dark); background: var(--green-soft); font-size: 11px; line-height: 1.6; }
.send-result.error { color: var(--red); background: #fbefed; }
.send-progress-track { height: 4px; overflow: hidden; margin-top: 8px; border-radius: 4px; background: rgb(82 110 80 / 14%); }
.send-progress-bar { height: 100%; width: 0; background: var(--green); transition: width .2s ease; }
.send-row { display: flex; align-items: center; justify-content: space-between; margin-top: 20px; }
.send-actions { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.send-note { display: grid; gap: 4px; color: #9a9f97; font-size: 10px; }
.button-send { min-height: 42px; color: #fff; background: var(--green); }
.button-send:hover:not(:disabled) { background: var(--green-dark); }
.button-send svg { width: 16px; height: 16px; margin-left: 1px; }
.send-count { min-width: 22px; padding: 2px 6px; border-radius: 20px; color: var(--green-dark); background: rgb(255 255 255 / 88%); font-size: 10px; text-align: center; }
.button-stop { min-height: 36px; padding: 0 11px; color: var(--red); background: #fbefed; }
.button-stop:hover:not(:disabled) { background: #f5dfdb; }
.logs-panel { margin-top: 18px; padding-top: 16px; border-top: 1px solid var(--line); }
.logs-heading, .logs-actions, .logs-pagination { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.logs-heading { margin-bottom: 12px; }
.logs-heading h3 { margin: 0; font: 400 17px/1.3 "DM Serif Display", Georgia, serif; }
.logs-actions { justify-content: flex-end; }
.logs-status { min-height: 16px; display: flex; align-items: center; gap: 7px; margin: 8px 0; color: #858b83; font-size: 10px; }
.logs-actions .page-button { display: inline-flex; align-items: center; justify-content: center; gap: 6px; }
.logs-table-wrap { max-height: 320px; overflow: auto; border: 1px solid #edf0eb; border-radius: 6px; }
.logs-table { width: 100%; border-collapse: collapse; font-size: 10px; line-height: 1.5; text-align: left; }
.logs-table th, .logs-table td { padding: 8px; border-bottom: 1px solid #f0f2ee; vertical-align: top; }
.logs-table th { position: sticky; top: 0; color: #737a71; background: #fafbf9; font-weight: 600; }
.logs-table td:first-child { min-width: 150px; overflow-wrap: anywhere; }
.logs-table td:nth-child(2) { white-space: nowrap; }
.logs-table td:last-child { min-width: 170px; overflow-wrap: anywhere; }
.logs-table tr:last-child td { border-bottom: 0; }
.logs-pagination { padding-top: 10px; }
.login-shell { max-width: 570px; }
.login-panel { margin-top: 2px; }
.login-input { margin-bottom: 4px; }
.login-password-label { margin-top: 13px; }
.login-submit { width: 100%; margin-top: 20px; }
.login-submit svg { width: 16px; height: 16px; }
.login-error { margin-top: 10px; }

footer { padding: 22px 2px 0; color: #747b72; font-size: 10px; }
footer span { color: #a2a79f; }

@media (max-width: 900px) {
  .workspace-grid { grid-template-columns: minmax(0, 1fr); }
  .recipient-list { max-height: 360px; }
}

@media (max-width: 560px) {
  .shell { padding: 0 17px 32px; }
  .topbar { height: 62px; }
  .topbar-actions { gap: 8px; }
  .topbar-note { display: none; }
  .logout-button { padding: 6px 7px; }
  .intro { padding: 35px 0 23px; }
  h1 { font-size: 36px; }
  .intro p { max-width: 310px; font-size: 13px; line-height: 1.5; }
  .panel { padding: 22px 18px; }
  .upload-row { align-items: flex-start; flex-direction: column; gap: 10px; }
  .message-label-row { align-items: flex-start; flex-direction: column; gap: 0; }
  .merge-hint { margin-top: -3px; }
  .markdown-toolbar span { font-size: 9px; }
  .template-tools { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); }
  .template-tools button { min-height: 36px; }
  .template-picker-field { grid-column: 1 / -1; }
  .send-row { align-items: stretch; flex-direction: column; gap: 13px; }
  .send-actions { width: 100%; }
  .button-send { flex: 1; }
}

@media (prefers-reduced-motion: reduce) {
  .spinner { animation-duration: 1.5s; }
}
