:root {
  --thai-cream: #fff8e8;
  --thai-cream-strong: #fff3cf;
  --thai-gold-soft: #fde68a;
  --thai-gold: #f59e0b;
  --thai-navy: #0f2a5f;
  --thai-teal: #0ea5a3;
  --thai-green: #10b981;
  --thai-pink: #ec2f78;
  --thai-border: rgba(245, 158, 11, 0.22);
  --thai-shadow: rgba(15, 23, 42, 0.10);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Arial, Helvetica, sans-serif;
  background:
    radial-gradient(circle at top left, rgba(253, 230, 138, 0.35), transparent 34%),
    radial-gradient(circle at top right, rgba(236, 47, 120, 0.08), transparent 28%),
    linear-gradient(180deg, var(--thai-cream-strong) 0%, var(--thai-cream) 46%, #fffaf0 100%);
  color: #0f172a;
}

.hidden {
  display: none !important;
}

#appScreen {
  min-height: 100vh;
  background:
    radial-gradient(circle at top left, rgba(253, 230, 138, 0.35), transparent 34%),
    linear-gradient(180deg, var(--thai-cream-strong) 0%, var(--thai-cream) 50%, #fffaf0 100%);
}

.login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px;
}

.login-card {
  width: 100%;
  max-width: 420px;
  background: white;
  padding: 32px;
  border-radius: 16px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.08);
}

.login-card h1 {
  margin-top: 0;
}

input {
  width: 100%;
  padding: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 16px;
}

button {
  padding: 12px 18px;
  border: none;
  border-radius: 10px;
  background: #4057ff;
  color: white;
  font-size: 16px;
  cursor: pointer;
}

button:hover {
  opacity: 0.9;
}

.secondary-button {
  background: #e5e7eb;
  color: #1f2937;
}

.danger-button {
  background: #dc2626;
  color: white;
}

.small-button {
  padding: 8px 12px;
  font-size: 14px;
}

.error-message {
  color: #dc2626;
  min-height: 20px;
}

.app-header {
  background: rgba(255, 250, 238, 0.94);
  border-bottom: 1px solid var(--thai-border);
  box-shadow: 0 10px 28px rgba(245, 158, 11, 0.10);
}

.app-header h1 {
  color: var(--thai-navy);
}

.app-header p {
  margin: 0;
  color: #64748b;
}

.app-layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  min-height: calc(100vh - 98px);
}

.sidebar {
  background: rgba(255, 250, 238, 0.88);
  border-right: 1px solid var(--thai-border);
}

.main-panel {
  padding: 32px;
}

.inline-form {
  display: flex;
  gap: 10px;
  margin-bottom: 24px;
}

.button-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.folder-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.folder-item {
  padding: 12px;
  background: rgba(255, 255, 255, 0.82);
  border: 1px solid var(--thai-border);
  border-radius: 10px;
  margin-bottom: 10px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 10px 24px var(--thai-shadow);
}

.folder-item:hover {
  border-color: rgba(14, 165, 163, 0.45);
  background: #ffffff;
}

.folder-item.active {
  border-color: var(--thai-teal);
  background: linear-gradient(
    135deg,
    rgba(14, 165, 163, 0.14),
    rgba(253, 230, 138, 0.38)
  );
  color: var(--thai-navy);
}

.folder-name {
  font-weight: bold;
}

.empty-state {
  background: white;
  padding: 40px;
  border-radius: 16px;
  text-align: center;
  color: #64748b;
}

.panel-header {
  background: white;
  padding: 24px;
  border-radius: 16px;
  margin-bottom: 24px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.panel-header h2 {
  margin: 0 0 6px 0;
}

.panel-header p {
  margin: 0;
  color: #64748b;
}

.set-list {
  display: grid;
  gap: 16px;
}

.set-card {
  background: white;
  padding: 20px;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
}

.set-card:hover {
  border-color: #4057ff;
}

.set-card h3 {
  margin: 0 0 6px 0;
}

.set-card p {
  margin: 0;
  color: #64748b;
}

.card-editor {
  background: white;
  padding: 24px;
  border-radius: 16px;
  display: grid;
  gap: 14px;
  margin-bottom: 24px;
}

.card-list {
  display: grid;
  gap: 16px;
}

.flashcard {
  background: white;
  padding: 24px;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
}

.flashcard-top-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  margin-bottom: 12px;
}

.flashcard-number {
  font-weight: bold;
  color: #64748b;
}

