:root {
  --ink: #17191e;
  --muted: #5c6370;
  --line: #e2e4e8;
  --soft: #f3f4f6;
  --accent: #0e7c6b;
  --accent-soft: #d9e8e4;
  --danger: #d8433a;
  --bg: #ffffff;
}
* { box-sizing: border-box; }
html, body { height: 100%; overflow-x: hidden; overscroll-behavior-x: none; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Noto Sans JP", "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.45;
  overscroll-behavior: none;
}
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: inherit; }
.hidden { display: none !important; }
.err { margin: 12px 0 0; text-align: center; font-size: 13px; font-weight: 500; color: #b5443a; }
.tnum { font-variant-numeric: tabular-nums; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
/* アイコンは行ボックスに乗せず、親のflexで中央に合わせる */
[data-icon] { display: inline-flex; align-items: center; justify-content: center; line-height: 0; flex: 0 0 auto; }
[data-icon] svg { display: block; }
.brand, .btn, .pill, .row-toggle, .chat-top .ttl, .room-chip .meta span, .feats div { line-height: 1; }

/* 1画面に収める外枠 */
.screen {
  height: 100dvh;
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  padding: max(20px, env(safe-area-inset-top)) 24px max(24px, env(safe-area-inset-bottom));
  overflow-y: auto; /* 収まらない端末では最後の手段としてスクロール */
}
.screen.flush { padding-left: 0; padding-right: 0; padding-top: 0; }

/* ヘッダー */
.top { display: flex; align-items: center; justify-content: space-between; height: 44px; }
.brand { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 20px; letter-spacing: -0.01em; text-decoration: none; }
.brand svg { color: var(--accent); }
.pill { display: inline-flex; align-items: center; gap: 5px; height: 32px; padding: 0 12px; border-radius: 999px; background: var(--soft); color: var(--muted); font-size: 13px; font-weight: 500; }

h1 { margin: 0; font-size: 30px; font-weight: 700; line-height: 1.25; letter-spacing: -0.01em; }
.label { font-size: 13px; font-weight: 500; color: var(--muted); }
.grow { flex: 1 1 0; min-height: 0; }
.gap-s { height: 12px; } .gap-m { height: 24px; } .gap-l { height: 40px; } .gap-xl { height: 56px; }

/* 選択チップ */
.seg { display: flex; gap: 8px; }
.seg button {
  flex: 1 1 0; height: 52px; border-radius: 12px;
  border: 1px solid var(--line); background: #fff; font-size: 16px; font-weight: 500;
}
.seg button[aria-pressed="true"] { background: var(--ink); color: #fff; border-color: var(--ink); font-weight: 700; }

/* ボタン */
.btn {
  display: flex; align-items: center; justify-content: center; gap: 10px;
  width: 100%; height: 58px; border-radius: 16px; border: 0;
  font-size: 17px; font-weight: 700; text-decoration: none;
}
.btn.primary { background: var(--accent); color: #fff; }
.btn.primary:disabled { opacity: 0.45; cursor: default; }
.btn.dark { background: var(--ink); color: #fff; height: 56px; font-size: 16px; }
.btn.ghost { background: transparent; color: var(--muted); height: 48px; font-size: 15px; font-weight: 500; }
.icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 44px; height: 44px; border: 0; border-radius: 12px; background: transparent; color: var(--ink);
}

/* 入っているルーム */
.mine { min-height: 0; display: flex; flex-direction: column; }
.mine-list { display: flex; flex-direction: column; gap: 8px; max-height: 200px; overflow-y: auto; }
.mine-row { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 12px 0 16px; border-radius: 14px; background: var(--soft); text-decoration: none; flex: 0 0 auto; }
.mine-row .names { flex: 1 1 0; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.mine-row .title { display: none; font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mine-row .code { font-weight: 700; letter-spacing: 0.08em; font-size: 16px; }
.mine-row.has-title .title { display: block; }
.mine-row.has-title .code { font-size: 12px; font-weight: 500; color: var(--muted); }
.mine-row .meta { display: flex; gap: 12px; font-size: 13px; color: var(--muted); font-weight: 500; }
.mine-row .meta > span { display: inline-flex; align-items: center; gap: 4px; }
.mine-row .meta svg { width: 14px; height: 14px; }
.mine-row .chev { display: flex; color: #b8bcc6; }

/* 特徴3つ */
.feats { display: flex; flex-wrap: wrap; gap: 8px 14px; }
.feats div { display: flex; align-items: center; gap: 5px; font-size: 12.5px; font-weight: 500; color: var(--muted); white-space: nowrap; }
.feats svg { color: var(--accent); width: 18px; height: 18px; }

/* QRが主役。余った高さを全部使う */
.pills { display: flex; gap: 6px; }
.qr-hero { flex: 1 1 0; min-height: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 18px; padding: 20px 0 16px; }
.qr-hero #qr { flex: 1 1 0; min-height: 0; width: 100%; display: flex; justify-content: center; }
.qr-hero #qr svg { height: 100%; width: auto; max-width: 100%; max-height: 320px; }
.room-code { font-size: 24px; font-weight: 700; letter-spacing: 0.12em; }
.rc { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.room-title { font-size: 22px; font-weight: 700; line-height: 1.3; text-align: center; word-break: break-word; }
/* 名前があるときは番号を脇役に */
.has-title .room-code, .has-title .room-chip .code, .has-title .chat-top .code { font-size: 12px; font-weight: 500; color: var(--muted); letter-spacing: 0.08em; }
.chat-top .room-title { font-size: 16px; line-height: 1.2; max-width: 180px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.has-title .chat-top .code { display: none; } /* ヘッダーは2行まで。番号はQR画面で見られる */
.room-chip .room-title { font-size: 18px; text-align: left; }
.linkish { height: 36px; padding: 0 12px; border: 0; background: transparent; color: var(--accent); font-size: 14px; font-weight: 500; }
#sheet-title .input { width: 100%; }
/* 縦が短い端末（iPhone SE 等）: 消すボタンはメニューに任せ、QRに高さを回す */
@media (max-height: 600px) {
  .qr-hero { padding: 12px 0 10px; gap: 12px; }
  .room-code { font-size: 20px; }
  #burn-qr { display: none; }
  #v-qr .gap-m { height: 12px; }
}
.urlbar { display: flex; align-items: center; gap: 4px; height: 48px; padding: 0 4px 0 16px; border-radius: 14px; background: var(--soft); }
.urlbar span { flex: 1 1 0; min-width: 0; font-size: 14px; font-weight: 500; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.row-toggle { display: flex; align-items: center; gap: 12px; height: 56px; padding: 0 16px; border-radius: 14px; background: var(--soft); }
.row-toggle > span:not([data-icon]) { flex: 1 1 0; font-weight: 500; }
.switch { position: relative; width: 50px; height: 30px; padding: 2px; border: 0; border-radius: 999px; background: #c9ccd3; transition: background .15s; }
.switch[aria-checked="true"] { background: var(--accent); }
.switch i { display: block; width: 26px; height: 26px; border-radius: 999px; background: #fff; transition: transform .15s; }
.switch[aria-checked="true"] i { transform: translateX(20px); }

/* 参加 */
.room-chip { display: flex; align-items: center; gap: 16px; padding: 18px 20px; border-radius: 20px; background: var(--soft); }
.room-chip .sq { display: flex; align-items: center; justify-content: center; width: 52px; height: 52px; border-radius: 14px; background: #fff; }
.room-chip .code { font-size: 20px; font-weight: 700; letter-spacing: 0.1em; }
.room-chip .meta { display: flex; gap: 14px; font-size: 13px; color: var(--muted); font-weight: 500; }
.room-chip .meta span { display: inline-flex; align-items: center; gap: 5px; }
.input {
  width: 100%; height: 56px; padding: 0 18px; border: 1px solid var(--ink); border-radius: 14px; background: #fff;
  font-size: 18px; font-weight: 500; outline: none;
}
.input::placeholder { color: #9aa0ab; }
.preview { display: flex; align-items: flex-end; gap: 8px; }
.avatar { display: flex; align-items: center; justify-content: center; flex: 0 0 32px; width: 32px; height: 32px; border-radius: 999px; background: var(--accent-soft); color: var(--accent); font-size: 14px; font-weight: 700; }
.bubble { padding: 10px 14px; border-radius: 18px 18px 18px 4px; background: var(--soft); max-width: 280px; word-break: break-word; white-space: pre-wrap; }
.bubble.me { background: var(--accent); color: #fff; border-radius: 18px 18px 4px 18px; }
.bubble.cont { border-radius: 4px 18px 18px 18px; }
.name { font-size: 11px; font-weight: 500; color: var(--muted); padding-left: 4px; }

/* チャット */
.chat-top { display: flex; align-items: center; gap: 4px; height: 56px; padding: 0 12px; border-bottom: 1px solid var(--line); margin-top: max(0px, env(safe-area-inset-top)); }
.chat-top .center { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 2px; min-width: 0; }
.chat-top .code { font-size: 16px; font-weight: 700; letter-spacing: 0.08em; }
.chat-top .ttl { display: inline-flex; align-items: center; gap: 5px; font-size: 12px; color: var(--muted); font-weight: 500; }
.msgs { flex: 1 1 0; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 16px 16px 12px; }
.sys { align-self: center; font-size: 12px; font-weight: 500; color: var(--muted); }
.sys.chip { padding: 6px 12px; border-radius: 999px; background: var(--soft); }
.m { display: flex; align-items: flex-end; gap: 8px; max-width: 86%; }
.m.me { align-self: flex-end; flex-direction: row-reverse; gap: 6px; }
.m .col { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.m .time { font-size: 11px; color: var(--muted); padding-bottom: 4px; white-space: nowrap; }
.m .spacer { flex: 0 0 32px; }
.composer { display: flex; align-items: center; gap: 8px; padding: 10px 12px max(12px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line); }
.composer input { flex: 1 1 0; min-width: 0; height: 44px; padding: 0 16px; border: 1px solid var(--line); border-radius: 22px; background: var(--soft); outline: none; font-size: 16px; } /* 16px未満だとiOSがズームして横スクロールが残る */
.composer .send { width: 44px; height: 44px; border: 0; border-radius: 999px; background: var(--accent); color: #fff; display: flex; align-items: center; justify-content: center; }
.composer .send:disabled { opacity: 0.4; }

/* シート（メニュー等） */
.sheet-bg { position: fixed; inset: 0; background: rgba(23,25,30,.55); display: flex; align-items: flex-end; justify-content: center; z-index: 10; }
.sheet { width: 100%; max-width: 480px; background: #fff; border-radius: 28px 28px 0 0; padding: 12px 24px max(40px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; align-items: center; }
.sheet .handle { width: 40px; height: 5px; border-radius: 999px; background: var(--line); margin-bottom: 20px; }
.sheet h2 { margin: 0 0 20px; font-size: 20px; align-self: stretch; display: flex; align-items: center; gap: 8px; }
.menu { width: 100%; display: flex; flex-direction: column; gap: 8px; }
.menu button { display: flex; align-items: center; gap: 12px; height: 54px; padding: 0 16px; border: 0; border-radius: 14px; background: var(--soft); font-weight: 500; text-align: left; }
.menu button.danger { color: var(--danger); }
.menu .seat small { color: var(--muted); font-weight: 500; }
.steps { display: flex; align-items: flex-start; gap: 8px; width: 100%; }
.steps > div { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.steps .box { display: flex; align-items: center; justify-content: center; width: 72px; height: 72px; border-radius: 20px; background: var(--soft); }
.steps .box.dark { background: var(--ink); color: #fff; }
.steps .n { font-size: 12px; font-weight: 700; color: var(--accent); }
.steps .t { font-size: 13px; font-weight: 500; text-align: center; }
.steps > span { margin-top: 26px; color: #b8bcc6; }

/* 状態画面（消えた・満員 等） */
.state { flex: 1 1 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; text-align: center; color: var(--muted); }
.state b { font-size: 22px; color: var(--ink); }

/* 通話 */
.call { position: fixed; inset: 0; background: var(--ink); color: #fff; display: flex; flex-direction: column; align-items: center; padding: max(20px, env(safe-area-inset-top)) 24px max(40px, env(safe-area-inset-bottom)); z-index: 20; }
.call .big { width: 120px; height: 120px; border-radius: 999px; background: #e6e1d5; color: #6b5a2e; font-size: 48px; font-weight: 700; display: flex; align-items: center; justify-content: center; }
.call .who { font-size: 26px; font-weight: 700; margin-top: 24px; }
.call .dur { font-size: 34px; font-weight: 500; letter-spacing: .04em; color: #b8bcc6; margin-top: 10px; }
.call .status { margin-top: 20px; font-size: 12px; color: #b8bcc6; background: #2a2d35; padding: 0 12px; height: 30px; border-radius: 999px; display: inline-flex; align-items: center; gap: 6px; }
.call .ctrls { display: flex; gap: 28px; }
.call .ctrls > div { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 72px; font-size: 12px; color: #b8bcc6; }
.call .ctrls button { width: 64px; height: 64px; border: 0; border-radius: 999px; background: #2a2d35; color: #fff; display: flex; align-items: center; justify-content: center; }
.call .ctrls button.on { background: #fff; color: var(--ink); }
.call .ctrls button.end { background: var(--danger); }
