:root {
  --split: 54%;
  /* 答案エリアのフォントサイズ（ズーム機能用） */
  --answer-font-size: 16px;
  --answer-line-height: 2; /* font-sizeの2倍 */
}

/* INFO: 画面全体のズーム機能で使用するラッパー要素
   transform: scale() を適用し、zoom プロパティの代わりに使用
   Safari での座標ずれ問題を回避するため */
.zoom-wrapper {
  transform-origin: top left;
  width: 100%;
  min-height: 100vh;
}

@font-face {
  font-family: 'M PLUS 1 Code';
  src: url('./fonts/MPLUS1Code-Regular.ttf') format('truetype');
  font-weight: 400;
  font-style: normal;
  font-display: block;
}

/* --------------------------------------------------
   共通設定（前回から変更なし）
-------------------------------------------------- */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: "Noto Sans JP", sans-serif;
  color: #666666;
}

/* ===== 共通ボタン ===== */
.btn,
.menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 13px;
  border: 1px solid #c2c5cc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

/* ======= 既存ページ用スタイル群（省略せず残存） ======= */
/* ここには以前作成したページのスタイルが続きます … */

/* --------------------------------------------------
   ▼▼▼ ここから今回追記分（メニュー & モーダル） ▼▼▼
-------------------------------------------------- */

/* ===== ナビゲーションバー ===== */
.navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 56px;
  border-bottom: 1px solid #e1e3e8;
  padding: 0 24px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 20px;
  font-weight: 700;
}

.logo img {
  height: 34px;
}

.logo span {
  padding-left: 20px;
}

.guide-link {
  font-size: 15px;
  color: #1a1d21;
  text-decoration: none;
  margin-right: 20px;
}

.guide-link:hover {
  text-decoration: underline;
}

.exit-btn {
  padding: 6px 22px;
  font-size: 15px;
  border: none;
  border-radius: 28px;
  background: #1554d0;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.exit-btn:hover {
  background: #006ce3;
}

/* ===== メニュー本体 ===== */
.menu-container {
  width: 100%;
  height: calc(100% - 56px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 20px;
  padding-top: 80px;
}

.menu-btn {
  width: 480px;
  max-width: 90%;
  padding: 16px 10px;
  font-size: 16px;
  border-radius: 28px;
  border: none;
  background: #e9eef5;
  color: #1a1d21;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  text-decoration: none;
  /* 下線を消す */
}

.menu-btn:hover {
  background: #dbe4ee;
}

.menu-btn.primary {
  background: #1554d0;
  color: #fff;
}

.menu-btn.primary:hover {
  background: #006ce3;
}

/* --------------------------------------------------
   モーダル（司法試験過去問）
-------------------------------------------------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-overlay.active {
  display: flex;
}

.modal-dialog {
  width: 90%;
  max-width: 1050px;
  background: #fff;
  border-radius: 6px;
  padding: 32px 40px;
  color: #1a1d21;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.modal-header h2 {
  font-size: 22px;
  font-weight: 700;
}

.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #666;
}

.modal-close:hover {
  color: #000;
}

.modal-yobi-close {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  color: #666;
}

.modal-yobi-close:hover {
  color: #000;
}

hr {
  border: none;
  border-top: 1px solid #e1e3e8;
  margin: 24px 0;
}

.modal-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.modal-yobi-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
}

.modal-column h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 12px;
}

.qtable {
  width: 100%;
  border-collapse: collapse;
}

.qtable td {
  padding: 2px 0px;
  font-size: 15px;
}

.qtable td:first-child {
  color: #1a1d21;
  font-weight: 500;
  white-space: nowrap;
}

.qtable a {
  color: #1554d0;
  text-decoration: none;
  font-weight: 500;
}

.qtable a i {
  font-size: 10px;
  margin-left: 3px;
}

.qtable a:hover {
  text-decoration: underline;
}

/* ===== 基本設定 ===== */

html,
body {
  height: 100%;
  overflow: hidden;
  font-family: 'Noto Sans JP', sans-serif;
  color: #666666;
  touch-action: pan-x pan-y;
  overscroll-behavior: auto;
}

/* ===== ヘッダー ===== */
.header-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f5f6f8;
  padding: 8px 14px;
  border-bottom: 1px solid #d0d3d9;
}

.page-title {
  font-weight: 600;
}

.header-btns {
  display: flex;
  gap: 6px;
}

.btn {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 13px;
  border: 1px solid #c2c5cc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.btn.primary {
  border-color: #1554d0;
}

.btn:is(:hover, .is-active) {
  background: #1554d0;
  color: #fff;
}

/* パネル表示/非表示切り替えボタン */
.panel-toggles {
  display: flex;
  gap: 4px;
  margin-right: 12px;
  padding-right: 12px;
  border-right: 1px solid #c2c5cc;
}

.panel-toggle {
  min-width: 70px;
  justify-content: center;
}

/* active状態：パネル表示中（他のボタンと統一） */
.panel-toggle.active {
  background: #fff;
  color: inherit;
  border-color: #c2c5cc;
}

.panel-toggle.active:hover {
  background: #1554d0;
  color: #fff;
  border-color: #1554d0;
}

/* 非active状態：パネル非表示（グレーで区別） */
.panel-toggle:not(.active) {
  background: #e8e8e8;
  color: #999;
  border-color: #ccc;
}

.panel-toggle:not(.active):hover {
  background: #d0d0d0;
  color: #666;
}

/* 入替えボタン */
.panel-swap {
  min-width: 70px;
  justify-content: center;
  margin-left: 4px;
}

.panel-swap:disabled {
  background: #e8e8e8;
  color: #aaa;
  border-color: #ccc;
  cursor: not-allowed;
  opacity: 0.6;
}

.panel-swap:disabled:hover {
  background: #e8e8e8;
  color: #aaa;
}

.btn:disabled,
.btn.is-offline {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn:disabled:hover,
.btn.is-offline:hover {
  background: inherit;
  color: inherit;
}

/* ===== ナビゲーションバー ===== */

.guide-link:hover {
  text-decoration: underline;
}

.exit-btn {
  padding: 6px 22px;
  font-size: 15px;
  border: none;
  border-radius: 28px;
  background: #d32f2f;
  color: #fff;
  cursor: pointer;
  transition: background 0.15s;
}

.exit-btn:hover {
  background: #d32f2f;
}

/* ===== メインエリア ===== */
.main {
  display: flex;
  height: calc(100% - 72px);
  /* INFO: 背景色を設定しないと、子要素間の隙間から後ろの要素が透けて見える */
  background-color: #fff;
  /* INFO: メモエリア（position: absolute）の基準点とするため */
  position: relative;

  min-height: 0;
}

/* === 左ペイン === */
.editor-area {
  display: flex;
  width: var(--split);
  height: 100%;
  border-right: 1px solid #d0d3d9;
  /* INFO: 背景色を設定しないと、border-rightの内側に1pxの隙間ができ、
     後ろの要素が透けて見える問題が発生する */
  background-color: #e3e3e3;
  /* INFO: z-indexを設定して右ペインより前面に配置し、
     隙間から右ペインの内容が見えないようにする */
  position: relative;
  z-index: 1;

  min-height: 0;
}

.tool-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #eff1f5;
  border-right: 1px solid #d0d3d9;
  padding: 6px 4px;
  gap: 1px;
  width: 42px;

  position: relative;
}

.tool {
  width: 32px;
  height: 32px;
  font-size: 16px;
  background: #fff;
  border: 1px solid #c2c5cc;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s, color 0.2s;
}

.tool:hover,
.tool.is-active {
  background: #3a8dff;
  color: #fff;
}

.tool-separator {
  width: 60%;
  border: none;
  border-top: 1px solid #ccc;
  margin: 6px 0;
}

