/* よみぴた スタイル — UIイメージ2.png 案2（シンプル・ミニマル）準拠
   モバイルファースト: 基本＝縦積み＋タブ、min-width:768px で PC 2カラム（ADR-05） */

:root {
  --color-text: #1f2937;
  --color-muted: #6b7280;
  --color-bg: #f0f2f5;
  --color-card: #ffffff;
  --color-border: #e5e7eb;
  --color-primary: #2563eb;
  --color-primary-dark: #1d4ed8;
  --color-green: #16a34a;
  --color-orange: #ea580c;
  --color-red: #e11d48;
  --color-star: #f59e0b;
  --reverse-bg: #f3faee;
  --focus-ring: 2px solid #d97706;
  --radius: 10px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);

  /* 淡色サーフェス・状態色（ダークモードで一括して差し替えるため変数化。
     ライト時の値は従来のハードコード値と同一なので表示は変わらない） */
  --surface-subtle: #f9fafb;   /* ボタン・ホバー等の淡い背景 */
  --surface-hover: #f3f4f6;    /* ボタンホバー時の背景 */
  --surface-input: #fcfcfd;    /* 入力欄・ガイド表示の背景 */
  --surface-selected: #eff6ff; /* 選択中の行・チップの背景 */
  --surface-ad: #fafafa;       /* 広告枠・履歴チップの背景 */
  --notice-bg: #fef3c7;        /* 通知バー背景 */
  --notice-border: #f59e0b;    /* 通知バー境界 */
  --nosend-text: #166534;      /* 非送信ピルの文字 */
  --nosend-bg: #f0fdf4;        /* 非送信ピルの背景 */
  --nosend-border: #bbf7d0;    /* 非送信ピルの境界 */
  --progress-track: #e5e7eb;   /* 進捗バーのトラック */
  --overlay-bg: rgba(252, 252, 253, 0.62); /* 未読オーバーレイ */
  --danger-text: #b91c1c;      /* 破壊的操作ボタンの文字 */
  --danger-bg: #fef2f2;        /* 破壊的操作ボタンの背景 */
  --danger-border: #fecaca;    /* 破壊的操作ボタンの境界 */
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: system-ui, -apple-system, "Hiragino Sans", "Noto Sans JP", "Yu Gothic UI", sans-serif;
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.6;
}

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 2px;
}

button {
  font-family: inherit;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* ---- ヘッダー（案1準拠: 1行・アイコン＋青タイトル＋タグライン横並び） ---- */

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
  padding: 0.5rem 1rem;
}

.header-inner {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  max-width: 1160px;
  margin: 0 auto;
  flex-wrap: wrap;
}

.brand-icon {
  display: inline-flex;
  flex: none;
}

.header-inner h1 {
  margin: 0;
  font-size: 1.375rem;
  letter-spacing: 0.01em;
  color: var(--color-primary);
  white-space: nowrap;
}

.header-inner h1 a {
  color: inherit;
  text-decoration: none;
}

.tagline {
  margin: 0 0 0 0.5rem;
  font-size: 0.8125rem;
  color: var(--color-text);
  white-space: nowrap;
}

.header-actions {
  display: flex;
  gap: 0.5rem;
  flex: none;
  margin-left: auto;
}

/* 原稿非送信の常時表示（FR-09）— ヘッダー行内のピル表示 */
.no-send-note {
  margin: 0 0 0 auto;
  font-size: 0.7rem;
  color: var(--nosend-text);
  background: var(--nosend-bg);
  border: 1px solid var(--nosend-border);
  border-radius: 999px;
  padding: 0.15rem 0.6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 45vw;
}

.no-send-note:empty {
  display: none;
}

/* 狭い画面: タグラインを隠し、非送信文言は2段目のスリムな行に */
@media (max-width: 860px) {
  .tagline {
    display: none;
  }
}

@media (max-width: 640px) {
  .header-inner h1 {
    font-size: 1.125rem;
  }

  .header-btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }

  .no-send-note {
    order: 10;
    width: 100%;
    max-width: 100%;
    text-align: center;
    white-space: normal; /* 省略で意味が反転しないよう全文表示 */
  }
}

