:root {
  color-scheme: light;
  --bg: #fbf7f5;
  --surface: #ffffff;
  --ink: #2f2a28;
  --muted: #7a706b;
  --line: #ece3de;
  --accent: #d9577a;
  --accent-ink: #ffffff;
  --accent-soft: #fbe8ee;
  --warn: #b5541c;
  --warn-soft: #fdf0e6;
  --ok: #2f7d5b;
  --ok-soft: #e6f4ed;
  --radius: 14px;
  --shadow: 0 1px 2px rgba(60, 40, 30, .06), 0 4px 16px rgba(60, 40, 30, .06);
  font-family: "Hiragino Sans", "Hiragino Kaku Gothic ProN", "BIZ UDPGothic", "Yu Gothic UI", "Meiryo", sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--ink); font-size: 16px; line-height: 1.6; }
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }

.demo-ribbon { background: #3b3330; color: #fff; text-align: center; font-size: 12px; padding: 4px 16px; letter-spacing: .04em; }

.app-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; flex-wrap: wrap; padding: 14px 20px; background: var(--surface); border-bottom: 1px solid var(--line); }
.brand { display: flex; align-items: center; gap: 10px; }
.brand-mark { font-size: 28px; }
.brand-name { font-weight: 700; font-size: 18px; }
.brand-sub { font-size: 12px; color: var(--muted); }
.who { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); }
.who select { padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); color: var(--ink); font-size: 15px; }

.tabs { display: flex; gap: 4px; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); overflow-x: auto; }
.tab { border: 0; background: none; padding: 14px 14px 12px; font-weight: 600; color: var(--muted); border-bottom: 3px solid transparent; white-space: nowrap; }
.tab.is-active { color: var(--accent); border-bottom-color: var(--accent); }

main { max-width: 860px; margin: 0 auto; padding: 20px 16px 120px; }
.view { display: none; }
.view.is-active { display: block; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px 18px; }
h2 { font-size: 18px; margin: 0 0 12px; }
h3 { font-size: 15px; margin: 18px 0 8px; }
.muted { color: var(--muted); font-size: 13px; }

.toolbar { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 10px; }
.date-row { display: flex; gap: 8px; }
.toolbar input { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.toolbar input[type=search] { flex: 1; min-width: 200px; }

.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; padding: 6px 14px; font-size: 14px; }
.chip.is-active { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }

.btn-primary { background: var(--accent); color: var(--accent-ink); border: 0; border-radius: 10px; padding: 10px 18px; font-weight: 700; }
.btn-primary:disabled { opacity: .5; }
.btn-ghost { background: var(--surface); border: 1px solid var(--line); border-radius: 10px; padding: 9px 14px; }
.small { padding: 6px 12px; font-size: 14px; }