.tool.color {
  border: 2px solid #ccc;
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

.tool.color.orange {
  background: orange;
}

.tool.color.yellow {
  background: gold;
}

.tool.color.green {
  background: limegreen;
}

.tool.color.blue {
  background: dodgerblue;
}

.tool.color.red {
  background: crimson;
}

.tool-black i {
  color: black;
}

.tool-red i {
  color: #f54c3f;
}

.tool-blue i {
  color: #59aef5;
}

.tool-green i {
  color: #86FC04;
}

.tool-yellow i {
  color: #f8fc04;
}

.tool-orange i {
  color: #f7b34d;
}

/* INFO: スクロール末尾で装飾を選択・色変更したときに、ポップアップ／色ドロップダウンを
   手動スクロールで画面内に収められるよう、.pdf-view 末尾へ動的に積む下スクロール余地用の spacer。
   高さは DecorationSelectionController.updateBottomSpacer がインラインで設定する（通常時は 0）。 */
.pdf-bottom-spacer {
  width: 100%;
  height: 0;
  pointer-events: none;
}

.pdf-view {
  flex: 1;
  overflow: auto;
  display: block;
  position: relative;
  /* ✅ 高さを固定しない */
  max-height: none;
  /* ✅ 上限も外す */

  min-height: 0;
  overflow-y: auto;
  flex: 1 1 auto;
  -webkit-overflow-scrolling: touch;
}

/* === 右ペイン === */
.right-pane {
  display: flex;
  flex-direction: column;
  width: calc(100% - var(--split));
  height: 100%;
  /* INFO: 背景色を設定しないと、ディバイダ周辺の隙間から
     後ろの要素が透けて見える問題が発生する（.editor-areaと同様） */
  background-color: #fff;
  /* INFO: 内容が左側にはみ出して隙間から見えないようにする */
  overflow: hidden;
  /* INFO: divider-horizontalの含有ブロック（position:absoluteの基準）にするため設定。
     zoom-wrapperのtransformを含有ブロックにすると入替え後に位置ズレが発生する */
  position: relative;

  min-height: 0;
}

/* --- 条文エリア --- */
.article-area {
  display: flex;
  border-bottom: 1px solid #d0d3d9;

  height: 25%;

  flex: 0 0 auto;
}

.article-list {
  width: 35%;
  overflow-y: auto;
  border-right: 1px solid #d0d3d9;
  max-height: 100%;
}

.article-list .item {
  padding: 8px 10px;
  font-size: 14px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}

.article-list .item.is-selected,
.article-list .item:hover {
  background: #e9efff;
  font-weight: 600;
}

.article-detail {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  padding-left: 36px; /* ブックマークボタン用のスペースを確保 */
  font-size: 14px;
  line-height: 1.6;
  font-style: normal;
}

.article-detail li {
  list-style: none;
}

.article {
  margin-bottom: 15px;
}

._div_ArticleCaption {
  font-style: normal !important;
  font-weight: normal !important;
}

.article-detail div em span {
  font-style: normal !important;
}

.articleheading {
  font-style: normal !important;
}

/* ブックマークボタンを正しく配置するためにインラインブロックに変更 */
.article-detail em.articleheading[id] {
  display: inline-block;
}

.portiontitle {
  font-style: normal !important;
}

.supplprovision-label {
  font-style: normal !important;
}

.paragraphheading {
  font-style: normal !important;
}

.paragraph .sentence {
  display: block;
  margin: 0 0 0.5em 0;
  /* 下に余白を付けたい場合 */
}

.articletitle {
  font-weight: bold;
}

.paragraphtitle {
  font-weight: bold;
}

.itemtitle {
  font-weight: bold;
}

.item {
  display: flex;
  /* 横並びにする */
  align-items: flex-start;
  /* 上揃えにする */
}

.sentence {
  margin: 0;
  /* pタグのデフォルト余白を消す */
}

.paragraph .istitle {
  align-items: flex-start;
  /* 上揃え */
  flex-wrap: wrap;
  /* 2行目以降を折り返せるように */
}

.istitle-block {
  display: block;
}

.istitle-block .column {
  display: inline;
}

.paragraph .istitle .paragraphtitle {
  white-space: nowrap;
  /* 「第5条」の途中改行を防ぐ */
}

.paragraph .istitle .sentence {
  display: inline;
  margin: 0;
}

.paragraph .istitle .sentence:first-of-type {
  display: inline;
  /* 最初の <p> だけ横並びで続ける */
}

.Article {
  margin-bottom: 15px;
}

.paragraphtitle {
  flex: 0 0 auto;
  /* 幅固定 */
}

.sentence {
  margin: 0;
  /* pタグのデフォルト余白を消す */
  flex: 1;
  /* 残り幅で折り返し可能にする */
}

.mb-15 {
  margin-bottom: 15px;
}

.d-inline {
  display: inline;
}

.jftc_table .table01 {
  max-width: 100%;
  margin-bottom: 0.5em;
  table-layout: auto;
  width: 100%;
  margin-top: 30px;
  border-collapse: collapse;
}

.jftc_table .table01 .center {
  text-align: center;
  padding: 10px 10px 10px;
  vertical-align: middle;
  background: #e5eff7;
  border-top: 1px solid #909090;
  border-bottom: 1px solid #909090;
  border-right: 1px solid #909090;
  border-left: 1px solid #909090;
  font-size: 87.5%;
}

.jftc_table .table01 td {
  padding: 10px 10px 10px;
  vertical-align: middle;
  border-bottom: 1px solid #909090;
  border-right: 1px solid #909090;
  font-size: 87.5%;
}

.egov-table .tablestruct {
  border-collapse: collapse;
  width: 100%;
}

.egov-table .tablestruct .egov-table-th {
  padding: 8px;
  font-weight: normal;
}

.egov-table .tablestruct td {
  padding: 8px;
}

.egov-table .tablestruct .egov-table-tr {
  vertical-align: top;
}

.tablestruct-title {
  font-style: normal;
}

.clause {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  margin-bottom: 12px;
}

.bookmark {
  position: absolute;
  left: -34px;
  top: 0;
  width: 24px;
  height: 24px;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 18px;
  color: #666;
}

.bookmark:hover,
.bookmark.is-active {
  color: #f0b400;
}

/* --- 答案エリア --- */
.answer-area {
  display: flex;
  flex-direction: column;

  flex: 1 1 auto;
  min-height: 0;
}

.answer-header {
  background: #1554d0;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  font-size: 14px;
}

.search-btn {
  display: flex;
  align-items: center;
  gap: 4px;
  background: #1554d0;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 2px 8px;
  font-size: 13px;
  cursor: pointer;
}

textarea {
  flex: 1;
  border: none;
  resize: none;
  padding: 12px;
  font-size: 15px;
  line-height: 1.6;
  outline: none;
}

/* ブックマーク */
.bookmark-toggle {
  margin-top: 2px;
  cursor: pointer;
}

.bookmark-toggle input {
  display: none;
}

.bookmark-toggle i {
  font-size: 18px;
  color: #bbb;
  transition: color 0.2s;
}

.bookmark-toggle input:checked+i {
  color: #f0b400;
}

/* テキスト */
.clause p {
  margin: 0;
  line-height: 1.6;
}

/* ===== 残り時間表示 ===== */
.time-display {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  margin-left: 10px;
}

.time-display .label {
  color: #666666;
}

.time-display .time {
  color: red;
  font-weight: bold;
  font-family: 'Courier New', monospace;
  font-size: 20px;
}

/* 入力モード切替ボタン（2連） */
.input-toggle {
  display: inline-flex;
  border: 1px solid #ccc;
  border-radius: 6px;
  overflow: hidden;
}

.toggle-btn {
  font-size: 13px;
  line-height: 1.4;
  padding: 6px 12px;
  border: none;
  background: #fff;
  color: #333;
  cursor: pointer;
  min-width: 64px;
  text-align: center;
  white-space: nowrap;
}

.toggle-btn.active {
  background-color: #1756d3;
  color: #fff;
  font-weight: bold;
}

.toggle-btn:not(.active):hover {
  background-color: #1554d0;
  color: #fff;
}

.input-btn {
  font-size: 13px;
  line-height: 1.4;
  padding: 6px 12px;
  border: none;
  background: #fff;
  color: #333;
  cursor: pointer;
  min-width: 64px;
  text-align: center;
  white-space: nowrap;
}

.input-btn:not(:last-child) {
  border-right: 1px solid #ccc;
}

.input-btn.active {
  background: #1554d0;
  color: #fff;
  font-weight: bold;
}

/* カテゴリアコーディオン */
details.accordion {
  border-bottom: 1px solid #eee;
  font-size: 14px;
}

/* カテゴリ名 */
details.accordion summary {
  cursor: pointer;
  font-weight: bold;
  padding: 10px 12px;
  background: #f0f4f8;
  border-top: 1px solid #ddd;
  list-style: none;
}

details.accordion[open] summary {
  background: #e3eefc;
}

details.accordion summary::-webkit-details-marker {
  display: none;
}

/* 法令リスト本体 */
.accordion-body {
  display: flex;
  flex-direction: column;
  background: #fff;
}

/* 中身の法令 */
.accordion-body .item {
  padding: 6px 20px;
  border-top: 1px solid #f3f3f3;
  color: #333;
  font-weight: normal;
  background: #fff;
}

.accordion-body .item:hover {
  background: #f0f6ff;
}

.accordion-body .no-item {
  padding: 6px 20px;
  border-top: 1px solid #f3f3f3;
  color: #333;
  font-weight: normal;
  background: #eee;
}

.accordion-body .no-item:hover {
  background: #f0f6ff;
}

/* ===== 目次上部の操作エリア ===== */
/* ブラウザのズームに応じてフォントサイズ・アイコンサイズを自動調整 */
.toc-header {
  --header-font-size: clamp(9px, 1.2vw, 13px);
  --header-icon-size: clamp(7px, 0.9vw, 10px);

  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 6px;
  padding: 4px 8px;
  background: #f9fafb;
  border-bottom: 1px solid #d0d3d9;
}

/* ヘッダー内のボタンサイズを答案エリアの検索ボタンと統一（28px） */
.toc-header button,
.toc-header .btn {
  box-sizing: border-box;
  height: 28px;
  padding: 6px 12px;
  font-size: var(--header-font-size);
  font-weight: normal;
  white-space: nowrap;
  flex-shrink: 0;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

/* アイコン付きボタン共通（テキスト上・アイコン下の2行構成を28pxに収める） */
.toc-header .icon-btn {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0 12px;
  line-height: 1;
  overflow: hidden;
}

.toc-header .icon-btn i,
.toc-header .icon-btn svg {
  font-size: var(--header-icon-size);
  width: var(--header-icon-size);
  height: var(--header-icon-size);
}

.toc-search {
  box-sizing: border-box;
  height: 28px;
  width: 15%;
  min-width: 70px;
  padding: 4px 8px;
  font-size: var(--header-font-size);
  border: 1px solid #ccc;
  border-radius: 6px;
}

.toc-tabs {
  display: flex;
  border: 1px solid #ccc;
  border-radius: 6px;
  overflow: hidden;
}

.toc-tab {
  padding: 6px 12px;
  font-size: 13px;
  background: #fff;
  border: none;
  cursor: pointer;
  color: #333;
}

.toc-no-result {
  margin: 10px;
}

/* ===== 法令検索ボタン ===== */
#lawCount {
  margin-left: auto;
  font-size: 13px;
}

/* ===== トグルボタン（独立した「目次」「付箋一覧」） ===== */
.toc-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1554d0;
  color: #fff;
}

