/* てるるん一問一答（赤シートver）- WordPress Plugin CSS */
/* SWELL Theme Full Width Support */

.trr-fullwidth-container {
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  position: relative;
}

/* Override SWELL container width */
.post_content .trr-fullwidth-container,
.l-mainContent .trr-fullwidth-container,
.l-content .trr-fullwidth-container,
article .trr-fullwidth-container {
  max-width: none !important;
  width: 100vw !important;
  margin-left: calc(50% - 50vw) !important;
  margin-right: calc(50% - 50vw) !important;
  padding: 0 !important;
}

/* CSS Variables */
.trr-study {
  --trr-red-rgb: 255, 0, 0;
  --trr-red: rgba(var(--trr-red-rgb), .45);
  --trr-transition-fast: .18s;
  --trr-transition-med: .22s;
}

/* Base Reset for Plugin */
.trr-study *,
.trr-study *::before,
.trr-study *::after {
  box-sizing: border-box;
}

.trr-fullwidth-container {
  overflow-x: hidden;
}

.trr-study {
  display: flex;
  height: 100vh;
  overflow: hidden;
  font-family: "Noto Sans JP", sans-serif;
  background: #fff;
  color: #111;
  -webkit-font-smoothing: antialiased;
  margin: 0;
}

/* Sidebar */
.trr-sidebar {
  width: var(--trr-sidebar-width, 280px);
  min-width: var(--trr-sidebar-width, 280px);
  background: #fff;
  border-right: 1px solid #ddd;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  transition: width var(--trr-transition-med), padding var(--trr-transition-med);
  position: relative;
}

/* Sidebar Resizer (PC only) */
.trr-sidebar-resizer {
  flex: 0 0 5px;
  width: 5px;
  background: transparent;
  cursor: col-resize;
  position: relative;
  z-index: 130;
  transition: background 0.15s ease;
  margin-left: -3px;
  margin-right: -2px;
}

.trr-sidebar-resizer:hover,
.trr-sidebar-resizer.trr-dragging {
  background: #4a90e2;
}

.trr-sidebar-closed .trr-sidebar-resizer {
  display: none;
}

body.trr-sidebar-dragging {
  user-select: none;
  cursor: col-resize !important;
}

body.trr-sidebar-dragging .trr-sidebar,
body.trr-sidebar-dragging .trr-main-area {
  transition: none !important;
}

.trr-sidebar-closed .trr-sidebar {
  width: 0;
  min-width: 0;
  padding: 0;
  overflow: hidden;
}

.trr-sidebar-header {
  position: sticky;
  top: 0;
  z-index: 120;
  background: #fff;
  padding: 14px 0 10px;
  border-bottom: 1px solid #eee;
  min-height: 165px;
}

/* Site Logo */
.trr-sidebar-logo {
  text-align: center;
  margin: 0 auto;
  padding: 0 15px;
}

.trr-sidebar-logo a {
  display: inline-block;
}

.trr-site-logo {
  max-width: 200px;
  width: 100%;
  height: auto;
}

/* Sidebar Title (now div with image) */
.trr-sidebar-title {
  text-align: center;
  margin: 5px auto 15px;
  padding: 0 15px;
  /* max-width: 180px; */
  font-weight: bold;
  font-size: 16px;
  word-break: keep-all;
  overflow-wrap: break-word;
  line-break: strict;
}

/* 体験版：サイドバー見出しの副題（例: 無料体験版） */
.trr-sidebar-subtitle {
  display: inline-block;
  margin-top: 4px;
  font-size: 13px;
  font-weight: bold;
  color: #e2453f;
}

/* 体験版：画面下部の固定「購入に進む」バー（cta_url 指定時のみ） */
.trr-cta-bar {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 100000;
  height: 64px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  background: #fff;
  border-top: 1px solid #e3e3e3;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
}
.trr-cta-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  max-width: 100%;
  padding: 12px 32px;
  background: #f3982b;
  color: #fff;
  font-weight: bold;
  font-size: 16px;
  text-decoration: none;
  border-radius: 9999px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
}
.trr-cta-btn:hover {
  opacity: 0.92;
  color: #fff;
}
/* 固定バーぶん、アプリ本体の高さを縮めて重なりを防ぐ */
.trr-has-cta .trr-study {
  height: calc(100vh - 64px);
}

.trr-site-logo {
  max-width: 180px;
}

.trr-sidebar-header .trr-search-box {
  margin: 0 10px;
}

/* Sidebar list - remove all markers */
.trr-sidebar ul,
.trr-sidebar li,
#trr-menu,
#trr-menu li,
#trr-menu ul,
.trr-sub-list,
.trr-sub-list li,
.trr-study ul,
.trr-study li {
  list-style: none !important;
  list-style-type: none !important;
  padding-left: 0;
  margin-left: 0;
}

