/* === Reset & Base === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

@font-face {
  font-family: 'JfzsSealScript';
  src: url('../JFZSKSealScript_V3.5.ttf') format('truetype');
  font-display: swap;
}

:root {
  --ink: #0d0d1a;
  --ink-deep: #1a1a2e;
  --ink-wash: #2d2d44;
  --ink-mist: #4a4a5e;
  --ink-fade: #6a6a7e;
  --paper: #f0ebe0;
  --paper-light: #f7f2e8;
  --paper-warm: #ede5d3;
  --paper-dark: #e0d8c6;
  --seal: #a52a2a;
  --seal-deep: #8b2323;
  --seal-bright: #c4382e;
  --gold: #9a7818;
  --gold-light: #c4a032;
  --muted: #7a7165;
  --border: #c9c0a8;
  --border-light: #d9d0bc;
  --shadow-sm: 0 1px 4px rgba(13, 13, 26, 0.06);
  --shadow: 0 2px 12px rgba(13, 13, 26, 0.08);
  --shadow-lg: 0 8px 28px rgba(13, 13, 26, 0.14);
  --radius: 12px;
  --radius-sm: 6px;
  --font-cal: 'Ma Shan Zheng', 'Noto Serif SC', serif;
  --font-heading: 'ZCOOL XiaoWei', 'Noto Serif SC', serif;
  --font-body: 'Noto Serif SC', 'Georgia', serif;
}

html {
  scroll-behavior: smooth;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font-body);
  background: var(--paper);
  color: var(--ink);
  line-height: 1.65;
  min-height: 100vh;
  background-image:
    radial-gradient(ellipse at 15% 85%, rgba(13, 13, 26, 0.04) 0%, transparent 45%),
    radial-gradient(ellipse at 85% 15%, rgba(165, 42, 42, 0.03) 0%, transparent 40%),
    radial-gradient(ellipse at 50% 50%, rgba(154, 120, 24, 0.02) 0%, transparent 60%);
  background-attachment: fixed;
}

/* Paper grain texture overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.4;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='200' height='200'%3E%3Cfilter id='n'%3E%3CfeTurbulence baseFrequency='0.9' numOctaves='2' /%3E%3C/filter%3E%3Crect width='200' height='200' filter='url(%23n)' opacity='0.06'/%3E%3C/svg%3E");
}

#app {
  max-width: 540px;
  margin: 0 auto;
  padding: 0 16px 100px;
  min-height: 100vh;
  position: relative;
  z-index: 1;
}

/* === Ink Decoration === */

.ink-mountain {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 120px;
  pointer-events: none;
  opacity: 0.06;
  z-index: 0;
}

.ink-corner {
  position: absolute;
  width: 80px;
  height: 80px;
  pointer-events: none;
  opacity: 0.08;
}

.ink-corner-tl { top: 0; left: 0; }
.ink-corner-br { bottom: 0; right: 0; transform: rotate(180deg); }

/* === App Header === */

.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  background: rgba(240, 235, 224, 0.92);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-light);
  margin: 0 -16px;
  padding-top: max(10px, env(safe-area-inset-top));
}

.app-header-seal {
  width: 34px;
  height: 34px;
  background: var(--seal);
  color: var(--paper-light);
  font-family: var(--font-cal);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 5px;
  box-shadow: 0 2px 6px rgba(165, 42, 42, 0.3);
  flex-shrink: 0;
}

.app-header-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.app-header-cn {
  font-family: var(--font-cal);
  font-size: 14px;
  color: var(--seal);
  letter-spacing: 3px;
}

/* 首页 header 中「名」下方无中文时，不占位，让 Chinese Name 单独垂直对齐印章中心 */
.app-header-cn:empty {
  display: none;
}

.app-header-en {
  font-family: var(--font-heading);
  font-size: 14px;
  color: var(--muted);
}

/* === Select Wrapper (Custom Dropdown) === */

.select-wrap {
  position: relative;
  width: 100%;
}

.form-select {
  width: 100%;
  padding: 12px 38px 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  transition: border-color 0.2s, box-shadow 0.2s;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  cursor: pointer;
}

