/* Global Reset and Base Styles */
*, *::before, *::after {
  box-sizing: border-box; 
}

html, body {
  overflow-x: hidden;
  width: 100%;
  margin: 0;
  padding: 0;
}

body {
  font-family: system-ui, -apple-system, sans-serif;
  background: #f3f4f6;
  padding-top: 8px;
  display: flex;
  justify-content: center;

}

.app-container {
  width: 1200px;
  max-width: 98%; 
  background: white;
  padding: 22px 44px 32px;
  border-radius: 22px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.12);
  position: relative;
}

.hidden { display: none !important; }

#prepScoreBanner {
  display: none;                 /* JS controls visibility */
  max-width: 1100px;             /* 🔥 key: prevents full stretch */
  width: 100%;
  margin: 18px auto 24px;        /* 🔥 centers the banner */
  padding: 16px 22px;
  border-radius: 14px;
  border: 1px solid transparent;
  display: flex;
  align-items: center;
  justify-content: center;       /* 🔥 centers content */
  gap: 14px;
  flex-wrap: wrap;
  text-align: center;            /* 🔥 centers text */
  font-size: 16px;
  line-height: 1.5;
  font-weight: 500;
}

#prepScoreValue {
  font-size: 16px;               /* 🔥 prominent */
  font-weight: 700;
}

#prepScoreMsg {
  font-size: 15px;
  font-weight: 500;
  color: #374151;
}

#prepScoreBanner a {
  font-size: 15px;
  font-weight: 700;
  text-decoration: underline;
  margin-left: 6px;
}


/* ================== HEADER ================== */
h2 {
  text-align: center;
  margin-bottom: 6px;
  font-size: 24px;
  font-weight: 800;
}

.subtitle {
  text-align: center;
  font-size: 14px;
  color: #6b7280;
}

/* ================== AVATAR ================== */
.user-menu-wrapper {
  position: absolute;
  top: 20px;
  left: 26px;
  z-index: 1000;
}

.avatar-circle {
  width: 40px;
  height: 40px;
  background: #2563eb;
  color: white;
  border-radius: 50%;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(37,99,235,0.35);
}

.user-dropdown {
  position: absolute;
  top: 46px;              /* directly below avatar */
  left: 0;                /* aligned to avatar */
  min-width: 180px;
  width: max-content;     
  background: #ffffff;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0,0,0,0.12);
  padding: 6px 0;
  display: none;
  white-space: nowrap;    
}

.user-dropdown a {
  display: block;         
  padding: 10px 14px;
  font-size: 14px;
  color: #374151;
  text-decoration: none;
  border-bottom: 1px solid #f3f4f6;
  white-space: nowrap;    
}

.user-dropdown a:last-child { border-bottom: none; }
.user-dropdown a:hover { background: #f3f4f6; }

/* ================== FORM STYLING ================== */
.start-form-title {
  font-size: 20px;
  font-weight: 700;
  color: #111827;
  margin-bottom: 24px;
}

.form-row {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.form-row label {
  font-size: 14px;
  font-weight: 600;
  color: #374151;
}

.form-row input, 
.form-row select, 
.form-row textarea {
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid #d1d5db;
  font-size: 16px; /* Stop iOS Zoom */
  transition: border-color 0.2s, box-shadow 0.2s;
  width: 100%;
  box-sizing: border-box; 
}

.form-row input:focus, 
.form-row select:focus, 
.form-row textarea:focus {
  outline: none;
  border-color: #2563eb;
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.start-form-actions {
  display: flex;
  gap: 12px;
  margin-top: 32px;
  border-top: 1px solid #f3f4f6;
  padding-top: 24px;
}

.form-row input.hidden { display: none !important; }
textarea#jobDesc { resize: vertical; min-height: 100px; }

/* ================== GLOBAL LOADER ================== */
#globalLoader {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.global-loader-card {
  background: white;
  padding: 40px 60px;
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
  text-align: center;
  border: 1px solid rgba(229, 231, 235, 0.5);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
}

.global-loader-card::before {
  content: "";
  width: 40px; height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #2563eb;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin { 100% { transform: rotate(360deg); } }

.global-loader-card div { font-size: 16px; font-weight: 600; color: #1f2937; }

/* ================== TABLE & ACTIONS ================== */
.jd-link {
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
}

.col-action {
  display: flex;
  gap: 8px;
  flex-direction: column; /* Stacked buttons as per screenshot */
  align-items: center;
  justify-content: center;
}

/* ================== BUTTONS ================== */
.btn, .action-btn {
  padding: 8px 18px;
  border-radius: 999px;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #2563eb, #1d4ed8);
  color: white;
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 6px 14px rgba(37,99,235,0.35);
  transition: all .2s ease;
  display: inline-flex;
  justify-content: center;
  align-items: center;
}

.btn:hover, .action-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 10px 24px rgba(37,99,235,0.45);
}

.btn.danger { background: #dc2626; }

/* ================== CARDS & HISTORY ================== */
.card-section {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 18px;
  padding: 22px;
  margin-top: 14px;
}

.mid-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 22px;
  padding-bottom: 14px;
  border-bottom: 1px solid #f1f5f9;
}


#historySection .mid-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

#historySection #historyTitle {
  font-size: 20px;
  font-weight: 700;
  margin: 0;
}

#historySection #startInterviewBtn {
  white-space: nowrap;
}



#historyTable {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  margin-top: 18px;
  background: white;
  border-radius: 14px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}

