:root {
  color-scheme: light;
  --bg: #f7f9f8;
  --paper: #ffffff;
  --text: #071d36;
  --muted: #5d6b7b;
  --soft: #ecf1f0;
  --line: #d9e2e0;
  --accent: #007a5a;
  --accent-strong: #005f49;
  --accent-soft: #e5f5ef;
  --blue: #0b2947;
  --danger: #b42318;
  --shadow: 0 22px 55px rgba(7, 29, 54, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  overflow-x: hidden;
  min-width: 320px;
  margin: 0;
  color: var(--text);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.78), rgba(247, 249, 248, 0) 420px),
    var(--bg);
}

a {
  color: var(--accent-strong);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 72px;
  padding: 0 clamp(18px, 4vw, 56px);
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.88);
  backdrop-filter: blur(14px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--text);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.25rem, 2vw, 1.85rem);
  font-weight: 700;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 34px;
  height: 34px;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: var(--blue);
  font-family: Inter, ui-sans-serif, system-ui, sans-serif;
  font-size: 1rem;
}

.topbar-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 650;
}

.topbar-status svg,
.submit-button svg,
.summary-icon svg,
.success-mark svg {
  width: 21px;
  height: 21px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(0, 1.25fr) minmax(360px, 0.75fr);
  gap: clamp(20px, 3vw, 34px);
  width: min(1420px, calc(100% - clamp(24px, 6vw, 96px)));
  margin: clamp(22px, 4vw, 46px) auto 28px;
}

.letter-panel,
.form-panel {
  min-width: 0;
}

.letter-paper,
.form-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: var(--shadow);
}

.letter-paper {
  padding: clamp(26px, 4vw, 56px);
}

.panel-heading p {
  margin: 0 0 10px;
  color: var(--accent-strong);
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.letter-paper h1 {
  margin: 0 0 38px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.9rem, 3vw, 3rem);
  line-height: 1.05;
  text-align: center;
}

.letter-copy {
  display: grid;
  gap: 17px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1rem, 1.15vw, 1.16rem);
  line-height: 1.72;
  text-align: justify;
  text-justify: inter-word;
  hyphens: auto;
}

.letter-copy p {
  margin: 0;
}

.signature-summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  margin-top: 14px;
  padding: 18px 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
}

.signature-summary > div {
  display: flex;
  align-items: center;
  gap: 13px;
}

.summary-icon {
  display: grid;
  width: 44px;
  height: 44px;
  flex: 0 0 auto;
  place-items: center;
  border-radius: 8px;
  color: var(--blue);
  background: #eef4f8;
}

.signature-summary strong {
  display: block;
  font-size: 1rem;
}

.signature-summary span {
  display: block;
  color: var(--muted);
  font-size: 0.9rem;
}

#signature-count {
  color: var(--accent-strong);
  font-size: 1.05rem;
  text-align: right;
  white-space: nowrap;
}

.form-panel {
  position: sticky;
  top: 94px;
  align-self: start;
  padding: clamp(22px, 3vw, 32px);
}

.panel-heading {
  margin-bottom: 22px;
}

.panel-heading h2 {
  margin: 0 0 8px;
  font-size: clamp(1.55rem, 2.3vw, 2rem);
  line-height: 1.12;
}

.panel-heading span {
  color: var(--muted);
  line-height: 1.45;
}

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

.field {
  display: grid;
  gap: 7px;
  min-width: 0;
}

label {
  color: var(--text);
  font-size: 0.88rem;
  font-weight: 750;
}

label span[aria-hidden="true"] {
  color: var(--danger);
}

input,
textarea {
  width: 100%;
  border: 1px solid #cdd8d7;
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--text);
  background: #fff;
  font: inherit;
  font-size: 0.98rem;
  outline: none;
  transition: border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

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

input:focus,
textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 4px rgba(0, 122, 90, 0.12);
}

input:invalid:not(:placeholder-shown),
textarea:invalid:not(:placeholder-shown) {
  border-color: rgba(180, 35, 24, 0.7);
}