.toc-tab:not(:last-child) {
  border-right: 1px solid #ccc;
}

.toc-tab.is-active {
  background: #1554d0;
  color: #fff;
  font-weight: bold;
}

.toc-search-btn {
  background: #1554d0;
  color: #fff;
  border: none;
}

.toc-search-btn:hover {
  background: #0d3fa0;
}

/* ===== 条文検索フォーム ===== */
.article-search-form {
  display: flex;
  align-items: center;
  gap: 2px;
}

.article-search-label {
  font-size: var(--header-font-size);
  color: #333;
  white-space: nowrap;
}

.article-num-input {
  box-sizing: border-box;
  height: 28px;
  width: 36px;
  padding: 4px 2px;
  font-size: var(--header-font-size);
  text-align: center;
  border: 1px solid #ccc;
  border-radius: 4px;
}

/* スピンボタン（上下矢印）を非表示 */
.article-num-input::-webkit-outer-spin-button,
.article-num-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.article-num-input[type="number"] {
  -moz-appearance: textfield;
}

.toc-header .article-search-btn {
  background: #fff;
  color: #333;
  border: 1px solid #c2c5cc;
  opacity: 0.5;
}

.toc-header .article-search-btn.is-active {
  background: #1554d0;
  color: #fff;
  border: none;
  opacity: 1;
}

.toc-header .article-search-btn.is-active:hover {
  background: #0d3fa0;
}

/* 条文検索ハイライト（一時的な強調表示） */
.article-search-highlight {
  background-color: #fff3cd;
  transition: background-color 0.3s ease;
}

.lined-paper {
  overflow-x: hidden;
  overflow-wrap: normal;
  /* ズーム機能用にCSS変数を使用 */
  font-size: var(--answer-font-size);
  line-height: var(--answer-line-height);
  background-attachment: local;
  outline: none;
  overflow-y: auto;
  scrollbar-gutter: stable;  /* スクロールバー分のスペースを常に確保し、ズーム縮小時の改行を防止 */
  white-space: pre-wrap;
  /* 手動改行は保持、自然改行を許可 */
  word-break: break-word;
  font-family: 'Source Han Serif JP', 'Noto Serif CJK JP', serif;
  /* 既存のfont-feature-settings等はそのまま */
  font-variant-east-asian: full-width;
  font-feature-settings:
    "fwid" 1,   /* 全角幅を強制（半角文字も全角扱いに） */
    "pwid" 0,   /* 比例幅を無効化 */
    "palt" 0,
    "halt" 0,
    "pkna" 0,
    "kern" 0;   /* カーニング無効化で文字間の揺れを防止 */
  font-variant-numeric: tabular-nums;
  font-kerning: none;
  /* 全角幅の安定化（保険） */

  /* 高さはJavaScriptで動的に設定される */
  height: 100%;
  box-sizing: content-box;
  /* 枠線を幅計算に含めない */
  position: relative;
  margin-right: 5px;
  background-clip: content-box;
  background-origin: content-box;
  border-right: 1px solid #ddd;
  letter-spacing: normal;

  /* 30 全角 + 誤差補正 */
  width: 30em;
  min-width: 30em;
  max-width: 30em;
  border: 2px solid #ddd;

  /* 罫線は背景で描画（フォントサイズに連動） */
  /* INFO: line-height-pxはfont-size × line-height（例: 16px × 2 = 32px） */
  --line-height-px: calc(var(--answer-font-size) * var(--answer-line-height));
  background-image: repeating-linear-gradient(to bottom,
      transparent 0,
      transparent calc(var(--line-height-px) - 1px),
      #e5e5e5 calc(var(--line-height-px) - 1px),
      #e5e5e5 var(--line-height-px));
  background-size: 100% var(--line-height-px);

  scrollbar-width: thin;
  scrollbar-color: #c2c5cc transparent;
}

/* Chrome / Edge 用: .lined-paper のスクロールバーを thin 相当にする */
.lined-paper::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.lined-paper::-webkit-scrollbar-track {
  background: transparent;
}

.lined-paper::-webkit-scrollbar-thumb {
  background-color: #c2c5cc;
  border-radius: 4px;
}

/* 答案エリア全体のスクロールバーも thin 相当に統一 */
.answer-area .tab-content-container {
  scrollbar-width: thin;
  scrollbar-color: #c2c5cc transparent;
}

.answer-area .tab-content-container::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.answer-area .tab-content-container::-webkit-scrollbar-track {
  background: transparent;
}

.answer-area .tab-content-container::-webkit-scrollbar-thumb {
  background-color: #c2c5cc;
  border-radius: 4px;
}


@supports (width: 1ic) {
  .lined-paper {
    /* INFO: 30文字 + 余裕。ズーム縮小時のサブピクセル丸め誤差を吸収 */
    width: 31ic;
    min-width: 31ic;
    max-width: 31ic;
  }
}

@supports (width: 1ic) {
  html.sb-classic .lined-paper {
    width: calc(31ic + 1ic);
    min-width: calc(31ic + 1ic);
    max-width: calc(31ic + 1ic);
  }
}

.btn.is-active {
  background-color: #e0e0e0;
  color: #000;
}

#pauseBtn {
  width: 90px;
  /* 横幅を固定 */
  display: flex;
  /* 中央寄せ用 */
  align-items: center;
  /* 上下中央 */
  justify-content: center;
  /* 左右中央 */
  gap: 4px;
  /* アイコンと文字の間に少しスペース */
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: none;
  /* 中央揃えに必要 */
  justify-content: center;
  /* 横方向中央 */
  align-items: center;
  /* 縦方向中央 */
  z-index: 1000;
}

.modal {
  background: #fff;
  padding: 24px;
  border-radius: 8px;
  width: 400px;
  max-width: 90%;
  text-align: center;
  position: relative;
}

.modal-title {
  font-size: 20px;
  font-weight: bold;
  margin-bottom: 12px;
}

.modal-text {
  font-size: 16px;
  margin-bottom: 24px;
}

.modal-actions {
  display: flex;
  justify-content: space-around;
}

.modal-actions .btn {
  padding: 12px 28px;
  /* 少し大きめに */
  border-radius: 999px;
  /* 角丸（最大） */
  font-size: 16px;
  /* 少し大きく */
  font-weight: bold;
  border: none;
  cursor: pointer;
  transition: background-color 0.2s;
}

.modal-actions .btn.danger {
  background-color: #d32f2f;
  color: white;
}

.modal-actions .btn.cancel {
  background-color: #eee;
  color: #333;
}

.modal-actions .btn.primary {
  background-color: #1554d0;
  color: white;
}

.close-modal {
  position: absolute;
  top: 8px;
  right: 12px;
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
}

/* ===== 検索モーダル専用スタイル ===== */
.search-modal-box {
  display: none;
  position: absolute;
  top: 20%;
  left: var(--split);
  transform: translateX(-50%);
  background: #fff;
  border: 1px solid #ccc;
  border-radius: 8px;
  z-index: 1000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.search-modal-inner {
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 280px;
}

.search-modal-input {
  padding: 8px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 4px;
}

.search-modal-btn {
  padding: 8px;
  font-size: 14px;
  background: #1554d0;
  color: #fff;
  border: none;
  border-radius: 6px;
  cursor: pointer;
}

.search-modal-btn:hover {
  background: #003cb3;
}

.search-close-btn {
  position: absolute;
  top: 4px;
  right: 8px;
  font-size: 20px;
  border: none;
  background: none;
  color: #999;
  cursor: pointer;
}

.search-close-btn:hover {
  color: #333;
}

/* ハイライト色 */
mark {
  background-color: yellow;
  padding: 0;
}

/* === PDF.js テキストレイヤー === */
.textLayer {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  color: transparent;
  user-select: text;
  -webkit-user-select: text;
  pointer-events: auto;
  z-index: 12;
}

.textLayer span {
  transform-origin: 0 0;
  white-space: pre;
  line-height: 1;
  font-size: 1em;
}

.page {
  position: relative;
}

/* 最終ページは次のページがないため余白不要 */
.page:last-child {
  margin-bottom: 0 !important;
}

.page canvas {
  display: block;
  max-width: none;
  height: auto;
  z-index: 1;
}

#divider-vertical {
  width: 5px;
  background: transparent;
  cursor: ew-resize;
  position: absolute;
  top: 72px;
  bottom: 0;
  left: var(--split);
  z-index: 100;
}

