/*
 * Chat and language toggle, shared by the build report and the operating guide.
 *
 * Both pages carry the same panel, the same history and the same launcher, so
 * the styles live here rather than being copied into each document and drifting
 * apart. Page specific layout stays in the page.
 */
  /* ---------- language toggle ---------- */
  .lang{position:fixed;top:14px;right:14px;z-index:50;display:inline-flex;
    background:rgba(255,255,255,.14);border:1px solid rgba(255,255,255,.3);
    border-radius:100px;padding:3px;backdrop-filter:blur(8px)}
  .lang button{font:inherit;font-family:var(--ui);font-size:12px;font-weight:600;
    letter-spacing:.08em;color:rgba(255,255,255,.8);background:none;border:0;cursor:pointer;
    padding:0 13px;min-height:32px;border-radius:100px}
  .lang button[aria-pressed="true"]{background:#fff;color:var(--violet)}
  /* Past the hero the page is white, so the pill needs its own ground. */
  .lang.solid{background:var(--paper);border-color:var(--rule);box-shadow:0 6px 20px -10px rgba(22,18,28,.4)}
  .lang.solid button{color:var(--muted)}
  .lang.solid button[aria-pressed="true"]{background:var(--violet);color:#fff}

  .chat-launch{position:fixed;right:16px;bottom:16px;bottom:max(16px,env(safe-area-inset-bottom));
    z-index:45;font:inherit;font-size:14px;font-weight:700;color:#fff;cursor:pointer;
    display:inline-flex;align-items:center;gap:9px;min-height:52px;padding:0 22px;border:0;
    border-radius:100px;background:linear-gradient(135deg,#5b2d8e,#7c4dbb);
    box-shadow:0 18px 44px -18px rgba(43,20,66,.75);transition:transform .16s ease,opacity .18s ease}
  .chat-launch:hover{transform:translateY(-2px)}
  .chat-launch svg{width:19px;height:19px;stroke:#fff;fill:none;stroke-width:1.8;
    stroke-linecap:round;stroke-linejoin:round}

  .chat[hidden]{display:none}
  .chat{position:fixed;inset:0;z-index:60;background:rgba(22,18,28,.5);
    display:flex;align-items:flex-end;justify-content:center}
  .chat-panel{width:100%;max-width:640px;height:88dvh;max-height:88dvh;min-height:0;
    display:flex;flex-direction:column;background:var(--paper);
    border-radius:20px 20px 0 0;box-shadow:0 -20px 60px -30px rgba(22,18,28,.7);
    animation:rise .22s ease;overflow:hidden}
  @keyframes rise{from{transform:translateY(16px);opacity:0}to{transform:none;opacity:1}}
  @keyframes slidein{from{transform:translateX(18px);opacity:0}to{transform:none;opacity:1}}

  .chat-head{padding:16px 18px 14px;border-bottom:1px solid var(--rule);
    background:linear-gradient(160deg,#2a1442,#5b2d8e 70%,#7c4dbb)}
  .chat-head-top{display:flex;align-items:flex-start;justify-content:space-between;gap:10px}
  .chat-head h2{color:#fff;font-size:15.5px;margin:0;line-height:1.6}
  .chat-head p{color:rgba(255,255,255,.76);font-size:12px;margin:5px 0 0;line-height:1.7}
  .chat-close{font:inherit;font-size:26px;line-height:1;background:none;border:0;
    color:rgba(255,255,255,.72);cursor:pointer;min-width:44px;min-height:44px;padding:0}
  .chat-close:hover{color:#fff}
  /* [hidden] sets display:none in the UA sheet only, and an author rule of
     display:grid or display:flex beats it. Without these two lines the history
     pane opens on top of a log that is still laid out underneath it. */
  .chat-log[hidden],.chat-form[hidden]{display:none}
  .chat-acts{display:flex;align-items:center;gap:6px;margin-top:12px;flex-wrap:wrap}
  .chat-btn{font:inherit;font-size:12px;font-family:var(--ui);letter-spacing:.04em;
    background:rgba(255,255,255,.12);border:1px solid rgba(255,255,255,.24);color:#fff;
    border-radius:100px;padding:0 12px;min-height:32px;cursor:pointer;white-space:nowrap}
  .chat-btn:hover{background:rgba(255,255,255,.22)}
  .chat-btn[aria-pressed="true"]{background:#fff;color:var(--violet);border-color:#fff}

  /* 履歴 pane. Slides over the log rather than beside it, because at 375px
     there is no beside. */
  .hist[hidden]{display:none}
  .hist{flex:1 1 auto;min-height:0;overflow-y:auto;padding:16px 20px 20px;background:var(--wash)}
  .hist h3{font-size:13px;font-family:var(--ui);letter-spacing:.1em;text-transform:uppercase;
    color:var(--muted);font-weight:600;margin:0 0 12px}
  .hist-empty{font-size:13.5px;color:var(--muted);padding:18px 0}
  .hist-list{list-style:none;margin:0;padding:0;display:grid;gap:8px}
  .hist-list li{display:flex;align-items:stretch;gap:0;background:var(--paper);
    border:1px solid var(--rule);border-radius:12px;overflow:hidden}
  .hist-list li.on{border-color:var(--violet)}
  .hist-open{flex:1 1 auto;min-width:0;font:inherit;text-align:left;background:none;border:0;
    cursor:pointer;padding:13px 15px;color:var(--body)}
  .hist-open b{display:block;color:var(--ink);font-size:14px;font-weight:700;line-height:1.6;
    overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;
    -webkit-box-orient:vertical}
  .hist-open span{display:block;font-size:11.5px;color:var(--muted);margin-top:4px;
    font-family:var(--ui);letter-spacing:.04em}
  .hist-del{flex:0 0 auto;font:inherit;font-size:18px;line-height:1;background:none;border:0;
    border-left:1px solid var(--rule);color:var(--muted);cursor:pointer;width:46px}
  .hist-del:hover{color:#b3261e;background:var(--violet-dim)}
  .hist-foot{margin-top:16px;padding-top:14px;border-top:1px solid var(--rule);
    display:flex;align-items:center;justify-content:space-between;gap:12px;flex-wrap:wrap}
  .hist-note{font-size:11.5px;color:var(--muted);line-height:1.7;flex:1 1 200px}
  .hist-clear{font:inherit;font-size:12px;font-family:var(--ui);background:none;
    border:1px solid var(--rule);border-radius:100px;color:var(--muted);
    padding:0 14px;min-height:34px;cursor:pointer}
  .hist-clear:hover{border-color:#b3261e;color:#b3261e}

  .chat-log{flex:1 1 auto;min-height:0;overflow-y:auto;overscroll-behavior:contain;
    padding:20px;display:grid;gap:14px;align-content:start;background:var(--wash)}
  .msg{display:flex}
  .msg.me{justify-content:flex-end}
  .bubble{max-width:88%;min-width:0;padding:13px 16px;border-radius:14px;
    font-size:14.5px;line-height:1.9;overflow-wrap:anywhere}
  .msg.bot .bubble{background:var(--paper);border:1px solid var(--rule);color:var(--body);
    border-bottom-left-radius:5px}
  .msg.me .bubble{background:linear-gradient(135deg,#5b2d8e,#7c4dbb);color:#fff;
    border-bottom-right-radius:5px}
  .bubble p{margin:0 0 10px}
  .bubble p:last-child{margin-bottom:0}
  .bubble ul,.bubble ol{margin:6px 0 10px;padding-left:1.3em;display:grid;gap:5px}
  .bubble strong{color:var(--ink)}
  .msg.me .bubble strong{color:#fff}
  .bubble code{font-size:.88em;background:var(--violet-dim);color:var(--violet);
    padding:.1em .4em;border-radius:5px;overflow-wrap:anywhere}
  .msg.me .bubble code{background:rgba(255,255,255,.2);color:#fff}

  .cites{margin-top:12px;padding-top:10px;border-top:1px solid var(--rule);
    display:flex;flex-wrap:wrap;gap:6px;align-items:center}
  .cites-label{font-family:var(--ui);font-size:10px;letter-spacing:.14em;text-transform:uppercase;
    color:var(--muted);margin-right:2px}
  .cites a{font-size:11.5px;padding:4px 10px;border-radius:100px;text-decoration:none;
    background:var(--violet-dim);color:var(--violet);line-height:1.6}
  .cites a:hover{outline:1px solid var(--violet)}
  .cite-flat{font-size:11.5px;padding:4px 10px;border-radius:100px;line-height:1.6;
    background:var(--wash);border:1px solid var(--rule);color:var(--muted)}

  .starters{display:flex;flex-wrap:wrap;gap:8px}
  .starters button{font:inherit;font-size:13px;cursor:pointer;text-align:left;
    padding:10px 14px;min-height:44px;border-radius:100px;background:var(--paper);
    border:1px solid var(--rule);color:var(--body)}
  .starters button:hover{border-color:var(--violet);color:var(--violet)}

  .thinking{display:inline-flex;gap:3px;align-items:flex-end;height:15px}
  .thinking i{width:3px;height:100%;border-radius:2px;background:var(--violet);opacity:.35;
    animation:bar 1s ease-in-out infinite}
  .thinking i:nth-child(2){animation-delay:.12s}
  .thinking i:nth-child(3){animation-delay:.24s}
  .thinking i:nth-child(4){animation-delay:.36s}
  .thinking i:nth-child(5){animation-delay:.48s}
  @keyframes bar{0%,100%{transform:scaleY(.4);opacity:.35}50%{transform:scaleY(1);opacity:1}}

  .chat-form{display:flex;gap:9px;padding:14px 16px;
    padding-bottom:max(14px,env(safe-area-inset-bottom));
    border-top:1px solid var(--rule);background:var(--paper)}
  .chat-form input{font:inherit;font-size:16px;flex:1 1 auto;min-width:0;min-height:48px;
    padding:11px 18px;border:1px solid var(--rule);border-radius:100px;
    background:var(--paper);color:var(--ink)}
  .chat-form input:focus{outline:2px solid var(--violet-lo);outline-offset:1px;border-color:transparent}
  .chat-form button{flex:0 0 auto;width:48px;height:48px;border:0;border-radius:50%;cursor:pointer;
    background:linear-gradient(135deg,#5b2d8e,#7c4dbb);color:#fff;display:grid;place-items:center}
  .chat-form button:disabled{opacity:.45;cursor:not-allowed}
  .chat-form button svg{width:19px;height:19px;stroke:#fff;fill:none;stroke-width:1.9;
    stroke-linecap:round;stroke-linejoin:round}

  @media(min-width:640px){
    .chat{align-items:center;padding:24px}
    .chat-panel{border-radius:20px;height:min(680px,86dvh)}
  }

  /* From here the chat docks as a right hand column and pushes the page, so the
     report stays readable beside the answer that cites it. */
  @media(min-width:1024px){
    .chat{inset:0 0 0 auto;width:400px;background:none;padding:0;display:block;pointer-events:none}
    .chat-panel{pointer-events:auto;width:100%;max-width:none;height:100dvh;max-height:100dvh;
      border-radius:0;border-left:1px solid var(--rule);animation:slidein .22s ease;
      box-shadow:-18px 0 48px -32px rgba(22,18,28,.4)}
    html.chat-open{padding-right:400px}
    html.chat-open .chat-launch{opacity:0;pointer-events:none}
  }
