/* CAT AI の見た目: 白を基調にシンプルに。カメラまわりだけ暗い SF 調（スカウター風） */
:root {
  --bg: #f5f6f8; --card: #fff; --text: #14161b; --muted: #6b7280; --line: #e5e7eb;
  --accent: #0f9f84; --accent-soft: #e5f6f1; --scan: #7fe3c8; --dark: #0b0d12;
  --danger: #d93a3a; --radius: 16px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--bg); color: var(--text); -webkit-text-size-adjust: 100%; }
body { min-height: 100dvh; padding-bottom: calc(72px + var(--safe-b)); }
main { max-width: 640px; margin: 0 auto; padding: 8px 16px 24px; outline: none; }
h1 { font-size: 24px; margin: 12px 0 16px; letter-spacing: .01em; }
h2 { font-size: 18px; margin: 0 0 8px; }
h2.section { font-size: 15px; color: var(--muted); font-weight: 600; margin: 24px 4px 10px; }
h3 { font-size: 16px; margin: 0 0 8px; }
p { line-height: 1.6; }
a { color: var(--accent); text-decoration: none; }
.muted { color: var(--muted); }
.block { display: block; }

/* 上の帯 */
.top { position: sticky; top: 0; z-index: 5; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: rgba(245,246,248,.86); backdrop-filter: saturate(1.8) blur(14px); -webkit-backdrop-filter: saturate(1.8) blur(14px); }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; letter-spacing: .08em; }
.logo { width: 24px; height: 24px; border-radius: 7px; background: var(--dark) url(/icon.svg) center/cover; display: inline-block; }
.logo.big { width: 64px; height: 64px; border-radius: 18px; }
.icon-btn { border: 0; background: transparent; font-size: 22px; width: 40px; height: 40px; border-radius: 12px; color: var(--text); cursor: pointer; }
.icon-btn:active { background: var(--line); }

