#myday-chat-root {
  --blue: #1769ff;
  --blue-dark: #0c3a96;
  --purple: #9b8cff;
  --purple-dark: #7868dd;
  --ink: #202733;
  --muted: #738093;
  --line: #e5e9f2;
  --surface: #ffffff;
  --soft-blue: #f2f7ff;
  --soft-purple: #f6f3ff;
  --shadow: 0 22px 58px rgba(20, 38, 76, .26);
  --dock-bottom: -6px;
  --dock-right: 40px;
  --panel-bottom: 24px;
  font-family: "Microsoft JhengHei", "PingFang TC", Arial, sans-serif;
  color: var(--ink);
}

#myday-chat-root,
#myday-chat-root *,
#myday-chat-root *::before,
#myday-chat-root *::after {
  box-sizing: border-box;
}

/* 覆寫 a_myday layout_index.css 的 nav/header/section 全站規則 */
#myday-chat-root nav.chat-tabs {
  width: 100% !important;
  max-width: 100% !important;
  margin: 0 !important;
  display: grid !important;
  grid-template-columns: 1fr 1fr !important;
}

#myday-chat-root header.chat-header,
#myday-chat-root section.panel,
#myday-chat-root section.notice-detail,
#myday-chat-root header.detail-header,
#myday-chat-root .chat-input,
#myday-chat-root .detail-reply,
#myday-chat-root .messages,
#myday-chat-root .message-list,
#myday-chat-root .detail-body {
  width: 100% !important;
  max-width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
  min-width: 0;
}

#myday-chat-root .chat-widget > * {
  min-width: 0;
  max-width: 100%;
}

#myday-chat-root button,
#myday-chat-root textarea {
  font: inherit;
}

#myday-chat-root .assistant-fab {
  position: fixed;
  right: var(--dock-right);
  bottom: var(--dock-bottom);
  z-index: 10020;
  width: 90px;
  height: 90px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  cursor: pointer;
  transition: opacity .2s ease, transform .2s ease;
}

/* 訂單列表等頁：隱藏 FAB，僅能由頁面發問按鈕開啟 */
#myday-chat-root.is-fab-deferred .assistant-fab {
  display: none !important;
}

#myday-chat-root .fab-unread-badge {
  position: absolute;
  top: 0;
  right: 0;
  display: grid;
  place-items: center;
  min-width: 24px;
  height: 24px;
  padding: 0 6px;
  border: 2px solid #fff;
  border-radius: 999px;
  color: #fff;
  background: #f0522d;
  box-shadow: 0 4px 10px rgba(190, 54, 24, .35);
  font-size: 13px;
  font-weight: 800;
  line-height: 1;
  pointer-events: none;
}

#myday-chat-root .fab-unread-badge.is-hidden {
  display: none;
}

#myday-chat-root .assistant-fab:hover { transform: translateY(-2px); }
#myday-chat-root .assistant-fab[aria-expanded="true"] {
  opacity: 0;
  pointer-events: none;
  transform: translateY(10px) scale(.96);
}

#myday-chat-root .assistant-fab .brand-icon,
#myday-chat-root .brand-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  filter: drop-shadow(0 6px 12px rgba(8, 34, 88, .2));
}

#myday-chat-root .chat-header .brand-icon {
  width: 38px;
  height: 38px;
}

#myday-chat-root .chat-widget {
  position: fixed;
  right: var(--dock-right);
  bottom: var(--panel-bottom);
  z-index: 10030;
  display: grid;
  grid-template-rows: auto auto 1fr;
  width: min(500px, calc(100vw - 28px));
  height: min(680px, calc(100vh - var(--panel-bottom) - 24px));
  overflow: hidden;
  border: 1px solid rgba(23, 105, 255, .14);
  border-radius: 18px;
  background: var(--surface);
  box-shadow: var(--shadow);
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px) scale(.96);
  transform-origin: right bottom;
  transition: opacity .22s ease, transform .22s ease;
}

#myday-chat-root .chat-widget.is-open {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

