/* 信语 App — Mobile-first Web MVP */

:root {
  --bg: #F5F0EB;
  --bg-warm: #EDE6DC;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #FFFCF8;
  --text: #2C2417;
  --text-secondary: #6B5E4F;
  --text-muted: #9A8B7A;
  --accent: #8B6914;
  --accent-light: #C4A035;
  --accent-bg: rgba(139, 105, 20, 0.08);
  --border: rgba(44, 36, 23, 0.08);
  --shadow: 0 4px 24px rgba(44, 36, 23, 0.08);
  --shadow-lg: 0 12px 40px rgba(44, 36, 23, 0.12);
  --radius: 16px;
  --radius-sm: 12px;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-serif: 'Noto Serif SC', 'Songti SC', serif;
  --phone-w: 390px;
  --phone-h: 844px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  font-family: var(--font-sans);
  background: linear-gradient(145deg, #E8E0D5 0%, #D4C9BA 50%, #C9BAA8 100%);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

/* Desktop phone frame */
.desktop-frame {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  gap: 20px;
}

.phone-shell {
  width: var(--phone-w);
  height: var(--phone-h);
  max-height: calc(100vh - 80px);
  background: #1a1a1a;
  border-radius: 48px;
  padding: 12px;
  box-shadow:
    0 0 0 2px #333,
    0 24px 64px rgba(0, 0, 0, 0.35),
    inset 0 0 0 1px rgba(255, 255, 255, 0.05);
  position: relative;
  flex-shrink: 0;
}

.phone-notch {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 28px;
  background: #1a1a1a;
  border-radius: 0 0 18px 18px;
  z-index: 100;
}

.phone-screen {
  width: 100%;
  height: 100%;
  background: var(--bg);
  border-radius: 38px;
  overflow: hidden;
  position: relative;
}

.phone-home-indicator {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  width: 120px;
  height: 4px;
  background: rgba(255, 255, 255, 0.3);
  border-radius: 2px;
  z-index: 100;
}

.desktop-hint {
  font-size: 0.8rem;
  color: var(--text-secondary);
  text-align: center;
  max-width: 360px;
}

/* Mobile: full screen, no frame */
@media (max-width: 430px) {
  body {
    background: var(--bg);
  }

  .desktop-frame {
    padding: 0;
    min-height: 100dvh;
  }

  .phone-shell {
    width: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    background: var(--bg);
  }

  .phone-notch,
  .phone-home-indicator {
    display: none;
  }

  .phone-screen {
    border-radius: 0;
  }

  .desktop-hint {
    display: none;
  }
}

/* Onboarding */
.onboarding {
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 52px 24px 24px;
  background: linear-gradient(180deg, var(--bg) 0%, var(--bg-warm) 100%);
  overflow: hidden;
}

.onboarding-header {
  margin-bottom: 32px;
}

.onboarding-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  min-height: 32px;
}

.onboard-back-btn {
  border: none;
  background: transparent;
  color: var(--accent);
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  padding: 6px 0;
  font-family: inherit;
}

.onboard-back-btn:active {
  opacity: 0.6;
}

.app-logo {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.15em;
}

.onboarding-nav .step-indicator {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.progress-bar {
  height: 3px;
  background: var(--border);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 8px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-light));
  border-radius: 2px;
  transition: width 0.4s ease;
}

.onboarding-card {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  animation: slideIn 0.4s ease;
}

.onboarding-card h2 {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 8px;
}

.subtitle {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.option-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: 8px;
}

.option-list.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  align-content: start;
}

.option-btn {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  padding: 16px 18px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  cursor: pointer;
  text-align: left;
  transition: all 0.25s ease;
  font-family: inherit;
  color: var(--text);
}

.option-btn:active {
  transform: scale(0.98);
}

.option-btn.selected {
  border-color: var(--accent);
  background: var(--accent-bg);
  box-shadow: 0 0 0 1px var(--accent);
}

.opt-icon {
  font-size: 1.25rem;
}

.opt-label {
  font-size: 0.95rem;
  font-weight: 500;
}

.opt-desc {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.btn-primary {
  width: 100%;
  padding: 16px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--accent) 0%, #A07B1A 100%);
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
  font-family: inherit;
}