#historyTable thead { background: #f9fafb; }
#historyTable th { padding: 16px; font-size: 13px; text-transform: uppercase; color: #6b7280; text-align: left; }
#historyTable td { padding: 18px 16px; font-size: 14px; color: #111827; border-bottom: 1px solid #f1f5f9; }
#historyTable tbody tr:hover { background: #f8fafc; }

/* ================== PILLS ================== */
.status-pill { padding: 6px 14px; border-radius: 999px; font-size: 12px; font-weight: 700; }
.status-CREATED { background:#e0f2fe; color:#0369a1; }
.status-IN_PROGRESS { background:#fef3c7; color:#92400e; }
.status-COMPLETED { background:#dcfce7; color:#166534; }

.level-pill { padding: 4px 12px; border-radius: 6px; font-size: 12px; font-weight: 700; border: 1px solid transparent; }
.level-Easy { background:#ecfdf5; color:#065f46; border-color:#059669; }
.level-Medium { background:#fffbeb; color:#92400e; border-color:#d97706; }
.level-Difficult { background:#fef2f2; color:#991b1b; border-color:#dc2626; }

/* ================== JD MODAL ================== */
.jd-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.45);
  display: flex; align-items: center; justify-content: center; z-index: 1000;
}
.jd-modal-card {
  background: white; width: 700px; max-width: 92%; max-height: 80vh;
  border-radius: 18px; padding: 26px; box-shadow: 0 30px 80px rgba(0,0,0,0.35);
}

/* ================== LIVE INTERVIEW UI ================== */
#liveInterviewSection { max-width: 900px; margin: 20px auto; }
.live-timer-wrapper {
  background: #f8fafc; padding: 10px 20px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 8px; font-weight: 700;
  color: #475569; border: 1px solid #e2e8f0; margin-bottom: 20px;
}
#liveTimer { color: #dc2626; font-family: monospace; font-size: 1.1em; }
.live-question-box {
  background: #2563eb; color: white; padding: 24px; border-radius: 18px;
  font-size: 18px; font-weight: 600; line-height: 1.5; margin-bottom: 24px;
  box-shadow: 0 10px 15px -3px rgba(37, 99, 235, 0.2); position: relative;
}
.live-question-box::before {
  content: "Interviewer:"; display: block; font-size: 11px; text-transform: uppercase;
  letter-spacing: 0.1em; margin-bottom: 8px; opacity: 0.8;
}
.live-answer-box {
  background: #ffffff; border: 2px solid #e2e8f0; border-radius: 18px;
  padding: 24px; min-height: 250px; max-height: 400px; overflow-y: auto;
  font-size: 16px; line-height: 1.7; color: #1e293b; transition: all 0.3s ease;
}
.live-answer-box:empty::before { content: "Start speaking..."; color: #94a3b8; font-style: italic; }
.live-next-btn { margin-top: 24px; display: flex; justify-content: flex-end; }
.live-action-buttons { display: flex; gap: 10px; }

/* ================== ANALYTICS & REVIEW ================== */
/* =====================================================
   WEB — INTERVIEW SUMMARY HEADER (PREMIUM)
===================================================== */

.meta-card {
  background: linear-gradient(180deg, #ffffff, #f8fafc);
  border: 1px solid #e2e8f0;
  border-radius: 18px;
  padding: 22px 26px;
  margin-bottom: 28px;
  display: flex;
  flex-wrap: nowrap;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  box-shadow:
    0 10px 25px rgba(0,0,0,0.08),
    inset 0 1px 0 rgba(255,255,255,0.8);
}

.meta-row {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
}

.meta-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: #64748b;
  font-weight: 800;
}

.meta-value {
  font-size: 14px;
  font-weight: 700;
  color: #0f172a;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Emphasis pills inside header */
.meta-value.status-IN_PROGRESS {
  background: #fffbeb;
  color: #b45309;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  width: fit-content;
}

.meta-value.status-COMPLETED {
  background: #f0fdf4;
  color: #15803d;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 12px;
  width: fit-content;
}

.analytic-card {
  background: #ffffff; border-radius: 12px; padding: 16px; border: 1px solid #e2e8f0;
  border-top: 4px solid #cbd5e1; box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  transition: transform 0.2s;
}
.analytic-card.excellent { border-top-color: #22c55e; }
.analytic-card.good { border-top-color: #eab308; }
.analytic-card.poor { border-top-color: #ef4444; }
.analytic-label { font-size: 11px; font-weight: 800; text-transform: uppercase; color: #64748b; margin-bottom: 8px; }

.suggested-answer-box {
  background: #f8fafc; border: 1px solid #e2e8f0; border-left: 6px solid #2563eb;
  padding: 25px 30px; border-radius: 12px; font-size: 15.5px; color: #1e293b; line-height: 1.8;
}


/* =========================================
   📱 MOBILE OPTIMIZATION (FINAL ALIGNMENT & OVERFLOW FIX)
========================================= */
/* =========================================
   📱 MOBILE OPTIMIZATION (FINAL ALIGNMENT FIX)
========================================= */
@media (max-width: 768px) {
  .app-container {
    width: 100% !important;
    max-width: 100vw !important;
    padding: 15px !important;
    border-radius: 0;
    box-shadow: none;
  }

  /* Header & Avatar */
  .user-menu-wrapper { position: absolute; top: 15px; left: 15px; }
  h2 { text-align: center !important; margin: 45px 0 5px; font-size: 20px; }
  .subtitle { text-align: center !important; margin-bottom: 20px; }

  /* Reorder: Button Top, Title Bottom */
  @media (max-width: 768px) {

    /* ================== HISTORY HEADER — MOBILE ================== */
    #historySection .mid-header {
      display: flex;
      flex-direction: column;
      align-items: stretch;
      gap: 14px;
      border-bottom: none;
    }
  
    #historySection #startInterviewBtn {
      width: 100%;
      order: 1;
    }
  
    #historySection #historyTitle {
      order: 2;
      text-align: center;
      font-size: 18px;
      margin: 0;
    }
  }
  

  /* Table to Card Transformation */
  #historyTable, #historyTable thead, #historyTable tbody, #historyTable th, #historyTable td, #historyTable tr {
    display: block; width: 100%;
  }
  #historyTable thead { display: none; }
  #historyTable tr {
    background: #fff; border: 1px solid #e5e7eb; border-radius: 16px;
    margin-bottom: 20px; padding: 10px; box-shadow: 0 4px 12px rgba(0,0,0,0.05);
  }

  #historyTable td {
    display: flex;
    justify-content: space-between; 
    align-items: center;
    padding: 10px 5px;
    border-bottom: 1px solid #f3f4f6;
    min-height: 50px;
  }

  #historyTable td::before {
    content: attr(data-label);
    font-weight: 700;
    font-size: 11px;
    color: #64748b;
    text-transform: uppercase;
    flex: 1;
    text-align: left;
  }

/* --- TEXT ALIGNMENT FIX (Duration, Role, etc.) --- */
#historyTable td > * {
  flex: 1.5; 
  text-align: right; /* Aligns text to the right */
  display: flex;
  justify-content: flex-end; /* Pushes content to the right side of the card */
  font-size: 14px;
}

/* --- RE-CENTERING PILLS (Big Three) --- */
#historyTable td > .level-pill, 
#historyTable td > .status-pill, 
#historyTable td > .jd-link {
  flex: 0 0 auto; 
  display: inline-flex !important;
  align-items: center;
  justify-content: center; 
  margin-left: auto; /* 🚀 Pushes the pill to the right edge of the card */
  min-width: 100px;
  height: 32px;
  font-size: 11px !important;
  padding: 0 10px !important;
  border-radius: 6px;
}

  /* Action Buttons Area */
  #historyTable td:last-child {
    border-bottom: none;
    padding: 15px 5px;
    flex-direction: row !important;
  }
  #historyTable td:last-child::before { display: none; }

  .col-action {
    width: 100% !important;
    flex-direction: row !important;
    display: flex !important;
    gap: 10px;
  }

  .action-btn, .btn {
    flex: 1;
    padding: 8px 10px !important;
    font-size: 13px !important;
    min-height: 40px;
  }
}

