:root {
  color-scheme: light;
  --bg: #eef3f7;
  --panel: #ffffff;
  --ink: #17202a;
  --muted: #667485;
  --line: #d8e0e8;
  --accent: #16745f;
  --accent-dark: #0e5446;
  --facebook: #1877f2;
  --telegram: #229ed9;
  --warn: #a13b2a;
  --soft: #f5f8fb;
  --shadow: 0 18px 50px rgba(27, 43, 58, 0.12);
}

* {
  box-sizing: border-box;
}

html {
  overflow-x: hidden;
}

body {
  margin: 0;
  min-height: 100svh;
  background: var(--bg);
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-text-size-adjust: 100%;
  overflow-x: hidden;
}

body.modal-open {
  overflow: hidden;
}

.app {
  width: min(1180px, calc(100% - 32px));
  margin: 0 auto;
  padding: 34px 0;
  display: grid;
  grid-template-columns: minmax(320px, 450px) minmax(0, 1fr);
  gap: 22px;
}

.panel {
  min-width: 0;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
}

.input-panel {
  padding: 24px;
}

.result-panel {
  padding: 24px;
  min-height: 620px;
}

.title-row,
.result-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 22px;
}

.title-row > div,
.result-header > div {
  min-width: 0;
}

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

h1,
h2 {
  margin: 0;
  line-height: 1.12;
}

h1 {
  font-size: 32px;
}

h2 {
  font-size: 24px;
}

.status-pill {
  flex: 0 0 auto;
  padding: 8px 10px;
  border-radius: 999px;
  background: #e8f5f1;
  color: var(--accent-dark);
  font-size: 13px;
  font-weight: 700;
}

.status-pill.is-error {
  background: #fdecea;
  color: var(--warn);
}

form {
  display: grid;
  gap: 16px;
}

.mode-group {
  display: flex;
  gap: 12px;
  min-width: 0;
  min-inline-size: 0;
  max-width: 100%;
  margin: 0;
  padding: 0;
  border: 0;
}

.mode-group legend {
  width: 100%;
  margin-bottom: 8px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.mode-group label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  min-height: 44px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  cursor: pointer;
}

.mode-group label:has(input:checked) {
  border-color: var(--accent);
  background: #e8f5f1;
  color: var(--accent-dark);
}

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

.field span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.wide,
.short {
  width: 100%;
}

input,
textarea {
  display: block;
  width: 100%;
  max-width: 100%;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 11px 12px;
  color: var(--ink);
  background: #fff;
  font: inherit;
  font-size: 16px;
}

input[type="radio"] {
  width: auto;
  min-width: 18px;
  min-height: 18px;
  flex: 0 0 auto;
  padding: 0;
  accent-color: var(--accent);
}

textarea {
  resize: vertical;
  min-height: 84px;
}

input:focus,
textarea:focus {
  outline: 3px solid rgba(22, 116, 95, 0.16);
  border-color: var(--accent);
}

.primary-button,
.ghost-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.primary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  max-width: 100%;
  background: var(--accent);
  color: #fff;
}

.primary-button:disabled {
  cursor: wait;
  opacity: 0.7;
}

.ghost-button {
  padding: 0 14px;
  background: var(--soft);
  color: var(--ink);
  border: 1px solid var(--line);
}

.note {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.message-list {
  display: grid;
  gap: 12px;
}

.message-list.empty {
  min-height: 220px;
  place-items: center;
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  text-align: center;
}

.message-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
  background: #fff;
  overflow-wrap: anywhere;
}

.message-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 10px;
  color: var(--muted);
  font-size: 13px;
}

.message-subject {
  margin: 0 0 10px;
  font-size: 17px;
  line-height: 1.35;
}

.code {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 8px;
  border-radius: 6px;
  background: #fff1d8;
  color: #714a00;
  font-weight: 700;
  max-width: 100%;
  overflow-wrap: anywhere;
}

.twofa-card {
  text-align: center;
}

.twofa-code {
  margin: 0;
  font-size: clamp(34px, 12vw, 44px);
  line-height: 1;
  font-weight: 800;
  letter-spacing: 0;
  color: var(--accent-dark);
}