.onboarding-actions {
  flex-shrink: 0;
  padding-top: 16px;
  border-top: 1px solid var(--border);
  background: linear-gradient(180deg, transparent 0%, var(--bg) 24%);
}

.btn-primary:active {
  transform: scale(0.98);
}

.btn-primary.disabled,
.btn-primary:disabled {
  opacity: 0.4;
  pointer-events: none;
}

.btn-secondary {
  width: 100%;
  padding: 14px;
  margin-top: 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-solid);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
}

/* Reveal screen */
.reveal-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 28px;
  background: linear-gradient(180deg, #2C2417 0%, #4A3F2F 100%);
  color: #F5F0EB;
  text-align: center;
}

.reveal-animation {
  animation: fadeOut 2s ease 1.5s forwards;
}

.scroll-icon {
  font-size: 3rem;
  animation: float 2s ease-in-out infinite;
  margin-bottom: 16px;
}

.reveal-text {
  font-size: 0.95rem;
  opacity: 0.85;
  animation: pulse 1.5s ease-in-out infinite;
}

.reveal-result {
  opacity: 0;
  animation: fadeInUp 0.8s ease 3s forwards;
  width: 100%;
}

.reveal-greeting {
  font-family: var(--font-serif);
  font-size: 1.25rem;
  margin-bottom: 6px;
}

.reveal-profile {
  font-size: 0.85rem;
  opacity: 0.7;
  margin-bottom: 28px;
}

.widget-preview-large {
  background: rgba(255, 252, 248, 0.12);
  backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 32px;
  cursor: pointer;
  text-align: left;
}

.widget-preview-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  opacity: 0.7;
  margin-bottom: 16px;
}

.widget-verse-text {
  font-family: var(--font-serif);
  font-size: 1.05rem;
  line-height: 1.8;
  margin-bottom: 12px;
}

.widget-ref {
  font-size: 0.8rem;
  opacity: 0.6;
}

.reveal-screen .btn-primary {
  background: rgba(255, 252, 248, 0.95);
  color: var(--text);
}

/* Home / Widget */
.home-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.status-bar {
  display: flex;
  justify-content: space-between;
  padding: 14px 24px 8px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text);
}

.status-icons {
  letter-spacing: 2px;
  font-size: 0.65rem;
}

.home-wallpaper {
  flex: 1;
  padding: 20px 20px 0;
  background:
    radial-gradient(ellipse at 30% 20%, rgba(196, 160, 53, 0.12) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(139, 105, 20, 0.08) 0%, transparent 50%),
    var(--bg);
}

.home-greeting {
  margin-bottom: 32px;
}

.greeting-time {
  font-family: var(--font-serif);
  font-size: 1.4rem;
  font-weight: 600;
  margin-bottom: 4px;
}

.greeting-sub {
  font-size: 0.85rem;
  color: var(--text-secondary);
}

.widget-card {
  background: var(--surface-solid);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform 0.2s;
}

.widget-card:active {
  transform: scale(0.98);
}

.widget-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 14px;
}

.widget-brand {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.05em;
}

.widget-flip-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 0.7rem;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
}

.widget-text {
  font-family: var(--font-serif);
  font-size: 1rem;
  line-height: 1.85;
  color: var(--text);
  margin-bottom: 12px;
}

.widget-reference {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.widget-hint {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 16px;
}

.home-actions {
  display: flex;
  justify-content: center;
  margin-top: 28px;
  padding-bottom: 16px;
}

.btn-refresh-verse {
  padding: 12px 28px;
  border: 1.5px dashed var(--accent-light);
  border-radius: 24px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.2s, transform 0.15s;
}

.btn-refresh-verse:active {
  transform: scale(0.97);
  background: rgba(139, 105, 20, 0.14);
}

/* Reading */
.reading-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--surface-solid);
}

.reading-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 52px 16px 12px;
  border-bottom: 1px solid var(--border);
}

.back-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--accent-bg);
  border-radius: 50%;
  font-size: 1.1rem;
  cursor: pointer;
  color: var(--accent);
}

.reading-header span:not(.header-spacer) {
  font-weight: 600;
  font-size: 0.95rem;
}

