:root {
  --background: #e3e5f0;
  --surface: rgba(255, 255, 255, 0.76);
  --surface-strong: #f8f8fc;
  --text: #333442;
  --muted: #777989;
  --border: rgba(96, 98, 126, 0.16);
  --accent: #7771ba;
  --accent-dark: #5f599f;
  --accent-soft: #e5e3f6;
  --success: #557d67;
  --success-soft: #e1f0e7;
  --danger: #a95662;
  --danger-soft: #f6e3e6;
  --shadow: 0 20px 55px rgba(60, 61, 88, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  position: relative;
  min-height: 100vh;
  margin: 0;
  overflow-x: hidden;
  color: var(--text);
  background:
    radial-gradient(
      circle at 15% 10%,
      rgba(255, 255, 255, 0.75),
      transparent 27%
    ),
    radial-gradient(
      circle at 88% 18%,
      rgba(213, 207, 241, 0.65),
      transparent 28%
    ),
    var(--background);
  font-family:
    -apple-system,
    BlinkMacSystemFont,
    "Segoe UI",
    "PingFang SC",
    "Microsoft YaHei",
    sans-serif;
}

button,
input,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

.page-decoration {
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(2px);
  pointer-events: none;
}

.decoration-one {
  top: 120px;
  left: -100px;
  width: 270px;
  height: 270px;
  background: rgba(206, 216, 242, 0.62);
}

.decoration-two {
  right: -120px;
  bottom: 80px;
  width: 320px;
  height: 320px;
  background: rgba(225, 205, 235, 0.48);
}

.page-header,
.page-main,
.page-footer {
  width: min(1120px, calc(100% - 36px));
  margin-right: auto;
  margin-left: auto;
}

.page-header {
  position: relative;
  padding-top: 34px;
  padding-bottom: 40px;
  text-align: center;
}

.home-button {
  position: absolute;
  top: 30px;
  left: 0;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 42px;
  padding: 0 18px;
  border: 1px solid rgba(91, 91, 120, 0.14);
  border-radius: 999px;
  color: #555666;
  background: rgba(255, 255, 255, 0.72);
  box-shadow: 0 8px 25px rgba(74, 75, 105, 0.08);
  text-decoration: none;
  transition:
    transform 160ms ease,
    background 160ms ease;
}

.home-button:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.95);
}

.header-copy {
  max-width: 650px;
  margin: 50px auto 0;
}

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

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(35px, 6vw, 56px);
  line-height: 1.08;
  letter-spacing: -0.04em;
}

.page-description {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.8;
}

.page-main {
  display: grid;
  gap: 34px;
  padding-bottom: 60px;
}

.letter-form-section,
.public-letters-section {
  padding: 28px;
  border: 1px solid var(--border);
  border-radius: 30px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.section-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 23px;
}

.section-heading h2 {
  margin-bottom: 0;
  font-size: 25px;
  letter-spacing: -0.025em;
}

.review-note {
  display: inline-flex;
  align-items: center;
  min-height: 34px;
  padding: 0 14px;
  border-radius: 999px;
  color: var(--accent-dark);
  background: var(--accent-soft);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.letter-form {
  display: grid;
  gap: 20px;
}

.honeypot-field {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
  opacity: 0;
  pointer-events: none;
}

.form-field {
  display: grid;
  gap: 9px;
}

.field-label {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #4c4d5e;
  font-size: 14px;
  font-weight: 700;
}

.field-label small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

input,
textarea {
  width: 100%;
  border: 1px solid rgba(99, 100, 131, 0.15);
  outline: none;
  border-radius: 18px;
  color: var(--text);
  background: rgba(255, 255, 255, 0.7);
  transition:
    border-color 160ms ease,
    box-shadow 160ms ease,
    background 160ms ease;
}

input {
  min-height: 52px;
  padding: 0 17px;
}

textarea {
  min-height: 160px;
  padding: 16px 17px;
  resize: vertical;
  line-height: 1.75;
}

input:focus,
textarea:focus {
  border-color: rgba(119, 113, 186, 0.55);
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 0 0 4px rgba(119, 113, 186, 0.1);
}

input::placeholder,
textarea::placeholder {
  color: #a0a1ae;
}

.form-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
}