#myday-chat-root .chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 15px 16px;
  color: #fff;
  background: radial-gradient(circle at 86% 20%, rgba(123, 77, 255, .55), transparent 120px), linear-gradient(135deg, #2457b3, var(--blue) 56%, var(--purple));
}

#myday-chat-root .chat-brand { display: flex; align-items: center; gap: 10px; min-width: 0; }
#myday-chat-root .chat-brand strong { display: block; font-size: 17px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#myday-chat-root .chat-brand span { display: block; margin-top: 3px; color: rgba(255,255,255,.76); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#myday-chat-root .close-chat { width: 34px; height: 34px; border: 0; border-radius: 10px; color: #fff; background: rgba(255,255,255,.15); cursor: pointer; font-size: 24px; }

#myday-chat-root .chat-tabs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; padding: 10px; background: #fff; border-bottom: 1px solid var(--line); }
#myday-chat-root .chat-tab { height: 38px; border: 0; border-radius: 10px; color: #59677b; background: transparent; cursor: pointer; font-weight: 400; }
#myday-chat-root:not(.is-mobile-site) .chat-tab { height: 42px; font-size: 17px; }
#myday-chat-root .chat-tab.is-active { color: #fff; background: linear-gradient(135deg, var(--blue), var(--purple)); box-shadow: 0 8px 18px rgba(23, 105, 255, .2); }
#myday-chat-root .unread-badge { display: inline-grid; place-items: center; min-width: 20px; height: 20px; margin-left: 6px; padding: 0 6px; border-radius: 999px; color: #fff; background: var(--purple); font-size: 12px; }
#myday-chat-root .chat-tab.is-active .unread-badge { color: var(--blue-dark); background: #fff; }
#myday-chat-root .unread-badge.is-hidden { display: none; }

#myday-chat-root .panel { display: none; min-height: 0; }
#myday-chat-root .panel.is-active { display: grid; grid-template-rows: 1fr auto; }
#myday-chat-root .panel[data-panel="notices"].is-active { grid-template-rows: 1fr; }
#myday-chat-root .panel[data-panel="notices"] { grid-template-rows: 1fr auto; }

#myday-chat-root .messages,
#myday-chat-root .message-list,
#myday-chat-root .detail-body { min-height: 0; overflow-y: auto; }
#myday-chat-root .messages { padding: 16px 14px 18px; background: radial-gradient(circle at 100% 0, rgba(123,77,255,.14), transparent 170px), linear-gradient(180deg, #fbfdff, #f5f8ff); }
#myday-chat-root .message { display: grid; grid-template-columns: 32px minmax(0,1fr); gap: 8px; margin-bottom: 14px; }
#myday-chat-root .message.member { grid-template-columns: minmax(0,1fr) 32px; }
#myday-chat-root .role-icon { display: grid; place-items: center; width: 32px; height: 32px; border-radius: 999px; color: #fff; background: linear-gradient(135deg, var(--blue), var(--purple)); font-size: 15px; font-weight: 900; }
#myday-chat-root .message.member .role-icon { grid-column: 2; background: linear-gradient(135deg, var(--purple), var(--purple-dark)); }
#myday-chat-root .member .bubble-wrap { grid-column: 1; justify-self: end; }
#myday-chat-root .bubble { padding: 11px 13px; border: 1px solid #dbe7ff; border-radius: 14px 14px 14px 5px; background: #fff; font-size: 14px; line-height: 1.58; white-space: pre-line; }
#myday-chat-root .bubble .chat-inline-link,
#myday-chat-root .bubble .chat-login-link { color: var(--blue); font-weight: 600; text-decoration: underline; }
#myday-chat-root .bubble .chat-inline-link:hover,
#myday-chat-root .bubble .chat-login-link:hover { color: var(--blue-dark); }
#myday-chat-root .message.member .bubble { border-color: #ded6ff; border-radius: 14px 14px 5px 14px; background: var(--soft-purple); }
#myday-chat-root .quick-options { display: grid; gap: 8px; margin-top: 10px; }
#myday-chat-root .quick-options button { width: 100%; min-height: 34px; padding: 7px 10px; border: 1px solid #d8e5ff; border-radius: 9px; color: var(--blue-dark); background: #fff; cursor: pointer; text-align: left; font-size: 14px; transition: background .16s ease, border-color .16s ease, color .16s ease; }
#myday-chat-root .quick-options button:hover { color: #fff; background: var(--blue); border-color: var(--blue); }
#myday-chat-root .quick-options.category-options { gap: 12px; }
#myday-chat-root .quick-options.category-options button {
  display: flex;
  align-items: center;
  gap: 14px;
  min-height: 62px;
  padding: 12px 14px;
  border-color: #cfd8e8;
  border-radius: 10px;
  color: #6f5bd8;
  font-size: 16px;
  font-weight: 700;
}
#myday-chat-root .category-icon {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  flex: 0 0 auto;
  border-radius: 50%;
  color: #fff;
  background: #8b78f6;
  font-size: 17px;
  font-weight: 900;
  line-height: 1;
}
#myday-chat-root .category-icon svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}
#myday-chat-root .category-label { flex: 1 1 auto; min-width: 0; line-height: 1.35; }
#myday-chat-root .quick-options.category-options button:hover {
  color: #fff;
  background: var(--blue);
  border-color: var(--blue);
}
#myday-chat-root .quick-options.category-options button:hover .category-label {
  color: #fff;
}
#myday-chat-root .quick-options.category-options button:hover .category-icon {
  color: var(--blue);
  background: #fff;
}
#myday-chat-root .time { margin-top: 5px; color: #98a3b4; font-size: 11px; }
#myday-chat-root .message.member .time { text-align: right; }

