/* AI受付デモ — 色と余白は DESIGN.md に合わせる */
:root {
  --ink: #0b1220;
  --navy: #0a1f5c;
  --royal: #0b4fd6;
  --sky: #2f8cff;
  --slate: #5b6475;
  --line: #d9dee7;
  --mist: #f3f5f9;
  --white: #fff;
  /* 架空の医院の色（医院サイトの部分だけで使う） */
  --clinic: #1d5246;
  --clinic-soft: #eef4f2;
  --font: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic UI", "Yu Gothic", "Noto Sans JP", "Noto Sans CJK JP", "IPAexGothic", "IPAGothic", sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body {
  font-family: var(--font);
  color: var(--ink);
  background: var(--mist);
  font-size: 15px;
  line-height: 1.7;
  font-feature-settings: "palt" 1;
  -webkit-font-smoothing: antialiased;
}
button { font: inherit; color: inherit; cursor: pointer; }
h1, h2, p { margin: 0; }
[hidden] { display: none !important; }

/* ---------- 上部バー ---------- */
.bar { background: var(--white); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.bar-inner { max-width: 1320px; margin: 0 auto; padding: 0 24px; height: 56px; display: flex; align-items: center; gap: 32px; }
.bar-brand { display: flex; align-items: center; gap: 12px; min-height: 44px; text-decoration: none; color: var(--ink); }
.bar-brand img { display: block; height: 22px; width: auto; }
.bar-title { font-weight: 700; font-size: 14px; padding-left: 12px; border-left: 1px solid var(--line); }
.tabs { display: flex; gap: 4px; height: 100%; }
.tab { border: 0; background: none; padding: 0 14px; height: 100%; font-size: 14px; color: var(--slate); position: relative; }
.tab[aria-selected="true"] { color: var(--ink); font-weight: 700; }
.tab[aria-selected="true"]::after { content: ""; position: absolute; left: 14px; right: 14px; bottom: -1px; height: 2px; background: var(--royal); }
.bar-note { margin-left: auto; font-size: 12px; color: var(--slate); }

.view { max-width: 1320px; margin: 0 auto; padding: 24px; }

/* ---------- 1. Web チャット ---------- */
#view-chat { display: grid; grid-template-columns: minmax(0, 1fr) 380px; grid-template-rows: auto auto; gap: 24px; align-items: start; }
.site { grid-column: 1; grid-row: 1; background: var(--white); border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.site-head { border-bottom: 1px solid var(--line); }
.site-head-inner { display: flex; align-items: center; justify-content: space-between; padding: 16px 32px; }
.site-logo { display: flex; align-items: center; gap: 10px; font-weight: 700; color: var(--clinic); letter-spacing: .02em; }
.site-logo-mark { width: 22px; height: 22px; border-radius: 50%; border: 5px solid var(--clinic); }
.site-nav { display: flex; gap: 24px; font-size: 13px; color: var(--slate); }
.site-tel { color: var(--clinic); font-weight: 700; font-variant-numeric: tabular-nums; }
.site-hero { display: grid; grid-template-columns: 1.35fr 1fr; gap: 48px; padding: 56px 32px 48px; background: var(--clinic-soft); }
.site-kicker { font-size: 13px; color: var(--clinic); font-weight: 700; margin-bottom: 16px; }
.site-hero h1 { font-size: 28px; line-height: 1.5; letter-spacing: .01em; margin-bottom: 16px; }
.site-lead { color: #3b4252; }
.site-hours { margin: 0; align-self: end; background: var(--white); border-radius: 6px; padding: 8px 20px; font-size: 13px; font-variant-numeric: tabular-nums; }
.site-hours > div { display: grid; grid-template-columns: 1.2fr 1fr 1fr; padding: 10px 0; border-bottom: 1px solid var(--line); }
.site-hours > div:last-child { border-bottom: 0; }
.site-hours dt { font-weight: 700; }
.site-hours dd { margin: 0; }
.site-hours-head { color: var(--slate); font-size: 12px; }
.site-hours-head dt { font-weight: 400; }
.site-hours .off dd { color: var(--slate); }
.site-cols { display: grid; grid-template-columns: repeat(3, 1fr); gap: 32px; padding: 40px 32px 48px; }
.site-cols h2 { font-size: 15px; margin-bottom: 8px; color: var(--clinic); }
.site-cols p, .site-list { font-size: 14px; color: #3b4252; }
.site-list { margin: 0; padding-left: 1.1em; }

.try { grid-column: 1; grid-row: 2; background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 20px; }
.try { display: grid; grid-template-columns: 200px 1fr; column-gap: 24px; }
.try h2 { font-size: 14px; }
.try > p:first-of-type { grid-column: 1; }
.try-list { grid-column: 2; grid-row: 1 / span 3; align-content: start; }
.try-note { grid-column: 1; }
.try > p { font-size: 13px; color: var(--slate); margin: 4px 0 12px; }
.try-list { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 8px; }
.try-list button { border: 1px solid var(--line); background: var(--white); border-radius: 999px; padding: 4px 12px; font-size: 13px; }
.try-list button:hover { border-color: var(--royal); color: var(--royal); }
.try-note { font-size: 12px; color: var(--slate); margin-top: 8px; }

.chat { grid-column: 2; grid-row: 1 / span 2; position: sticky; top: 80px; background: var(--white); border: 1px solid var(--line); border-radius: 8px; display: flex; flex-direction: column; height: calc(100vh - 104px); min-height: 520px; max-height: 760px; overflow: hidden; }
.chat-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; padding: 14px 16px; background: var(--clinic); color: var(--white); }
.chat-name { font-weight: 700; font-size: 14px; }
.chat-sub { font-size: 12px; opacity: .8; }
.chat-reset { border: 1px solid rgba(255,255,255,.4); background: none; color: var(--white); border-radius: 4px; padding: 2px 8px; min-height: 44px; font-size: 12px; white-space: nowrap; }
.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; background: #fafbfc; }
.msg { max-width: 86%; padding: 9px 13px; border-radius: 12px; font-size: 14px; line-height: 1.65; white-space: pre-line; animation: in .2s ease-out; }
.msg.bot { background: var(--white); border: 1px solid var(--line); border-top-left-radius: 4px; align-self: flex-start; }
.msg.me { background: var(--clinic); color: var(--white); border-top-right-radius: 4px; align-self: flex-end; }
.msg.note { align-self: stretch; max-width: none; background: none; border: 1px dashed var(--line); color: var(--slate); font-size: 12px; border-radius: 6px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; align-self: flex-start; max-width: 100%; animation: in .2s ease-out; }
.chips button { border: 1px solid var(--clinic); color: var(--clinic); background: var(--white); border-radius: 999px; padding: 3px 12px; min-height: 44px; font-size: 13px; }
.chips button:hover { background: var(--clinic-soft); }
.chips button:disabled { opacity: .45; cursor: default; }
.card { align-self: flex-start; width: 86%; border: 1px solid var(--line); border-radius: 8px; background: var(--white); font-size: 13px; animation: in .2s ease-out; }
.card dl { margin: 0; padding: 10px 14px; }
.card dl div { display: grid; grid-template-columns: 5em 1fr; padding: 3px 0; }
.card dt { color: var(--slate); }
.card dd { margin: 0; font-weight: 700; }
.card .card-act { display: flex; gap: 8px; padding: 10px 14px; border-top: 1px solid var(--line); }
.typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: var(--white); border: 1px solid var(--line); border-radius: 12px; border-top-left-radius: 4px; }
.typing i { width: 5px; height: 5px; border-radius: 50%; background: var(--slate); animation: blink 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
.chat-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.chat-form input { flex: 1; min-width: 0; border: 1px solid var(--line); border-radius: 6px; padding: 8px 12px; font: inherit; font-size: 14px; }
.chat-form input:focus { outline: 2px solid var(--clinic); outline-offset: -1px; border-color: transparent; }
.chat-form button, .btn { border: 0; background: var(--ink); color: var(--white); border-radius: 6px; padding: 8px 16px; font-size: 14px; font-weight: 700; }
.btn-line { border: 1px solid var(--line); background: var(--white); color: var(--ink); border-radius: 6px; padding: 6px 12px; font-size: 13px; }
.card .btn { background: var(--clinic); padding: 6px 14px; font-size: 13px; }

@keyframes in { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }
@keyframes blink { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }

/* ---------- 2. AI 電話 ---------- */
#view-call { display: grid; grid-template-columns: 280px minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.call-side, .call-main, .call-sheet { background: var(--white); border: 1px solid var(--line); border-radius: 8px; }
.call-side { padding: 20px; }
.call-side h2, .call-sheet h2 { font-size: 14px; margin-bottom: 12px; }
.scenarios { list-style: none; margin: 0 0 20px; padding: 0; display: grid; gap: 8px; }
.scenarios button { width: 100%; text-align: left; border: 1px solid var(--line); background: var(--white); border-radius: 6px; padding: 10px 12px; }
.scenarios button strong { display: block; font-size: 14px; }
.scenarios button span { display: block; font-size: 12px; color: var(--slate); line-height: 1.5; margin-top: 2px; }
.scenarios button[aria-pressed="true"] { border-color: var(--royal); box-shadow: inset 0 0 0 1px var(--royal); }
.voice-toggle { display: flex; gap: 8px; align-items: center; min-height: 44px; font-size: 13px; cursor: pointer; }
.voice-toggle input { margin: 0; flex-shrink: 0; }
.call-help { font-size: 12px; color: var(--slate); margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); }

.call-main { display: flex; flex-direction: column; min-height: 600px; }
.call-status { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.call-label { font-weight: 700; }
.call-label.live::before { content: ""; display: inline-block; width: 8px; height: 8px; border-radius: 50%; background: var(--royal); margin-right: 8px; vertical-align: 1px; animation: blink 1.2s infinite; }
.call-meta { font-size: 12px; color: var(--slate); }
.call-ctrl { display: flex; align-items: center; gap: 12px; }
.call-timer { font-variant-numeric: tabular-nums; color: var(--slate); font-size: 14px; }
.wave { height: 40px; display: flex; align-items: center; justify-content: center; gap: 3px; border-bottom: 1px solid var(--line); background: var(--mist); }
.wave i { width: 3px; height: 4px; border-radius: 2px; background: var(--line); transition: height .12s; }
.wave.ai i { background: var(--royal); }
.wave.caller i { background: var(--slate); }
.transcript { list-style: none; margin: 0; padding: 20px; display: flex; flex-direction: column; gap: 14px; overflow-y: auto; max-height: 520px; }
.transcript li { display: grid; grid-template-columns: 64px 1fr; gap: 12px; animation: in .2s ease-out; }
.transcript .who { font-size: 12px; color: var(--slate); padding-top: 2px; }
.transcript .ai .who { color: var(--royal); font-weight: 700; }
.transcript .text { font-size: 14px; }
.transcript .empty { display: block; color: var(--slate); font-size: 13px; }

.call-sheet { padding: 20px; }
.sheet { margin: 0; font-size: 13px; }
.sheet div { display: grid; grid-template-columns: 6em 1fr; padding: 8px 0; border-bottom: 1px solid var(--line); }
.sheet dt { color: var(--slate); }
.sheet dd { margin: 0; font-weight: 700; }
.sheet dd.fresh { animation: hl 1.2s ease-out; }
@keyframes hl { from { background: #e6efff; } to { background: transparent; } }
.sheet-result { margin-top: 16px; font-size: 13px; font-weight: 700; }
.sheet-result.done { color: var(--royal); }
.sheet-result.callback { color: var(--ink); }

/* ---------- 3. 管理画面 ---------- */
.admin-head { display: flex; justify-content: space-between; align-items: flex-end; margin-bottom: 20px; }
.admin-head h1 { font-size: 22px; }
.admin-date { font-size: 13px; color: var(--slate); }
.filter { display: flex; border: 1px solid var(--line); border-radius: 6px; overflow: hidden; background: var(--white); }
.filter button { border: 0; background: none; padding: 6px 14px; font-size: 13px; border-right: 1px solid var(--line); }
.filter button:last-child { border-right: 0; }
.filter button.on { background: var(--ink); color: var(--white); }
.kpis { display: grid; grid-template-columns: repeat(4, 1fr); background: var(--white); border: 1px solid var(--line); border-radius: 8px; margin-bottom: 24px; }
.kpi { padding: 18px 22px; border-right: 1px solid var(--line); }
.kpi:last-child { border-right: 0; }
.kpi p { font-size: 12px; color: var(--slate); }
.kpi strong { display: block; font-size: 30px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1.3; }
.kpi strong small { font-size: 14px; font-weight: 400; margin-left: 2px; }
.kpi.accent strong { color: var(--royal); }
.admin-grid { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 24px; align-items: start; }
.panel { background: var(--white); border: 1px solid var(--line); border-radius: 8px; padding: 20px; }
.panel h2 { font-size: 14px; margin-bottom: 12px; }
.panel h2.mt { margin-top: 28px; }
.panel-note { font-size: 12px; color: var(--slate); margin-top: 8px; }
.log { width: 100%; border-collapse: collapse; font-size: 13px; }
.log th { text-align: left; font-size: 12px; color: var(--slate); font-weight: 400; padding: 6px 8px; border-bottom: 1px solid var(--ink); white-space: nowrap; }
.log td { padding: 10px 8px; border-bottom: 1px solid var(--line); vertical-align: top; }
.log td:first-child { font-variant-numeric: tabular-nums; white-space: nowrap; }
.log td:nth-child(2), .log td:nth-child(3), .log td:nth-child(5) { white-space: nowrap; }
.log tr.new td { animation: hl 1.6s ease-out; }
.st { font-size: 12px; padding: 1px 8px; border-radius: 999px; border: 1px solid var(--line); }
.st.wait { border-color: var(--ink); font-weight: 700; }
.rules { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.rules li { display: flex; justify-content: space-between; gap: 8px; padding: 8px 0; border-bottom: 1px solid var(--line); }
.rules em { font-style: normal; font-size: 12px; color: var(--royal); border: 1px solid var(--royal); border-radius: 3px; padding: 0 5px; align-self: center; white-space: nowrap; }
.bars { display: flex; align-items: flex-end; gap: 6px; height: 120px; padding-top: 8px; }
.bars div { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; height: 100%; font-size: 12px; color: var(--slate); font-variant-numeric: tabular-nums; }
.bars span.b { width: 100%; background: #b9c3d3; border-radius: 2px 2px 0 0; }
.bars span.b.hi { background: var(--royal); }
.bars span.v { margin-bottom: 2px; }
.bars span.h { margin-top: 4px; }

/* ---------- 狭い画面 ---------- */
@media (max-width: 1080px) {
  .bar-note { display: none; }
  #view-chat, #view-call, .admin-grid { grid-template-columns: 1fr; }
  .site, .try, .chat { grid-column: 1; grid-row: auto; }
  .chat { position: static; height: 600px; }
  .try { grid-template-columns: 1fr; }
  .try-list { grid-column: 1; grid-row: auto; margin-top: 4px; }
  .site-hero { grid-template-columns: 1fr; gap: 24px; }
}
@media (max-width: 640px) {
  .bar-inner { gap: 12px; padding: 0 12px; }
  .bar-title { display: none; }
  .tab { padding: 0 8px; font-size: 13px; }
  .view { padding: 12px; }
  .call-status, .admin-head { flex-direction: column; align-items: flex-start; }
  .call-ctrl { width: 100%; justify-content: space-between; }
  .call-ctrl button, .filter button { white-space: nowrap; }
  .site-nav { display: none; }
  .site-head-inner, .site-hero, .site-cols { padding-left: 20px; padding-right: 20px; }
  .site-hero h1 { font-size: 22px; }
  .site-cols { grid-template-columns: 1fr; gap: 20px; }
  .kpis { grid-template-columns: repeat(2, 1fr); }
  .kpi:nth-child(2) { border-right: 0; }
  .kpi:nth-child(-n+2) { border-bottom: 1px solid var(--line); }
  .log td:nth-child(4) { min-width: 12em; }
  .panel { overflow-x: auto; }
}

/* ---------- 埋め込み型（chatbot.html） ---------- */
.embed { background: var(--white); }
.embed-page { max-width: 1120px; margin: 0 auto; padding: 24px 24px 96px; }
.site-full { border: 0; border-radius: 0; }
.site-band { display: grid; grid-template-columns: 1fr 1fr; gap: 32px; padding: 40px 32px; border-top: 1px solid var(--line); }
.site-band h2 { font-size: 15px; color: var(--clinic); margin-bottom: 8px; }
.site-band p { font-size: 14px; color: #3b4252; }
.embed .try { display: block; grid-column: auto; grid-row: auto; background: var(--mist); border: 0; }
.embed .try-list { margin-top: 4px; }
.site-foot { padding: 24px 32px; font-size: 12px; color: var(--slate); border-top: 1px solid var(--line); }
.embed .chat { position: fixed; right: 24px; bottom: 88px; width: 380px; height: min(620px, calc(100vh - 160px)); min-height: 0; max-height: none; top: auto; display: none; z-index: 20; box-shadow: 0 12px 32px rgba(11, 18, 32, .16); }
.embed .chat.open { display: flex; animation: in .2s ease-out; }
.chat-tools { display: flex; gap: 6px; }
.chat-close { border: 1px solid rgba(255,255,255,.4); background: none; color: var(--white); border-radius: 4px; padding: 2px 8px; font-size: 12px; white-space: nowrap; }
.launcher { position: fixed; right: 24px; bottom: 24px; z-index: 21; border: 0; background: var(--clinic); color: var(--white); font-weight: 700; font-size: 14px; border-radius: 999px; padding: 12px 22px; box-shadow: 0 6px 18px rgba(11, 18, 32, .18); }
.launcher[aria-expanded="true"] { background: var(--ink); }
@media (max-width: 640px) {
  .embed-page { padding: 12px 12px 88px; }
  .site-band { grid-template-columns: 1fr; padding: 28px 20px; }
  .embed .chat { left: 8px; right: 8px; width: auto; bottom: 80px; height: calc(100vh - 150px); }
}
