/* ================================================
   Garden Bloom — 记单词
   Coral + Sage on warm cream. Botanical, fresh, alive.
   ================================================ */

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

:root {
  --c-bg:       #fef9f0;
  --c-surface:  #ffffff;
  --c-coral:    #e8734a;
  --c-coral-lt: #fef3ea;
  --c-sage:     #7d9d7b;
  --c-sage-lt:  #eef4ed;
  --c-sage-dk:  #5c7a5a;
  --c-text:     #3d3535;
  --c-text-2:   #9b8e84;
  --c-border:   #f0e8dd;
  --c-danger:   #e05560;
  --c-danger-lt:#fef0f1;
  --c-amber:    #e8a850;
  --c-amber-lt: #fef8ef;
  --c-sky:      #6bacc4;
  --c-sky-lt:   #eef7fa;
  --radius-sm:  10px;
  --radius:     18px;
  --radius-lg:  24px;
  --shadow:     0 2px 12px rgba(61,53,53,.06);
  --shadow-md:  0 4px 20px rgba(61,53,53,.08);
  --shadow-lg:  0 12px 40px rgba(61,53,53,.12);
  --tab-h:      68px;
  --header-h:   56px;
  --font-display: 'Playfair Display', Georgia, serif;
  --font-body:    'Quicksand', 'SF Pro Rounded', sans-serif;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-body);
  background: var(--c-bg);
  color: var(--c-text);
  line-height: 1.6;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  padding-bottom: var(--tab-h);
  padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
  user-select: none;
  overscroll-behavior: none;
  -webkit-overflow-scrolling: touch;
  background-image:
    radial-gradient(ellipse at 20% 5%, rgba(232,115,74,.04) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 30%, rgba(125,157,123,.04) 0%, transparent 50%),
    radial-gradient(ellipse at 50% 80%, rgba(232,168,80,.03) 0%, transparent 40%);
}

/* --- Header --- */
header {
  position: sticky;
  top: 0;
  z-index: 10;
  background: rgba(254,249,240,.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  padding: 0 20px;
  padding-top: env(safe-area-inset-top, 0px);
  height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid transparent;
}
header.scrolled { border-bottom-color: var(--c-border); }
header h1 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--c-text);
  letter-spacing: -.01em;
}
header .date {
  font-size: .82rem;
  color: var(--c-text-2);
  font-weight: 500;
  background: var(--c-surface);
  padding: 5px 14px;
  border-radius: 99px;
  box-shadow: var(--shadow);
}

/* --- Tab Bar --- */
#tab-bar {
  position: fixed;
  bottom: 12px;
  bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  width: calc(100% - 32px);
  max-width: 448px;
  height: var(--tab-h);
  background: rgba(255,255,255,.88);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: 99px;
  display: flex;
  z-index: 10;
  box-shadow: 0 4px 24px rgba(61,53,53,.10), 0 0 0 1px rgba(240,232,221,.8);
  padding: 4px;
}
#tab-bar button {
  flex: 1;
  border: none;
  background: none;
  font-family: var(--font-body);
  font-size: .8rem;
  font-weight: 600;
  color: var(--c-text-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  cursor: pointer;
  border-radius: 99px;
  transition: all .25s cubic-bezier(.4,0,.2,1);
  position: relative;
}
#tab-bar button.active {
  color: var(--c-coral);
  background: var(--c-coral-lt);
}
#tab-bar button .icon { font-size: 1.25rem; transition: transform .25s; }
#tab-bar button.active .icon { transform: scale(1.1); }

/* --- Pages --- */
.tab-page { display: none; padding: 20px 16px; animation: fadeUp .35s ease; }
.tab-page.active { display: block; }

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

/* --- Add Word Form --- */
.add-word-form {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-md);
  margin-bottom: 24px;
  border: 1px solid var(--c-border);
}
.add-word-form .row { display: flex; gap: 10px; }
.add-word-form input {
  flex: 1;
  padding: 12px 16px;
  border: 2px solid var(--c-border);
  border-radius: 99px;
  font-size: 16px;
  font-family: var(--font-body);
  font-weight: 500;
  outline: none;
  background: var(--c-bg);
  color: var(--c-text);
  transition: border-color .2s, box-shadow .2s;
}
.add-word-form input:focus {
  border-color: var(--c-coral);
  box-shadow: 0 0 0 4px var(--c-coral-lt);
}
.add-word-form input::placeholder { color: var(--c-text-2); font-weight: 400; }
.add-word-form button[type="submit"] {
  padding: 12px 22px;
  background: var(--c-coral);
  color: #fff;
  border: none;
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: transform .15s, box-shadow .15s;
  box-shadow: 0 4px 14px rgba(232,115,74,.3);
}
.add-word-form button[type="submit"]:active { transform: scale(.95); }