.trr .trr-sidebar ul,
.trr-study ul {
  padding: 0;
  margin: 0;
  list-style: none !important;
}

.trr-sidebar li::marker,
#trr-menu li::marker,
.trr-sub-list li::marker,
.trr-study li::marker {
  content: none !important;
  display: none !important;
  font-size: 0 !important;
  color: transparent !important;
}

.trr-sub-item {
  padding: 8px 12px !important;
  margin-bottom: 6px !important;
  border-radius: 6px;
  cursor: pointer;
  margin-left: 10px !important;
  font-size: 16px;
}

.trr-sub-item:hover {
  background: #e6e6e6;
}

.trr-sub-item.trr-active {
  background: #d6ecff;
}

.trr-sub-item.trr-active:hover {
  background: #c1d4e5;
}

/* Main Area */
.trr-main-area {
  flex: 1;
  overflow: auto;
  background: #fff;
  position: relative;
  max-width: 100%;
}

#trr-menu {
  padding: 16px 14px 20px;
}

/* Content Topbar */
.trr-content-topbar {
  position: sticky;
  top: 0;
  z-index: 15000;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 5px;
  padding: 10px 12px;
  background: white;
  border-bottom: 1px solid #eee;
  box-shadow: 0 1px 4px rgba(20, 20, 30, .04);
  --trr-topbar-h: 64px;
  transition: transform .22s cubic-bezier(.2, .9, .2, 1), max-height .22s ease, padding .18s ease, opacity .18s ease;
  will-change: transform, max-height, padding, opacity;
  max-height: 1000px;
  overflow: hidden;
  border-bottom: 1px solid #ddd;
  border-left: 1px solid #ddd;
  border-right: 1px solid #ddd;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

@media(min-width:769px) {
  .trr-sidebar-closed .trr-content-topbar {
    padding-left: 50px;
  }

  .trr-sidebar-logo {
    padding: 0 21px 0 0px;
  }
}

.trr-content-topbar>* {
  min-width: 0;
}

.trr-content-topbar .trr-topbar-right {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
  margin-left: auto;
  flex: 0 1 auto;
  flex-wrap: wrap;
}

#trr-findBarPlaceholder {
  display: none;
}

/* Header */
.trr-hdr {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 50px 30px 30px 30px;
}

.trr-hdr-left {
  display: flex;
  align-items: center;
  gap: 8px;
}

.trr-controls {
  display: flex;
  gap: 8px;
}

.trr-controls button {
  padding: 6px 12px;
  border-radius: 6px;
  border: 0;
  cursor: pointer;
  background: #444;
  color: #fff;
}

/* Toggle Sheet Button - centered text */
#trr-toggle-sheet {
  padding: 0 12px;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, .08);
  border: 0;
  color: #fff;
  font-weight: bold;
  cursor: pointer;
  transition: background .14s, color .14s, transform .08s;
  background: #e74c3c;
  width: 120px;
  font-size: 15px;
  height: 36px;
  min-width: 130px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  vertical-align: middle;
  box-sizing: border-box;
}

#trr-toggle-sheet.trr-off {
  background: #777;
}

#trr-toggle-sheet.trr-off:hover {
  background: #5a5a5a;
}

#trr-toggle-sheet.trr-on {
  background: #e74c3c;
}

#trr-toggle-sheet.trr-on:hover {
  background: #be3425;
}

/* Navigation Buttons */
#trr-back,
#trr-backToSearch,
#trr-clearSearchResults {
  display: none;
  background: transparent;
  color: #393939;
  border: 1px solid #393939;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 15px;
  min-width: 170px;
  height: 36px;
}

#trr-back:hover,
#trr-backToSearch:hover,
#trr-clearSearchResults:hover {
  background: #f1f1f1;
}

/* Problem List */
.trr-problem-list {
  font-size: 16px;
  line-height: 1.9;
}

.trr-q {
  font-weight: bold;
  margin: 13px 0 16px;
  font-size: 18px;
}

/* Sidebar Toggle Buttons */
#trr-closeSidebar {
  position: absolute;
  top: -1px;
  right: -1px;
  z-index: 16000;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 0 0 0 6px;
  border: 1px solid #ddd;
  background: #fff;
  color: #333;
  cursor: pointer;
  user-select: none;
  transition: transform var(--trr-transition-fast), opacity var(--trr-transition-med);
}

#trr-openSidebar {
  position: fixed;
  top: -1px;
  left: 0;
  z-index: 16000;
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 0 0 6px 0;
  border: 1px solid #ddd;
  background: #fff;
  color: #333;
  cursor: pointer;
  user-select: none;
  transition: transform var(--trr-transition-fast), opacity var(--trr-transition-med);
}

