@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Luckiest+Guy&display=swap');

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

:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --card-border: rgba(0,0,0,0.08);
  --text: #1d1d1f;
  --text-secondary: #6e6e73;
  --text-tertiary: #86868b;
  --accent: #888;
  --quiz-color: #00E5CC;
  --flash-color: #A78BFA;
  --summary-color: #FBBF24;
  --keyterms-color: #38BDF8;
  --truefalse-color: #F87171;
  --match-color: #4ADE80;
  --green: #34d399;
  --green-bg: rgba(52, 211, 153, 0.12);
  --red: #f87171;
  --red-bg: rgba(248, 113, 113, 0.12);
  --option-letter-bg: rgba(0,0,0,0.06);
  --drop-border: rgba(0,0,0,0.15);
  --explanation-bg: rgba(0,0,0,0.04);
  --spinner-track: rgba(0,0,0,0.08);
  --score-track: rgba(0,0,0,0.08);
  --dot-bg: rgba(0,0,0,0.12);
  --btn-secondary-bg: #e8e8ed;
  --btn-secondary-hover: #dcdce2;
  --radius: 20px;
  --pill: 9999px;
}

/* ─── TOP BAR (only visible on upload + mode select) ─── */
.top-bar {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  display: flex;
  gap: 0.5rem;
  z-index: 100;
  transition: opacity 0.2s;
}
.top-bar.hidden {
  display: none !important;
}

.top-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: var(--card);
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.top-btn:hover {
  border-color: var(--text-secondary);
}

/* ─── SETTINGS PANEL ─── */
.settings-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}

.settings-panel {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 2rem;
  width: 90%;
  max-width: 520px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
}
.settings-panel h3 {
  font-family: "Luckiest Guy", cursive;
  font-size: 1.3rem;
  font-weight: 400;
  margin-bottom: 1.5rem;
  text-align: center;
  flex-shrink: 0;
}

.settings-scroll {
  overflow-y: auto;
  flex: 1;
  min-height: 0;
  padding-right: 0.5rem;
}

.color-section {
  margin-bottom: 1.5rem;
}
.color-section-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  margin-bottom: 0.75rem;
}
.color-swatches {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}
.color-swatch {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid transparent;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}
.color-swatch:hover {
  transform: scale(1.15);
}
.color-swatch.active {
  border-color: var(--text);
}
.color-swatch.active::after {
  content: "\2713";
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #000;
}

.settings-close {
  display: block;
  width: 100%;
  margin-top: 0.5rem;
  padding: 0.75rem;
  border: none;
  border-radius: var(--pill);
  background: var(--btn-secondary-bg);
  color: var(--text);
  font-size: 0.9rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
  flex-shrink: 0;
}
.settings-close:hover {
  background: var(--btn-secondary-hover);
}

body {
  font-family: "Inter", -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

.screen {
  display: none;
  min-height: 100vh;
  padding: 2rem;
  animation: fadeIn 0.4s ease;
}
.screen.active {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  padding-top: 4rem;
}

/* Auth, upload, and generating screens center vertically */
#auth-screen.active,
#upload-screen.active,
#generating-screen.active {
  justify-content: center;
  padding-top: 2rem;
}

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

/* ─── HERO ─── */
.hero {
  text-align: center;
  margin-bottom: 3rem;
}
.hero h1 {
  font-family: "Luckiest Guy", cursive;
  font-size: 7rem;
  font-weight: 400;
  color: var(--text);
  letter-spacing: 1px;
  line-height: 0.9;
}
/* Upload screen has colored bg — Study stays dark, Buddy is white */
#auth-screen .hero h1,
#upload-screen .hero h1 {
  color: #1d1d1f;
}
#auth-screen .tagline,
#upload-screen .tagline {
  color: rgba(255,255,255,0.75);
}
.hero-mode h1 {
  font-size: 4.5rem;
}
/* Branding — "Buddy" is white on colored bg, gray on dashboard */
.accent {
  color: #fff;
}
.hero-neutral .accent {
  color: #999;
}
.tagline {
  color: var(--text-secondary);
  font-size: 1.15rem;
  margin-top: 0.75rem;
  font-weight: 400;
}