.form-select:focus {
  outline: none;
  border-color: var(--seal);
  box-shadow: 0 0 0 3px rgba(165, 42, 42, 0.08);
}

.form-select:invalid {
  color: var(--muted);
}

.select-arrow {
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--ink-fade);
  pointer-events: none;
  transition: transform 0.2s;
}

.select-wrap:focus-within .select-arrow {
  transform: translateY(-50%) rotate(180deg);
  color: var(--seal);
}

/* === Bottom Bar === */

.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 540px;
  padding: 12px 16px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
  background: rgba(240, 235, 224, 0.95);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border-light);
  z-index: 50;
  display: flex;
  gap: 10px;
}

.bottom-bar .btn-primary {
  flex: 1;
}

/* === Input View === */

.hero {
  text-align: center;
  padding: 28px 20px 20px;
  position: relative;
}

.hero-seal {
  width: 56px;
  height: 56px;
  margin: 0 auto 18px;
  background: var(--seal);
  color: var(--paper-light);
  font-family: var(--font-cal);
  font-size: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  box-shadow: 0 3px 10px rgba(165, 42, 42, 0.35), inset 0 0 0 2px rgba(255,255,255,0.15);
  transform: rotate(-4deg);
  position: relative;
}

.hero-seal::after {
  content: '';
  position: absolute;
  inset: -3px;
  border-radius: 8px;
  background: var(--seal);
  opacity: 0.15;
  filter: blur(6px);
  z-index: -1;
}

.hero-title {
  font-family: var(--font-heading);
  font-size: 26px;
  font-weight: 400;
  color: var(--ink);
  letter-spacing: 1px;
  margin-bottom: 6px;
  position: relative;
  display: inline-block;
}

.hero-title-cn {
  display: none;
}

.hero-subtitle {
  font-size: 13px;
  color: var(--muted);
  line-height: 1.6;
  max-width: 320px;
  margin: 0 auto;
}

.hero-divider {
  width: 40px;
  height: 1px;
  background: var(--ink-fade);
  margin: 16px auto 0;
  position: relative;
  opacity: 0.4;
}

.hero-divider::before,
.hero-divider::after {
  content: '';
  position: absolute;
  top: 50%;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--ink-fade);
  transform: translateY(-50%);
}

.hero-divider::before { left: -8px; }
.hero-divider::after { right: -8px; }

/* === Form Card === */

.form-card {
  background: var(--paper-light);
  border-radius: var(--radius);
  padding: 28px 22px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  position: relative;
}

.form-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 20%;
  right: 20%;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--seal), transparent);
  opacity: 0.3;
  border-radius: 2px;
}

.form-group {
  margin-bottom: 22px;
}

.form-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 10px;
  letter-spacing: 0.3px;
}

.form-label-cn {
  font-family: var(--font-cal);
  font-size: 14px;
  color: var(--seal);
  font-weight: 400;
}

.form-optional {
  font-weight: 400;
  color: var(--muted);
  font-size: 11px;
}

.form-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 6px;
}

.form-input {
  width: 100%;
  padding: 12px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 15px;
  color: var(--ink);
  background: var(--paper);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--seal);
  box-shadow: 0 0 0 3px rgba(165, 42, 42, 0.08);
}

.form-input::placeholder {
  color: var(--muted);
  opacity: 0.5;
}

/* === Gender Selector === */

.gender-selector {
  display: flex;
  gap: 10px;
}

.gender-option {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  background: var(--paper);
  transition: all 0.2s;
  position: relative;
}

.gender-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.gender-option .cn-mark {
  font-family: var(--font-cal);
  font-size: 16px;
  opacity: 0.5;
}

.gender-option.selected {
  border-color: var(--seal);
  color: var(--seal);
  background: rgba(165, 42, 42, 0.04);
  font-weight: 700;
}

.gender-option.selected .cn-mark {
  opacity: 1;
  color: var(--seal);
}

/* === Name Length Selector === */

.length-selector {
  display: flex;
  gap: 8px;
}