.header-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.4rem 0.7rem;
  font-size: 0.8125rem;
  color: var(--color-text);
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
}

.header-btn:hover {
  background: var(--surface-subtle);
}

/* ---- 通知バー（非ブロッキング） ---- */

.notice-bar {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: var(--notice-bg);
  border-bottom: 1px solid var(--notice-border);
  font-size: 0.875rem;
}

.notice-bar[hidden] {
  display: none;
}

.notice-bar span {
  flex: 1;
}

#notice-close {
  background: none;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  padding: 0 0.25rem;
}

/* ---- タブ（モバイルのみ表示） ---- */

.tabs {
  display: flex;
  background: var(--color-card);
  border-bottom: 1px solid var(--color-border);
}

.tab {
  flex: 1;
  padding: 0.75rem 0.5rem;
  font-size: 1rem;
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  color: var(--color-muted);
}

.tab[aria-selected="true"] {
  color: var(--color-primary);
  border-bottom-color: var(--color-primary);
  font-weight: bold;
}

/* ---- パネル・カード ---- */

.panel {
  display: none;
  min-width: 0;
}

.panel.is-active {
  display: block;
}

.main {
  padding: 1rem;
  max-width: 1160px;
  margin: 0 auto;
}

.card {
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.card-title {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 0.75rem;
  font-size: 1.0625rem;
}

.card-title-note {
  font-size: 0.75rem;
  font-weight: normal;
  color: var(--color-muted);
}

.badge-num {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.5rem;
  height: 1.5rem;
  flex: none;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.875rem;
  font-weight: bold;
}

/* ---- ① 原稿エリア ---- */

#manuscript {
  width: 100%;
  font: inherit;
  font-size: 0.9375rem;
  padding: 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  resize: vertical;
  color: var(--color-text);
  background: var(--surface-input);
}

#manuscript:focus {
  background: var(--color-card);
}

.manuscript-footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.char-count {
  margin: 0;
  font-size: 0.875rem;
}

.char-count strong {
  font-size: 1.375rem;
  font-variant-numeric: tabular-nums;
}

.char-count-note {
  font-size: 0.7rem;
  color: var(--color-muted);
}

.manuscript-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.manuscript-actions button {
  padding: 0.35rem 0.75rem;
  font-size: 0.8125rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  background: var(--surface-subtle);
  cursor: pointer;
}

.manuscript-actions button:hover:not(:disabled) {
  background: var(--surface-hover);
}

.manuscript-actions button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- ② 推定時間 ---- */

.usecase-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.preset-btn {
  padding: 0.35rem 0.7rem;
  font-size: 0.8125rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  background: var(--surface-subtle);
  cursor: pointer;
  color: var(--color-text);
}

.preset-btn .usecase-speed {
  color: var(--color-muted);
  font-size: 0.7rem;
}

.preset-btn.is-selected {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: #fff;
}

.preset-btn.is-selected .usecase-speed {
  color: #dbeafe;
}

.estimate-list {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--color-border);
}

.estimate-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.55rem 0.5rem;
  font: inherit;
  font-size: 0.9375rem;
  text-align: left;
  color: var(--color-text);
  background: none;
  border: none;
  border-bottom: 1px solid var(--color-border);
  cursor: pointer;
}

.estimate-row:hover {
  background: var(--surface-subtle);
}

.estimate-row.is-selected {
  background: var(--surface-selected);
}

.level-icon {
  display: inline-flex;
  flex: none;
}

.icon-slow { color: var(--color-green); }
.icon-normal { color: var(--color-orange); }
.icon-fast { color: var(--color-red); }

.level-name {
  font-weight: bold;
  min-width: 4.2em;
}

.level-speed {
  font-size: 0.75rem;
  color: var(--color-muted);
}

.level-time {
  margin-left: auto;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
}

.time-slow { color: var(--color-green); }
.time-normal { color: var(--color-orange); }
.time-fast { color: var(--color-red); }

.badge {
  color: var(--color-star);
  font-size: 1rem;
}

/* ---- 段落ごとの目安タイム ---- */

.paragraph-breakdown {
  margin-top: 0.7rem;
  padding-top: 0.5rem;
  border-top: 1px solid var(--color-border);
}

.paragraph-breakdown summary {
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--color-text);
  user-select: none;
}