/* ================== REFINED REVIEW UI ================== */


/* Star Ratings Alignment */
.star-rating {
  display: flex;
  gap: 2px;
  font-size: 18px;
  color: #d1d5db; /* Default empty star */
}

.star.filled { color: #f59e0b; } /* Professional Gold */

/* Feedback Boxes */
.feedback-box {
  padding: 15px;
  border-radius: 12px;
  line-height: 1.6;
}

.feedback-box.good { background: #f0fdf4; border: 1px solid #dcfce7; color: #166534; }
.feedback-box.bad { background: #fef2f2; border: 1px solid #fee2e2; color: #991b1b; }

.suggested-answer-box {
  background: #f1f5f9;
  padding: 20px;
  border-radius: 12px;
  border-left: 5px solid #2563eb;
}



/* =====================================================
   🔒 HISTORY REVIEW ISOLATION FIX
===================================================== */

/* ----- DESKTOP HISTORY REVIEW HEADER ----- */
#historyViewSection .mid-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-bottom: 1px solid #f1f5f9;
}

#historyViewSection .mid-header h3 {
  margin: 0;
  font-size: 20px;
  font-weight: 700;
}

#historyViewSection .mid-header .btn {
  width: auto;
  min-width: 90px;
}

/* =====================================================
   📱 HISTORY REVIEW — MOBILE FIX
===================================================== */
@media (max-width: 768px) {

  /* Header stack: title first, button below */
  #historyViewSection .mid-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    border-bottom: none;
  }

  #historyViewSection .mid-header h3 {
    text-align: center;
    font-size: 18px;
  }

  #historyViewSection .mid-header .btn {
    width: 100%;
    justify-content: center;
  }

  /* Meta card MUST stack cleanly */
  #historyViewSection .meta-card {
    flex-direction: column;
    align-items: stretch;
    gap: 14px;
  }

  #historyViewSection .meta-row {
    width: 100%;
    min-width: 0;
  }

  #historyViewSection .meta-value {
    white-space: normal;
  }
}


