/* =========================
 * Minutes (Web) - app.css
 * =======================*/

/* ===== フォント（任意） ===== */
@font-face {
  font-family: "IPAexGothic";
  src: url("./assets/fonts/ipaexg.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

/* ===== テーマ変数 ===== */
:root {
  --bg: #ffffff;
  --fg: #1f1f1f;
  --muted: #6b6b6b;
  --primary: #2962ff;
  --border: #e5e7eb;
  --card: #fafafa;
  --radius: 14px;
  --shadow: 0 6px 18px rgba(0, 0, 0, 0.06);

  /* STEP10 */
  --icon-fg: #5C6BAA;

  /* 通常ボタンのホバー/押下 */
  --btn-hover: #e9edf6;
  --btn-press: #e1e6f2;
  --btn-border-hover: #c7cfe6;
  --btn-border-press: #b8c3e0;

  /* 危険操作 */
  --danger: #DC3C64;
  --danger-border: #DC3C64;
  --danger-press: #C52B51;

  /* --- 要望 #2173（ボタン配色） --- */
  --soft-blue: #5C6BAA;       /* 固定：ヘッダーアイコン（ライト時）相当 */
  --soft-blue-press: #A7B7F7; /* hover/press */
  --soft-pink: #FF7A7A;             /* 削除/初期化 */
  --soft-pink-press: #e7a7a7;       /* マウスオーバー/押下時 */
}
:root.dark {
  --bg: #121212;
  --fg: #ececec;
  --muted: #a0a0a0;
  --primary: #82b1ff;
  --border: #2a2a2a;
  --card: #171717;

  --icon-fg: #eeeeee;

  --btn-hover: #1a1d25;
  --btn-press: #151922;
  --btn-border-hover: #3a4460;
  --btn-border-press: #323b54;
}

/* ===== ベース ===== */
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family:
    "IPAexGothic",
    "Noto Sans JP",
    "Noto Sans CJK JP",
    "Hiragino Sans",
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    "Meiryo",
    "MS PGothic",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
}

/* ===== AppBar ===== */
.appbar {
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}
.appbar__row {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
}
.appbar__title { font-size: 18px; font-weight: 700; }
.appbar__nav {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: flex-end;
}

/* ===== 共通UI ===== */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--fg);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  text-decoration: none;
  transition:
    background .18s ease,
    border-color .18s ease,
    box-shadow .18s ease,
    transform .02s ease;
  touch-action: manipulation;
}
.btn:disabled { opacity: 0.5; cursor: not-allowed; }
.btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 2px; }

.btn:not(.btn-danger):not(.icon-btn):hover {
  background: var(--btn-hover);
  border-color: var(--btn-border-hover);
}
.btn:not(.btn-danger):not(.icon-btn):active {
  background: var(--btn-press);
  border-color: var(--btn-border-press);
  transform: translateY(1px);
}

a.btn, a.btn:link, a.btn:visited, a.btn:hover, a.btn:active {
  text-decoration: none; color: inherit;
}

/* ======= STEP10: ヘッダー用アイコンボタン ======= */
.btn.icon-btn {
  --tap: 44px;
  --icon-size: 24px;
  width: var(--tap);
  height: var(--tap);
  padding: 0;
  border: none;
  background: transparent;
  color: var(--icon-fg);
  position: relative;

  /* ★タップ/長押しの青ハイライト抑止（ヘッダーアイコンだけ） */
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  user-select: none;
}
.btn.icon-btn::before {
  content: "";
  display: block;
  width: var(--icon-size);
  height: var(--icon-size);
  margin: 0;
  background-color: currentColor;
  -webkit-mask: no-repeat center / contain;
          mask: no-repeat center / contain;
}
.btn.icon-btn.i-home::before {
  -webkit-mask-image: url("assets/icons/home-outline.svg");
          mask-image: url("assets/icons/home-outline.svg");
}
.btn.icon-btn.i-mic::before {
  -webkit-mask-image: url("assets/icons/microphone.svg");
          mask-image: url("assets/icons/microphone.svg");
}
.btn.icon-btn.i-cog::before {
  -webkit-mask-image: url("assets/icons/cog.svg");
          mask-image: url("assets/icons/cog.svg");
}
.btn.icon-btn:hover { filter: brightness(1.05); }
.btn.icon-btn:active { transform: translateY(1px); }