.flashcard-content {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.flashcard-label {
  font-size: 12px;
  font-weight: bold;
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.flashcard-value {
  font-size: 20px;
  font-weight: bold;
}

.study-panel {
  background: white;
  padding: 32px;
  border-radius: 16px;
  margin-top: 24px;
}

.study-progress {
  color: #64748b;
  font-weight: bold;
}

.study-card {
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  padding: 40px;
  margin: 24px 0;
  text-align: center;
  background: #f8fafc;
}

.study-label {
  font-size: 12px;
  color: #64748b;
  text-transform: uppercase;
  font-weight: bold;
  margin-bottom: 12px;
}

.study-term {
  font-size: 42px;
  font-weight: bold;
  margin-bottom: 28px;
}

.study-definition {
  font-size: 28px;
  font-weight: bold;
  color: #4057ff;
}

.menu-wrapper {
  position: relative;
}

.menu-button {
  background: transparent;
  color: inherit;
  border: none;
  padding: 6px 10px;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  border-radius: 8px;
}

.menu-button:hover {
  background: rgba(0, 0, 0, 0.08);
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 36px;
  min-width: 140px;
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  z-index: 20;
  overflow: hidden;
}

.dropdown-menu button {
  width: 100%;
  padding: 10px 12px;
  background: white;
  color: #1f2937;
  border: none;
  border-radius: 0;
  text-align: left;
  font-size: 14px;
}

.dropdown-menu button:hover {
  background: #f3f4f6;
}

.dropdown-menu .danger-menu-item {
  color: #dc2626;
}

.folder-item.active .menu-button:hover {
  background: rgba(255, 255, 255, 0.2);
}

.app-header-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}

textarea {
  width: 100%;
  padding: 14px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  font-size: 16px;
  font-family: Arial, sans-serif;
  resize: vertical;
}

.flashcard-extra {
  margin-top: 18px;
  display: grid;
  gap: 12px;
}

.flashcard-extra-item {
  background: #f8fafc;
  padding: 12px;
  border-radius: 10px;
}

.flashcard-extra-label {
  font-size: 12px;
  font-weight: bold;
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.flashcard-extra-value {
  font-size: 16px;
}

.study-extra-details {
  margin-top: 28px;
  display: grid;
  gap: 14px;
  text-align: left;
}

.study-extra-item {
  background: white;
  padding: 14px;
  border-radius: 10px;
  border: 1px solid #e5e7eb;
}

.study-extra-label {
  font-size: 12px;
  font-weight: bold;
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 6px;
}

.study-extra-value {
  font-size: 18px;
}

.study-flip-card {
  width: min(100%, 900px);
  height: clamp(360px, 55vh, 560px);
  perspective: 1200px;
  margin: 32px auto;
  cursor: pointer;
}

.study-flip-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.55s ease;
  transform-style: preserve-3d;
}

.study-flip-card.is-flipped .study-flip-inner {
  transform: rotateX(180deg);
}

.study-face {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 48px;
  text-align: center;
  background: #ffffff;
  box-shadow: 0 10px 35px rgba(15, 23, 42, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  overflow-y: auto;
}

.study-front {
  color: #1f2937;
}

.study-back {
  transform: rotateX(180deg);
  background: #ffffff;
}

.study-term {
  font-size: clamp(42px, 6vw, 72px);
  font-weight: 500;
  margin: 0;
}

.study-definition {
  font-size: clamp(36px, 5vw, 60px);
  font-weight: 500;
  color: #1f2937;
  margin-bottom: 28px;
}

.study-back .secondary-button {
  margin: 0 auto;
}

.study-panel {
  max-width: 1000px;
  margin: 0 auto;
}

.study-navigation {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 22px;
  margin-top: 24px;
}

.nav-arrow-button {
  width: 64px;
  height: 56px;
  border-radius: 18px;
  font-size: 28px;
  font-weight: bold;
  background: #e5e7eb;
  color: #1f2937;
  display: flex;
  justify-content: center;
  align-items: center;
}

.nav-arrow-button:hover {
  background: #d1d5db;
}

/* STUDY MODE COUNTERS */

.study-scoreboard {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 0 auto 18px auto;
  width: min(100%, 900px);
}

.score-pill {
  padding: 8px 14px;
  border-radius: 999px;
  font-weight: bold;
  font-size: 15px;
}

.learning-pill {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.know-pill {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

/* STUDY MODE STATUS BUTTONS */

.study-status-actions {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 18px;
  margin-top: 18px;
}

.status-button {
  min-width: 160px;
  padding: 14px 22px;
  border-radius: 999px;
  font-weight: bold;
}

.still-learning-button {
  background: #fff7ed;
  color: #c2410c;
  border: 1px solid #fed7aa;
}

.know-button {
  background: #ecfdf5;
  color: #059669;
  border: 1px solid #a7f3d0;
}

.still-learning-button.active {
  background: #f97316;
  color: white;
}

.know-button.active {
  background: #10b981;
  color: white;
}

.reset-progress-button {
  display: block;
  margin: 16px auto 0 auto;
  background: transparent;
  color: #64748b;
  padding: 8px 12px;
  font-size: 14px;
}

.reset-progress-button:hover {
  background: #f3f4f6;
}

/* CARD SWIPE TRANSITIONS */

.study-flip-card {
  transition: transform 0.28s ease, opacity 0.28s ease;
}

.study-flip-card.swipe-out-left {
  transform: translateX(-120%) rotate(-4deg);
  opacity: 0;
}

.study-flip-card.swipe-out-right {
  transform: translateX(120%) rotate(4deg);
  opacity: 0;
}

.study-flip-card.swipe-in-left {
  transform: translateX(-120%) rotate(-4deg);
  opacity: 0;
}

.study-flip-card.swipe-in-right {
  transform: translateX(120%) rotate(4deg);
  opacity: 0;
}

/* IMPROVED STUDY CARD TRANSITIONS */

.study-flip-card.no-transition {
  transition: none !important;
}

.study-flip-card.swipe-out-left {
  transform: translateX(-120%) rotate(-4deg);
  opacity: 0;
}

.study-flip-card.swipe-out-right {
  transform: translateX(120%) rotate(4deg);
  opacity: 0;
}

.study-flip-card.swipe-in-left {
  transform: translateX(-120%) rotate(-4deg);
  opacity: 0;
}

.study-flip-card.swipe-in-right {
  transform: translateX(120%) rotate(4deg);
  opacity: 0;
}

.study-flip-card.glow-know .study-face {
  box-shadow: 0 0 0 4px rgba(16, 185, 129, 0.25),
    0 0 45px rgba(16, 185, 129, 0.45);
}

.study-flip-card.glow-learning .study-face {
  box-shadow: 0 0 0 4px rgba(249, 115, 22, 0.25),
    0 0 45px rgba(249, 115, 22, 0.45);
}

/* CARD LIST ACCORDION */

.flashcard {
  padding: 20px 24px;
}

.flashcard-top-row {
  margin-bottom: 14px;
}

.flashcard-content {
  align-items: start;
}

.flashcard-extra {
  margin-top: 18px;
}

.flashcard-extra.hidden {
  display: none;
}

/* STUDY MODE OPTIONS */

.study-options {
  width: min(100%, 900px);
  margin: 0 auto 16px auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
}

.study-options label {
  margin: 0;
  font-size: 14px;
  color: #64748b;
  font-weight: bold;
}

.study-options select {
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: 10px;
  background: white;
  font-size: 14px;
}

.study-options {
  justify-content: space-between;
}

.study-option-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.shuffle-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 14px;
  color: #64748b;
  font-weight: bold;
  cursor: pointer;
}

.shuffle-toggle input {
  width: auto;
}

/* BULK CARD IMPORTER */

.bulk-card-importer {
  background: white;
  padding: 24px;
  border-radius: 16px;
  margin-bottom: 24px;
  border: 1px solid #e5e7eb;
}

.bulk-card-importer h3 {
  margin: 0 0 8px 0;
}

.bulk-card-importer p {
  color: #64748b;
  margin: 0 0 14px 0;
}

.bulk-import-message {
  margin-top: 12px;
  font-weight: bold;
  color: #059669;
}

/* INLINE CARD EDITOR */

.inline-card-editor {
  margin-top: 18px;
  padding: 20px;
  border-radius: 14px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  display: grid;
  gap: 10px;
}

.inline-card-editor h4 {
  margin: 0 0 8px 0;
}

.inline-card-editor label {
  margin: 8px 0 0 0;
  font-size: 13px;
  color: #64748b;
  font-weight: bold;
}

.inline-card-editor input,
.inline-card-editor textarea {
  background: white;
}

/* COMPACT CARD SUMMARY ROW */

.flashcard-summary {
  display: grid;
  grid-template-columns: 1.3fr 0.8fr 1.4fr;
  gap: 20px;
  align-items: start;
  margin-top: 10px;
}

.flashcard-summary-item {
  min-width: 0;
}

.flashcard-summary-label {
  font-size: 12px;
  font-weight: bold;
  color: #64748b;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.flashcard-summary-value {
  font-size: 20px;
  font-weight: 600;
  color: #0f172a;
  line-height: 1.3;
  word-break: break-word;
}

@media (max-width: 900px) {
  .flashcard-summary {
    grid-template-columns: 1fr;
    gap: 14px;
  }
}

/* INLINE CARD EDITOR - COMPACT ROW LAYOUT */

.inline-card-editor {
  margin-top: 18px;
  padding: 24px;
  border-radius: 18px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
  display: grid;
  gap: 18px;
}

.inline-card-editor h4 {
  margin: 0;
  font-size: 20px;
}

.inline-edit-main-row {
  display: grid;
  grid-template-columns: 1.3fr 0.5fr 1.3fr;
  gap: 24px;
  align-items: end;
}

.inline-edit-field {
  display: grid;
  gap: 8px;
}

.inline-edit-field label {
  margin: 0;
  font-size: 13px;
  color: #64748b;
  font-weight: bold;
}

.inline-edit-field input,
.inline-edit-field textarea {
  width: 100%;
  background: white;
}

.inline-card-editor .button-row {
  margin-top: 4px;
}

@media (max-width: 900px) {
  .inline-edit-main-row {
    grid-template-columns: 1fr;
  }
}

/* CARD SEARCH */

.card-search-bar {
  background: white;
  padding: 18px;
  border-radius: 16px;
  border: 1px solid #e5e7eb;
  margin-bottom: 18px;
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 12px;
  align-items: center;
}

.card-search-message {
  margin: -6px 0 18px 4px;
  color: #64748b;
  font-weight: bold;
  font-size: 14px;
}

@media (max-width: 700px) {
  .card-search-bar {
    grid-template-columns: 1fr;
  }
}

/* THEMED LOGIN HOMEPAGE */

.login-screen {
  min-height: 100vh;
  background:
    radial-gradient(circle at top, rgba(255, 226, 141, 0.45), transparent 45%),
    linear-gradient(180deg, #fff3cf 0%, #fff8e8 52%, #fffaf0 100%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: 28px;
  overflow: auto;
}

.login-hero {
  width: min(1600px, 100%);
  position: relative;
  margin: 0 auto;
}

.login-hero-image {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 0;
  object-fit: contain;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.12);
}

/* This sits INSIDE the empty box already drawn into the image */
.themed-login-card {
  position: absolute;
  left: 50%;
  top: 70%;
  transform: translate(-50%, -50%);
  width: min(440px, 34%);
  background: transparent;
  border: 0;
  border-radius: 0;
  padding: 0;
  box-shadow: none;
  text-align: center;
  z-index: 2;
}

.login-card-decoration {
  display: none;
}

.themed-login-card h1 {
  color: #0f2a5f;
  font-size: clamp(24px, 2.7vw, 42px);
  line-height: 1.05;
  margin: 0 0 10px;
  letter-spacing: -0.04em;
}

.themed-login-card p {
  color: #ec2f78;
  font-size: clamp(14px, 1.35vw, 22px);
  font-weight: 800;
  margin: 0 0 22px;
}

.password-field {
  width: 100%;
  margin: 0 auto 18px;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  background: #ffffff;
  border: 2px solid #f59e0b;
  border-radius: 16px;
  padding: 0 16px;
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.12);
}

.password-icon {
  font-size: 18px;
}

.password-field input {
  border: 0;
  outline: 0;
  padding: 16px 0;
  font-size: clamp(15px, 1.25vw, 20px);
  background: transparent;
  color: #0f172a;
  min-width: 0;
}

.password-field input::placeholder {
  color: #94a3b8;
}

.login-enter-button {
  width: 78%;
  border: 0;
  border-radius: 18px;
  padding: 15px 20px;
  background: linear-gradient(135deg, #0ea5a3, #10b981);
  color: white;
  font-size: clamp(17px, 1.4vw, 24px);
  font-weight: 900;
  box-shadow: 0 16px 30px rgba(14, 165, 163, 0.28);
  cursor: pointer;
  transition:
    transform 0.16s ease,
    box-shadow 0.16s ease,
    filter 0.16s ease;
}

.login-enter-button:hover {
  transform: translateY(-2px);
  box-shadow: 0 20px 36px rgba(14, 165, 163, 0.35);
  filter: brightness(1.03);
}

.login-enter-button:active {
  transform: translateY(0);
}

.themed-login-card .error-message {
  min-height: 22px;
  margin: 12px 0 0;
  color: #dc2626;
  font-size: 14px;
  font-weight: 800;
}

/* Mobile fallback: image becomes banner, form becomes normal card below */
@media (max-width: 800px) {
  .login-screen {
    padding: 14px;
  }

  .login-hero-image {
    height: 300px;
    object-fit: cover;
    object-position: top center;
  }

  .themed-login-card {
    position: relative;
    left: auto;
    top: auto;
    transform: none;
    width: min(520px, 100%);
    margin: -18px auto 0;
    background:
      linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 250, 238, 0.96));
    border: 1px solid rgba(245, 158, 11, 0.28);
    border-radius: 28px;
    padding: 30px 24px;
    box-shadow:
      0 26px 60px rgba(15, 23, 42, 0.16),
      0 0 0 8px rgba(255, 255, 255, 0.45);
  }

  .themed-login-card h1 {
    font-size: 34px;
  }

  .themed-login-card p {
    font-size: 18px;
  }

  .login-enter-button {
    width: 100%;
  }
}

/* SET VIEW ACTION BUTTONS AND CREATOR PANELS */

.set-action-buttons {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.set-action-buttons button {
  white-space: nowrap;
}

.active-panel-button {
  background: linear-gradient(135deg, rgba(14, 165, 163, 0.14), rgba(16, 185, 129, 0.14));
  border-color: rgba(14, 165, 163, 0.35);
  color: var(--thai-teal);
  box-shadow: 0 10px 24px rgba(14, 165, 163, 0.12);
}

.card-editor,
.bulk-card-importer,
.conversation-create-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--thai-border);
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.06);
}