.header-spacer {
  width: 36px;
}

.reading-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 20px 100px;
  -webkit-overflow-scrolling: touch;
}

.reading-ref {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 20px;
}

.reading-text {
  font-family: var(--font-serif);
  font-size: 1.1rem;
  line-height: 2;
  margin-bottom: 16px;
}

.reading-text.interactive {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  line-height: 1.9;
}

.reading-text.subtle,
.reading-text-en.subtle {
  font-size: 0.9rem;
  color: var(--text-secondary);
  font-family: var(--font-sans);
  line-height: 1.75;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
}

.reading-text-zh.subtle {
  font-family: var(--font-serif);
  font-size: 1rem;
  color: var(--text);
  line-height: 2;
  padding-top: 12px;
  border-top: 1px dashed var(--border);
  margin-bottom: 16px;
}

.reading-text-zh.subtle.interactive {
  font-size: 0.95rem;
}

.word-tap {
  cursor: pointer;
  border-radius: 3px;
  padding: 0 1px;
  transition: background 0.15s;
}

.word-tap:active,
.word-tap:hover {
  background: var(--accent-bg);
  color: var(--accent);
}

.word-tap.saved {
  background: rgba(139, 105, 20, 0.15);
  border-bottom: 2px solid var(--accent-light);
}

.word-tap.has-zh-pair {
  cursor: help;
}

.word-tap.word-hover,
.word-tap.has-zh-pair:hover,
.word-tap.has-en-pair:hover,
.reading-text .zh-match.pair-highlight,
.word-tap.pair-highlight {
  background: var(--accent-bg);
  color: var(--accent);
}

.reading-text .zh-match {
  transition: background 0.15s, box-shadow 0.15s;
  border-radius: 3px;
  padding: 0 2px;
}

.reading-text .zh-match.pair-highlight,
.reading-text .zh-match.zh-highlight {
  background: repeating-linear-gradient(
    -45deg,
    rgba(196, 160, 53, 0.28),
    rgba(196, 160, 53, 0.28) 2px,
    rgba(196, 160, 53, 0.12) 2px,
    rgba(196, 160, 53, 0.12) 5px
  );
  box-shadow: inset 0 -2px 0 rgba(139, 105, 20, 0.5);
  color: var(--text);
}

.word-tap.pair-highlight {
  background: repeating-linear-gradient(
    -45deg,
    rgba(196, 160, 53, 0.28),
    rgba(196, 160, 53, 0.28) 2px,
    rgba(196, 160, 53, 0.12) 2px,
    rgba(196, 160, 53, 0.12) 5px
  );
  box-shadow: inset 0 -2px 0 rgba(139, 105, 20, 0.5);
  color: var(--accent);
}

.word-tap.word-active {
  background: var(--accent-bg);
  color: var(--accent);
  outline: 2px solid var(--accent-light);
  outline-offset: 1px;
}

/* 双击单词小菜单 */
.word-menu {
  position: absolute;
  z-index: 120;
  min-width: 160px;
  max-width: 220px;
  background: var(--surface-solid);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  padding: 12px;
  animation: menuPop 0.15s ease;
}

.word-menu-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}

.word-menu-head strong {
  font-size: 1rem;
  color: var(--accent);
}

.word-menu-phonetic {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.word-menu-zh {
  font-size: 0.9rem;
  font-weight: 500;
  margin-bottom: 10px;
  line-height: 1.4;
}

.word-menu-btn {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--accent) 0%, #A07B1A 100%);
  color: #fff;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
}

.word-menu-btn:disabled {
  background: var(--bg-warm);
  color: var(--text-muted);
  cursor: default;
}

@keyframes menuPop {
  from { opacity: 0; transform: scale(0.92); }
  to { opacity: 1; transform: scale(1); }
}

.context-box {
  margin-top: 28px;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
}