#divider-horizontal {
  height: 5px;
  background: transparent;
  cursor: ns-resize;
  position: absolute;
  left: 75%;
  top: 70%;
  width: 50%;
  transform: translateX(-50%);
  z-index: 100;
}

.tab-container {
  display: flex;
  align-items: center;
  border-top: 1px solid #ccc;
  background: #f9f9f9;
  padding: 4px;
  position: relative;
}

.tab-list-wrapper {
  overflow-x: auto;
  flex: 1;
}

.tab-list {
  display: flex;
  list-style: none;
  padding: 0;
  margin: 0;
}

.tab-item {
  padding: 6px 12px;
  font-size: 13px;
  white-space: nowrap;
  cursor: pointer;
  background: #ccc;
  margin-right: 4px;
  border-radius: 4px;
  color: #666;
}

.tab-item.active {
  background: #1554d0;
  color: white;
}

.tab-scroll {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 0 8px;
}

.tab-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  padding: 4px 8px;
  background: #f1f1f1;
  border-bottom: 1px solid #ccc;
}

/* タブ切り替えの中身用クラス */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

.select-question-btn {
  background-color: #eee;
  border: 1px solid #ccc;
  padding: 6px 10px;
  margin: 4px;
  cursor: pointer;
  border-radius: 5px;
}

.select-question-btn.selected {
  background-color: #007bff;
  color: #fff;
}

.selected-questions-container {
  margin: 10px 0;
  padding: 10px;
  background: #f2f2f2;
  border: 1px dashed #ccc;
  border-radius: 5px;
  font-size: 14px;
  width: 460px;

  /* スクロール可能にするための追加プロパティ */
  max-height: 190px;  /* 最大高さを設定（お好みで調整可能） */
  overflow-y: auto;   /* 縦スクロールを有効化 */
  overflow-x: hidden; /* 横スクロールは無効化 */
}

.selected-questions-container span {
  display: block;
  margin-bottom: 4px;
}

.selected-questions-container {
  display: none;
}

/* ✅ モーダル高さを常にブラウザの80%にし、スクロール可能に */
.modal-dialog {
  max-height: 80vh;
  overflow-y: auto;
}

.pen-layer {
  position: absolute;
  z-index: 20;
  pointer-events: auto;
}

.textLayer {
  z-index: 12;
  position: absolute;
}

/* Active state visuals for tool buttons */
.tool.active {
  box-shadow: 0 0 0 2px currentColor inset;
  background-color: #bbb;
}

/* === マーカー/ペン 共通ポップオーバー（水平トグル＋色選択） === */
/* INFO: 付箋のポップオーバーと共存するため、.tool-popover という独立クラスを使用 */
.tool-popover {
  position: absolute;
  display: none;
  flex-direction: column;
  background-color: #ffffff;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.18);
  padding: 6px 0;
  min-width: 180px;
  z-index: 120;
}

.tool-popover.show {
  display: flex;
}

/* 水平ON/OFFトグル行 */
.tool-popover-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid #eeeeee;
  background-color: #f5f5f5;
  font-size: 14px;
  color: #333333;
}

.tool-popover-toggle-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  color: #555555;
  font-size: 16px;
}

.tool-popover-toggle-label {
  flex: 1;
  user-select: none;
}

/* iOS風トグルスイッチ */
.tool-popover-switch {
  position: relative;
  display: inline-block;
  width: 40px;
  height: 22px;
  flex-shrink: 0;
}

.tool-popover-switch-input {
  opacity: 0;
  width: 0;
  height: 0;
}

.tool-popover-switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #cccccc;
  border-radius: 22px;
  transition: background-color 0.2s;
}

.tool-popover-switch-slider::before {
  content: "";
  position: absolute;
  height: 18px;
  width: 18px;
  left: 2px;
  top: 2px;
  background-color: #ffffff;
  border-radius: 50%;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
  transition: transform 0.2s;
}

.tool-popover-switch-input:checked + .tool-popover-switch-slider {
  background-color: #2196f3;
}

.tool-popover-switch-input:checked + .tool-popover-switch-slider::before {
  transform: translateX(18px);
}

/* 色選択行 */
.tool-popover-color-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 16px;
  background: none;
  border: none;
  width: 100%;
  cursor: pointer;
  font-size: 14px;
  color: #333333;
  text-align: left;
}

.tool-popover-color-row:hover {
  background-color: #f0f0f0;
}

.tool-popover-color-row.active {
  background-color: #e8e8e8;
}

.tool-popover-color-dot {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.08);
}

.tool-popover-color-label {
  flex: 1;
  user-select: none;
}

.pdf-view, #pdf-container {
  background-color: #e3e3e3ff;
}

/* PDFズーム縮小時に左右中央揃えにする */
#pdf-container {
  display: flex;
  flex-direction: column;
  /* INFO: align-items: center は拡大時に左スクロールができなくなるため使用しない */
}

/* 各ページを中央揃え（拡大時も左右スクロール可能） */
#pdf-container .page {
  margin-left: auto;
  margin-right: auto;
}

/* INFO: 見開き2ページ表示モード(#301)。
   .pdf-container--spread が #pdf-container に付与されている間は CSS Grid で2列固定にする。
   既存の display:flex は上書きされる。
   grid-template-columns は auto auto にして各列がページの実コンテンツ幅にぴったり追従するようにし、
   justify-content: center で行全体を中央寄せする。これにより左右ページの間は CSS の gap(12px) のみとなり、
   1fr 1fr で見られた「セル内中央寄せによる左右ページ間の余白」を発生させない。 */
#pdf-container.pdf-container--spread {
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  gap: 12px;
}

/* INFO: 見開きモードで右側の相方を持たない最終ページ(奇数ページ終端、複数PDF連続表示時の各PDF末尾)を
   2列分使って中央揃えで配置する。クラスの付与・剥奪は PdfController._applySpreadLastAloneClass() が担当。
   単一ページモード時はこのクラスが付いていても親の display:flex なので無視される(grid-column は効かない)。 */
.pdf-container--spread .page--spread-last-alone {
  grid-column: span 2;
  justify-self: center;
}

/* INFO: createPageBox がインラインで設定する margin-bottom:12px は単一ページモード(flex 縦積み)の
   行間用。見開きモード(Grid)では gap:12px が row-gap として効くため、margin-bottom と合算されて
   行間が 24px になってしまう。見開き中は margin-bottom を 0 に上書きして縦・横の間隔を gap だけに揃える。
   インラインスタイルを上書きする必要があるため !important を付与する。 */
.pdf-container--spread .page {
  margin-bottom: 0 !important;
}

/* Guard against clipping */
.pdf-view {
  overflow: auto;
  max-height: none;
  min-height: 0;
}

/* === Fix: allow the PDF pane to scroll inside the flex layout === */
.editor-area {
  min-height: 0;
}

/* let child (.pdf-view) become a real scroll container */
.pdf-view {
  min-height: 0;
  overflow-y: auto;
}

/* ensure vertical scrolling is enabled */

/* === Hotfix: enable inner scrolling in flex layout === */
.main {
  min-height: 0;
}

/* allow children to size below content height */
.editor-area {
  min-height: 0;
}

/* allow .pdf-view to become the scroll container */
.pdf-view {
  min-height: 0;
  overflow-y: auto;
}

/* ensure vertical scroll engages */





/* ===== 解答時間入力（メニュー保持デザイン） ===== */
.menu-input {
  gap: 12px;
  justify-content: center;
}

.menu-input-label {
  font-weight: 600;
}

.menu-input input {
  flex: 0 0 60px;
  height: 34px;
  border: 1px solid #c2c5cc;
  border-radius: 6px;
  padding: 0 10px;
  font-size: 16px;
  background: #fff;
  color: #1a1d21;
}

.menu-input input:focus {
  outline: 2px solid #1554d0;
  outline-offset: 2px;
}

.menu-input-suffix {
  color: #1a1d21;
  font-weight: 600;
}

/* =============================================
   FIX: Keep .answer-area height fixed and prevent overflow outside
   - .answer-area stays at its layout height (e.g., 50% of right pane)
   - Inner contents scroll inside without changing .answer-area height
   ============================================= */
.answer-area {
  /* ensure children cannot protrude outside of the fixed box */
  overflow: hidden;
  /* important for flex layouts so inner scroll containers can size */
  min-height: 0;
  position: relative;
}

