/* ══════════════════════════════════════════════════════════
   Audio Guide — 音声ガイド付き自動スクロール UI
   ══════════════════════════════════════════════════════════ */

/* PC では非表示 */
@media (min-width: 1025px) {
  #ag-bar { display: none !important; }
  body.has-ag,
  body.has-ag.ag-open { padding-bottom: 0 !important; }
}

/* モバイル・タブレットでも一時非表示（iOS onend バグ調査中）→ 復活時はこのブロックを削除 */
@media (max-width: 1024px) {
  #ag-bar { display: none !important; }
  body.has-ag,
  body.has-ag.ag-open { padding-bottom: 0 !important; }
}

/* 折りたたみ時はヘッダー行分だけ余白、展開時はフルの高さ */
body.has-ag {
  padding-bottom: 46px;
}
body.has-ag.ag-open {
  padding-bottom: 110px;
}

/* ── Fixed bar ───────────────────────────────────────────── */
#ag-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 10000;
  background: #001234;
  color: #d4ecff;
  border-top: 2px solid #0b63ce;
  box-shadow: 0 -4px 28px rgba(0, 18, 60, 0.5);
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
}

/* ── Header row ──────────────────────────────────────────── */
.ag-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 7px 41px 7px 26px;
  border-bottom: 1px solid rgba(72, 160, 255, 0.18);
}

.ag-icon {
  font-size: 17px;
  flex-shrink: 0;
}

.ag-name {
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}

.ag-status {
  flex: 1;
  font-size: 12px;
  color: #7ec8ff;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}

.ag-collapse-btn {
  flex-shrink: 0;
  background: transparent;
  border: 1px solid rgba(72, 160, 255, 0.35);
  color: #d4ecff;
  border-radius: 4px;
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  line-height: 1.6;
  transition: background 0.15s;
}
.ag-collapse-btn:hover,
.ag-collapse-btn:focus-visible {
  background: rgba(11, 99, 206, 0.3);
  outline: 2px solid #0b63ce;
}

/* ── Body ────────────────────────────────────────────────── */
.ag-body {
  padding: 10px 16px 12px;
}
.ag-body[hidden] {
  display: none;
}

/* ── Controls row ────────────────────────────────────────── */
.ag-ctrl {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.ag-btn {
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.15s, transform 0.1s;
  line-height: 1.4;
}
.ag-btn:focus-visible {
  outline: 2px solid var(--yellow, #fff21a);
  outline-offset: 2px;
}
.ag-btn:disabled {
  opacity: 0.32;
  cursor: default;
  transform: none;
}
.ag-btn:not(:disabled):hover {
  opacity: 0.85;
}
.ag-btn:not(:disabled):active {
  transform: scale(0.96);
}

.ag-btn-play  { background: #0b63ce; color: #fff; }
.ag-btn-pause { background: #e09600; color: #001234; }
.ag-btn-stop  { background: #c0392b; color: #fff; }

/* ── Speed control ───────────────────────────────────────── */
.ag-speed-grp {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}

.ag-speed-lbl {
  font-size: 12px;
  color: #7ec8ff;
  white-space: nowrap;
}

.ag-speed-range {
  width: 80px;
  accent-color: #0b63ce;
  cursor: pointer;
}

.ag-speed-num {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  min-width: 32px;
}

/* ── Section info ────────────────────────────────────────── */
.ag-info {
  margin-top: 6px;
  font-size: 11px;
  color: #7ec8ff;
  min-height: 15px;
}

/* ── Reading highlight ───────────────────────────────────── */
[data-ag-section] {
  scroll-margin-top: 80px;
  transition: box-shadow 0.3s;
}

.ag-reading {
  box-shadow: inset 0 0 0 3px rgba(11, 99, 206, 0.55),
              0 0 0 3px rgba(11, 99, 206, 0.18) !important;
  border-radius: 4px;
  position: relative;
}

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 600px) {
  body.has-ag.ag-open { padding-bottom: 130px; }

  .ag-ctrl { gap: 6px; }

  .ag-btn {
    padding: 5px 10px;
    font-size: 12px;
  }

  .ag-speed-grp {
    margin-left: 0;
    width: 100%;
    justify-content: flex-end;
  }

  .ag-speed-range { width: 60px; }
}