.mode-file-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 0.75rem;
}
.mode-file-row .tagline {
  margin-top: 0;
}
.mode-file-row .btn-link {
  margin-top: 0;
  font-size: 0.85rem;
  color: var(--text-tertiary);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* ─── CARDS ─── */
.card {
  background: var(--card);
  border: 1px solid var(--card-border);
  border-radius: var(--radius);
  padding: 2.5rem;
}

.upload-card {
  width: 100%;
  max-width: 440px;
}

.drop-zone {
  border: 1.5px dashed var(--drop-border);
  border-radius: 16px;
  padding: 3rem 1.5rem;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
}
.drop-zone:hover,
.drop-zone.dragover {
  border-color: var(--text-secondary);
  background: rgba(128,128,128,0.06);
}
.drop-icon {
  font-size: 2rem;
  margin-bottom: 0.75rem;
}
.drop-zone p {
  color: var(--text);
  font-weight: 500;
}
.drop-zone .small {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 0.25rem;
  font-weight: 400;
}

.file-name {
  margin-top: 1rem;
  padding: 0.6rem 1rem;
  background: rgba(128,128,128,0.12);
  border-radius: var(--pill);
  font-weight: 600;
  font-size: 0.9rem;
  text-align: center;
  color: var(--text-secondary);
}

/* ─── MODE SELECT ─── */
.mode-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.25rem;
  width: 100%;
  max-width: 960px;
}

.mode-card {
  text-align: center;
  transition: transform 0.2s, box-shadow 0.2s;
  color: #fff;
  border: none;
  display: flex;
  flex-direction: column;
}
.mode-card .btn-primary {
  margin-top: auto;
}
.mode-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

/* Each mode card gets its color as background */
.mode-card-quiz { background: var(--quiz-color); }
.mode-card-flash { background: var(--flash-color); }
.mode-card-summary { background: var(--summary-color); }
.mode-card-keyterms { background: var(--keyterms-color); }
.mode-card-truefalse { background: var(--truefalse-color); }
.mode-card-match { background: var(--match-color); }

.mode-label {
  font-family: "Luckiest Guy", cursive;
  font-size: 2.2rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
  color: #fff;
  text-transform: uppercase;
}

.mode-card > p {
  color: rgba(255,255,255,0.85);
  font-size: 0.9rem;
  margin-bottom: 1.75rem;
  line-height: 1.5;
}

.mode-stepper {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.mode-stepper label {
  font-weight: 600;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Stepper buttons on mode cards — white style */
.mode-card .stepper-btn {
  border-color: rgba(255,255,255,0.4);
  color: #fff;
}
.mode-card .stepper-btn:hover {
  border-color: #fff;
  color: #fff;
}
.mode-card input[type="number"] {
  color: #fff;
}

/* Mode card buttons — white inverted */
.mode-card .btn-primary {
  background: rgba(255,255,255,0.95);
  color: #000;
}
.mode-card .btn-primary:hover:not(:disabled) {
  background: #fff;
  opacity: 1;
}

/* ─── STYLE PILLS (Summary) ─── */
.mode-pills {
  margin-bottom: 0.75rem;
}
.mode-pills label {
  display: block;
  font-weight: 600;
  font-size: 0.8rem;
  color: rgba(255,255,255,0.7);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.5rem;
  text-align: left;
}

.style-toggles {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

.style-pill {
  padding: 0.35rem 0.75rem;
  border-radius: var(--pill);
  border: 1.5px solid rgba(255,255,255,0.4);
  background: transparent;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
}
.style-pill:hover {
  border-color: #fff;
}
.style-pill.active {
  background: rgba(255,255,255,0.95);
  color: #000;
  border-color: transparent;
}

/* ─── STEPPER (generic) ─── */
.stepper {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}
.stepper-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--card-border);
  background: transparent;
  color: var(--text);
  font-size: 1.1rem;
  cursor: pointer;
  transition: all 0.15s;
}
.stepper-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}
input[type="number"] {
  width: 44px;
  text-align: center;
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  font-family: inherit;
}
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
}

/* ─── SCREEN ACTIONS (side-by-side buttons) ─── */
.screen-actions {
  display: flex;
  gap: 0.5rem;
  max-width: 400px;
  width: 100%;
}
.screen-actions .btn-secondary {
  flex: 1;
  margin-top: 0;
}
.mode-screen-bg .screen-actions .btn-secondary {
  background: rgba(255,255,255,0.2);
  color: #fff;
}
.mode-screen-bg .screen-actions .btn-secondary:hover {
  background: rgba(255,255,255,0.35);
}