/* =====================================================
   FINAL SAFE OVERRIDES (ONLY HISTORY + REVIEW HEADER)
===================================================== */

/* ---------- WEB: History Header ---------- */
@media (min-width: 769px) {
  #historySection .mid-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  #historySection #historyTitle {
    order: 1;
    text-align: left;
  }

  #historySection #startInterviewBtn {
    order: 2;
    width: auto;
  }
}

/* ---------- MOBILE: History Header ---------- */
@media (max-width: 768px) {
  #historySection .mid-header {
    display: flex;
    flex-direction: column;
    gap: 14px;
    border-bottom: none;
  }

  #historySection #startInterviewBtn {
    order: 1;
    width: 100%;
  }

  #historySection #historyTitle {
    order: 2;
    text-align: center;
    font-size: 18px;
    margin: 0;
  }
}

/* ---------- Review Meta Card (Visual Strength) ---------- */
#historyViewSection .meta-card {
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}

/* =====================================================
   HARD OVERRIDE — FORCE HISTORY HEADER LAYOUT
   (Overrides all broken / nested rules safely)
===================================================== */

#historySection .mid-header {
  display: flex !important;
}

/* WEB */
@media (min-width: 769px) {
  #historySection .mid-header {
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: center !important;
  }

  #historySection #startInterviewBtn {
    order: 2 !important;
  }

  #historySection #historyTitle {
    order: 1 !important;
  }
}

