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

:root {
  --bg:        var(--tg-theme-bg-color, #1c1c1e);
  --bg2:       var(--tg-theme-secondary-bg-color, #2c2c2e);
  --text:      var(--tg-theme-text-color, #ffffff);
  --hint:      var(--tg-theme-hint-color, #8e8e93);
  --accent:    var(--tg-theme-button-color, #0a84ff);
  --btn-text:  var(--tg-theme-button-text-color, #ffffff);
  --radius:    12px;
  --gap:       12px;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  min-height: 100vh;
  padding-top: 0;
  padding-bottom: 100px;
}

/* ── Nav ── */
.nav {
  position: fixed;
  bottom: 12px;
  left: 12px;
  right: 12px;
  background: var(--bg2);
  display: flex;
  border-radius: 50px;
  box-shadow: 0 4px 24px rgba(0,0,0,0.4);
  z-index: 100;
  padding: 4px;
}
.nav-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 10px 0;
  border: none;
  background: none;
  color: var(--hint);
  font-size: 10px;
  cursor: pointer;
  transition: color .15s, background .15s;
  border-radius: 45px;
}
.nav-btn.active {
  color: var(--accent);
  background: rgba(10,132,255,0.12);
}
.nav-btn svg { width: 22px; height: 22px; }

/* ── Screens ── */
.screen { display: none; padding: 0 var(--gap) var(--gap); }
.screen.active { display: block; }

/* ── Header ── */
.header {
  padding: 16px var(--gap) 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 60px;
}
.header-title { font-size: 20px; font-weight: 700; color: var(--text); opacity: 0.9; }
.header-title-add { margin-bottom: 24px; }
.header-title-summary { margin-bottom: 20px; text-align: center; }
.header-title-spaced { margin-bottom: 24px; display: block; }
.header-sub { font-size: 14px; color: var(--hint); }

/* ── Card ── */
.card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: var(--gap);
}
.garden-card { padding: 18px 16px 14px; }
.garden-item { margin-bottom: 14px; }
.garden-item:last-child { margin-bottom: 0; }
.garden-info {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text);
}
.garden-bar {
  height: 6px;
  background: var(--bg);
  border-radius: 3px;
  overflow: hidden;
}
.garden-fill {
  height: 100%;
  width: 0%;
  transition: width 0.8s cubic-bezier(0.4, 0, 0.2, 1);
}
.seeds { background: #8e8e93; }
.sprouts { background: #ff9500; }
.trees { background: #34c759; }
.diamonds { background: #5856d6; }

.card-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--hint);
  margin-bottom: 10px;
}

/* ── Button ── */
.btn {
  width: 100%;
  padding: 14px;
  border-radius: var(--radius);
  border: none;
  background: var(--accent);
  color: var(--btn-text);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: var(--gap);
  transition: opacity .15s;
}
.btn:active { opacity: .8; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn.secondary {
  background: var(--bg2);
  color: var(--text);
}

/* ── Stats row ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--gap);
  margin-bottom: var(--gap);
}
.stats-grid-3col {
  grid-template-columns: 1fr 1fr 1fr;
  margin-bottom: 20px;
}
.stat-card {
  background: var(--bg2);
  border-radius: var(--radius);
  padding: 14px;
  text-align: center;
}
.stat-card-small { padding: 10px; }
.stat-icon { font-size: 18px; margin-bottom: 4px; }
.stat-val { font-size: 28px; font-weight: 700; }
.stat-val-small { font-size: 18px; }
.stat-label { font-size: 12px; color: var(--hint); margin-top: 2px; }

.card-summary { text-align: center; padding: 24px 16px; }

/* ── Practice ── */
.practice-screen-content {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 160px);
  padding: 0;
}
.practice-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
  position: relative;
}
.prog-pill {
  background: rgba(48, 209, 88, 0.15);
  color: #30d158;
  padding: 4px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.02em;
}
.practice-badge {
  padding: 4px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  font-weight: 800;
  font-size: 10px;
  letter-spacing: 0.05em;
}
.practice-badge-new { background: rgba(48, 209, 88, 0.15); color: #30d158; }
.practice-badge-review { background: rgba(10, 132, 255, 0.15); color: var(--accent); }

.word-card-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  perspective: 1200px;
  position: relative;
  touch-action: none;
}

.word-card {
  width: 100%;
  max-width: 340px;
  height: 440px;
  background: var(--bg2);
  border-radius: 32px;
  position: relative;
  transform-style: preserve-3d;
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.1), background-color 0.3s ease, border-color 0.3s ease;
  cursor: pointer;
  user-select: none;
  box-shadow: 0 12px 40px rgba(0,0,0,0.3);
  border: 2px solid transparent;
}
.word-card.swiping { transition: none !important; }
.word-card.flipped { transform: rotateY(180deg); }

.word-face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px;
  text-align: center;
}
.word-back { transform: rotateY(180deg); }

.word-main { 
  font-size: 32px; 
  font-weight: 800; 
  margin-bottom: 12px; 
  letter-spacing: -0.02em;
  color: var(--text);
}
.word-trans { 
  font-size: 28px; 
  color: var(--accent); 
  font-weight: 700;
  letter-spacing: -0.01em;
}
.word-example { 
  font-size: 16px; 
  color: var(--text);
  opacity: 0.5;
  margin-top: 24px; 
  line-height: 1.5;
  width: 100%;
}

/* Swipe accent colors - Forced visibility */
.word-card.swipe-left { background-color: rgba(255, 69, 58, 0.25) !important; border-color: #ff453a !important; }
.word-card.swipe-right { background-color: rgba(48, 209, 88, 0.25) !important; border-color: #30d158 !important; }
.word-card.swipe-up { background-color: rgba(255, 214, 10, 0.25) !important; border-color: #ffd60a !important; }

.practice-footer {
  padding-top: 20px;
  display: flex;
  justify-content: center;
  gap: 12px;
}

.btn-practice-footer {
  width: auto;
  min-width: 80px;
  height: 48px;
  padding: 0 24px;
  font-size: 14px;
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 24px;
}
.btn-practice-footer svg { width: 20px; height: 20px; }

/* ── Add words ── */
textarea {
  width: 100%;
  min-height: 140px;
  background: var(--bg2);
  border: none;
  border-radius: var(--radius);
  padding: 12px;
  color: var(--text);
  font-size: 15px;
  resize: vertical;
  outline: none;
  margin-bottom: var(--gap);
}
textarea::placeholder { color: var(--hint); }

/* ── Settings ── */
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.settings-row:last-child { border-bottom: none; }
.settings-label { font-size: 15px; }
.settings-value { color: var(--hint); font-size: 15px; }

.practice-switch {
  display: flex;
  background: var(--bg);
  border-radius: 10px;
  padding: 3px;
  gap: 0;
}
.practice-opt, .lang-opt {
  flex: 1;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: none;
  color: var(--hint);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.practice-opt.active, .lang-opt.active {
  background: var(--accent);
  color: var(--btn-text);
}

/* ── Stepper ── */
.stepper {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: 10px;
  padding: 2px;
}
.stepper button {
  width: 36px;
  height: 36px;
  border: none;
  background: none;
  color: var(--accent);
  font-size: 20px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stepper span {
  min-width: 40px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
}

select {
  appearance: none;
  -webkit-appearance: none;
  background: var(--bg);
  color: var(--text);
  border: none;
  padding: 8px 12px;
  border-radius: 10px;
  font-size: 15px;
  font-family: inherit;
  outline: none;
  text-align: right;
}

.time-wrap {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--bg);
    padding: 4px 10px;
    border-radius: 10px;
}

input[type="time"], input[type="number"] {
  background: none;
  border: none;
  color: var(--text);
  font-size: 15px;
  outline: none;
  font-family: inherit;
}
input[type="number"] { text-align: right; width: 60px; background: var(--bg); padding: 4px 10px; border-radius: 10px; }

/* ── Summary ── */
.summary-icon { font-size: 40px; margin-bottom: 12px; }
.summary-msg { font-size: 18px; font-weight: 700; }

.text-good { color: #30d158; }
.text-hard { color: #ffd60a; }
.text-again { color: #ff453a; }
.text-hint { color: var(--hint); }
.text-accent { color: var(--accent); }

mark {
  background: rgba(10, 132, 255, 0.25);
  color: var(--accent);
  border-radius: 2px;
  padding: 0 2px;
}

/* ── Utility ── */
.mt-8 { margin-top: 8px; }
.p-gap { padding: var(--gap); }
.px-gap { padding-left: var(--gap); padding-right: var(--gap); }
.p-0-gap { padding: 0 var(--gap); }

/* ── Search ── */
.search-input-wrap { position: relative; margin-bottom: var(--gap); }
.search-input {
  width: 100%;
  background: var(--bg2);
  border: none;
  border-radius: var(--radius);
  padding: 12px 16px;
  color: var(--text);
  font-size: 15px;
  outline: none;
}
.search-input::placeholder { color: var(--hint); }
.no-results { text-align: center; padding: 20px; color: var(--hint); }
.word-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.word-row:last-child { border-bottom: none; }
.word-row-content { cursor: pointer; flex: 1; }
.word-row-text { font-size: 15px; }
.word-row-trans { font-size: 14px; color: var(--hint); }
.del-btn {
  background: none;
  border: none;
  color: #ff453a;
  font-size: 20px;
  cursor: pointer;
  padding: 0 0 0 12px;
  flex-shrink: 0;
}

/* ── Toast ── */
.toast {
  position: fixed;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.8);
  color: #fff;
  padding: 10px 20px;
  border-radius: 20px;
  font-size: 14px;
  opacity: 0;
  transition: all .25s;
  pointer-events: none;
  z-index: 200;
  white-space: nowrap;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── File Input ── */
.file-input-label {
    display: block;
    text-align: center;
    padding: 10px;
    color: var(--accent);
    font-size: 14px;
    cursor: pointer;
    margin-bottom: var(--gap);
}
#file-input { display: none; }

.btn-share {
  display: block;
  margin: 0 auto;
  padding: 8px 16px;
  border: none;
  border-radius: var(--radius);
  background: var(--bg);
  color: var(--accent);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity .15s;
}
.btn-share:active { opacity: .8; }
.btn-danger { color: #ff453a; }

.btn-row {
  display: flex;
  justify-content: center;
  gap: 12px;
}

/* ── Edit sheet ── */
.edit-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
}
.edit-overlay.open { display: block; }
.edit-sheet {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: var(--bg2);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 20px var(--gap) 32px;
  z-index: 301;
  transform: translateY(100%);
  transition: transform .25s ease;
}
.edit-sheet.open { transform: translateY(0); }
.edit-sheet-title {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 16px;
  text-align: center;
}
.edit-input {
  display: block;
  width: 100%;
  background: var(--bg);
  border: none;
  border-radius: var(--radius);
  padding: 12px;
  color: var(--text);
  font-size: 15px;
  outline: none;
  margin-bottom: 10px;
  font-family: inherit;
}
.edit-input::placeholder { color: var(--hint); }

.info-footer {
    margin-top: 20px;
    text-align: center;
    color: var(--hint);
    font-size: 12px;
}
