* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; font: 13px/1.5 -apple-system, BlinkMacSystemFont, "PingFang SC", "Noto Sans SC", sans-serif; background: #f5f5f5; color: #1f2329; }
body { height: 100dvh; }
.hidden { display: none !important; }
.whale { font-size: 48px; line-height: 1; }
.whale.sm { font-size: 26px; }
.gate { min-height: 100%; display: grid; place-items: center; background: linear-gradient(180deg, #eef3ff, #f7f7f8); padding: 24px 16px; }
.gate-card { width: min(360px, 100%); background: #fff; border-radius: 16px; padding: 32px 24px; box-shadow: 0 12px 40px rgba(15,23,42,.08); text-align: center; }
.gate-card h1 { margin: 8px 0 4px; }
.gate-card p { color: #667085; margin: 0 0 16px; }
.gate-card input, .gate-card button, .composer textarea, .composer button, .new, .ghost, .pick-bar button {
  width: 100%; border: 1px solid #e5e7eb; border-radius: 10px; padding: 10px 12px; font: inherit;
}
.gate-card button, .new, #send { background: #4d6bfe; color: #fff; border: 0; cursor: pointer; font-weight: 600; margin-top: 10px; }
#send:disabled, .pick-bar button:disabled { opacity: .55; cursor: wait; }
.err { color: #c00; min-height: 1.2em; }
.app { display: flex; height: 100%; min-height: 0; position: relative; overflow: hidden; }
.side { width: 280px; background: #f7f8fa; border-right: 1px solid #eceef2; padding: 14px; display: flex; flex-direction: column; gap: 10px; z-index: 20; overflow: hidden; transition: width .2s ease, padding .2s ease, opacity .15s ease, border-width .2s ease; }
.app.side-collapsed .side { width: 0; padding: 0; border-right-width: 0; opacity: 0; pointer-events: none; }
.side-head { display: flex; gap: 8px; align-items: center; }
.side-head .new { margin-top: 0; }
.side-hint { margin: 0; color: #98a2b3; font-size: 12px; }
.list { flex: 1; overflow: auto; display: flex; flex-direction: column; gap: 6px; }
.item-row { display: flex; gap: 6px; align-items: stretch; }
.item { flex: 1; text-align: left; border: 0; background: transparent; border-radius: 10px; padding: 10px 12px; cursor: pointer; color: #344054; min-width: 0; }
.item.active, .item:hover { background: #eceef5; }
.rename { flex: none; width: 52px; border: 0; background: #fff; border-radius: 10px; color: #667085; cursor: pointer; font-size: 12px; }
.rename-input { flex: 1; border: 1px solid #4d6bfe; border-radius: 10px; padding: 8px 10px; font: inherit; }
.ghost { background: #fff; color: #475467; margin-top: auto; cursor: pointer; }
.main { flex: 1; display: flex; flex-direction: column; min-width: 0; min-height: 0; background: #fff; overflow: hidden; }
.top { display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-bottom: 1px solid #f0f0f0; padding-top: max(10px, env(safe-area-inset-top)); }
.top-actions { margin-left: auto; display: flex; gap: 8px; flex: none; align-items: center; }
.pause-btn { border: 1px solid #e5e7eb; background: #fff; border-radius: 10px; padding: 6px 10px; font: inherit; cursor: pointer; color: #344054; white-space: nowrap; }
#pickModeBtn.on { background: #eef2ff; border-color: #4d6bfe; color: #3538cd; }
.alarm-toast { position: fixed; right: 16px; bottom: 24px; z-index: 40; background: #111827; color: #fff; border-radius: 14px; padding: 14px 16px; max-width: min(360px, 88vw); box-shadow: 0 12px 32px rgba(0,0,0,.24); }
.alarm-toast strong { display: block; margin-bottom: 4px; }
.pause-btn.on { background: #fef3c7; border-color: #fcd34d; color: #92400e; }
.who { display: flex; align-items: center; gap: 8px; font-size: 16px; }
.icon-btn { width: 40px; height: 40px; border: 0; background: #f2f4f7; border-radius: 10px; cursor: pointer; font-size: 18px; flex: none; }
#openSide { display: none; }
.app.side-collapsed #openSide { display: inline-grid; place-items: center; }
.thread { flex: 1; min-height: 0; overflow-y: auto; overflow-x: hidden; padding: 20px 16% 12px; -webkit-overflow-scrolling: touch; overscroll-behavior: contain; touch-action: pan-y; }
.empty { color: #98a2b3; text-align: center; margin-top: 16vh; padding: 0 20px; }
.row { display: flex; gap: 10px; margin: 0 0 16px; align-items: flex-start; }
.row.me { flex-direction: row-reverse; }
.pick { margin-top: 8px; width: 18px; height: 18px; flex: none; accent-color: #4d6bfe; }
.bubble { max-width: min(720px, 82%); background: #f4f4f5; border-radius: 12px; padding: 8px 12px; font-size: 13px; white-space: pre-wrap; word-break: break-word; }
.row.me .bubble { background: #4d6bfe; color: #fff; }
.bubble.pending { opacity: .85; }
.bubble.thinking { color: #667085; font-style: italic; }
.think { margin: 0 0 8px; border: 1px solid #eceef2; border-radius: 10px; background: #fafafa; }
.think summary { cursor: pointer; padding: 6px 10px; color: #667085; font-size: 12px; list-style: none; }
.think summary::-webkit-details-marker { display: none; }
.think-body { padding: 0 10px 8px; color: #667085; font-size: 12px; line-height: 1.45; max-height: 220px; overflow: auto; white-space: pre-wrap; }
.av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; background: #eef2ff; flex: none; }
.file-card { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-top: 8px; padding-top: 8px; border-top: 1px solid rgba(0,0,0,.06); }
.file-card a { color: #4d6bfe; text-decoration: none; background: #eef2ff; padding: 6px 10px; border-radius: 8px; font-size: 13px; }
.row.me .file-card a { background: rgba(255,255,255,.18); color: #fff; }
.thumbs { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.thumbs img, .thumbs a.file-chip { max-width: 220px; max-height: 160px; border-radius: 10px; object-fit: cover; background: #fff; }
.thumbs a.file-chip { display: inline-flex; align-items: center; padding: 8px 10px; text-decoration: none; color: inherit; border: 1px solid rgba(0,0,0,.08); max-width: none; }
.attach-box { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 0 8px; }
.attach-chip { display: flex; align-items: center; gap: 6px; background: #f2f4f7; border-radius: 10px; padding: 6px 8px; font-size: 12px; }
.attach-chip img { width: 36px; height: 36px; object-fit: cover; border-radius: 6px; }
.attach-chip button { border: 0; background: transparent; cursor: pointer; color: #667085; }
.composer-row { display: flex; gap: 8px; align-items: flex-end; }
.composer .tool { width: auto; flex: none; background: #fff; color: #344054; border: 1px solid #e5e7eb; margin-top: 0; padding: 10px 12px; border-radius: 10px; cursor: pointer; }
#micBtn.hold { touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; min-width: 88px; }
#micBtn.rec { background: #fee4e2; color: #b42318; border-color: #fda29b; }
.voice-tag { margin-left: 8px; font-size: 12px; color: #4d6bfe; font-weight: 500; }
.bubble audio { width: min(260px, 100%); margin-top: 8px; }
.pick-bar { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 8px 16%; border-top: 1px solid #f0f0f0; background: #f8fafc; flex-wrap: wrap; }
.pick-bar span { color: #475467; font-size: 13px; }
.pick-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.pick-bar button { width: auto; background: #fff; cursor: pointer; margin: 0; }
.composer { display: flex; flex-direction: column; padding: 12px 16%; padding-bottom: max(12px, env(safe-area-inset-bottom)); border-top: 1px solid #f0f0f0; background: #fff; }
.composer textarea { resize: none; min-height: 52px; max-height: 160px; flex: 1; width: auto; }
.composer #send { width: 88px; margin-top: 0; flex: none; }
.backdrop,
.backdrop[hidden] { display: none; pointer-events: none; }
@media (max-width: 860px) {
  #openSide { display: inline-grid; place-items: center; }
  .app.side-collapsed .side { width: min(86vw, 300px); padding: 14px; border-right-width: 1px; opacity: 1; }
  .side { position: fixed; inset: 0 auto 0 0; width: min(86vw, 300px); transform: translateX(-105%); transition: transform .2s ease; box-shadow: none; padding-bottom: max(14px, env(safe-area-inset-bottom)); }
  .app.side-open .side { transform: none; box-shadow: 8px 0 28px rgba(15,23,42,.16); opacity: 1; pointer-events: auto; }
  .app.side-open .backdrop { display: block; position: fixed; inset: 0; background: rgba(15,23,42,.35); z-index: 15; border: 0; pointer-events: auto; }
  .thread, .composer, .pick-bar { padding-left: 12px; padding-right: 12px; }
  .pick-bar { flex-direction: column; align-items: stretch; }
  .pick-actions { width: 100%; }
  .pick-bar button { flex: 1; min-height: 40px; }
  .bubble { max-width: 86%; }
  .composer textarea { min-height: 44px; }
  .top-actions { flex-wrap: wrap; justify-content: flex-end; }
  .composer-row { flex-wrap: wrap; }
  .composer textarea { min-width: 0; width: 100%; order: -1; flex: 1 0 100%; }
}