/* Red Sheet */
.trr-red-sheet {
  position: fixed;
  left: 0;
  width: 0;
  height: 0;
  bottom: 0;
  background: var(--trr-red);
  pointer-events: none;
  z-index: 11000;
  transform: translateY(100%);
  transition: transform .28s cubic-bezier(.2, .9, .2, 1), opacity .12s, height .15s ease-out;
  will-change: transform, left, width, height, bottom, opacity;
  opacity: 0;
  visibility: hidden;
  cursor: grab;
  touch-action: pan-y;
  -webkit-overflow-scrolling: touch;
  -webkit-tap-highlight-color: transparent;
}

.trr-red-sheet.trr-visible {
  transform: translateY(0) !important;
  opacity: 1 !important;
  visibility: visible !important;
  pointer-events: auto !important;
  border-radius: 13px 13px 0 0;
  display: block !important;
  min-height: 110px;
  max-height: 80vh;
}

.trr-red-sheet.trr-dragging {
  cursor: grabbing;
}

/* Problem Area */
.trr-problem-area {
  margin: 30px;
}

.trr-meta {
  font-size: 13px;
  color: #666;
  margin-bottom: 8px;
}

.trr-explanation {
  line-height: 1.8;
  white-space: pre-wrap;
  font-size: 17px;
}

.trr-q-number {
  font-weight: bold;
  font-size: 22px;
}

.trr-explanation-meta {
  font-weight: bold;
  margin-bottom: 20px;
  font-size: 20px;
}

.trr-explanation-footer {
  margin-top: 8px;
  color: #666;
  font-size: 13px;
}

/* Colors */
.trr-red,
.red {
  color: rgb(var(--trr-red-rgb));
}

.trr-blue,
.blue {
  color: rgb(0, 108, 255);
}

.trr-green,
.green {
  color: rgb(0, 168, 0);
}

.trr-purple,
.purple {
  color: rgb(128, 0, 192);
}

.trr-yellow,
.yellow {
  color: rgb(204, 153, 0);
}

.trr-gray,
.gray {
  color: rgb(128, 128, 128);
  font-weight: normal !important;
}

.trr-gray *,
.gray * {
  font-weight: normal !important;
}

/* RB Wrapped */
.trr-rb-wrapped {
  display: inline;
  white-space: normal;
  font-size: 18px;
}

.trr-rb-paren {
  color: #111;
}

.trr-rb-inner {
  display: inline;
  font-weight: bold;
}

.trr-hidden-by-red {
  visibility: hidden !important;
  opacity: 0 !important;
}

/* Search Box */
.trr-search-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  overflow: hidden;
  border: 2px solid #3d79d5;
  border-radius: 3px;
  margin-bottom: 20px;
  padding: 0;
  box-sizing: border-box;
  height: 40px;
}

.trr-search-box input[type=search] {
  flex: 1 1 auto;
  min-width: 0;
  max-width: 100%;
  width: 250px;
  height: 45px;
  padding: 5px 12px;
  border: none;
  box-sizing: border-box;
  font-size: 1em;
  outline: none;
  background: transparent;
}

.trr-search-box input[type=search]::placeholder {
  color: #777;
}

.trr-search-box #trr-searchBtn {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 45px;
  height: 45px;
  border: none;
  background-color: #3d79d5;
  cursor: pointer;
  padding: 0 0 0 4px;
  box-sizing: border-box;
  text-indent: -9999px;
  white-space: nowrap;
  overflow: hidden;
}

.trr-search-box #trr-searchBtn::after {
  content: '';
  width: 24px;
  height: 24px;
  display: block;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M18.031 16.6168L22.3137 20.8995L20.8995 22.3137L16.6168 18.031C15.0769 19.263 13.124 20 11 20C6.032 20 2 15.968 2 11C2 6.032 6.032 2 11 2C15.968 2 20 6.032 20 11C20 13.124 19.263 15.0769 18.031 16.6168ZM16.0247 15.8748C17.2475 14.6146 18 12.8956 18 11C18 7.1325 14.8675 4 11 4C7.1325 4 4 7.1325 4 11C4 14.8675 7.1325 18 11 18C12.8956 18 14.6145 17.2475 15.8748 16.0247L16.0247 15.8748Z' fill='%23fff'%3E%3C/path%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-size: 22px 22px;
}

@media(max-width:420px) {
  .trr-search-box input[type=search] {
    width: auto;
    padding: 5px 8px;
  }

  .trr-search-box {
    border-radius: 4px;
  }
}

/* Search Results */
.trr-search-results {
  margin-top: 8px;
}

.trr-result-item {
  padding: 10px 12px;
  border-radius: 6px;
  cursor: pointer;
  border: 1px solid transparent;
  margin-bottom: 8px;
}

.trr-result-item:hover {
  background: #f4f8ff;
  border-color: #e0e8ff;
}