/* ★タッチで付く focus の枠を消す（focus-visible は後段で復活） */
.btn.icon-btn:focus { outline: none; }

.btn.icon-btn:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }

/* === 詳細ビューのツールバー === */
.detail-toolbar { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }

/* === フォームコントロール === */
.input,
.select {
  -webkit-appearance: none;
  appearance: none;
  box-shadow: none;
  border: 1px solid var(--border) !important;
  background: var(--bg);
  color: var(--fg);
  border-radius: 10px;
}
.input {
  width: 100%;
  padding: 10px;
}
.select {
  padding: 6px 10px;
  padding-right: 28px;
  border: 1px solid var(--border) !important;
  background: var(--bg);
  color: var(--fg);
  border-radius: 10px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b6b6b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  background-size: 12px 8px;
}
:root.dark .select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a0a0a0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}
.input:focus-visible,
.select:focus-visible {
  outline: 2px solid rgba(56,189,248,.35);
  outline-offset: 2px;
  border-color: var(--primary);
}

/* ===== Toggle Switch (theme) ===== */
.toggle { display: inline-flex; align-items: center; gap: 10px; }
.toggle__input {
  position: absolute;
  width: 1px; height: 1px;
  margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); clip-path: inset(50%);
  white-space: nowrap;
}
.toggle__label {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  cursor: pointer;
  user-select: none;
}
.toggle__text { color: var(--fg); }

.toggle__track {
  width: 46px; height: 26px;
  border-radius: 9999px;
  background: var(--bg);
  border: 1px solid var(--border);
  position: relative;
  transition: background .2s ease, border-color .2s ease, box-shadow .2s ease;
}
.toggle__thumb {
  position: absolute;
  top: 50%; left: 2px;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: #fff;
  border: 1px solid var(--border);
  transform: translateY(-50%);
  box-shadow: 0 1px 2px rgba(0,0,0,.15);
  transition: left .18s ease, transform .06s ease;
}
.toggle__label:active .toggle__thumb { transform: translateY(-50%) scale(0.96); }

.toggle__input:checked + .toggle__label .toggle__track {
  background: var(--primary);
  border-color: var(--primary);
}
.toggle__input:checked + .toggle__label .toggle__thumb { left: 22px; }

.toggle__input:focus-visible + .toggle__label .toggle__track {
  box-shadow: 0 0 0 3px rgba(56,189,248,.35);
}
.toggle__input:disabled + .toggle__label { opacity: .6; cursor: not-allowed; }

/* ===== コンテナ/カード ===== */
.container { max-width: 960px; margin: 0 auto; padding: 16px; }
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 12px;
}

/* ===== リスト（Home） ===== */
.list { display: flex; flex-direction: column; gap: 10px; }
.item {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
}
.item__meta { font-size: 12px; color: var(--muted); }
.home-note { font-size: 12px; color: var(--muted); }

/* ===== 詳細ビュー（本文） ===== */
.editor {
  width: 100%;
  min-height: 60vh;
  margin-top: 8px;
  padding: 12px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  white-space: pre-wrap;
  overflow: auto;
  font-family:
    "IPAexGothic",
    "Noto Sans JP",
    "Noto Sans CJK JP",
    "Hiragino Sans",
    "Hiragino Kaku Gothic ProN",
    "Yu Gothic",
    "Meiryo",
    "MS PGothic",
    system-ui,
    -apple-system,
    "Segoe UI",
    Roboto,
    sans-serif;
}

/* ===== 要約リスト（箇条書き） ===== */
#summaryList { margin-top: 12px; padding-left: 1.2em; }
#summaryList li { margin: 4px 0; line-height: 1.5; }

/* ===== 検索バー ===== */
.search__bar { display: flex; align-items: center; gap: 8px; flex-wrap: nowrap; }
.search__bar .input { flex: 1 1 0%; min-width: 0; }
.search__bar #searchBtn { flex: 0 0 auto; }
@media (max-width: 560px) {
  .search__bar { flex-direction: column; align-items: stretch; }
}

/* ===== ユーティリティ ===== */
.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }

