body[data-subject-theme="kiso"] { --oq-accent: #167d84; --oq-dark: #145268; }
body[data-subject-theme="tekisei"] { --oq-accent: #25638b; --oq-dark: #153e61; }
body[data-subject-theme="senmon"] { --oq-accent: #28705f; --oq-dark: #174d4b; }

#pastMenuScreen .one-question-entry {
  grid-column: auto;
  background: linear-gradient(135deg, var(--oq-accent, #176d82), var(--oq-dark, #174b66));
  border: 0;
}

#oneQuestionMenuScreen .topbar,
#oneQuestionTopicScreen .topbar,
#oneQuestionQuizScreen .topbar { background: var(--oq-dark, #174b66); }

.oq-section { display: grid; gap: 22px; max-width: 1000px; margin: 0 auto; padding: 22px 18px 32px; }
.oq-start { padding: 19px 21px; background: #fff; border: 1px solid #d4e1e9; border-radius: 8px; }
.oq-start h2, .oq-section-heading h2, .oq-subheading { margin: 0; color: #193c55; font-size: 17px; line-height: 1.45; }
.oq-subheading { font-size: 15px; margin-bottom: -12px; }
.oq-section-heading { display: flex; align-items: baseline; justify-content: space-between; margin: 0 0 11px; }
.oq-quick-count { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 12px; }
.oq-quick-count button { min-width: 49px; min-height: 38px; padding: 6px 10px; border: 1px solid #c8d8e2; border-radius: 6px; background: #fff; color: #31566b; font: inherit; font-size: 13px; font-weight: 700; }
.oq-quick-count button[aria-pressed="true"] { background: #dceef2; border-color: var(--oq-accent, #176d82); color: #123d52; }
.oq-panel {
  min-width: 0;
  background: #fff;
  border: 1px solid #d4e1e9;
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(18, 48, 68, .08);
  padding: 16px;
}
.oq-panel h2,
.oq-panel h3 { margin: 0; color: var(--oq-dark, #174b66); line-height: 1.4; }
.oq-panel h2 { font-size: 20px; }
.oq-panel h3 { font-size: 16px; }
.oq-note { margin: 8px 0 0; color: #566b79; font-size: 13px; line-height: 1.65; }
.oq-random-row { display: grid; grid-template-columns: minmax(100px, 180px) minmax(0, 1fr); gap: 12px; align-items: end; margin-top: 14px; }
.oq-count-label { display: grid; gap: 6px; color: #304b5c; font-size: 13px; font-weight: 800; }
.oq-count-label input {
  width: 100%; min-height: 48px; border: 1px solid #b9cbd7; border-radius: 9px;
  padding: 8px 12px; color: #122e42; background: #fff; font: inherit; font-size: 18px;
}
.oq-button {
  appearance: none; min-height: 48px; border: 1px solid #b8cbd7; border-radius: 9px;
  padding: 11px 14px; color: #174b66; background: #fff; font: inherit; font-weight: 800;
  text-align: left; cursor: pointer; touch-action: manipulation;
}
.oq-button:focus-visible { outline: 3px solid #65aaca; outline-offset: 2px; }
.oq-button.primary { color: #fff; background: var(--oq-accent, #176d82); border-color: var(--oq-accent, #176d82); }
.oq-button.subtle { background: #f3f7f9; }
.oq-button:disabled { color: #778692; background: #eef1f3; border-color: #d9dfe3; cursor: default; }
.oq-full { width: 100%; }
.oq-random-button { margin-top: 12px; text-align: center; }
.oq-count-summary { display: block; margin-top: 5px; color: #617481; font-size: 13px; font-weight: 600; }
.oq-category-grid, .oq-topic-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; }
.oq-category-button, .oq-topic-button { display: flex; min-width: 0; align-items: center; gap: 11px; min-height: 68px; border-radius: 7px; box-shadow: none; }
.oq-category-number { flex: 0 0 auto; font-size: 13px; font-variant-numeric: tabular-nums; color: var(--oq-accent, #176d82); }
.oq-category-name { flex: 1 1 auto; min-width: 0; }
.oq-category-button strong { display: block; color: #193c55; font-size: 15px; line-height: 1.35; }
.oq-category-button small { display: block; margin-top: 2px; color: #607583; font-size: 11px; line-height: 1.35; font-weight: 500; }
.oq-category-count { flex: 0 0 auto; color: #516b7b; font-size: 12px; font-weight: 700; white-space: nowrap; }
.oq-chevron { flex: 0 0 auto; color: #608499; font-size: 24px; line-height: 1; }
.oq-topic-button strong { display: block; flex: 1 1 auto; min-width: 0; color: #183d56; font-size: 15px; line-height: 1.45; }
.oq-count-badge { flex: 0 0 auto; color: var(--oq-accent, #176d82); font-size: 13px; font-weight: 900; white-space: nowrap; }
.oq-back-row { display: flex; gap: 8px; }
.oq-back-row .oq-button { flex: 1; text-align: center; }

.oq-quiz-wrap { max-width: 900px; margin: 0 auto; padding: 16px 16px calc(140px + env(safe-area-inset-bottom)); }
.oq-quiz-meta { display: flex; justify-content: space-between; gap: 12px; color: #4f6878; font-size: 13px; font-weight: 800; }
.oq-progress { height: 7px; margin: 9px 0 16px; overflow: hidden; border-radius: 99px; background: #dce7ed; }
.oq-progress > span { display: block; height: 100%; width: 0; background: var(--oq-accent, #176d82); transition: width .18s ease; }
.oq-card {
  background: #fff; border: 1px solid #d5e2ea; border-radius: 12px;
  box-shadow: 0 5px 18px rgba(18, 48, 68, .08); padding: 18px;
}
.oq-origin { margin: 0 0 12px; color: #5c7180; font-size: 12px; font-weight: 800; }
.oq-prompt { margin: 0 0 12px; color: #385466; font-size: 14px; font-weight: 800; line-height: 1.6; }
.oq-statement { overflow-wrap: anywhere; color: #142f42; font-size: 18px; font-weight: 700; line-height: 1.8; }
.oq-statement img { max-width: 100%; height: auto; }
.oq-answer-dock { position: fixed; left: 50%; bottom: 0; z-index: 70; transform: translateX(-50%); width: min(430px, 100%); display: flex; align-items: stretch; gap: 8px; padding: 8px 10px calc(8px + env(safe-area-inset-bottom)); box-sizing: border-box; background: rgba(239, 246, 250, .97); border-top: 1px solid #ccdae3; box-shadow: 0 -5px 18px rgba(19, 48, 68, .13); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }
.oq-answer-dock[hidden], .oq-dock-next[hidden] { display: none !important; }
.oq-answers { flex: 1 1 auto; min-width: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.oq-dock-next { flex: 0 0 108px; text-align: center; }
.oq-answer {
  min-height: 58px; border: 1px solid #b9cbd6; border-radius: 8px; background: #fff;
  color: #183d56; font: inherit; font-size: 32px; font-weight: 700; line-height: 1; cursor: pointer;
}
.oq-answer[data-value="true"] { border-color: #247954; color: #176744; }
.oq-answer[data-value="false"] { border-color: #c14a4a; color: #a72f36; }
.oq-answer:disabled { opacity: .7; cursor: default; }
.oq-answer.selected { box-shadow: 0 0 0 3px rgba(31, 100, 132, .16); }
.oq-answer.correct-choice { background: #e6f5ed; border-color: #238455; color: #12613c; opacity: 1; }
.oq-answer.wrong-choice { background: #fff0f0; border-color: #c34646; color: #a72f36; opacity: 1; }
.oq-result-feedback { display: none; margin-top: 24px; padding: 15px 17px; border-radius: 7px; line-height: 1.75; }
.oq-result-feedback.visible { display: block; }
.oq-result-feedback.good { color: #155b3c; background: #e8f5ed; }
.oq-result-feedback.bad { color: #8f2e33; background: #fff0f0; }
.oq-explanation { margin-top: 8px; color: #283f50; font-size: 15px; line-height: 1.8; white-space: pre-line; }
.oq-details { margin-top: 14px; border-top: 1px solid #dce5ea; padding-top: 10px; }
.oq-details summary { min-height: 40px; display: flex; align-items: center; color: #235c78; font-size: 13px; font-weight: 800; cursor: pointer; }
.oq-source-details { color: #304858; font-size: 14px; line-height: 1.75; overflow-wrap: anywhere; }
.oq-source-details p:first-child { margin-top: 0; }
.oq-next-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-top: 26px; }
.oq-next-row .oq-button { text-align: center; }
.oq-final { text-align: center; }
.oq-final-score { margin: 8px 0; color: var(--oq-accent, #176d82); font-size: 38px; font-weight: 900; }
.oq-final-list { margin: 14px 0 0; padding: 0; list-style: none; text-align: left; }
.oq-final-list li { padding: 10px 0; border-top: 1px solid #e1e8ec; line-height: 1.55; }

@media (max-width: 520px) {
  .oq-category-grid, .oq-topic-list { grid-template-columns: 1fr; }
  .oq-section { padding: 14px 12px 24px; gap: 18px; }
  .oq-start { padding: 16px; }
  .oq-random-row { grid-template-columns: minmax(76px, .35fr) minmax(0, .65fr); gap: 8px; }
  .oq-count-label input { min-height: 48px; }
  .oq-quiz-wrap { padding: 12px 12px calc(140px + env(safe-area-inset-bottom)); }
  .oq-card { padding: 15px; }
  .oq-statement { font-size: 17px; }
}
@media (min-width: 700px) { .oq-answer-dock { width: min(760px, calc(100vw - 48px)); } }
@media (min-width: 1000px) { .oq-answer-dock { width: min(960px, calc(100vw - 72px)); } }