.paragraph-list {
  margin: 0.5rem 0 0;
  padding-left: 1.4rem;
  list-style: decimal;
}

.paragraph-list li {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.3rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.8125rem;
}

.paragraph-list li:last-child {
  border-bottom: none;
}

.paragraph-snippet {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--color-text);
}

.paragraph-cumulative {
  flex: none;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

/* ---- 逆算ボックス ---- */

.reverse-box {
  margin-top: 0.9rem;
  padding: 0.8rem 1rem;
  background: var(--reverse-bg);
  border-radius: 8px;
  text-align: center;
}

.reverse-box p {
  margin: 0;
  font-size: 0.9375rem;
  white-space: pre-line;
  line-height: 1.9;
}

.reverse-box strong {
  color: var(--color-green);
  font-size: 1.125rem;
}

.reverse-box p.is-over strong {
  color: var(--color-red);
}

/* ---- 広告枠・アフィリエイト（ADR-06: 原稿DOMと分離） ---- */

.ad-box {
  margin-top: 1rem;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--color-border);
}

.ad-label {
  margin: 0 0 0.25rem;
  font-size: 0.7rem;
  color: var(--color-muted);
}

.ad-slot {
  min-height: 90px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-ad);
  border: 1px dashed var(--color-border);
  border-radius: 8px;
}

.ad-placeholder {
  margin: 0;
  color: var(--color-muted);
  font-size: 0.8rem;
}

.affiliate-links {
  list-style: none;
  padding: 0;
  margin: 0.5rem 0 0;
  font-size: 0.8rem;
}

.affiliate-links li {
  margin-top: 0.25rem;
  color: var(--color-muted);
}

.affiliate-links a {
  color: var(--color-primary);
}

/* ---- ③ 練習モード ---- */

.practice-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.target-time {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.target-label {
  font-size: 0.875rem;
  margin-right: 0.15rem;
}

#target-time-input {
  width: 5.2rem;
  padding: 0.45rem 0.5rem;
  font: inherit;
  font-size: 1.125rem;
  font-variant-numeric: tabular-nums;
  text-align: center;
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.stepper {
  width: 2.1rem;
  height: 2.1rem;
  font-size: 1.05rem;
  line-height: 1;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  background: var(--surface-subtle);
  cursor: pointer;
}

.stepper:hover {
  background: var(--surface-hover);
}

.practice-start {
  flex: 1;
  min-width: 11rem;
  padding: 0.65rem 1.2rem;
  font-size: 1rem;
  font-weight: bold;
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.practice-start:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.practice-start:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.practice-start.is-running {
  background: var(--color-red);
}

/* 統計行（経過時間・目標との差・進捗） */

.practice-stats {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.5rem;
  margin: 0.9rem 0;
  padding: 0.7rem 0;
  border-top: 1px solid var(--color-border);
  border-bottom: 1px solid var(--color-border);
}

.stat {
  text-align: center;
}

.stat:not(:last-child) {
  border-right: 1px solid var(--color-border);
}

.stat-label {
  display: block;
  font-size: 0.75rem;
  color: var(--color-muted);
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  line-height: 1.3;
}

#practice-diff.is-within {
  color: var(--color-green);
}

#practice-diff.is-over {
  color: var(--color-red);
}

.progress-bar {
  height: 6px;
  margin: 0.35rem 0.5rem 0;
  background: var(--progress-track);
  border-radius: 999px;
  overflow: hidden;
}

#progress-fill {
  height: 100%;
  width: 0%;
  background: var(--color-green);
  transition: width 0.1s linear;
}

/* ガイド表示 */

.guide-viewport {
  position: relative;
  height: 46vh;
  overflow: hidden;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--surface-input);
}

/* カラオケ風（機能4）: translateY ではなく viewport 自体をスクロールさせて追従する */
.guide-viewport.is-karaoke {
  overflow-y: auto;
}

.guide-text {
  font-size: clamp(1.5rem, 3.5vw + 0.5rem, 2.25rem);
  line-height: 1.8;
  padding: 1rem 1.25rem;
  white-space: pre-wrap;
  overflow-wrap: break-word;
  will-change: transform;
}

