/* ============================================
   iquit · 辞职信工厂 · iOS-Native UI
   主题: 牛皮纸 + 墨黑字 + 红色印章
   ============================================ */

:root {
  --paper: #f4ebd6;
  --paper-2: #ede1c0;
  --paper-deep: #e5d5a8;
  --ink: #1a1410;
  --ink-2: #3d2f24;
  --ink-3: #6e5a48;
  --ink-4: #a08670;
  --stamp: #b3261e;
  --stamp-soft: rgba(179, 38, 30, 0.1);
  --accent-hot: #f57c00;
  --accent-crazy: #d32f2f;
  --accent-decent: #2e7d32;
  --stroke: rgba(26, 20, 16, 0.15);
  --stroke-strong: rgba(26, 20, 16, 0.35);
  --card-bg: #fdf8ec;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
}

* { -webkit-tap-highlight-color: transparent; -webkit-touch-callout: none; }
html, body { margin: 0; padding: 0; overflow-x: hidden; overscroll-behavior-y: none; background: var(--paper); }
body {
  min-height: 100vh; min-height: 100dvh;
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'PingFang SC', 'STSong', 'SimSun', serif;
  -webkit-font-smoothing: antialiased;
  background: var(--paper);
}
input, select, textarea, button { font-family: inherit; -webkit-appearance: none; appearance: none; }

/* 纸张纹理 */
.paper-texture {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.4;
  background-image:
    radial-gradient(ellipse at 15% 10%, rgba(179, 38, 30, 0.06) 0%, transparent 40%),
    radial-gradient(ellipse at 85% 90%, rgba(139, 94, 60, 0.08) 0%, transparent 50%),
    repeating-radial-gradient(circle at 50% 50%, transparent 0 2px, rgba(139, 94, 60, 0.02) 2px 4px);
}
.paper-lines {
  position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: 0.08;
  background: repeating-linear-gradient(to bottom, transparent 0 29px, var(--ink-3) 29px 30px);
}

.app-container {
  position: relative; z-index: 1;
  max-width: 440px; margin: 0 auto;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 40px);
}
.hidden { display: none !important; }

/* ===== Hero ===== */
.hero { padding: 8px 0 20px; animation: fadeUp 0.6s var(--ease-out); }
.brand-stamp-row { display: flex; align-items: center; gap: 16px; margin-bottom: 16px; }
.brand-stamp {
  flex-shrink: 0; width: 72px; height: 72px;
  border: 3px double var(--stamp);
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  background: var(--stamp);
  color: #fef8ec;
  font-size: 20px; font-weight: 800;
  letter-spacing: 0.05em;
  transform: rotate(-4deg);
  font-family: 'STSong', serif;
  box-shadow: 0 3px 8px rgba(179, 38, 30, 0.2);
}
.brand-info { flex: 1; min-width: 0; }
.title {
  font-size: 26px; font-weight: 800;
  letter-spacing: 0.2em; color: var(--ink);
  margin: 0; line-height: 1.15;
  font-family: 'STSong', 'SimSun', serif;
}
.subtitle {
  font-size: 10px; color: var(--ink-3);
  margin: 4px 0 0; letter-spacing: 0.3em;
}
.tagline {
  font-size: 13px; line-height: 1.85;
  color: var(--ink-2); margin: 0; text-align: center;
  padding: 14px 16px;
  border-left: 3px solid var(--stamp);
  border-right: 3px solid var(--stamp);
  background: rgba(255, 255, 255, 0.35);
  border-radius: 2px;
}

