#team-chat {
  position: fixed;
  inset: 0;
  margin: auto;
  box-sizing: border-box;
  width: min(620px, calc(100vw - 32px));
  max-height: calc(100dvh - 32px);
  padding: 0;
  overflow: hidden;
  color: var(--t-1, #172238);
  background: var(--bg-1, #fff);
  border: 1px solid var(--b-1, #d5dfed);
  border-radius: 16px;
  box-shadow: 0 20px 70px rgb(16 24 39 / 28%);
}

#team-chat::backdrop { background: rgb(16 24 39 / 48%); }
#team-chat [hidden] { display: none !important; }
#team-chat :focus-visible { outline: 2px solid var(--accent-h, #d13e06); outline-offset: 2px; }
#btn-team-chat { flex: 0 0 auto; min-width: 34px; }
#btn-team-chat svg { display: block; }

.team-chat-panel {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
  height: min(620px, calc(100dvh - 34px));
  box-sizing: border-box;
}

.team-chat-header { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
.team-chat-header h2 { margin: 0; font-size: 20px; }
.team-chat-room { display: flex; align-items: center; gap: 10px; font-size: 13px; font-weight: 650; }
.team-chat-room select { min-width: 0; flex: 1; }
.team-chat-notice { display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--t-2, #52637d); }
.team-chat-notice:has(p:empty) { display: none; }
.team-chat-notice p { margin: 0; }

#team-chat button, #team-chat select, #team-chat textarea {
  min-height: 38px;
  padding: 7px 11px;
  border: 1px solid var(--b-1, #d5dfed);
  border-radius: 8px;
  color: inherit;
  background: var(--bg-1, #fff);
  font: inherit;
}

#team-chat button { cursor: pointer; font-size: 13px; font-weight: 700; }
#team-chat button:disabled { opacity: .55; cursor: default; }

.team-chat-history {
  flex: 1;
  min-height: 0;
  overflow: auto;
  overscroll-behavior: contain;
  padding: 12px;
  border: 1px solid var(--b-1, #d5dfed);
  border-radius: 10px;
  background: var(--bg-2, #f4f7fb);
}

.team-chat-history > button { display: block; margin: 0 auto 12px; }
.team-chat-history ol { display: grid; gap: 10px; padding: 0; margin: 0; list-style: none; }
.team-chat-message {
  justify-self: start;
  width: fit-content;
  max-width: min(90%, 430px);
  padding: 9px 12px;
  border: 1px solid var(--b-1, #d5dfed);
  border-radius: 12px;
  background: var(--bg-1, #fff);
}

.team-chat-message.is-mine {
  justify-self: end;
  background: color-mix(in srgb, var(--accent-h, #d13e06) 10%, var(--bg-1, #fff));
}

.team-chat-message div { display: flex; flex-wrap: wrap; gap: 4px 10px; font-size: 12px; }
.team-chat-message time { color: var(--t-2, #52637d); }
.team-chat-message p { margin: 4px 0 0; font-size: 14px; line-height: 1.45; white-space: pre-wrap; overflow-wrap: anywhere; }
.team-chat-compose { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: end; gap: 6px 10px; }
.team-chat-compose label { grid-column: 1 / -1; font-size: 13px; font-weight: 650; }
#team-chat textarea { width: 100%; box-sizing: border-box; resize: vertical; max-height: 120px; font-size: 16px; }
#team-chat button[type="submit"] { background: #bd3806; color: #fff; border-color: #bd3806; }

@media (max-width: 520px) {
  #team-chat { width: calc(100vw - 16px); max-height: calc(100dvh - 16px); }
  .team-chat-panel { height: calc(100dvh - 18px); padding: 14px; }
  #team-chat button, #team-chat select, #btn-team-chat { min-height: 44px; }
  #btn-team-chat { min-width: 44px; }
}
