:root {
  --bg: #ffffff;
  --bg-side: #f6f7f8;
  --bg-hover: #eceef1;
  --bg-active: #e3e6ea;
  --text: #111827;
  --muted: #6b7280;
  --line: #e5e7eb;
  --accent: #111827;
  --accent-text: #ffffff;
  --mark: #fff3bf;
  --tag-meeting: #2563eb;
  --tag-phone: #059669;
  --tag-call: #7c3aed;
  --tag-other: #6b7280;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #15171a;
    --bg-side: #1c1f23;
    --bg-hover: #25292e;
    --bg-active: #2d3238;
    --text: #e5e7eb;
    --muted: #9ca3af;
    --line: #2d3238;
    --accent: #e5e7eb;
    --accent-text: #111827;
    --mark: #5c4a00;
    --tag-meeting: #60a5fa;
    --tag-phone: #34d399;
    --tag-call: #a78bfa;
    --tag-other: #9ca3af;
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: "Noto Sans JP", -apple-system, BlinkMacSystemFont, sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}
[hidden] { display: none !important; }
.muted { color: var(--muted); }
button { font: inherit; color: inherit; }

.btn {
  display: inline-block;
  padding: 10px 20px;
  border-radius: 8px;
  background: var(--accent);
  color: var(--accent-text);
  text-decoration: none;
  font-weight: 500;
  border: 0;
  cursor: pointer;
}

/* ログイン */
.login { min-height: 100%; display: grid; place-items: center; padding: 16px; }
.login-card { text-align: center; max-width: 360px; }
.login-card h1 { font-size: 24px; margin: 12px 0 4px; }
.login-card p { color: var(--muted); margin: 0 0 24px; }