.card-editor h3,
.conversation-create-card h3 {
  margin: 0 0 8px 0;
  color: var(--thai-navy);
}

.card-editor p,
.conversation-create-card p {
  margin: 0 0 14px 0;
  color: #64748b;
}

.conversation-create-card {
  padding: 24px;
  border-radius: 16px;
  margin-bottom: 24px;
  display: grid;
  gap: 14px;
}

.conversation-create-card .form-grid {
  display: grid;
  gap: 12px;
}

.conversation-section {
  margin-top: 24px;
}

.conversation-list {
  display: grid;
  gap: 14px;
}

.conversation-card {
  background: rgba(255, 255, 255, 0.94);
  border: 1px solid var(--thai-border);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.06);
}

.conversation-card h4 {
  margin: 0 0 8px 0;
  color: var(--thai-navy);
}

.conversation-card p {
  margin: 0 0 8px 0;
  color: #64748b;
}

.conversation-speakers {
  font-weight: 800;
  color: var(--thai-teal) !important;
}

@media (max-width: 900px) {
  .panel-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .set-action-buttons {
    justify-content: flex-start;
  }
}

/* CONVERSATION BUILDER POLISH */

.conversation-section {
  margin-top: 32px;
}

.conversation-list {
  display: grid;
  gap: 18px;
  margin-top: 18px;
}