#myday-chat-root .chat-typing-indicator .typing-bubble {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-width: 52px;
  padding: 12px 14px;
}

#myday-chat-root .typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--purple));
  animation: myday-chat-typing-bounce 1.2s ease-in-out infinite;
}

#myday-chat-root .typing-dot:nth-child(2) { animation-delay: .15s; }
#myday-chat-root .typing-dot:nth-child(3) { animation-delay: .3s; }

@keyframes myday-chat-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .45; }
  30% { transform: translateY(-5px); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
  #myday-chat-root .typing-dot {
    animation: none;
    opacity: .7;
  }
}

#myday-chat-root .chat-input.is-processing textarea {
  color: #8b97a8;
  background: #f5f7fb;
  cursor: wait;
}

#myday-chat-root .chat-input.is-processing .send-btn {
  opacity: .88;
  cursor: wait;
}

#myday-chat-root .chat-input,
#myday-chat-root .detail-reply { display: grid; grid-template-columns: minmax(0,1fr) 70px; gap: 8px; align-items: center; padding: 16px 12px 12px; border-top: 1px solid var(--line); background: #fff; }
#myday-chat-root .chat-input textarea,
#myday-chat-root .detail-reply textarea { width: 100%; height: 75px; min-height: 75px; max-height: 75px; margin: 0; padding: 5px 12px; border: 1px solid #d7deeb; border-radius: 11px; resize: none; outline: none; font-size: 15px; line-height: normal; }
#myday-chat-root .send-btn { display: flex; align-items: center; justify-content: center; height: 75px; min-height: 75px; margin: 0; padding: 0; border: 0; border-radius: 11px; color: #fff; background: linear-gradient(135deg, var(--blue), var(--purple)); cursor: pointer; font-weight: 400; font-size: 14px; line-height: 1; }

#myday-chat-root .message-list { padding: 14px; background: linear-gradient(180deg, #fbfdff, #f7f9fd); }
#myday-chat-root .status-filters { display: flex; gap: 8px; overflow-x: auto; padding-bottom: 12px; }
#myday-chat-root .status-filter { display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto; min-height: 32px; margin: 0; padding: 0 10px; border: 1px solid #dbe4f4; border-radius: 999px; color: #536174; background: #fff; cursor: pointer; font-size: 14px; font-weight: 400; line-height: 1; white-space: nowrap; }
#myday-chat-root .status-filter.is-active { color: #fff; border-color: var(--blue); background: linear-gradient(135deg, var(--blue), var(--purple)); }
#myday-chat-root .filter-count { display: inline-flex; align-items: center; justify-content: center; min-width: 18px; height: 18px; margin: 0 0 0 4px; padding: 0 5px; border-radius: 999px; color: var(--blue-dark); background: var(--soft-blue); font-size: 11px; line-height: 1; }
#myday-chat-root .status-filter.is-active .filter-count { background: #fff; }

