* { box-sizing: border-box; }

/* Must outrank the id-specificity display rules below (e.g. #auth-screen),
   otherwise setting el.hidden has no visual effect. */
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f4f3f8;
  color: #222;
}
.screen { min-height: 100vh; }
.screen[hidden] { display: none; }

#auth-screen:not([hidden]) {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.card {
  background: #fff;
  border-radius: 12px;
  padding: 24px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  max-width: 480px;
  margin: 16px auto;
}

h1 { color: #673ab7; margin-top: 0; }

form#auth-form { display: flex; flex-direction: column; gap: 10px; }
input, select {
  padding: 10px;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 16px;
}
button {
  padding: 10px 16px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  cursor: pointer;
  background: #673ab7;
  color: #fff;
}
button:hover { opacity: 0.9; }
.error { color: #c0392b; }

header {
  background: #673ab7;
  color: #fff;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
}
header h1 { color: #fff; margin: 0; font-size: 20px; }
nav { display: flex; gap: 8px; flex-wrap: wrap; }
.tab-btn { background: rgba(255,255,255,0.15); }
.tab-btn.active { background: #fff; color: #673ab7; }
#logout-btn { background: rgba(255,255,255,0.15); }

#levels-bar { background: #ece7f5; }

#levels-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 20px;
  background: transparent;
  color: #4b2e83;
  font-size: 13px;
  border-radius: 0;
  text-align: left;
}
.levels-caret { font-size: 11px; opacity: 0.7; }

#levels-list {
  display: flex;
  gap: 8px;
  padding: 0 20px 10px;
  flex-wrap: wrap;
}
.level-chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 13px;
  background: #d8cdf0;
  color: #4b2e83;
}
.level-chip.locked { background: #e0e0e0; color: #888; }

main { max-width: 640px; margin: 0 auto; padding: 16px; }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

.prompt-text {
  font-size: 28px;
  text-align: center;
  margin: 24px 0;
}
.prompt-characters { font-size: 56px; }
.prompt-traditional { font-size: 20px; color: #888; text-align: center; }

.audio-play-btn {
  display: block;
  margin: 24px auto;
  font-size: 18px;
  padding: 16px 32px;
}

.prompt-area {
  cursor: pointer;
  padding: 16px 8px;
  border-radius: 10px;
  user-select: none;
}
.prompt-area:hover { background: #faf9fd; }

.prompt-audio-sign {
  font-size: 64px;
  text-align: center;
  margin: 16px 0;
}

.reveal-hint {
  text-align: center;
  font-size: 13px;
  color: #999;
  margin-top: 8px;
}

.btn-reveal {
  display: block;
  width: 100%;
  margin-top: 8px;
  padding: 14px;
  font-size: 16px;
  background: #ede8f7;
  color: #4b2e83;
}

/* Reveal and the rating buttons share one slot, so tapping Reveal puts the
   ratings exactly where the thumb (or cursor) already is.
   Desktop: the slot sits at the bottom of a fixed-height card, right under the
   content. Only touch screens get it pinned to the viewport bottom -- on a tall
   monitor that would strand the buttons far below the card. */
#practice-card {
  /* tall enough that neither the prompt nor the revealed answer grows the card,
     which would move the action slot between the two states */
  min-height: 460px;
  display: flex;
  flex-direction: column;
}
.action-bar {
  margin-top: auto;
  padding-top: 12px;
}
.action-bar .btn-reveal,
.action-bar .answer-row { margin-top: 0; }

@media (hover: none) and (pointer: coarse), (max-width: 600px) {
  #practice-card { min-height: 0; display: block; }
  #tab-practice { padding-bottom: 84px; }
  .action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10;
    max-width: 640px;
    margin: 0 auto;
    padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
    background: #fff;
    border-top: 1px solid #eee;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.07);
  }
}

.answer-reveal {
  margin-top: 16px;
  text-align: center;
}
.answer-characters { font-size: 44px; }
.answer-pinyin { font-size: 22px; color: #673ab7; margin-top: 4px; }
.answer-english { font-size: 20px; margin-top: 8px; }

.answer-row { display: flex; gap: 10px; margin-top: 24px; flex-wrap: wrap; }
.answer-row button { flex: 1; min-width: 80px; padding: 14px; font-size: 16px; }
.btn-no { background: #e74c3c; }
.btn-yes { background: #27ae60; }
.btn-absolutely { background: #2980b9; }
.btn-remove { background: #e6a817; color: #3a2a00; width: 100%; }
.btn-unsure { background: #f5e6c8; color: #6b5323; width: 100%; }
.btn-not-yet { background: #ece7f0; color: #5a4a68; width: 100%; }

.forced-banner {
  background: #fff3cd;
  color: #7a5b00;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 12px;
  text-align: center;
  font-size: 14px;
}

.recheck-banner {
  background: #e3f0fb;
  color: #1c5480;
  padding: 10px;
  border-radius: 8px;
  margin-bottom: 12px;
  text-align: center;
  font-size: 14px;
}

.mc-options { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; }
.mc-options button { background: #f0edf8; color: #333; text-align: left; }
.mc-options button.correct { background: #27ae60; color: #fff; }
.mc-options button.incorrect { background: #e74c3c; color: #fff; }
.mc-options button:disabled { cursor: default; }

.length-picker { display: flex; gap: 8px; margin-top: 12px; }

table { width: 100%; border-collapse: collapse; margin-top: 12px; font-size: 14px; }
th, td { text-align: left; padding: 6px 8px; border-bottom: 1px solid #eee; }
tr.excluded { opacity: 0.45; }
.manage-secondary { font-size: 12px; color: #999; }
.badge { padding: 2px 8px; border-radius: 999px; font-size: 12px; }
.badge.internalized { background: #d4f4dd; color: #1e7a3a; }
.badge.not-internalized { background: #f0f0f0; color: #666; }
td.actions { display: flex; gap: 6px; flex-wrap: wrap; }
td.actions button { padding: 4px 8px; font-size: 12px; }

.progress-line { font-size: 14px; margin: 6px 0; }
.exam-score { font-size: 18px; font-weight: bold; text-align: center; margin-top: 16px; }
