/* 聊天面板（src/chat_view.mjs）。用设计系统「不打盹像素」的变量和部件（ds/，都在 .bd 下）；
   这里只补面板在抽屉里的位置、气泡、选项和最下面那一行输入。 */

/* 竖屏：面板占满抽屉（顶上留一条看得见店），里面只有对话那一块滚动，输入那一行一直贴着底 */
.chat-host { overflow: hidden; }
.chat-host > .chat-panel {
  flex: 1 1 auto; min-height: 0; max-width: 560px; margin-top: 0; gap: var(--space-3);
  border-left: 0; border-right: 0; border-bottom: 0; box-shadow: none;
  padding-bottom: calc(var(--space-3) + env(safe-area-inset-bottom));
}
.chat-panel .bd-panel__title:focus { outline: none; }

.chat-list {
  flex: 1 1 auto; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; overscroll-behavior: contain;
  display: flex; flex-direction: column; gap: var(--space-3); padding: var(--space-1) 0;
}
/* 话少的时候贴着底（靠近手指和输入框），多了从上往下排 */
.chat-list > :first-child { margin-top: auto; }

/* 气泡：她的在右边（金色），收银机的在左边（卡片底）。字可以选中、复制（起草的文案要能拿走） */
.chat-msg {
  margin: 0; max-width: 86%; padding: var(--space-2) var(--space-3); font: 400 16px/24px var(--font-sans);
  white-space: pre-wrap; overflow-wrap: anywhere; user-select: text; -webkit-user-select: text;
}
.chat-msg.is-reg { align-self: flex-start; background: var(--card); color: var(--paper); box-shadow: inset 0 0 0 2px var(--line); }
.chat-msg.is-me { align-self: flex-end; background: var(--gold); color: var(--ink); }
.chat-msg.is-sending { opacity: 0.6; }
.chat-msg.is-failed { box-shadow: inset 0 0 0 2px var(--copper); }

/* 它正在做什么 */
.chat-progress { margin: 0; display: flex; align-items: center; gap: var(--space-2); color: var(--muted); font: 400 14px/20px var(--font-sans); min-height: 24px; }
.chat-progress .bd-dots i { background: var(--muted); }

/* 能点的：选项、开头那几句、重新问。和卡片里的按钮一个字号，一行排不下就换行 */
.chat-opts { display: flex; flex-wrap: wrap; gap: var(--space-2); }
.chat-panel .chat-opt { flex: 1 1 auto; min-width: 96px; min-height: 46px; padding: 10px 16px; font: 700 16px/24px var(--font-sans); white-space: normal; }
.chat-empty, .chat-note { display: flex; flex-direction: column; gap: var(--space-2); }
.chat-note .chat-opt { align-self: flex-start; flex: 0 0 auto; }

/* 最下面：想打字也行。输入框 16px（小了 iPhone 会把页面放大） */
.chat-compose { flex: 0 0 auto; display: flex; gap: var(--space-2); align-items: stretch; }
.chat-compose .bd-input { flex: 1 1 auto; min-width: 0; padding-left: 8px; padding-right: 8px; } /* 窄屏上四样排一行：留够「想打字也行」 */
.chat-compose .bd-input::placeholder { color: var(--muted); }
.chat-panel .chat-send { flex: 0 0 auto; min-width: 56px; min-height: 46px; padding: 2px 14px 6px 12px; }

/* 按住说话：和输入框、发送在同一行。按住时变成天蓝（不用红：红点像新消息提醒）。
   touch-action: none 才不会一按住就被当成滚动而中断；不让选字、不出长按菜单 */
.chat-panel .chat-mic {
  flex: 0 0 auto; min-width: 44px; min-height: 46px; padding: 2px 12px 6px 10px; display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: 700 16px/24px var(--font-sans); white-space: nowrap;
  touch-action: none; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent;
}
.chat-mic .bd-icon { width: 20px; height: 20px; flex: 0 0 auto; fill: currentColor; }
.chat-panel .chat-mic.is-rec { background: var(--sky); color: var(--ink); box-shadow: inset -4px -4px 0 #3fa9b0; transform: translate(2px, 2px); }
.chat-panel .chat-mic.is-rec.is-out { background: var(--raise); color: var(--paper); box-shadow: inset 0 0 0 2px var(--copper); }

/* 输入框上面那一行：正在听 / 正在听写 / 没听清 / 撤回。没有内容就不占地方 */
.chat-voice-status {
  flex: 0 0 auto; display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); color: var(--paper); font: 400 16px/24px var(--font-sans);
}
.chat-voice-status:empty { display: none; }
.chat-voice-status.is-out { color: var(--copper); }
.chat-voice-status .bd-dots i { background: var(--sky); }
.chat-panel .chat-undo { min-height: 44px; min-width: 56px; padding: 2px 12px 6px; font: 700 16px/24px var(--font-sans); }
.chat-bars { display: inline-flex; align-items: flex-end; gap: 3px; height: 18px; }
.chat-bars i { width: 4px; height: 6px; background: var(--sky); animation: chat-bar 0.9s steps(1) infinite; }
.chat-bars i:nth-child(2) { animation-delay: 0.2s; } .chat-bars i:nth-child(3) { animation-delay: 0.4s; } .chat-bars i:nth-child(4) { animation-delay: 0.6s; }
@keyframes chat-bar { 0% { height: 6px; } 25% { height: 14px; } 50% { height: 18px; } 75% { height: 10px; } }
@media (prefers-reduced-motion: reduce) { .chat-bars i { animation: none; height: 12px; } }

/* ---------- 第二批：发图、前几天、开头那一条、还挂着的事 ---------- */

