/* Reading Module Styles — Official IELTS CD-style */

.sec-outer[data-sec="reading"] .sec-inner {
  font-family: var(--font-b);
  background: var(--bg);
  color: var(--text);
  height: calc(100vh - 46px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#readingSelScreen {
  position: absolute;
  inset: 0;
  background: var(--bg);
  z-index: 900;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
}

#readingTestUi {
  flex: 1;
  display: none;
  flex-direction: column;
  overflow: hidden;
}

/* ── IELTS TOPBAR (shared look) ── */
.it-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 48px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid #ddd;
  flex-shrink: 0;
  z-index: 10;
}
.it-topbar-l { display: flex; align-items: center; gap: 16px; }
.it-logo {
  font-family: 'Arial Black', Arial, sans-serif;
  font-weight: 900;
  font-size: 22px;
  color: #c4161c;
  letter-spacing: -0.5px;
}
.it-timer {
  font-size: 14px;
  color: #333;
  font-weight: 600;
}
.it-topbar-r { display: flex; align-items: center; gap: 8px; }
.it-topbar-btn {
  background: none;
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 5px 14px;
  font-size: 13px;
  color: #333;
  cursor: pointer;
  font-family: inherit;
}
.it-topbar-btn:hover { background: #f5f5f5; }

/* ── REVIEW BAR ── */
.it-review-bar {
  background: #1a73e8;
  color: white;
  padding: 8px 24px;
  font-size: 14px;
  text-align: center;
  font-weight: 600;
}

/* ── PASSAGE PANEL ── */
.passage-title {
  font-family: var(--font-d);
  font-size: 28px;
  font-weight: 800;
  color: #000;
  margin-bottom: 20px;
  line-height: 1.3;
}

.passage-text {
  font-size: 15px;
  line-height: 1.85;
  color: #222;
  user-select: text;
}

.passage-text b { color: #000; font-weight: 700; }
.passage-text p { margin: 0 0 12px; }

/* ── SPLIT-PANE LAYOUT ── */
.split {
  flex: 1;
  display: flex;
  overflow: hidden;
  min-height: 0;
  background: #fff;
}

.reading-side {
  width: 50%;
  flex-shrink: 0;
  overflow-y: auto;
  min-height: 0;
  padding: 32px;
  border-right: 1px solid #ddd;
}

.divider {
  width: 4px;
  background: #e0e0e0;
  cursor: col-resize;
  flex-shrink: 0;
}
.divider:hover { background: #1a73e8; }

.q-side {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 0;
}

.q-scroll {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  padding: 28px 32px;
}

/* ── IELTS BOTTOM BAR ── */
.it-botbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  background: #fff;
  border-top: 1px solid #ddd;
  flex-shrink: 0;
  min-height: 48px;
}

.it-parts {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.it-part {
  padding: 6px 14px;
  font-size: 12px;
  font-weight: 600;
  color: #666;
  cursor: pointer;
  border-radius: 4px;
  white-space: nowrap;
}
.it-part:hover { background: #f0f0f0; }
.it-part.active {
  background: #e8f0fe;
  color: #1a73e8;
  font-weight: 700;
}
.it-part .it-part-count {
  font-weight: 400;
  color: #999;
  margin-left: 6px;
  font-size: 11px;
}

.it-qstrip {
  display: flex;
  gap: 3px;
  overflow-x: auto;
  flex: 1;
  padding: 2px 0;
}
.it-qstrip::-webkit-scrollbar { height: 3px; }
.it-qstrip::-webkit-scrollbar-thumb { background: #ccc; border-radius: 2px; }

/* Question number buttons in bottom strip */
.qbtn {
  width: 28px;
  height: 28px;
  border-radius: 4px;
  border: 1px solid #ccc;
  background: #fff;
  font-size: 11px;
  font-weight: 600;
  color: #555;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.qbtn:hover { border-color: #1a73e8; }
.qbtn.done {
  background: #1a73e8;
  color: #fff;
  border-color: #1a73e8;
}

.it-nav-arrows {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}
.it-arrow {
  width: 40px;
  height: 36px;
  border-radius: 6px;
  background: #333;
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.it-arrow:hover { background: #555; }

/* ══════════════════════════════════════════════
   QUESTION RENDERING — Official IELTS Style
   ══════════════════════════════════════════════ */

/* Section header ("Questions 1-7") */
.q-section-header {
  font-size: 16px;
  font-weight: 700;
  color: #000;
  margin: 28px 0 6px;
  padding-bottom: 4px;
  border-bottom: 1px solid #ddd;
}
.q-section-header:first-child { margin-top: 0; }

/* Section instruction block */
.q-instruction {
  background: #f5f0eb;
  border: 1px solid #e0d8cf;
  border-radius: 4px;
  padding: 14px 18px;
  margin: 20px 0 16px;
  font-size: 14px;
  line-height: 1.7;
  color: #333;
}
.q-instruction:first-child { margin-top: 0; }

.q-options-list {
  border: 1px solid #ddd;
  border-radius: 4px;
  padding: 12px 18px;
  margin-bottom: 16px;
  font-size: 14px;
  line-height: 1.9;
  color: #333;
  background: #fafafa;
}
.q-option-item { padding: 1px 0; }

/* ── MCQ / Radio questions ── */
.mcq-item {
  margin-bottom: 24px;
}

.mcq-stem {
  font-size: 15px;
  line-height: 1.6;
  color: #000;
  margin-bottom: 10px;
}

.mcqn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 28px;
  padding: 0 5px;
  height: 24px;
  border: 1px solid #999;
  border-radius: 3px;
  font-size: 13px;
  font-weight: 700;
  color: #333;
  margin-right: 8px;
  flex-shrink: 0;
}

.mcq-opt {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  margin: 2px 0;
  cursor: pointer;
  border-radius: 4px;
  font-size: 14px;
  color: #333;
  line-height: 1.5;
  transition: background 0.15s;
}
.mcq-opt:hover { background: #f5f5f5; }

/* Radio circle */
.mdot {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid #999;
  flex-shrink: 0;
  position: relative;
  transition: all 0.15s;
}

/* Selected state — blue fill + row highlight */
.mcq-opt.sel {
  background: #e8f0fe;
}
.mcq-opt.sel .mdot {
  border-color: #1a73e8;
  background: #1a73e8;
}
.mcq-opt.sel .mdot::after {
  content: '';
  position: absolute;
  top: 4px; left: 4px;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #fff;
}

/* Checkbox for "Choose TWO" */
.c2-opt .cbox {
  width: 18px;
  height: 18px;
  border-radius: 3px;
  border: 2px solid #999;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  transition: all 0.15s;
}
.c2-opt.sel .cbox {
  border-color: #1a73e8;
  background: #1a73e8;
}

/* Review states */
.mcq-opt.correct { background: #e6f4ea; }
.mcq-opt.correct .mdot { border-color: #34a853; background: #34a853; }
.mcq-opt.wrong { background: #fce8e6; }
.mcq-opt.wrong .mdot { border-color: #ea4335; background: #ea4335; }

/* ── Gap fill items ── */
.gap-item {
  font-size: 15px;
  line-height: 1.9;
  color: #333;
  margin-bottom: 12px;
  padding: 6px 0;
}

/* Inline gap input — matches official style */
.iinput {
  display: inline-block;
  width: 120px;
  height: 32px;
  border: 1px solid #999;
  border-radius: 2px;
  padding: 0 8px;
  font-size: 14px;
  font-family: inherit;
  color: #000;
  background: #fff;
  text-align: center;
  vertical-align: middle;
  outline: none;
  transition: border-color 0.2s;
}
.iinput:focus { border-color: #1a73e8; box-shadow: 0 0 0 2px rgba(26,115,232,0.15); }
.iinput.answered { border-color: #1a73e8; background: #f0f6ff; }
.iinput.correct { border-color: #34a853; background: #e6f4ea; }
.iinput.wrong { border-color: #ea4335; background: #fce8e6; }

/* ── Dropdown select (matching/heading) ── */
.q-dropdown {
  display: inline-block;
  margin-top: 6px;
  padding: 7px 30px 7px 10px;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  color: #333;
  background: #fff;
  border: 1px solid #999;
  border-radius: 2px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='10' height='6' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  min-width: 80px;
}
.q-dropdown:focus { outline: none; border-color: #1a73e8; box-shadow: 0 0 0 2px rgba(26,115,232,0.15); }
.q-dropdown.answered { border-color: #1a73e8; background-color: #f0f6ff; }

.dropdown-item .mcq-stem { margin-bottom: 4px; }

/* Inline dropdown for wordbank summary completion */
.wordbank-summary { line-height: 2.2; }
.q-dropdown-inline {
  display: inline-block;
  padding: 4px 24px 4px 8px;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  color: #333;
  background: #fff;
  border: 1px solid #999;
  border-radius: 3px;
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg width='8' height='5' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23666'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  min-width: 70px;
  vertical-align: middle;
}
.q-dropdown-inline:focus { outline: none; border-color: #1a73e8; box-shadow: 0 0 0 2px rgba(26,115,232,0.15); }
.q-dropdown-inline.answered { border-color: #1a73e8; background-color: #f0f6ff; }

/* ── Review hints ── */
.hint { font-size: 13px; color: #34a853; font-weight: 700; }
.hint-wrapper { margin-top: 6px; }
.exp-box {
  margin-top: 8px;
  background: #e8f0fe;
  border: 1px solid #c2d7f5;
  border-radius: 4px;
  padding: 10px 14px;
  font-size: 13px;
  color: #174ea6;
  line-height: 1.6;
}
.exp-box b { color: #0d47a1; }

/* ── HIGHLIGHTING & NOTES ── */
.reading-highlight { background-color: #ffeb3b; color: #000; }
.reading-note-trigger { background-color: #ffccbc; border-bottom: 2px solid #ff5722; cursor: pointer; position: relative; }
.reading-note-trigger::after { content: '📝'; font-size: 12px; vertical-align: super; margin-left: 2px; }

.reading-context-menu { position: fixed; background: white; border: 1px solid #ddd; box-shadow: 0 4px 12px rgba(0,0,0,0.15); border-radius: 6px; padding: 6px 0; z-index: 2000; min-width: 150px; }
.context-menu-item { padding: 9px 16px; font-size: 13px; color: #333; cursor: pointer; display: flex; align-items: center; gap: 8px; }
.context-menu-item:hover { background: #f0f0f0; }
.context-menu-item.danger:hover { background: #fce8e6; color: #ea4335; }
.context-menu-divider { height: 1px; background: #eee; margin: 4px 0; }

/* Sticky Note Modal */
.note-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.3); display: flex; align-items: center; justify-content: center; z-index: 3000; }
.note-modal { background: #fff9c4; width: 300px; padding: 20px; border-radius: 4px; box-shadow: 0 8px 24px rgba(0,0,0,0.2); border: 1px solid #fbc02d; }
.note-modal-header { font-size: 12px; font-weight: 800; color: #f57f17; text-transform: uppercase; margin-bottom: 12px; display: flex; justify-content: space-between; align-items: center; }
.note-modal textarea { width: 100%; height: 120px; background: transparent; border: none; border-bottom: 1px solid #fbc02d; font-family: inherit; font-size: 14px; line-height: 1.5; resize: none; outline: none; padding: 4px 0; }
.note-modal-footer { display: flex; justify-content: flex-end; gap: 10px; margin-top: 16px; }
.note-btn { padding: 6px 12px; font-size: 12px; font-weight: 700; border-radius: 4px; cursor: pointer; }
.note-btn-save { background: #fbc02d; color: #7f5e00; border: none; }
.note-btn-cancel { background: transparent; border: 1px solid #fbc02d; color: #f57f17; }

/* ── RESPONSIVE ── */
@media (max-width: 768px) {
  .it-topbar {
    padding: 6px 12px;
    flex-wrap: wrap;
    height: auto;
    min-height: 44px;
    gap: 6px;
  }

  .it-topbar-btn {
    min-height: 44px;
    padding: 8px 14px;
  }

  .split {
    flex-direction: column;
    overflow: hidden;
  }

  .divider {
    display: none;
  }

  .reading-side, .q-side {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 100% !important;
    border-right: none;
    flex: 1 1 50% !important;
    min-height: 0 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    padding: 20px !important;
  }

  .reading-side {
    border-bottom: 3px solid var(--accent);
  }

  .passage-title {
    font-size: 20px;
  }

  .passage-text {
    font-size: 14px;
    line-height: 1.75;
  }

  .it-botbar {
    flex-wrap: wrap;
    padding: 8px;
    gap: 6px;
    height: auto;
    min-height: 48px;
  }

  .it-parts {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .it-part {
    min-height: 44px;
    display: flex;
    align-items: center;
    padding: 8px 14px;
  }

  .it-qstrip {
    width: 100%;
    justify-content: flex-start;
  }

  .it-nav-arrows {
    width: 100%;
    justify-content: center;
  }

  .it-arrow {
    min-width: 44px;
    min-height: 44px;
  }

  .qbtn {
    width: 32px;
    height: 32px;
    font-size: 12px;
  }

  .q-scroll {
    padding: 20px 16px;
  }

  .note-modal {
    width: 90%;
    max-width: 300px;
  }
}

@media (max-width: 480px) {
  .it-topbar-l {
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    width: 100%;
  }

  .it-topbar-r {
    width: 100%;
    justify-content: center;
    flex-wrap: wrap;
  }

  .it-logo {
    font-size: 18px;
  }

  .reading-side, .q-side {
    padding: 16px !important;
  }

  .passage-title {
    font-size: 18px;
  }

  .iinput {
    width: 100%;
    min-width: 80px;
  }

  .mcq-opt {
    padding: 10px 12px;
    font-size: 14px;
    min-height: 44px;
  }

  .q-section-header {
    font-size: 14px;
  }

  .q-instruction {
    padding: 12px 14px;
    font-size: 13px;
  }

  .q-dropdown {
    width: 100%;
    min-height: 44px;
  }
}
