/* ===== המילים שלי — playful theme for a 10-year-old ===== */

:root {
  --purple: #8b5cf6;
  --purple-dark: #7c3aed;
  --pink: #ec4899;
  --pink-light: #fbcfe8;
  --yellow: #fbbf24;
  --green: #34d399;
  --red: #f87171;
  --ink: #3b3054;
  --card: #ffffff;
  --radius: 22px;
  --shadow: 0 6px 20px rgba(139, 92, 246, .18);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: "Segoe UI", "Arial Hebrew", Arial, sans-serif;
  color: var(--ink);
  background: linear-gradient(160deg, #fdf2ff 0%, #ede9fe 45%, #fce7f3 100%);
  min-height: 100vh;
}

.app-header {
  text-align: center;
  padding: 24px 16px 8px;
}
.app-header h1 {
  margin: 0;
  font-size: 2rem;
  background: linear-gradient(90deg, var(--purple), var(--pink));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  cursor: pointer;
}
.subtitle { margin: 4px 0 0; color: #9b8bbf; font-weight: 600; }

#main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
}

.screen { animation: pop-in .25s ease; }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* ===== Buttons ===== */
button {
  font-family: inherit;
  font-size: 1rem;
  border: none;
  cursor: pointer;
  border-radius: var(--radius);
  transition: transform .12s ease, box-shadow .12s ease;
}
button:active { transform: scale(.96); }

.big-btn {
  display: block;
  width: 100%;
  padding: 14px;
  margin: 10px 0;
  font-size: 1.15rem;
  font-weight: 700;
  background: #fff;
  color: var(--purple-dark);
  box-shadow: var(--shadow);
}
.big-btn.primary {
  background: linear-gradient(90deg, var(--purple), var(--pink));
  color: #fff;
}
.big-btn.ghost { background: transparent; box-shadow: none; color: #9b8bbf; }

.small-btn, .tiny-btn {
  padding: 8px 16px;
  background: #fff;
  color: var(--purple-dark);
  font-weight: 600;
  box-shadow: var(--shadow);
}
.tiny-btn { font-size: .85rem; padding: 6px 12px; }
.small-btn.danger { color: var(--red); }

.back-btn {
  background: transparent;
  color: #9b8bbf;
  font-weight: 700;
  padding: 6px 0;
  margin-bottom: 6px;
}

/* ===== Home ===== */
.list-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px 18px;
  margin: 12px 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 14px;
  border: 3px solid transparent;
}
.list-card:hover { border-color: var(--pink-light); }
.list-card .list-emoji { font-size: 1.8rem; }
.list-card .list-info { flex: 1; }
.list-card .list-name { font-weight: 700; font-size: 1.1rem; }
.list-card .list-sub { color: #9b8bbf; font-size: .85rem; margin-top: 2px; }
.list-card .exam-soon {
  background: var(--yellow);
  color: #7c5800;
  border-radius: 999px;
  font-size: .75rem;
  font-weight: 700;
  padding: 4px 10px;
  white-space: nowrap;
}
.empty-msg {
  text-align: center;
  color: #9b8bbf;
  padding: 40px 10px;
  font-size: 1.05rem;
}
.backup-row {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-top: 26px;
  opacity: .8;
}

/* ===== Editor ===== */
.form-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin-bottom: 16px;
}
label { display: block; font-weight: 600; margin: 8px 0; }
input[type="text"], input[type="date"] {
  width: 100%;
  padding: 10px 12px;
  margin-top: 4px;
  border: 2px solid var(--pink-light);
  border-radius: 14px;
  font-size: 1rem;
  font-family: inherit;
  background: #fffafe;
}
input:focus { outline: none; border-color: var(--purple); }

.words-heading { margin: 18px 0 8px; }
.word-row {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  align-items: center;
}
.word-row input { flex: 1; margin-top: 0; }
.word-row .en-input { direction: ltr; text-align: left; }
.word-row .remove-row {
  background: transparent;
  font-size: 1.1rem;
  padding: 4px;
  color: var(--red);
}
.editor-actions { margin-top: 20px; }

/* ===== List view ===== */
.list-meta { color: #9b8bbf; font-weight: 600; margin-top: -6px; }
.practice-menu { display: grid; gap: 12px; margin: 18px 0; }
.mode-btn {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 14px 18px;
  text-align: right;
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  column-gap: 14px;
  align-items: center;
  border: 3px solid transparent;
}
.mode-btn:hover { border-color: var(--pink-light); }
.mode-emoji { grid-row: 1 / 3; font-size: 1.7rem; }
.mode-name { font-weight: 700; font-size: 1.05rem; color: var(--purple-dark); }
.mode-desc { color: #9b8bbf; font-size: .82rem; }

#word-table {
  width: 100%;
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  border-collapse: collapse;
  overflow: hidden;
}
#word-table th, #word-table td { padding: 9px 14px; text-align: right; }
#word-table td:nth-child(2) { direction: ltr; text-align: left; font-weight: 600; color: var(--purple-dark); }
#word-table thead { background: var(--pink-light); }
#word-table tbody tr:nth-child(even) { background: #faf5ff; }
#word-table .row-speak { background: transparent; padding: 2px 6px; font-size: 1rem; }
.list-actions { display: flex; gap: 10px; justify-content: center; margin: 18px 0; }

/* ===== Practice ===== */
.progress-track {
  height: 14px;
  background: #fff;
  border-radius: 999px;
  box-shadow: inset 0 2px 5px rgba(0,0,0,.06);
  overflow: hidden;
  margin: 8px 0 4px;
}
#progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--purple), var(--pink));
  border-radius: 999px;
  transition: width .3s ease;
}
.counter { text-align: center; color: #9b8bbf; font-weight: 700; margin: 4px 0 12px; }

.question-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 26px 20px;
  text-align: center;
}
.question-word {
  font-size: 2.2rem;
  font-weight: 800;
  min-height: 1.3em;
  margin-bottom: 14px;
  color: var(--purple-dark);
}
.question-word.en { direction: ltr; }
.speak-btn {
  background: var(--pink-light);
  color: var(--purple-dark);
  font-weight: 700;
  padding: 10px 20px;
  margin-bottom: 14px;
  font-size: 1.05rem;
}
#answer-input {
  text-align: center;
  font-size: 1.3rem;
  border-radius: 14px;
  margin-bottom: 12px;
}
#answer-input.en { direction: ltr; }
#answer-input.correct { border-color: var(--green); background: #ecfdf5; }
#answer-input.wrong { border-color: var(--red); background: #fef2f2; animation: shake .35s; }
#answer-input.almost { border-color: var(--yellow); background: #fffbeb; animation: shake .35s; }
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.feedback { font-size: 1.15rem; font-weight: 700; margin: 10px 0; }
.feedback.good { color: #059669; }
.feedback.bad { color: var(--red); }
.feedback.almost { color: #d97706; }
.feedback .correct-answer {
  display: block;
  direction: ltr;
  font-size: 1.4rem;
  color: var(--purple-dark);
  margin-top: 6px;
  letter-spacing: .05em;
}

/* ===== Summary ===== */
.summary-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 30px 20px;
  text-align: center;
}
.summary-stars { font-size: 2.6rem; letter-spacing: .1em; margin-bottom: 8px; }
.summary-score { font-size: 1.2rem; font-weight: 700; color: #9b8bbf; }
#summary-mistakes { margin: 14px 0; }
#summary-mistakes table {
  margin: 0 auto;
  border-collapse: collapse;
}
#summary-mistakes td { padding: 6px 12px; }
#summary-mistakes td.en { direction: ltr; font-weight: 700; color: var(--purple-dark); }
.summary-actions { margin-top: 16px; }

/* ===== Confetti ===== */
#confetti-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
  z-index: 50;
}
.confetti {
  position: absolute;
  top: -20px;
  font-size: 1.4rem;
  animation: fall linear forwards;
}
@keyframes fall {
  to { transform: translateY(105vh) rotate(720deg); opacity: .6; }
}