/* MOBILE */
@media (max-width: 768px) {
  #historySection .mid-header {
    flex-direction: column !important;
    gap: 14px !important;
    border-bottom: none !important;
  }

  #historySection #startInterviewBtn {
    order: 1 !important;
    width: 100% !important;
  }

  #historySection #historyTitle {
    order: 2 !important;
    text-align: center !important;
    font-size: 18px !important;
  }
}


/* =====================================================
   FINAL — HISTORY REVIEW PAGE (ANALYTICS / RIGHT / WRONG)
===================================================== */

/* HEADER */
#historyViewSection .mid-header {
  display: flex !important;
  justify-content: space-between !important;
  align-items: center !important;
  margin-bottom: 24px;
}

/* MOBILE HEADER */
@media (max-width: 768px) {
  #historyViewSection .mid-header {
    flex-direction: column !important;
    gap: 14px !important;
    border-bottom: none !important;
  }

  #historyViewSection .mid-header h3 {
    text-align: center !important;
  }

  #historyViewSection .mid-header .btn {
    width: 100% !important;
  }
}

/* ANALYTICS GRID VISUAL STRENGTH */
#historyViewSection .analytic-card {
  box-shadow: 0 6px 18px rgba(0,0,0,0.08);
}

/* RIGHT / WRONG / RECOMMENDATION SPACING */
#historyViewSection .feedback-box,
#historyViewSection .suggested-answer-box {
  margin-bottom: 18px;
}

/* =====================================================
   FALLBACK STYLING — RAW ANALYTICS HTML
===================================================== */

#historyContent > div {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 18px;
  margin-bottom: 16px;
}

#historyContent b {
  display: block;
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 8px;
  color: #111827;
}

#historyContent ul {
  padding-left: 20px;
  margin: 0;
}

#historyContent li {
  margin-bottom: 6px;
  color: #334155;
}


/* =====================================================
   WEB FIX — ANSWER ANALYTICS ACCORDION
===================================================== */

.section-toggle {
  margin-bottom: 16px;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #ffffff;
  overflow: hidden;
}

.section-header {
  padding: 14px 20px;
  background: #f8fafc;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  color: #1e293b;
  display: flex;
  align-items: center;
  gap: 10px;
}

.section-header:hover {
  background: #f1f5f9;
}

.section-header .arrow {
  font-size: 11px;
  color: #64748b;
  transition: transform 0.2s ease;
}

.section-header.open .arrow {
  transform: rotate(90deg);
}

.section-body {
  padding: 16px 20px;
  background: #ffffff;
  line-height: 1.7;
}


.feedback-box {
  padding: 16px 20px;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.6;
}

.feedback-box.good {
  background: #f0fdf4;
  border: 1px solid #dcfce7;
  border-left: 5px solid #22c55e;
}

.feedback-box.bad {
  background: #fef2f2;
  border: 1px solid #fee2e2;
  border-left: 5px solid #ef4444;
}

.feedback-box ul {
  margin: 0;
  padding-left: 18px;
}

.feedback-box li {
  margin-bottom: 8px;
}


.suggested-answer-box {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  border-left: 6px solid #2563eb;
  padding: 22px 26px;
  border-radius: 12px;
  font-size: 15px;
  line-height: 1.8;
  color: #1e293b;
}

/* =====================================================
   WEB — QUESTION ACCORDION (Q1, Q2…)
===================================================== */

.accordion-item {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 16px;
  margin-bottom: 20px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,0.04);
}

.accordion-header {
  padding: 18px 22px;
  background: linear-gradient(180deg, #f8fafc, #ffffff);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 12px;
  font-weight: 700;
  font-size: 15px;
  color: #0f172a;
}

.accordion-header:hover {
  background: #f1f5f9;
}

.accordion-icon {
  font-size: 12px;
  color: #64748b;
  transition: transform 0.25s ease;
}

.accordion-icon.open {
  transform: rotate(90deg);
}

.accordion-body {
  padding: 22px;
  background: #ffffff;
}


/* MOBILE FIX — center single History button in action column */
@media (max-width: 768px) {

  #historyTable td:last-child {
    justify-content: center !important;
    text-align: center !important;
  }

  #historyTable td:last-child > * {
    justify-content: center !important;
    text-align: center !important;
    margin: 0 auto !important;
  }

  #historyTable td:last-child .col-action {
    justify-content: center !important;
    width: 100%;
  }

}