.trr-search-mark {
  background: #fff39a;
  padding: 0 .15em;
  border-radius: 2px;
  line-height: 1;
  outline: 1px solid rgba(0, 0, 0, .04);
}

/* Find Bar */
.trr-find-bar {
  display: block;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  font-size: 14px;
  border-radius: 6px;
  background: #fff;
  border: 1px solid #777;
  min-width: 0;
  max-width: 100%;
  box-sizing: border-box;
  min-width: 220px;
}

.trr-find-keyword {
  font-weight: 700;
  color: #222;
  margin-right: 8px;
  width: calc(100% - 50px);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
  margin-right: auto;
}

.trr-find-count {
  font-weight: 700;
  color: #333;
  min-width: 80px;
  text-align: right;
}

.trr-find-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.trr-find-btn:hover {
  background: rgba(0, 0, 0, .04);
}

@media(max-width:768px) {
  .trr-find-keyword {
    width: calc(100% - 50px);
  }
}

@media(max-width:420px) {
  .trr-find-keyword {
    width: calc(100% - 50px);
    font-size: 13px;
  }
}

mark.trr-search-mark.trr-active {
  background: #ffd54f;
  outline: 2px solid rgba(0, 0, 0, .06);
  padding: 0 .08em;
  border-radius: 2px;
}

.trr-find-icon {
  width: 14px;
  height: 14px;
  display: inline-block;
  line-height: 1;
  text-align: center;
  font-size: 15px;
  color: #333;
}

/* Images from JSON - Support for figure_S, figure_M, figure_L, ImonItou_img, ImonItou_img_mon */
.trr-study img,
.trr-study picture,
.trr-study video,
.trr-study svg,
.trr-study iframe {
  max-width: 100%;
  height: auto;
  display: block;
}

/* Figure classes from JSON */
.trr-problem-list figure,
.trr-problem-list .figure_S,
.trr-problem-list .figure_M,
.trr-problem-list .figure_L {
  display: block;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  margin: 30px auto !important;
}

