:root {
  color-scheme: light;
  --bg: #f8faf7;
  --surface: #ffffff;
  --text: #17201b;
  --muted: #5d6b63;
  --line: #dce5dd;
  --primary: #126b5b;
  --primary-pressed: #0c5648;
  --accent: #d97706;
  --danger: #b91c1c;
  --shadow: 0 14px 32px rgba(18, 47, 38, 0.12);
}

* {
  box-sizing: border-box;
}

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

body {
  min-height: 100vh;
  margin: 0;
  color: var(--text);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", sans-serif;
  letter-spacing: 0;
  background:
    linear-gradient(180deg, rgba(18, 107, 91, 0.09), rgba(248, 250, 247, 0) 34%),
    var(--bg);
}

button {
  font: inherit;
}

.app-shell {
  width: min(100%, 560px);
  min-height: 100vh;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 18px max(26px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.topbar {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
  padding-top: 10px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--primary);
  font-size: 13px;
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: 28px;
  line-height: 1.18;
  font-weight: 750;
}

.status-pill {
  flex: 0 0 auto;
  min-width: 64px;
  padding: 8px 10px;
  border: 1px solid rgba(18, 107, 91, 0.2);
  border-radius: 8px;
  color: var(--primary);
  background: rgba(18, 107, 91, 0.08);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
}

.status-pill.error {
  color: var(--danger);
  border-color: rgba(185, 28, 28, 0.24);
  background: rgba(185, 28, 28, 0.08);
}

.text-panel {
  margin-top: 8px;
  min-height: 300px;
  padding: 24px;
  display: flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.moment-text {
  width: 100%;
  margin: 0;
  font-size: 24px;
  line-height: 1.72;
  font-weight: 650;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.moment-text.loading,
.moment-text.error {
  color: var(--muted);
  font-size: 18px;
  font-weight: 600;
}

.moment-text.error {
  color: var(--danger);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 10px;
}

.primary-button,
.secondary-button {
  min-height: 52px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 17px;
  font-weight: 750;
  cursor: pointer;
  transition:
    transform 160ms ease,
    background 160ms ease,
    border-color 160ms ease,
    color 160ms ease;
}

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

.primary-button:active,
.secondary-button:active {
  transform: translateY(1px);
}

.primary-button:active {
  background: var(--primary-pressed);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.secondary-button {
  color: var(--primary);
  border-color: rgba(18, 107, 91, 0.22);
  background: #eef6f1;
}

.helper-text {
  min-height: 24px;
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.7;
}

.helper-text.error {
  color: var(--danger);
}

.toast {
  position: fixed;
  left: 50%;
  bottom: max(28px, env(safe-area-inset-bottom));
  z-index: 10;
  width: max-content;
  max-width: calc(100vw - 36px);
  padding: 11px 14px;
  border-radius: 8px;
  color: #ffffff;
  background: rgba(23, 32, 27, 0.92);
  font-size: 14px;
  line-height: 1.45;
  text-align: center;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, 12px);
  transition:
    opacity 180ms ease,
    transform 180ms ease;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, 0);
}

.fallback-mask {
  position: fixed;
  inset: 0;
  z-index: 9;
  padding: 18px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  background: rgba(11, 20, 17, 0.42);
}

.fallback-mask[hidden] {
  display: none;
}

.fallback-dialog {
  width: min(100%, 520px);
  padding: 20px;
  border-radius: 8px;
  background: var(--surface);
  box-shadow: 0 18px 48px rgba(11, 20, 17, 0.24);
}

.fallback-dialog h2 {
  margin: 0 0 8px;
  font-size: 20px;
  line-height: 1.3;
}

.fallback-dialog p {
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.65;
}

.fallback-actions {
  display: grid;
  grid-template-columns: 1fr 112px;
  gap: 10px;
  margin-top: 18px;
}

@media (max-width: 380px) {
  .app-shell {
    padding-left: 14px;
    padding-right: 14px;
  }

  h1 {
    font-size: 24px;
  }

  .text-panel {
    min-height: 270px;
    padding: 20px;
  }

  .moment-text {
    font-size: 21px;
  }

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

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

@media (min-width: 700px) {
  .app-shell {
    justify-content: center;
    padding-top: 40px;
    padding-bottom: 40px;
  }
}