.length-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  background: var(--paper);
  transition: all 0.2s;
  position: relative;
  text-align: center;
}

.length-option input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.length-cn {
  font-family: var(--font-cal);
  font-size: 15px;
  color: var(--muted);
  opacity: 0.6;
  transition: all 0.2s;
}

.length-label {
  font-size: 12px;
  font-weight: 600;
  color: var(--ink);
}

.length-hint {
  font-size: 9px;
  color: var(--muted);
  opacity: 0.7;
}

.length-option.selected {
  border-color: var(--seal);
  background: rgba(165, 42, 42, 0.04);
}

.length-option.selected .length-cn {
  opacity: 1;
  color: var(--seal);
}

.length-option.selected .length-label {
  color: var(--seal);
}

/* === Trait Chips === */

.chips-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 7px 13px;
  border: 1px solid var(--border);
  border-radius: 18px;
  cursor: pointer;
  background: var(--paper);
  transition: all 0.2s;
  user-select: none;
}

.chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.chip-label {
  font-size: 12px;
  color: var(--ink);
  font-weight: 500;
}

.chip-cn {
  font-family: var(--font-cal);
  font-size: 12px;
  color: var(--muted);
}

.chip.selected {
  border-color: var(--seal);
  background: rgba(165, 42, 42, 0.06);
}

.chip.selected .chip-label,
.chip.selected .chip-cn {
  color: var(--seal);
}

/* === Primary Button === */

.btn-primary {
  width: 100%;
  padding: 15px;
  background: var(--ink-deep);
  color: var(--paper-light);
  border: none;
  border-radius: var(--radius-sm);
  font-family: var(--font-heading);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  transition: transform 0.15s, box-shadow 0.2s, background 0.2s;
  letter-spacing: 1px;
  position: relative;
  overflow: hidden;
}

.btn-primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.08), transparent);
  transition: left 0.5s;
}

.btn-primary:hover {
  transform: translateY(-1px);
  background: var(--ink);
  box-shadow: 0 6px 20px rgba(13, 13, 26, 0.3);
}

.btn-primary:hover::before {
  left: 100%;
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-arrow {
  transition: transform 0.2s;
  font-family: var(--font-body);
}

.btn-primary:hover .btn-arrow {
  transform: translateX(4px);
}

/* === More Options Toggle === */

.more-options-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 14px 16px;
  margin-top: 4px;
  margin-bottom: 4px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-family: var(--font-body);
  color: var(--ink-mist);
  transition: all 0.25s ease;
}

.more-options-toggle:hover,
.more-options-toggle.active {
  border-color: var(--seal);
  border-style: solid;
  background: rgba(165, 42, 42, 0.03);
  color: var(--ink);
}

.more-options-text {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
}

.more-options-cn {
  font-family: var(--font-cal);
  font-size: 15px;
  color: var(--seal);
  font-weight: 400;
}

.more-options-en {
  font-size: 11px;
  color: var(--muted);
  letter-spacing: 0.3px;
}

.more-options-arrow {
  transition: transform 0.3s ease;
  flex-shrink: 0;
}

.more-options-toggle.active .more-options-arrow {
  transform: rotate(180deg);
}

.more-options-section {
  max-height: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-height 0.35s ease, opacity 0.3s ease, margin 0.3s ease;
  margin-top: 0;
}

.more-options-section.expanded {
  max-height: 800px;
  opacity: 1;
  margin-top: 20px;
}

/* === Features Strip === */

.features-strip {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-top: 28px;
  padding: 20px 8px 0;
  border-top: 1px solid var(--border-light);
}

.feature-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  text-align: center;
  flex: 1;
}

.feature-icon {
  width: 28px;
  height: 28px;
  border: 1px solid var(--gold);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-cal);
  font-size: 13px;
  color: var(--gold);
}

.feature-item span {
  font-size: 10px;
  color: var(--muted);
  line-height: 1.3;
}

/* === Results View === */

.results-header {
  text-align: center;
  padding: 20px 0 20px;
}

.results-title {
  font-family: var(--font-heading);
  font-size: 22px;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: 4px;
}