/* ─── BUTTONS ─── */
.btn-primary {
  display: block;
  width: 100%;
  margin-top: 1.25rem;
  padding: 0.9rem;
  border: none;
  border-radius: var(--pill);
  background: var(--accent);
  color: #000;
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: opacity 0.15s;
}
.btn-primary:hover:not(:disabled) {
  opacity: 0.85;
}
.btn-primary:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

.btn-secondary {
  display: block;
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.9rem;
  border: none;
  border-radius: var(--pill);
  background: var(--btn-secondary-bg);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-secondary:hover {
  background: var(--btn-secondary-hover);
}

.btn-link {
  margin-top: 2rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: color 0.15s;
}
.btn-link:hover {
  color: var(--text);
}

/* ─── LOADING ─── */
.loading {
  text-align: center;
  padding: 2rem 0;
}
.loading p {
  color: var(--text-secondary);
  font-size: 0.95rem;
}
.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--spinner-track);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 1rem;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ─── MODE SCREEN BACKGROUND ─── */
.mode-screen-bg {
  background: var(--accent) !important;
}

/* ─── CLOSE BUTTON (fixed top-right, like settings was) ─── */
.close-btn {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: rgba(255,255,255,0.25);
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  line-height: 1;
  z-index: 100;
}
.close-btn:hover {
  background: rgba(255,255,255,0.4);
}

/* ─── CONSISTENT SCREEN HEADER ─── */
.screen-header {
  width: 100%;
  max-width: 700px;
  margin-bottom: 1.5rem;
  text-align: center;
}

.screen-mode-name {
  font-family: "Luckiest Guy", cursive;
  font-size: 5rem;
  font-weight: 400;
  color: #fff;
  margin-bottom: 0.25rem;
  text-transform: uppercase;
}

.screen-title {
  font-size: 1rem;
  font-weight: 500;
  color: rgba(255,255,255,0.75);
  line-height: 1.4;
  margin-bottom: 1rem;
}

.screen-header-meta {
  margin-top: 0.5rem;
}
.screen-header-meta .score-label,
.screen-header-meta .progress-info {
  color: rgba(255,255,255,1);
}
.screen-header-meta .score-text {
  color: #fff;
}
.screen-header-meta .score-track {
  background: rgba(255,255,255,0.2);
}
.screen-header-meta .score-fill {
  background: #fff;
}

/* ─── SCREEN BODY (content card) ─── */
.screen-body {
  width: 100%;
  max-width: 700px;
}
.screen-body-wide {
  max-width: 700px;
}

/* ─── QUIZ ─── */
.score-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}
.score-label {
  font-family: "Luckiest Guy", cursive;
  font-weight: 400;
  font-size: 1.6rem;
  color: #fff;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.score-track {
  flex: 1;
  height: 4px;
  background: var(--score-track);
  border-radius: 2px;
  overflow: hidden;
}
.score-fill {
  height: 100%;
  width: 0%;
  background: var(--accent);
  border-radius: 2px;
  transition: width 0.4s ease;
}
.score-text {
  font-family: "Luckiest Guy", cursive;
  font-weight: 400;
  font-size: 1.6rem;
  color: #fff;
}
.progress-info {
  font-family: "Luckiest Guy", cursive;
  font-weight: 400;
  font-size: 1rem;
  color: #fff;
}

.quiz-columns {
  display: flex;
  gap: 1.25rem;
  width: 100%;
  max-width: 700px;
  align-items: flex-start;
}

.quiz-col-left {
  flex: 3;
  min-width: 0;
}
.quiz-col-right {
  flex: 2;
  min-width: 0;
  position: sticky;
  top: 2rem;
}

.question-text {
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.5;
  margin-bottom: 1.75rem;
}