.counter,
.hint {
  color: var(--muted);
  font-size: 0.78rem;
}

.counter {
  justify-self: end;
}

.submit-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 0 18px;
  font: inherit;
  font-size: 1rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease;
}

.submit-button {
  gap: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  box-shadow: 0 16px 32px rgba(0, 122, 90, 0.2);
}

.submit-button:hover,
.secondary-button:hover {
  transform: translateY(-1px);
}

.submit-button:disabled {
  cursor: wait;
  opacity: 0.68;
  transform: none;
}

.secondary-button {
  color: var(--accent-strong);
  background: #fff;
  border-color: rgba(0, 122, 90, 0.38);
}

.form-message {
  min-height: 22px;
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.45;
}

.form-message.error {
  color: var(--danger);
}

.authorization-note {
  margin: -4px 0 0;
  color: var(--muted);
  font-size: 0.84rem;
  line-height: 1.42;
}

.success-panel {
  display: grid;
  justify-items: center;
  gap: 14px;
  padding: 26px 18px 8px;
  text-align: center;
}

.success-mark {
  display: grid;
  width: 78px;
  height: 78px;
  place-items: center;
  border-radius: 999px;
  color: #fff;
  background: var(--accent);
}

.success-mark svg {
  width: 40px;
  height: 40px;
  stroke-width: 2.5;
}

.success-panel h2 {
  margin: 0;
  font-size: clamp(1.4rem, 2vw, 1.85rem);
}

.success-panel p {
  max-width: 520px;
  margin: 0;
  color: var(--muted);
  line-height: 1.5;
}

.signer-list-card {
  margin-top: 24px;
  padding-top: 22px;
  border-top: 1px solid var(--line);
}

.signer-list-card h3 {
  margin: 0 0 14px;
  color: var(--blue);
  font-size: 1.2rem;
  line-height: 1.2;
}

.signer-list {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.signer-list li {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 50px;
  padding: 12px 14px;
  border: 1px solid rgba(0, 122, 90, 0.24);
  border-left: 5px solid var(--accent);
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(0, 122, 90, 0.11), #fbfdfc 42%);
  color: var(--text);
  box-shadow: 0 10px 22px rgba(7, 29, 54, 0.05);
}

.signer-list li span {
  color: var(--blue);
  font-size: 1.08rem;
  font-weight: 900;
  line-height: 1.25;
}

.signer-list li.empty {
  color: var(--muted);
  font-weight: 600;
}

.signer-list time {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 650;
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

.hp {
  position: absolute;
  left: -10000px;
  width: 1px;
  height: 1px;
  opacity: 0;
}

.footer {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  width: min(1420px, calc(100% - clamp(24px, 6vw, 96px)));
  margin: 0 auto 34px;
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 980px) {
  .page-shell {
    grid-template-columns: 1fr;
  }

  .form-panel {
    position: static;
  }
}

@media (max-width: 720px) {
  .topbar {
    min-height: 64px;
    padding-inline: 16px;
  }

  .topbar-status span {
    display: none;
  }

  .page-shell,
  .footer {
    width: calc(100vw - 20px);
    max-width: calc(100vw - 20px);
    margin-inline: auto;
    padding-inline: 0;
    overflow: visible;
  }

  .letter-paper,
  .form-panel {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    padding: 16px;
  }

  .letter-paper h1 {
    overflow-wrap: anywhere;
    font-size: clamp(1.48rem, 7.4vw, 1.82rem);
    line-height: 1.12;
  }

  .letter-copy {
    max-width: 100%;
    font-size: 0.92rem;
    line-height: 1.62;
    text-align: justify;
    text-align-last: left;
    hyphens: auto;
    -webkit-hyphens: auto;
    overflow-wrap: normal;
  }

  .letter-copy p {
    overflow-wrap: normal;
  }

  .signature-summary,
  .footer {
    align-items: flex-start;
    flex-direction: column;
  }

  #signature-count {
    text-align: left;
  }

  .signer-list li {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
    min-height: 58px;
  }

  .signer-list li span {
    font-size: 1.05rem;
  }
}
