/* ボイスメモ要約アプリ：スマホ（幅375px）を最優先。ダークモード対応 */
:root {
  color-scheme: light dark;
  --bg: #f4f6fa; --card: #fff; --text: #1f2937; --muted: #6b7280; --line: #e5e7eb;
  --input-bg: #fff; --input-line: #d1d5db;
  --primary: #2563eb; --primary-dark: #1d4ed8; --on-primary: #fff;
  --danger: #dc2626; --danger-line: #fecaca;
  --warn-bg: #fef3c7; --warn: #92400e;
  --err-bg: #fee2e2; --err: #991b1b;
  --ok-bg: #dcfce7; --ok: #166534;
  --blue-bg: #dbeafe; --blue: #1e40af;
  --chip-bg: #eef2ff; --chip: #3730a3;
  --track: #e5e7eb; --hl: #fef08a; --press: #f3f4f6;
  --toast-bg: #111827; --toast: #fff;
  --nav-h: 56px; --radius: 12px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0f1115; --card: #1b1f27; --text: #e5e7eb; --muted: #9ca3af; --line: #2d333d;
    --input-bg: #12151b; --input-line: #3b4350;
    --primary: #3b82f6; --primary-dark: #2563eb; --on-primary: #fff;
    --danger: #f87171; --danger-line: #5b2323;
    --warn-bg: #3a2e0c; --warn: #fcd34d;
    --err-bg: #3b1515; --err: #fca5a5;
    --ok-bg: #12301d; --ok: #86efac;
    --blue-bg: #1e3a5f; --blue: #bfdbfe;
    --chip-bg: #26304d; --chip: #c7d2fe;
    --track: #2d333d; --hl: #4a4310; --press: #262b35;
    --toast-bg: #e5e7eb; --toast: #111827;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; background: var(--bg); color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic UI", Meiryo, sans-serif;
  font-size: 16px; line-height: 1.6;
  -webkit-tap-highlight-color: transparent;
}
a { color: var(--primary); text-decoration: none; }
h1 { font-size: 1.35rem; margin: 0 0 .6rem; line-height: 1.4; word-break: break-word; }
h2 { font-size: 1.05rem; margin: 1.3rem 0 .5rem; }
h3 { font-size: .95rem; margin: .8rem 0 .2rem; color: var(--muted); }
p { margin: .4rem 0; }
.muted { color: var(--muted); }
.small { font-size: .85rem; }
.pre { white-space: pre-wrap; word-break: break-word; }
.errtext { color: var(--err); }

/* レイアウト */
#view {
  max-width: 720px; margin: 0 auto;
  padding: 16px max(14px, env(safe-area-inset-right)) calc(var(--nav-h) + env(safe-area-inset-bottom) + 28px) max(14px, env(safe-area-inset-left));
}
body.tr-bar-on #view { padding-bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 92px); }
#tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; display: flex; background: var(--card); border-top: 1px solid var(--line);
  padding-bottom: env(safe-area-inset-bottom); z-index: 20;
}
#tabbar a {
  flex: 1; text-align: center; padding: 6px 0 4px; font-size: .72rem; color: var(--muted); min-height: var(--nav-h);
}
#tabbar a span { display: block; font-size: 1.3rem; line-height: 1.3; }
#tabbar a.active { color: var(--primary); font-weight: 700; }

/* 部品 */
.card { background: var(--card); border: 1px solid var(--line); border-radius: var(--radius); padding: 12px 14px; margin-bottom: 10px; }
.row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.row.between { justify-content: space-between; }
.grow { flex: 1 1 auto; min-width: 0; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px; min-height: 44px; padding: 8px 14px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); border-radius: 10px;
  font-size: .95rem; font-family: inherit; cursor: pointer; text-align: center;
}
.btn:active { background: var(--press); }
.btn.primary { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.btn.primary:active { background: var(--primary-dark); }
.btn.danger { color: var(--danger); border-color: var(--danger-line); }
.btn.sm { padding: 4px 10px; font-size: .85rem; }
.btn.block { display: flex; width: 100%; }
.btn.big { display: flex; width: 100%; min-height: 64px; font-size: 1.2rem; font-weight: 700; border-radius: 14px; margin: 8px 0 4px; }
.btn[disabled] { opacity: .5; pointer-events: none; }

label.f { display: block; margin: 14px 0 4px; font-size: .85rem; color: var(--muted); font-weight: 600; }
label.f .hint { font-weight: 400; }
.f-title { margin: 16px 0 6px; font-size: .9rem; font-weight: 700; }
input[type=text], input[type=password], input[type=date], input[type=search], select, textarea {
  width: 100%; min-height: 44px; padding: 8px 10px; border: 1px solid var(--input-line); border-radius: 8px;
  background: var(--input-bg); font: inherit; color: var(--text);
}
textarea { min-height: 90px; resize: vertical; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--primary); outline-offset: 0; border-color: var(--primary); }
input:disabled, textarea:disabled { opacity: .6; }
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; pointer-events: none; }