/* 試験別ヘッダーカラー（テーブル等で使用） */
body { --trr-th-bg: #2c5e8b; }
body.trr-mode-senmon { --trr-th-bg: #ed7a1d; }
body.trr-mode-ippan  { --trr-th-bg: #0583ce; }

/* テーブル */
.trr-problem-list table {
  border-collapse: collapse;
  margin: 24px auto;
  background: white;
  max-width: 100%;
  table-layout: auto;
  width: auto !important;
}
.trr-problem-list table.has-fixed-layout { table-layout: auto; width: auto !important; }
.trr-problem-list table th,
.trr-problem-list table td {
  padding: 8px 12px;
  border: 1px solid #ddd;
  vertical-align: middle;
}
.trr-problem-list table th {
  font-weight: bold;
  background: var(--trr-th-bg);
  color: white;
  text-align: center;
}
.trr-problem-list table .has-text-align-center { text-align: center; }
.trr-problem-list table .has-text-align-left { text-align: left; }
.trr-problem-list table .has-text-align-right { text-align: right; }
.trr-problem-list .swl-cell-bg { display: none; }
.trr-problem-list th[data-has-cell-bg='1'],
.trr-problem-list td[data-has-cell-bg='1'] {
  background-color: var(--trr-th-bg);
  color: white;
}
.trr-problem-list [data-text-color='white'] { color: white; }
.trr-problem-list .has-swl-deep-01-color { color: #1f4e72; }
.trr-problem-list .has-swl-deep-04-background-color {
  background-color: var(--trr-th-bg);
  color: white;
}
@media (min-width: 768px) {
  .trr-problem-list table th br { display: none; }
}

.trr-problem-list .figure_SSSS {
  max-width: 100px;
}

.trr-problem-list .figure_SSS {
  max-width: 150px;
}

.trr-problem-list .figure_SS {
  max-width: 240px;
}

.trr-problem-list .figure_S {
  max-width: 370px;
}

.trr-problem-list .figure_M {
  max-width: 600px;
}

.trr-problem-list .figure_L {
  max-width: 800px;
}

.trr-problem-list .figure_LL {
  max-width: 1100px;
}

/* figureを画像のサイズに合わせる（右側の余白を消す）*/
.trr-problem-list figure { width: fit-content !important; }

/* 枠線なしフィギュア */
.trr-problem-list figure.noborder .ImonItou_img,
.trr-problem-list figure.noborder .ImonItou_img_mon { border: none !important; }

/* 動画もfigureに従う */
.trr-problem-list figure video { width: 100%; height: auto; display: block; }
.trr-problem-list video { max-width: 100%; }

/* Image classes from JSON - make clickable for modal */
.trr-problem-list .ImonItou_img,
.trr-problem-list .ImonItou_img_mon {
  border: 1px solid rgb(217, 217, 217);
  cursor: zoom-in;
  max-width: 100%;
  height: auto;
}

/* Caption styling from JSON */
.trr-problem-list .fig_caption,
.trr-problem-list figcaption {
  display: block;
  text-align: center;
  font-size: 13px;
  color: #666;
  margin-top: 8px;
  line-height: 1.4;
}

.trr-study pre,
.trr-study code {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
  max-width: 100%;
}

/* ===== SWELL 風ブログカード（外部記事リンク） ===== */
.trr-explanation a.p-blogCard__title {
  display: block;
  text-decoration: none !important;
  color: inherit;
  margin: 16px 10px;
  max-width: none;
}
.trr-explanation .swell-block-postLink { display: block; }
.trr-explanation .p-blogCard {
  border: 1px solid #ddd;
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  transition: box-shadow 0.2s, transform 0.2s;
}
.trr-explanation a.p-blogCard__title:hover .p-blogCard {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  transform: translateY(-1px);
}
.trr-explanation .p-blogCard__inner {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  position: relative;
}
/* 「てるるん日記」バッジは非表示 */
.trr-explanation .p-blogCard__caption { display: none; }
.trr-explanation .p-blogCard__thumb,
.trr-explanation .c-postThumb {
  flex: 0 0 30%;
  max-width: 210px;
  min-width: 110px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  overflow: hidden;
  background: #fff;
}
.trr-explanation .p-blogCard__thumb figure,
.trr-explanation .c-postThumb__figure {
  width: 100% !important;
  max-width: none !important;
  margin: 0 !important;
  padding: 0;
}
.trr-explanation .p-blogCard__thumb img,
.trr-explanation .c-postThumb__img {
  width: 100% !important;
  height: auto !important;
  max-width: none !important;
  max-height: 120px;
  object-fit: contain;
  display: block;
  border: none !important;
  margin: 0;
}
.trr-explanation .p-blogCard__body {
  flex: 1;
  padding: 10px 14px;
  font-weight: 700;
  color: #222;
  font-size: 1em;
  line-height: 1.45;
  min-width: 0;
  word-break: break-word;
}
.trr-explanation .p-blogCard__excerpt {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 6px;
  font-weight: normal;
  font-size: 0.85em;
  color: #666;
  line-height: 1.5;
}

/* Image Modal - Enhanced with caption support */
.trr-img-modal-overlay {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, .92);
  z-index: 20000;
  padding: 20px;
  overflow: auto;
  -webkit-overflow-scrolling: touch;
}

.trr-img-modal-overlay.trr-open {
  display: flex;
}

.trr-img-modal-box {
  position: relative;
  max-width: 95vw;
  max-height: 95vh;
  width: auto;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: trr-modal-zoom-in 0.25s ease-out;
}

@keyframes trr-modal-zoom-in {
  from {
    opacity: 0;
    transform: scale(0.85);
  }

  to {
    opacity: 1;
    transform: scale(1);
  }
}

.trr-img-modal-content {
  background: transparent;
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.trr-img-modal-content img {
  max-width: 95vw;
  max-height: 80vh;
  height: auto;
  display: block;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 4px 30px rgba(0, 0, 0, 0.4);
}

/* PC表示: 画像を80vw × 80vh の範囲いっぱいまで拡大して表示 */
@media (min-width: 769px) {
  .trr-img-modal-content {
    width: 80vw;
    height: 80vh;
  }
  .trr-img-modal-content img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-width: none;
    max-height: none;
    box-shadow: none;
  }
}

.trr-img-modal-close {
  position: absolute;
  top: -70px;
  right: 0;

  width: 60px;
  height: 60px;

  border: 0;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  cursor: pointer;

  transition: background 0.15s, transform 0.15s;
}

.trr-img-modal-close::before,
.trr-img-modal-close::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 26px;
  height: 3px;
  background: #fff;
  transform-origin: center;
}

.trr-img-modal-close::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.trr-img-modal-close::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.trr-img-modal-close:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: scale(1.1);
}

.trr-img-modal-caption {
  color: #fff;
  font-size: 15px;
  text-align: center;
  padding: 14px 24px;
  max-width: 90vw;
  line-height: 1.6;
  background: rgba(0, 0, 0, 0.65);
  border-radius: 8px;
  margin-top: 16px;
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.trr-img-modal-caption:empty {
  display: none;
}

/* Modal responsive adjustments */
@media(max-width:768px) {

  .trr-hdr {
    margin-top: 50px;
  }

  .trr-img-modal-overlay {
    padding: 10px 3vw;
  }

  .trr-img-modal-content img {
    max-width: 94vw;
    max-height: 75vh;
  }

  .trr-img-modal-close {
    top: -70px;
    right: -5px;
    font-size: 28px;
    padding: 6px 12px;
  }

  .trr-img-modal-caption {
    font-size: 14px;
    padding: 10px 16px;
    max-width: 95vw;
  }
}

/* Exam Headings */
.trr-exam-heading {
  padding: 7px 5px !important;
  font-weight: bold;
  font-size: 22px;
  margin: 0;
  list-style: none !important;
  list-style-type: none !important;
}

.trr-exam-heading::marker {
  content: none !important;
  display: none !important;
}

.trr-exam-heading-ippan {
  border-bottom: 2px solid #3d79d5;
  color: #3d79d5;
}

.trr-exam-heading-senmon {
  border-bottom: 2px solid #ed7a1d;
  color: #ed7a1d;
}

.trr-exam-child {
  margin: 20px 0;
}

.trr-category-heading {
  font-weight: bold;
  margin: 15px 0 15px 5px !important;
  font-size: 17px;
  list-style: none !important;
  list-style-type: none !important;
}

.trr-category-heading::marker {
  content: none !important;
  display: none !important;
}

.trr-menu-count {
  color: #888;
  font-weight: normal;
  font-size: 0.85em;
  margin-left: 4px;
}

.trr-search-box input[type=search]::-webkit-search-cancel-button {
  cursor: pointer;
}

/* Explanation Fieldset */
.trr-explanation-fieldset {
  border: 1.6px solid #333;
  font-size: 100%;
  padding: 20px;
  margin: 0 0 3em 0;
  border-radius: 8px;
  /* fieldset は仕様上 min-width が min-content になり、中の固定幅 figure 等で枠が広がるため
     min-width: 0 で抑え、figure の max-width: 100% を効かせる（スマホで画像がはみ出す問題対策） */
  min-width: 0;
  max-width: 100%;
  overflow: hidden;
}
.trr-explanation {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: break-word;
}
/* 親幅を超える figure / img を必ず親に収める（インラインの width:Npx !important があっても効くよう !important） */
.trr-explanation figure,
.trr-explanation .p-blogCard__thumb img,
.trr-explanation img {
  max-width: 100% !important;
}

.trr-explanation-fieldset legend {
  padding: 0 10px;
  font-size: 20px;
}

.trr-ex-boxed {
  margin: 0 0 1em 0;
  border-radius: 5px;
  overflow: visible;
}

.trr-ex-boxed .trr-ex-boxed-title {
  display: inline-block;
  position: relative;
  top: 3px;
  padding: 0 .5em;
  height: 1.5em;
  line-height: 1.5em;
  background: #fff;
  font-weight: bold;
  text-align: center;
  border-radius: 5px 5px 0 0;
}

.trr-ex-boxed .trr-ex-boxed-body {
  background: rgba(255, 255, 255, 0);
  border-radius: 0 5px 5px 5px;
  padding: 20px;
  font-size: 100%;
  border: 3px solid #888;
}

.trr-ex-gray.trr-explanation-fieldset {
  border-color: #888;
}

.trr-ex-gray.trr-explanation-fieldset legend {
  color: #666;
}

.trr-ex-gray .trr-ex-boxed-title {
  color: #666;
  border: 1px solid #888;
}

.trr-ex-gray .trr-ex-boxed-body {
  border: 3px solid #888;
}

.trr-ex-lightgray.trr-explanation-fieldset {
  border-color: #bbb;
}

.trr-ex-lightgray.trr-explanation-fieldset legend {
  color: #888;
}

.trr-ex-lightgray .trr-ex-boxed-title {
  color: #888;
  border: 1px solid #bbb;
}

.trr-ex-lightgray .trr-ex-boxed-body {
  border: 3px solid #bbb;
}

/* Review Filter */
#trr-reviewFilter {
  padding: 6px 8px;
  border-radius: 6px;
  border: 1px solid #777;
  background: #fff;
  font-size: 16px;
  min-width: 150px;
  cursor: pointer;
  height: 36px;
  background-color: white;
  min-width: 190px;
}

.trr-review-label {
  margin-left: 8px;
  font-size: 19px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  vertical-align: middle;
  position: relative;
  cursor: pointer;
}

.trr-review-label input[type=checkbox] {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  margin: 0;
  padding: 0;
  left: -9999px;
}

.trr-review-label .trr-review-check {
  width: 18px;
  height: 18px;
  display: inline-block;
  background-image: none !important;
  opacity: 1 !important;
  background-color: #fff;
  border: 1.5px solid #333;
  border-radius: 4px;
  box-sizing: border-box;
  position: relative;
}

.trr-review-text {
  margin-left: 2px;
}

.trr-review-label .trr-review-check::after {
  content: "";
  position: absolute;
  inset: -7px;
  display: block;
  background-image: url("https://terurunnikki.com/wp-content/uploads/2024/12/check.png");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 23px 23px;
  opacity: 0;
  transition: opacity .12s ease;
  top: -18px;
  left: -3px;
}

.trr-review-label input[type=checkbox]:checked+.trr-review-check::after {
  opacity: 1;
}

.trr-problem[data-reviewed="1"] .trr-q-number {
  color: #ea152b;
}

.trr-q-number-row {
  display: inline-flex;
  align-items: center;
  gap: 15px;
}

/* Topbar Closed State */
.trr-content-topbar.trr-closed {
  transform: translateY(calc(-1 * var(--trr-topbar-h))) !important;
  max-height: 0 !important;
  padding-top: 0 !important;
  padding-bottom: 0 !important;
  opacity: 0 !important;
  visibility: visible !important;
  gap: 0 !important;
  box-shadow: none !important;
  border-bottom: 0 !important;
}

@media(max-width:1250px) {

  .trr-topbar-right,
  .trr-topbar-left {
    width: 100%;
    flex-wrap: wrap;
  }

  .trr-topbar-right-item,
  .trr-topbar-left button {
    flex: 1;
  }

  #trr-findBarPlaceholder {
    width: 100%;
  }
}

