:root {
  color-scheme: light;
  --ink: #1e2724;
  --ink-muted: #65716c;
  --paper: #f5f2eb;
  --surface: #fffdf8;
  --line: #d9d6ce;
  --teal: #246b65;
  --teal-dark: #174e4a;
  --coral: #a94f40;
  --coral-dark: #83392f;
  --gold: #986d2f;
  --shadow: 0 18px 50px rgba(30, 39, 36, 0.08);
}

* {
  box-sizing: border-box;
}

html {
  min-width: 320px;
  background: var(--paper);
}

body {
  min-width: 320px;
  margin: 0;
  color: var(--ink);
  background: var(--paper);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
  font-size: 16px;
  line-height: 1.6;
}

button,
input,
select {
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: not-allowed;
}

:focus-visible {
  outline: 3px solid #d79242;
  outline-offset: 3px;
}

.skip-link {
  position: absolute;
  top: 0;
  left: 16px;
  z-index: 10;
  padding: 8px 12px;
  color: var(--surface);
  background: var(--teal-dark);
  transform: translateY(-120%);
}

.skip-link:focus {
  transform: translateY(0);
}

.page-shell {
  width: min(100% - 32px, 720px);
  margin: 0 auto;
  padding: 24px 0 40px;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 40px;
  border-bottom: 1px solid var(--line);
}

.brand {
  color: var(--ink);
  font-size: 1.05rem;
  font-weight: 700;
  text-decoration: none;
}

.brand span {
  color: var(--ink-muted);
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.header-mark {
  color: var(--ink-muted);
  font-size: 0.8rem;
}

.intro {
  padding: 58px 0 30px;
}

.eyebrow,
.preview-label {
  margin: 0 0 8px;
  color: var(--teal);
  font-size: 0.77rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

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

h1 {
  max-width: 15ch;
  margin-bottom: 18px;
  font-size: clamp(2rem, 5vw, 3.3rem);
  line-height: 1.1;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 6px;
  font-size: 1.1rem;
  line-height: 1.3;
}

.intro-copy,
.muted-copy {
  color: var(--ink-muted);
}

.intro-copy {
  max-width: 48ch;
  margin-bottom: 0;
}

.surface {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.status {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  min-height: 28px;
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.status-dot {
  width: 9px;
  height: 9px;
  flex: 0 0 9px;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--ink-muted);
}

.status-success {
  color: var(--teal-dark);
}

.status-success .status-dot {
  background: var(--teal);
}

.status-warning {
  color: var(--gold);
}

.status-warning .status-dot {
  background: var(--gold);
}

.status-error {
  color: var(--coral-dark);
}

.status-error .status-dot {
  background: var(--coral);
}

.preview-panel,
.letter-panel,
.open-panel,
.actions-panel,
.report-panel,
.trusted-login-panel,
.trusted-result-panel {
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.sender-identity {
  margin-bottom: 24px;
  color: var(--ink);
  font-size: 1.35rem;
  font-weight: 700;
  overflow-wrap: anywhere;
}

.preview-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
}

.preview-grid > div {
  min-width: 0;
}

.preview-grid .preview-label {
  margin-bottom: 4px;
}

.preview-grid > div > div:last-child,
.preview-grid time {
  display: block;
  overflow-wrap: anywhere;
}

.letter-body {
  max-height: min(62vh, 680px);
  overflow: auto;
  padding: 18px 0 4px;
  color: var(--ink);
  font-family: "Iowan Old Style", "Noto Serif SC", "Songti SC", serif;
  font-size: 1.08rem;
  line-height: 1.9;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.button {
  min-height: 48px;
  padding: 10px 16px;
  border: 1px solid transparent;
  border-radius: 6px;
  font-weight: 700;
  line-height: 1.25;
  transition: background-color 140ms ease, border-color 140ms ease, color 140ms ease;
}

.button-primary {
  color: #fffdf8;
  background: var(--teal);
}

.button-primary:hover:not(:disabled) {
  background: var(--teal-dark);
}

.button-secondary {
  color: var(--ink);
  border-color: var(--line);
  background: var(--surface);
}

.button-secondary:hover:not(:disabled) {
  border-color: var(--teal);
  color: var(--teal-dark);
}

.button-danger {
  color: #fffdf8;
  background: var(--coral);
}

.button-danger:hover:not(:disabled) {
  background: var(--coral-dark);
}

.button:disabled {
  opacity: 0.48;
}

.open-panel .button {
  width: 100%;
}

.muted-copy {
  margin: 12px 0 0;
  font-size: 0.88rem;
}

.assurance-copy {
  margin: 24px 0 0;
  padding-left: 14px;
  border-left: 3px solid var(--teal);
  color: var(--ink-muted);
  font-size: 0.92rem;
}

.action-heading {
  margin-bottom: 18px;
}

.action-heading .muted-copy {
  margin-bottom: 0;
}

.action-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.action-grid .button {
  min-width: 0;
}

.text-button {
  min-height: 40px;
  padding: 6px 0;
  border: 0;
  color: var(--teal-dark);
  background: transparent;
  font-weight: 700;
  text-align: left;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.report-panel label,
.report-panel select {
  display: block;
  width: 100%;
}

.trusted-contact-form {
  display: grid;
  gap: 16px;
}

.field label,
.field input {
  display: block;
  width: 100%;
}

.field label {
  margin-bottom: 8px;
  font-weight: 700;
}

.field input {
  min-height: 48px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
}

.field input:focus {
  border-color: var(--teal);
}

.field-error {
  margin: 7px 0 0;
  color: var(--coral-dark);
  font-size: 0.84rem;
}

.trusted-code-panel {
  display: grid;
  gap: 16px;
}

.trusted-contact-form .button {
  width: 100%;
}

.trusted-result-panel h2 {
  margin-bottom: 8px;
}

.trusted-result-panel .muted-copy {
  margin: 0;
}

.report-panel label {
  margin-bottom: 8px;
  font-weight: 700;
}

.report-panel select {
  min-height: 48px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--ink);
  background: var(--surface);
}

.report-actions {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 16px;
}

.site-footer {
  padding-top: 22px;
  color: var(--ink-muted);
  font-size: 0.78rem;
}

.site-footer p {
  margin-bottom: 0;
}

[hidden] {
  display: none !important;
}

@media (max-width: 520px) {
  .page-shell {
    width: min(100% - 24px, 720px);
    padding-top: 16px;
  }

  .intro {
    padding: 42px 0 24px;
  }

  h1 {
    font-size: 2.15rem;
  }

  .surface {
    padding: 18px;
  }

  .preview-grid,
  .action-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .action-grid .button {
    width: 100%;
  }

  .report-actions {
    align-items: stretch;
    flex-direction: column;
    gap: 8px;
  }

  .report-actions .text-button {
    text-align: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