#myday-chat-root .notice-card { display: grid; grid-template-columns: 42px minmax(0,1fr) auto; gap: 10px; align-items: center; padding: 12px; margin-bottom: 10px; border: 1px solid var(--line); border-radius: 13px; background: #fff; cursor: pointer; }
#myday-chat-root .notice-card.is-read { opacity: .68; }
#myday-chat-root .notice-icon { display: grid; place-items: center; width: 42px; height: 42px; border-radius: 12px; color: var(--blue); background: var(--soft-blue); }
#myday-chat-root .notice-card.is-unread .notice-icon { color: #fff; background: linear-gradient(135deg, var(--blue), var(--purple)); }
#myday-chat-root .notice-card strong { display: block; margin-bottom: 4px; color: var(--blue-dark); font-size: 14px; }
#myday-chat-root .notice-goods-link { color: var(--blue-dark); text-decoration: underline; text-underline-offset: 2px; }
#myday-chat-root .notice-card span { display: block; color: #536174; font-size: 13px; line-height: 1.45; }
#myday-chat-root .notice-time { margin-top: 6px; color: #96a1b2; font-size: 12px; }
#myday-chat-root .notice-state { padding: 4px 8px; border-radius: 999px; color: var(--blue-dark); background: var(--soft-blue); font-size: 12px; font-weight: 400; white-space: nowrap; }
#myday-chat-root .notice-card.is-unread .notice-state { color: #fff; background: var(--purple); }
#myday-chat-root .notice-footer { padding: 12px 14px; border-top: 1px solid var(--line); color: var(--muted); background: #fff; font-size: 12px; text-align: center; }
#myday-chat-root .notice-footer.is-hidden { display: none; }

#myday-chat-root .notice-list-tail {
  margin-top: 6px;
  padding: 14px 4px 6px;
  border-top: 1px solid var(--line);
  text-align: center;
}

#myday-chat-root .notice-list-summary {
  color: var(--muted);
  font-size: 12px;
}

#myday-chat-root .notice-more-link { display: inline-block; margin-top: 8px; color: var(--blue); font-size: 14px; font-weight: 700; text-decoration: none; }
#myday-chat-root .notice-more-link:hover { color: var(--blue-dark); text-decoration: underline; }
#myday-chat-root .notice-empty { padding: 24px; text-align: center; color: var(--muted); font-size: 14px; }
#myday-chat-root .notice-loading { padding: 24px; text-align: center; color: var(--muted); font-size: 14px; }
#myday-chat-root .notice-login-prompt { display: grid; gap: 16px; justify-items: center; padding: 32px 24px; }
#myday-chat-root .notice-login-prompt .notice-empty { padding: 0; }
#myday-chat-root .notice-login-btn { min-width: 120px; padding: 10px 24px; border: 0; border-radius: 11px; color: #fff; background: linear-gradient(135deg, var(--blue), var(--purple)); cursor: pointer; font-weight: 800; font-size: 15px; }
#myday-chat-root .notice-login-btn:hover { opacity: .92; }