/* =====================================================
   📱 MOBILE — REVIEW PAGE COMPACT & FULL-WIDTH LAYOUT
   (Does NOT affect desktop)
===================================================== */

@media (max-width: 768px) {

  /* ---------- Reduce outer card padding ---------- */
  #historyViewSection.card-section,
  #historyViewSection .card-section,
  #historyViewSection .accordion-item {
    padding: 14px !important;
    margin-bottom: 14px !important;
    border-radius: 14px !important;
  }

  /* ---------- Question header tighter ---------- */
  #historyViewSection .accordion-header {
    padding: 4px 4px !important;
    font-size: 15px !important;
    line-height: 1.4 !important;
  }

  /* ---------- Accordion body compact ---------- */
  #historyViewSection .accordion-body {
    padding: 4px !important;
  }

  /* ---------- Section headers (My Answer, Analytics etc.) ---------- */
  #historyViewSection .section-header {
    padding: 4px 14px !important;
    font-size: 15px !important;
  }

  #historyViewSection .section-body {
    padding: 4px !important;
  }

  /* ---------- Answer box ---------- */
  #historyViewSection .live-answer-box,
  #historyViewSection .answer-box {
    padding: 16px !important;
    min-height: auto !important;
  }

  /* ---------- Analytics stars area: USE GRID FULL WIDTH ---------- */
  #historyViewSection .analytic-card {
    width: 100% !important;
    margin: 0 !important;
    padding: 14px !important;
  }

  /* If analytics are inside a container, make them 2 per row */
  #historyViewSection .section-body:has(.analytic-card) {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 12px !important;
  }

  /* fallback for browsers without :has */
  #historyViewSection .analytic-card {
    display: block;
  }

  /* ---------- Feedback boxes tighter ---------- */
  #historyViewSection .feedback-box,
  #historyViewSection .suggested-answer-box {
    padding: 16px !important;
    margin-bottom: 12px !important;
    font-size: 14px !important;
    line-height: 1.6 !important;
  }

  /* ---------- Bullet spacing tighter ---------- */
  #historyViewSection ul {
    padding-left: 18px !important;
  }

  #historyViewSection li {
    margin-bottom: 6px !important;
  }

}
/* =====================================================
   📱 FINAL MOBILE COMPACT REVIEW LAYOUT
   Aggressive whitespace optimization (mobile only)
===================================================== */

@media (max-width: 768px) {

  /* ---------- OUTER CONTAINER ---------- */
  #historyViewSection.card-section{
    padding:2px !important;
  }

  /* ---------- ACCORDION ITEMS ---------- */
  #historyViewSection .accordion-item{
    margin-bottom:12px !important;
    border-radius:14px !important;
  }

  #historyViewSection .accordion-header{
    padding:12px 12px !important;
    font-size:15px !important;
  }

  #historyViewSection .accordion-body{
    padding:12px !important;
  }

  /* ---------- SECTION HEADERS ---------- */
  #historyViewSection .section-header{
    padding:10px 12px !important;
    font-size:15px !important;
  }

  #historyViewSection .section-body{
    padding:12px !important;
  }

  /* ---------- ANSWER BOX FULL WIDTH ---------- */
  #historyViewSection .live-answer-box,
  #historyViewSection .answer-box{
    padding:14px !important;
    width:100% !important;
    line-height:1.55 !important;
    border-radius:12px !important;
  }

  /* ---------- ANALYTICS → COMPACT ROW STYLE ---------- */
  #historyViewSection .analytic-card{

    display:flex !important;
    flex-direction:row !important;
    align-items:center !important;
    justify-content:space-between !important;

    width:100% !important;
    padding:10px 14px !important;
    margin:6px 0 !important;

    border-radius:10px !important;
  }

  #historyViewSection .analytic-label{
    margin:0 !important;
    font-size:12px !important;
  }

  #historyViewSection .star-rating{
    font-size:16px !important;
  }

  /* STACK analytics tightly */
  #historyViewSection .section-body:has(.analytic-card){
    display:block !important;
  }

  /* ---------- FEEDBACK BOXES COMPACT ---------- */
  #historyViewSection .feedback-box,
  #historyViewSection .suggested-answer-box{

    padding:14px !important;
    margin-bottom:10px !important;
    border-radius:12px !important;

    line-height:1.6 !important;
    font-size:14px !important;

    width:100% !important;
  }

  /* ---------- REDUCE LIST SPACING ---------- */
  #historyViewSection ul{
    margin:6px 0 !important;
    padding-left:18px !important;
  }

  #historyViewSection li{
    margin-bottom:4px !important;
  }

  /* ---------- FIX RECOMMENDED ANSWER NARROW TEXT ---------- */
  #historyViewSection .suggested-answer-box *{
    max-width:100% !important;
    white-space:normal !important;
  }

  /* ---------- REDUCE BIG TEXT GAPS ---------- */
  #historyViewSection p{
    margin:6px 0 !important;
  }

}
/* =====================================================
   📱 TRUE EDGE-TO-EDGE MOBILE REVIEW FIX
===================================================== */