.options-container {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.option-btn {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  width: 100%;
  padding: 1rem 1.25rem;
  border: 1px solid var(--card-border);
  border-radius: 14px;
  background: transparent;
  color: var(--text);
  font-size: 0.95rem;
  font-family: inherit;
  text-align: left;
  cursor: pointer;
  transition: all 0.15s;
}
.option-btn:disabled {
  cursor: default;
  opacity: 0.6;
}
.option-btn:hover:not(:disabled) {
  border-color: var(--text-secondary);
  background: rgba(0,0,0,0.02);
}

.option-letter {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: var(--pill);
  background: var(--option-letter-bg);
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  color: var(--text-secondary);
  transition: all 0.15s;
}
.option-btn:hover:not(:disabled) .option-letter {
  background: var(--text-secondary);
  color: #fff;
}

.option-btn.correct {
  border-color: var(--green);
  background: var(--green-bg);
}
.option-btn.correct .option-letter {
  background: var(--green);
  color: #000;
}

.option-btn.incorrect {
  border-color: var(--red);
  background: var(--red-bg);
  animation: shake 0.35s ease;
}
.option-btn.incorrect .option-letter {
  background: var(--red);
  color: #000;
}

.option-btn.reveal-correct {
  border-color: var(--green);
  background: var(--green-bg);
}
.option-btn.reveal-correct .option-letter {
  background: var(--green);
  color: #000;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  50% { transform: translateX(6px); }
  75% { transform: translateX(-4px); }
}

/* Feedback panel (right column) */
.feedback-panel {
  min-height: 200px;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  padding: 1.5rem;
  background: #fff;
  border-radius: 14px;
  border: 1px solid var(--card-border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}
.feedback-panel .btn-primary {
  background: var(--accent);
  color: #fff;
}
.tf-buttons {
  margin-bottom: 0;
}
.feedback-panel.feedback-empty {
  align-items: center;
  justify-content: center;
}
.feedback-panel.feedback-empty::after {
  content: "Select an answer";
  color: var(--text-secondary);
  font-size: 0.9rem;
}
.feedback-panel.feedback-answered::after {
  display: none;
}

.feedback-status {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 1rem;
  color: var(--text);
}

.explanation-box {
  padding: 0;
  background: none;
  font-size: 0.9rem;
  color: var(--text-tertiary);
  line-height: 1.6;
  animation: fadeIn 0.25s ease;
}

/* ─── FLASHCARDS ─── */
.flash-progress-bar {
  height: 4px;
  background: rgba(255,255,255,0.2);
  border-radius: 2px;
  overflow: hidden;
  margin-bottom: 0.4rem;
}
.flash-progress-fill {
  height: 100%;
  width: 0%;
  background: #fff;
  border-radius: 2px;
  transition: width 0.4s ease;
}

.flashcard-carousel {
  width: 100%;
  max-width: 700px;
  height: 420px;
  perspective: 800px;
  overflow: visible;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 1.5rem;
}

/* Stacked cards behind */
.flash-stack {
  position: absolute;
  width: 88%;
  height: 88%;
  border-radius: var(--radius);
  background: #fff;
  pointer-events: none;
  left: 50%;
  top: 50%;
}
.flash-stack-1 {
  transform: translate(-50%, -50%) rotate(-2deg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
  z-index: 3;
}
.flash-stack-2 {
  transform: translate(-50%, -50%) rotate(3deg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  z-index: 2;
}
.flash-stack-3 {
  transform: translate(-50%, -50%) rotate(-4deg);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
  z-index: 1;
}

.flashcard {
  width: 88%;
  height: 88%;
  cursor: pointer;
  transition: transform 0.3s ease;
  transform-style: preserve-3d;
  position: relative;
  z-index: 4;
}

/* Flick animation — lifts out, then returns behind */
.flashcard.flick-left {
  animation: flickLeft 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.flashcard.flick-right {
  animation: flickRight 0.7s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}
.flashcard.flick-left,
.flashcard.flick-right {
  z-index: 5;
}
.flashcard.to-back {
  z-index: 3;
}

@keyframes flickLeft {
  0%   { transform: rotate(0deg) translateX(0) scale(1); }
  30%  { transform: rotate(-20deg) translateX(-90%) scale(0.8); }
  100% { transform: rotate(-2deg) translateX(0) scale(1); }
}
@keyframes flickRight {
  0%   { transform: rotate(0deg) translateX(0) scale(1); }
  30%  { transform: rotate(20deg) translateX(90%) scale(0.8); }
  100% { transform: rotate(2deg) translateX(0) scale(1); }
}

/* Incoming card sits behind, then settles into place */
.flashcard.deck-next {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.95);
  z-index: 4;
  transition: transform 0.4s ease;
}
.flashcard.deck-next.settle {
  transform: translate(-50%, -50%) scale(1);
}

.flashcard-inner {
  width: 100%;
  height: 100%;
  position: relative;
  transition: transform 0.6s cubic-bezier(0.4, 0.2, 0.2, 1);
  transform-style: preserve-3d;
}

.flashcard.flipped .flashcard-inner {
  transform: rotateY(180deg);
}

/* Add subtle 3D depth shadow during flip */
.flashcard-inner::after {
  content: "";
  position: absolute;
  inset: 8%;
  background: rgba(0,0,0,0.06);
  border-radius: var(--radius);
  transform: translateZ(-10px);
  filter: blur(12px);
}

.flashcard-front,
.flashcard-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: var(--radius);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  text-align: center;
}

.flash-label {
  position: absolute;
  top: 1.25rem;
  left: 1.5rem;
  font-family: "Luckiest Guy", cursive;
  font-size: 1.2rem;
  font-weight: 400;
  opacity: 0.3;
}

.flashcard-front {
  background: #fff;
  border: 1px solid var(--card-border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
  transform: translateZ(1px);
}
.flashcard-front .flash-label {
  color: var(--text);
}
.flashcard-front p {
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.4;
  color: var(--text);
}

.flashcard-back {
  background: #fff;
  border: 1px solid var(--card-border);
  box-shadow: 0 4px 20px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
  transform: rotateY(180deg) translateZ(1px);
}
.flashcard-back .flash-label {
  color: var(--accent);
  opacity: 0.5;
}
.flashcard-back p {
  font-size: 1.15rem;
  line-height: 1.7;
  color: var(--text-tertiary);
  font-weight: 500;
}

.flip-hint {
  position: absolute;
  bottom: 1rem;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
  opacity: 0.5;
}

/* ─── SUMMARY ─── */
.summary-badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: var(--pill);
  background: var(--accent);
  color: #000;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.summary-card {
  width: 100%;
  max-width: 700px;
  margin-bottom: 1rem;
}

.summary-content {
  line-height: 1.8;
  font-size: 0.95rem;
}
.summary-content h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 1.5rem 0 0.75rem;
}
.summary-content h3 {
  font-size: 1.1rem;
  font-weight: 700;
  margin: 1.25rem 0 0.5rem;
}
.summary-content h4 {
  font-size: 1rem;
  font-weight: 700;
  margin: 1rem 0 0.5rem;
}
.summary-content p {
  margin-bottom: 0.75rem;
  color: var(--text-tertiary);
}
.summary-content strong {
  color: var(--text);
}
.summary-content ul,
.summary-content ol {
  margin: 0.5rem 0 0.75rem 1.5rem;
  color: var(--text-tertiary);
}
.summary-content li {
  margin-bottom: 0.35rem;
}
.summary-content code {
  background: var(--explanation-bg);
  padding: 0.15rem 0.4rem;
  border-radius: 4px;
  font-size: 0.9em;
}
.summary-content hr {
  border: none;
  border-top: 1px solid var(--card-border);
  margin: 1.5rem 0;
}
.summary-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
}
.summary-content th,
.summary-content td {
  border: 1px solid var(--card-border);
  padding: 0.6rem 0.75rem;
  text-align: left;
}
.summary-content th {
  background: var(--explanation-bg);
  font-weight: 700;
  color: var(--text);
}
.summary-content td {
  color: var(--text-tertiary);
}

#summary-done-btn {
  max-width: 280px;
}

