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

:root {
  /* Test List palette */
  --tl-bg: #F5F5F5;
  --tl-brand: #62C8DF;
  --text-primary: #626768;
  --text-secondary: #7B8182;
  --text-tertiary: #959A9B;
  --icon-chevron: #B0B3B4;
  --green-check: #A8DF62;
  --grey-icon: #D7D9D9;
  --live-red: #D56F62;
  --card-attempted-bg: #ECFFD5;
  --card-live-bg: #FDFDED;
  --pro-bg: #E5E6E6;
  --pro-text: #4A4D4E;
  --mock-bg: #E1F4F9;
  --mock-text: #3C8090;
  --gold: #FCE795;
  --gold-icon: #FFCC00;
  --divider: #E5E6E6;

  /* Overall Progress palette */
  --op-dark: #1F4851;
  --op-dark-highlight: #2B5861;
  --op-link: #4A69A2;
  --band-green: #82C42D;
  --band-yellow: #FFCC00;
  --band-orange: #FFA500;
  --band-red: #D56F62;
}

* { box-sizing: border-box; }
html, body {
  margin: 0;
  padding: 0;
  background: #DADFE0;
  font-family: 'Roboto', -apple-system, BlinkMacSystemFont, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
button { font-family: inherit; border: none; background: none; cursor: pointer; padding: 0; }
ul { list-style: none; margin: 0; padding: 0; }
img { display: block; }

/* ---- device / mobile-first shell ------------------------------------- */
.device {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  min-height: 100vh;
  background: var(--tl-bg);
  position: relative;
  overflow: hidden;
  box-shadow: 0 0 40px rgba(0,0,0,0.15);
}
@media (min-width: 431px) {
  html, body { display: flex; justify-content: center; }
  .device { min-height: 100vh; margin-top: 0; }
}

.screen { display: none; height: 100vh; height: 100dvh; flex-direction: column; }
.screen.is-active { display: flex; }

.icon-btn { display: flex; align-items: center; justify-content: center; width: 24px; height: 24px; flex: 0 0 auto; }

.tag { display: inline-flex; align-items: center; justify-content: center; border-radius: 2px; font-weight: 500; white-space: nowrap; }
.tag--new { background: var(--gold); color: var(--pro-text); font-size: 10px; line-height: 12px; padding: 2px 6px; margin-left: 6px; font-weight: 500; }
.tag--pro { background: var(--pro-bg); color: var(--pro-text); font-size: 8px; line-height: 10px; padding: 2px 6px; font-weight: 400; }
.tag--mock { background: var(--mock-bg); color: var(--mock-text); font-size: 10px; line-height: 12px; padding: 2px 4px; font-weight: 500; margin-top: 4px; border-radius: 2px; }
.tag--live { display: inline-flex; align-items: center; gap: 2px; background: transparent; color: var(--live-red); font-size: 10px; line-height: 12px; padding: 2px 3px; font-weight: 500; text-transform: uppercase; }
.tag--live i { width: 6px; height: 6px; border-radius: 50%; background: var(--live-red); display: inline-block; }

/* ============================================================ TEST LIST */
.tl-header { background: var(--tl-brand); flex: 0 0 auto; }
.tl-header__row { display: flex; align-items: center; justify-content: space-between; padding: 16px; gap: 16px; }
.tl-header__title { flex: 1; text-align: center; color: #fff; font-size: 20px; line-height: 24px; font-weight: 700; margin: 0; }

.tl-tabs { display: flex; gap: 4px; padding: 8px 8px 0; overflow-x: auto; scrollbar-width: none; }
.tl-tabs::-webkit-scrollbar { display: none; }
.tl-tab { flex: 0 0 auto; color: #fff; font-size: 14px; line-height: 17px; font-weight: 400; padding: 11px 6px; position: relative; opacity: 0.85; }
.tl-tab.is-active { font-weight: 500; opacity: 1; padding-bottom: 12px; }
.tl-tab.is-active::after { content: ''; position: absolute; left: 0; right: 0; bottom: 0; height: 3px; background: #fff; border-radius: 2px 2px 0 0; }

.tl-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 16px 16px 0; }

.promo-banner {
  width: 100%; display: flex; align-items: center; gap: 10px;
  background: var(--card-live-bg);
  border: 1px solid #FFE066;
  border-radius: 8px;
  padding: 10px 10px 8px;
  margin-bottom: 20px;
  text-align: left;
}
.promo-banner__icon { flex: 0 0 auto; width: 28px; height: 28px; }
.promo-banner__text { flex: 1; display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.promo-banner__title { font-size: 14px; line-height: 17px; font-weight: 500; color: var(--text-primary); display: flex; align-items: center; }
.promo-banner__sub { font-size: 12px; line-height: 14px; color: var(--text-secondary); }

.month-groups { display: flex; flex-direction: column; gap: 20px; }
.month-group { display: flex; flex-direction: column; gap: 12px; }
.month-head { display: flex; align-items: center; gap: 8px; }
.month-head__label { font-size: 12px; line-height: 14px; font-weight: 500; color: var(--text-tertiary); white-space: nowrap; }
.month-head__label.is-current { color: var(--tl-brand); }
.month-head__line { flex: 1; height: 1px; background: var(--divider); }

.month-cards { display: flex; flex-direction: column; gap: 8px; }

.trow { display: flex; align-items: flex-start; gap: 12px; transition: opacity .2s; }
.trow--faded { opacity: 0.6; }
.trow--clickable { cursor: pointer; }
.trow--clickable:active .tcard { filter: brightness(0.97); }
.trow__icon { flex: 0 0 auto; width: 20px; height: 20px; margin-top: 12px; }

.tcard {
  /* gap only matters for mock cards (icon + tag group, then title/meta) —
     regular cards have a single child. 8px read as cramped, so widened it. */
  flex: 1; display: flex; gap: 16px; align-items: flex-start;
  background: #fff; border-radius: 4px; padding: 12px;
  box-shadow: 1px 1px 8px 0 rgba(0,0,0,0.08);
  min-width: 0;
}
.tcard--attempted { background: var(--card-attempted-bg); }
.tcard--live { background: var(--card-live-bg); }
.tcard--upcoming { box-shadow: none; }

/* No fixed width here — the "Mock Test" tag is wider than the 40px icon, so a
   fixed-width column let it overflow past the boundary and crowd the gap. */
.tcard__mock-icon { flex: 0 0 auto; display: flex; flex-direction: column; align-items: center; }
.tcard__body { flex: 1; display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.tcard__top { display: flex; align-items: flex-start; justify-content: space-between; gap: 8px; }
.tcard__title { font-size: 14px; line-height: 17px; font-weight: 500; color: var(--text-primary); }
.tcard__meta { font-size: 12px; line-height: 14px; color: var(--text-secondary); }

.tcard__tags { display: flex; align-items: center; gap: 6px; flex: 0 0 auto; }
.tcard__rank { display: flex; flex-direction: column; align-items: flex-end; gap: 2px; flex: 0 0 auto; }
.tcard__rank-label { display: flex; align-items: center; gap: 3px; font-size: 10px; line-height: 12px; color: var(--text-secondary); white-space: nowrap; }
.tcard__rank-value { font-size: 12px; line-height: 14px; font-weight: 500; color: var(--text-primary); }

.empty-state { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px 0 8px; color: var(--text-secondary); font-size: 13px; }
.empty-state p { margin: 0; }

.prev-years { margin-top: 20px; padding-bottom: 24px; }
.prev-years__list { display: flex; flex-direction: column; }
.prev-year-row { width: 100%; display: flex; align-items: center; justify-content: space-between; padding: 16px 0; border-bottom: 1px solid var(--divider); font-size: 14px; font-weight: 500; color: var(--text-primary); }
.prev-year-row:last-child { border-bottom: none; }

.bottom-nav {
  flex: 0 0 auto; display: flex; background: var(--tl-bg);
  padding: 8px 16px calc(8px + env(safe-area-inset-bottom));
  box-shadow: 0 -4px 16px rgba(0,0,0,0.1);
  gap: 4px;
}
.bn-item { flex: 1; display: flex; flex-direction: column; align-items: center; gap: 4px; color: var(--text-tertiary); padding: 7px 0; position: relative; }
.bn-item span { font-size: 10px; line-height: 12px; font-weight: 500; }
.bn-item.is-active { color: var(--tl-brand); }
.bn-item.is-active::after { content: ''; position: absolute; bottom: -8px; left: 0; right: 0; height: 4px; background: var(--tl-brand); border-radius: 2px 2px 0 0; }

/* ============================================================ OVERALL PROGRESS */
.op-scroll { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; background: var(--tl-bg); }

.op-header { background: var(--op-dark); padding-top: max(24px, env(safe-area-inset-top)); padding-bottom: 8px; }
.op-header__row { display: flex; align-items: center; gap: 16px; padding: 16px; }
.op-header__title { flex: 1; color: #fff; font-size: 18px; line-height: 22px; font-weight: 500; margin: 0; }
.op-filter { display: flex; align-items: center; gap: 4px; color: #fff; font-size: 12px; line-height: 14px; font-weight: 500; flex: 0 0 auto; position: relative; white-space: nowrap; }
.op-filter select { position: absolute; inset: 0; opacity: 0; width: 100%; height: 100%; }

.op-legend { display: flex; align-items: center; gap: 8px; padding: 0 16px 6px; color: #fff; font-size: 12px; line-height: 14px; }
.op-legend__item { display: flex; align-items: center; gap: 4px; }
.op-legend__sep { width: 1px; height: 13px; background: rgba(229,230,230,0.5); }
.marker { display: inline-block; }
.marker--diamond { width: 8px; height: 8px; background: var(--band-red); transform: rotate(45deg); border-radius: 2px; }
.marker--square { width: 12px; height: 12px; background: var(--tl-brand); border-radius: 2px; }

.op-chart-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; padding: 0 8px 8px; scrollbar-width: none; }
.op-chart-scroll::-webkit-scrollbar { display: none; }
.op-chart-svg { display: block; }
.op-chart-xlabel {
  font-family: 'Roboto', sans-serif; font-size: 10px; line-height: 12px; font-weight: 500;
  color: #fff; text-align: center; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.op-chart-date { font-family: 'Roboto', sans-serif; font-size: 10px; line-height: 14px; font-weight: 400; color: #fff; display: flex; align-items: center; justify-content: center; gap: 2px; }

.op-insights-wrap { position: relative; z-index: 1; margin-top: -44px; padding: 0 0 0 16px; }
.op-insights { display: flex; gap: 12px; overflow-x: auto; padding-right: 16px; padding-bottom: 4px; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; scrollbar-width: none; }
.op-insights::-webkit-scrollbar { display: none; }
.op-insight-card {
  flex: 0 0 257px; scroll-snap-align: start;
  display: flex; gap: 10px; align-items: flex-start;
  background: #fff; border-radius: 8px; padding: 12px 16px;
  box-shadow: 1px 1px 8px 0 rgba(0,0,0,0.08);
}
.op-insight-card__icon { flex: 0 0 auto; width: 28px; height: 28px; }
.op-insight-card p { margin: 0; font-size: 12px; line-height: 14px; font-weight: 500; color: var(--text-primary); }

.op-section { padding: 24px 16px 0; }
.op-section__head { display: flex; align-items: center; gap: 6px; }
.op-section__head h2 { margin: 0; font-size: 12px; line-height: 14px; font-weight: 500; color: var(--text-tertiary); text-transform: uppercase; letter-spacing: 0.2px; }
.op-section__sub { margin: 8px 0 16px; font-size: 12px; line-height: 14px; color: var(--text-primary); }

.info-dot { width: 14px; height: 14px; border-radius: 50%; border: 1.4px solid var(--text-tertiary); color: var(--text-tertiary); font-size: 9px; font-style: italic; font-family: Georgia, serif; display: flex; align-items: center; justify-content: center; line-height: 1; }
.info-dot--sm { flex: 0 0 auto; width: 16px; height: 16px; border-color: var(--text-secondary); color: var(--text-secondary); }

/* Info icon (exported SVG) — recolored per usage via CSS mask + currentColor,
   so we don't need multiple pre-tinted copies of the asset. */
.icon-info {
  display: inline-block; flex: 0 0 auto; width: 14px; height: 14px; color: var(--text-tertiary);
  background-color: currentColor;
  -webkit-mask: url('../assets/icon-info.svg') no-repeat center / contain;
  mask: url('../assets/icon-info.svg') no-repeat center / contain;
}
.icon-info--sm { width: 16px; height: 16px; }
.icon-info--muted { color: var(--text-secondary); }
.icon-info-btn { display: flex; align-items: center; justify-content: center; }

/* ============================================================ BOTTOM SHEET */
.sheet-overlay {
  position: absolute; inset: 0; background: rgba(0,0,0,0.5);
  opacity: 0; pointer-events: none; transition: opacity .25s ease; z-index: 40;
}
.sheet-overlay.is-open { opacity: 1; pointer-events: auto; }

.bottom-sheet {
  position: absolute; left: 0; right: 0; bottom: 0; z-index: 41;
  background: #fff; border-radius: 16px 16px 0 0;
  transform: translateY(100%); transition: transform .3s ease;
  max-height: 85%; overflow-y: auto;
}
.bottom-sheet.is-open { transform: translateY(0); }
.bottom-sheet__inner { display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 40px 16px 28px; }
.bottom-sheet__title { margin: 0; font-size: 20px; line-height: 24px; font-weight: 700; color: var(--pro-text); text-align: center; }
.bottom-sheet__list { margin: 0; padding-left: 18px; display: flex; flex-direction: column; gap: 12px; align-self: stretch; list-style: disc; }
.bottom-sheet__list li { font-size: 14px; line-height: 17px; color: var(--text-primary); }
.bottom-sheet__btn {
  width: 100%; height: 40px; margin-top: 6px; background: var(--tl-brand); color: #fff; border-radius: 4px;
  font-size: 14px; font-weight: 700; letter-spacing: 0.5px;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.2);
}
.bottom-sheet__btn:active { filter: brightness(0.94); }

.op-improve-card { background: #fff; border-radius: 8px; padding: 12px 0; box-shadow: 1px 1px 8px 0 rgba(0,0,0,0.08); }
.op-improve-list { display: flex; flex-direction: column; }
.op-improve-item { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-bottom: 1px solid var(--tl-bg); }
.op-improve-item:last-child { border-bottom: none; }
.op-improve-item img { flex: 0 0 auto; width: 27px; height: 28px; border-radius: 3.2px; object-fit: cover; }
.op-improve-item span { flex: 1; font-size: 12px; line-height: 14px; font-weight: 500; color: var(--text-primary); }

.op-show-more { width: 100%; display: flex; align-items: center; justify-content: center; gap: 6px; padding-top: 16px; color: var(--op-link); font-size: 12px; line-height: 14px; font-weight: 500; }
.op-show-more svg { transition: transform .2s; }
.op-show-more.is-expanded svg { transform: rotate(180deg); }

.op-subject-controls { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }
.op-sort { display: flex; align-items: center; gap: 8px; color: var(--text-primary); font-size: 12px; line-height: 14px; font-weight: 500; }
.op-sort svg { color: var(--text-secondary); }
.op-subject-controls__sep { width: 1px; height: 12px; background: var(--grey-icon); }
.op-show-dropdown { display: flex; align-items: center; gap: 4px; font-size: 12px; line-height: 14px; color: var(--text-tertiary); margin-left: auto; }
.op-show-dropdown strong { color: var(--text-primary); font-weight: 500; }

.op-subject-list { display: flex; flex-direction: column; gap: 8px; }
.op-subject-row {
  display: flex; align-items: center; gap: 12px; background: #fff; border-radius: 8px; padding: 8px;
}
.op-subject-row::before { content: ''; width: 4px; height: 40px; border-radius: 10px; background: var(--bar-color, #ccc); flex: 0 0 auto; }
.op-subject-row__name { flex: 1; font-size: 14px; line-height: 17px; font-weight: 500; color: var(--text-primary); }
.op-subject-row__value { font-size: 10px; line-height: 12px; font-weight: 500; color: var(--pro-text); white-space: nowrap; }

.op-footnote { display: flex; align-items: flex-start; gap: 6px; margin: 16px 0 32px; font-size: 12px; line-height: 14px; color: var(--text-secondary); }

/* ============================================================ GT START */
.gt-start-header .tl-header__title { text-align: left; font-size: 18px; line-height: 22px; font-weight: 500; }
.gt-start-body { flex: 1; overflow-y: auto; display: flex; flex-direction: column; align-items: center; padding: 28px 26px 0; gap: 28px; }

.gt-start-laurel { position: relative; width: 96px; height: 78px; flex: 0 0 auto; }
.gt-start-laurel__img { display: block; width: 100%; height: 100%; }
.gt-start-laurel__letter {
  position: absolute; top: 16px; left: 0; right: 0; text-align: center;
  font-size: 18px; font-weight: 700; color: var(--text-secondary);
}

.gt-start-card {
  width: 100%; max-width: 308px; background: #fff; border-radius: 4px;
  box-shadow: 1px 1px 8px 0 rgba(0,0,0,0.15);
  padding: 28px 24px; display: flex; flex-direction: column; align-items: center; gap: 24px;
}
.gt-start-card h2 { margin: 0; font-size: 18px; line-height: 22px; font-weight: 500; color: var(--text-primary); text-align: center; }
.gt-start-divider { width: 100%; height: 1px; background: var(--divider); margin-top: 16px; }
.gt-start-desc { margin: 0; font-size: 14px; line-height: 17px; color: var(--text-secondary); text-align: center; }
.gt-start-desc strong { font-weight: 500; color: inherit; }

.gt-start-btn {
  width: 100%; height: 40px; background: var(--tl-brand); color: #fff; border-radius: 4px;
  font-size: 14px; font-weight: 700; letter-spacing: 0.5px; text-transform: uppercase;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.2);
}
.gt-start-btn:active { filter: brightness(0.94); }

.gt-start-footer { margin: 0 0 28px; text-align: center; font-size: 12px; line-height: 14px; color: var(--text-secondary); }
.gt-start-footer a { color: var(--op-link); font-weight: 500; text-decoration: none; }

/* ============================================================ LAST QUESTION (test taking) */
.q-topbar { flex: 0 0 auto; display: flex; align-items: center; gap: 12px; padding: 16px 20px 0; }
.q-topbar__left { display: flex; align-items: center; gap: 4px; flex: 1; min-width: 0; }
.q-topbar__part { font-size: 14px; line-height: 17px; font-weight: 500; color: var(--text-secondary); white-space: nowrap; }
.q-topbar__index { font-size: 14px; line-height: 17px; font-weight: 400; color: var(--tl-brand); white-space: nowrap; }
.q-topbar__timer { font-size: 14px; line-height: 17px; font-weight: 400; color: var(--text-secondary); flex: 0 0 auto; }

.q-body { flex: 1; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 23px 20px 20px; display: flex; flex-direction: column; }
.q-text { margin: 0 0 40px; font-size: 20px; line-height: 24px; font-weight: 700; color: var(--text-primary); }

.q-options { display: flex; flex-direction: column; gap: 12px; }
.q-option {
  display: flex; align-items: center; gap: 8px; min-height: 64px;
  padding: 12px; border-radius: 4px; background: #fff; transition: background-color .15s;
}
.q-option.is-selected { background: rgba(98, 200, 223, 0.2); }
.q-option__letter { flex: 0 0 auto; font-size: 14px; line-height: 17px; font-weight: 400; color: var(--text-tertiary); }
.q-option__text { flex: 1; font-size: 16px; line-height: 19px; font-weight: 500; color: var(--text-primary); }

.q-guess-row { display: flex; align-items: center; gap: 8px; margin-top: 20px; }
.q-guess { display: flex; align-items: center; gap: 8px; font-size: 14px; line-height: 17px; color: var(--text-tertiary); position: relative; }
.q-guess input { position: absolute; opacity: 0; width: 20px; height: 20px; margin: 0; cursor: pointer; }
.q-guess__box {
  width: 20px; height: 20px; border-radius: 4px; background: #fff; border: 1.5px solid var(--grey-icon);
  box-shadow: 0 1px 1px rgba(0,0,0,0.1); flex: 0 0 auto; position: relative;
}
.q-guess input:checked + .q-guess__box { background: var(--tl-brand); border-color: var(--tl-brand); }
.q-guess input:checked + .q-guess__box::after {
  content: ''; position: absolute; left: 5px; top: 2px; width: 5px; height: 9px;
  border: solid #fff; border-width: 0 2px 2px 0; transform: rotate(45deg);
}

.q-bottombar {
  flex: 0 0 auto; height: 56px; display: flex; align-items: center; gap: 28px;
  padding: 0 16px calc(0px + env(safe-area-inset-bottom)); background: #fff;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.1);
}
.q-complete-btn {
  margin-left: auto; width: 150px; height: 40px; background: var(--tl-brand); color: #fff;
  border-radius: 4px; font-size: 14px; font-weight: 700; letter-spacing: 0.5px;
  box-shadow: inset 0 -2px 3px rgba(0,0,0,0.2);
}
.q-complete-btn:active { filter: brightness(0.94); }
#q-bookmark.is-active svg path { fill: var(--tl-brand); stroke: var(--tl-brand); }