.notes { display: grid; gap: 12px; }
.note.is-important { border-left: 5px solid #d33; }
.note-head { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.note-time { margin-left: auto; font-size: 13px; color: var(--muted); }
.note-body { margin: 10px 0; font-size: 16px; }
.note-foot { display: flex; justify-content: space-between; align-items: center; gap: 8px; flex-wrap: wrap; }
.note-actions { display: flex; gap: 8px; }
.readers { font-size: 12px; color: var(--muted); }
.btn-read { border: 1px solid var(--ok); color: var(--ok); background: var(--surface); border-radius: 10px; }
.btn-read.is-read { background: var(--ok-soft); }
.empty { color: var(--muted); text-align: center; padding: 30px 0; }

.badge { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; background: #eee; }
.badge-important { background: #d33; color: #fff; }
.c-pickup { background: #e4efff; color: #2456a6; }
.c-meal { background: #fff3d6; color: #8a5a00; }
.c-bath { background: #dff5f5; color: #13706f; }
.c-health { background: #fde4e4; color: #a32b2b; }
.c-info { background: #ecebf6; color: #4a4385; }
.chip.c-pickup.is-active, .chip.c-meal.is-active, .chip.c-bath.is-active, .chip.c-health.is-active, .chip.c-info.is-active { background: var(--accent); color: #fff; }

.form fieldset { border: 0; padding: 0; margin: 0 0 8px; }
.form legend { font-weight: 600; margin-bottom: 6px; }
.field { display: grid; gap: 6px; margin: 12px 0; }
.field span { font-weight: 600; font-size: 14px; }
.field input, .field select, .field textarea { width: 100%; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--surface); }
.check { display: flex; gap: 8px; align-items: center; margin: 6px 0; }
.check input { width: 20px; height: 20px; }
.hint { font-size: 13px; color: var(--muted); margin: 0 0 12px; }
.form-actions { display: flex; gap: 10px; flex-wrap: wrap; }

.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 640px) { .stats-grid { grid-template-columns: 1fr; } }
.bars { list-style: none; padding: 0; margin: 0; display: grid; gap: 8px; }
.bars li { display: grid; grid-template-columns: 1fr 90px 44px; align-items: center; gap: 8px; font-size: 14px; }
.bar { height: 10px; background: var(--accent-soft); border-radius: 999px; overflow: hidden; }
.bar span { display: block; height: 100%; background: var(--accent); border-radius: 999px; }
.bars-warn .bar { background: var(--warn-soft); }
.bars-warn .bar span { background: var(--warn); }
.bar-count { text-align: right; color: var(--muted); font-size: 13px; }
.link { background: none; border: 0; padding: 0; text-align: left; color: var(--ink); text-decoration: underline dotted; text-underline-offset: 3px; }
.link:disabled { text-decoration: none; cursor: default; }
.recent { list-style: none; padding: 0; margin: 0; }
.recent li { display: flex; gap: 10px; align-items: baseline; flex-wrap: wrap; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.recent-time { color: var(--muted); font-size: 12px; min-width: 76px; font-variant-numeric: tabular-nums; }
.recent-q { flex: 1; min-width: 160px; }
.tag { font-size: 12px; padding: 1px 8px; border-radius: 999px; background: var(--accent-soft); color: #9c2f4f; }
.tag-warn { background: var(--warn-soft); color: var(--warn); }
.tag-sample { background: #eee; color: #666; }
.settings { margin-top: 16px; }
.settings summary { cursor: pointer; font-weight: 600; }

/* ---------- 使い方ヘルプ ---------- */
.help-fab { position: fixed; right: 20px; bottom: 20px; z-index: 20; background: var(--accent); color: #fff; border: 0; border-radius: 999px; padding: 14px 22px; font-size: 17px; font-weight: 700; box-shadow: 0 6px 20px rgba(217, 87, 122, .4); }
.help-panel { position: fixed; right: 20px; bottom: 20px; z-index: 30; width: min(420px, calc(100vw - 32px)); height: min(680px, calc(100vh - 40px)); background: var(--surface); border-radius: 18px; box-shadow: 0 12px 40px rgba(40, 20, 10, .25); display: flex; flex-direction: column; overflow: hidden; }
@media (max-width: 520px) { .help-panel { right: 16px; bottom: 16px; height: calc(100vh - 32px); } }
.help-head { display: flex; justify-content: space-between; align-items: center; padding: 12px 16px; background: var(--accent); color: #fff; }
.help-title { font-weight: 700; font-size: 17px; }
.help-mode { font-size: 12px; opacity: .95; }
.icon-btn { background: none; border: 0; color: inherit; font-size: 24px; line-height: 1; padding: 4px 8px; }
.help-log { flex: 1; overflow-y: auto; padding: 14px; background: var(--bg); display: flex; flex-direction: column; gap: 12px; }
.msg { max-width: 88%; display: flex; flex-direction: column; gap: 4px; }
.msg-user { align-self: flex-end; align-items: flex-end; }
.msg-bot { align-self: flex-start; }
.bubble { padding: 10px 14px; border-radius: 16px; background: var(--surface); border: 1px solid var(--line); white-space: pre-wrap; word-break: break-word; }
.msg-user .bubble { background: var(--accent-soft); border-color: #f4c9d6; }
.line.step { padding-left: 1.2em; text-indent: -1.2em; }
.msg-time { font-size: 11px; color: var(--muted); }
.mask-done { font-size: 12px; color: var(--ok); background: var(--ok-soft); border-radius: 8px; padding: 4px 8px; }
.is-handoff .bubble { background: var(--warn-soft); border-color: #f2d2bb; }
.handoff-label { font-size: 12px; font-weight: 700; color: var(--warn); }
.sources { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.sources-label { font-size: 12px; color: var(--muted); width: 100%; }
.source { font-size: 13px; border: 1px solid #f4c9d6; background: var(--surface); color: #9c2f4f; border-radius: 999px; padding: 3px 10px; }
.typing .bubble { color: var(--muted); font-style: italic; }
.help-suggest { display: flex; flex-wrap: wrap; gap: 6px; padding: 0 14px 8px; background: var(--bg); }
.suggest { font-size: 13px; border: 1px dashed #e7a9bb; background: var(--surface); border-radius: 999px; padding: 4px 10px; }
.help-form { border-top: 1px solid var(--line); padding: 10px 12px 8px; background: var(--surface); }
.pii-note { margin: 0 0 6px; font-size: 12px; color: var(--warn); font-weight: 600; }
.mask-preview { margin-bottom: 6px; padding: 6px 10px; border-radius: 8px; background: var(--ok-soft); font-size: 12px; }
.mask-title { color: var(--ok); font-weight: 700; }
.mask-text { color: var(--ink); }
.help-input-row { display: flex; gap: 8px; align-items: flex-end; }
.help-input-row textarea { flex: 1; resize: none; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; }
.help-meta { display: flex; justify-content: space-between; font-size: 11px; color: var(--muted); margin-top: 4px; }
.is-over { color: #d33; font-weight: 700; }

/* ---------- マニュアル表示 ---------- */
.modal { position: fixed; inset: 0; z-index: 40; background: rgba(30, 20, 15, .45); display: grid; place-items: center; padding: 16px; }
.modal-box { background: var(--surface); border-radius: 16px; width: min(720px, 100%); max-height: calc(100vh - 32px); display: flex; flex-direction: column; overflow: hidden; }
.modal-head { display: flex; justify-content: space-between; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.modal-title { font-weight: 700; }
.modal-body { overflow-y: auto; padding: 8px 20px 20px; }
.md h3 { font-size: 15px; color: var(--muted); margin: 12px 0 0; }
.md h4 { font-size: 18px; margin: 4px 0 8px; color: var(--accent); }
.md .when { font-size: 13px; color: var(--muted); background: var(--bg); padding: 4px 10px; border-radius: 8px; }
.md table { border-collapse: collapse; width: 100%; font-size: 14px; margin: 8px 0; }
.md th, .md td { border: 1px solid var(--line); padding: 6px 8px; text-align: left; }
.md th { background: var(--bg); }