.answer-area.at-bottom::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 21px;
  background: var(--mask-color, #fff);
  pointer-events: none;
  z-index: 10;
  border-bottom-left-radius: inherit;
  border-bottom-right-radius: inherit;
}

.answer-header {
  flex: 0 0 auto;
}

/* The area that actually scrolls inside the fixed .answer-area */
.tab-content-container {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: hidden;
  overflow-x: auto;
}

/* Avoid accidental overflow due to flex sizing */
.answer-editor,
.answer-editor .lined-paper {
  min-width: 0;
  min-height: 0;
}

/* If any contenteditable block creates unexpected growth,
   the scroll remains within .tab-content-container */

/* === Flash (toast) message === */
.flash-message {
  position: fixed;
  top: 16px;
  left: var(--split);
  transform: translateX(-50%);
  background: rgba(21, 84, 208, 0.8);
  color: #fff;
  padding: 10px 16px;
  border-radius: 8px;
  font-size: 14px;
  z-index: 2000;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}

.flash-message.show {
  opacity: 1;
}



/* === Page Count, Line Count, Lined Paper 横並び設定 === */
.tab-content {
  display: flex;
  flex-direction: row;
  align-items: stretch;
}

.page-count {
  width: 20px;
  flex: 0 0 20px;
}

.line-count {
  width: 20px;
  flex: 0 0 20px;

  align-items: flex-start;
}

.lined-paper {
  flex: 0 0 auto;
  line-break: anywhere;
}

/* INFO: IME変換中でも30文字を超えた分が視覚的に次の行に折り返して見えるようにする。
   word-break: break-all で強制的に折り返し、確定後に _splitLongDivs() で正式に分割される */
.lined-paper > div {
  white-space: pre-wrap;
  word-break: break-all;
  overflow-wrap: break-word;
  max-width: 30ic;  /* IME変換中も30文字で折り返すための制限 */
}

/* 高さを .lined-paper に合わせる */
.page-count,
.line-count {
  display: flex;
  align-items: flex-start;
}


/* ==== 横並びレイアウト（.page-count / .line-count / .lined-paper） ==== */
/* jQueryの .show() が inline style で display:block; を付与するため、!important で上書き */
.tab-content.active {
  display: flex !important;
  flex-direction: row;
  align-items: stretch;
}

/* 3要素を横並びに固定（左から 20px / 20px / 残り幅） */
.tab-content>.page-count,
.tab-content>.line-count {
  width: 20px;
  flex: 0 0 20px;
}

.tab-content>.lined-paper {
  flex: 0 0 auto;
  min-width: 0;
  /* はみ出し防止 */
}

/* 高さは flex の stretch で .lined-paper に自動追従 */

.page-count,
.line-count {
  width: 20px;
  display: inline-block;
  vertical-align: top;
}

.tab-content {
  display: flex;
  align-items: stretch;
  /* 左ガター/右紙の高さを一致させる */
}

.lined-paper {
  flex: 0 0 auto;
}


/* === line-count 表示用 === */
.line-count {
  overflow: hidden;
  white-space: nowrap;
  font-size: 10px;
  line-height: normal;
  text-align: right;
  /* 左寄せ（※以前の要望に合わせる） */
  padding-right: 5px;
  user-select: none;
  color: red;
}

.line-count>div {
  box-sizing: border-box;
}


/* === law search current mark === */
.article-detail mark.law-current {
  outline: 2px solid #f5b828;
  background: #f5b828;
  /* 既存ハイライトの上に少し目立つ色 */
}

/* 前へ/次へボタン（有効時は青系） */
#lawPrevBtn,
#lawNextBtn {
  background: #1554d0;
  color: #fff;
}

#lawPrevBtn:hover:not(:disabled),
#lawNextBtn:hover:not(:disabled) {
  background: #0d3fa0;
}

#lawPrevBtn[disabled],
#lawNextBtn[disabled] {
  background: #fff;
  color: #333;
  border: 1px solid #c2c5cc;
  opacity: 0.5;
  cursor: not-allowed;
}

/* === 付箋ポップオーバー === */
/* INFO: 付箋ポップオーバーは法務省版に合わせ「サイズ」＋「背景色」を1枚の白カードに集約する。 */
.note-popover {
  position: absolute;
  display: none;
  flex-direction: column;
  background: #fff;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .18);
  padding: 6px 0;
  min-width: 132px;
  z-index: 110;
}

.note-popover.show {
  display: flex;
}

.note-popover-section {
  display: flex;
  flex-direction: column;
}

/* セクション間（サイズ／背景色）の区切り線 */
.note-popover-section + .note-popover-section {
  border-top: 1px solid #eee;
  margin-top: 4px;
  padding-top: 4px;
}

.note-popover-heading {
  padding: 4px 16px;
  font-size: 12px;
  color: #9aa0a6;
}

/* サイズ行・背景色行（ラジオ／ドット ＋ ラベル）。選択行は薄グレーで強調する。 */
.note-size-btn,
.note-color-btn {
  display: flex;
  align-items: center;
  gap: 14px;
  width: 100%;
  padding: 7px 16px;
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 14px;
  color: #1a1d21;
  text-align: left;
}

.note-size-btn:hover,
.note-color-btn:hover {
  background: #f5f5f5;
}

.note-size-btn.selected,
.note-color-btn.selected {
  background: #eaeaea;
}

/* サイズ選択のラジオ（未選択＝グレー枠の円／選択＝塗りつぶし） */
.note-size-radio {
  position: relative;
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border: 2px solid #9aa0a6;
  border-radius: 50%;
  box-sizing: border-box;
}

.note-size-btn.selected .note-size-radio {
  border-color: #1a1d21;
}

.note-size-btn.selected .note-size-radio::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1a1d21;
}

/* 背景色選択の色ドット */
.note-color-dot {
  flex: 0 0 auto;
  width: 16px;
  height: 16px;
  border-radius: 50%;
}

/* === 付箋（sticky note） === */
.note-host {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 40;
}

.sticky-note {
  position: absolute;
  min-width: 20px;
  max-width: none;
  padding: 8px 10px;
  border-radius: 6px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
  color: #1a1d21;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre;
  word-break: normal;
  outline: none;
  border: 2px solid transparent;
  pointer-events: auto;
  box-sizing: border-box;
}

.sticky-note.editing {
  border-color: #ff9800;
}

/* INFO: contentEditable には native placeholder がないため、空のとき(:empty)だけ擬似要素でヒントを出す。
   入力すると :empty が外れて自動的に消える。pointer-events:none で入力の邪魔をしない。
   font-size は付箋本体（サイズ係数込み）を継承するため、プレースホルダーもサイズに追従する。 */
.sticky-note:empty::before {
  content: "テキストを入力してください...";
  color: rgba(0, 0, 0, .4);
  pointer-events: none;
}

.sticky-note.orange {
  background: rgba(255, 231, 179, 0.7);
}

.sticky-note.yellow {
  background: rgba(255, 245, 157, 0.7);
}

.sticky-note.green {
  background: rgba(200, 230, 201, 0.7);
}

.sticky-note.blue {
  background: rgba(187, 222, 251, 0.7);
}

.sticky-note.red {
  background: rgba(255, 205, 210, 0.7);
}

.note-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 35;
  pointer-events: none;
}

/* === 装飾の選択・削除（仕様 §2） === */
/* INFO: 選択中の装飾に重ねる青枠オーバーレイ。各ページに差し込み、注釈レイヤーと同じ座標系で描画する。
   pointer-events:none で下のレイヤー操作を妨げない。付箋(z40)より手前に出すため z-index:50。 */
.decoration-selection-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 50;
  pointer-events: none;
  display: none;
}

.decoration-selection-layer.show {
  display: block;
}

/* INFO: 付箋選択時の青枠（DOM要素）。note-host 内に重ね、付箋と同じ座標系で配置するため zoom に自動追従する。 */
.decoration-note-frame {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid #2196f3;
  pointer-events: none;
  z-index: 1;
}

/* === 装飾ホバーで枠線表示 === */
/* INFO: 装飾上にカーソルが乗ったとき「クリックすると選択される」プレビューとして出す黒系の枠線。
   ペン・マーカー用の canvas オーバーレイ。選択用青枠(z-index:50)の直下(z-index:49)に重ね、
   青枠が出ているときは青枠が手前に来るようにする。pointer-events:none で下のレイヤー操作を妨げない。 */
.decoration-hover-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 49;
  pointer-events: none;
  display: none;
}

.decoration-hover-layer.show {
  display: block;
}

/* INFO: 付箋ホバー時の黒枠（DOM要素）。選択時の青枠と同形状・同配置で、色だけ黒系・控えめな細枠にする。 */
.decoration-hover-note-frame {
  position: absolute;
  box-sizing: border-box;
  border: 1.5px solid #333333;
  pointer-events: none;
  z-index: 1;
}

/* INFO: 付箋は移動可（仕様 §2）。掴んで動かせることを示すため移動カーソルを出す。
   編集中（ダブルクリック）はテキスト入力なのでテキストカーソルへ戻す。 */
