  :root {
    color-scheme: light;
    --bg: #ffffff; --panel: #ffffff; --side: #fff6ec; --text: #52483f; --muted: #948270;
    --line: #f3e6d6; --accent: #ee7f2d; --accent-weak: #fff0e0; --user: #fff0e0; --hover: #fdf0e2; --danger: #b91c1c; --ok: #15803d;
  }
  * { box-sizing: border-box; }
  html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
    font-family: "Yu Gothic UI", "游ゴシック", "Hiragino Sans", "Meiryo", system-ui, sans-serif; font-size: 15px; }
  button, select, input, textarea { font: inherit; color: inherit; }
  button { cursor: pointer; border: 1px solid var(--line); background: var(--panel); border-radius: 8px; padding: 6px 12px; }
  button:hover { border-color: var(--accent); }
  button.primary { background: var(--accent); color: #fff; border-color: var(--accent); }
  button.danger { color: var(--danger); }
  select, input[type=text], input[type=password], input[type=number], textarea {
    background: var(--panel); border: 1px solid var(--line); border-radius: 8px; padding: 6px 8px; }
  #app { display: grid; grid-template-columns: 260px 1fr; height: 100%; }
  aside { background: var(--side); border-right: 1px solid var(--line); display: flex; flex-direction: column; min-height: 0; }
  aside .top { padding: 12px; display: flex; gap: 8px; }
  aside .top button { flex: 1; }
  #chatList { flex: 1; overflow-y: auto; padding: 0 8px; }
  .chatItem { display: flex; align-items: center; gap: 4px; padding: 8px; border-radius: 8px; cursor: pointer; }
  .chatItem:hover { background: var(--panel); }
  .chatItem.active { background: var(--panel); border: 1px solid var(--line); }
  .chatItem .t { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
  .chatItem .del { border: none; background: transparent; color: var(--muted); padding: 2px 6px; }
  #usageBox { padding: 12px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); line-height: 1.6; }
  #usageBox b { color: var(--text); }
  .bar { height: 6px; background: var(--line); border-radius: 3px; overflow: hidden; margin-top: 4px; }
  .bar > div { height: 100%; background: var(--ok); }
  main { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
  header { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; padding: 10px 16px; border-bottom: 1px solid var(--line); background: var(--panel); }
  header label { font-size: 13px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
  header .spacer { flex: 1; }
  #messages { flex: 1; overflow-y: auto; padding: 20px 16px; }
  .msg { max-width: 860px; margin: 0 auto 16px; }
  .msg .who { font-size: 12px; color: var(--muted); margin-bottom: 4px; display: flex; gap: 8px; align-items: center; }
  .msg .body { padding: 12px 14px; border-radius: 12px; line-height: 1.75; overflow-wrap: anywhere; }
  .msg.user .body { background: var(--user); white-space: pre-wrap; }
  .msg.assistant .body { background: var(--panel); border: 1px solid var(--line); }
  .msg .files { font-size: 12px; color: var(--muted); margin-top: 4px; }
  .msg .meta { font-size: 12px; color: var(--muted); margin-top: 4px; display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
  .msg .meta button { padding: 2px 8px; font-size: 12px; }
  .msg .err { color: var(--danger); }
  .thinking { color: var(--muted); font-style: italic; }
  .body h1, .body h2, .body h3 { margin: 12px 0 6px; line-height: 1.4; }
  .body h1 { font-size: 1.3em; } .body h2 { font-size: 1.15em; } .body h3 { font-size: 1.05em; }
  .body p { margin: 6px 0; }
  .body ul, .body ol { margin: 6px 0; padding-left: 1.5em; }
  .body pre { background: var(--bg); border: 1px solid var(--line); border-radius: 8px; padding: 10px; overflow-x: auto; white-space: pre; }
  .body code { background: var(--bg); padding: 1px 4px; border-radius: 4px; font-family: Consolas, monospace; font-size: 0.92em; }
  .body pre code { background: none; padding: 0; }
  .body table { border-collapse: collapse; margin: 8px 0; display: block; overflow-x: auto; }
  .body th, .body td { border: 1px solid var(--line); padding: 4px 8px; text-align: left; }
  #empty { max-width: 640px; margin: 10vh auto; text-align: center; color: var(--muted); line-height: 1.9; }
  #empty h2 { color: var(--text); }
  footer { border-top: 1px solid var(--line); background: var(--panel); padding: 10px 16px; }
  #composer { max-width: 860px; margin: 0 auto; }
  #chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 6px; }
  .chip { font-size: 12px; background: var(--accent-weak); border-radius: 999px; padding: 3px 4px 3px 10px; display: flex; align-items: center; gap: 4px; }
  .chip button { border: none; background: transparent; padding: 0 6px; }
  .row { display: flex; gap: 8px; align-items: flex-end; }
  #input { flex: 1; resize: vertical; min-height: 56px; max-height: 40vh; }
  #hint { font-size: 12px; color: var(--muted); margin-top: 6px; display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
  #hint select { font-size: 12px; padding: 2px 4px; }
  .save { color: var(--ok); }
  .searchBox { padding: 0 12px 8px; }
  .searchBox input { width: 100%; }
  .chatItem .ren { border: none; background: transparent; color: var(--muted); padding: 2px 4px; }
  .noHit { padding: 8px; color: var(--muted); font-size: 13px; }
  .msg.sp-A .body, .msg.sp-B .body { max-width: 85%; }
  .msg.sp-A .body { background: var(--user); }
  .msg.sp-B { display: flex; flex-direction: column; align-items: flex-end; }
  .msg.sp-B .body { background: var(--accent-weak); }
  .msg.sp-mod .body { background: transparent; border: 1px dashed var(--line); font-size: 14px; }
  .msg.sp-sys .body { background: transparent; color: var(--danger); font-size: 13px; padding: 4px 0; }
  .rallyHead, .rallyBar { max-width: 860px; margin: 0 auto 16px; padding: 12px 14px; border: 1px solid var(--line);
    border-radius: 12px; background: var(--panel); font-size: 13px; line-height: 1.7; }
  .rallyBar { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
  .rallyBar .grow { flex: 1; }
  .row2 { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
  @media (max-width: 760px) { .row2 { grid-template-columns: 1fr; } }
  .field textarea.small { min-height: 70px; }
  #drop { position: fixed; inset: 0; background: rgba(194,65,12,.12); border: 3px dashed var(--accent); display: none;
    align-items: center; justify-content: center; font-size: 22px; z-index: 50; }
  dialog { border: 1px solid var(--line); border-radius: 12px; background: var(--panel); color: var(--text); width: min(640px, 94vw); padding: 20px; }
  dialog::backdrop { background: rgba(0,0,0,.35); }
  dialog h3 { margin-top: 0; }
  .field { margin-bottom: 14px; }
  .field > label { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
  .field input[type=text], .field input[type=password], .field input[type=number], .field textarea, .field select { width: 100%; }
  .field textarea { min-height: 180px; }
  .actions { display: flex; gap: 8px; justify-content: flex-end; flex-wrap: wrap; }
  .note { font-size: 12px; color: var(--muted); line-height: 1.6; }
  #toast { position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%); background: var(--text); color: var(--bg);
    padding: 8px 14px; border-radius: 8px; display: none; z-index: 60; font-size: 14px; }
  /* ===== 見た目(丸み・余白・影) ===== */
  html, body { font-family:"Yu Gothic Medium","游ゴシック Medium","游ゴシック体","Yu Gothic UI","Hiragino Sans","Meiryo",system-ui,sans-serif !important; }
  html, body { font-weight: 500; -webkit-text-stroke: 0.3px currentColor; }
  .msg.assistant .body, .msg.assistant .body * { -webkit-text-stroke: 0; font-weight: 400; }
  .msg.assistant .body b, .msg.assistant .body strong, .msg.assistant .body th, .msg.assistant .body h1, .msg.assistant .body h2, .msg.assistant .body h3 { font-weight: 700; }
  dialog, dialog * { -webkit-text-stroke: 0; }
  dialog { font-weight: 400; }
  dialog b, dialog strong, dialog h3, .field > label { font-weight: 600; }
  /* ===== 形(3案で共通):丸み・余白・影 ===== */
  :root { --r: 12px; --shadow: 0 1px 2px rgba(30,25,15,.05), 0 6px 18px rgba(30,25,15,.06); }
  button { border-radius: 10px; padding: 7px 14px; box-shadow: 0 1px 1px rgba(0,0,0,.03); transition: background .15s, border-color .15s, box-shadow .15s; }
  button:hover { background: var(--hover); border-color: var(--line); }
  button.primary { box-shadow: 0 1px 2px rgba(0,0,0,.12); }
  button.primary:hover { background: var(--accent); filter: brightness(1.06); border-color: var(--accent); }
  select, input[type=text], input[type=password], input[type=number], textarea { border-radius: 10px; padding: 7px 10px; }
  select:focus, input:focus, textarea:focus { outline: 2px solid var(--accent-weak); border-color: var(--accent); }
  #app { grid-template-columns: 272px 1fr; }
  aside .top { padding: 6px 12px; }
  aside .top:first-child { padding-top: 14px; }
  aside .top button { text-align: left; border-color: transparent; background: transparent; box-shadow: none; padding: 9px 12px; font-size: 14px; }
  aside .top button:hover { background: var(--hover); }
  aside .top button.primary { text-align: center; background: var(--accent); color: #fff; padding: 10px 12px; box-shadow: 0 1px 2px rgba(0,0,0,.15); }
  aside .top button.primary:hover { background: var(--accent); }
  .searchBox { padding: 6px 12px 10px; }
  .chatItem { padding: 9px 10px; border-radius: 10px; border: 1px solid transparent; font-size: 14px; }
  .chatItem:hover { background: var(--hover); }
  .chatItem.active { background: var(--panel); border-color: var(--line); box-shadow: var(--shadow); }
  #usageBox { padding: 14px 16px 10px; border-top-color: var(--line); }
  header { padding: 10px 24px; gap: 8px 14px; background: var(--bg); border-bottom: 1px solid var(--line); }
  header label { font-size: 12.5px; }
  #model { max-width: 190px; }
  #messages { padding: 28px 24px; }
  .msg { max-width: 800px; margin-bottom: 22px; }
  .msg .who { font-size: 12px; margin-bottom: 6px; }
  .msg .body { border-radius: 16px; padding: 14px 18px; }
  .msg.user { display: flex; flex-direction: column; align-items: flex-end; }
  .msg.user .body { max-width: 78%; border-radius: 18px 18px 4px 18px; }
  .body pre { border-radius: 10px; }
  .body table { border-radius: 8px; }
  .body th { background: var(--hover); }
  .msg .meta button { border-radius: 8px; }
  footer { border-top: none; background: transparent; padding: 8px 24px 16px; }
  #composer { max-width: 800px; }
  #composer .row { background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 10px; box-shadow: var(--shadow); align-items: flex-end; }
  #input { border: none; background: transparent; outline: none !important; min-height: 48px; padding: 8px 6px; }
  #composer .row button { border-color: transparent; background: transparent; box-shadow: none; }
  #composer .row button:hover { background: var(--hover); }
  #composer .row button.primary { background: var(--accent); color: #fff; padding: 9px 20px; }
  #hint { margin-top: 8px; padding: 0 6px; }
  .bar { height: 8px; border-radius: 4px; }
  dialog { border-radius: 18px; box-shadow: 0 20px 60px rgba(0,0,0,.25); border: none; }

  button.primary, aside .top button.primary, #composer .row button.primary { color:#fff; }
  .msg .who { display:none; }
  header { background:transparent; border:none; }
  aside { border-right:none; }
  .msg .meta button { border-radius:999px; background:transparent; border:1px solid var(--line); padding:2px 11px; font-size:12px; color:var(--muted); }
  .msg .meta button:hover { background:var(--hover); }
  .body pre { background:#f6ead9 !important; color:var(--text); border:1px solid var(--line); border-radius:12px; }
  .body pre code, .body code { background:transparent !important; }
  .body th { background:var(--hover); }
  dialog { width:min(700px,94vw); padding:28px 32px 24px; background:var(--panel); border-radius:22px; box-shadow:0 24px 70px rgba(60,35,10,.28); }
  dialog::backdrop { background:rgba(60,35,10,.35); backdrop-filter:blur(2px); }
  dialog h3 { font-size:19px; margin:0 0 6px; }
  .field { background:none; border:none; border-bottom:1px solid var(--line); border-radius:0; padding:16px 0; margin:0; }
  .field > label { color:var(--text); font-weight:600; font-size:13.5px; margin-bottom:8px; }
  .field input[type=text], .field input[type=password], .field input[type=number], .field textarea, .field select { background:var(--bg); border:1px solid var(--line); }
  .note { color:var(--muted); }
  dialog .actions button { border-radius:999px; }

  .msg.assistant .body { background:transparent; box-shadow:none; border:none; padding:2px; font-size:15.5px; line-height:1.95; }
  .msg.user .body { background:var(--user); color:var(--text); border-radius:22px; }
  .chatItem:hover { background:#ffe3c7; }
  .chatItem.active { background:#ffd6ae; border-color:transparent; box-shadow:none; font-weight:600; }
  .chatItem.active:hover { background:#ffd6ae; }
  aside .top button.primary { background:var(--accent); color:#fff; }
  button.primary, #composer .row button.primary { background:var(--accent); }
  #composer .row { border:1px solid var(--line); box-shadow:0 6px 24px rgba(120,70,20,.10); border-radius:26px; }
  a { color:var(--accent); }
  /* ===== 待っている間の表示(動く輪・点・あと何秒か) ===== */
  .waiting { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 8px; color: var(--muted); font-size: 14px; font-style: normal; margin: 4px 0; }
  .waiting .spin { width: 14px; height: 14px; border: 2px solid var(--accent-weak); border-top-color: var(--accent); border-radius: 50%; animation: wspin .8s linear infinite; flex: none; }
  .waiting .wtxt { color: var(--text); }
  .waiting .wdots i { display: inline-block; width: 5px; height: 5px; margin-left: 3px; border-radius: 50%; background: var(--accent); opacity: .25; animation: wdot 1.2s infinite ease-in-out; }
  .waiting .wdots i:nth-child(2) { animation-delay: .2s; }
  .waiting .wdots i:nth-child(3) { animation-delay: .4s; }
  @keyframes wspin { to { transform: rotate(360deg); } }
  @keyframes wdot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
  @media (prefers-reduced-motion: reduce) { .waiting .spin, .waiting .wdots i { animation: none; } .waiting .wdots i { opacity: .7; } }
  /* ===== 入力欄: 入力の窓だけを丸く作り、添付・コードは窓の外(下)に置く。窓は1行から始まり、行が増えると上に伸びる ===== */
  #composer .row { display: grid; grid-template-columns: auto auto 1fr auto; grid-template-areas: "inp inp inp snd" "att code . ."; gap: 4px 8px; align-items: end; background: transparent; border: none; box-shadow: none; border-radius: 0; padding: 0; }
  #composer .row #input { grid-area: inp; width: 100%; box-sizing: border-box; field-sizing: content; min-height: 0; height: auto; max-height: 40vh; resize: none; padding: 12px 18px; line-height: 1.6; text-align: left; overflow-y: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 26px; box-shadow: 0 6px 24px rgba(120,70,20,.10); }
  #composer .row #sendBtn, #composer .row #stopBtn { grid-area: snd; align-self: end; height: 46px; border-radius: 23px; }
  #composer .row #attachBtn { grid-area: att; }
  #composer .row #codeBtn { grid-area: code; }
  #composer .row #attachBtn, #composer .row #codeBtn { padding: 4px 10px; font-size: 13px; color: var(--muted); }
  @media (max-width: 760px) {
    #app { grid-template-columns: 1fr; }
    aside { display: none; }
    aside.open { display: flex; position: fixed; inset: 0 30% 0 0; z-index: 40; }
    #menuBtn { display: inline-block !important; }
  }