/* ===== 404 ===== */
.view[data-view="404"] .card { text-align: center; }
.view[data-view="404"] h2 { margin: 0 0 6px; }
.view[data-view="404"] .item__meta { margin-top: 4px; }

/* スクロールバー幅を予約 */
:root { scrollbar-gutter: stable both-edges; }
@supports not (scrollbar-gutter: stable) { html { overflow-y: scroll; } }

/* --- 要約ボタン --- */
.view[data-view="text"] #summarizeBtn {
  background: #38bdf8 !important;
  color: #fff !important;
  border-color: #38bdf8 !important;
  transition: background .2s ease, box-shadow .2s ease, transform .02s ease;
}
.view[data-view="text"] #summarizeBtn:hover { background: #0ea5e9 !important; }
.view[data-view="text"] #summarizeBtn:active { transform: translateY(1px); }
.view[data-view="text"] #summarizeBtn:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(56, 189, 248, 0.35);
}

/* ===== 削除（危険）ボタン ===== */
.btn.btn-danger {
  background: var(--soft-pink);
  border-color: var(--soft-pink);
  color: #fff;
}
.btn.btn-danger:hover {
  background: var(--soft-pink-press);
  border-color: var(--soft-pink-press);
}
.btn.btn-danger:active { background: var(--soft-pink-press); }
.btn.btn-danger:focus-visible {
  outline: 2px solid rgba(255, 122, 122, 0.55);
  outline-offset: 2px;
}

/* ===== 要望 #2173: 再生/保存ボタン（薄い青） ===== */
/* Home: 再生ボタン */
.btn[data-audio-play] {
  background: var(--soft-blue);
  border-color: var(--soft-blue);
  color: #fff;
}
.btn[data-audio-play]:not(:disabled):hover {
  background: var(--soft-blue-press);
  border-color: var(--soft-blue-press);
}
.btn[data-audio-play]:not(:disabled):active {
  background: var(--soft-blue-press);
  border-color: var(--soft-blue-press);
  transform: translateY(1px);
}
.btn[data-audio-play]:focus-visible {
  outline: 2px solid rgba(92, 107, 170, 0.55);
  outline-offset: 2px;
}
.btn[data-audio-play]:disabled {
  background: var(--soft-blue);
  border-color: var(--soft-blue);
  color: #fff;
}

/* Record: 保存ボタン */
#saveRecBtn.btn {
  background: var(--soft-blue);
  border-color: var(--soft-blue);
  color: #fff;
}
#saveRecBtn.btn:hover {
  background: var(--soft-blue-press);
  border-color: var(--soft-blue-press);
}
#saveRecBtn.btn:active {
  background: var(--soft-blue-press);
  border-color: var(--soft-blue-press);
  transform: translateY(1px);
}
#saveRecBtn.btn:focus-visible {
  outline: 2px solid rgba(92, 107, 170, 0.55);
  outline-offset: 2px;
}

/* Record: 保存/初期化（refresh）ボタンの横幅を統一（端末フォント差でズレないよう固定幅） */
#saveRecBtn.btn,
#refreshRecBtn.btn {
  width: calc(3.12em + 24px);
  white-space: nowrap;
  box-sizing: border-box;
}

/* アイコン色固定 */
a.btn.icon-btn,
a.btn.icon-btn:link,
a.btn.icon-btn:visited,
a.btn.icon-btn:hover,
a.btn.icon-btn:active {
  color: var(--icon-fg) !important;
}

/* ===== 更新トースト ===== */
#updateToast {
  position: fixed;
  left: 0;
  right: 0;
  bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: flex;
  justify-content: center;
  z-index: 10000;
  pointer-events: none;
}
#updateToast[hidden] { display: none !important; }
#updateToast .card {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  box-shadow: 0 10px 24px rgba(0, 0, 0, .18);
}
#updateToast .item__meta { margin-right: 8px; }
#updateToast .actions { margin-left: auto; display: flex; gap: 8px; }

#updateToast:not([hidden]) .card { animation: toast-in .24s ease-out; }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(8px) scale(0.98); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}
#updateToast.is-leaving .card { animation: toast-out .18s ease-in forwards; }
@keyframes toast-out {
  from { opacity: 1; transform: translateY(0) scale(1); }
  to   { opacity: 0; transform: translateY(6px) scale(0.98); }
}
@media (max-width: 560px) {
  #updateToast { padding: 0 8px; }
  #updateToast .card { width: 100%; }
  #updateToast .item__meta { flex: 1 1 auto; }
}