#myday-chat-root .panel[data-panel="notices"].is-active { grid-template-rows: 1fr auto; min-height: 0; }
#myday-chat-root .panel.show-detail { grid-template-rows: 1fr !important; }
#myday-chat-root .panel.show-detail .message-list,
#myday-chat-root .panel.show-detail .notice-footer,
#myday-chat-root .panel.show-detail .status-filters { display: none !important; }
#myday-chat-root .notice-detail { display: none; min-height: 0; grid-template-rows: auto 1fr auto; background: linear-gradient(180deg, #fbfdff, #f7f9fd); }
#myday-chat-root .panel.show-detail .notice-detail.is-active { display: grid; min-height: 0; }
#myday-chat-root .detail-header { display: flex; align-items: center; gap: 10px; padding: 14px; border-bottom: 1px solid var(--line); background: #fff; }
#myday-chat-root .back-notices { width: 34px; height: 34px; border: 1px solid #dbe4f4; border-radius: 10px; color: var(--blue-dark); background: #fff; cursor: pointer; font-size: 20px; }
#myday-chat-root .detail-title strong { display: block; color: var(--blue-dark); font-size: 15px; }
#myday-chat-root .detail-title span { display: block; margin-top: 3px; color: var(--muted); font-size: 13px; }
#myday-chat-root .detail-body { padding: 16px; }
#myday-chat-root .detail-thread-item { margin-bottom: 12px; padding: 12px; border: 1px solid var(--line); border-radius: 13px; background: #fff; font-size: 14px; line-height: 1.6; }
#myday-chat-root .detail-thread-content { white-space: normal; word-break: break-word; }
#myday-chat-root .detail-thread-content img { display: block; max-width: 100%; height: auto; margin-top: 8px; border-radius: 8px; }
#myday-chat-root .detail-thread-content a { color: var(--blue); text-decoration: underline; word-break: break-all; }
#myday-chat-root .detail-thread-content a:hover { color: var(--blue-dark); }
#myday-chat-root .detail-thread-item.staff { border-color: #ffd6d6; background: #fff8f8; }
#myday-chat-root .detail-thread-meta { margin-bottom: 6px; font-size: 12px; color: var(--muted); font-weight: 800; }

/* myday_mobile：貓頭貼齊右下角、浮於底部選單上方 */
#myday-chat-root.is-mobile-site {
  --dock-bottom: 57px;
  --dock-right: 5px;
  --fab-size: 72px;
}

#myday-chat-root.is-mobile-site .assistant-fab {
  width: var(--fab-size);
  height: var(--fab-size);
}

#myday-chat-root.is-mobile-site .chat-widget {
  display: grid !important;
  grid-template-rows: auto auto minmax(0, 1fr) !important;
  min-height: 0;
}

#myday-chat-root.is-mobile-site .panel.is-active {
  display: grid !important;
  grid-template-rows: minmax(0, 1fr) auto !important;
  min-height: 0;
  overflow: hidden;
}

#myday-chat-root.is-mobile-site .messages,
#myday-chat-root.is-mobile-site .message-list,
#myday-chat-root.is-mobile-site .detail-body {
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

#myday-chat-root.is-mobile-site .chat-input,
#myday-chat-root.is-mobile-site .detail-reply {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) 70px !important;
  gap: 8px;
  align-items: center;
  flex-shrink: 0;
  padding: 12px;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}

#myday-chat-root.is-mobile-site .chat-input textarea,
#myday-chat-root.is-mobile-site .detail-reply textarea {
  width: 100% !important;
  height: 75px !important;
  min-height: 75px !important;
  max-height: 75px !important;
  margin: 0 !important;
  padding: 5px 12px !important;
  border: 1px solid #d7deeb !important;
  border-radius: 11px !important;
  color: var(--ink) !important;
  background: #fff !important;
  resize: none !important;
  line-height: normal !important;
}

#myday-chat-root.is-mobile-site .send-btn {
  display: flex !important;
  align-items: center;
  justify-content: center;
  width: 100% !important;
  height: 75px !important;
  min-height: 75px !important;
  margin: 0 !important;
  padding: 0 !important;
}

@media (max-width: 520px) {
  body.myday-chat-open { overflow: hidden; }
  #myday-chat-root .assistant-fab { width: 72px; height: 72px; }
  #myday-chat-root .chat-widget { inset: 0; width: 100vw; height: 100vh; height: 100dvh; border: 0; border-radius: 0; transform: translateX(100%); transform-origin: right center; }
  #myday-chat-root .chat-widget.is-open { transform: translateX(0); }
}