/* ─── KEY TERMS ─── */
.keyterms-list {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.keyterm-card {
  padding: 1.5rem;
}

.keyterm-term {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 0.5rem;
}

.keyterm-def {
  font-size: 0.95rem;
  line-height: 1.6;
  margin-bottom: 0.5rem;
}

.keyterm-ctx {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--text-secondary);
  line-height: 1.5;
}

#keyterms-done-btn {
  max-width: 280px;
}

/* ─── TRUE/FALSE ─── */

.tf-statement {
  font-size: 1.2rem;
  font-weight: 600;
  line-height: 1.6;
  margin-bottom: 2rem;
  min-height: 3.5rem;
}

.tf-buttons {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.tf-btn {
  flex: 1;
  padding: 1.25rem;
  border: 2px solid var(--card-border);
  border-radius: 16px;
  background: transparent;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.15s;
  letter-spacing: 1px;
}

.tf-btn-true:hover:not(:disabled) {
  border-color: var(--green);
  background: var(--green-bg);
  color: var(--green);
}
.tf-btn-false:hover:not(:disabled) {
  border-color: var(--red);
  background: var(--red-bg);
  color: var(--red);
}

.tf-btn.tf-correct {
  border-color: var(--green);
  background: var(--green-bg);
  color: var(--green);
}
.tf-btn.tf-wrong {
  border-color: var(--red);
  background: var(--red-bg);
  color: var(--red);
  animation: shake 0.35s ease;
}

.tf-btn:disabled {
  cursor: not-allowed;
  opacity: 0.6;
}


/* ─── MATCH ─── */
.match-columns {
  display: flex;
  gap: 1.25rem;
  width: 100%;
  max-width: 700px;
  align-items: flex-start;
}

/* Pulse right column items when a term is selected */
.match-columns.awaiting-match #match-defs .match-item:not(.match-matched):not(.match-matched-hide) {
  animation: pulseGlow 1.5s ease-in-out infinite;
}