.results-title-cn {
  font-family: var(--font-cal);
  font-size: 14px;
  color: var(--seal);
  letter-spacing: 4px;
  margin-bottom: 8px;
}

.results-subtitle {
  font-size: 12px;
  color: var(--muted);
}

/* === Name Cards === */

.cards-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.name-card {
  background: var(--paper-light);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-light);
  position: relative;
  animation: cardAppear 0.5s ease-out backwards;
}

.name-card:nth-child(2) { animation-delay: 0.1s; }
.name-card:nth-child(3) { animation-delay: 0.2s; }
.name-card:nth-child(4) { animation-delay: 0.3s; }

@keyframes cardAppear {
  from {
    opacity: 0;
    transform: translateY(16px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.name-card.primary {
  border: 1.5px solid var(--seal);
  box-shadow: 0 4px 24px rgba(165, 42, 42, 0.12);
}

.name-card.primary::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--seal-deep), var(--seal-bright), var(--seal-deep));
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 18px 0;
}

.badge-top {
  font-size: 10px;
  font-weight: 700;
  color: var(--seal);
  background: rgba(165, 42, 42, 0.08);
  padding: 3px 10px;
  border-radius: 3px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.btn-back-to-input {
  background: none;
  border: none;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  font-family: var(--font-body);
  padding: 4px 8px;
}

.btn-back-to-input:hover {
  color: var(--ink);
}

/* === Calligraphy Area === */

.calligraphy-area {
  text-align: center;
  padding: 28px 20px 22px;
  position: relative;
  background:
    radial-gradient(ellipse at center, rgba(13, 13, 26, 0.015) 0%, transparent 70%),
    linear-gradient(180deg, var(--paper-light) 0%, var(--paper-warm) 100%);
}

/* Ink splash behind characters */
.calligraphy-area::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200px;
  height: 200px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(13, 13, 26, 0.025) 0%, transparent 60%);
  border-radius: 50%;
  pointer-events: none;
}

.calligraphy-name {
  font-family: var(--font-cal);
  font-size: 54px;
  color: var(--ink);
  letter-spacing: 6px;
  line-height: 1.4;
  display: flex;
  justify-content: center;
  gap: 8px;
  position: relative;
  z-index: 1;
  flex-wrap: wrap;
}

.char-pair {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  opacity: 0;
  animation: pairAppear 0.7s ease-out forwards;
}

.calligraphy-name .char {
  display: inline-block;
  animation: inkSpread 0.7s ease-out forwards;
}

.char-pinyin {
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink-fade);
  letter-spacing: 1px;
  font-style: italic;
  opacity: 0.75;
}

@keyframes pairAppear {
  0% {
    opacity: 0;
    transform: translateY(12px);
  }
  100% {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes inkSpread {
  0% {
    opacity: 0;
    transform: translateY(12px) scale(0.85);
    filter: blur(3px);
  }
  60% {
    opacity: 0.8;
    filter: blur(1px);
  }
  100% {
    opacity: 1;
    transform: translateY(0) scale(1);
    filter: blur(0);
  }
}

/* Brush stroke divider */
.brush-divider {
  width: 60px;
  height: 2px;
  margin: 14px auto 0;
  background: var(--ink-fade);
  border-radius: 2px;
  position: relative;
  opacity: 0.3;
}

.brush-divider::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 5px;
  height: 5px;
  background: var(--seal);
  border-radius: 50%;
  transform: translate(-50%, -50%);
  opacity: 0.6;
}

/* === Seal Stamp === */

.card-seal {
  position: absolute;
  top: 14px;
  right: 20px;
  z-index: 2;
}

.seal-stamp {
  width: 36px;
  height: 36px;
  background: var(--seal);
  color: var(--paper-light);
  font-family: var(--font-cal);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transform: rotate(6deg);
  box-shadow: 0 2px 6px rgba(165, 42, 42, 0.3);
  opacity: 0.85;
  position: relative;
}

.seal-stamp::after {
  content: '';
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 2px;
}

/* === Surname Phonetic Reason === */

.surname-reason {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px 4px;
  flex-wrap: wrap;
}

.surname-reason-label {
  font-family: var(--font-cal);
  font-size: 13px;
  color: var(--seal);
  background: rgba(165, 42, 42, 0.08);
  padding: 1px 8px;
  border-radius: 3px;
}

.surname-reason-pinyin {
  font-family: var(--font-heading);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: 0.5px;
}

.surname-reason-dash {
  color: var(--muted);
  font-size: 12px;
}

.surname-reason-text {
  font-family: var(--font-body);
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
}

/* === Card Body === */

.card-body {
  padding: 0 22px 8px;
}

.card-section {
  padding: 14px 0;
  border-top: 1px dashed var(--border);
}

.section-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 700;
  color: var(--gold);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 8px;
}

