:root {
  --blue: #1466E0;
  --blue-dark: #0f55bd;
  --yellow: #FFC23A;
  --ink: #1B2B45;
  --sub: #5b6b82;
  --line: #dfe5ee;
  --bg: #f3f6fb;
  --card: #ffffff;
  --me: #1466E0;
  --them: #ffffff;
  --danger: #c63a2f;
  --font: "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  --lh: 1.6;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: var(--font);
  line-height: var(--lh);
  color: var(--ink);
  background: var(--bg);
  -webkit-text-size-adjust: 100%;
  overscroll-behavior-y: none;
}
[hidden] { display: none !important; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

#app { display: flex; flex-direction: column; height: 100dvh; max-width: 640px; margin: 0 auto; }

.topbar {
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: space-between;
  padding: calc(env(safe-area-inset-top) + 10px) 12px 10px 16px;
  background: var(--blue); color: #fff;
}
.brand { display: flex; flex-direction: column; min-width: 0; }
.brand-name { font-weight: 700; font-size: 18px; letter-spacing: .01em; }
.brand-org { font-size: 12px; opacity: .85; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.icon-btn { background: none; border: 0; color: #fff; padding: 8px; border-radius: 8px; cursor: pointer; }
.icon-btn:focus-visible { outline: 2px solid #fff; }

.view { flex: 1 1 auto; overflow-y: auto; padding: 16px; }
.view.chat { display: flex; flex-direction: column; padding: 0; overflow: hidden; }

.center-box { display: flex; flex-direction: column; align-items: center; gap: 12px; margin-top: 30vh; }
.spinner { width: 32px; height: 32px; border-radius: 50%; border: 3px solid var(--line); border-top-color: var(--blue); animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.card { background: var(--card); border: 1px solid var(--line); border-radius: 14px; padding: 20px 16px; }
.card.narrow { max-width: 440px; margin: 8px auto 24px; }
h1 { font-size: 20px; margin: 0 0 8px; line-height: 1.4; }
h2 { font-size: 17px; margin: 0; }
.muted { color: var(--sub); }
.small { font-size: 13px; }
p { margin: 0 0 12px; }

.field { display: block; margin-bottom: 14px; }
.field span { display: block; font-size: 14px; font-weight: 600; margin-bottom: 4px; }
input, select, textarea { font: inherit; color: inherit; }
.field input, .field select {
  width: 100%; font-size: 17px; padding: 11px 12px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff;
}
.field input:focus, .field select:focus, textarea:focus { outline: 2px solid var(--blue); outline-offset: 0; border-color: var(--blue); }
#loginId { letter-spacing: .08em; }
.lang-field { margin-top: 20px; margin-bottom: 0; }

.btn {
  display: block; width: 100%; font: inherit; font-size: 16px; font-weight: 700;
  padding: 12px 16px; border: 0; border-radius: 12px;
  background: var(--blue); color: #fff; cursor: pointer; line-height: 1.4;
}
.btn:active { background: var(--blue-dark); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-outline { background: #fff; color: var(--blue); border: 1.5px solid var(--blue); }
.btn-outline:active { background: #eef4ff; }
.btn-small { display: inline-block; width: auto; font-size: 14px; padding: 8px 14px; border-radius: 10px; }
.btn-col { display: flex; flex-direction: column; gap: 10px; margin-top: 8px; }
.link-btn { background: none; border: 0; color: var(--blue); font: inherit; font-size: 14px; font-weight: 600; padding: 6px 4px; cursor: pointer; }
.error { color: var(--danger); font-size: 14px; }
.note { background: #fff6de; border: 1px solid var(--yellow); border-radius: 10px; padding: 10px 12px; font-size: 14px; }

.consent-body { white-space: pre-line; font-size: 15px; margin-bottom: 12px; max-height: 50vh; overflow-y: auto; padding: 12px; background: var(--bg); border-radius: 10px; }
a { color: var(--blue); }

/* チャット */
.banner { flex: 0 0 auto; margin: 10px 12px 0; padding: 12px; background: #fff; border: 1px solid var(--line); border-left: 4px solid var(--yellow); border-radius: 10px; font-size: 14px; }
.banner p { margin: 0 0 6px; }
.banner-title { font-weight: 700; }
.banner-actions { display: flex; align-items: center; gap: 12px; margin-top: 8px; }
#iosBanner { display: flex; gap: 8px; align-items: flex-start; }
#iosBanner p { flex: 1; margin: 0; }

.messages { flex: 1 1 auto; overflow-y: auto; padding: 12px 12px 8px; -webkit-overflow-scrolling: touch; }
.older-btn { display: block; margin: 0 auto 12px; background: #fff; border: 1px solid var(--line); border-radius: 999px; padding: 6px 14px; font: inherit; font-size: 13px; color: var(--sub); cursor: pointer; }
.empty { text-align: center; margin: 24px 16px; font-size: 14px; }

.day { text-align: center; margin: 14px 0 10px; }
.day span { display: inline-block; font-size: 12px; color: var(--sub); background: #e6ecf5; border-radius: 999px; padding: 2px 10px; }

.row { display: flex; flex-direction: column; margin-bottom: 10px; }
.row.me { align-items: flex-end; }
.row.them { align-items: flex-start; }
.who { font-size: 12px; color: var(--sub); margin: 0 6px 2px; font-weight: 600; }
.line { display: flex; align-items: flex-end; gap: 6px; max-width: 86%; }
.row.me .line { flex-direction: row-reverse; }
.bubble {
  padding: 9px 12px; border-radius: 16px; font-size: 15.5px;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: normal;
}
.row.me .bubble { background: var(--me); color: #fff; border-bottom-right-radius: 4px; }
.row.them .bubble { background: var(--them); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.row.staff .bubble { border-left: 3px solid var(--yellow); }
.row.me .bubble a { color: #fff; }
.time { font-size: 11px; color: var(--sub); white-space: nowrap; flex: 0 0 auto; }
.row.pending .bubble { opacity: .6; }
.row.failed .bubble { opacity: .8; box-shadow: 0 0 0 2px var(--danger); cursor: pointer; }
.fail-note { font-size: 12px; color: var(--danger); margin: 3px 6px 0; cursor: pointer; background: none; border: 0; font-family: inherit; text-align: right; padding: 0; }

.choices { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0 2px; max-width: 92%; }
.choice {
  font: inherit; font-size: 14.5px; font-weight: 600; line-height: 1.35;
  padding: 8px 14px; border-radius: 999px; border: 1.5px solid var(--blue);
  background: #fff; color: var(--blue); cursor: pointer;
}
.choice:active { background: #eef4ff; }
.choice:disabled { cursor: default; opacity: .45; }
.choice.selected { background: var(--blue); color: #fff; opacity: 1; }

.composer {
  flex: 0 0 auto; display: flex; align-items: flex-end; gap: 8px;
  padding: 8px 10px calc(env(safe-area-inset-bottom) + 8px);
  background: #fff; border-top: 1px solid var(--line);
}
.composer textarea {
  flex: 1; resize: none; font-size: 16px; line-height: 1.45;
  padding: 9px 12px; border: 1px solid var(--line); border-radius: 20px;
  max-height: 140px; background: var(--bg);
}
.send-btn {
  flex: 0 0 auto; width: 42px; height: 42px; border-radius: 50%; border: 0;
  background: var(--blue); color: #fff; display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.send-btn:disabled { opacity: .4; cursor: default; }

/* メニュー・確認 */
.overlay { position: fixed; inset: 0; background: rgba(15, 25, 45, .45); display: flex; align-items: flex-end; justify-content: center; z-index: 20; }
.sheet { background: #fff; width: 100%; max-width: 640px; border-radius: 16px 16px 0 0; padding: 12px 16px calc(env(safe-area-inset-bottom) + 16px); max-height: 85dvh; overflow-y: auto; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 4px 0 8px; }
.menu-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; width: 100%; padding: 14px 2px; border: 0; border-top: 1px solid var(--line); background: none; font: inherit; font-size: 15.5px; color: var(--ink); text-align: left; text-decoration: none; }
.menu-row select { font-size: 15px; padding: 6px 8px; border: 1px solid var(--line); border-radius: 8px; background: #fff; max-width: 60%; }
.menu-link { cursor: pointer; color: var(--ink); }
.menu-link.danger { color: var(--danger); }
.menu-sub { padding: 0 2px 10px; }
.menu-sub p { margin: 6px 0 0; }
#confirmOverlay { align-items: center; }
.dialog { background: #fff; border-radius: 14px; padding: 18px 16px 14px; width: calc(100% - 32px); max-width: 400px; }
.dialog p { font-size: 15.5px; }
.dialog-actions { display: flex; gap: 10px; }
.dialog-actions .btn { flex: 1; }

.toast { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 80px); transform: translateX(-50%); background: rgba(27, 43, 69, .92); color: #fff; padding: 10px 16px; border-radius: 10px; font-size: 14px; max-width: calc(100% - 32px); z-index: 30; }

/* 言語ごとの調整（背の高い文字） */
html[lang="my"], html[lang="km"] { --lh: 1.95; }
html[lang="th"], html[lang="ne"] { --lh: 1.75; }
html[lang="my"] .bubble, html[lang="km"] .bubble { padding-top: 7px; padding-bottom: 7px; }