/* Manual fill */
.manual-fill { display: none; margin-top: 14px; }
.manual-fill.show { display: block; animation: fadeUp .3s ease; }
.manual-fill input,
.manual-fill textarea {
  width: 100%;
  padding: 11px 16px;
  border: 2px solid var(--c-border);
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-family: var(--font-body);
  margin-bottom: 10px;
  outline: none;
  background: var(--c-bg);
  color: var(--c-text);
  transition: border-color .2s;
  resize: vertical;
}
.manual-fill textarea { min-height: 64px; }
.manual-fill input:focus,
.manual-fill textarea:focus { border-color: var(--c-amber); }
#mf-confirm {
  width: 100%;
  padding: 12px;
  background: var(--c-amber);
  color: #fff;
  border: none;
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  transition: transform .15s;
}
#mf-confirm:active { transform: scale(.97); }

/* --- Section titles --- */
.section-title {
  font-size: .78rem;
  color: var(--c-text-2);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 10px;
  margin-top: 20px;
  padding-left: 4px;
}
.section-title:first-child { margin-top: 0; }

/* --- Word List --- */
.word-list { list-style: none; }
.word-item {
  background: var(--c-surface);
  border-radius: var(--radius);
  padding: 16px 18px;
  margin-bottom: 10px;
  box-shadow: var(--shadow);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: transform .15s, box-shadow .15s;
  border: 1px solid transparent;
  animation: fadeUp .4s ease both;
}
.word-item:nth-child(1) { animation-delay: .02s; }
.word-item:nth-child(2) { animation-delay: .05s; }
.word-item:nth-child(3) { animation-delay: .08s; }
.word-item:nth-child(4) { animation-delay: .11s; }
.word-item:nth-child(5) { animation-delay: .14s; }
.word-item:nth-child(n+6) { animation-delay: .16s; }
.word-item:active { transform: scale(.98); box-shadow: var(--shadow-md); }
.word-item .word-text {
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 600;
  font-style: italic;
  color: var(--c-text);
}
.word-item .word-meta { font-size: .8rem; color: var(--c-text-2); font-weight: 500; }
.badge {
  display: inline-block;
  padding: 5px 14px;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
}
.badge-learn  { background: var(--c-coral-lt); color: var(--c-coral); }
.badge-review { background: var(--c-amber-lt); color: var(--c-amber); }
.badge-done   { background: var(--c-sage-lt);  color: var(--c-sage-dk); }