.conversation-card {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 18px;
  padding: 24px 30px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--thai-border);
  border-radius: 22px;
  box-shadow: 0 18px 45px var(--thai-shadow);
}

.conversation-card h4 {
  margin: 0 0 8px 0;
  color: var(--thai-navy);
  font-size: 22px;
}

.conversation-card p {
  margin: 0 0 8px 0;
}

.conversation-speakers {
  color: var(--thai-teal);
  font-weight: 800;
}

.conversation-editor-panel {
  margin-top: 24px;
  padding: 28px 32px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--thai-border);
  border-radius: 22px;
  box-shadow: 0 18px 45px var(--thai-shadow);
}

.conversation-editor-header {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: start;
  gap: 18px;
  margin-bottom: 22px;
}

.conversation-editor-header h3 {
  margin: 0 0 8px 0;
  color: var(--thai-navy);
  font-size: 24px;
}

.conversation-editor-header p {
  margin: 0 0 8px 0;
}

.conversation-line-list {
  margin-top: 18px;
}

.conversation-line-list .empty-state {
  padding: 42px 24px;
  background: rgba(255, 248, 232, 0.7);
  border: 1px dashed var(--thai-border);
  border-radius: 18px;
  box-shadow: none;
}

/* RESTORE THAI WARM BUTTON / STUDY MODE THEME */