.sticky-note {
  cursor: move;
}
.sticky-note.editing {
  cursor: text;
}

/* INFO: 装飾ホバー中はカーソルを矢印（default）に統一し「クリックすると選択される」ことを示す
   （仕様: 装飾ホバー。法務省版に合わせて矢印カーソルとする）。付箋の move（常時表示）もホバー中は
   矢印で上書きする。DecorationSelectionController がホバー開始時に body へ .decoration-hover を付与
   ／離脱時に除去する。 */
body.decoration-hover,
body.decoration-hover * {
  cursor: default !important;
}

/* INFO: 選択中の移動可能な装飾（ペン・付箋）の上で移動（move）カーソルを出し、ドラッグで動かせる
   ことを示す（仕様 §2）。DecorationSelectionController が body へ .decoration-move を付与する。
   - ペン: canvas 描画でカーソルを持つ要素がないため、選択中ペンのホバー中はこのクラスで移動カーソルを出す。
   - 付箋: 要素側 .sticky-note { cursor: move } で出すが、ドラッグ準備で pointer-events:none にする間は
     要素のカーソルが効かず選択直後に十字が遅れるため、選択時にこのクラスを併用して即座に十字を出す。
   マーカーは移動対象外なので付与されず（矢印のまま）、非選択ホバー（.decoration-hover）にも影響しない。 */
body.decoration-move,
body.decoration-move * {
  cursor: move !important;
}

/* INFO: 選択中のマーカーの上では指差し（pointer）カーソルを出す。マーカーは移動対象外（ドラッグ非対応）で
   選択操作のみのため、移動カーソルではなく指差しで「選択できる」ことを示す。マーカーも canvas 描画で
   カーソルを持つ要素がないため、DecorationSelectionController が選択中マーカー上で body へ
   .decoration-point を付与する。非選択ホバー（.decoration-hover）には影響しない。 */
body.decoration-point,
body.decoration-point * {
  cursor: pointer !important;
}

/* INFO: 装飾ドラッグ中は全体を移動（move）カーソルに統一する（DecorationSelectionController が
   ドラッグ開始時に body へ .decoration-dragging を付与／終了時に除去する）。選択中ホバーの十字（move）
   からドラッグ中まで同じカーソルで一貫させる。 */
body.decoration-dragging,
body.decoration-dragging * {
  cursor: move !important;
}

/* INFO: ペンのドラッグ移動中だけ表示する浮遊レイヤー（仕様 §2）。
   ページ内canvasはビットマップ外を描けず、ページ外・ページ間でペンが消えるため、
   ビューポート全面の固定canvasにペンと青枠を描いて常に見えるようにする。最前面・クリック透過。 */
.decoration-drag-layer {
  position: fixed;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 9999;
  display: none;
}
.decoration-drag-layer.show {
  display: block;
}

/* INFO: 選択中の装飾の右下に出すゴミ箱削除ポップアップ。
   既存ツールポップオーバーと同じく .zoom-wrapper 直下へ移動し、overflow:hidden クリッピングと
   transform:scale 座標系に揃える（位置は JS 側で scale を割って補正）。 */
.decoration-delete-popover {
  position: absolute;
  display: none;
  background-color: #ffffff;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  padding: 4px;
  z-index: 130;
}

.decoration-delete-popover.show {
  display: inline-flex;
}

.decoration-delete-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 15px;
  color: #555;
}

.decoration-delete-btn:hover {
  background-color: #f3f3f3;
}

/* INFO: マーカー選択時のみ表示する色変更UI（仕様 §2）。法務省版に合わせ、
   削除ボタンの左に「現在色ドット＋シェブロン」を置き、押下で5色ドロップダウンを下方向に開く。 */
.decoration-color-select {
  position: relative;
  display: inline-flex;
  align-items: center;
  margin-right: 4px;
  padding-right: 4px;
  border-right: 1px solid #eee;
}

.decoration-color-select[hidden] {
  display: none;
}

.decoration-color-current {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  height: 28px;
  padding: 0 4px;
  background: none;
  border: none;
  border-radius: 4px;
  cursor: pointer;
}

.decoration-color-current:hover {
  background-color: #f3f3f3;
}

.decoration-color-dot {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  box-sizing: border-box;
}

.decoration-color-chevron {
  font-size: 10px;
  color: #888;
}

.decoration-color-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  display: none;
  flex-direction: column;
  gap: 8px;
  background-color: #f5f5f5;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  padding: 10px 12px;
  z-index: 1;
}

.decoration-color-menu.show {
  display: flex;
}

.decoration-color-swatch {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  background: none;
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

/* INFO: 現在適用中の色は青リングで強調（ドットと枠の間に白い隙間を作る二重リング）。 */
.decoration-color-swatch.is-current .decoration-color-dot {
  box-shadow: 0 0 0 2px #ffffff, 0 0 0 4px #1a73e8;
}


/* === page-count 表示用 (.line-count と同一スタイル) === */
.page-count {
  overflow: hidden;
  white-space: nowrap;
  font-size: 10px;
  line-height: normal;
  text-align: right;
  padding-right: 5px;
  user-select: none;
  color: red;
  display: block;
}

/* === ▼ 仮想ページ縦コントローラ（「1」「4」「上」「下」） === */
.editor-area {
  position: relative;
}

.page-ctrl {
  position: absolute;
  left: 6px;
  bottom: 10px;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  width: 32px;
  /* スクショの幅感 */
  z-index: 60;
  /* PDFやツールより前に */
}

.page-ctrl .ctrl-btn,
.page-ctrl .page-input,
.page-ctrl .page-total {
  width: 32px;
  height: 32px;
  border: 1px solid #c2c5cc;
  border-radius: 6px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #1a1d21;
  box-sizing: border-box;
}

/* 「1」= 入力欄（編集可） */
.page-ctrl .page-input {
  text-align: center;
  font-weight: 600;
  outline: none;
}

/* 「4」= 総ページ（編集不可、クリック不可） */
.page-ctrl .page-total {
  user-select: none;
  pointer-events: none;
  font-weight: 600;
  background: #f7f8fa;
}

/* 上下の矢印ボタン */
.page-ctrl .ctrl-btn {
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, opacity .15s;
}

.page-ctrl .ctrl-btn i {
  font-size: 14px;
}

/* INFO: .tool:hover (#3a8dff) と同色を採用し、トップツールバー全体で視覚的整合性を取る */
.page-ctrl .ctrl-btn:hover {
  background: #3a8dff;
  color: #fff;
  border-color: #3a8dff;
}

/* Active / Disabled を class で簡単制御 */
.page-ctrl .ctrl-btn.active {
  background: #1554d0;
  color: #fff;
  border-color: #1554d0;
}

.page-ctrl .ctrl-btn.disabled {
  opacity: .4;
  cursor: not-allowed;
  pointer-events: none;
}

/* INFO: pointer-events: none で hover は発火しない想定だが、CSS優先順位の安全策として明示的に上書きする */
.page-ctrl .ctrl-btn.disabled:hover {
  background: #fff;
  color: #1a1d21;
  border-color: #c2c5cc;
}


/* === ▼ 仮想ページ縦コントローラ（toolbar内配置） === */
#pageCtrl.page-ctrl {
  position: absolute;
  left: 5px;
  /* INFO: ツールバーは上部5ボタン(選択/手/マーカー/ペン/付箋) + 区切り + 下部4ボタン(ズーム系)
     で構成されるため、最後のボタン(fit-width)直下に来るよう約317pxに調整。
     ボタン1個(高さ32px + gap1px = 33px)増減につき33pxずらす。
     INFO: 選択モードボタン新設(PR #315)で上部が4→5ボタンに増えた分、284px→317pxへ。
     これを怠ると縦コントローラがfit-widthボタンに被って見えなくなる。
     マーカー/ペン集約前は 515px だった */
  top: var(--pagectrl-top, 317px);
  display: flex;
  flex-direction: column;
  gap: 1px;
  width: 32px;
  z-index: 60;
}

.page-ctrl .ctrl-btn,
.page-ctrl .page-input {
  width: 32px;
  height: 32px;
  border: 1px solid #c2c5cc;
  border-radius: 6px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  color: #1a1d21;
  box-sizing: border-box;
}

.page-ctrl .page-total {
  width: 32px;
  height: 32px;
  border: 1px solid #c2c5cc;
  border-radius: 6px;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  color: #1a1d21;
  box-sizing: border-box;
}

.page-ctrl .page-input {
  text-align: center;
  font-weight: 600;
  outline: none;
}

.page-ctrl .page-total {
  user-select: none;
  pointer-events: none;
  font-weight: 600;
  background: #f7f8fa;
}

.page-ctrl .ctrl-btn {
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s, opacity .15s;
}

.page-ctrl .ctrl-btn i {
  font-size: 14px;
}

/* INFO: .tool:hover (#3a8dff) と同色を採用し、トップツールバー全体で視覚的整合性を取る */
.page-ctrl .ctrl-btn:hover {
  background: #3a8dff;
  color: #fff;
  border-color: #3a8dff;
}