@media (max-width: 768px) {

  /* ---------- MAKE PAGE USE FULL SCREEN ---------- */
  .app-container{
    padding:8px !important;
  }

  #historyViewSection{
    padding:6px !important;
  }

  /* ---------- REMOVE FLOATING CARD EFFECT ---------- */
  #historyViewSection .accordion-item,
  #historyViewSection .card-section{
    border-radius:2px !important;
    margin-bottom:10px !important;
    padding:2px !important;
  }

  /* ---------- HEADERS MICRO SPACING ---------- */
  #historyViewSection .accordion-header,
  #historyViewSection .section-header{
    padding:4px !important;
  }

  /* ---------- REMOVE DOUBLE PADDING ---------- */
  #historyViewSection .accordion-body,
  #historyViewSection .section-body{
    padding:8px !important;
  }

  /* ---------- ANSWER BOX FULL WIDTH ---------- */
  #historyViewSection .live-answer-box,
  #historyViewSection .answer-box{
    padding:10px !important;
    width:100% !important;
    margin:0 !important;
  }

  /* ---------- ANALYTICS COMPACT ---------- */
  #historyViewSection .analytic-card{

    display:flex !important;
    flex-direction:row !important;
    justify-content:space-between !important;
    align-items:center !important;

    width:100% !important;
    padding:8px 10px !important;
    margin:4px 0 !important;
    border-radius:8px !important;
  }

  #historyViewSection .analytic-label{
    font-size:12px !important;
    margin:0 !important;
  }

  #historyViewSection .star-rating{
    font-size:15px !important;
  }

  /* ---------- FEEDBACK BOX EDGE TO EDGE ---------- */
  #historyViewSection .feedback-box,
  #historyViewSection .suggested-answer-box{

    width:100% !important;
    margin:6px 0 !important;
    padding:10px !important;
    border-radius:10px !important;
  }

  /* ---------- CRITICAL FIX FOR NARROW TEXT ---------- */
  #historyViewSection .suggested-answer-box{
    max-width:100% !important;
  }

  #historyViewSection .suggested-answer-box *{
    max-width:100% !important;
    width:auto !important;
    white-space:normal !important;
  }

  /* ---------- REMOVE EXTRA PARAGRAPH GAPS ---------- */
  #historyViewSection p{
    margin:4px 0 !important;
  }

  #historyViewSection ul{
    margin:4px 0 !important;
    padding-left:16px !important;
  }

  #historyViewSection li{
    margin-bottom:4px !important;
  }

}
/* =====================================================
   📱 MOBILE FULL-WIDTH FIX (REMOVE SIDE GUTTERS)
===================================================== */

@media (max-width:768px){

  /* stop flex centering */
  body{
    display:block !important;
  }

  /* make container truly full width */
  .app-container{
    width:100vw !important;
    max-width:100vw !important;
    margin:0 !important;
    border-radius:0 !important;
    padding:10px !important;
    box-shadow:none !important;
  }

}
/* =====================================================
   📱 FINAL MOBILE EDGE-TO-EDGE REVIEW FIX
   (removes nested card spacing completely)
===================================================== */

