/* 耳コピ用プレーヤー：最初から最後まで一画面（ページはスクロールしない）。フラット・不透明・1px境界・角丸6px */
[hidden] { display: none !important; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }

html, body { height: 100dvh; overflow: hidden; }
.ec-main { max-width: 1100px; padding: 0.8rem 1rem 0.9rem; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }

/* ───────── 読み込み前：画面中央のドロップ領域 ───────── */
.ec-intro { flex: 1 1 auto; min-height: 0; display: flex; overflow-y: auto; }
html.ec-on .ec-intro { display: none; }
.ec-hero { width: 100%; max-width: 640px; margin: auto; }
.ec-hero h1 { font-size: 1.9rem; font-weight: 700; margin-bottom: 0.5rem; }
.ec-hero .pt-lead { font-size: 0.95rem; line-height: 1.8; margin-bottom: 1.3rem; }

.ec-drop {
  display: flex; flex-direction: column; align-items: center; gap: 0.2rem;
  padding: 2.6rem 1.2rem; background: var(--surface);
  border: 2px dashed var(--border); border-radius: 6px;
}
.ec-drop-ico { color: var(--pt-accent); margin-bottom: 0.5rem; }
.ec-drop .pt-drop-main { font-size: 1.1rem; font-weight: 700; }
.ec-drop .pt-drop-sub { font-size: 0.8rem; line-height: 1.5; }

.ec-feat {
  list-style: none; margin: 1rem 0 0; padding: 0;
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 1px;
  background: var(--border); border: 1px solid var(--border); border-radius: 6px; overflow: hidden;
}
.ec-feat li { background: var(--surface); padding: 0.65rem 0.8rem; display: flex; flex-direction: column; gap: 0.1rem; }
.ec-feat b { font-size: 0.86rem; font-weight: 700; }
.ec-feat span { font-size: 0.75rem; line-height: 1.45; color: var(--text-sub); }

.ec-link { display: block; margin: 0.7rem auto 0; background: none; border: none; color: var(--pt-accent); font: inherit; font-size: 0.88rem; padding: 0.35rem 0.6rem; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; border-radius: 6px; }
.ec-link:hover { background: var(--pt-accent-soft); }

/* 使い方・よくある質問（SEO解説ブロックを窓で出す） */
.ec-guide { position: fixed; inset: 0; z-index: 1000; background: rgba(15, 23, 42, 0.55); display: flex; align-items: center; justify-content: center; padding: 1rem; }
.ec-guide-box { position: relative; width: 100%; max-width: 760px; max-height: 100%; display: flex; flex-direction: column; background: var(--surface); border: 1px solid var(--border); border-radius: 6px; overflow: hidden; }
.ec-guide .seo-guide { margin: 0; border: 0; border-radius: 0; flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding-right: 3.2rem; }
.ec-guide-x { position: absolute; top: 0.6rem; right: 0.6rem; z-index: 1; }

/* ───────── 読み込み後：アプリ ───────── */
.ec-app { flex: 1 1 auto; min-height: 0; display: flex; flex-direction: column; gap: 0.55rem; overflow-x: hidden; overflow-y: auto; }

