:root {
  --crimson: #C00000;
  --crimson-deep: #8E0000;
  --crimson-soft: #FBEFEF;
  --ink: #1A1A1A;
  --ink-soft: #2A2A2A;
  --paper: #FFFFFF;
  --line: #E9E6E2;
  --muted: #77726C;
  --hover: #F8F7F5;
  --sans: "Noto Sans JP", "Hiragino Sans", -apple-system, BlinkMacSystemFont, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 14px;
  color-scheme: light;
}

.workspace {
  display: flex;
  height: 100vh;
  height: 100dvh;
}

/* --- サイドバー: GlobaRの黒。アクティブのみ深紅 --- */

.sidebar {
  width: 224px;
  min-width: 224px;
  background: var(--ink);
  color: rgba(255, 255, 255, 0.78);
  padding: 18px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.workspace-name {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
  font-size: 15px;
  color: #fff;
  padding: 4px 8px 18px;
  letter-spacing: 0.02em;
}

.workspace-mark {
  width: 26px;
  height: 26px;
  min-width: 26px;
  border-radius: 7px;
  background: var(--crimson);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
}

.sidebar-section {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.4);
  padding: 10px 8px 4px;
}

.channel {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 8px;
  border-radius: 7px;
  font-size: 14px;
  cursor: default;
}

.channel.active {
  background: var(--crimson);
  color: #fff;
  font-weight: 600;
}

.channel-mark {
  width: 20px;
  height: 20px;
  min-width: 20px;
  border-radius: 5px;
  background: rgba(255, 255, 255, 0.16);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-family: var(--sans);
  font-weight: 600;
}

.sidebar-foot {
  margin-top: auto;
  font-size: 11.5px;
  line-height: 1.7;
  color: rgba(255, 255, 255, 0.42);
  padding: 12px 8px 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.09);
}

/* --- メイン --- */

.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--paper);
}

.channel-header {
  border-bottom: 1px solid var(--line);
  padding: 12px 20px;
}

.channel-title {
  display: flex;
  align-items: center;
  gap: 10px;
}

.channel-name {
  font-weight: 700;
  font-size: 15px;
}

.channel-sub {
  font-size: 12px;
  color: var(--muted);
  margin-top: 1px;
}

/* --- botのマーク: 「立」の朱印 --- */

.bot-mark {
  background: var(--crimson);
  color: #fff;
  font-family: var(--sans);
  font-weight: 600;
}

.bot-mark.small {
  width: 24px;
  height: 24px;
  min-width: 24px;
  font-size: 12px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* --- メッセージ --- */

.chat {
  flex: 1;
  overflow-y: auto;
  padding: 14px 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.day-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 2px 0 10px;
  color: var(--muted);
  font-size: 11.5px;
}

.day-divider::before,
.day-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--line);
}

.msg-row {
  display: flex;
  gap: 11px;
  padding: 7px 8px;
  border-radius: 8px;
  animation: rise 0.22s ease-out both;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@media (prefers-reduced-motion: reduce) {
  .msg-row { animation: none; }
  .dot-flash span { animation: none; opacity: 0.6; }
}

.msg-row:hover {
  background: var(--hover);
}

.avatar {
  width: 36px;
  height: 36px;
  min-width: 36px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 16px;
  color: #fff;
}

.msg-row.user .avatar {
  background: var(--ink-soft);
  font-family: var(--sans);
  font-size: 13px;
}

.msg-body {
  flex: 1;
  min-width: 0;
}

.msg-meta {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.msg-name {
  font-weight: 700;
  font-size: 13.5px;
}

.msg-time {
  font-size: 11px;
  color: var(--muted);
}

.msg-text {
  font-size: 14px;
  line-height: 1.75;
  margin-top: 2px;
  white-space: pre-wrap;
}

/* botの声: ゴシックだが本文よりわずかに大きく・行間広めにして「確定文書からの回答」の重みを出す */
.msg-text.bot-voice {
  font-family: var(--sans);
  font-weight: 500;
  font-size: 14.5px;
  line-height: 1.85;
}

/* --- エスカレーション --- */

.msg-row.escalate {
  border-left: 3px solid var(--crimson);
  border-radius: 0 8px 8px 0;
  background: var(--crimson-soft);
}

.escalate-action {
  display: inline-block;
  margin-top: 10px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  color: var(--crimson-deep);
}

/* --- タイピングインジケーター --- */

.msg-text.typing {
  color: var(--muted);
  font-family: var(--sans);
  font-size: 13px;
}

.dot-flash {
  display: inline-flex;
  gap: 3px;
  padding: 2px 0;
  margin-left: 6px;
  vertical-align: middle;
}

.dot-flash span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--muted);
  animation: blink 1.2s infinite ease-in-out;
}

.dot-flash span:nth-child(2) { animation-delay: 0.2s; }
.dot-flash span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.25; }
  40% { opacity: 1; }
}

/* --- サンプル質問チップ --- */

.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.chip {
  font-family: var(--sans);
  font-size: 13px;
  color: var(--ink);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.chip:hover {
  border-color: var(--crimson);
  background: var(--crimson-soft);
}

/* --- 入力欄 --- */

.composer {
  padding: 6px 20px 14px;
}

.composer-box {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 8px 8px 8px 14px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.composer-box:focus-within {
  border-color: var(--crimson);
  box-shadow: 0 0 0 1px var(--crimson);
}

textarea#input {
  flex: 1;
  resize: none;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: var(--sans);
  max-height: 120px;
  padding: 6px 0;
  background: transparent;
}

button#send {
  background: var(--crimson);
  color: #fff;
  border: none;
  border-radius: 9px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s ease;
}

button#send:hover {
  background: var(--crimson-deep);
}

button#send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button#send:focus-visible,
.chip:focus-visible {
  outline: 2px solid var(--crimson);
  outline-offset: 2px;
}

.composer-hint {
  font-size: 11px;
  color: var(--muted);
  padding: 6px 4px 0;
}

/* --- レスポンシブ --- */

@media (max-width: 640px) {
  .sidebar { display: none; }

  .channel-header { padding: 10px 14px; }
  .chat { padding: 12px 14px 16px; }
  .composer { padding: 6px 14px 14px; }
  .msg-row { padding: 6px 4px; }

  .avatar {
    width: 30px;
    height: 30px;
    min-width: 30px;
    font-size: 14px;
  }

  .msg-text.bot-voice { font-size: 14px; }

  textarea#input { font-size: 16px; }

  button#send {
    width: 40px;
    height: 40px;
  }

  .composer-hint { display: none; }
}

@media (max-width: 380px) {
  .channel-sub { display: none; }
}