/* 未読部分（▼ラインより下）を淡色化 — 案2準拠（既読=濃色） */
.guide-unread-overlay {
  position: absolute;
  top: 30%;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--overlay-bg);
  pointer-events: none;
}

.guide-marker {
  position: absolute;
  top: 30%;
  left: 0;
  right: 0;
  border-top: 2px dashed var(--color-green);
  pointer-events: none;
}

.guide-marker span {
  position: absolute;
  right: 0.35rem;
  top: 0;
  transform: translateY(-55%);
  color: var(--color-green);
  font-size: 0.875rem;
  background: var(--surface-input);
  line-height: 1;
}

/* カラオケ風ガイド（機能4）: 原稿は静止させ、読了済み/未読で色分けする */
.guide-text .guide-read {
  color: var(--color-primary);
}

.guide-text .guide-unread {
  color: var(--color-muted);
}

/* ---- 履歴（横並びチップ） ---- */

.history-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.history-list {
  list-style: none;
  display: flex;
  align-items: stretch;
  gap: 0.4rem;
  padding: 0.25rem 0 0.75rem;
  margin: 0;
  overflow-x: auto;
  /* overflow-x のみ指定すると仕様上 overflow-y が暗黙的に auto 扱いになり、
     縦スクロール判定と横スクロールバーの描画が競合して崩れることがあるため明示的に止める */
  overflow-y: hidden;
  flex: 1;
  min-width: 0;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.history-list::-webkit-scrollbar {
  height: 6px;
}

.history-list::-webkit-scrollbar-track {
  background: transparent;
}

.history-list::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 999px;
}

.history-list .chip {
  flex: none;
  min-width: 7.2rem;
  padding: 0.45rem 0.6rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  background: var(--surface-ad);
  text-align: center;
  font-size: 0.7rem;
  color: var(--color-muted);
  white-space: pre-line;
  line-height: 1.5;
}

.history-list .chip .chip-time {
  display: block;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  color: var(--color-text);
}

.history-list .chip.is-latest {
  border-color: var(--color-primary);
  background: var(--surface-selected);
}

.history-list .chip.is-latest .chip-label {
  color: var(--color-primary);
  font-weight: bold;
}

.history-list .arrow {
  flex: none;
  align-self: center;
  color: var(--color-muted);
}

.history-placeholder {
  color: var(--color-muted);
  font-size: 0.875rem;
  margin: 0;
  flex: 1;
}

#btn-history-clear {
  flex: none;
  padding: 0.45rem 0.8rem;
  font-size: 0.8125rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  background: var(--surface-subtle);
  cursor: pointer;
}

#btn-history-clear:hover:not(:disabled) {
  background: var(--surface-hover);
}

#btn-history-clear:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* ---- ダイアログ ---- */

.app-dialog {
  max-width: 26rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  padding: 1.25rem;
  color: var(--color-text);
  background: var(--color-card);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
}

.app-dialog::backdrop {
  background: rgba(0, 0, 0, 0.35);
}

.app-dialog h2 {
  margin: 0 0 0.6rem;
  font-size: 1.125rem;
}

.app-dialog ol {
  padding-left: 1.25rem;
  font-size: 0.9rem;
}

.app-dialog p {
  font-size: 0.875rem;
}

.dialog-close {
  margin-top: 0.5rem;
  padding: 0.4rem 1rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  background: var(--surface-subtle);
  cursor: pointer;
}

.danger-btn {
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  color: var(--danger-text);
  background: var(--danger-bg);
  border: 1px solid var(--danger-border);
  border-radius: 8px;
  cursor: pointer;
}

/* ---- 設定ダイアログ: 練習ガイドの見せ方（機能4） ---- */

.guide-style-field {
  margin: 0.9rem 0;
  padding: 0;
  border: none;
}

.guide-style-field legend {
  font-size: 0.875rem;
  font-weight: bold;
  margin-bottom: 0.4rem;
  padding: 0;
}

.guide-style-field label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  margin-top: 0.4rem;
}

/* ---- 原稿の保存・開くダイアログ（機能1） ---- */

.manuscript-name-label {
  display: block;
  font-size: 0.875rem;
  margin-bottom: 0.9rem;
}