button,
.primary-button,
.secondary-button {
  border-radius: 14px;
}

.primary-button,
button:not(.secondary-button):not(.danger-button):not(.menu-button):not(.nav-arrow-button):not(.status-button):not(.example-mini-flip-card):not(.conversation-line-flip-card){
  background: linear-gradient(135deg, var(--thai-teal), var(--thai-green));
  color: white;
  border: none;
  box-shadow: 0 14px 30px rgba(14, 165, 163, 0.22);
}

.secondary-button,
.nav-arrow-button {
  background: #fffaf0;
  color: var(--thai-navy);
  border: 1px solid var(--thai-border);
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.10);
}

.secondary-button:hover,
.nav-arrow-button:hover {
  background: var(--thai-cream-strong);
  transform: translateY(-1px);
}

.study-panel {
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--thai-border);
  box-shadow: 0 24px 70px var(--thai-shadow);
}

.study-flip-card {
  border: 1px solid var(--thai-border);
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 70px rgba(15, 23, 42, 0.08);
}

.study-term,
.study-definition {
  color: var(--thai-navy);
}

.reveal-details-button,
#revealDetailsButton {
  background: #fffaf0;
  color: var(--thai-navy);
  border: 1px solid var(--thai-border);
}

/* RESTORE EXAMPLE SENTENCE MINI FLIP CARD */

.example-flip-detail {
  overflow: hidden;
}

.example-mini-flip-card {
  width: 100%;
  min-height: 58px;
  position: relative;
  display: grid;
  align-items: center;
  text-align: left;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.98), rgba(255, 248, 232, 0.98));
  border: 1px solid var(--thai-border);
  border-radius: 14px;
  padding: 14px 16px;
  color: var(--thai-navy);
  box-shadow: none;
  cursor: pointer;
}

.example-mini-flip-card:hover {
  transform: none;
  filter: none;
  background: #fffaf0;
}

.example-mini-flip-front,
.example-mini-flip-back {
  grid-area: 1 / 1;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
  font-size: 20px;
  line-height: 1.35;
}

.example-mini-flip-front {
  opacity: 1;
  transform: translateY(0);
}

.example-mini-flip-back {
  opacity: 0;
  transform: translateY(8px);
  color: var(--thai-teal);
  font-weight: 800;
}

.example-mini-flip-card.is-flipped .example-mini-flip-front {
  opacity: 0;
  transform: translateY(-8px);
}

.example-mini-flip-card.is-flipped .example-mini-flip-back {
  opacity: 1;
  transform: translateY(0);
}

/* CONVERSATION LINE DISPLAY */

.conversation-line-editor {
  margin-top: 24px;
  padding: 24px;
  background: #fffaf0;
  border: 1px solid var(--thai-border);
  border-radius: 18px;
}

.conversation-line-editor h4 {
  margin: 0 0 16px 0;
  color: var(--thai-navy);
}

.conversation-line-editor select,
.conversation-line-editor input,
.conversation-line-editor textarea {
  width: 100%;
  border: 1px solid var(--thai-border);
  border-radius: 12px;
  padding: 13px 15px;
  font-size: 16px;
  background: white;
  color: var(--thai-navy);
}