.privacy-note {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.6;
}

.submit-button,
.refresh-button {
  border: 0;
  cursor: pointer;
  transition:
    transform 160ms ease,
    box-shadow 160ms ease,
    opacity 160ms ease;
}

.submit-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  min-width: 145px;
  min-height: 48px;
  padding: 0 22px;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(
    135deg,
    var(--accent),
    var(--accent-dark)
  );
  box-shadow: 0 12px 28px rgba(95, 89, 159, 0.25);
  font-weight: 750;
}

.submit-button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 16px 34px rgba(95, 89, 159, 0.32);
}

.submit-button:disabled {
  cursor: wait;
  opacity: 0.65;
}

.submit-icon {
  font-size: 18px;
}

.refresh-button {
  min-height: 36px;
  padding: 0 15px;
  border-radius: 999px;
  color: #626377;
  background: rgba(255, 255, 255, 0.72);
}

.refresh-button:hover {
  transform: translateY(-1px);
  background: #fff;
}

.form-message {
  padding: 14px 16px;
  border-radius: 16px;
  font-size: 13px;
  line-height: 1.6;
}

.form-message.success {
  color: var(--success);
  background: var(--success-soft);
}

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

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

.letter-card {
  position: relative;
  min-height: 190px;
  padding: 21px;
  border: 1px solid rgba(95, 96, 125, 0.1);
  border-radius: 23px;
  background: var(--letter-background, #f8f6ec);
  box-shadow: 0 14px 32px rgba(66, 67, 91, 0.1);
  transform: rotate(var(--letter-rotation, 0deg));
  transition:
    transform 180ms ease,
    box-shadow 180ms ease;
}

.letter-card:hover {
  z-index: 2;
  transform:
    rotate(0deg)
    translateY(-4px);
  box-shadow: 0 20px 38px rgba(66, 67, 91, 0.15);
}

.letter-card::before {
  position: absolute;
  top: -7px;
  left: 50%;
  width: 58px;
  height: 17px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.56);
  content: "";
  transform: translateX(-50%) rotate(-2deg);
}

.letter-author {
  display: flex;
  align-items: center;
  gap: 11px;
  margin-bottom: 17px;
}

.letter-avatar {
  display: grid;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--avatar-background);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.28);
  font-size: 16px;
  font-weight: 800;
}

.letter-author-copy {
  min-width: 0;
}

.letter-author-name {
  display: block;
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.letter-time {
  display: block;
  margin-top: 3px;
  color: rgba(74, 75, 90, 0.58);
  font-size: 11px;
}

.letter-content {
  margin-bottom: 0;
  color: #4a4b58;
  font-size: 14px;
  line-height: 1.85;
  overflow-wrap: anywhere;
  white-space: pre-wrap;
}

.state-panel {
  display: grid;
  min-height: 170px;
  padding: 25px;
  place-items: center;
  border: 1px dashed rgba(96, 97, 124, 0.2);
  border-radius: 22px;
  color: var(--muted);
  text-align: center;
}

.state-panel p {
  margin: 7px 0 0;
}

.state-panel strong {
  margin-top: 10px;
  color: var(--text);
}

.error-state {
  color: var(--danger);
  background: var(--danger-soft);
}

.empty-icon {
  font-size: 30px;
}

.page-footer {
  padding: 0 0 34px;
  color: rgba(82, 83, 99, 0.62);
  text-align: center;
  font-size: 12px;
}

@media (max-width: 720px) {
  .page-header {
    padding-top: 24px;
  }

  .home-button {
    position: static;
    margin-right: auto;
  }

  .header-copy {
    margin-top: 40px;
  }

  .letter-form-section,
  .public-letters-section {
    padding: 21px;
    border-radius: 24px;
  }

  .form-footer {
    align-items: stretch;
    flex-direction: column;
  }

  .submit-button {
    width: 100%;
  }

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

@media (max-width: 460px) {
  .page-header,
  .page-main,
  .page-footer {
    width: min(100% - 24px, 1120px);
  }

  .section-heading {
    align-items: flex-start;
  }

  .review-note {
    padding: 0 11px;
  }
}
