:root {
  --bg: #f4f7fb;
  --card: #ffffff;
  --text: #162032;
  --muted: #607089;
  --brand: #0f6ed3;
  --brand-strong: #0a4a8f;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Helvetica Neue", Arial, sans-serif;
  background: radial-gradient(circle at 20% 10%, #edf3fd, transparent 45%), linear-gradient(180deg, #f7fafc, #eef2f8);
  color: var(--text);
}

.app-shell {
  max-width: 960px;
  margin: 0 auto;
  padding: 2rem 1rem;
}

.header h1 {
  margin: 0;
  font-size: 1.8rem;
  color: var(--brand-strong);
}

.header p {
  margin-top: 0.35rem;
  color: var(--muted);
}

.stepper {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  margin-top: 1.5rem;
}

.step-chip {
  background: rgba(15, 110, 211, 0.08);
  color: #426384;
  border-radius: 999px;
  padding: 0.55rem 0.9rem;
  font-size: 0.95rem;
}

.step-chip.is-active {
  background: rgba(15, 110, 211, 0.14);
  color: #0a4a8f;
  font-weight: 700;
}

.step-panel {
  margin-top: 1.4rem;
}

.search-form {
  margin-top: 1.5rem;
}

.input-row {
  display: flex;
  gap: 0.5rem;
}

.search-form {
  position: relative;
}

.search-form input {
  flex: 1;
  border: 1px solid #d5deeb;
  border-radius: 10px;
  padding: 0.75rem 1rem;
  font-size: 1rem;
}

.search-form button {
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  padding: 0 1.1rem;
  font-size: 1rem;
  cursor: pointer;
}

.search-form button:hover {
  background: var(--brand-strong);
}

.step-actions {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  margin-top: 1.25rem;
}

.step-actions button:not(.ghost-button) {
  border: 0;
  border-radius: 10px;
  background: var(--brand);
  color: #fff;
  padding: 0.8rem 1.1rem;
  font-size: 1rem;
  cursor: pointer;
}

.step-actions button:not(.ghost-button):hover {
  background: var(--brand-strong);
}

.secondary-button,
.ghost-button {
  border-radius: 10px;
  padding: 0.8rem 1.1rem;
  font-size: 1rem;
  cursor: pointer;
}

.secondary-button {
  border: 0;
  background: var(--brand);
  color: #fff;
}

.secondary-button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.ghost-button {
  border: 1px solid #cbd7e8;
  background: #fff;
  color: var(--text);
}

.status {
  margin-top: 1rem;
  min-height: 1.4rem;
  color: var(--muted);
}

.selection-info {
  margin-top: 1rem;
  background: #edf5ff;
  border: 1px solid #d7e6fb;
  border-radius: 10px;
  color: #21466b;
  padding: 0.7rem 0.9rem;
}

.suggestions {
  position: absolute;
  inset: calc(100% + 0.45rem) 0 auto 0;
  background: #ffffff;
  border: 1px solid #d7dce4;
  border-radius: 14px;
  box-shadow: 0 18px 40px rgba(13, 31, 58, 0.08);
  padding: 0.45rem;
  z-index: 20;
}

.suggestions-title {
  padding: 0.65rem 0.9rem 0.45rem;
  color: #3f3526;
  font-size: 0.92rem;
}

.suggestion-item {
  width: 100%;
  border: 0;
  background: transparent;
  border-radius: 10px;
  padding: 0.95rem 1rem;
  text-align: left;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 0.3rem 1rem;
  cursor: pointer;
}

.suggestion-item:hover,
.suggestion-item.is-active {
  background: #f3f6fa;
}

.suggestion-main {
  font-weight: 700;
  color: #18120b;
}

.suggestion-type,
.suggestion-sub {
  color: #332b20;
  font-size: 0.94rem;
}

.suggestion-sub {
  grid-column: 1 / -1;
}

.card {
  background: var(--card);
  border: 1px solid #dbe5f5;
  border-left: 5px solid var(--brand);
  border-radius: 12px;
  padding: 1rem;
  margin-top: 0.75rem;
  box-shadow: 0 8px 20px rgba(13, 31, 58, 0.05);
}

.result-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.9rem;
  margin-top: 0.75rem;
}

.selectable-card {
  margin-top: 0;
  border-left-width: 1px;
}

.selectable-card.is-selected {
  border-color: #9cc4f4;
  box-shadow: 0 10px 24px rgba(15, 110, 211, 0.12);
}

.selection-toggle {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  margin-bottom: 0.8rem;
  color: #36516f;
  font-size: 0.95rem;
}

.selection-toggle input {
  width: 1.1rem;
  height: 1.1rem;
}

.card h3 {
  margin: 0;
  font-size: 1.2rem;
}

.muted {
  color: var(--muted);
}

.meta {
  margin: 0.5rem 0;
  line-height: 1.45;
}

.links a {
  margin-right: 1rem;
}

.notice {
  margin-top: 1rem;
  color: #6f2b2b;
  background: #fff2f2;
  border: 1px solid #ffd1d1;
  border-radius: 10px;
  padding: 0.65rem 0.9rem;
}

.selection-summary,
.letter-preview-block {
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid #dbe5f5;
  border-radius: 14px;
  padding: 1rem;
  box-shadow: 0 8px 20px rgba(13, 31, 58, 0.04);
}

.selection-summary h2,
.letter-preview-block h2 {
  margin: 0 0 0.85rem;
  font-size: 1.15rem;
}

.selected-members {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.selected-pill {
  background: #eef5ff;
  border: 1px solid #d8e5f7;
  border-radius: 12px;
  padding: 0.7rem 0.85rem;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.selected-pill span {
  color: var(--muted);
  font-size: 0.92rem;
}

.letter-form {
  margin-top: 1rem;
}

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

.form-grid label {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  font-weight: 700;
}

.form-grid label span {
  font-size: 0.95rem;
}

.form-grid input,
.form-grid textarea {
  border: 1px solid #d5deeb;
  border-radius: 10px;
  padding: 0.8rem 0.95rem;
  font-size: 1rem;
  font-family: inherit;
  font-weight: 400;
  background: #fff;
  color: var(--text);
}

.form-grid textarea {
  resize: vertical;
}

.full-width {
  grid-column: 1 / -1;
}

.letter-preview-block {
  margin-top: 1rem;
}

.letter-preview {
  background: #fff;
  border: 1px solid #e2e9f4;
  border-radius: 12px;
  padding: 1rem;
}

.letter-preview p {
  margin: 0.95rem 0 0;
  line-height: 1.55;
}

.preview-meta {
  white-space: pre-line;
  line-height: 1.55;
  margin-top: 0.9rem;
}

.preview-meta:first-child {
  margin-top: 0;
}

.page-footer {
  margin-top: 2.25rem;
  padding-top: 1rem;
  text-align: center;
}

.footer-link {
  color: #55657d;
  font-size: 0.96rem;
  text-decoration: none;
  border-bottom: 1px solid rgba(85, 101, 125, 0.35);
  padding-bottom: 0.08rem;
}

.footer-link:hover,
.footer-link:focus-visible {
  color: #21344d;
  border-bottom-color: rgba(33, 52, 77, 0.55);
}

@media (max-width: 640px) {
  .input-row {
    flex-direction: column;
  }

  .step-actions {
    flex-direction: column;
  }

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

  .full-width {
    grid-column: auto;
  }

  .search-form button {
    padding: 0.85rem 1.1rem;
  }

  .suggestions {
    inset: calc(100% + 0.45rem) 0 auto 0;
  }
}