/* 上段：ファイル名と時間 */
.ec-top { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex: 0 0 auto; padding: 0 0.1rem; }
.ec-file { display: flex; align-items: center; gap: 0.5rem; min-width: 0; }
.ec-file-ico { flex: 0 0 auto; color: var(--pt-accent); }
.ec-fname { font-weight: 700; font-size: 1rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ec-textbtn { flex: 0 0 auto; background: none; border: none; color: var(--pt-accent); font: inherit; font-size: 0.82rem; padding: 0.25rem 0.5rem; border-radius: 6px; cursor: pointer; white-space: nowrap; }
.ec-textbtn:hover { background: var(--pt-accent-soft); }
.ec-time { font-size: 1.75rem; font-weight: 700; line-height: 1.1; color: var(--text); white-space: nowrap; font-variant-numeric: tabular-nums; }
.ec-ttot { font-size: 1rem; font-weight: 500; color: var(--text-sub); }

/* 波形（残りの高さをすべて使う） */
.ec-wave {
  position: relative;
  flex: 1 1 auto;
  min-height: 80px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--surface);
  overflow: hidden;
  touch-action: pan-y;
  user-select: none;
  -webkit-user-select: none;
}
.ec-wave canvas { position: absolute; inset: 0; display: block; width: 100%; height: 100%; cursor: crosshair; }
/* 全体バー：ファイル全体の中の A〜B・再生位置・いま見ている範囲 */
.ec-ovr { position: relative; flex: 0 0 auto; height: 14px; border: 1px solid var(--border); border-radius: 6px; background: var(--bg); overflow: hidden; touch-action: none; user-select: none; -webkit-user-select: none; }
.ec-ovr.is-zoomed { cursor: grab; }
.ec-ovr.is-drag { cursor: grabbing; }
.ec-ovr-ab { position: absolute; top: 0; bottom: 0; background: var(--pt-accent); opacity: 0.45; min-width: 2px; }
.ec-ovr-ab.is-off { opacity: 0.22; }
.ec-ovr-view { position: absolute; top: 0; bottom: 0; border: 2px solid var(--text-sub); border-radius: 4px; box-sizing: border-box; min-width: 6px; pointer-events: none; }
.ec-ovr-ph { position: absolute; top: 0; bottom: 0; width: 2px; margin-left: -1px; background: var(--pt-err); pointer-events: none; }
.ec-wnote { flex: 0 0 auto; margin: 0; }