.conversation-line-list {
  display: grid;
  gap: 14px;
  margin-top: 22px;
}

.conversation-line-card {
  max-width: 72%;
  padding: 16px 18px;
  border-radius: 18px;
  border: 1px solid var(--thai-border);
  background: white;
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.07);
}

.speaker-a-line {
  justify-self: start;
}

.speaker-b-line {
  justify-self: end;
  background: #fff8e8;
}

.conversation-line-speaker {
  font-size: 13px;
  font-weight: 800;
  color: var(--thai-teal);
  margin-bottom: 6px;
  text-transform: uppercase;
}

.conversation-line-thai {
  font-size: 20px;
  font-weight: 800;
  color: var(--thai-navy);
  margin-bottom: 6px;
}

.conversation-line-script {
  font-size: 18px;
  color: var(--thai-navy);
  margin-bottom: 6px;
}

.conversation-line-english {
  color: #52637a;
  margin-bottom: 6px;
}

.conversation-line-notes {
  font-size: 14px;
  color: #7c6f5b;
  border-top: 1px solid var(--thai-border);
  padding-top: 8px;
  margin-top: 8px;
}

/* CONVERSATION LINE FLIP BUBBLES */

.conversation-line-card {
  max-width: 72%;
  border: none;
  background: transparent;
  box-shadow: none;
  padding: 0;
}

.conversation-line-flip-card {
  width: 100%;
  min-width: 260px;
  min-height: 132px;
  display: grid;
  align-items: stretch;
  text-align: left;
  border: 1px solid var(--thai-border);
  border-radius: 18px;
  padding: 0;
  background: white;
  color: var(--thai-navy);
  box-shadow: 0 12px 30px rgba(15, 23, 42, 0.07);
  cursor: pointer;
  overflow: hidden;
}

.speaker-b-line .conversation-line-flip-card {
  background: #fff8e8;
}

.conversation-line-front,
.conversation-line-back {
  grid-area: 1 / 1;
  display: grid;
  align-content: center;
  gap: 8px;
  padding: 18px 20px;
  transition:
    opacity 0.18s ease,
    transform 0.18s ease;
}

.conversation-line-front {
  opacity: 1;
  transform: translateY(0);
}

.conversation-line-back {
  opacity: 0;
  transform: translateY(10px);
}

.conversation-line-flip-card.is-flipped .conversation-line-front {
  opacity: 0;
  transform: translateY(-10px);
}

.conversation-line-flip-card.is-flipped .conversation-line-back {
  opacity: 1;
  transform: translateY(0);
}

.conversation-line-speaker {
  display: block;
  font-size: 13px;
  font-weight: 800;
  color: var(--thai-teal);
  text-transform: uppercase;
}

.conversation-line-thai {
  display: block;
  font-size: 24px;
  font-weight: 900;
  color: var(--thai-navy);
}

.conversation-line-script {
  display: block;
  font-size: 22px;
  font-weight: 800;
  color: var(--thai-navy);
}

.conversation-line-english {
  display: block;
  color: #52637a;
  font-size: 18px;
  border-top: 1px solid var(--thai-border);
  padding-top: 8px;
}

.muted-text {
  color: #8a7d68;
  font-weight: 500;
}

/* WARM CONVERSATION BUBBLE COLOURS */