/* 2 画面（左: 一覧 / 右: 本文） */
.app { display: grid; grid-template-columns: 360px 1fr; height: 100vh; height: 100dvh; }
.app.with-ai { grid-template-columns: 320px 1fr 380px; }
.side { background: var(--bg-side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
.side-head { display: flex; align-items: center; flex-wrap: wrap; gap: 8px; padding: 18px 16px 8px; }
.side-head .ghost { padding: 3px 10px; white-space: nowrap; }
.side-head .ghost.on { background: var(--bg-active); }
.side-head h1 { font-size: 20px; margin: 0; white-space: nowrap; }
.side-head #count { white-space: nowrap; }
.search { padding: 0 16px 8px; }
.search input {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 15px;
}
.filters { display: flex; gap: 6px; padding: 0 16px 10px; flex-wrap: wrap; }
.chip {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 999px;
  padding: 2px 12px;
  font-size: 13px;
  cursor: pointer;
}
.chip.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }

.list { overflow-y: auto; flex: 1; padding-bottom: 24px; }
.day { font-size: 13px; color: var(--muted); padding: 14px 16px 4px; font-weight: 500; }
.item {
  display: block;
  padding: 10px 16px;
  text-decoration: none;
  color: inherit;
  border-left: 3px solid transparent;
}
.item:hover { background: var(--bg-hover); }
.item.on { background: var(--bg-active); border-left-color: var(--accent); }
.item .t { font-weight: 500; line-height: 1.5; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.item .m { font-size: 13px; color: var(--muted); display: flex; gap: 8px; align-items: center; margin-top: 2px; }
.tag { font-size: 12px; font-weight: 500; }
.tag.meeting { color: var(--tag-meeting); }
.tag.phone { color: var(--tag-phone); }
.tag.call { color: var(--tag-call); }
.tag.other { color: var(--tag-other); }
.todo-badge { font-size: 12px; }
.none { padding: 24px 16px; color: var(--muted); }

/* 本文 */
.detail { overflow-y: auto; min-width: 0; }
.empty { display: grid; place-items: center; height: 100%; padding: 16px; }
.doc { max-width: 820px; margin: 0 auto; padding: 32px 40px 80px; }
.back { display: none; margin-bottom: 12px; text-decoration: none; color: var(--muted); }
.doc h1 { font-size: 26px; line-height: 1.4; margin: 0 0 6px; }
.doc .when { color: var(--muted); margin-bottom: 14px; display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.grow { flex: 1; }
.small { font-size: 13px; }
.toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 20px; padding-bottom: 14px; border-bottom: 1px solid var(--line); }
.toolbar button, .ghost {
  border: 1px solid var(--line);
  background: var(--bg);
  border-radius: 6px;
  padding: 4px 12px;
  font-size: 14px;
  cursor: pointer;
}
.toolbar button:hover, .ghost:hover { background: var(--bg-hover); }
.toolbar button.on { background: var(--accent); color: var(--accent-text); border-color: var(--accent); }
.menu { position: relative; }
.menu-list {
  position: absolute; right: 0; top: calc(100% + 4px); z-index: 5;
  display: flex; flex-direction: column; min-width: 180px;
  background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 4px;
  box-shadow: 0 6px 20px rgb(0 0 0 / 0.12);
}
.menu-list button { border: 0; text-align: left; padding: 6px 10px; }

.banner {
  display: flex; gap: 8px; align-items: center; flex-wrap: wrap;
  padding: 10px 14px; margin-bottom: 20px; border-radius: 8px;
  background: var(--bg-side); border: 1px solid var(--line); font-size: 14px;
}
.banner.ai { border-color: var(--tag-call); }
.banner .btn { padding: 4px 14px; font-size: 14px; }

.editor {
  width: 100%; min-height: 60vh; resize: vertical;
  font: 15px/1.7 ui-monospace, SFMono-Regular, Menlo, monospace;
  color: var(--text); background: var(--bg-side);
  border: 1px solid var(--line); border-radius: 8px; padding: 14px;
}
.edit-actions { display: flex; gap: 10px; align-items: center; margin-top: 12px; flex-wrap: wrap; }
.edit-actions .btn { padding: 6px 20px; }

#history-list { margin-bottom: 20px; display: flex; flex-direction: column; gap: 4px; }
.version {
  display: flex; gap: 12px; text-align: left; border: 1px solid var(--line); background: var(--bg);
  border-radius: 6px; padding: 6px 12px; cursor: pointer; font-size: 14px;
}
.version:hover { background: var(--bg-hover); }

/* AI パネル */
.ai { border-left: 1px solid var(--line); background: var(--bg-side); display: flex; flex-direction: column; min-height: 0; }
.ai-head { display: flex; align-items: center; padding: 14px 16px; border-bottom: 1px solid var(--line); }
.ai-head .ghost { padding: 0 10px; font-size: 18px; line-height: 1.6; }
.ai-head .ghost.small { font-size: 13px; padding: 2px 10px; margin-right: 4px; }
.ai-scope { padding: 8px 16px; border-bottom: 1px solid var(--line); }
.ai-log { flex: 1; overflow-y: auto; padding: 14px 16px; display: flex; flex-direction: column; gap: 10px; }
.msg { padding: 8px 12px; border-radius: 10px; white-space: pre-wrap; font-size: 15px; max-width: 92%; }
.msg.user { align-self: flex-end; background: var(--accent); color: var(--accent-text); }
.msg.assistant { align-self: flex-start; background: var(--bg); border: 1px solid var(--line); }
.hint { line-height: 1.8; }
.msg a.ref { color: inherit; font-weight: 700; text-decoration: underline; text-underline-offset: 3px; }
.msg a.ref .d { font-weight: 400; color: var(--muted); margin-left: 4px; font-size: 13px; }
.proposals { align-self: flex-start; display: flex; flex-direction: column; gap: 6px; max-width: 92%; }
.proposal {
  display: flex; flex-direction: column; align-items: flex-start; gap: 2px; text-align: left; cursor: pointer;
  border: 1px solid var(--tag-call); background: var(--bg); color: var(--text); border-radius: 10px; padding: 8px 12px; font-size: 14px;
}
.proposal:hover { background: var(--bg-hover); }
.proposal .k { color: var(--tag-call); font-size: 12px; }
.ai-form { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.ai-form textarea {
  font: inherit; font-size: 15px; resize: none; padding: 8px 10px; border-radius: 8px;
  border: 1px solid var(--line); background: var(--bg); color: var(--text);
}
.ai-form .btn { align-self: flex-end; padding: 6px 20px; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%); z-index: 20;
  background: var(--accent); color: var(--accent-text); padding: 8px 16px; border-radius: 8px; font-size: 14px;
  max-width: calc(100% - 32px);
}
.body h2 { font-size: 19px; margin: 32px 0 8px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.body h3 { font-size: 16px; margin: 20px 0 6px; }
.body p { margin: 0 0 12px; }
.body ul { padding-left: 1.4em; margin: 0 0 12px; }
.body li { margin: 3px 0; }
.body li:has(> input[type="checkbox"]) { list-style: none; margin-left: -1.4em; }
.body input[type="checkbox"] { margin-right: 6px; }
.body a { color: inherit; }
.body code { font-size: 14px; background: var(--bg-side); padding: 1px 4px; border-radius: 4px; }
mark { background: var(--mark); color: inherit; border-radius: 2px; }

details.transcript { margin-top: 32px; border-top: 1px solid var(--line); padding-top: 12px; }
details.transcript summary { cursor: pointer; font-size: 19px; font-weight: 700; padding: 8px 0; }
details.transcript .body { font-size: 15px; }

/* スマホ: 一覧と本文を切り替える。AI パネルは下から出す */
@media (max-width: 760px) {
  .app, .app.with-ai { grid-template-columns: 1fr; }
  .ai { position: fixed; left: 0; right: 0; bottom: 0; height: 62dvh; z-index: 10; border-left: 0; border-top: 1px solid var(--line); border-radius: 14px 14px 0 0; box-shadow: 0 -8px 24px rgb(0 0 0 / 0.15); }
  .toolbar button { font-size: 13px; padding: 4px 10px; }
  .app.reading .side { display: none; }
  .app:not(.reading) .detail { display: none; }
  .side { border-right: 0; }
  .doc { padding: 16px 16px 64px; }
  .back { display: inline-block; }
  .doc h1 { font-size: 22px; }
}

/* PDF（印刷）: 一覧・ボタン・AI パネルを消して本文だけ。文字起こしは選んだときだけ */
@media print {
  @page { margin: 16mm 14mm; }
  body { background: #fff; color: #000; font-size: 11pt; }
  .side, .ai, .toolbar, .banner, .back, #history-list, .toast { display: none !important; }
  .app, .app.with-ai { display: block; height: auto; }
  .detail { overflow: visible; }
  .doc { max-width: none; padding: 0; }
  .doc h1 { font-size: 18pt; }
  .tag { color: #000 !important; }
  .body h2 { break-after: avoid; border-color: #ccc; }
  .body li, .body p { break-inside: avoid; }
  details.transcript { display: none; }
  .print-transcript details.transcript { display: block; break-before: page; }
  details.transcript summary { list-style: none; }
}

/* 録音のアップロード */
.upload { border: 1px solid var(--line); border-radius: 12px; padding: 0; width: min(440px, calc(100% - 32px)); background: var(--bg); color: var(--text); }
.upload::backdrop { background: rgb(0 0 0 / 0.35); }
.upload form { padding: 20px; display: flex; flex-direction: column; gap: 12px; }
.upload h2 { margin: 0; font-size: 18px; }
.upload p { margin: 0; }
.field { display: flex; flex-direction: column; gap: 4px; font-size: 14px; font-weight: 500; }
.field input {
  font: inherit; font-weight: 400; font-size: 16px; padding: 8px 10px;
  border: 1px solid var(--line); border-radius: 8px; background: var(--bg-side); color: var(--text);
}
.progress { height: 6px; background: var(--bg-side); border-radius: 3px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--accent); transition: width 0.2s; }
.error { color: #dc2626; }
.uploads { padding: 6px 16px 4px; display: flex; flex-direction: column; gap: 6px; }
.up { border: 1px dashed var(--line); border-radius: 8px; padding: 8px 10px; font-size: 14px; background: var(--bg); }
.up .t { font-weight: 500; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.up .m { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: center; color: var(--muted); font-size: 13px; }
.up .m .s { flex: 1 1 100%; order: -1; }
.up .m button { border: 0; background: none; color: var(--muted); text-decoration: underline; cursor: pointer; padding: 0; font-size: 13px; }
.up.error .s { color: #dc2626; }

/* 録音・ファイル・AI のボタン */
.actions { display: flex; gap: 8px; padding: 0 16px 12px; flex-wrap: wrap; }
.actions .ghost { padding: 8px 14px; }
.btn.rec { display: inline-flex; align-items: center; gap: 8px; }
.btn.rec .dot { width: 10px; height: 10px; border-radius: 50%; background: #ef4444; }
#record-open.live .dot, #record.live .rec-time { animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: 0.35; } }
@media (prefers-reduced-motion: reduce) { #record-open.live .dot, #record.live .rec-time { animation: none; } }
a.ghost { text-decoration: none; display: inline-block; color: inherit; }
.rec-panel { padding: 20px; display: flex; flex-direction: column; gap: 14px; }
.rec-panel h2 { margin: 0; font-size: 18px; }
.rec-panel p { margin: 0; }
.rec-time { font-size: 44px; font-weight: 500; text-align: center; font-variant-numeric: tabular-nums; letter-spacing: 0.02em; }
.rec-level { height: 4px; background: var(--bg-side); border-radius: 2px; overflow: hidden; }
.rec-level div { height: 100%; width: 0; background: #ef4444; transition: width 0.08s linear; }

/* 本文の補助 */
.when .private { color: var(--tag-call); font-weight: 500; }
.menu-list .danger { color: #dc2626; }

/* 設定・運営 */
.platform { max-width: 820px; margin: 0 auto; padding: 16px; }
.settings section { margin: 28px 0; }
.settings h2 { font-size: 17px; margin: 0 0 12px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.form { display: flex; flex-direction: column; gap: 12px; }
.form textarea, .form input, .form select, .table select, .num {
  padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: var(--bg); color: var(--text); font: inherit; font-size: 15px;
}
.form.inline { flex-direction: row; flex-wrap: wrap; margin-top: 12px; }
.form.inline input[type="email"] { flex: 2 1 220px; }
.form.inline input[name="name"] { flex: 1 1 120px; }
.form .btn, .form.inline .btn { padding: 8px 20px; }
.table { width: 100%; border-collapse: collapse; }
.table th { text-align: left; font-size: 13px; font-weight: 500; color: var(--muted); padding: 4px 8px; }
.table td { padding: 10px 8px; border-top: 1px solid var(--line); vertical-align: middle; }
.table .r { text-align: right; white-space: nowrap; }
.table tr.off td { opacity: 0.5; }
.num { width: 90px; text-align: right; padding: 4px 8px; }
.stat { display: flex; gap: 12px; align-items: baseline; }
.stat strong { font-size: 28px; font-weight: 500; }
.row { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.side-head #tenant-name { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
