/* Mobile shell — 下タブ5つ。チャットは既存のまま、他4画面をここが受け持つ。
   色はアプリ共通トークン（bg #08080a / panel #131A22 / rule #22303F / text #DFE8F0 /
   muted #8CA0B3 / amber #F0A73A / teal #4FC9A6 / red #E4685A / blue #5AA6E4）。 */
:root{
  --nb-bg:#08080a; --nb-panel:#131A22; --nb-panel2:#0E141B; --nb-rule:#22303F;
  --nb-text:#DFE8F0; --nb-muted:#8CA0B3; --nb-amber:#F0A73A; --nb-teal:#4FC9A6;
  --nb-red:#E4685A; --nb-blue:#5AA6E4;
  --nb-mono:'IBM Plex Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  --nb-sans:'Noto Sans JP', -apple-system, 'Hiragino Kaku Gothic ProN', 'Yu Gothic', sans-serif;
}
body.has-bnav .app{ padding-bottom: 0 }
body.has-bnav .composer{ margin-bottom: calc(var(--bnav-h, 64px) + 10px) }
body.has-bnav .thread{ padding-bottom: 18px }

.bnav{
  position:fixed; left:0; right:0; bottom:0; z-index:60;
  display:grid; grid-template-columns:repeat(5,1fr);
  background:rgba(8,8,10,.92); backdrop-filter:blur(14px);
  border-top:1px solid var(--nb-rule);
  padding:6px 2px calc(6px + env(safe-area-inset-bottom));
}
.bnav button{
  appearance:none; background:none; border:0; cursor:pointer;
  display:flex; flex-direction:column; align-items:center; gap:3px;
  color:var(--nb-muted); font-family:var(--nb-sans); font-size:10.5px; letter-spacing:.02em;
  padding:5px 2px 3px; border-radius:10px; min-height:46px;
}
.bnav button svg{ width:21px; height:21px; stroke:currentColor; fill:none; stroke-width:1.6; stroke-linecap:round; stroke-linejoin:round }
.bnav button.on{ color:var(--nb-amber) }
.bnav button.on svg{ stroke-width:1.9 }
.bnav button:active{ background:rgba(240,167,58,.10) }

.views{
  position:fixed; left:0; right:0; top:0; bottom:var(--bnav-h, 64px);
  overflow-y:auto; -webkit-overflow-scrolling:touch; background:var(--nb-bg);
  color:var(--nb-text); font-family:var(--nb-sans); z-index:50;
}
body:not([data-tab="chat"]) .app{ display:none }
body[data-tab="chat"] .views{ display:none }

.vwrap{ padding:14px 13px 40px; max-width:720px; margin:0 auto }
.vhead{ display:flex; align-items:baseline; gap:9px; margin:6px 2px 12px }
.vhead h2{ font-size:17px; font-weight:650; margin:0; letter-spacing:.01em }
.vhead .sub{ font-size:11.5px; color:var(--nb-muted) }
.vhead .sp{ flex:1 }
.vhead button.ghost{
  appearance:none; background:transparent; border:1px solid var(--nb-rule); color:var(--nb-muted);
  border-radius:9px; padding:6px 10px; font-size:11.5px; font-family:inherit; cursor:pointer
}
.vhead button.ghost:active{ color:var(--nb-text) }