.conversation-line-flip-card {
  background: linear-gradient(135deg, #ffffff, #fffaf0);
  border: 1px solid rgba(245, 158, 11, 0.28);
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
}

.speaker-b-line .conversation-line-flip-card {
  background: linear-gradient(135deg, #fff8e8, #fff3cf);
  border: 1px solid rgba(245, 158, 11, 0.32);
}

.conversation-line-speaker {
  color: var(--thai-gold);
}

.speaker-b-line .conversation-line-speaker {
  color: var(--thai-teal);
}

.conversation-line-thai {
  color: var(--thai-navy);
}

.conversation-line-script {
  color: var(--thai-navy);
}

.conversation-line-english {
  color: #6b5f4a;
  border-top: 1px solid rgba(245, 158, 11, 0.24);
}

.conversation-line-flip-card:hover {
  background: linear-gradient(135deg, #fffaf0, #fff3cf);
  transform: translateY(-1px);
}

.speaker-b-line .conversation-line-flip-card:hover {
  background: linear-gradient(135deg, #fff3cf, #fde68a);
}

/* FINAL CONVERSATION BUBBLE THEME OVERRIDE */

.conversation-line-flip-card {
  background: linear-gradient(135deg, #ffffff, #fffaf0) !important;
  color: var(--thai-navy) !important;
  border: 1px solid rgba(245, 158, 11, 0.28) !important;
  box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08) !important;
}

.speaker-b-line .conversation-line-flip-card {
  background: linear-gradient(135deg, #fff8e8, #fff3cf) !important;
  color: var(--thai-navy) !important;
  border: 1px solid rgba(245, 158, 11, 0.34) !important;
}

.conversation-line-flip-card:hover {
  background: linear-gradient(135deg, #fffaf0, #fff3cf) !important;
  transform: translateY(-1px);
}

.speaker-b-line .conversation-line-flip-card:hover {
  background: linear-gradient(135deg, #fff3cf, #fde68a) !important;
}

.conversation-line-speaker {
  color: var(--thai-gold) !important;
}

.speaker-b-line .conversation-line-speaker {
  color: var(--thai-teal) !important;
}

.conversation-line-thai,
.conversation-line-script {
  color: var(--thai-navy) !important;
}

.conversation-line-english {
  color: #6b5f4a !important;
  border-top: 1px solid rgba(245, 158, 11, 0.24) !important;
}

/* CONVERSATION EDITOR ACTION BUTTONS */

.conversation-editor-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.conversation-line-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-bottom: 8px;
}

.speaker-a-line .conversation-line-actions {
  justify-content: flex-start;
}

.speaker-b-line .conversation-line-actions {
  justify-content: flex-end;
}

.conversation-icon-button {
  width: 38px;
  height: 38px;
  min-width: 38px;
  padding: 0;
  border-radius: 12px;
  font-size: 15px;
  display: inline-grid;
  place-items: center;
}

/* TEACHER DASHBOARD */

.teacher-dashboard-card {
  max-width: 760px;
  padding: 32px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--thai-border);
  border-radius: 22px;
  box-shadow: 0 18px 45px var(--thai-shadow);
}

.create-student-panel {
  margin-top: 24px;
  padding: 24px;
  background: #fffaf0;
  border: 1px solid var(--thai-border);
  border-radius: 18px;
  display: grid;
  gap: 14px;
}

.create-student-panel h3,
.teacher-student-list-header h3 {
  margin: 0;
  color: var(--thai-navy);
}

.create-student-panel .form-grid {
  display: grid;
  gap: 12px;
}

.teacher-student-list-header {
  margin-top: 28px;
  margin-bottom: 14px;
}

.teacher-student-list-header p {
  margin: 6px 0 0;
  color: #64748b;
}

.student-list {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}

.student-card {
  display: inline-flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
}

.student-card-name {
  font-weight: 900;
}

.student-card-username {
  opacity: 0.85;
  font-size: 14px;
}

.helper-message {
  margin: 0;
  min-height: 20px;
  color: #64748b;
  font-weight: 700;
}

/* TEACHER VIEW LAYOUT CLEANUP */

.teacher-mode .main-panel {
  padding: 32px 40px;
}

.teacher-mode .teacher-dashboard-card {
  max-width: none;
  width: 100%;
  min-height: calc(100vh - 210px);
}

.teacher-sidebar-content h2 {
  margin-top: 0;
}

.sidebar-helper-text {
  margin: -6px 0 18px 0;
  color: #64748b;
  font-size: 14px;
  font-weight: 700;
}

.sidebar-student-list {
  display: grid;
  gap: 10px;
}

.sidebar-student-list .student-card {
  width: 100%;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid var(--thai-border);
  border-radius: 14px;
  color: var(--thai-navy);
  box-shadow: 0 10px 24px var(--thai-shadow);
  text-align: left;
  display: grid;
  gap: 3px;
}

.sidebar-student-list .student-card:hover {
  border-color: rgba(14, 165, 163, 0.45);
  background: #ffffff;
  transform: translateY(-1px);
}

.sidebar-student-list .student-card-name {
  font-size: 16px;
  font-weight: 900;
}

.sidebar-student-list .student-card-username {
  font-size: 13px;
  color: #64748b;
}

.teacher-dashboard-note {
  margin-top: 24px;
  padding: 20px;
  background: #fffaf0;
  border: 1px solid var(--thai-border);
  border-radius: 18px;
}

.teacher-dashboard-note h3 {
  margin: 0 0 6px 0;
  color: var(--thai-navy);
}

.teacher-dashboard-note p {
  margin: 0;
  color: #64748b;
}

/* TEACHER DASHBOARD FINAL LAYOUT */

.teacher-mode .main-panel {
  padding: 32px 40px;
}

.teacher-mode .teacher-dashboard-card {
  max-width: none;
  width: 100%;
  min-height: calc(100vh - 210px);
}

.teacher-sidebar-content h2 {
  margin-top: 0;
}

.empty-template-message {
  list-style: none;
  padding: 16px;
  background: rgba(255, 255, 255, 0.72);
  border: 1px dashed var(--thai-border);
  border-radius: 14px;
  color: #64748b;
  font-weight: 800;
}

.teacher-student-list-panel {
  margin-top: 24px;
  padding: 20px;
  background: #fffaf0;
  border: 1px solid var(--thai-border);
  border-radius: 18px;
}

.teacher-student-list-header h3 {
  margin: 0;
  color: var(--thai-navy);
}

.teacher-student-list-header p {
  margin: 6px 0 16px 0;
  color: #64748b;
}

.teacher-main-student-list {
  display: grid;
  gap: 10px;
}

.teacher-main-student-list .student-card {
  width: 100%;
  min-height: 62px;
  padding: 14px 18px;
  background: rgba(255, 255, 255, 0.96);
  border: 1px solid var(--thai-border);
  border-radius: 14px;
  color: var(--thai-navy);
  box-shadow: 0 10px 24px var(--thai-shadow);
  text-align: left;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
}

.teacher-main-student-list .student-card:hover {
  border-color: rgba(14, 165, 163, 0.45);
  background: #ffffff;
  transform: translateY(-1px);
}

.teacher-main-student-list .student-card-name {
  font-size: 20px;
  font-weight: 900;
}

.teacher-main-student-list .student-card-username {
  display: none;
}

.teacher-main-student-list .student-card::after {
  content: "⋯";
  font-size: 24px;
  font-weight: 900;
  color: var(--thai-navy);
}

/* SOFT STUDENT ROW COLOURS */

.teacher-main-student-list .student-card {
  background: rgba(255, 255, 255, 0.96) !important;
  color: var(--thai-navy) !important;
  border: 1px solid var(--thai-border) !important;
  box-shadow: 0 10px 24px var(--thai-shadow) !important;
}

.teacher-main-student-list .student-card:hover {
  background: #ffffff !important;
  border-color: rgba(14, 165, 163, 0.45) !important;
  transform: translateY(-1px);
}

.teacher-main-student-list .student-card-name {
  color: var(--thai-navy) !important;
}

.teacher-main-student-list .student-card::after {
  color: var(--thai-navy) !important;
}

.teacher-main-student-list .student-card:focus {
  outline: 3px solid rgba(14, 165, 163, 0.22);
  outline-offset: 2px;
}

/* CLEAN HEADER LAYOUT */

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 24px;
  padding: 18px 28px 20px;
}

.app-header > div:first-child {
  min-width: 0;
}

.app-header h1 {
  margin: 0 0 8px 0;
  line-height: 1.1;
}

.app-header p {
  margin: 0;
}

.app-header-actions {
  margin-left: auto;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding-bottom: 4px;
}

.app-header-button {
  background: #fffaf0 !important;
  color: var(--thai-navy) !important;
  border: 1px solid var(--thai-border) !important;
  box-shadow: 0 10px 24px rgba(245, 158, 11, 0.10) !important;
  white-space: nowrap;
}

.app-header-button:hover {
  background: var(--thai-cream-strong) !important;
  transform: translateY(-1px);
}

/* LOGIN OVERLAY TEXT CLEANUP */

.themed-login-card > p {
  margin: 0 0 24px 0;
  color: #ec2f78;
  font-weight: 900;
  text-align: center;
}

/* STUDENT MANAGEMENT MENU */

.teacher-main-student-list .student-card {
  cursor: pointer;
  position: relative;
}

.teacher-main-student-list .student-card::after {
  content: none !important;
}

.student-card-main {
  display: grid;
  gap: 3px;
}

.teacher-main-student-list .student-card-username {
  display: block;
  font-size: 13px;
  color: #64748b;
}

.student-menu-wrapper {
  justify-self: end;
}

.student-menu-button {
  background: transparent !important;
  color: var(--thai-navy) !important;
  box-shadow: none !important;
  border: none !important;
  padding: 6px 10px;
  font-size: 24px;
  line-height: 1;
}

.student-menu-button:hover {
  background: rgba(245, 158, 11, 0.12) !important;
  transform: none;
}

.student-dropdown-menu {
  min-width: 180px;
  z-index: 50;
}

.student-lock-badge {
  width: fit-content;
  margin-top: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: #fee2e2;
  color: #b91c1c;
  font-size: 12px;
  font-weight: 900;
}

.locked-student-card {
  opacity: 0.72;
  border-color: rgba(220, 38, 38, 0.25) !important;
}

/* FIX STUDENT ROW MENU CLICK TARGET */

.student-card-main {
  cursor: pointer;
}

.student-menu-wrapper {
  position: relative;
  z-index: 20;
}

.student-menu-button {
  position: relative;
  z-index: 21;
  cursor: pointer;
}

/* FIX STUDENT DROPDOWN STACKING */

.teacher-main-student-list {
  overflow: visible;
}

.teacher-main-student-list .student-card {
  position: relative;
  overflow: visible;
  z-index: 1;
}

.teacher-main-student-list .student-card.student-card-menu-open {
  z-index: 1000;
}

.student-menu-wrapper {
  position: relative;
  z-index: 1001;
}

.student-dropdown-menu {
  position: absolute;
  right: 0;
  top: 42px;
  min-width: 190px;
  z-index: 1002;
  background: white;
  border: 1px solid var(--thai-border);
  border-radius: 14px;
  box-shadow: 0 18px 44px rgba(15, 23, 42, 0.16);
  overflow: hidden;
}

.student-dropdown-menu button {
  width: 100%;
  background: white !important;
  color: var(--thai-navy) !important;
  border: none !important;
  box-shadow: none !important;
  border-radius: 0 !important;
  padding: 12px 14px;
  text-align: left;
  font-size: 14px;
}

.student-dropdown-menu button:hover {
  background: var(--thai-cream-strong) !important;
  transform: none;
}

.student-dropdown-menu .lock-student-menu-item {
  color: #b91c1c !important;
  font-weight: 800;
}