.page-ctrl .ctrl-btn.active {
  background: #1554d0;
  color: #fff;
  border-color: #1554d0;
}

.page-ctrl .ctrl-btn.disabled {
  opacity: .4;
  cursor: not-allowed;
  pointer-events: none;
}

/* INFO: pointer-events: none で hover は発火しない想定だが、CSS優先順位の安全策として明示的に上書きする */
.page-ctrl .ctrl-btn.disabled:hover {
  background: #fff;
  color: #1a1d21;
  border-color: #c2c5cc;
}


/* === 仮想ページ区切りマーカー === */
.virtual-page-marker {
  position: absolute;
  left: 0;
  right: 0;
  height: 0;
  border-top: 1px dashed rgba(200, 0, 0, 0.7);
  color: red;
  font-size: 11px;
  line-height: 1;
  text-align: center;
  pointer-events: none;
  z-index: 999;
}


/* === 選択完了ボタン デザイン === */
.modal-close,
.modal-yobi-close {
  border: 2px solid #1554d0 !important;
  border-radius: 20px !important;
  color: #1554d0 !important;
  background: #fff !important;
  font-size: 14px !important;
  font-weight: bold !important;
  padding: 4px 14px !important;
  cursor: pointer !important;
  transition: background 0.2s, color 0.2s !important;
}

.modal-close:hover,
.modal-yobi-close:hover {
  background: #1554d0 !important;
  color: #fff !important;
}

/* ==== 選択完了ボタン（モーダルの閉じる）リデザイン ==== */
.modal-header .modal-close,
.modal-header .modal-yobi-close {
  background: transparent !important;
  border: 2px solid #1554d0 !important;
  color: #1554d0 !important;
  border-radius: 999px !important;
  padding: 6px 14px !important;
  font-size: 14px !important;
  font-weight: 700 !important;
  line-height: 1 !important;
  cursor: pointer;
}

.modal-header .modal-close:hover,
.modal-header .modal-yobi-close:hover {
  background: #1554d0 !important;
  color: #ffffff !important;
}


/* ▼ 右端の縦罫線（40pxの余白の左側に1px線） */


/* ===== 解答欄タブ表示制御（統合版） ===== */
.answer-area .tab-content-container {
  display: flex;
  justify-content: center;
  /* コンテナ幅 > コンテンツ幅のとき中央寄せ */
  overflow-x: auto;
  /* 横スクロールを許可 */
  overflow-y: hidden;
  /* 縦スクロールは.lined-paperで行う */
  position: relative;
}

.answer-area .tab-content {
  display: none;
  width: max-content;
  /* 中身の幅に合わせる */
  position: relative;
}

.answer-area .tab-content.active {
  display: flex !important;
  flex-direction: row;
  align-items: stretch;
}

/* 列幅の安定化 */
.answer-area .tab-content>.page-count,
.answer-area .tab-content>.line-count {
  width: 20px;
  flex: 0 0 20px;
}

.answer-area .tab-content>.lined-paper {
  flex: 0 0 auto;
  min-width: 0;
}


/* Static counters inner wrappers for smooth translateY */
.line-count-inner,
.page-count-inner {
  will-change: transform;
}


/* 高さを可変にしたいので CSS 変数で管理 */
:root {
  --navbar-h: 56px;
  /* 実寸と違えば後のJSで上書き */
  --header-bottom-h: 44px;
  /* 実寸と違えば後のJSで上書き */
}

/* 上段ヘッダー（既存 .navbar） */
.navbar {
  position: sticky;
  top: 0;
  z-index: 1000;
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

/* 下段ヘッダー（固定したい .header-bottom） */
.header-bottom {
  position: sticky;
  top: var(--navbar-h);
  /* 上段の下にピタッと重ねる */
  z-index: 999;
  /* navbar よりわずかに下でOK */
  background: #fff;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .06);
}

.header-container {
  overflow: hidden;
}

.main {
  overflow: hidden;
}

#page-exam {
  height: 100%;
  overflow: hidden;
}

.header-bold {
  font-weight: bold;
}

/* accessDeniedModal styles removed - use existing .modal-overlay / .modal rules for consistent styling */

/* ===============================
   ブックマーク機能
   =============================== */

/* ブックマークボタン（法令本文内） */
.bookmark-btn {
  position: absolute;
  left: -24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  background: transparent;
  cursor: pointer;
  color: #999;
}

/* ブックマークボタンを配置するために親要素にposition: relativeを設定 */
.article-detail div.lawnumber[id="Mp-LawNum"],
.article-detail div.LawNum[id="Mp-LawNum"],
.article-detail .preamble[id^="Mp-Preamble"],
.article-detail p.treaty-preamble[id^="Mp-Preamble"],
.article-detail div.treaty-preamble-div[id="Mp-Preamble"],
.article-detail article[id="Mp-Preamble-At"],
.article-detail p[id="Mp-Preamble"],
.article-detail p[id^="Mp-Amendment"],
.article-detail section.part[id*="-Pa_"],
.article-detail section.Part[id*="-Pa_"],
.article-detail section.chapter[id*="-Ch_"],
.article-detail section.Chapter[id*="-Ch_"],
.article-detail section.chapter[id^="Mp-Ch_"],
.article-detail section.Chapter[id^="Mp-Ch_"],
.article-detail div[id^="Mp-Ch_"],
.article-detail section.section[id*="-Se_"],
.article-detail section.Section[id*="-Se_"],
.article-detail section.subsection[id*="-Ss_"],
.article-detail section.Subsection[id*="-Ss_"],
.article-detail section.division[id*="-Di_"],
.article-detail section.Division[id*="-Di_"],
.article-detail section[id*="-At_"],
.article-detail article[id*="-At_"],
.article-detail article.article,
.article-detail div.Article[id^="je_at"],
.article-detail div.Paragraph,
.article-detail div.article[id^="art-"],
.article-detail div.article[id^="Mp-At_"],
.article-detail div.article[id^="Mp-Sp-At_"],
.article-detail div.paragraph,
.article-detail [id*="-Pr_"],
.article-detail [id*="-It_"],
.article-detail div.item[id],
.article-detail .portion.subitem,
.article-detail div._div_Subitem1Sentence[id],
.article-detail div._div_Subitem2Sentence[id],
.article-detail div._div_Subitem3Sentence[id],
.article-detail div._div_AppdxTableTitle[id],
.article-detail div.appdxtable-title[id],
.article-detail div._div_SupplProvisionAppdxTableTitle[id],
.article-detail div._div_TableStructTitle[id],
.article-detail div._div_RemarksLabel[id],
.article-detail ._div_TOCPart,
.article-detail ._div_TOCChapter,
.article-detail ._div_TOCSection,
.article-detail ._div_TOCSubsection,
.article-detail ._div_TOCDivision,
.article-detail ._div_TOCSupplProvision,
.article-detail .openiengtocitem,
.article-detail .toc-suppl-provision,
.article-detail em.articleheading[id],
.article-detail em.paragraphheading[id],
.article-detail p.sentence[id*="-Sig_"],
.article-detail div.istitle[id*="-Body"],
.article-detail h3.chaptertitle[id],
.article-detail h2.chaptertitle[id],
.article-detail section.chapter[id^="Mp-Ch_"] > h2.chaptertitle,
.article-detail section.Chapter[id^="Mp-Ch_"] > h2.chaptertitle,
.article-detail h1.lawtitle[id],
.article-detail h1.LawTitle_text,
.article-detail h1[id^="Mp-Part_"],
.article-detail h2[id^="Mp-Ch_"],
.article-detail h3[id^="Mp-Se_"],
.article-detail h3.sectiontitle[id],
.article-detail h3.ChapterTitle.sectiontitle[id],
.article-detail h4.sectiontitle[id],
.article-detail h4.subsectiontitle[id],
.article-detail h4[id^="Mp-Ss_"],
.article-detail h4[id*="-Ss_"],
.article-detail p.sentence[id^="Mp-Appdx_"],
.article-detail div._div_EnactStatement[id],
.article-detail div.paragraph[id*="-Pr_"],
.article-detail div.paragraph[id*="-Np_"],
.article-detail p.sentence[id$="-Title"],
.article-detail p.sentence[id$="-Body"],
.article-detail p.sentence[id$="-Cat"],
.article-detail div.istitle[id*="-Is_"],
.article-detail p.sentence[id*="-Si_"],
.article-detail div._div_ParagraphCaption[id$="-Cap"],
.article-detail div._div_ParagraphSentence[id$="-Sen"],
.article-detail div.sectiontitle[id$="-Title"],
.article-detail p.sentence[id$="-Sen"],
.article-detail h2.sectiontitle[id$="-Title"] {
  position: relative;
}

.bookmark-btn:hover {
  color: #1554d0;
}

.bookmark-btn.is-bookmarked {
  color: #1554d0;
}

.bookmark-btn .bookmark-icon {
  width: 16px;
  height: 16px;
}