/* 波形の下：ループの状態と拡大 */
.ec-info { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; flex: 0 0 auto; min-height: 2rem; padding: 0 0.1rem; }
.ec-loopinfo { font-size: 0.85rem; color: var(--text-sub); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ec-zoom { display: inline-flex; align-items: center; gap: 0.3rem; flex: 0 0 auto; }
.ec-zoom .btn { width: auto; min-width: 2.2rem; padding: 0.25rem 0.55rem; }
.ec-zval { font-size: 0.82rem; min-width: 2.4rem; text-align: center; color: var(--text-sub); }

/* 操作ドック：上＝よく使う操作（3つの区画）、下＝詳しい設定のボタン */
.ec-dock { flex: 0 0 auto; border: 1px solid var(--border); border-radius: 6px; background: var(--surface); overflow: hidden; }
.ec-row1 { display: flex; flex-wrap: wrap; align-items: stretch; gap: 0.7rem 0; padding: 0.75rem 0.9rem; }
.ec-zone { display: flex; flex-direction: column; gap: 0.4rem; padding: 0 1.2rem; border-left: 1px solid var(--border); }
.ec-zone:first-child { padding-left: 0; border-left: 0; }
.ec-zone:last-child { padding-right: 0; flex: 1 1 14rem; min-width: 12rem; }
.ec-cap { font-size: 0.7rem; font-weight: 700; letter-spacing: 0.04em; color: var(--text-sub); line-height: 1; }
.ec-grp { display: flex; align-items: center; gap: 0.4rem; flex: 1 1 auto; }
.ec-grp .btn { width: auto; }
.ec-transport .btn:not(.ec-play), .ec-loopgrp .btn { height: 2.6rem; padding: 0 0.95rem; font-size: 0.92rem; }
.ec-play { display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem; min-width: 8.5rem; height: 3rem; padding: 0 1.3rem; font-size: 1.02rem; font-weight: 700; color: #fff; background: var(--pt-accent); border-color: var(--pt-accent); }
.ec-play svg { flex: 0 0 auto; }
.ec-tg[aria-pressed="true"] { background: var(--pt-accent); color: #fff; border-color: var(--pt-accent); font-weight: 700; }
.ec-tg[aria-pressed="true"]:hover { background: var(--pt-accent-hover); color: #fff; }
html[data-theme="dark"] .ec-tg[aria-pressed="true"], html[data-theme="dark"] .ec-tg[aria-pressed="true"]:hover { color: #0b1220; }
.ec-speed input[type="range"] { flex: 1 1 auto; min-width: 5rem; width: auto; }
.ec-speed .btn { min-width: 2.2rem; height: 2.2rem; padding: 0 0.5rem; }
.ec-speed-val { min-width: 3.6rem; text-align: right; font-size: 1.2rem; font-weight: 700; color: var(--pt-accent); font-variant-numeric: tabular-nums; }

/* 詳しい設定を開くボタン（1px の線で区切った帯） */
.ec-row2 { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 1px; background: var(--border); border-top: 1px solid var(--border); }
.ec-tile {
  display: flex; flex-direction: column; align-items: flex-start; gap: 0.15rem;
  padding: 0.55rem 0.85rem; min-width: 0;
  border: 0; border-radius: 0; background: var(--surface);
  color: var(--text); font-family: var(--font); text-align: left; cursor: pointer;
  transition: background 0.15s;
}
.ec-tile:hover { background: var(--pt-accent-soft); }
.ec-tile:focus-visible { outline: 2px solid var(--pt-accent); outline-offset: -2px; }
.ec-tile[aria-expanded="true"] { background: var(--pt-accent-soft); box-shadow: inset 0 -2px 0 var(--pt-accent); }
.ec-tl { display: inline-flex; align-items: center; gap: 0.35rem; max-width: 100%; font-size: 0.74rem; color: var(--text-sub); line-height: 1.2; white-space: nowrap; overflow: hidden; }
.ec-tl svg { flex: 0 0 auto; }
.ec-tv { font-size: 0.95rem; font-weight: 700; line-height: 1.25; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ec-tile.is-set .ec-tv, .ec-tile.is-set .ec-tl { color: var(--pt-accent); }

/* ポップオーバー（ボタンの上に出る小さなパネル） */
.ec-pop {
  position: fixed; z-index: 900;
  width: 340px; max-width: calc(100vw - 16px);
  background: var(--surface); color: var(--text);
  border: 1px solid var(--border); border-radius: 6px;
  box-shadow: 0 6px 20px rgba(15, 23, 42, 0.16);
  padding: 0.7rem 0.9rem 0.9rem;
  overflow-y: auto; overscroll-behavior: contain;
}
html[data-theme="dark"] .ec-pop { box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5); }
.ec-pop-h { display: flex; align-items: center; justify-content: space-between; margin: 0 0 0.75rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border); font-weight: 700; font-size: 0.95rem; }
.ec-pop-x { background: none; border: none; font-size: 1.3rem; line-height: 1; color: var(--text-sub); cursor: pointer; border-radius: 6px; padding: 0.1rem 0.45rem; }
.ec-pop-x:hover { color: var(--text); background: var(--bg); }
.ec-pop .form-group { margin-bottom: 0.7rem; }
.ec-pop .form-group label { font-size: 0.85rem; }
.ec-pop .pt-hint { margin-top: 0.4rem; }
.ec-pop input[type="range"] { width: 100%; }
.ec-scrim { position: fixed; inset: 0; z-index: 890; background: transparent; }

.ec-chips { display: flex; flex-wrap: wrap; align-items: center; gap: 0.35rem; margin-top: 0.4rem; margin-bottom: 0.2rem; }
.ec-chips .btn { width: auto; }
.ec-chips .btn.is-on { background: var(--pt-accent-soft); color: var(--pt-accent); border-color: var(--pt-accent); font-weight: 700; }

.ec-trainer { border-top: 1px solid var(--border); margin-top: 0.8rem; padding-top: 0.75rem; }
.ec-trainer-row { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.6rem; font-size: 0.88rem; }
.ec-trainer-row label { display: inline-flex; align-items: center; gap: 0.35rem; margin: 0; font-weight: 400; }
.ec-trainer-row input { width: 4.2rem; padding: 0.3rem 0.4rem; }
.ec-trainer-row.is-off { opacity: 0.45; }

/* 聴く音の選択肢 */
.ec-opts { display: flex; flex-direction: column; gap: 0.3rem; }
.ec-opts label { display: flex; align-items: center; gap: 0.6rem; margin: 0; padding: 0.45rem 0.6rem; border: 1px solid var(--border); border-radius: 6px; cursor: pointer; font-weight: 400; }
.ec-opts label:hover { border-color: var(--pt-accent); }
.ec-opts label:has(input:checked) { border-color: var(--pt-accent); background: var(--pt-accent-soft); }
.ec-opts label:has(input:focus-visible) { outline: 2px solid var(--pt-accent); outline-offset: 1px; }
.ec-opts input { width: auto; flex: 0 0 auto; margin: 0; accent-color: var(--pt-accent); }
.ec-opts span { display: flex; flex-direction: column; line-height: 1.3; }
.ec-opts b { font-size: 0.9rem; font-weight: 600; }
.ec-opts small { font-size: 0.76rem; color: var(--text-sub); }
.ec-opts input:disabled + span { opacity: 0.5; }

/* しおり */
.ec-mk-add { width: auto; }
.ec-mklist { list-style: none; padding: 0; margin: 0.6rem 0 0; display: flex; flex-direction: column; gap: 0.35rem; max-height: min(40dvh, 280px); overflow-y: auto; }
.ec-mklist li { display: flex; align-items: center; gap: 0.4rem; border: 1px solid var(--border); border-radius: 6px; padding: 0.3rem 0.4rem; background: var(--surface); }
.ec-mklist .mk-go { width: auto; flex: 0 0 auto; padding: 0.3rem 0.5rem; font-size: 0.82rem; }
.ec-mklist input[type="text"] { flex: 1 1 auto; min-width: 0; padding: 0.3rem 0.5rem; }
.ec-mklist .mk-del { width: auto; flex: 0 0 auto; padding: 0.3rem 0.5rem; font-size: 0.82rem; }
.ec-mklist.empty { display: none; }

/* キー操作 */
.ec-keys { display: grid; grid-template-columns: auto 1fr; gap: 0.2rem 0.8rem; font-size: 0.84rem; margin: 0.2rem 0 0.7rem; }
.ec-keys dt { font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 0.8rem; color: var(--text); background: var(--bg); border: 1px solid var(--border); border-radius: 4px; padding: 0 0.4rem; text-align: center; justify-self: start; }
.ec-keys dd { color: var(--text-sub); margin: 0; }
@media (pointer: coarse) { .ec-keys { display: none; } }

/* 読み込み完了などの通知（アプリ表示中は上に重ねる） */
html.ec-on #load-notice { position: fixed; top: 4rem; left: 50%; transform: translateX(-50%); z-index: 950; width: max-content; max-width: min(560px, calc(100vw - 24px)); cursor: pointer; }
#load-notice:not([hidden]) { margin-bottom: 0.5rem; }

/* 幅がせまいとき：設定はボトムシート */
@media (max-width: 760px) {
  .ec-main { padding: 0.6rem 0.75rem 0.7rem; }
  .ec-row1 { padding: 0.6rem; gap: 0.55rem; }
  .ec-zone { flex: 1 1 100%; padding: 0; border-left: 0; }
  .ec-zone:last-child { min-width: 0; flex-basis: 100%; }
  .ec-cap { display: none; }
  .ec-time { font-size: 1.35rem; }
  .ec-ttot { font-size: 0.85rem; }
  .ec-row2 { grid-template-columns: repeat(4, minmax(0, 1fr)); }
  .ec-tile:last-child { grid-column: span 2; }
  .ec-tile { padding: 0.5rem 0.6rem; }
  .ec-transport .btn { flex: 1 1 auto; }
  .ec-transport .ec-play { flex: 2 1 auto; }
  .ec-loopgrp .btn { flex: 1 1 auto; padding-left: 0.4rem; padding-right: 0.4rem; }
  .ec-pop { left: 0 !important; right: 0 !important; bottom: 0 !important; top: auto !important; width: auto; max-width: none; max-height: 62dvh !important; border-radius: 6px 6px 0 0; border-bottom: none; padding-bottom: calc(0.9rem + env(safe-area-inset-bottom, 0px)); }
  .ec-hero h1 { font-size: 1.5rem; }
  .ec-feat { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .ec-drop { padding: 1.8rem 1rem; }
}
@media (max-width: 760px) and (max-height: 700px) {
  .ec-app { gap: 0.4rem; }
  .ec-row1 { padding: 0.45rem; gap: 0.4rem; }
  .ec-transport .btn:not(.ec-play), .ec-loopgrp .btn { height: 2.3rem; }
  .ec-play { height: 2.6rem; }
  .ec-tile { padding: 0.35rem 0.5rem; }
  .ec-hero .pt-lead { margin-bottom: 0.9rem; font-size: 0.88rem; line-height: 1.65; }
  .ec-drop { padding: 1.2rem 1rem; }
  .ec-drop-ico { width: 30px; height: 30px; margin-bottom: 0.3rem; }
  .ec-feat li { padding: 0.45rem 0.65rem; }
}

/* 高さが足りないとき：説明を減らして1画面に収める */
@media (max-height: 560px) {
  .ec-hero .pt-lead, .ec-feat { display: none; }
  .ec-hero h1 { font-size: 1.3rem; margin-bottom: 0.6rem; }
  .ec-drop { padding: 1.1rem 1rem; }
  .ec-drop-ico { display: none; }
}

/* 横向きのスマホなど、高さがとても小さいとき */
@media (max-height: 480px) {
  .ec-main { padding: 0.4rem 0.75rem 0.5rem; }
  .tool-header { padding: 0.4rem 1rem; }
  .ec-app { gap: 0.3rem; }
  .ec-wave { min-height: 56px; }
  .ec-time { font-size: 1.2rem; }
  .ec-row1 { flex-wrap: nowrap; gap: 0.5rem 0.75rem; padding: 0.4rem; }
  .ec-zone { flex: 0 0 auto; padding: 0; border-left: 0; }
  .ec-zone:last-child { flex: 1 1 auto; min-width: 8rem; }
  .ec-cap { display: none; }
  .ec-transport .btn:not(.ec-play), .ec-loopgrp .btn { height: 2.1rem; padding: 0 0.6rem; }
  .ec-play { height: 2.4rem; min-width: 5.5rem; padding: 0 0.9rem; }
  .ec-row2 { grid-template-columns: repeat(7, minmax(0, 1fr)); }
  .ec-tile:last-child { grid-column: auto; }
  .ec-tile { flex-direction: row; align-items: center; gap: 0.35rem; padding: 0.3rem 0.4rem; }
  .ec-tile .ec-tv { display: none; }
  .ec-pop { max-height: 80dvh !important; }
}

@media (max-width: 420px) {
  .ec-tl { gap: 0.2rem; font-size: 0.68rem; }
  .ec-tl svg { width: 13px; height: 13px; }
  .ec-tile { padding-left: 0.5rem; padding-right: 0.3rem; }
  .ec-file-ico { display: none; }
  .ec-textbtn { font-size: 0.74rem; padding: 0.25rem 0.3rem; }
  .ec-fname { min-width: 3.5rem; }
}
.ec-engine { margin-top: 0.7rem; padding-top: 0.6rem; border-top: 1px solid var(--border); }
.ec-engine .pt-hint { margin: 0.35rem 0 0; }
.ec-engine-note:empty { display: none; }
.ec-engine-note { color: var(--pt-accent); }