.section-label::before {
  content: '';
  width: 12px;
  height: 1px;
  background: var(--gold);
  opacity: 0.5;
}

.source-text {
  font-size: 13px;
  color: var(--ink);
  font-weight: 700;
  margin-bottom: 4px;
}

.dynasty {
  font-weight: 400;
  color: var(--muted);
  font-size: 11px;
}

.original-text {
  font-family: var(--font-cal);
  font-size: 17px;
  color: var(--ink-wash);
  line-height: 1.8;
  margin: 8px 0;
  letter-spacing: 1px;
}

.translation {
  font-size: 12px;
  color: var(--muted);
  font-style: italic;
  line-height: 1.5;
}

.meaning-text {
  font-size: 13px;
  color: var(--ink-wash);
  line-height: 1.7;
}

/* === Trait Tags === */

.trait-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.trait-tag {
  font-family: var(--font-cal);
  font-size: 13px;
  color: var(--seal);
  background: rgba(165, 42, 42, 0.06);
  padding: 3px 10px;
  border-radius: 3px;
  border: 1px solid rgba(165, 42, 42, 0.12);
}

/* === Card Actions === */

.card-actions {
  display: flex;
  gap: 8px;
  padding: 14px 22px 22px;
}

.btn-pronounce,
.btn-stroke,
.btn-share {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 11px 4px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-pronounce:hover {
  border-color: var(--seal);
  color: var(--seal);
  background: rgba(165, 42, 42, 0.04);
}

.btn-pronounce.speaking {
  border-color: var(--seal);
  color: var(--seal);
  background: rgba(165, 42, 42, 0.08);
}

.btn-pronounce.speaking svg {
  animation: pulse 0.8s ease-in-out infinite;
}

.btn-stroke:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(154, 120, 24, 0.05);
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

.btn-share:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper-light);
}

/* === Results Footer === */

.results-footer {
  text-align: center;
  margin-top: 28px;
  padding-bottom: 20px;
  display: none;
}

.btn-secondary {
  padding: 11px 28px;
  background: transparent;
  color: var(--ink);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  border-color: var(--ink);
  background: var(--ink);
  color: var(--paper-light);
}

/* === Toast === */

.toast {
  position: fixed;
  bottom: 30px;
  left: 50%;
  transform: translateX(-50%) translateY(80px);
  background: var(--ink-deep);
  color: var(--paper-light);
  padding: 11px 22px;
  border-radius: 22px;
  font-size: 13px;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
  max-width: 90%;
  text-align: center;
}

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

/* === Footer Brand === */

.brand-footer {
  text-align: center;
  margin-top: 32px;
  padding: 16px 0;
  font-size: 11px;
  color: var(--muted);
  opacity: 0.6;
}

.brand-footer .cn {
  font-family: var(--font-cal);
  font-size: 14px;
  color: var(--seal);
  letter-spacing: 3px;
  margin-bottom: 4px;
  display: block;
}

/* === Stroke Order Modal === */

.stroke-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.stroke-modal.show {
  opacity: 1;
}

.stroke-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13, 13, 26, 0.6);
  backdrop-filter: blur(4px);
}

.stroke-modal-content {
  position: relative;
  background: var(--paper-light);
  border-radius: 16px;
  width: 92%;
  max-width: 420px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 28px 24px 24px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  border: 1px solid var(--border);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
}