/* 編・章タイトル用ブックマークボタン（フォントサイズが大きいため位置調整） */
/* INFO: h2.chaptertitle の行の高さ（約36px）の半分(18px) - ボタン高さ(20px)の半分(10px) = 8px */
.bookmark-btn-chapter {
  top: 6px;
}

/* 法令タイトル用ブックマークボタン（h1.lawtitle - さらにフォントサイズが大きいため位置調整） */
.bookmark-btn-lawtitle {
  top: 13px;
}

/* 章タイトル用ブックマークボタン（h3.chaptertitle - 裁判所法など） */
.bookmark-btn-h3chapter {
  top: 2px;
}

/* 節タイトル用ブックマークボタン（h3.sectiontitle - 住宅品確法など） */
.bookmark-btn-h3section {
  top: 2px;
}

/* 節タイトル用ブックマークボタン（h4.sectiontitle - 商法など） */
.bookmark-btn-h4section {
  top: 0px;
}

/* 条文見出し用ブックマークボタン（em.articleheading - 附則等のカテゴリー） */
/* INFO: インライン要素のため、デフォルトのtopをリセット */
.bookmark-btn-heading {
  top: -2px;
}

/* 法令メタ情報（法令番号など）の下マージンを除去 */
.law-meta-no-margin {
  margin-bottom: 0;
}

/* ブックマーク一覧ボタン（ヘッダー内） */
.bookmark-list-btn {
  background: #1554d0;
  color: #fff;
}

.bookmark-list-btn:hover {
  background: #0d3fa0;
}

/* ブックマーク一覧モーダル */
.bookmark-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
}

.bookmark-modal.is-open {
  display: block;
}

.bookmark-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
}

.bookmark-modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  background: #fff;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
}

.bookmark-modal-header {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
  border-bottom: 1px solid #eee;
}

.bookmark-modal-header h3 {
  margin: 0;
  font-size: 16px;
}

.bookmark-modal-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

.bookmark-modal-body.is-loading {
  opacity: 0.5;
  pointer-events: none;
}

.bookmark-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.bookmark-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}

.bookmark-item:hover {
  background: #f9f9f9;
}

.bookmark-item-content {
  flex: 1;
  min-width: 0;
}

.bookmark-item-law {
  display: block;
  font-size: 12px;
  color: #666;
  margin-bottom: 4px;
}

.bookmark-item-text {
  display: block;
  font-size: 14px;
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bookmark-item-delete {
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  font-size: 16px;
  cursor: pointer;
  color: #999;
}

.bookmark-item-delete:hover {
  color: #e74c3c;
}

.bookmark-empty-message {
  text-align: center;
  color: #999;
  padding: 40px 0;
}

.bookmark-modal-footer {
  padding: 16px;
  border-top: 1px solid #eee;
  text-align: center;
}

.bookmark-modal-close {
  padding: 8px 24px;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fff;
  cursor: pointer;
  font-size: 14px;
}

.bookmark-modal-close:hover {
  background: #f5f5f5;
}

/* ブックマークジャンプ時のハイライト効果 */
.bookmark-highlight {
  animation: bookmark-highlight-fade 2s ease-out;
}

@keyframes bookmark-highlight-fade {
  0% {
    background-color: #fff3cd;
  }
  100% {
    background-color: transparent;
  }
}

/* ========================================
   メモエリア
   ======================================== */

/* メモエリア基本スタイル */
.memo-area {
  display: none;
  position: absolute;
  background: #fff;
  border: 1px solid #d0d3d9;
  z-index: 500;
  flex-direction: column;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.memo-area.is-open {
  display: flex;
  flex-direction: column;
}

/* 配置パターン: 左配置（問題エリアの上） */
.memo-area.position-left {
  top: 0;
  left: 0;
  width: var(--split);
  height: 100%;
}

/* 配置パターン: 全画面 */
.memo-area.position-full {
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

/* 配置パターン: 右配置（右ペインの上） */
.memo-area.position-right {
  top: 0;
  right: 0;
  width: calc(100% - var(--split));
  height: 100%;
}

/* メモヘッダー */
.memo-header {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: #f5f5f5;
  border-bottom: 1px solid #d0d3d9;
  flex-shrink: 0;
}

/* 配置切り替えボタングループ */
.memo-position-btns {
  display: flex;
  gap: 4px;
}

.memo-pos-btn {
  padding: 6px 12px;
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.2s, color 0.2s;
}

.memo-pos-btn:hover {
  background: #e9ecef;
}

.memo-pos-btn.active {
  background: #007bff;
  color: #fff;
  border-color: #007bff;
}

/* 閉じるボタン */
.memo-close-btn {
  padding: 6px 16px;
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
  transition: background-color 0.2s;
}

.memo-close-btn:hover {
  background: #e9ecef;
}

/* テキストエリア */
.memo-textarea {
  flex: 1;
  padding: 12px;
  border: none;
  resize: none;
  font-size: 14px;
  line-height: 1.6;
  outline: none;
  font-family: inherit;
}

.memo-textarea::placeholder {
  color: #999;
}

/* メモボタンのactive状態 */
#memoBtn.active {
  background: #007bff;
  color: #fff;
  border-color: #007bff;
}

/* =====================================================
   パネル表示/非表示切り替え用レイアウト
   ===================================================== */

/* 法令エリアラッパー（toc-header + divider-horizontal + article-area を包含）
   INFO: デフォルトではright-paneと同じflex-direction: columnで
   内部要素を縦に並べる。パネル切り替え時に横並びレイアウトに対応 */
.article-wrapper {
  display: contents;
}

/* 共通: 非表示パネルを隠す */
.main.hide-editor .editor-area {
  display: none;
}

.main.hide-article .article-wrapper {
  display: none;
}

.main.hide-answer .answer-area {
  display: none;
}

/* -----------------------------------------------------
   入替え対応: position-basedレイアウト規則
   INFO: パネル入替え後もレイアウトが正しく機能するよう、
   要素名ではなくDOM上の配置位置で適用するCSS規則。
   主要なレイアウト制御はPanelSwapControllerのJSが担当する。
   ----------------------------------------------------- */

/* editor-areaがright-pane内にある場合、左ペイン用のスタイルを解除 */
/* INFO: ベースCSSのwidth/height/z-indexが残ると重なりやレイアウト崩れの原因になる。
   position: relativeは#pageCtrl等のabsolute子要素の基準として必要なため維持。
   overflow: hiddenで#pageCtrl等が高さ制限時にはみ出さないようクリップする */
.right-pane > .editor-area {
  width: auto;
  height: auto;
  border-right: none;
  z-index: auto;
  flex: 1 1 auto;
  overflow: hidden;
}

/* INFO: editor-areaがright-pane内にある場合、高さが制限されるため
   ツールバーのボタンがflex-shrinkで縮小してしまう。
   ボタンサイズを維持してスクロール可能にする。
   スクロールバー常時表示環境ではスクロールバーがコンテンツ領域を圧迫して
   ボタンが隠れるため、scrollbar-gutterで領域を確保しwidthをautoにする */
.right-pane > .editor-area .tool-bar {
  overflow-y: auto;
  scrollbar-gutter: stable;
  width: auto;
  flex-shrink: 0;
}

.right-pane > .editor-area .tool-bar .tool {
  flex-shrink: 0;
}

/* INFO: editor-areaがright-pane内にある場合、pageCtrlをtool-bar内に
   JSで移動するため、absolute配置を解除してtoolbarのflex itemとして扱う。
   これによりtoolbarの他のボタンと一緒にスクロール可能になり重なりを防ぐ */
.tool-bar > #pageCtrl.page-ctrl {
  position: static;
  flex-shrink: 0;
  margin-top: 6px;
  padding-top: 6px;
  border-top: 1px solid #ccc;
}

/* answer-areaが左エリア（.mainの直下）にある場合、左ペイン用のスタイルを適用 */
.main > .answer-area {
  width: var(--split);
  height: 100%;
  border-right: 1px solid #d0d3d9;
  flex: 0 0 auto;
}

/* article-wrapperが左エリア（.mainの直下）にある場合、左ペイン用のスタイルを適用 */
/* INFO: display:contentsからdisplay:flexへの切り替えはJSが担当 */
.main > .article-wrapper {
  width: var(--split);
  height: 100%;
  border-right: 1px solid #d0d3d9;
  flex: 0 0 auto;
}

/* 左エリアが非表示の場合: right-paneが全幅を占める */
.main.left-hidden > .right-pane {
  width: 100% !important;
}

/* right-paneが不要な場合（左エリアのみ表示）は非表示 */
.main.right-all-hidden > .right-pane {
  display: none;
}

/* article-areaが実体化されたarticle-wrapper内にある場合のflex伸長 */
/* INFO: article-wrapperがdisplay: flexの場合（左エリア配置時や横並び時）に
   article-areaが残り空間を埋めるために必要 */
.article-wrapper[style*="display: flex"] .article-area,
.article-wrapper[style*="display:flex"] .article-area {
  flex: 1 1 auto;
  height: auto;
  border-bottom: none;
  min-height: 0;
  overflow: hidden;
}