/* --- Word Card Modal --- */
#word-card {
  border: none;
  border-radius: var(--radius-lg);
  padding: 0;
  width: 90vw;
  max-width: 400px;
  max-height: 85dvh;
  max-height: 85vh;
  box-shadow: var(--shadow-lg);
  overflow: visible;
  animation: cardIn .3s cubic-bezier(.34,1.56,.64,1);
}
.card-wrapper {
  display: flex;
  flex-direction: column;
  max-height: 85dvh;
  max-height: 85vh;
  overflow: hidden;
  border-radius: var(--radius-lg);
  background: var(--c-surface);
}
@keyframes cardIn {
  from { opacity: 0; transform: scale(.9) translateY(20px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
#word-card::backdrop {
  background: rgba(61,53,53,.35);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}
.card-inner {
  padding: 24px 24px 0;
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

.card-stage {
  display: inline-block;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .04em;
  text-transform: uppercase;
  padding: 5px 14px;
  border-radius: 99px;
  margin-bottom: 14px;
}
.card-stage.learn  { background: var(--c-coral-lt); color: var(--c-coral); }
.card-stage.review { background: var(--c-amber-lt); color: var(--c-amber); }

.card-word {
  font-family: var(--font-display);
  font-size: clamp(1.6rem, 5vw, 2.4rem);
  font-weight: 700;
  font-style: italic;
  line-height: 1.1;
  margin-bottom: 6px;
  color: var(--c-text);
}
.card-phonetic {
  font-family: var(--font-body);
  font-size: .9rem;
  color: var(--c-text-2);
  margin-bottom: 16px;
  font-weight: 500;
}

.card-meanings { margin-bottom: 8px; }
.card-meaning {
  padding: 12px 0;
  border-bottom: 1px solid var(--c-border);
}
.card-meaning:last-child { border-bottom: none; }
.card-meaning .pos {
  font-size: .72rem;
  color: var(--c-coral);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .05em;
  margin-bottom: 3px;
}
.card-meaning .def {
  font-size: .95rem;
  line-height: 1.5;
  color: var(--c-text);
}
.card-meaning .ex {
  font-size: .85rem;
  color: var(--c-text-2);
  font-style: italic;
  margin-top: 4px;
  padding-left: 12px;
  border-left: 3px solid var(--c-coral-lt);
}

/* Reveal bar */
.card-reveal-bar {
  text-align: center;
  padding: 20px 0 8px;
}
.card-reveal-bar button {
  padding: 14px 36px;
  background: var(--c-sage-lt);
  color: var(--c-sage-dk);
  border: 2px dashed var(--c-sage);
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
}
.card-reveal-bar button:active {
  background: var(--c-sage);
  color: #fff;
  border-style: solid;
}
.card-content.hidden-answer { display: none; }

/* Actions */
.card-actions {
  display: flex;
  gap: 12px;
  padding: 16px 24px 20px;
  flex-shrink: 0;
  background: var(--c-surface);
  border-top: 1px solid var(--c-border);
}
.card-actions.hidden { display: none; }
.card-actions button {
  flex: 1;
  padding: 14px;
  border: none;
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
}
.btn-forgot   { background: var(--c-danger-lt); color: var(--c-danger); }
.btn-forgot:active { background: var(--c-danger); color: #fff; }
.btn-remember { background: var(--c-sage-lt); color: var(--c-sage-dk); }
.btn-remember:active { background: var(--c-sage); color: #fff; }

/* --- Stats --- */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
.stat-card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  padding: 22px 16px;
  box-shadow: var(--shadow);
  text-align: center;
  transition: transform .15s;
  border: 1px solid var(--c-border);
}
.stat-card:active { transform: scale(.97); }
.stat-card .stat-value {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 700;
  font-style: italic;
  line-height: 1;
}
.stat-card:nth-child(1) .stat-value { color: var(--c-coral); }
.stat-card:nth-child(2) .stat-value { color: var(--c-sage); }
.stat-card:nth-child(3) .stat-value { color: var(--c-amber); }
.stat-card:nth-child(4) .stat-value { color: var(--c-sky); }
.stat-card:nth-child(5) .stat-value { color: var(--c-sage); }
.stat-card:nth-child(6) .stat-value { color: var(--c-danger); }
.stat-card .stat-label {
  font-size: .8rem;
  color: var(--c-text-2);
  margin-top: 6px;
  font-weight: 600;
}

/* --- Search --- */
.search-box {
  width: 100%;
  padding: 12px 18px;
  border: 2px solid var(--c-border);
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: 16px;
  margin-bottom: 16px;
  outline: none;
  background: var(--c-surface);
  color: var(--c-text);
  box-shadow: var(--shadow);
  transition: border-color .2s, box-shadow .2s;
}
.search-box:focus {
  border-color: var(--c-sage);
  box-shadow: 0 0 0 4px var(--c-sage-lt);
}
.search-box::placeholder { color: var(--c-text-2); }

/* --- Empty state --- */
.empty-state {
  text-align: center;
  padding: 56px 16px;
  color: var(--c-text-2);
}
.empty-state .icon { font-size: 3.5rem; margin-bottom: 14px; }
.empty-state p {
  font-size: .95rem;
  font-weight: 500;
}

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--c-text);
  color: var(--c-bg);
  padding: 12px 28px;
  border-radius: 99px;
  font-family: var(--font-body);
  font-size: .88rem;
  font-weight: 600;
  z-index: 100;
  box-shadow: 0 8px 30px rgba(61,53,53,.2);
  animation: toastIn .3s cubic-bezier(.34,1.56,.64,1);
}
@keyframes toastIn {
  from { opacity: 0; transform: translateX(-50%) translateY(16px) scale(.9); }
  to   { opacity: 1; transform: translateX(-50%) translateY(0) scale(1); }
}

/* --- Hidden --- */
.hidden { display: none !important; }

/* --- Standalone (PWA) adjustments --- */
@media (display-mode: standalone) {
  header {
    padding-top: env(safe-area-inset-top, 0px);
    height: calc(var(--header-h) + env(safe-area-inset-top, 0px));
  }
  #tab-bar {
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  }
  body {
    padding-bottom: calc(var(--tab-h) + env(safe-area-inset-bottom, 0px));
  }
  #word-card, .card-wrapper {
    max-height: calc(85dvh - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
  }
}