#manuscript-name-input {
  display: block;
  width: 100%;
  margin-top: 0.3rem;
  padding: 0.45rem 0.6rem;
  font: inherit;
  font-size: 0.9375rem;
  color: var(--color-text);
  background: var(--surface-input);
  border: 1px solid var(--color-border);
  border-radius: 8px;
}

.manuscript-list {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 14rem;
  overflow-y: auto;
  border-top: 1px solid var(--color-border);
}

.manuscript-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.1rem;
  border-bottom: 1px solid var(--color-border);
}

.manuscript-item-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.manuscript-item-name {
  font-size: 0.9375rem;
  font-weight: bold;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.manuscript-item-meta {
  font-size: 0.75rem;
  color: var(--color-muted);
}

.manuscript-item-action {
  flex: none;
  padding: 0.35rem 0.7rem;
  font-size: 0.8125rem;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  color: var(--color-text);
  background: var(--surface-subtle);
  cursor: pointer;
}

.manuscript-item-action:hover {
  background: var(--surface-hover);
}

.manuscript-save-new {
  width: 100%;
  margin-top: 0.75rem;
  padding: 0.55rem 1rem;
  font-size: 0.9375rem;
  font-weight: bold;
  color: #fff;
  background: var(--color-primary);
  border: none;
  border-radius: 8px;
  cursor: pointer;
}

.manuscript-save-new:hover:not(:disabled) {
  background: var(--color-primary-dark);
}

.manuscript-save-new:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.manuscript-empty,
.manuscript-limit-note {
  font-size: 0.875rem;
  color: var(--color-muted);
  margin: 0.5rem 0 0;
}

/* ---- フッター ---- */

.site-footer {
  padding: 1.25rem 1rem 1.5rem;
  text-align: center;
  color: var(--color-muted);
}

.footer-links {
  margin-bottom: 0.4rem;
  font-size: 0.875rem;
}

.footer-links a {
  color: var(--color-primary);
}

/* ---- サイドメニュー（関連ページ） ---- */

.side-menu-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.2s ease, visibility 0.2s ease;
  z-index: 40;
}

.side-menu-backdrop.is-open {
  opacity: 1;
  visibility: visible;
}

.side-menu {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  width: min(320px, 85vw);
  background: var(--color-card);
  border-left: 1px solid var(--color-border);
  box-shadow: -12px 0 30px rgba(0, 0, 0, 0.15);
  padding: 1.1rem 1.25rem 1.5rem;
  overflow-y: auto;
  transform: translateX(100%);
  visibility: hidden;
  transition: transform 0.25s ease, visibility 0.25s ease;
  z-index: 50;
}

.side-menu.is-open {
  transform: translateX(0);
  visibility: visible;
}

.side-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  padding-bottom: 0.6rem;
  border-bottom: 1px solid var(--color-border);
}

.side-menu-header h2 {
  margin: 0;
  font-size: 1.0625rem;
  color: var(--color-primary);
}

.side-menu-close {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  font-size: 1.1rem;
  line-height: 1;
  color: var(--color-text);
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
}

.side-menu-close:hover {
  background: var(--surface-subtle);
}