/* カード・ボタン・入力 */
.card { background: var(--card); border-radius: var(--radius); padding: 16px; box-shadow: 0 1px 2px rgba(0,0,0,.04); margin-bottom: 14px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px; padding: 0 18px; border-radius: 12px;
  border: 1px solid var(--line); background: var(--card); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
.btn.primary { background: var(--text); color: #fff; border-color: var(--text); }
.btn.small { min-height: 34px; padding: 0 12px; font-size: 14px; }
.btn.wide { width: 100%; }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.danger-outline { color: var(--danger); border-color: #f2c4c4; background: transparent; margin-top: 18px; }
.link { border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; padding: 4px; cursor: pointer; }
.link.danger { color: var(--danger); }
.form label, .auth label { display: grid; gap: 6px; margin-bottom: 14px; font-size: 14px; color: var(--muted); }
input, textarea, select { font: inherit; font-size: 16px; color: var(--text); width: 100%; padding: 11px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fbfbfc; }
input:focus, textarea:focus, select:focus { outline: 2px solid var(--accent-soft); border-color: var(--accent); }
textarea { resize: vertical; min-height: 64px; }
label.check { display: flex !important; align-items: flex-start; gap: 10px; color: var(--text) !important; }
label.check input { width: 22px; height: 22px; flex: none; margin-top: 2px; accent-color: var(--accent); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.actions { display: flex; gap: 10px; justify-content: flex-end; }
.form-error { color: var(--danger); min-height: 1em; margin: 0 0 10px; font-size: 14px; }
.badge { display: inline-block; font-size: 12px; font-weight: 600; color: var(--accent); background: var(--accent-soft); padding: 3px 10px; border-radius: 999px; margin: 0; }

/* ログイン */
.auth-wrap { padding-top: 12px; }
.hero { text-align: center; padding: 18px 0 10px; }
.hero h1 { margin: 10px 0 4px; letter-spacing: .1em; }
.hero p { color: var(--muted); margin: 0 auto; max-width: 320px; font-size: 14px; }
.auth .btn { width: 100%; }
.policy ul { margin: 0 0 12px; padding-left: 18px; font-size: 13px; color: var(--muted); line-height: 1.6; }
.policy li { margin-bottom: 4px; }
.swap { text-align: center; font-size: 14px; color: var(--muted); }
.lang-switch { display: flex; justify-content: center; gap: 6px; }
.lang-switch button { border: 1px solid var(--line); background: transparent; border-radius: 999px; padding: 6px 12px; font: inherit; font-size: 13px; color: var(--muted); cursor: pointer; }
.lang-switch button.on { background: var(--text); color: #fff; border-color: var(--text); }

/* ホーム: カメラ解析を一番大きく（スカウター風） */
.scan-card { display: flex; align-items: center; gap: 18px; padding: 26px 20px; border-radius: 22px; color: #fff; margin-top: 8px;
  background: radial-gradient(120% 140% at 0% 0%, #17322c 0%, var(--dark) 60%); box-shadow: 0 10px 30px rgba(11,13,18,.25); position: relative; overflow: hidden; }
.scan-card::after { content: ""; position: absolute; inset: 0; background: repeating-linear-gradient(0deg, rgba(127,227,200,.05) 0 1px, transparent 1px 4px); pointer-events: none; }
.scan-ring { width: 76px; height: 76px; border-radius: 50%; border: 2px solid var(--scan); display: grid; place-items: center; flex: none;
  box-shadow: 0 0 0 6px rgba(127,227,200,.12), inset 0 0 18px rgba(127,227,200,.25); }
.scan-ring .ti { background: var(--scan); }
.scan-text { display: grid; gap: 4px; }
.scan-text strong { font-size: 20px; letter-spacing: .04em; }
.scan-text span { color: #b9c2cf; font-size: 14px; }
.scan-text em { font-style: normal; font-size: 12px; color: var(--scan); }
.cat-strip { display: flex; gap: 14px; overflow-x: auto; padding: 4px 4px 8px; scrollbar-width: none; }
.cat-chip { display: grid; justify-items: center; gap: 6px; color: var(--text); font-size: 13px; min-width: 72px; }
.cat-chip.add { color: var(--muted); }
.empty-state { text-align: center; color: var(--muted); }

/* 猫のアイコン */
.avatar { border-radius: 50%; object-fit: cover; background: var(--accent-soft); color: var(--accent); display: inline-grid; place-items: center; font-weight: 700; flex: none; }
.avatar.md { width: 48px; height: 48px; font-size: 18px; }
.avatar.lg { width: 64px; height: 64px; font-size: 24px; }
.avatar.xl { width: 112px; height: 112px; font-size: 40px; }
.avatar.empty { border: 1px dashed #b7dfd3; }

/* 一覧 */
.title-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.list { padding: 4px 0; }
.row { display: flex; align-items: center; gap: 12px; padding: 10px 16px; color: var(--text); }
.row + .row { border-top: 1px solid var(--line); }
.row-main { display: grid; gap: 2px; flex: 1; min-width: 0; }
.row-main span { font-size: 13px; }
.chev { color: var(--muted); font-size: 22px; }

/* プロフィール */
.back { display: inline-block; margin: 8px 0 0; font-size: 15px; }
.profile-head { text-align: center; padding: 8px 0 4px; }
.profile-head h1 { margin: 10px 0 2px; }
.profile-head p { margin: 0 0 10px; }
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-grid figure { margin: 0; background: var(--card); border-radius: 12px; overflow: hidden; }
.photo-grid figure.is-avatar { outline: 2px solid var(--accent); }
.photo-grid img { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; }
.photo-grid figcaption { display: flex; justify-content: space-between; align-items: center; padding: 2px 4px; min-height: 30px; }
.photo-grid figcaption .badge { font-size: 11px; padding: 2px 8px; white-space: nowrap; }
.photo-grid figcaption .link { font-size: 12px; white-space: nowrap; padding: 4px 2px; }
.photo-add { aspect-ratio: 1; border: 1.5px dashed #c9ced6; border-radius: 12px; background: transparent; color: var(--muted); display: grid; place-content: center; gap: 2px; font: inherit; cursor: pointer; }
.photo-add span { font-size: 28px; line-height: 1; }
.info { margin-top: 16px; }
.info-row { padding: 10px 0; }
.info-row + .info-row { border-top: 1px solid var(--line); }
.info dt { font-size: 12px; color: var(--muted); margin-bottom: 2px; }
.info dd { margin: 0; white-space: pre-wrap; line-height: 1.5; }
.danger-zone h3 { color: var(--danger); }

/* 準備中の画面 */
.soon-card { text-align: center; padding: 36px 20px; margin-top: 16px; }
.soon-card p { color: var(--muted); }

/* 下のメニュー */
.tabs { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: grid; grid-template-columns: repeat(4, 1fr);
  padding: 6px 8px calc(6px + var(--safe-b)); background: rgba(255,255,255,.92); backdrop-filter: saturate(1.8) blur(14px); -webkit-backdrop-filter: saturate(1.8) blur(14px); border-top: 1px solid var(--line); }
.tabs[hidden] { display: none; }
.tabs a { display: grid; justify-items: center; gap: 3px; padding: 6px 0; color: var(--muted); font-size: 11px; font-weight: 600; }
.tabs a.active { color: var(--text); }
.tabs a.active .ti { background: var(--accent); }

/* アイコン（線画。色は background で変える） */
.ti { width: 24px; height: 24px; display: inline-block; background: currentColor; -webkit-mask: var(--i) center/contain no-repeat; mask: var(--i) center/contain no-repeat; }
.ti.big { width: 34px; height: 34px; }
.ti.muted { background: var(--muted); }
.ti-home { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'%3E%3Cpath d='M3 10.5 12 3l9 7.5V20a1 1 0 0 1-1 1h-5v-6h-6v6H4a1 1 0 0 1-1-1z'/%3E%3C/svg%3E"); }
.ti-camera { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'%3E%3Cpath d='M3 8a2 2 0 0 1 2-2h2.5l1.5-2h6l1.5 2H19a2 2 0 0 1 2 2v10a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z'/%3E%3Ccircle cx='12' cy='13' r='4'/%3E%3C/svg%3E"); }
.ti-chat { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'%3E%3Cpath d='M4 5h16a1 1 0 0 1 1 1v10a1 1 0 0 1-1 1H9l-5 4V6a1 1 0 0 1 1-1z'/%3E%3C/svg%3E"); }
.ti-cat { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linejoin='round'%3E%3Cpath d='M4 19V6l4 3h8l4-3v13a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2z'/%3E%3Ccircle cx='9' cy='14' r='1' fill='black'/%3E%3Ccircle cx='15' cy='14' r='1' fill='black'/%3E%3C/svg%3E"); }

/* ---------- チャット ---------- */
.small { font-size: 12px; }
.center { text-align: center; }
.ellipsis { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.avatar.sm { width: 34px; height: 34px; font-size: 14px; }
body.in-room { padding-bottom: calc(76px + var(--safe-b)); }
body.in-room .top { display: none; }
.room-head { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 10px; margin: 0 -16px; padding: 10px 12px;
  background: rgba(245,246,248,.9); backdrop-filter: saturate(1.8) blur(14px); -webkit-backdrop-filter: saturate(1.8) blur(14px); border-bottom: 1px solid var(--line); }
.room-name { flex: 1; font-size: 17px; }
.back-btn { font-size: 30px; line-height: 1; color: var(--text); padding: 0 6px 4px; }
.icon-btn.small { width: 36px; height: 36px; display: grid; place-items: center; }
.search-bar { display: flex; gap: 8px; align-items: center; margin: 8px 0; }
.search-bar[hidden] { display: none; }
.messages { display: flex; flex-direction: column; gap: 14px; padding: 14px 0 8px; }
.empty-chat { margin-top: 40px; }
.center-btn { align-self: center; }
.msg { display: flex; gap: 8px; align-items: flex-end; max-width: 100%; }
.msg time { font-size: 11px; color: var(--muted); white-space: nowrap; }
.msg.owner { flex-direction: column; align-items: flex-end; gap: 3px; }
.msg.owner .bubble { background: var(--accent); color: #fff; border-radius: 18px 18px 4px 18px; padding: 10px 14px; max-width: 78%; white-space: pre-wrap; word-break: break-word; line-height: 1.5; }
.msg.cat { align-items: flex-start; }
.msg-body { display: grid; gap: 3px; max-width: 84%; min-width: 0; }
.bubble.analysis { background: var(--card); border-radius: 4px 18px 18px 18px; padding: 12px 14px; box-shadow: 0 1px 2px rgba(0,0,0,.05); display: grid; gap: 8px; }
.bubble.analysis.undetermined { background: #f1f2f4; }
.bubble.pending { color: var(--muted); display: flex; align-items: center; gap: 8px; }
.bubble-head { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.tag { font-size: 11px; font-weight: 700; padding: 2px 8px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); }
.undetermined .tag { background: #e5e7eb; color: #4b5563; }
.conf { font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--line); color: var(--muted); white-space: nowrap; }
.conf-medium { color: #0b6e5b; border-color: #a7dccd; }
.conf-low { color: #8a6d1f; border-color: #ead9a6; }
.summary { margin: 0; white-space: pre-line; line-height: 1.6; }
.bubble audio { width: 100%; height: 36px; }
.basis summary { cursor: pointer; color: var(--accent); font-size: 13px; font-weight: 600; }
.basis h4 { font-size: 12px; color: var(--muted); margin: 10px 0 4px; }
.basis ul { margin: 0; padding-left: 18px; font-size: 13px; line-height: 1.55; }
.basis li { margin-bottom: 4px; }
.basis .tag { margin-left: 4px; }
.papers a { color: var(--text); text-decoration: underline; text-decoration-color: #c9ced6; }
.grade { font-size: 11px; font-weight: 700; padding: 1px 6px; border-radius: 6px; background: #eef0f3; }
.grade-A, .grade-B { background: #e5f6f1; color: #0b6e5b; }
.grade-C { background: #fbf3dc; color: #8a6d1f; }
.grade-D, .grade-E { background: #f7e1e1; color: #9b2c2c; }
.feedback { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; border-top: 1px solid var(--line); padding-top: 8px; }
.fb-btn { border: 1px solid var(--line); background: #fbfbfc; border-radius: 999px; padding: 5px 12px; font: inherit; font-size: 13px; cursor: pointer; }
.fb-saved { display: flex; gap: 8px; align-items: center; font-size: 13px; color: var(--muted); flex-wrap: wrap; }
.fb-form { display: grid; gap: 6px; width: 100%; }
.fb-form p { margin: 4px 0 0; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip { border: 1px solid var(--line); background: #fff; border-radius: 999px; padding: 5px 11px; font: inherit; font-size: 13px; cursor: pointer; }
.chip.on { background: var(--text); color: #fff; border-color: var(--text); }
.vet { margin: 6px 0 0; font-size: 13px; color: #9b2c2c; }
.composer { position: fixed; left: 0; right: 0; bottom: 0; z-index: 10; display: flex; gap: 8px; align-items: flex-end; padding: 8px 10px calc(8px + var(--safe-b));
  background: rgba(255,255,255,.95); backdrop-filter: saturate(1.8) blur(14px); -webkit-backdrop-filter: saturate(1.8) blur(14px); border-top: 1px solid var(--line); }
.composer textarea { min-height: 42px; max-height: 120px; resize: none; border-radius: 21px; padding: 10px 14px; }
.mic-btn, .send-btn { flex: none; width: 42px; height: 42px; border-radius: 50%; border: 0; display: grid; place-items: center; cursor: pointer; }
.mic-btn { background: var(--dark); }
.mic-btn .ti { background: var(--scan); }
.send-btn { background: var(--accent); }
.send-btn .ti { background: #fff; width: 20px; height: 20px; }
.sheet-wrap { position: fixed; inset: 0; z-index: 30; background: rgba(11,13,18,.45); display: flex; align-items: flex-end; justify-content: center; }
.sheet { background: var(--card); width: 100%; max-width: 640px; border-radius: 22px 22px 0 0; padding: 20px 18px calc(18px + var(--safe-b)); display: grid; gap: 12px; }
.sheet h3 { margin: 0; }
.sheet-actions { display: grid; gap: 8px; }
.btn.ghost { border-color: transparent; color: var(--muted); }
.rec-status { display: flex; align-items: center; gap: 8px; font-weight: 700; min-height: 22px; }
.rec-dot { width: 12px; height: 12px; border-radius: 50%; background: var(--danger); animation: blink 1s infinite; }
@keyframes blink { 50% { opacity: .25; } }
.dots { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); animation: blink .8s infinite; }
@media (min-width: 900px) { .composer { max-width: 640px; margin: 0 auto; border: 1px solid var(--line); border-radius: 18px 18px 0 0; } }
.ti-mic { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.8' stroke-linecap='round'%3E%3Crect x='9' y='3' width='6' height='12' rx='3'/%3E%3Cpath d='M5 11a7 7 0 0 0 14 0M12 18v3'/%3E%3C/svg%3E"); }
.ti-send { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linejoin='round'%3E%3Cpath d='M4 12 20 4l-6 16-3-7z'/%3E%3C/svg%3E"); }
.ti-search { --i: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='1.9' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='6.5'/%3E%3Cpath d='m16 16 4.5 4.5'/%3E%3C/svg%3E"); }

.listen-banner { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(70px + var(--safe-b)); z-index: 12; display: flex; align-items: center; gap: 10px;
  background: var(--dark); color: #fff; padding: 8px 10px 8px 14px; border-radius: 999px; box-shadow: 0 6px 20px rgba(0,0,0,.25); font-size: 13px; max-width: 94vw; width: max-content; white-space: nowrap; }
.listen-banner .rec-dot { flex: none; }
.listen-banner .btn { min-height: 30px; white-space: nowrap; flex: none; background: transparent; color: var(--scan); border-color: #2c4a43; }
.meter { width: 60px; height: 6px; border-radius: 3px; background: #2a2f38; overflow: hidden; flex: none; }
.meter-bar { display: block; height: 100%; width: 0; background: var(--scan); transition: width .1s; }

#toast { position: fixed; left: 50%; bottom: calc(90px + var(--safe-b)); transform: translate(-50%, 20px); background: var(--text); color: #fff;
  padding: 10px 16px; border-radius: 999px; font-size: 14px; opacity: 0; pointer-events: none; transition: .2s; z-index: 20; max-width: 90vw; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (min-width: 900px) {
  main { padding-top: 16px; }
  .tabs { max-width: 640px; margin: 0 auto; left: 0; right: 0; border-radius: 18px 18px 0 0; border: 1px solid var(--line); }
}