/* 列表上面一条细的：左边还挂着几件，右边前几天。不加色、不加数字红点 */
.chat-bar { flex: 0 0 auto; display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); margin: calc(var(--space-2) * -1) 0 calc(var(--space-1) * -1); }
.chat-panel .chat-bar__btn {
  min-height: 44px; padding: 0 var(--space-2); display: inline-flex; align-items: center; gap: var(--space-2);
  background: none; border: 0; color: var(--muted); font: 400 14px/20px var(--font-sans); cursor: pointer; -webkit-tap-highlight-color: transparent;
}
.chat-panel .chat-bar__btn:focus-visible { outline: 2px dashed currentColor; outline-offset: -6px; }
.chat-bar__days { margin-left: auto; }
.chat-caret { width: 0; height: 0; border-left: 5px solid currentColor; border-top: 5px solid transparent; border-bottom: 5px solid transparent; }
.chat-caret.is-open { border-left: 5px solid transparent; border-right: 5px solid transparent; border-top: 5px solid currentColor; border-bottom: 0; }
.chat-bar--past { justify-content: flex-start; margin: 0; min-height: 36px; }
.chat-pastday { color: var(--muted); font: 700 14px/20px var(--font-sans); }

/* 还挂着的清单：短，超出就在里面滚 */
.chat-items { flex: 0 0 auto; margin: 0; padding: 0; list-style: none; max-height: 34vh; overflow-y: auto; display: flex; flex-direction: column; gap: var(--space-2); }
.chat-item { display: flex; align-items: center; justify-content: space-between; gap: var(--space-2); padding: var(--space-2) var(--space-3); background: var(--card); box-shadow: inset 0 0 0 2px var(--line); }
.chat-item__title { flex: 1 1 auto; min-width: 0; color: var(--paper); font: 400 16px/22px var(--font-sans); overflow-wrap: anywhere; }
.chat-item__btns { flex: 0 0 auto; display: flex; gap: var(--space-2); }
.chat-panel .chat-item__btn { min-width: 56px; min-height: 44px; padding: 2px 10px 6px; font: 700 16px/24px var(--font-sans); }

/* 每天开头那一条：上面一行小小的日子，下面是收银机的一句话 */
.chat-opener { display: flex; flex-direction: column; align-items: flex-start; gap: var(--space-2); max-width: 100%; }
.chat-day { margin: 0; color: var(--muted); font: 400 12px/16px var(--font-sans); letter-spacing: 0.05em; }
.chat-panel .chat-week { flex: 0 0 auto; }

/* 她发的图：气泡里固定大小的小图，点开看大的；图没了就一句话 */
.chat-msg .chat-thumb { display: block; margin: 0 0 var(--space-2); padding: 0; border: 0; background: var(--ink); cursor: pointer; -webkit-tap-highlight-color: transparent; }
.chat-msg .chat-thumb img { display: block; width: 132px; height: 132px; object-fit: cover; image-rendering: auto; box-shadow: inset 0 0 0 2px var(--line); }
.chat-msg .chat-thumb:focus-visible { outline: 2px dashed currentColor; outline-offset: 2px; }
.chat-gone { display: block; margin: 0 0 var(--space-2); color: var(--muted); font: 400 14px/20px var(--font-sans); }
.chat-msg.is-me .chat-gone { color: var(--ink); }
.chat-lightbox {
  position: fixed; inset: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: var(--space-3);
  background: rgba(0, 0, 0, 0.88); cursor: zoom-out;
}
.chat-lightbox img { max-width: 100%; max-height: 100%; object-fit: contain; }
.chat-panel .chat-lightbox__close { position: absolute; top: calc(var(--space-3) + env(safe-area-inset-top)); right: var(--space-3); min-width: 64px; min-height: 46px; padding: 2px 14px 6px; font: 700 16px/24px var(--font-sans); }

/* 挑好的图：输入框上面一小行，缩略图、一句话、✕ */
.chat-attach { flex: 0 0 auto; display: flex; align-items: center; gap: var(--space-2); }
.chat-attach__img { flex: 0 0 auto; width: 56px; height: 56px; object-fit: cover; box-shadow: inset 0 0 0 2px var(--line); }
.chat-attach__body { flex: 1 1 auto; min-width: 0; display: flex; align-items: center; flex-wrap: wrap; gap: var(--space-2); color: var(--paper); font: 400 16px/24px var(--font-sans); }
.chat-attach__body .bd-dots i { background: var(--sky); }
.chat-panel .chat-attach__x { flex: 0 0 auto; width: 44px; height: 44px; min-width: 44px; min-height: 44px; padding: 0; display: inline-flex; align-items: center; justify-content: center; }
.chat-attach__x .bd-icon { width: 20px; height: 20px; fill: currentColor; }
.chat-attach-note { flex: 0 0 auto; margin: 0; }
.chat-panel .chat-attach-btn { flex: 0 0 auto; min-width: 44px; min-height: 46px; padding: 2px 10px 6px; display: inline-flex; align-items: center; justify-content: center; }
.chat-attach-btn .bd-icon { width: 24px; height: 24px; fill: currentColor; }
.chat-file { display: none; }

/* 翻前几天：挑哪一天、回到今天 */
.chat-picker { display: flex; flex-direction: column; gap: var(--space-3); }
.chat-picker__close { align-self: flex-start; flex: 0 0 auto; }
.chat-panel .chat-today { flex: 0 0 auto; min-height: 46px; font: 700 16px/24px var(--font-sans); }

/* 横屏和电脑：右边一栏，不要底部抽屉的样子 */
@media (min-aspect-ratio: 23/20) {
  .chat-host > .chat-panel { max-width: none; border: 0; padding: 0; background: none; }
}