/* ===== Fields ===== */
.card-group { animation: fadeUp 0.6s var(--ease-out) 0.1s both; }
.field { margin-bottom: 14px; }
.field-label {
  display: flex; align-items: center; justify-content: space-between;
  font-size: 13px; color: var(--ink-2); font-weight: 600;
  margin-bottom: 8px; padding-left: 2px;
  letter-spacing: 0.05em;
}
.field-optional {
  font-size: 10px; color: var(--ink-3); padding: 2px 8px;
  border: 1px solid var(--stroke); border-radius: 999px;
  font-weight: 400;
}
.select-wrap { position: relative; }
.ios-select, .ios-input, .ios-textarea {
  width: 100%; padding: 14px 16px;
  background: var(--card-bg);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  color: var(--ink); font-size: 16px;
  outline: none;
  transition: all 0.2s var(--ease-out);
  font-family: inherit;
}
.ios-select { padding-right: 40px; background-image: none !important; }
.ios-textarea { resize: none; line-height: 1.6; }
.ios-select:focus, .ios-input:focus, .ios-textarea:focus {
  border-color: var(--stamp);
  box-shadow: 0 0 0 3px var(--stamp-soft);
}
.select-arrow {
  position: absolute; right: 14px; top: 50%; transform: translateY(-50%);
  width: 16px; height: 16px; color: var(--ink-3); pointer-events: none;
}
.counter {
  text-align: right; font-size: 11px; color: var(--ink-3);
  margin-top: 4px; font-variant-numeric: tabular-nums;
}

/* ===== Buttons ===== */
.primary-btn {
  width: 100%; padding: 16px 20px; margin-top: 18px;
  background: var(--ink);
  border: none; border-radius: 12px;
  color: var(--paper);
  font-size: 15px; font-weight: 700;
  letter-spacing: 0.3em;
  cursor: pointer;
  box-shadow: 0 6px 18px -6px rgba(26, 20, 16, 0.5);
  transition: transform 0.2s var(--ease-out);
}
.primary-btn:active { transform: scale(0.97); }