/* ===== Date field ===== */
.date-field {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 4px;
}
.date-display { font-weight: 700; color: var(--purple-dark); }

/* ===== Hebrew calendar picker ===== */
.cal-overlay[hidden] { display: none; }
.cal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(59, 48, 84, .45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 12px;
}
.cal-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  width: 100%;
  max-width: 480px;
  animation: pop-in .2s ease;
}
.cal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}
.cal-title { font-weight: 800; font-size: 1.15rem; color: var(--purple-dark); text-align: center; }
.cal-title .cal-greg { display: block; font-size: .75rem; color: #9b8bbf; font-weight: 600; }
.cal-nav {
  background: var(--pink-light);
  color: var(--purple-dark);
  font-size: 1.3rem;
  font-weight: 800;
  width: 40px;
  height: 40px;
  border-radius: 50%;
}
.cal-weekdays, .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.cal-weekdays div {
  text-align: center;
  font-size: .72rem;
  font-weight: 700;
  color: #9b8bbf;
  padding: 4px 0;
}
.cal-day {
  background: #faf5ff;
  border: 2px solid transparent;
  border-radius: 12px;
  min-height: 56px;
  padding: 3px 2px;
  font-family: inherit;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  cursor: pointer;
}
.cal-day:hover { border-color: var(--pink-light); }
.cal-day.empty { background: transparent; cursor: default; }
.cal-day.shabbat { background: #fdf3fa; }
.cal-day.today { border-color: var(--yellow); }
.cal-day.selected { border-color: var(--purple); background: #ede9fe; }
.cal-day .heb-day { font-weight: 800; font-size: .95rem; color: var(--ink); }
.cal-day .greg-day { font-size: .65rem; color: #9b8bbf; }
.cal-day .holiday {
  font-size: .58rem;
  font-weight: 700;
  color: var(--pink);
  text-align: center;
  line-height: 1.15;
  margin-top: 1px;
}
.cal-day.has-holiday { background: var(--pink-light); }
.cal-footer { display: flex; justify-content: center; gap: 10px; margin-top: 12px; }

/* ===== Keyboard language magic toggle ===== */
#kbd-magic {
  position: fixed;
  bottom: 14px;
  left: 14px;
  z-index: 60;
  background: var(--card);
  color: var(--purple-dark);
  font-weight: 700;
  font-size: .82rem;
  padding: 9px 14px;
  border-radius: 999px;
  box-shadow: var(--shadow);
  display: none;
}
body.typing-screen #kbd-magic { display: block; }
#kbd-magic.off { opacity: .55; color: #9b8bbf; }

/* ===== Voice picker ===== */
.voice-seg {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin: 12px 0;
  font-weight: 700;
  color: #9b8bbf;
  font-size: .9rem;
}
.voice-seg button {
  padding: 7px 16px;
  border-radius: 999px;
  background: #fff;
  box-shadow: var(--shadow);
  color: #9b8bbf;
  font-weight: 700;
  font-size: .9rem;
}
.voice-seg select {
  padding: 7px 10px;
  border-radius: 12px;
  border: 2px solid var(--pink-light);
  background: #fffafe;
  color: var(--purple-dark);
  font-family: inherit;
  font-weight: 600;
  font-size: .85rem;
  max-width: 220px;
}
.voice-seg select:focus { outline: none; border-color: var(--purple); }
.voice-seg.compact { margin: 4px 0 8px; }
.voice-hint {
  text-align: center;
  color: #b45309;
  background: #fef3c7;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: .85rem;
  font-weight: 600;
  margin: 0 0 10px;
}

/* ===== Confirm / message dialog ===== */
.modal-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 24px 20px;
  width: 100%;
  max-width: 380px;
  text-align: center;
  animation: pop-in .2s ease;
}
#modal-msg { font-size: 1.1rem; font-weight: 700; margin: 0 0 16px; }

/* ===== Wrong-answer flash ===== */
.question-card.flash-wrong { animation: flash-wrong .7s ease; }
@keyframes flash-wrong {
  0%, 100% { box-shadow: var(--shadow); }
  30% { box-shadow: 0 0 0 6px var(--red), 0 6px 20px rgba(248, 113, 113, .45); }
}

@media (max-width: 420px) {
  .app-header h1 { font-size: 1.6rem; }
  .question-word { font-size: 1.8rem; }
}