.context-box h4 {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.context-box p {
  font-size: 0.9rem;
  line-height: 1.7;
  color: var(--text-secondary);
}

.reading-tip {
  margin-top: 20px;
  font-size: 0.8rem;
  color: var(--text-muted);
  padding: 12px;
  background: var(--accent-bg);
  border-radius: var(--radius-sm);
}

/* Vocabulary */
.vocab-screen,
.settings-screen {
  height: 100%;
  display: flex;
  flex-direction: column;
  background: var(--bg);
}

.screen-header {
  padding: 52px 20px 16px;
}

.screen-header h1 {
  font-family: var(--font-serif);
  font-size: 1.5rem;
  font-weight: 600;
}

.header-sub {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-top: 4px;
}

.vocab-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 16px 100px;
  -webkit-overflow-scrolling: touch;
}

.vocab-card {
  background: var(--surface-solid);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}

.vocab-word-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 4px;
}

.vocab-word {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--accent);
}

.vocab-phonetic {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.vocab-delete {
  margin-left: auto;
  width: 28px;
  height: 28px;
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 1.2rem;
  cursor: pointer;
  border-radius: 50%;
}

.vocab-zh {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 8px;
}

.vocab-intro {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 12px;
}

.vocab-link {
  width: 100%;
  padding: 10px;
  border: 1px dashed var(--accent-light);
  border-radius: 8px;
  background: var(--accent-bg);
  color: var(--accent);
  font-size: 0.82rem;
  cursor: pointer;
  font-family: inherit;
  text-align: left;
}

.empty-state {
  text-align: center;
  padding: 60px 24px;
  color: var(--text-muted);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 16px;
}

.empty-state .sub {
  font-size: 0.85rem;
  margin-top: 8px;
}

/* Settings */
.settings-group {
  padding: 0 20px 24px;
}

.settings-group h3 {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 12px;
}

.settings-item {
  display: flex;
  justify-content: space-between;
  padding: 14px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.settings-item span:last-child {
  color: var(--text-secondary);
  text-align: right;
  max-width: 55%;
}

.settings-group.about p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

.settings-desc {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 14px;
}

.mode-toggle {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.mode-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 14px 10px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--surface-solid);
  cursor: pointer;
  font-family: inherit;
  transition: all 0.2s;
}

.mode-btn.active {
  border-color: var(--accent);
  background: var(--accent-bg);
  box-shadow: 0 0 0 1px var(--accent);
}

.mode-title {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text);
}

.mode-sub {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.word-menu-intro {
  font-size: 0.82rem;
  color: var(--text-secondary);
  line-height: 1.5;
  margin-bottom: 12px;
}

.about-privacy {
  margin-top: 10px;
  padding: 10px 12px;
  background: var(--accent-bg);
  border-radius: var(--radius-sm);
  font-size: 0.8rem !important;
}

/* Tab bar */
.tab-bar {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  background: rgba(255, 252, 248, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border);
  padding-bottom: calc(8px + var(--safe-bottom));
  z-index: 50;
}

.tab-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 8px 4px;
  border: none;
  background: transparent;
  cursor: pointer;
  font-family: inherit;
  color: var(--text-muted);
  transition: color 0.2s;
}

.tab-item.active {
  color: var(--accent);
}

.tab-icon {
  font-size: 1.2rem;
}

.tab-label {
  font-size: 0.65rem;
  font-weight: 500;
}

/* Toast */
.toast {
  position: absolute;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(44, 36, 23, 0.88);
  color: #fff;
  padding: 10px 20px;
  border-radius: 24px;
  font-size: 0.85rem;
  opacity: 0;
  transition: opacity 0.3s, transform 0.3s;
  z-index: 150;
  white-space: nowrap;
}

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

/* Animations */
@keyframes slideIn {
  from { opacity: 0; transform: translateX(30px); }
  to { opacity: 1; transform: translateX(0); }
}

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

@keyframes fadeOut {
  to { opacity: 0; visibility: hidden; height: 0; overflow: hidden; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes pulse {
  0%, 100% { opacity: 0.85; }
  50% { opacity: 0.5; }
}

@keyframes slideUp {
  from { transform: translateY(100%); }
  to { transform: translateY(0); }
}

@media (max-width: 430px) {
  .onboarding {
    padding-top: max(52px, env(safe-area-inset-top));
  }

  .reading-header,
  .screen-header {
    padding-top: max(52px, calc(env(safe-area-inset-top) + 12px));
  }
}