.disclaimer {
  text-align: center; font-size: 11px; line-height: 1.7;
  color: var(--ink-3); margin: 18px 0 0; letter-spacing: 0.03em;
}
.legal-links {
  text-align: center; font-size: 11px; letter-spacing: 0.1em;
  margin: 8px 0 0; color: var(--ink-3); opacity: 0.9;
}
.legal-links a {
  color: var(--stamp-red, #8b2c2c);
  text-decoration: none;
  border-bottom: 0.5px solid rgba(139, 44, 44, 0.4);
  padding-bottom: 1px;
}
.legal-links a:active { opacity: 0.6; }
.legal-links .sep { margin: 0 8px; opacity: 0.5; }

/* ===== Loading ===== */
.loading-wrap { text-align: center; padding: 80px 0; animation: fadeUp 0.5s var(--ease-out); }
.typewriter {
  display: inline-flex; gap: 4px; align-items: center;
  padding: 18px 22px;
  background: var(--card-bg);
  border: 1px solid var(--stroke-strong);
  border-radius: 10px;
  font-size: 24px; font-weight: 700;
  font-family: 'STSong', serif;
  color: var(--ink);
}
.tw-letter {
  opacity: 0;
  animation: tw-appear 0.3s ease forwards;
}
.tw-letter:nth-child(1) { animation-delay: 0.1s; }
.tw-letter:nth-child(2) { animation-delay: 0.3s; }
.tw-letter:nth-child(3) { animation-delay: 0.5s; }
.tw-letter:nth-child(4) { animation-delay: 0.7s; }
.tw-letter:nth-child(5) { animation-delay: 0.9s; }
.tw-cursor {
  color: var(--stamp); font-weight: 400;
  animation: blink 0.8s infinite step-end;
}
@keyframes tw-appear { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes blink { 50% { opacity: 0; } }
.loading-text { margin-top: 20px; font-size: 14px; letter-spacing: 0.3em; color: var(--ink-2); }

/* ===== Tab Bar ===== */
.tab-bar {
  position: relative;
  display: grid; grid-template-columns: repeat(3, 1fr);
  background: var(--paper-2);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 4px;
  margin-bottom: 14px;
}
.tab-btn {
  position: relative; z-index: 2;
  padding: 10px 6px;
  background: transparent; border: none;
  font-size: 13px; color: var(--ink-3);
  font-weight: 600; letter-spacing: 0.1em;
  cursor: pointer;
  border-radius: 9px;
  transition: color 0.3s var(--ease-out);
}
.tab-btn.active { color: var(--ink); }
.tab-indicator {
  position: absolute; top: 4px; left: 4px;
  height: calc(100% - 8px);
  width: calc(33.333% - 0px);
  background: var(--card-bg);
  border-radius: 9px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
  transition: transform 0.35s var(--spring);
  z-index: 1;
  transform: translateX(0);
}
.tab-indicator.pos-1 { transform: translateX(100%); }
.tab-indicator.pos-2 { transform: translateX(200%); }

/* Boss reaction row */
.boss-row, .hr-row {
  display: flex; align-items: center; gap: 12px;
  padding: 10px 14px;
  background: var(--card-bg);
  border: 1px solid var(--stroke);
  border-radius: 10px;
  margin-bottom: 8px;
}
.boss-label, .hr-label {
  font-size: 11px; color: var(--ink-3);
  letter-spacing: 0.2em;
  flex-shrink: 0;
}
.boss-text {
  flex: 1;
  font-size: 14px; color: var(--ink);
  font-style: italic;
}
.stars {
  flex: 1; font-size: 16px; color: var(--stamp);
  letter-spacing: 0.1em;
}

/* ===== Letter Paper ===== */
.poster-card {
  background: var(--card-bg);
  border: 1px solid var(--stroke-strong);
  border-radius: 6px;
  padding: 2px;
  box-shadow: 0 20px 50px -10px rgba(0,0,0,0.15);
  position: relative;
}
.letter-paper {
  padding: 24px 22px;
  background: var(--card-bg);
  border: 1px solid var(--stroke);
  border-radius: 4px;
  position: relative;
  background-image:
    repeating-linear-gradient(to bottom, transparent 0 31px, rgba(110, 90, 72, 0.1) 31px 32px);
  font-family: 'STSong', 'SimSun', serif;
}
.letter-header {
  display: flex; justify-content: space-between; align-items: flex-start;
  border-bottom: 1.5px solid var(--ink);
  padding-bottom: 10px;
  margin-bottom: 14px;
}
.letter-to { display: flex; gap: 6px; align-items: baseline; }
.letter-hint {
  font-size: 11px; color: var(--ink-3); letter-spacing: 0.1em;
}
.letter-to-value {
  font-size: 15px; font-weight: 700; color: var(--ink);
  letter-spacing: 0.1em;
}
.letter-stamp {
  padding: 4px 10px;
  border: 2px solid var(--stamp);
  border-radius: 4px;
  color: var(--stamp);
  font-size: 11px; font-weight: 700;
  letter-spacing: 0.3em;
  transform: rotate(8deg);
  background: rgba(179, 38, 30, 0.05);
}
.letter-title {
  font-size: 18px; font-weight: 700;
  color: var(--ink); margin: 0 0 16px;
  letter-spacing: 0.1em;
  line-height: 1.5;
  text-align: center;
  padding: 6px 0;
  border-top: 1px solid var(--stroke);
  border-bottom: 1px solid var(--stroke);
}
.letter-body {
  font-size: 15px; line-height: 2;
  color: var(--ink-2);
  letter-spacing: 0.05em;
  text-indent: 2em;
  white-space: pre-wrap;
  word-break: break-word;
}
.letter-tags {
  display: flex; flex-wrap: wrap; gap: 6px;
  margin-top: 14px; padding-top: 12px;
  border-top: 1px dashed var(--stroke);
}
.letter-tag {
  font-size: 11px;
  padding: 3px 10px;
  background: var(--stamp-soft);
  color: var(--stamp);
  border: 1px solid var(--stamp);
  border-radius: 999px;
  font-weight: 500;
}
.letter-sign {
  display: flex; align-items: center; justify-content: flex-end;
  gap: 10px; margin-top: 20px;
  padding-top: 12px;
  border-top: 2px solid var(--ink);
}
.sign-line { width: 30px; height: 1px; background: var(--ink); }
.sign-name {
  font-size: 14px; color: var(--ink);
  font-style: italic; letter-spacing: 0.15em;
}

.poster-footer {
  margin-top: 14px; text-align: center;
  font-size: 9px; color: var(--ink-3);
  letter-spacing: 0.2em;
}

/* ===== Action buttons ===== */
.action-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 14px; }
.secondary-btn {
  display: flex; align-items: center; justify-content: center;
  gap: 6px; padding: 12px 14px;
  background: var(--card-bg);
  border: 1px solid var(--ink);
  border-radius: 10px;
  color: var(--ink);
  font-size: 14px; font-weight: 600;
  letter-spacing: 0.1em; cursor: pointer;
  transition: all 0.2s var(--ease-out);
}
.secondary-btn:active { transform: scale(0.96); background: var(--ink); color: var(--paper); }
.btn-icon { width: 16px; height: 16px; flex-shrink: 0; }

.ghost-btn {
  width: 100%; padding: 12px;
  background: transparent;
  border: 1px dashed var(--stroke-strong);
  border-radius: 10px;
  color: var(--ink-3);
  font-size: 13px; cursor: pointer;
  margin-top: 10px;
}
.ghost-btn:active { transform: scale(0.98); }

/* ===== chuanshu ===== */
.chuanshu-entry {
  position: relative; display: block;
  margin-top: 18px; padding: 22px 16px;
  background: #fff;
  border: 1.5px dashed var(--stamp);
  border-radius: 14px;
  text-decoration: none; text-align: center;
}
.chuanshu-eyebrow { font-size: 10px; letter-spacing: 0.4em; color: var(--ink-3); margin: 0 0 6px; }
.chuanshu-title {
  font-size: 17px; font-weight: 800; letter-spacing: 0.3em;
  color: var(--stamp); margin: 0 0 4px;
  font-family: 'STSong', serif;
}
.chuanshu-sub { font-size: 12px; color: var(--ink-3); margin: 0; }

/* ===== Onboarding ===== */
.onboarding-overlay {
  position: fixed; inset: 0; z-index: 9999;
  background: rgba(26, 20, 16, 0.5);
  backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  display: flex; align-items: center; justify-content: center;
  padding: calc(var(--safe-top) + 24px) 20px calc(var(--safe-bottom) + 24px);
  animation: fadeIn 0.3s var(--ease-out);
}
.onboarding-card {
  width: 100%; max-width: 400px;
  background: var(--card-bg);
  border: 1px solid var(--stroke-strong);
  border-radius: 16px; padding: 28px 22px;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
  animation: onboardIn 0.5s var(--spring);
}
.onboarding-icon {
  display: flex; justify-content: center; margin-bottom: 14px;
}
.big-stamp {
  display: inline-block;
  width: 64px; height: 64px;
  border: 3px double var(--stamp);
  border-radius: 6px;
  background: var(--stamp); color: #fef8ec;
  font-size: 32px; font-weight: 800;
  line-height: 58px;
  text-align: center;
  letter-spacing: 0;
  font-family: 'STSong', serif;
  transform: rotate(-6deg);
}
.onboarding-title {
  text-align: center; font-size: 20px; font-weight: 700;
  color: var(--ink); margin: 0 0 4px;
}
.onboarding-subtitle {
  text-align: center; font-size: 12px;
  color: var(--ink-3); margin: 0 0 18px; letter-spacing: 0.25em;
}
.onboarding-rules {
  display: flex; flex-direction: column; gap: 12px;
  padding: 14px; background: var(--paper);
  border: 1px solid var(--stroke); border-radius: 10px;
}
.rule-item { display: flex; gap: 12px; align-items: flex-start; }
.rule-icon { flex-shrink: 0; font-size: 18px; margin-top: 2px; }
.rule-en { font-size: 13px; font-weight: 600; color: var(--ink); }
.rule-zh { font-size: 11px; color: var(--ink-3); margin-top: 1px; }

/* ===== Animations ===== */
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes onboardIn { from { opacity: 0; transform: translateY(20px) scale(0.96); } to { opacity: 1; transform: translateY(0) scale(1); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}
@media (min-width: 768px) {
  .app-container { max-width: 480px; padding-top: calc(var(--safe-top) + 40px); }
}

/* ============ 金句卡 · Punchline Card ============ */
.punchline-wrap {
  margin-top: 28px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
}
.punchline-eyebrow {
  text-align: center;
  font-size: 11px;
  letter-spacing: 0.36em;
  color: var(--ink-3);
  margin: 0;
  text-indent: 0.36em;
}
.punchline-card {
  position: relative;
  aspect-ratio: 4 / 5;
  width: 100%;
  border-radius: 14px;
  background:
    radial-gradient(ellipse at 18% 12%, rgba(179, 38, 30, 0.05) 0%, transparent 45%),
    radial-gradient(ellipse at 86% 92%, rgba(139, 94, 60, 0.08) 0%, transparent 55%),
    repeating-linear-gradient(to bottom, transparent 0 29px, rgba(110, 90, 72, 0.06) 29px 30px),
    var(--card-bg);
  box-shadow:
    0 2px 4px rgba(26, 20, 16, 0.08),
    0 16px 40px rgba(26, 20, 16, 0.15);
  overflow: hidden;
  border: 1px solid var(--stroke);
}
.punchline-card::before {
  content: '';
  position: absolute;
  inset: 12px;
  border: 1px dashed var(--stroke-strong);
  border-radius: 8px;
  pointer-events: none;
}
.punchline-inner {
  position: relative;
  height: 100%;
  padding: 32px 28px 24px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 10px;
}
.punchline-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12px;
  letter-spacing: 0.32em;
  color: var(--ink-2);
  font-weight: 600;
  text-indent: 0.32em;
}
.punchline-stamp-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background: var(--stamp);
  color: var(--paper);
  border-radius: 4px;
  font-family: 'STSong', 'SimSun', serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0;
  text-indent: 0;
  box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}
