.english-reading-note-page * {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

.english-reading-note-page {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  min-height: 100vh;
}

/* アプリヘッダー */
.app-header {
  background: linear-gradient(135deg, #4a90a4 0%, #357abd 100%);
  color: white;
  padding: 12px 20px;
  text-align: center;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.app-header h2 {
  font-size: 1.2em;
  margin: 0;
}

.app-header p {
  opacity: 0.9;
  font-size: 0.95em;
}

.manual-link-wrapper {
  margin-top: 20px;
}

.placeholder .manual-link {
  color: #4a90a4;
  text-decoration: underline;
  font-size: 1em;
}

.placeholder .manual-link:hover {
  color: #357abd;
}

/* メインレイアウト */
.main-layout {
  position: relative;
  padding-right: 140px;
  min-height: calc(100vh - 100px);
}

/* サイドバー */
.sidebar {
  position: fixed;
  top: 50px;
  right: 0;
  width: 140px;
  height: calc(100vh - 50px);
  background: #f8f9fa;
  border-left: 1px solid #e0e0e0;
  padding: 15px 10px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  z-index: 1;
}

.tool-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.section-label {
  font-size: 0.75em;
  font-weight: 600;
  color: #666;
  margin-bottom: 2px;
}

.tool-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

/* 横区切り線 */
.toolbar-divider-h {
  height: 1px;
  background: #ddd;
  margin: 5px 0;
}

.tool-section label {
  font-weight: 600;
  color: #555;
  font-size: 0.9em;
}

.btn {
  padding: 8px 16px;
  border: none;
  border-radius: 6px;
  background: #4a90a4;
  color: white;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.85em;
  transition: all 0.2s;
}

.btn:hover:not(:disabled) {
  background: #357abd;
  transform: translateY(-1px);
}

.btn:disabled {
  background: #ccc;
  cursor: not-allowed;
}

.btn-primary {
  background: #28a745;
}

.btn-primary:hover {
  background: #218838;
}

.btn-danger {
  background: #dc3545;
}

.btn-danger:hover:not(:disabled) {
  background: #c82333;
}

.btn.active {
  background: #ff6b35;
  box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.3);
}

.btn-small {
  padding: 6px 12px;
  font-size: 0.8em;
}

.btn-icon {
  padding: 6px 10px;
  font-size: 1em;
  min-width: 36px;
}

.btn-delete {
  background: #aaa;
  position: relative;
}

.btn-delete::after {
  content: '×';
  position: absolute;
  top: -2px;
  right: -2px;
  font-size: 0.6em;
  background: #e57373;
  color: white;
  border-radius: 50%;
  width: 12px;
  height: 12px;
  line-height: 12px;
}

.btn-delete:hover:not(:disabled) {
  background: #999;
}

/* マーカー消去ボタン（白い四角に赤い斜線） */
.eraser-btn {
  background-color: white;
  border: 2px solid #999;
  color: #e53935;
  font-weight: bold;
  font-size: 1.2em;
  line-height: 1;
}

/* トグルスイッチ */
.toggle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  user-select: none;
  margin-top: 5px;
}

.toggle-label input[type='checkbox'] {
  width: 36px;
  height: 20px;
  appearance: none;
  background: #ccc;
  border-radius: 10px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
}

.toggle-label input[type='checkbox']::before {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 16px;
  height: 16px;
  background: white;
  border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-label input[type='checkbox']:checked {
  background: #4a90a4;
}

.toggle-label input[type='checkbox']:checked::before {
  transform: translateX(16px);
}

.toggle-text {
  font-size: 0.85em;
  font-weight: 600;
  color: #555;
}

.select {
  padding: 6px 8px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 0.8em;
  background: white;
  width: 100%;
}

.color-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.color-btn {
  width: 28px;
  height: 28px;
  border: 2px solid #ccc;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
}

.color-btn:hover {
  transform: scale(1.1);
  border-color: #666;
}

.color-btn.active {
  border-color: #333;
  border-width: 3px;
  transform: scale(1.15);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* メインコンテンツ */
.main-content {
  position: relative;
  padding: 20px 30px;
  flex: 1;
  background: white;
}

.text-display {
  position: relative;
  z-index: 1;
  line-height: 2;
  font-size: 1.35em;
  font-family: 'Times New Roman', 'YuMincho', 'Yu Mincho', 'Hiragino Mincho ProN', serif;
  color: #333;
  max-width: 900px;
  margin: 0 auto;
  user-select: none;
}

.text-display.plain-mode {
  user-select: text;
}

.text-display.plain-mode .word {
  cursor: text;
}

.text-display.plain-mode .word:hover {
  background-color: transparent;
}

.placeholder {
  color: #888;
  padding: 20px;
}

.placeholder .start-message {
  text-align: center;
  font-size: 1.2em;
  color: #666;
  margin-bottom: 30px;
  padding: 20px;
  background: #f5f5f5;
  border-radius: 8px;
}

.placeholder .manual-container {
  text-align: left;
  color: #333;
}

/* 話者名のスタイル */
.speaker {
  font-weight: bold;
  color: #4a90a4;
  margin-right: 5px;
}

/* 段落スタイル */
.paragraph {
  margin-bottom: 10px;
  text-indent: 1.5em;
}

.dialogue-line {
  margin-bottom: 12px;
}

/* テキスト単語のスタイル */
.word {
  display: inline;
  padding: 2px 1px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
  border-radius: 2px;
}

.word:hover {
  background-color: rgba(0, 0, 0, 0.05);
}

.word.highlighted {
  border-radius: 3px;
}

.word.underlined {
  text-decoration: underline;
  text-decoration-color: rgba(100, 100, 100, 0.5);
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

.word.selecting {
  background-color: rgba(74, 144, 164, 0.3) !important;
}

.word.arrow-start {
  outline: 3px solid #ff6b35;
  outline-offset: 2px;
}

/* 矢印キャンバス */
#arrow-canvas {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  z-index: 2;
}

/* 付箋 */
.note {
  position: absolute;
  background: linear-gradient(135deg, #fff9c4 0%, #fff59d 100%);
  border: 1px solid #fbc02d;
  border-radius: 4px;
  padding: 10px;
  min-width: 180px;
  min-height: 60px;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.15);
  z-index: 100;
  cursor: move;
  font-size: 0.9em;
}

.note-resize {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: se-resize;
  background: linear-gradient(135deg, transparent 50%, #fbc02d 50%);
  border-radius: 0 0 4px 0;
}

.note::before {
  content: '';
  position: absolute;
  top: -8px;
  left: 15px;
  width: 16px;
  height: 16px;
  background: #fbc02d;
  border-radius: 50%;
}

.note-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
  padding-bottom: 5px;
  border-bottom: 1px dashed #fbc02d;
}

.note-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 10px;
  color: #f57c00;
  padding: 2px;
  transition: transform 0.2s;
}

.note.collapsed .note-toggle {
  transform: rotate(-90deg);
}

.note-title {
  font-weight: bold;
  color: #f57c00;
  font-size: 0.85em;
  flex: 1;
}

.note-actions {
  display: flex;
  gap: 4px;
}

.note-edit {
  background: #4a90a4;
  color: white;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.note-edit:hover {
  background: #357abd;
}

.note-close {
  background: #e57373;
  color: white;
  border: none;
  border-radius: 50%;
  width: 18px;
  height: 18px;
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

.note-close:hover {
  background: #ef5350;
}

.note-content {
  color: #333;
  line-height: 1.5;
  word-wrap: break-word;
}

.note.collapsed .note-content {
  display: none;
}

.note.collapsed .note-resize {
  display: none;
}

.note.collapsed {
  min-width: auto;
  min-height: auto;
  height: auto !important;
}

/* モーダル */
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  justify-content: center;
  align-items: center;
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  padding: 25px;
  border-radius: 12px;
  width: 90%;
  max-width: 450px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.modal-content h2 {
  margin-bottom: 15px;
  color: #333;
  font-size: 1.2em;
}

#note-text {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 1em;
  font-family: inherit;
  resize: vertical;
  margin-bottom: 15px;
}

#note-text:focus {
  outline: none;
  border-color: #4a90a4;
}

.modal-buttons {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* モード表示 */
.mode-indicator {
  position: fixed;
  bottom: 20px;
  right: 20px;
  padding: 10px 20px;
  background: #ff6b35;
  color: white;
  border-radius: 20px;
  font-weight: bold;
  font-size: 0.9em;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  display: none;
  z-index: 50;
}

.mode-indicator.show {
  display: block;
}

/* セクションヘッダー */
.section-header {
  background: #e3f2fd;
  padding: 10px 15px;
  margin: 20px 0 15px 0;
  border-left: 4px solid #4a90a4;
  font-weight: bold;
  color: #1976d2;
  border-radius: 0 4px 4px 0;
}

/* 区切り線 */
.divider {
  border: none;
  border-top: 2px dashed #ddd;
  margin: 25px 0;
}

/* ファイル操作ボタン */
.btn-file-save,
.btn-file-load,
.btn-file-text,
.btn-file-print {
  width: 100%;
  margin-bottom: 4px;
}

.btn-file-save {
  background: #28a745;
}

.btn-file-save:hover:not(:disabled) {
  background: #218838;
}

.btn-file-load {
  background: #17a2b8;
}

.btn-file-load:hover:not(:disabled) {
  background: #138496;
}

.btn-file-text {
  background: #6f42c1;
}

.btn-file-text:hover:not(:disabled) {
  background: #5a32a3;
}

.btn-file-print {
  background: #6c757d;
}

.btn-file-print:hover:not(:disabled) {
  background: #5a6268;
}

/* レスポンシブ */
@media (max-width: 768px) {
  .control-panel {
    flex-direction: column;
    align-items: stretch;
  }

  .tool-section {
    justify-content: center;
  }

  .text-display {
    font-size: 1em;
    line-height: 2;
  }

  .app-header h2 {
    font-size: 1.3em;
  }

  .legend {
    justify-content: center;
  }
}

/* ===== マニュアル ===== */
.manual-container {
  max-width: 900px;
  margin: 0 auto;
}

.manual-container h2 {
  color: #4a90a4;
  font-size: 1.4rem;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid #4a90a4;
}

.manual-container h3 {
  color: #444;
  font-size: 1.1rem;
  margin: 24px 0 12px 0;
}

.manual-container p {
  margin-bottom: 12px;
  line-height: 1.8;
}

.manual-container ul,
.manual-container ol {
  margin-left: 24px;
  margin-bottom: 12px;
}

.manual-container li {
  margin-bottom: 8px;
  line-height: 1.6;
}

.manual-box {
  background: white;
  border-radius: 12px;
  padding: 24px;
  margin-bottom: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

.manual-box h3 {
  color: #4a90a4;
  font-size: 1.2rem;
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #f0f0f0;
}

.manual-box h4 {
  color: #444;
  font-size: 1rem;
  margin: 20px 0 12px 0;
}

.tool-item {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 12px;
  background: #f9f9f9;
  border-radius: 8px;
  margin-bottom: 12px;
}

.tool-icon {
  font-size: 1.5rem;
  min-width: 40px;
  text-align: center;
}

.tool-desc {
  flex: 1;
}

.tool-desc strong {
  color: #333;
}

.shortcut {
  display: inline-block;
  background: #e0e0e0;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9rem;
  margin-left: 8px;
}

.color-sample {
  display: inline-block;
  width: 20px;
  height: 20px;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 8px;
}

.workflow {
  background: #e3f2fd;
  border-left: 4px solid #4a90a4;
  padding: 16px;
  border-radius: 0 8px 8px 0;
  margin: 16px 0;
}

.workflow-title {
  font-weight: bold;
  color: #4a90a4;
  margin-bottom: 8px;
}

.tip {
  background: #fff8e1;
  border-left: 4px solid #ffc107;
  padding: 12px 16px;
  border-radius: 0 8px 8px 0;
  margin: 16px 0;
}

.tip-title {
  font-weight: bold;
  color: #ff8f00;
  margin-bottom: 4px;
}

.manual-container code {
  background: #f0f0f0;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: monospace;
}

.manual-container table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0;
}

.manual-container th,
.manual-container td {
  border: 1px solid #e0e0e0;
  padding: 10px 12px;
  text-align: left;
}

.manual-container th {
  background: #f5f5f5;
  font-weight: 600;
}

.manual-container pre {
  background: #f5f5f5;
  padding: 16px;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.85rem;
  white-space: pre-wrap;
}

.prompt-box {
  position: relative;
  margin: 16px 0;
}

.prompt-box pre {
  padding-right: 80px;
}

.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 4px 12px;
  background: #4a90a4;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

.copy-btn:hover {
  background: #357abd;
}

/* ===== 印刷用スタイル ===== */
@media print {
  /* UI要素を非表示 */
  .sidebar {
    display: none !important;
  }

  .app-header {
    display: none !important;
  }

  .modal {
    display: none !important;
  }

  .placeholder {
    display: none !important;
  }

  .ars-header,
  .ars-footer,
  .ars-breadcrumb-nav {
    display: none !important;
  }

  /* レイアウトをリセット */
  .english-reading-note-page {
    max-width: 100%;
    box-shadow: none;
    border-radius: 0;
  }

  .main-layout {
    padding-right: 0;
    min-height: auto;
  }

  .main-content {
    padding: 20px;
  }

  /* テキスト表示を最大幅に */
  .text-display {
    max-width: 100%;
    font-size: 12pt;
    line-height: 1.8;
  }

  /* 背景色を印刷 */
  .word.highlighted {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    color-adjust: exact !important;
  }

  /* 下線を明確に印刷 */
  .word.underlined {
    text-decoration: underline;
    text-decoration-color: #333 !important;
    text-decoration-thickness: 1.5px;
  }

  /* 付箋の印刷スタイル */
  .note {
    position: relative !important;
    page-break-inside: avoid;
    margin: 10px 0;
    box-shadow: none;
    border: 1px solid #ccc;
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  .note::before {
    display: none;
  }

  .note-resize {
    display: none;
  }

  .note-toggle,
  .note-edit,
  .note-close {
    display: none;
  }

  /* キャンバス（矢印）の印刷 */
  #arrow-canvas {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }

  /* セクションヘッダー */
  .section-header {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
    page-break-after: avoid;
  }

  /* 対話行の改ページ制御 */
  .dialogue-line {
    page-break-inside: avoid;
  }

  /* ページ設定 */
  @page {
    margin: 2cm;
    size: A4;
  }
}