.side-menu-section-title {
  margin: 1.1rem 0 0.4rem;
  font-size: 0.75rem;
  font-weight: bold;
  color: var(--color-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.side-menu-section-title:first-of-type {
  margin-top: 0;
}

.side-menu-list {
  list-style: none;
  margin: 0;
  padding: 0;
  border-top: 1px solid var(--color-border);
}

.side-menu-list li {
  border-bottom: 1px solid var(--color-border);
}

.side-menu-list a {
  display: block;
  padding: 0.65rem 0.2rem;
  font-size: 0.9375rem;
  color: var(--color-text);
  text-decoration: none;
  border-radius: 6px;
}

.side-menu-list a:hover {
  color: var(--color-primary);
  background: var(--surface-subtle);
}

/* ---- 時間別ページの導入ブロック（ADR-04） ---- */

.page-hero {
  max-width: 1160px;
  margin: 0 auto;
  padding: 1rem 1rem 0;
}

.page-hero h2 {
  margin: 0 0 0.4rem;
  font-size: 1.25rem;
}

.page-hero p {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--color-muted);
}

/* ---- 本文コンテンツ（文字数目安表・コツ・FAQ、SEO本文強化） ---- */

.page-content {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0.5rem 1rem 1.5rem;
}

.page-content h3 {
  margin: 1.5rem 0 0.6rem;
  font-size: 1.0625rem;
}

.page-content h3:first-of-type {
  margin-top: 0.25rem;
}

.page-content > p {
  margin: 0 0 0.6rem;
  font-size: 0.9375rem;
  color: var(--color-muted);
}

.content-table-wrap {
  overflow-x: auto;
}

.content-table {
  width: 100%;
  max-width: 26rem;
  border-collapse: collapse;
  font-size: 0.9375rem;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  overflow: hidden;
}

.content-table th,
.content-table td {
  padding: 0.55rem 0.8rem;
  text-align: left;
  border-bottom: 1px solid var(--color-border);
}

.content-table thead th {
  background: var(--surface-subtle);
  font-weight: bold;
}

.content-table tbody tr:last-child td {
  border-bottom: none;
}

.content-table th:last-child,
.content-table td:last-child {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.content-tips {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 0.6rem;
}

.content-tips li {
  padding: 0.75rem 0.9rem;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: var(--radius);
  font-size: 0.9375rem;
}

.content-tips li strong {
  display: block;
  margin-bottom: 0.25rem;
  color: var(--color-primary);
}

.content-faq {
  margin: 0;
}

.content-faq dt {
  position: relative;
  margin-top: 0.85rem;
  padding-left: 1.7rem;
  font-weight: bold;
}

.content-faq dt::before {
  content: "Q";
  position: absolute;
  top: 0;
  left: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.25rem;
  height: 1.25rem;
  border-radius: 50%;
  background: var(--color-primary);
  color: #fff;
  font-size: 0.75rem;
}

.content-faq dd {
  margin: 0.3rem 0 0 1.7rem;
  color: var(--color-muted);
  font-size: 0.9375rem;
}

@media (min-width: 640px) {
  .content-tips {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ---- 静的ページ（プライバシーポリシー等） ---- */

.static-page {
  max-width: 720px;
  margin: 0 auto;
  padding: 1rem;
  background: var(--color-card);
  border-radius: var(--radius);
}

.static-page h2 {
  font-size: 1.375rem;
  margin: 1rem 0 0.5rem;
}

.static-page h3 {
  font-size: 1.0625rem;
  margin: 1.25rem 0 0.375rem;
}

.static-page ul {
  padding-left: 1.25rem;
}

/* ---- PCレイアウト: 768px以上で2カラム、タブ非表示（ADR-05） ---- */

@media (min-width: 768px) {
  .tabs {
    display: none;
  }

  .main {
    display: grid;
    grid-template-columns: minmax(0, 5fr) minmax(0, 7fr);
    gap: 1rem;
    align-items: start;
  }

  .panel {
    display: block;
  }
}

/* ==== 推定タブの目標タイム入力（機能: 逆算ボックス上に同UIを配置） ==== */

.reverse-target {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
}

/* ==== 練習モードのボタン群（スタート/一時停止/終了/破棄） ==== */

.practice-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  flex: 1;
  min-width: 12rem;
}

.practice-buttons > button {
  flex: 1 1 auto;
  min-width: 6.5rem;
  padding: 0.65rem 1rem;
  font-size: 1rem;
  font-weight: bold;
  color: #fff;
  border: none;
  border-radius: 10px;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.practice-buttons .practice-start {
  min-width: 6.5rem;
}

.practice-buttons .practice-pause {
  background: var(--color-orange);
}

.practice-buttons .practice-finish {
  background: var(--color-green);
}

/* 破棄は控えめな見た目にし、記録される「終了」と誤認しにくくする */
.practice-buttons .practice-discard {
  color: var(--color-red);
  background: var(--color-card);
  border: 1px solid var(--color-border);
  box-shadow: none;
}

.practice-buttons .practice-discard:hover {
  background: var(--surface-subtle);
}

/* ==== 保存原稿の個別削除（保存/開くダイアログ） ==== */

.manuscript-item-actions {
  display: flex;
  gap: 0.4rem;
  flex: none;
}

.manuscript-item-delete {
  flex: none;
  padding: 0.35rem 0.7rem;
  font-size: 0.8125rem;
  color: var(--color-red);
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  cursor: pointer;
}

.manuscript-item-delete:hover {
  background: var(--surface-subtle);
}

/* ==== 設定ダイアログ: テーマ選択（guide-style-field と同じ体裁） ==== */

.theme-field {
  margin: 0.9rem 0;
  padding: 0;
  border: none;
}

.theme-field legend {
  font-size: 0.875rem;
  font-weight: bold;
  margin-bottom: 0.4rem;
  padding: 0;
}

.theme-field label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  font-size: 0.875rem;
  margin-top: 0.4rem;
}

/* ==== 404 ページ ==== */

.notfound-page {
  text-align: center;
}

.notfound-code {
  margin: 0.5rem 0 0;
  font-size: 3.5rem;
  font-weight: bold;
  color: var(--color-primary);
  font-variant-numeric: tabular-nums;
}

.notfound-home {
  color: var(--color-primary);
}

.notfound-links {
  list-style: none;
  padding: 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5rem;
}

.notfound-links a {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border: 1px solid var(--color-border);
  border-radius: 999px;
  color: var(--color-primary);
  text-decoration: none;
  font-size: 0.875rem;
}

.notfound-links a:hover {
  background: var(--surface-subtle);
}

/* ==== ダークモード ====
   [data-theme="dark"]（明示指定）と、data-theme 未指定（＝自動）時の OS ダーク設定の
   両方で同じ配色に切り替える。data-theme="light"（ライト明示）のときは適用しない。
   変数を差し替えるだけで、var() を参照している各コンポーネントに一括反映される。 */

[data-theme="dark"] {
  --color-text: #e5e7eb;
  --color-muted: #9aa4b2;
  --color-bg: #0b1220;
  --color-card: #131c2b;
  --color-border: #2a3648;
  --color-primary: #3b82f6;
  --color-primary-dark: #60a5fa;
  --color-green: #34d399;
  --color-orange: #fb923c;
  --color-red: #fb7185;
  --color-star: #fbbf24;
  --reverse-bg: #14251a;
  --focus-ring: 2px solid #fbbf24;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);

  --surface-subtle: #1b2536;
  --surface-hover: #24314a;
  --surface-input: #0f1826;
  --surface-selected: #1e2f4d;
  --surface-ad: #16202f;
  --notice-bg: #3a2f10;
  --notice-border: #b8860b;
  --nosend-text: #86efac;
  --nosend-bg: #10241a;
  --nosend-border: #1f5136;
  --progress-track: #2a3648;
  --overlay-bg: rgba(11, 18, 32, 0.62);
  --danger-text: #fca5a5;
  --danger-bg: #2a1416;
  --danger-border: #5b2327;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme]) {
    --color-text: #e5e7eb;
    --color-muted: #9aa4b2;
    --color-bg: #0b1220;
    --color-card: #131c2b;
    --color-border: #2a3648;
    --color-primary: #3b82f6;
    --color-primary-dark: #60a5fa;
    --color-green: #34d399;
    --color-orange: #fb923c;
    --color-red: #fb7185;
    --color-star: #fbbf24;
    --reverse-bg: #14251a;
    --focus-ring: 2px solid #fbbf24;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5), 0 1px 2px rgba(0, 0, 0, 0.4);

    --surface-subtle: #1b2536;
    --surface-hover: #24314a;
    --surface-input: #0f1826;
    --surface-selected: #1e2f4d;
    --surface-ad: #16202f;
    --notice-bg: #3a2f10;
    --notice-border: #b8860b;
    --nosend-text: #86efac;
    --nosend-bg: #10241a;
    --nosend-border: #1f5136;
    --progress-track: #2a3648;
    --overlay-bg: rgba(11, 18, 32, 0.62);
    --danger-text: #fca5a5;
    --danger-bg: #2a1416;
    --danger-border: #5b2327;
  }
}

/* ==== モーション低減（装飾的な transition/animation を無効化） ====
   練習ガイドの進行は JS による inline transform / scrollTop 更新で行っており
   CSS transition ではないため、この指定では止まらない（機能は維持される）。 */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}