.copy-code-button {
  min-height: 38px;
  margin-top: 14px;
  padding: 0 16px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #e8f5f1;
  color: var(--accent-dark);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.show-more-button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.preview {
  margin: 10px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.message-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 12px;
}

.detail-button {
  min-height: 36px;
  padding: 0 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: #e8f5f1;
  color: var(--accent-dark);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.detail-button:hover,
.detail-button:focus-visible {
  background: #d7eee7;
}

.error {
  color: var(--warn);
}

pre {
  overflow: auto;
  max-width: 100%;
  max-height: 360px;
  padding: 14px;
  border-radius: 8px;
  background: #101820;
  color: #d7e7ef;
  font-size: 12px;
}

.site-footer {
  grid-column: 1 / -1;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 6px;
  padding: 2px 0 8px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
}

.site-footer a {
  color: var(--facebook);
  font-weight: 700;
  text-decoration: none;
}

.site-footer a:hover,
.site-footer a:focus-visible {
  text-decoration: underline;
}

.site-footer .telegram-link {
  color: var(--telegram);
}

.mail-modal[hidden] {
  display: none;
}

.mail-modal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(8, 18, 28, 0.66);
}

.mail-modal-card {
  width: min(980px, 100%);
  max-height: min(86vh, 900px);
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr);
  overflow: hidden;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  box-shadow: 0 28px 80px rgba(8, 18, 28, 0.34);
}

.mail-modal-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 20px 14px;
  border-bottom: 1px solid var(--line);
}

.mail-modal-header > div {
  min-width: 0;
}

.modal-close-button {
  min-height: 38px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  color: var(--ink);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.mail-detail-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 14px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.mail-detail-meta span {
  overflow-wrap: anywhere;
}

.mail-detail-content {
  overflow: auto;
  min-height: 240px;
  padding: 18px 20px;
  background: #fff;
  color: #1f2933;
  line-height: 1.55;
  overflow-wrap: anywhere;
}

.mail-detail-content img,
.mail-detail-content table {
  max-width: 100%;
}

.mail-detail-content table {
  border-collapse: collapse;
}

.mail-detail-content a {
  color: var(--facebook);
}

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

  .result-panel {
    min-height: 420px;
  }
}

@media (max-width: 560px) {
  .app {
    display: block;
    width: 100%;
    max-width: 100%;
    padding: 10px 8px 16px;
  }

  .input-panel,
  .result-panel {
    padding: 16px;
    box-shadow: 0 10px 28px rgba(27, 43, 58, 0.1);
  }

  .result-panel,
  .site-footer {
    margin-top: 10px;
  }

  .title-row,
  .result-header {
    gap: 12px;
    margin-bottom: 16px;
  }

  .title-row {
    align-items: flex-start;
    flex-direction: column;
  }

  .result-header {
    align-items: center;
  }

  .grid {
    grid-template-columns: 1fr;
  }

  .mode-group {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    gap: 8px;
  }

  .mode-group label {
    justify-content: flex-start;
    min-width: 0;
    padding: 8px 10px;
  }

  h1 {
    font-size: 26px;
  }

  h2 {
    font-size: 20px;
  }

  form {
    gap: 14px;
  }

  textarea {
    min-height: 112px;
  }

  .primary-button {
    width: 100%;
    min-height: 48px;
  }

  .ghost-button {
    min-height: 40px;
    padding: 0 12px;
  }

  .note {
    margin-top: 14px;
  }

  .result-panel {
    min-height: 0;
  }

  .message-list.empty {
    min-height: 150px;
    padding: 18px;
  }

  .message-card {
    padding: 14px;
  }

  .message-actions {
    justify-content: stretch;
  }

  .detail-button {
    width: 100%;
    min-height: 42px;
  }

  .message-meta {
    gap: 6px;
  }

  .mail-modal {
    padding: 8px;
  }

  .mail-modal-card {
    max-height: calc(100svh - 16px);
  }

  .mail-modal-header {
    padding: 14px;
  }

  .mail-detail-meta {
    padding: 10px 14px;
  }

  .mail-detail-content {
    padding: 14px;
  }

  .site-footer {
    padding: 6px 0 4px;
    font-size: 12px;
  }
}