.punchline-style-tag {
  align-self: flex-start;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--stamp-soft);
  color: var(--stamp);
  font-size: 12px;
  letter-spacing: 0.18em;
  text-indent: 0.18em;
  font-weight: 600;
  border: 1px solid rgba(179, 38, 30, 0.25);
}
.punchline-headline {
  flex: 1;
  display: flex;
  align-items: center;
  font-family: 'STSong', 'SimSun', 'Noto Serif SC', serif;
  font-size: 32px;
  line-height: 1.35;
  font-weight: 700;
  color: var(--ink);
  letter-spacing: 0.04em;
  word-break: break-word;
  padding: 4px 0;
  max-height: 45%;
  overflow: hidden;
  display: -webkit-box;
  -webkit-line-clamp: 4;
  -webkit-box-orient: vertical;
}
.punchline-dash {
  height: 1px;
  background: repeating-linear-gradient(to right, var(--stroke-strong) 0 6px, transparent 6px 12px);
}
.punchline-boss-block {
  padding: 8px 0 4px;
}
.punchline-boss-label {
  font-size: 10px;
  letter-spacing: 0.42em;
  text-indent: 0.42em;
  color: var(--ink-3);
  margin-bottom: 8px;
}
.punchline-boss-text {
  font-family: 'STSong', 'SimSun', serif;
  font-size: 17px;
  line-height: 1.55;
  color: var(--ink-2);
  font-weight: 500;
}
.punchline-footer {
  text-align: center;
  font-size: 10px;
  letter-spacing: 0.32em;
  color: var(--ink-4);
  text-indent: 0.32em;
  margin-top: 4px;
}
.punchline-big-stamp {
  position: absolute;
  bottom: 54px;
  right: 24px;
  width: 76px;
  height: 76px;
  border: 3px double var(--stamp);
  color: var(--stamp);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'STSong', 'SimSun', serif;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-indent: 0.1em;
  transform: rotate(-12deg);
  opacity: 0.78;
  background: rgba(179, 38, 30, 0.03);
  pointer-events: none;
}