/* Topbar Buttons */
#trr-closeTopbarBtn {
  display: none;
  position: relative;
  z-index: 16000;
  height: 40px;
  line-height: 40px;
  background: #fff;
  color: #333;
  cursor: pointer;
  user-select: none;
  padding: 8px 0 12px 0;
  text-align: center;
  font-size: 14px;
  border: none;
  border-top: 1px solid #ddd;
  width: calc(100% + 20px);
  margin: 5px -10px 0;
}

/* 閉じるボタンの矢印（上向き＝閉じる方向） */
#trr-closeTopbarBtn::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-right: 2px solid #333;
  border-top: 2px solid #333;
  transform: rotate(-45deg);
  margin-left: 8px;
  vertical-align: middle;
  position: relative;
  top: 1px;
  margin-left: 15px;
}

#trr-openTopbarBtn {
  display: none;
  position: fixed;
  z-index: 16000;
  height: 40px;
  line-height: 40px;
  border-radius: 0 0 6px 6px;
  background: #fff;
  color: #333;
  cursor: pointer;
  user-select: none;
  padding: 0 12px;
  text-align: center;
  font-size: 14px;
  border: none;
  border-bottom: 1px solid #ddd;
  border-left: 1px solid #ddd;
  border-right: 1px solid #ddd;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