@keyframes pulseGlow {
  0%, 100% { border-color: var(--card-border); }
  50% { border-color: var(--accent); }
}


.match-col {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.75rem;
}
#match-terms {
  flex: 1;
  align-self: center;
}
#match-defs {
  flex: 2;
  position: relative;
}

/* Tooltip on RHS items on hover when awaiting match */
.match-columns.awaiting-match #match-defs .match-item:not(.match-matched):not(.match-matched-hide) {
  position: relative;
}
.match-columns.awaiting-match #match-defs .match-item:not(.match-matched):not(.match-matched-hide):hover::after {
  content: "Select to match";
  position: absolute;
  top: -2rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 600;
  padding: 0.25rem 0.6rem;
  border-radius: var(--pill);
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
}

.match-item {
  padding: 0.6rem 0.9rem;
  border: 1.5px solid var(--card-border);
  border-radius: 10px;
  background: var(--card);
  color: var(--text);
  font-size: 0.9rem;
  font-family: inherit;
  cursor: pointer;
  transition: all 0.2s;
  text-align: left;
  line-height: 1.4;
}
.match-term {
  font-weight: 700;
  font-size: 1rem;
}

.match-item:hover:not(.match-matched):not(.match-wrong) {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.match-term.match-selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.match-def.match-selected {
  border-color: var(--accent);
  background: var(--accent);
  color: #fff;
}

.match-item.match-matched {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}
.match-item.match-matched-hide {
  display: none;
}

.match-item.match-wrong {
  border-color: var(--red);
  background: var(--red-bg);
  animation: shake 0.35s ease;
}

.match-complete-card {
  width: 100%;
  max-width: 420px;
  text-align: center;
  margin-top: 1rem;
}
.match-complete-card h2 {
  font-family: "Luckiest Guy", cursive;
  font-size: 1.5rem;
  font-weight: 400;
  margin-bottom: 0.5rem;
}
/* ─── INLINE RESULTS ─── */
.inline-results {
  text-align: center;
  max-width: 420px;
  width: 100%;
  animation: fadeIn 0.4s ease;
}

.inline-results-emoji {
  font-size: 10rem;
  margin-bottom: 0.5rem;
}

.inline-results h2 {
  font-family: "Luckiest Guy", cursive;
  font-size: 3.5rem;
  font-weight: 400;
  color: #fff;
  margin-bottom: 0.5rem;
  text-transform: uppercase;
}

.inline-results p {
  color: rgba(255,255,255,0.75);
  font-size: 1rem;
}


.hidden {
  display: none !important;
}

/* ─── HISTORY ─── */
#history-screen {
  background: #888;
}

.history-list {
  width: 100%;
  max-width: 700px;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.history-card {
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  padding: 1.5rem;
}
.history-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
}

.history-name {
  font-weight: 700;
  font-size: 1.05rem;
  margin-bottom: 0.35rem;
}

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

/* ─── AUTH SCREEN ─── */
#auth-screen .upload-card {
  min-height: 200px;
  overflow: visible;
}
#clerk-sign-in {
  min-height: 150px;
}

/* ─── CLERK USER BUTTON ─── */
#clerk-user-button {
  display: flex;
  align-items: center;
}

@media (max-width: 768px) {
  .hero h1 { font-size: 2.5rem; }
  .card { padding: 1.75rem; }
  .mode-cards {
    grid-template-columns: 1fr;
    max-width: 400px;
  }
  .quiz-columns { flex-direction: column; }
  .quiz-col-right { position: static; }
  .flashcard { height: 260px; }
  .match-columns { flex-direction: column; }
}