.chip { display: inline-block; padding: 1px 10px; border-radius: 999px; background: var(--chip-bg); color: var(--chip); font-size: .78rem; white-space: nowrap; flex: 0 0 auto; }
.chip.wait { background: var(--warn-bg); color: var(--warn); }
.chip.run { background: var(--blue-bg); color: var(--blue); }
.chip.done { background: var(--ok-bg); color: var(--ok); }
.chip.fail { background: var(--err-bg); color: var(--err); }

.banner { padding: 10px 12px; border-radius: 10px; margin: 10px 0; }
.banner.warn { background: var(--warn-bg); color: var(--warn); }
.banner.err { background: var(--err-bg); color: var(--err); }
.banner.ok { background: var(--ok-bg); color: var(--ok); }

.bar { height: 8px; background: var(--track); border-radius: 999px; overflow: hidden; margin: 8px 0 4px; }
.bar > div { height: 100%; background: var(--primary); transition: width .3s; }
.bar > .indeterminate { width: 35%; animation: slide 1.4s ease-in-out infinite; }
@keyframes slide { from { margin-left: -35%; } to { margin-left: 100%; } }

/* 録音カード */
.rec { display: block; color: inherit; }
.rec:active { background: var(--press); }
.rec .rt { font-weight: 700; word-break: break-word; }
.rec .top { flex-wrap: nowrap; align-items: flex-start; }
.rec .head { margin-top: 4px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; color: var(--text); }