@media (max-width:768px){

  /* ---- stop centering layout ---- */
  body{
    display:block !important;
  }

  /* ---- main container FULL WIDTH ---- */
  .app-container{
    width:100% !important;
    max-width:100% !important;
    margin:0 !important;
    padding:6px !important;
    border-radius:0 !important;
    box-shadow:none !important;
  }

  /* ---- remove outer card feeling ---- */
  #historyViewSection.card-section{
    border:none !important;
    padding:2px !important;
    margin:0 !important;
  }

  /* ---- flatten accordion cards ---- */
  #historyViewSection .accordion-item{
    border-radius:10px !important;
    margin:8px 0 !important;
    padding:0 !important;
  }

  /* ---- headers tight ---- */
  #historyViewSection .accordion-header,
  #historyViewSection .section-header{
    padding:10px !important;
  }

  /* ---- body tight ---- */
  #historyViewSection .accordion-body,
  #historyViewSection .section-body{
    padding:8px !important;
  }

  /* ---- answer boxes FULL WIDTH ---- */
  #historyViewSection .live-answer-box,
  #historyViewSection .answer-box,
  #historyViewSection .feedback-box,
  #historyViewSection .suggested-answer-box{
    width:100% !important;
    margin:6px 0 !important;
    padding:10px !important;
  }

  /* ---- analytics compact rows ---- */
  #historyViewSection .analytic-card{
    display:flex !important;
    justify-content:space-between !important;
    align-items:center !important;
    padding:8px 10px !important;
    margin:4px 0 !important;
    width:100% !important;
  }

  /* ---- reduce text gaps ---- */
  #historyViewSection p{ margin:4px 0 !important; }
  #historyViewSection ul{ margin:4px 0 !important; padding-left:16px !important; }
  #historyViewSection li{ margin-bottom:4px !important; }

}

/* =========================================
   📱 HARD MOBILE FULL-WIDTH OVERRIDE
   Forces ALL ancestors to allow edge-to-edge layout
========================================= */

@media screen and (max-width: 900px){

  html, body{
    width:100% !important;
    max-width:100% !important;
    overflow-x:hidden !important;
  }

  body{
    display:block !important;
    margin:0 !important;
    padding:0 !important;
  }

  /* kill ANY centered wrapper */
  body > *{
    max-width:100% !important;
  }

  /* force main container edge-to-edge */
  .app-container{
    width:100% !important;
    max-width:100% !important;
    margin:0 !important;
    padding:6px !important;
    border-radius:0 !important;
    box-shadow:none !important;
  }

  /* remove card padding causing inner gutters */
  .card-section{
    padding:8px !important;
    margin:8px 0 !important;
    border-radius:10px !important;
  }

  /* flatten nested cards */
  .accordion-item{
    margin:8px 0 !important;
    border-radius:10px !important;
  }

  .accordion-body,
  .section-body{
    padding:8px !important;
  }

  .accordion-header,
  .section-header{
    padding:4px !important;
  }

  /* make content boxes truly full width */
  .feedback-box,
  .suggested-answer-box,
  .live-answer-box{
    width:100% !important;
    margin:6px 0 !important;
    padding:10px !important;
  }

}


/* =========================================
   📱 MOBILE MASTER OVERRIDE — REAL FIX
========================================= */

@media screen and (max-width: 768px){

  /* 🚨 THIS is the real problem */
  body{
    display:block !important;
    justify-content:unset !important;
    padding:0 !important;
    margin:0 !important;
  }

  /* make container use full screen */
  .app-container{
    width:100% !important;
    max-width:100% !important;
    margin:0 !important;
    padding:4px !important;   /* 👈 your requested 4px */
    border-radius:0 !important;
    box-shadow:none !important;
  }

  /* ALL cards tight */
  .card-section,
  .accordion-item,
  .meta-card{
    padding:4px !important;
    margin:6px 0 !important;
    border-radius:8px !important;
  }

  /* headers tight */
  .accordion-header,
  .section-header{
    padding:4px 6px !important;
  }

  /* bodies tight */
  .accordion-body,
  .section-body{
    padding:4px !important;
  }

  /* content boxes tight */
  .feedback-box,
  .suggested-answer-box,
  .live-answer-box{
    padding:4px !important;
    margin:4px 0 !important;
    width:100% !important;
  }

}
/* 📱 Mobile — slight inner offset for summary/meta content */
@media (max-width:768px){

  /* the card itself */
  #historyViewSection .meta-card{
    padding-top: 2px;
    padding-left:12px !important;   /* small shift from left */
    padding-right:12px !important;
    padding-bottom: 2px;
  }

  /* each label/value block */
  #historyViewSection .meta-row{
    padding-left:4px !important;    /* micro offset */
    padding-bottom: 2px;
    padding-top: 2px;
  }

}