.stroke-modal.show .stroke-modal-content {
  transform: scale(1) translateY(0);
}

.stroke-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border: none;
  background: var(--paper);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s;
}

.stroke-close:hover {
  background: var(--ink-deep);
  color: var(--paper-light);
}

.stroke-modal-header {
  text-align: center;
  margin-bottom: 20px;
}

.stroke-title-cn {
  font-family: var(--font-cal);
  font-size: 14px;
  color: var(--seal);
  letter-spacing: 4px;
  display: block;
  margin-bottom: 4px;
}

.stroke-title {
  font-family: var(--font-heading);
  font-size: 20px;
  font-weight: 400;
  color: var(--ink);
  margin-bottom: 6px;
}

.stroke-subtitle {
  font-size: 12px;
  color: var(--muted);
}

.stroke-subtitle strong {
  font-family: var(--font-cal);
  font-size: 16px;
  color: var(--ink);
  font-weight: 400;
}

.stroke-chars-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  margin-bottom: 20px;
}

.stroke-char-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 12px;
  background: var(--paper);
  border-radius: 10px;
  border: 1px solid var(--border-light);
  transition: all 0.3s ease;
  opacity: 0.45;
}

.stroke-char-wrapper.active {
  opacity: 1;
  border-color: var(--seal);
  background: rgba(165, 42, 42, 0.04);
  box-shadow: 0 2px 12px rgba(165, 42, 42, 0.12);
  transform: scale(1.03);
}

.stroke-char-label {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stroke-char-canvas {
  width: 90px;
  height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stroke-char-canvas svg {
  display: block;
}

.stroke-not-found {
  font-size: 11px;
  color: var(--muted);
  text-align: center;
  padding: 20px 0;
}

.stroke-char-pinyin {
  font-size: 14px;
  color: var(--ink-fade);
  font-style: italic;
  letter-spacing: 1px;
}

.stroke-char-controls {
  margin-top: 2px;
}

.btn-stroke-replay {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 5px 12px;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--paper-light);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 11px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-stroke-replay:hover {
  border-color: var(--seal);
  color: var(--seal);
  background: rgba(165, 42, 42, 0.04);
}

.stroke-modal-actions {
  text-align: center;
  padding-top: 16px;
  border-top: 1px dashed var(--border);
}

.btn-stroke-play-all {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 24px;
  border: 1px solid var(--ink-deep);
  border-radius: var(--radius-sm);
  background: var(--ink-deep);
  color: var(--paper-light);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-stroke-play-all:hover {
  background: var(--ink);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(13, 13, 26, 0.25);
}

.stroke-hint {
  font-size: 11px;
  color: var(--muted);
  margin-top: 10px;
}

/* === Share Card Modal === */

.card-modal {
  position: fixed;
  inset: 0;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  padding: 10px;
}

.card-modal.show {
  opacity: 1;
}

.card-modal-overlay {
  position: absolute;
  inset: 0;
  background: rgba(13, 13, 26, 0.65);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.card-modal-content {
  position: relative;
  background: var(--paper-light);
  border-radius: 16px;
  width: 100%;
  max-width: 370px;
  max-height: 92vh;
  overflow-y: auto;
  padding: 28px 18px 18px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.35);
  border: 1px solid var(--border);
  transform: scale(0.9) translateY(20px);
  transition: transform 0.3s ease;
}

.card-modal.show .card-modal-content {
  transform: scale(1) translateY(0);
}

.card-close {
  position: absolute;
  top: 10px;
  right: 10px;
  width: 30px;
  height: 30px;
  border: none;
  background: var(--paper);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.2s;
  z-index: 10;
}

.card-close:hover {
  background: var(--ink-deep);
  color: var(--paper-light);
}

.card-modal-header {
  text-align: center;
  margin-bottom: 14px;
}

.card-title-cn {
  font-family: var(--font-cal);
  font-size: 13px;
  color: var(--seal);
  letter-spacing: 4px;
  display: block;
  margin-bottom: 2px;
}

.card-title {
  font-family: var(--font-heading);
  font-size: 17px;
  font-weight: 400;
  color: var(--ink);
}

.card-preview-area {
  display: flex;
  justify-content: center;
  margin-bottom: 16px;
  overflow-x: auto;
}

/* === Share Card (the actual card image content) === */

.share-card {
  width: 320px;
  flex-shrink: 0;
  background: #f7f2e8;
  border-radius: 10px;
  overflow: hidden;
  position: relative;
  box-shadow: 0 2px 12px rgba(13, 13, 26, 0.08);
  border: 1px solid #d9d0bc;
}

.share-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at 20% 80%, rgba(13, 13, 26, 0.03) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 20%, rgba(165, 42, 42, 0.02) 0%, transparent 45%);
  pointer-events: none;
  z-index: 0;
}

.sc-corner-tl {
  position: absolute;
  top: 0;
  left: 0;
  width: 48px;
  height: 48px;
  pointer-events: none;
  z-index: 1;
}

.sc-mountain {
  position: absolute;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 36px;
  pointer-events: none;
  z-index: 0;
}

.sc-inner {
  padding: 48px 22px 24px;
  position: relative;
  z-index: 2;
}

.sc-name-area {
  text-align: center;
  position: relative;
}

.sc-name-area::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 180px;
  height: 180px;
  transform: translate(-50%, -50%);
  background: radial-gradient(circle, rgba(13, 13, 26, 0.03) 0%, transparent 60%);
  border-radius: 50%;
  pointer-events: none;
}