/* 開くボタンの矢印（下向き＝開く方向） */
#trr-openTopbarBtn::after {
  content: "";
  display: inline-block;
  width: 10px;
  height: 10px;
  border-right: 2px solid #333;
  border-top: 2px solid #333;
  transform: rotate(135deg);
  margin-left: 8px;
  vertical-align: middle;
  position: relative;
  top: -3px;
  margin-left: 15px;
}

.trr-topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Mobile Responsive */
@media(max-width:768px) {

  #trr-closeSidebar,
  #trr-openSidebar {
    display: none !important;
  }

  .trr-study {
    flex-direction: column;
    height: 99vh;
  }

  .trr-sidebar {
    width: 100%;
    min-width: 100%;
    height: 99vh;
  }

  .trr-sidebar-resizer {
    display: none !important;
  }

  .trr-main-area {
    position: fixed;
    top: 0;
    left: 100%;
    width: 100%;
    height: 100vh;
    z-index: 10;
  }

  .trr-show-content .trr-sidebar {
    transform: translateX(-100%);
    position: fixed;
    left: 0;
    top: 0;
    height: 100vh;
    z-index: 1;
  }

  .trr-show-content .trr-main-area {
    left: 0;
    transform: translateX(0);
  }

  #trr-back {
    display: inline-block;
  }

  .trr-content-topbar {
    padding: 8px 10px;
    border-radius: 0 0 6px 6px;
  }

  .trr-problem-list {
    font-size: 15px;
  }

  #trr-toggle-sheet {
    padding: 0 12px;
    min-width: 150px;
  }

  /* closeTopbarBtn: 768px以下でcontentTopbarが表示されている時のみ表示 */
  .trr-fullwidth-container.trr-show-content .trr-content-topbar:not(.trr-closed) #trr-closeTopbarBtn {
    display: block;
  }

  .trr-fullwidth-container:not(.trr-show-content) #trr-closeTopbarBtn,
  .trr-content-topbar.trr-closed #trr-closeTopbarBtn {
    display: none !important;
  }

  .trr-sidebar-title {
    text-align: center;
    padding: 0 10px;
  }

  .trr-sidebar-logo {
    padding: 0 10px;
  }

  .trr-site-logo {
    max-width: 180px;
  }

  /* Red sheet on mobile - fixed to viewport bottom */
  /* Note: bottom and position are controlled by JS to account for mobile browser chrome */
  .trr-red-sheet.trr-visible {
    transform: translateY(0) !important;
    opacity: 1 !important;
    visibility: visible !important;
    pointer-events: auto !important;
    display: block !important;
    z-index: 11000 !important;
    width: 100vw !important;
    left: 0 !important;
    position: sticky !important;
    border-radius: 13px 13px 0 0;
    min-height: 200px;
    max-height: 100lvh;
  }

  /* Browser-specific min-height for red sheet on mobile */
  /* Safari: 100px */
  body.trr-browser-safari .trr-red-sheet.trr-visible {
    min-height: 100px;
  }

  /* Yahoo: 100px */
  body.trr-browser-yahoo .trr-red-sheet.trr-visible {
    min-height: 100px;
  }

  /* Chrome: 200px (default) */
  body.trr-browser-chrome .trr-red-sheet.trr-visible {
    min-height: 200px;
  }

  /* Other browsers: 200px */
  body.trr-browser-other .trr-red-sheet.trr-visible {
    min-height: 200px;
  }

  /* Smooth touch scrolling for red sheet resize */
  .trr-red-sheet {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    /* GPUアクセラレーションを有効化してスムーズな描画を実現 */
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
  }

  .trr-red-sheet.trr-dragging {
    /* ドラッグ中はすべてのトランジションを無効化して即座に追従 */
    transition: none !important;
    will-change: height;
  }

  .trr-red-sheet:not(.trr-dragging) {
    /* ドラッグしていない時のみトランジションを適用（表示/非表示のアニメーション用） */
    transition: transform 0.28s cubic-bezier(.2, .9, .2, 1), opacity 0.12s;
  }

  /* Ensure main area scrollbar is above closeTopbarBtn */
  .trr-main-area {
    z-index: 15001;
  }

  /* Hide WordPress header when showing content on mobile */
  body.trr-hide-wp-header #header,
  body.trr-hide-wp-header .l-header,
  body.trr-hide-wp-header header#header,
  body.trr-hide-wp-header .header,
  body.trr-hide-wp-header [id*="header"],
  body.trr-hide-wp-header .site-header {
    display: none !important;
    visibility: hidden !important;
    height: 0 !important;
    overflow: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
  }

  #trr-back,
  #trr-backToSearch,
  #trr-clearSearchResults,
  #trr-toggle-sheet,
  #trr-reviewFilter,
  #trr-closeTopbarBtn,
  #trr-openTopbarBtn,
  .trr-find-bar {
    height: 50px;
    font-size: 16px;
  }

  .trr-sub-item {
    padding: 10px 12px !important;
    font-size: 18px;
  }

  .trr-category-heading {
    font-size: 19px;
  }

  .trr-category-heading {
    margin: 25px 0 25px 5px !important;
  }

  #trr-menu {
    padding: 16px 14px 150px;
  }

  .trr-sidebar-title {
    font-size: min(1.6rem, 20px);
  }
}

