/* ニアシナ 基本UI */
:root {
  --bg: #0f1220;
  --panel: #171b2e;
  --panel2: #1f2440;
  --fg: #eef1f8;
  --muted: #98a0b8;
  --accent: #7fd8c8;
  --accent2: #a6b4ff;
  --danger: #ff8a8a;
  --radius: 16px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--bg); color: var(--fg);
  font-family: system-ui, -apple-system, "Hiragino Kaku Gothic ProN", sans-serif;
  font-size: 16px; line-height: 1.6;
}
/* アプリの外枠。画面の高さに固定し、スクロールするのは #app の中だけにする。
   こうすると下タブや会話の入力欄を position:fixed で浮かせる必要がなくなる。
   （iOSのホーム画面アプリでは、固定要素が画面上部に二重に描かれたり、
     画面の下端とずれた位置に置かれる不具合が出る。実機で発生。） */
body { display: flex; flex-direction: column; overflow: hidden; height: 100%; }
@supports (height: 100dvh) { body { height: 100dvh; } }
/* ソフトキーボードで見えている高さが変わったとき（chat.js が --vvh を入れる） */
body.vv { height: var(--vvh); }
#app {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch;
  display: flex; flex-direction: column;
}

.auth-wrap { flex: 1; display: grid; place-items: center; padding: 24px; }
.auth-card {
  width: 100%; max-width: 380px; background: var(--panel);
  border-radius: var(--radius); padding: 28px 24px;
  box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.brand { display: flex; align-items: center; gap: 12px; margin-bottom: 8px; }
.brand img { width: 44px; height: 44px; }
.brand h1 { font-size: 1.35rem; margin: 0; letter-spacing: .08em; }
.tagline { color: var(--muted); font-size: .88rem; margin: 0 0 24px; }

label { display: block; font-size: .82rem; color: var(--muted); margin: 14px 0 6px; }
input[type=text], input[type=email], input[type=password], input[type=tel] {
  width: 100%; padding: 13px 14px; font-size: 1rem;
  background: var(--panel2); color: var(--fg);
  border: 1px solid transparent; border-radius: 12px;
}
input:focus { outline: none; border-color: var(--accent); }

button {
  width: 100%; padding: 14px; font-size: 1rem; font-weight: 600;
  border: none; border-radius: 12px; cursor: pointer;
  background: var(--accent); color: #08221d; margin-top: 18px;
}
button:active { transform: translateY(1px); }
button:disabled { opacity: .5; }
button.ghost { background: transparent; color: var(--accent); border: 1px solid #33395c; }
button.link { background: none; color: var(--muted); font-weight: 400; font-size: .85rem; margin-top: 12px; padding: 6px; }
button.danger { background: transparent; color: var(--danger); border: 1px solid #4a2b38; }

.msg { margin-top: 14px; padding: 11px 13px; border-radius: 10px; font-size: .87rem; }
.msg.err { background: #3a1f2a; color: var(--danger); }
.msg.ok { background: #16302c; color: var(--accent); }
.msg.info { background: var(--panel2); color: var(--muted); }
.hidden { display: none !important; }

/* 線画アイコン（ns-icons.js）。文字と並べるときは行の高さに合わせる。 */
.ic { display: inline-block; width: 24px; height: 24px; flex: none; vertical-align: -.28em; }
.row .name > .ic, .row .sub > .ic, .fx-label > .ic { width: 18px; height: 18px; vertical-align: -.22em; margin-right: 7px; opacity: .85; }
.topbar button > .ic { width: 22px; height: 22px; vertical-align: -.3em; }
.row button > .ic { width: 19px; height: 19px; vertical-align: -.28em; }
body.easy .row .name > .ic, body.easy .row .sub > .ic { width: 22px; height: 22px; }
body.easy .topbar button > .ic { width: 26px; height: 26px; }

.divider { display: flex; align-items: center; gap: 10px; margin: 22px 0 4px; color: var(--muted); font-size: .78rem; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: #2a3050; }

.topbar {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 12px 14px; background: var(--panel); position: sticky; top: 0; z-index: 10;
  min-height: 56px;
}
/* 折り返し対策：タイトルは1行＋末尾…、左右のボタンは中身の幅で固定。
   （button{width:100%} が topbar 内にも効き、タイトルが min-content まで
   潰されて１文字ずつ縦に折れていた） */
.topbar h2 {
  font-size: 1.05rem; margin: 0; flex: 1 1 auto; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  text-align: center;
}
.topbar h2:first-child { text-align: left; }
.topbar button, .topbar .who {
  flex: 0 0 auto; width: auto; max-width: 40%;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar button { margin: 0; padding: 8px 6px; }
.topbar .who { color: var(--muted); font-size: .82rem; }
.content { padding: 18px; flex: 1; }
.section-title { font-size: .78rem; color: var(--muted); text-transform: uppercase; letter-spacing: .1em; margin: 22px 0 10px; }
.list { display: flex; flex-direction: column; gap: 10px; }
.row {
  background: var(--panel); border-radius: 12px; padding: 14px 16px;
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
}
.row.tap { cursor: pointer; }
.row .main { min-width: 0; }
.row .name { font-weight: 600; overflow-wrap: anywhere; }
.row .sub { color: var(--muted); font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row button { width: auto; flex: 0 0 auto; margin: 0; padding: 8px 14px; font-size: .82rem; white-space: nowrap; }
.badge { font-size: .72rem; padding: 3px 9px; border-radius: 999px; background: var(--panel2); color: var(--muted); white-space: nowrap; }
.empty { color: var(--muted); text-align: center; padding: 32px 12px; font-size: .9rem; }

.ctype { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 8px; }
.ctype.family_home { background: #ffb37f; }
.ctype.family_far { background: #ffd97f; }
.ctype.partner { background: #ff9fc4; }
.ctype.friends { background: #7fd8c8; }
.ctype.work { background: #a6b4ff; }
.ctype.custom { background: #98a0b8; }

body.easy { font-size: 20px; }
body.easy button { padding: 20px; font-size: 1.2rem; border-radius: 16px; }
body.easy .auth-card { max-width: 440px; padding: 32px 26px; }
body.easy input { padding: 18px; font-size: 1.15rem; }
body.easy .topbar { min-height: 64px; }
body.easy .topbar h2 { font-size: 1.25rem; }
body.easy .topbar button { padding: 10px 8px; font-size: 1.05rem; border-radius: 12px; }

/* 今日のひとこと */
.daily-compose { background: var(--panel); border-radius: var(--radius); padding: 16px; }
.daily-compose input[type=text] { margin-top: 4px; }
.daily-prev { margin-top: 12px; border-radius: 12px; overflow: hidden; }
.daily-prev img { width: 100%; display: block; }
.daily-actions { display: flex; gap: 10px; }
.daily-actions button { flex: 1; }
.daily-card { background: var(--panel); border-radius: 14px; overflow: hidden; }
.daily-img { width: 100%; display: block; max-height: 320px; object-fit: cover; }
.daily-body { padding: 12px 14px; }
.daily-who { font-size: .82rem; color: var(--muted); display: flex; justify-content: space-between; }
.daily-day { color: #6b7390; }
.daily-text { margin-top: 4px; font-size: 1rem; }
body.easy .daily-text { font-size: 1.2rem; }

/* アプリ棚 */
.app-ask { background: var(--panel); border-radius: var(--radius); padding: 16px; }
.app-ask textarea {
  width: 100%; padding: 13px 14px; font-size: 1rem; margin-top: 4px;
  background: var(--panel2); color: var(--fg); border: 1px solid transparent;
  border-radius: 12px; font-family: inherit; resize: vertical;
}
.app-ask textarea:focus { outline: none; border-color: var(--accent); }
/* 🎤 は欄の中に重ねると打った文字にかぶるので、欄の下に文字つきのボタンで出す */
.app-ask .ask-tools { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.app-ask .ask-tools:empty { display: none; }
.app-ask .ask-tools + .fx-label { margin-top: 10px; }
.app-ask .vin-btn.ask-mic {
  width: auto; margin: 0; padding: 9px 15px; border-radius: 999px;
  display: inline-flex; align-items: center; gap: 7px;
  background: var(--panel2); color: var(--fg); border: 1px solid #33395c;
  font-size: .88rem; font-weight: 600; line-height: 1.2;
}
.app-ask .vin-btn.ask-mic > .ic { width: 19px; height: 19px; vertical-align: 0; }
.app-ask .vin-btn.ask-mic.on { background: var(--danger); border-color: var(--danger); color: #2a0b0b; }
.app-ask .vin-btn.ask-mic.busy { opacity: .55; }
body.easy .app-ask .vin-btn.ask-mic { padding: 14px 20px; font-size: 1.05rem; }

/* ---------- P1-16 ホーム画面から開いたとき（アプリ表示） ---------- */
/* status-bar-style=black-translucent なので、上端は時計・ノッチの下に入る。
   env() はブラウザタブでは0なので、両方に同じ指定でよい。 */
.topbar { padding-top: calc(12px + env(safe-area-inset-top)); }
body.easy .topbar { padding-top: calc(14px + env(safe-area-inset-top)); }
.auth-wrap { padding-top: calc(24px + env(safe-area-inset-top)); }
.content { padding-bottom: calc(18px + env(safe-area-inset-bottom)); }
/* ブラウザらしい振る舞い（引っ張って再読み込み・上下のバウンド）を止める */
html { overscroll-behavior-y: none; }
body { overscroll-behavior-y: contain; }
/* 長押しでリンクメニューや選択が出ないように（本文は選択できるまま残す） */
button, .topbar, .badge, .ctype { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }

/* 起動中（#app の中身が入るまで）。最初の描画でまるごと消える。 */
#boot {
  flex: 1; display: grid; place-content: center; justify-items: center; gap: 14px;
  padding: 24px calc(24px + env(safe-area-inset-right)) 24px calc(24px + env(safe-area-inset-left));
}
#boot img { width: 88px; height: 88px; animation: boot-breathe 1.7s ease-in-out infinite; }
#boot .boot-t { color: var(--muted); font-size: .9rem; letter-spacing: .2em; }
#boot .boot-slow { display: none; color: var(--muted); font-size: .85rem; text-align: center; max-width: 300px; }
#boot.slow .boot-slow { display: block; }
@keyframes boot-breathe { 0%, 100% { opacity: .4; } 50% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { #boot img { animation: none; opacity: .85; } }

/* 「ホーム画面に追加」の案内シート（pwa.js） */
.pwa-sheet {
  position: fixed; inset: 0; z-index: 1200;
  background: rgba(6,8,16,.72); display: flex; align-items: flex-end;
}
.pwa-card {
  width: 100%; background: var(--panel);
  border-radius: 20px 20px 0 0;
  padding: 22px 20px calc(22px + env(safe-area-inset-bottom));
  box-shadow: 0 -12px 40px rgba(0,0,0,.45);
}
.pwa-title { font-size: 1.1rem; font-weight: 700; }
.pwa-lead { color: var(--muted); font-size: .88rem; margin: 8px 0 0; }
.pwa-steps { margin: 16px 0 0; padding-left: 1.35em; font-size: .93rem; }
.pwa-steps li { margin-bottom: 9px; }
.pwa-steps b { color: var(--accent); }
body.easy .pwa-card { padding: 26px 22px calc(26px + env(safe-area-inset-bottom)); }
body.easy .pwa-title { font-size: 1.35rem; }
body.easy .pwa-lead { font-size: 1.05rem; }
body.easy .pwa-steps { font-size: 1.15rem; }