/* 種類の選択 */
.kinds { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.kinds button {
  min-height: 52px; padding: 6px 8px; border: 2px solid var(--line); background: var(--card); color: var(--text);
  border-radius: 12px; font: inherit; font-size: .95rem; cursor: pointer;
}
.kinds button.on { border-color: var(--primary); background: var(--blue-bg); color: var(--blue); font-weight: 700; }
.kinds button[disabled] { opacity: .6; }
.filebtn { width: 100%; min-height: 56px; border-style: dashed; border-width: 2px; }
#s-fileinfo { margin: 6px 0; word-break: break-all; }

/* 詳細 */
.back { margin: 0 0 6px; }
.meta { margin-bottom: 8px; }
.tools { display: grid; grid-template-columns: repeat(auto-fit, minmax(92px, 1fr)); gap: 8px; margin: 10px 0; }
.sec h2 { margin: 0 0 6px; font-size: 1rem; }
.sec p { margin: 0; }
.sec.lead p { font-size: 1.05rem; line-height: 1.6; }
.sec.advice { border: 1px dashed var(--line); background: var(--bg); }
.sec.advice p.small { margin-bottom: 4px; }
.authcard { max-width: 420px; margin: 24px auto; }
.authcard h1 { font-size: 1.2rem; margin: 0 0 12px; }
#pass { font-family: ui-monospace, Consolas, monospace; letter-spacing: .03em; }
.sharepick-q { font-weight: 600; margin-bottom: 8px; }
.sharepick-btns { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 8px; }
.sharepick-btns .btn { min-height: 48px; }
.sec.prep { border-left: 4px solid var(--primary); }
.sec.prep .row.between { align-items: center; margin-bottom: 4px; }
.sec.prep h2 { margin: 0; }
.checklist { list-style: none; padding-left: 0; }
.checklist li { padding-left: 1.5em; position: relative; }
.checklist li::before { content: "□"; position: absolute; left: 0; }
details.sec.more > summary { margin: -4px 0 0; }
details.sec.more h3 { margin: 8px 0 2px; font-size: .95rem; }
.list { margin: .2rem 0; padding-left: 1.2rem; }
.list li { margin: 4px 0; word-break: break-word; }
.qa p { margin: 0 0 4px; word-break: break-word; }
.qa + .qa { border-top: 1px solid var(--line); padding-top: 8px; margin-top: 8px; }
.editbar { margin: 10px 0; }
.erow { border: 1px solid var(--line); border-radius: 10px; padding: 8px; margin-bottom: 8px; display: grid; gap: 6px; }
.erow textarea { min-height: 60px; }
.erow .btn { justify-self: end; }

/* 文字起こし */
details.card > summary { cursor: pointer; font-weight: 600; min-height: 44px; display: flex; align-items: center; }
.segment { display: inline-flex; border: 1px solid var(--input-line); border-radius: 10px; overflow: hidden; margin: 4px 0 8px; }
.segment button { border: 0; background: var(--card); color: var(--text); padding: 8px 14px; min-height: 44px; font: inherit; font-size: .9rem; cursor: pointer; }
.segment button.on { background: var(--primary); color: var(--on-primary); }
.seg { display: flex; gap: 6px; align-items: flex-start; padding: 2px 4px; border-radius: 8px; }
.seg .play {
  flex: 0 0 auto; min-width: 84px; min-height: 44px; border: 0; background: transparent; color: var(--primary);
  font: inherit; font-size: .85rem; font-variant-numeric: tabular-nums; text-align: left; cursor: pointer; padding: 0 4px;
}
.seg .time { flex: 0 0 auto; min-width: 84px; padding: 10px 4px 0; color: var(--muted); font-size: .85rem; font-variant-numeric: tabular-nums; }
.seg .stext { flex: 1 1 auto; min-width: 0; padding: 10px 0; word-break: break-word; }
.seg.changed .stext { text-decoration: underline dotted var(--muted); text-underline-offset: 4px; }
.seg.playing { background: var(--hl); }

/* 設定 */
.urlrow { display: flex; gap: 8px; align-items: center; margin: 8px 0 4px; }
.urlrow code { flex: 1 1 auto; min-width: 0; word-break: break-all; background: var(--press); padding: 8px 10px; border-radius: 8px; font-size: .9rem; }
.qr { display: inline-block; background: #fff; padding: 10px; border-radius: 10px; margin: 6px 0 10px; }
.qr svg { width: 180px; height: 180px; display: block; }
.switch { display: flex; justify-content: space-between; align-items: center; gap: 12px; min-height: 44px; cursor: pointer; }
.switch input[type=checkbox] {
  -webkit-appearance: none; appearance: none; flex: 0 0 auto; width: 52px; height: 32px; border-radius: 999px;
  background: var(--track); position: relative; margin: 0; cursor: pointer; transition: background .2s; border: 0;
}
.switch input[type=checkbox]::after {
  content: ""; position: absolute; top: 3px; left: 3px; width: 26px; height: 26px; border-radius: 50%; background: #fff; transition: left .2s;
  box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.switch input[type=checkbox]:checked { background: var(--primary); }
.switch input[type=checkbox]:checked::after { left: 23px; }
.trashrow { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.statusline { margin: 6px 0; }

/* 再生バー（画面下。ナビの上） */
#trbar {
  display: none; position: fixed; left: 0; right: 0; z-index: 25;
  bottom: calc(var(--nav-h) + env(safe-area-inset-bottom));
  background: var(--card); border-top: 1px solid var(--line); box-shadow: 0 -2px 8px rgba(0,0,0,.12);
  padding: 4px max(10px, env(safe-area-inset-right)) 4px max(10px, env(safe-area-inset-left));
  align-items: center; gap: 8px;
}
#trbar.on { display: flex; }
#trbar button { min-width: 44px; min-height: 44px; border: 0; background: transparent; color: var(--text); font-size: 1.2rem; cursor: pointer; }
#trtime { font-variant-numeric: tabular-nums; font-size: .9rem; }
#trname { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* トースト */
#toast {
  position: fixed; left: 50%; bottom: calc(var(--nav-h) + env(safe-area-inset-bottom) + 76px); transform: translateX(-50%) translateY(20px);
  background: var(--toast-bg); color: var(--toast); padding: 10px 16px; border-radius: 10px; max-width: calc(100vw - 32px);
  opacity: 0; pointer-events: none; transition: .2s; z-index: 50; font-size: .9rem;
}
#toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
#toast.err { background: #b91c1c; color: #fff; }