.card{
  background:var(--nb-panel); border:1px solid var(--nb-rule); border-radius:13px;
  padding:12px 13px; margin-bottom:10px;
}
.card.tight{ padding:10px 12px }
.card h3{ margin:0 0 7px; font-size:13px; font-weight:640; letter-spacing:.02em }
.kv{ display:grid; grid-template-columns:auto 1fr; gap:4px 12px; font-size:12.5px }
.kv dt{ color:var(--nb-muted); white-space:nowrap }
.kv dd{ margin:0; text-align:right; font-family:var(--nb-mono); font-size:12px }
.stat{ display:grid; grid-template-columns:repeat(3,1fr); gap:8px; margin-bottom:10px }
.stat .s{ background:var(--nb-panel2); border:1px solid var(--nb-rule); border-radius:11px; padding:9px 10px }
.stat .s b{ display:block; font-family:var(--nb-mono); font-size:17px; font-weight:600; line-height:1.25 }
.stat .s span{ font-size:10.5px; color:var(--nb-muted) }
.badge{
  display:inline-block; font-family:var(--nb-mono); font-size:10px; letter-spacing:.04em;
  border:1px solid var(--nb-rule); border-radius:6px; padding:1.5px 6px; color:var(--nb-muted); margin-right:5px
}
.badge.run{ color:var(--nb-teal); border-color:rgba(79,201,166,.45) }
.badge.wait{ color:var(--nb-amber); border-color:rgba(240,167,58,.45) }
.badge.fail{ color:var(--nb-red); border-color:rgba(228,104,90,.45) }
.badge.done{ color:var(--nb-blue); border-color:rgba(90,166,228,.45) }
.row{ border-top:1px solid var(--nb-rule); padding:10px 0 }
.row:first-of-type{ border-top:0 }
.row .t{ font-size:13px; line-height:1.5; word-break:break-word }
.row .m{ margin-top:4px; font-size:11px; color:var(--nb-muted); display:flex; gap:8px; flex-wrap:wrap; align-items:center }
.row .m code{ font-family:var(--nb-mono); font-size:10.5px; color:var(--nb-muted) }
.acts{ display:flex; gap:6px; flex-wrap:wrap; margin-top:8px }
.acts button{
  appearance:none; background:var(--nb-panel2); border:1px solid var(--nb-rule); color:var(--nb-text);
  border-radius:9px; padding:6px 11px; font-size:11.5px; font-family:inherit; cursor:pointer
}
.acts button.pri{ border-color:rgba(240,167,58,.5); color:var(--nb-amber) }
.acts button.danger{ border-color:rgba(228,104,90,.45); color:var(--nb-red) }
.acts button:active{ transform:translateY(1px) }
details.fold{ margin-top:7px }
details.fold summary{ font-size:11.5px; color:var(--nb-muted); cursor:pointer; list-style:none }
details.fold summary::-webkit-details-marker{ display:none }
details.fold summary:before{ content:'▸ '; font-family:var(--nb-mono) }
details.fold[open] summary:before{ content:'▾ ' }
details.fold .body{ margin-top:6px; font-size:11.5px; color:var(--nb-muted); line-height:1.6; white-space:pre-wrap; word-break:break-word }
.skel{ height:14px; border-radius:7px; margin:8px 0; background:linear-gradient(90deg,#151d26,#1b2530,#151d26); background-size:200% 100%; animation:sh 1.2s linear infinite }
@keyframes sh{ from{ background-position:0 0 } to{ background-position:-200% 0 } }
.empty{ font-size:12.5px; color:var(--nb-muted); padding:14px 2px; line-height:1.7 }
.err{ border:1px solid rgba(228,104,90,.4); background:rgba(228,104,90,.07); border-radius:12px; padding:11px 12px; font-size:12.5px; line-height:1.6 }
.err b{ color:var(--nb-red) }
.fld{ display:block; margin:9px 0 }
.fld span{ display:block; font-size:11px; color:var(--nb-muted); margin-bottom:4px }
input.i, textarea.i, select.i{
  width:100%; box-sizing:border-box; background:var(--nb-panel2); color:var(--nb-text);
  border:1px solid var(--nb-rule); border-radius:10px; padding:10px 11px; font-size:14px; font-family:inherit
}
textarea.i{ min-height:74px; resize:vertical }
input.i:focus, textarea.i:focus, select.i:focus{ outline:none; border-color:rgba(240,167,58,.55) }
.mono{ font-family:var(--nb-mono) }
.bar{ height:5px; border-radius:4px; background:var(--nb-panel2); overflow:hidden; margin:7px 0 3px }
.bar i{ display:block; height:100%; background:var(--nb-teal) }
.note{ font-size:11px; color:var(--nb-muted); line-height:1.65; margin-top:8px }
.toast2{
  position:fixed; left:50%; transform:translateX(-50%); bottom:calc(var(--bnav-h, 64px) + 14px);
  background:#1B2530; border:1px solid var(--nb-rule); color:var(--nb-text);
  padding:9px 14px; border-radius:11px; font-size:12.5px; z-index:70; opacity:0; transition:opacity .18s; pointer-events:none
}
.toast2.on{ opacity:1 }
@media (min-width:760px){ .bnav{ max-width:720px; margin:0 auto; border-left:1px solid var(--nb-rule); border-right:1px solid var(--nb-rule) } }

/* --- シェル確定：下タブを「重ねる」のをやめて、縦の並びの1段として置く ---
   以前は .bnav を fixed で重ね、その高さ（--bnav-h）を入力欄の下マージンに
   足していた。高さの測り方しだいで黒い余白が出たり消えたりする作りだった。
   いまは body を縦のflexにして [アプリ本体][タブ] を並べるだけなので、
   余白を計算する必要がない（セーフエリアはタブ自身の padding が持つ）。 */
html,body{ height:100%; overflow:hidden; overscroll-behavior:none }
body.has-bnav{ display:flex; flex-direction:column; height:100dvh; min-height:0 }
body.has-bnav .app{ flex:1 1 auto; min-height:0; height:auto; padding-bottom:0 }
body.has-bnav .main-col{ min-height:0 }
body.has-bnav .bar, body.has-bnav .composer{ flex:none }
body.has-bnav .splash{ position:fixed }
body.has-bnav .composer{ margin-bottom:8px }
body.has-bnav .chips{ padding-bottom:6px }
body.has-bnav .bnav{ position:static; flex:0 0 auto }
body.has-bnav .views{ position:static; flex:1 1 auto; min-height:0 }
/* シェル表示では一覧の最後が下タブ／ホームインジケータに重ならないよう、必ず下端に余白を残す
   （重なると「カードが無い」ように見える＝押せない・読めない）。 */
body.has-bnav .vwrap{ padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 56px) }
body.has-bnav .views{ overscroll-behavior:contain }
.toast2{ bottom:calc(env(safe-area-inset-bottom, 0px) + 74px) }
@supports not (height:100dvh){ body.has-bnav{ height:100% } }

body.has-bnav .bar{ padding-top: calc(env(safe-area-inset-top, 0px) + 16px) }

/* iOS: ステータスバーに潜り込ませない（env() が 0 を返す埋め込みブラウザでもヘッダーを沈めない） */
html.ios body.has-bnav .bar{padding-top:58px;padding-top:calc(max(env(safe-area-inset-top,0px),52px) + 6px)}
/* 実測した上端余白（JS が --wa-top を入れる）。env() が 0 を返す埋め込みブラウザでも沈めない。 */
html.wa-shell body.has-bnav .bar{ padding-top: calc(max(var(--wa-top, 0px), env(safe-area-inset-top, 0px)) + 16px) }
/* 高さも実測（可視ビューポート）に合わせる。dvh が実際に見えている高さとずれる環境の対策。 */
html.wa-shell body.has-bnav{ height: var(--wa-h, 100dvh) }

/* standalone（ホーム画面アプリ）は env() が 0 を返す端末がある。JS の実測が入る前でも沈まないよう下限 59px を保証する。 */
@media all and (display-mode: standalone){
  html.wa-shell body.has-bnav .bar, html.ios body.has-bnav .bar{ padding-top: calc(max(var(--wa-top, 0px), env(safe-area-inset-top, 0px), 59px) + 16px) }
}

/* header text must never be vertically clipped by the safe-area padding */
body.has-bnav .bar{align-items:center;min-height:0;padding-bottom:10px}
body.has-bnav .who{min-height:0;justify-content:center}
body.has-bnav .nm{line-height:1.3}
body.has-bnav .st{line-height:1.35;max-height:none}
body.has-bnav .chips{padding-right:18px;scroll-padding-right:18px}

/* the header row and its two text lines must never be clipped by a fixed box */
body.has-bnav .bar{height:auto!important;max-height:none!important;overflow:visible!important}
body.has-bnav .who{height:auto!important;max-height:none!important;overflow:visible!important}
body.has-bnav .nm,body.has-bnav .st{height:auto!important;max-height:none!important;overflow:visible!important;line-height:1.4}