.sc-name {
  display: flex;
  justify-content: center;
  gap: 8px;
  position: relative;
  z-index: 1;
}

.sc-char-pair {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.sc-char {
  font-family: 'Ma Shan Zheng', 'Noto Serif SC', serif;
  font-size: 54px;
  color: #0d0d1a;
  line-height: 1.15;
}

.sc-char-pinyin {
  font-family: 'Noto Serif SC', serif;
  font-size: 13px;
  color: #6a6a7e;
  font-style: italic;
  letter-spacing: 0.5px;
}

.sc-footer {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  padding: 16px 22px 20px;
  position: relative;
  z-index: 2;
}

.sc-english-box {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.sc-english-label {
  font-family: 'ZCOOL XiaoWei', 'Noto Serif SC', serif;
  font-size: 8px;
  color: #9a9189;
  letter-spacing: 1.5px;
  text-transform: uppercase;
}

.sc-english-text {
  font-family: 'Noto Serif SC', serif;
  font-size: 13px;
  color: #2d2d44;
  font-weight: 500;
  font-style: italic;
}

.sc-brand-box {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 6px;
}

.sc-brand-cn {
  font-family: 'Ma Shan Zheng', 'Noto Serif SC', serif;
  font-size: 12px;
  color: #a52a2a;
  letter-spacing: 2px;
}

/* Square seal stamp — 墨韵取名 (right-to-left vertical reading, carved look) */
.sc-brand-seal {
  width: 52px;
  height: 52px;
  background: #c4382e;
  color: #f7f0e4;
  font-family: 'JfzsSealScript', 'Ma Shan Zheng', 'Noto Serif SC', serif;
  font-weight: normal;
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: 1fr 1fr;
  align-items: center;
  justify-items: center;
  border-radius: 2px;
  box-shadow:
    0 0 0 1px rgba(196, 56, 46, 0.25),
    0 1px 3px rgba(165, 42, 42, 0.25);
  position: relative;
  overflow: hidden;
}

.sc-brand-seal::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 18% 25%, rgba(247, 240, 228, 0.08) 0%, transparent 35%),
    radial-gradient(circle at 82% 75%, rgba(0, 0, 0, 0.08) 0%, transparent 30%),
    radial-gradient(circle at 50% 50%, transparent 60%, rgba(0, 0, 0, 0.06) 100%);
  pointer-events: none;
}

.sc-brand-seal::after {
  content: '';
  position: absolute;
  inset: 0;
  border: 0.5px solid rgba(247, 240, 228, 0.35);
  border-radius: 1px;
  pointer-events: none;
}