/* Global style to hide WordPress header when needed */
body.trr-hide-wp-header #header,
body.trr-hide-wp-header .l-header,
body.trr-hide-wp-header header#header,
body.trr-hide-wp-header .header,
body.trr-hide-wp-header [id*="header"],
body.trr-hide-wp-header .site-header {
  display: none !important;
  visibility: hidden !important;
  height: 0 !important;
  overflow: hidden !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

/* Title styling */
#trr-title {
  font-size: 24px;
  margin: 0;
  line-height: 1.4;
}

/* Ensure images in modal are not clickable for zoom again */
.trr-img-modal-overlay.trr-open img {
  cursor: default;
}

/* 要復習フィルタで該当0件のときに表示する案内 */
.trr-filter-empty-msg {
  margin: 24px 0;
  padding: 16px 20px;
  color: #666;
  font-size: 16px;
  background: #f7f7f7;
  border-radius: 8px;
  text-align: center;
}

/* ===== スマホで「問題文の画像」が右にはみ出す問題の対策 ===== */
/* 問題文の図(.trr-problem 直下の figure)は width:fit-content + 固定px幅
   (figure_M=600px 等)で指定されている。iOS Safari では fit-content が画像本来の
   幅(max-content)として扱われることがあり、画面幅を超えて右にはみ出す。
   スマホ幅では figure をコンテナ幅に収め、画像も親幅いっぱいまでに制限する。
   ※ 解説欄(.trr-explanation)の画像には同等の対策が既に入っている(上部参照)。
   ※ .trr-problem 直下の figure のみを対象にし、解説欄の画像には影響しない。 */
@media (max-width: 768px) {
  .trr-problem > figure {
    width: auto !important;
    max-width: 100% !important;
  }
  .trr-problem > figure img {
    max-width: 100% !important;
    height: auto !important;
    margin-left: auto !important;
    margin-right: auto !important;
  }
}