/* ===== ファイル名が長い場合のレイアウト対策 ===== */
.item { align-items: flex-start; }

.item__left { flex: 1 1 auto; min-width: 0; }
.item__right {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 120px;
}
.item__title {
  display: block;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.detail-filename {
  word-break: break-all;
  overflow-wrap: anywhere;
  white-space: normal;
}

/* ===== mp3変換ボタン ===== */
.btn.btn-mp3convert {
  background: transparent;
  border-color: var(--danger-border);
  color: var(--danger);
}
.btn.btn-mp3convert:hover { filter: brightness(1.05); }
.btn.btn-mp3convert:active { transform: translateY(1px); }
.btn.btn-mp3convert:disabled {
  opacity: 0.45;
  filter: grayscale(1);
  border-color: var(--border);
  color: var(--muted);
}

/* ===== 処理中ダイアログ ===== */
.hidden { display: none !important; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 20000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(2px);
}
.modal-card {
  width: min(92vw, 520px);
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
  padding: 0;
}
.modal-body {
  padding: 16px 18px;
  line-height: 1.6;
}

/* =========================================================
   ★Record: スマホはカスタム再生UI（「0:00のみ」）
   - PC: <audio controls> をそのまま表示
   - Mobile: controls を外し、#previewUi を表示
   ========================================================= */
.preview-wrap { width: 100%; }

#previewAudio {
  width: 100%;
  display: block;
  min-height: 52px;
}

/* ★開始前（srcなし時）の見た目 */
#previewAudio.is-inactive {
  opacity: 0.55;
  filter: grayscale(1);
  pointer-events: none;
}

/* スマホモード（JSが #previewWrap に mobile-preview を付与） */
#previewWrap.mobile-preview #previewAudio {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

#previewUi {
  width: 100%;
  border-radius: 9999px;
  padding: 4px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(0,0,0,.04);
}
:root.dark #previewUi {
  background: rgba(255,255,255,.08);
}

#previewWrap.mobile-preview #previewUi[hidden] { display: none !important; }

.preview-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  width: 40px;
  height: 40px;
  border-radius: 9999px;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.preview-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.preview-curtime {
  font-variant-numeric: tabular-nums;
  min-width: 5ch; /* 00:00 */
  color: var(--muted);
}

.preview-seek {
  flex: 1 1 auto;
  min-width: 120px;
}

.mt-12:has(> #vuMeter){
  display: flex;
  align-items: center;
  gap: 10px;
}

/* バーを伸ばす */
.mt-12:has(> #vuMeter) > #vuMeter{
  flex: 1 1 auto;
  min-width: 0;
}

/* タイマーは縮まない */
.mt-12:has(> #vuMeter) > #recTimer{
  flex: 0 0 auto;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

#previewMuteBtn{
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

#previewWrap.mobile-preview .preview-ui { display:flex; }
#previewWrap:not(.mobile-preview) #previewUi { display:none !important; }


/* ===== Inline Player (Home row) ===== */
.m-inline-player{
  margin-top: 8px;
}

.m-inline-player__viz{
  display:block;
  width:100%;
  height:28px;        /* ここが0だと「見えない」 */
  border-radius: 6px; /* 任意（不要なら削除可） */
}

.m-inline-player__controls{
  display:flex;
  align-items:center;
  gap:10px;
  margin-top: 6px;
}

.m-inline-player__seek{
  flex: 1 1 auto;
  min-width: 0;
}

.m-inline-player__mute{
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  padding: 0 6px;     /* タップ領域は確保 */
  line-height: 1;
  font-size: 22px;
}

/* fix: show custom preview UI on PC too */
#previewWrap #previewUi {
  display: flex !important;
}
/* ===== App Dialog (uiConfirm/uiAlert) =====
 * ダークモード時：confirm の「キャンセル」文字が見えづらい対策
 * - OK ボタン（.appDialogBtnPrimary）は対象外
 */
:root.dark .appDialogBtn:not(.appDialogBtnPrimary) {
  color: #000000 !important;
}