.sc-brand-seal .seal-char {
  font-size: 19px;
  line-height: 1;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  color: #f7f0e4;
  width: 100%;
  height: 100%;
  overflow: visible;
}

.sc-seal {
  width: 34px;
  height: 34px;
  background: #a52a2a;
  color: #f7f2e8;
  font-family: 'Ma Shan Zheng', 'Noto Serif SC', serif;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transform: rotate(5deg);
  box-shadow: 0 2px 6px rgba(165, 42, 42, 0.3);
  opacity: 0.85;
  position: relative;
  flex-shrink: 0;
}

.sc-seal::after {
  content: '';
  position: absolute;
  inset: 2px;
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: 2px;
}

/* === Card Modal Action Buttons === */

.card-modal-actions {
  display: flex;
  gap: 10px;
}

.btn-card-save,
.btn-card-share {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-card-save {
  border: 1px solid var(--border);
  background: var(--paper);
  color: var(--ink);
}

.btn-card-save:hover {
  border-color: var(--gold);
  color: var(--gold);
  background: rgba(154, 120, 24, 0.05);
}

.btn-card-share {
  border: 1px solid var(--ink-deep);
  background: var(--ink-deep);
  color: var(--paper-light);
}

.btn-card-share:hover {
  background: var(--ink);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(13, 13, 26, 0.25);
}

.btn-card-save:disabled,
.btn-card-share:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

.card-loading {
  display: inline-block;
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 0.6s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* === Responsive === */

@media (max-width: 380px) {
  .calligraphy-name {
    font-size: 42px;
    letter-spacing: 4px;
    gap: 6px;
  }

  .char-pinyin {
    font-size: 12px;
  }

  .hero-title {
    font-size: 22px;
  }

  .features-strip {
    flex-direction: column;
    gap: 12px;
  }

  .feature-item {
    flex-direction: row;
    gap: 10px;
  }

  .feature-item span {
    text-align: left;
  }

  .form-select {
    font-size: 14px;
    padding: 11px 34px 11px 12px;
  }

  .card-actions {
    gap: 6px;
    padding: 12px 16px 18px;
  }

  .btn-pronounce,
  .btn-stroke,
  .btn-share {
    font-size: 11px;
    padding: 10px 2px;
    gap: 4px;
  }

  .stroke-modal-content {
    padding: 24px 16px 20px;
  }

  .bottom-bar {
    padding: 10px 12px;
    padding-bottom: max(10px, env(safe-area-inset-bottom));
  }

  .card-modal-content {
    padding: 24px 14px 14px;
  }

  .share-card {
    width: 290px;
  }

  .sc-char {
    font-size: 46px;
  }

  .sc-inner {
    padding: 40px 18px 20px;
  }
}

@media (min-width: 600px) {
  #app {
    padding: 0 20px 100px;
  }

  .hero-title {
    font-size: 30px;
  }

  .calligraphy-name {
    font-size: 60px;
  }

  .char-pinyin {
    font-size: 16px;
  }
}

/* === Style Picker (Classical / Popular) — bottom CTA buttons, side by side === */
.style-picker {
  display: flex;
  flex-direction: row;
  gap: 14px;
  margin: 8px auto 34px;
  max-width: 420px;
  padding: 0 4px;
}

.style-option {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 9px 6px;
  background: var(--paper-warm);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  color: var(--ink);
  cursor: pointer;
  font-family: var(--font-body);
  text-align: center;
  transition: all 0.22s ease;
  box-shadow: var(--shadow-sm);
}

.style-option:hover {
  transform: translateY(-1px);
  border-color: var(--seal);
  box-shadow: var(--shadow);
}

.style-cn {
  font-size: 17px;
  font-family: 'STKaiti', 'KaiTi', '楷体', var(--font-heading), serif;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--seal);
}

.style-option:hover .style-cn {
  color: var(--seal-deep);
}

.style-en {
  font-size: 11px;
  font-family: 'STKaiti', 'KaiTi', '楷体', var(--font-body), serif;
  letter-spacing: 0.3px;
  color: var(--ink-fade);
  opacity: 0.92;
}
