:root {
  --ink: #1a1a2e;
  --paper: #f5f0e8;
  --accent: #c8522a;
  --muted: #7a7060;
  --line: #d4c9b0;
  --bubble-user: #1a1a2e;
  --sidebar: #ede8dc;
  --sidebar-w: 260px;
  --topbar-h: 57px;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: "Noto Sans TC", sans-serif;
  background: var(--paper);
  color: var(--ink);
  height: 100dvh; /* ← 改這裡 */
  display: flex;
  overflow: hidden;
}
/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar);
  border-right: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  flex-shrink: 0;
  transition:
    width 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    padding 0.3s cubic-bezier(0.4, 0, 0.2, 1),
    transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  overflow: hidden;
  position: relative;
  z-index: 100;
}
.sidebar.collapsed {
  width: 0;
  padding: 24px 0;
  border-right-color: transparent;
}

/* Mobile: sidebar as overlay */
@media (max-width: 640px) {
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    transform: translateX(0);
    width: var(--sidebar-w) !important;
    padding: 24px 16px !important;
    border-right: 1px solid var(--line) !important;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  }
  .sidebar.collapsed {
    transform: translateX(calc(-1 * var(--sidebar-w)));
  }
  .sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 99;
    display: none;
  }
  .sidebar-overlay.visible {
    display: block;
  }
}

/* Sidebar inner wrapper prevents content jumping during collapse */
.sidebar-inner {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: calc(var(--sidebar-w) - 32px);
  overflow: hidden;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.logo-icon {
  width: 36px;
  height: 36px;
  background: var(--accent);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}
.logo-text {
  font-family: "Noto Serif TC", serif;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.3;
  color: var(--ink);
  white-space: nowrap;
}
.logo-sub {
  font-size: 11px;
  color: var(--muted);
  font-weight: 300;
  white-space: nowrap;
}
.new-chat-btn {
  background: var(--accent);
  color: white;
}
.new-chat-btn:hover {
  background: var(--accent);
  color: white;
}
.secondary-btn:hover {
  background: var(--accent);
}
.history-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--muted);
  margin-bottom: 10px;
  flex-shrink: 0;
  white-space: nowrap;
}

#historyList {
  flex: 1;
  overflow-y: auto;
}
#historyList::-webkit-scrollbar {
  width: 3px;
}
#historyList::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 2px;
}

.history-item {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 8px;
  border-radius: 6px;
  font-size: 13px;
  color: var(--muted);
  cursor: pointer;
  transition: background 0.15s;
  margin-bottom: 2px;
}
.history-item:hover,
.history-item.active {
  background: var(--line);
  color: var(--ink);
}
.history-item-text {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.history-del {
  display: none;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--muted);
  font-size: 14px;
  flex-shrink: 0;
  line-height: 1;
  padding: 0;
  transition:
    color 0.15s,
    background 0.15s;
}
.history-item:hover .history-del {
  display: flex;
}
.history-del:hover {
  color: var(--accent);
  background: rgba(200, 82, 42, 0.1);
}
.sidebar-footer {
  margin-top: 12px;
  font-size: 11px;
  color: var(--muted);
  line-height: 1.6;
  padding-top: 16px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}

/* ── Main ── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
#mainContent {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;

  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--paper);
  gap: 12px;
  flex-shrink: 0;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}
.topbar-center {
  height: 100%;
}
.topbar-title {
  font-family: "Noto Serif TC", serif;
  font-size: 16px;
  font-weight: 600;
  white-space: nowrap;
}

/* Toggle button */
.toggle-btn {
  width: 34px;
  height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition:
    background 0.15s,
    border-color 0.15s;
  position: relative;
}
.toggle-btn:hover {
  background: var(--sidebar);
  border-color: var(--muted);
}
.toggle-btn svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: var(--ink);
  stroke-width: 1.8;
  stroke-linecap: round;
  transition: transform 0.3s;
}

/* ── Messages ── */
.messages {
  flex: 1;
  overflow-y: auto;
  padding: 32px 48px;
  display: flex;
  flex-direction: column;
  gap: 24px;
}
.messages::-webkit-scrollbar {
  width: 4px;
}
.messages::-webkit-scrollbar-thumb {
  background: var(--line);
  border-radius: 2px;
}

@media (max-width: 768px) {
  .messages {
    padding: 20px 16px;
  }
}

/* Welcome screen */
.welcome {
  text-align: center;
  padding: 48px 24px;
  max-width: 520px;
  margin: 0 auto;
  width: 100%;
}
.welcome-icon {
  margin-bottom: 16px;
}

.welcome-icon img {
  width: 72px;
  height: 72px;
  object-fit: contain;
}
.welcome h1 {
  font-family: "Noto Serif TC", serif;
  font-size: 26px;
  font-weight: 700;
  margin-bottom: 10px;
}
.welcome p {
  font-size: 14px;
  color: var(--muted);
  line-height: 1.7;
  margin-bottom: 28px;
}
.suggestions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  text-align: left;
}
@media (max-width: 480px) {
  .suggestions {
    grid-template-columns: 1fr;
  }
  .welcome h1 {
    font-size: 22px;
  }
  .welcome {
    padding: 32px 16px;
  }
}
.suggestion-card {
  background: white;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 14px;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 13px;
  color: var(--ink);
  line-height: 1.5;
}
.suggestion-card:hover {
  border-color: var(--accent);
  box-shadow: 0 2px 12px rgba(200, 82, 42, 0.1);
}
.suggestion-icon {
  font-size: 18px;
  margin-bottom: 6px;
  display: block;
}

/* Messages */
.message {
  display: flex;
  gap: 14px;
  animation: fadeIn 0.3s ease;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
.message.user {
  flex-direction: row-reverse;
}
.avatar {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  flex-shrink: 0;
  margin-top: 2px;
}
.avatar.ai {
  background: var(--accent);
  color: white;
  font-family: "Noto Serif TC", serif;
  font-size: 13px;
  font-weight: 700;
}
.avatar-icon-0 {
  width: 30px;
  height: 30px;
  object-fit: contain;
}
.avatar-icon {
  width: 24px;
  height: 24px;
  object-fit: contain;
}
.avatar.user-av {
  background: var(--accent);
  color: white;
}
.bubble {
  max-width: 68%;
  padding: 14px 18px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.75;
}
.message.ai .bubble {
  background: white;
  border: 1px solid var(--line);
  border-top-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
}
.message.user .bubble {
  background: var(--bubble-user);
  color: white;
  border-top-right-radius: 4px;
}

@media (max-width: 640px) {
  .bubble {
    max-width: calc(100% - 48px);
  }
  .avatar {
    width: 30px;
    height: 30px;
  }
}

/* Message formatting */
.summary-block {
  background: #faf7f2;
  border-left: 3px solid var(--accent);
  padding: 12px 14px;
  border-radius: 0 8px 8px 0;
  margin-bottom: 14px;
  font-size: 13px;
}
.summary-block strong {
  display: block;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 6px;
}
.detail-item {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  font-size: 13.5px;
}
.detail-num {
  color: var(--accent);
  font-weight: 600;
  flex-shrink: 0;
}
.sources-block {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--line);
}
.sources-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 10px;
}
.source-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.source-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  border-radius: 8px;
  background: #faf7f2;
  border: 1px solid var(--line);
  cursor: pointer;
  transition:
    border-color 0.15s,
    background 0.15s;
}
.source-row:hover {
  border-color: var(--accent);
  background: #fff7f4;
}
.source-num {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent);
  min-width: 18px;
  flex-shrink: 0;
  padding-top: 1px;
}
.source-name {
  font-size: 12.5px;
  color: var(--ink);
  line-height: 1.5;
}
.source-arrow {
  font-size: 11px;
  color: var(--muted);
  margin-left: auto;
  padding-top: 2px;
  flex-shrink: 0;
  transition: transform 0.15s;
}
.source-row:hover .source-arrow {
  transform: translateX(2px);
  color: var(--accent);
}

/* Inline citation superscript chips */
.src-chips {
  display: inline;
}
.src-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  color: white;
  cursor: pointer;
  user-select: none;
  vertical-align: super;
  line-height: 1;
  margin-left: 2px;
  transition:
    transform 0.1s,
    opacity 0.1s;
  position: relative;
  top: -2px;
}
.src-chip:hover {
  transform: scale(1.2);
  opacity: 0.85;
}
.src-chip:active {
  transform: scale(0.95);
}

.typing {
  display: flex;
  gap: 5px;
  padding: 6px 0;
}
.typing span {
  width: 7px;
  height: 7px;
  background: var(--muted);
  border-radius: 50%;
  animation: bounce 1.2s infinite;
}
.typing span:nth-child(2) {
  animation-delay: 0.2s;
}
.typing span:nth-child(3) {
  animation-delay: 0.4s;
}
@keyframes bounce {
  0%,
  60%,
  100% {
    transform: translateY(0);
  }
  30% {
    transform: translateY(-6px);
  }
}

/* ── Input area ── */
.input-area {
  padding: 16px 48px 20px;
  border-top: 1px solid var(--line);
  background: var(--paper);
  flex-shrink: 0;
}
.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: white;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  padding: 10px 14px;
  transition: border-color 0.2s;
}
.input-wrapper:focus-within {
  border-color: var(--ink);
}
#userInput {
  flex: 1;
  border: none;
  outline: none;
  font-family: "Noto Sans TC", sans-serif;
  font-size: 14px;
  color: var(--ink);
  background: transparent;
  resize: none;
  max-height: 120px;
  line-height: 1.6;
}
#userInput::placeholder {
  color: #b0a89a;
}
.send-btn {
  width: 34px;
  height: 34px;
  background: var(--ink);
  border: none;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s;
}
.send-btn:hover {
  background: var(--accent);
}
.send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}
.send-btn svg {
  width: 16px;
  height: 16px;
  fill: white;
}
.disclaimer {
  text-align: center;
  font-size: 11px;
  color: var(--muted);
  margin-top: 8px;
}

@media (max-width: 768px) {
  .input-area {
    padding: 12px 16px 16px;
  }
}

/* ── Bootstrap modals ── */
.modal {
  --bs-modal-bg: #fff;
  --bs-modal-color: var(--ink);
  --bs-modal-border-color: var(--line);
  --bs-modal-border-radius: 14px;
  --bs-modal-header-border-color: var(--line);
  --bs-modal-footer-border-color: var(--line);
  --bs-backdrop-bg: #000;
  --bs-backdrop-opacity: 0.35;
}
.modal-content {
  border: 1px solid var(--line);
  border-radius: 14px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.18);
  overflow: hidden;
  color: var(--ink);
}
.modal-header {
  background: #faf7f2;
  border-bottom: 1px solid var(--line);
  padding: 12px 16px;
}
.modal-title {
  font-family: "Noto Serif TC", serif;
  font-weight: 700;
  font-size: 14px;
  color: var(--ink);
}
.modal-body {
  font-size: 13.5px;
  line-height: 1.8;
}
.modal-footer {
  background: #fff;
  border-top: 1px solid var(--line);
}
.btn-close:focus {
  box-shadow: 0 0 0 0.2rem rgba(200, 82, 42, 0.18);
}
.modal .btn-dark {
  --bs-btn-bg: var(--ink);
  --bs-btn-border-color: var(--ink);
  --bs-btn-hover-bg: var(--accent);
  --bs-btn-hover-border-color: var(--accent);
}
.modal .form-control {
  border-color: var(--line);
  color: var(--ink);
}
.modal .form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 0.2rem rgba(200, 82, 42, 0.14);
}
.law-modal .modal-dialog {
  max-width: min(680px, calc(100% - 32px));
}
.law-modal-header {
  background: #faf7f2;
}
.law-modal-title {
  font-size: 14px;
}
.law-modal-close {
  border-radius: 4px;
}
.law-modal-body {
  padding: 14px 16px;
  max-height: min(62vh, 560px);
  line-height: 1.8;
  font-size: 13.5px;
}
.law-modal-footer {
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #fff;
}
.law-modal-link {
  font-size: 12px;
  color: var(--accent);
  text-decoration: none;
}
.law-modal-status {
  font-size: 12px;
  color: var(--muted);
}

/* ── Confirm modal ── */
.confirm-modal {
  --bs-backdrop-opacity: 0.25;
}
.confirm-box {
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  text-align: center;
}
.confirm-box .modal-body {
  padding: 24px 28px;
}
.confirm-box p {
  font-size: 14px;
  color: var(--ink);
  margin-bottom: 20px;
  line-height: 1.6;
}
.confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}
.confirm-cancel {
  padding: 8px 22px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: white;
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.confirm-cancel:hover {
  background: #f5f0e8;
}
.confirm-ok {
  padding: 8px 22px;
  border-radius: 8px;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 13px;
  cursor: pointer;
  transition: opacity 0.15s;
}
.confirm-ok:hover {
  opacity: 0.85;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

.auth-box {
  display: flex;
  gap: 6px;
  align-items: center;
}

.auth-input {
  width: 180px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 6px 9px;
  font-size: 12px;
  outline: none;
}

.auth-input:focus {
  border-color: var(--accent);
}

.auth-btn,
.auth-logout {
  border: none;
  border-radius: 8px;
  padding: 6px 10px;
  font-size: 12px;
  cursor: pointer;
  background: var(--ink);
  color: white;
}

.auth-logout {
  background: var(--muted);
}

.auth-user {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 12px;
  color: var(--muted);
}

.plan-badge {
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  font-size: 11px;
}

@media (max-width: 640px) {
  .auth-input {
    width: 120px;
  }

  .topbar-actions {
    gap: 6px;
  }
}
.pricing-note {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  font-size: 13px;
  color: #8a7a64;
  line-height: 1.4;
}

.upgrade-link {
  border: 0;
  background: #d6522c;
  color: #fff;
  border-radius: 999px;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 600;
  white-space: nowrap;
}
.plain-answer {
  line-height: 1.8;
  margin-bottom: 14px;
}

.markdown-answer h2,
.markdown-answer h3,
.markdown-answer h4 {
  color: var(--ink);
  font-weight: 800;
  line-height: 1.35;
  margin: 18px 0 8px;
}

.markdown-answer h2 {
  font-size: 20px;
}

.markdown-answer h3 {
  font-size: 16px;
}

.markdown-answer h4 {
  font-size: 14px;
}

.markdown-answer p {
  margin: 0 0 12px;
}

.markdown-answer ol,
.markdown-answer ul {
  margin: 8px 0 14px 20px;
  padding: 0;
}

.markdown-answer li {
  margin: 8px 0;
  padding-left: 2px;
}

.markdown-answer hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 16px 0;
}

.sources-block.compact {
  margin-top: 16px;
  padding-top: 14px;
  border-top: 1px solid var(--border);
}

.sources-block.compact .sources-label {
  margin-bottom: 10px;
}

.sources-block.compact .source-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.source-preview {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.5;
}
mark {
  background: linear-gradient(120deg, #ffe58f, #ffd666);
  padding: 0 2px;
  border-radius: 3px;
}
.answer-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
}

.message-actions {
  margin-top: 12px;
  display: flex;
  gap: 8px;
}

.professional-report-card {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid rgba(200, 82, 42, 0.28);
  border-radius: 8px;
  background: #fff7f4;
  text-align: center;
}

.professional-report-kicker {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.professional-report-card h6 {
  margin: 0 0 8px;
  color: var(--ink);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.35;
}

.professional-report-card p {
  max-width: 520px;
  margin: 0 auto 12px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.65;
}

.professional-report-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 7px 13px;
  border: 1px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    transform 0.15s;
}

.professional-report-btn:hover {
  border-color: var(--accent);
  background: var(--accent);
  transform: translateY(-1px);
}

.speech-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  min-height: 28px;
  padding: 4px 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
  transition:
    background 0.15s,
    border-color 0.15s,
    color 0.15s;
}

.speech-btn:hover:not(:disabled),
.speech-btn.speaking {
  background: #fff7f4;
  border-color: var(--accent);
  color: var(--accent);
}

.speech-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.speech-btn i {
  font-size: 14px;
  line-height: 1;
}

.action-btn {
  border: 1px solid var(--border);
  background: #fff;
  padding: 4px 10px;
  font-size: 13px;
  border-radius: 6px;
  cursor: pointer;
}

.action-btn:hover {
  background: #f5f5f5;
}
.logo-wrap {
  height: 100%;
  display: flex;
  align-items: center;
}
.logo-img {
  height: 85%;
  width: auto;
  object-fit: contain;
}
.auth-user button {
  transition: all 0.15s ease;
}

.auth-user button:hover {
  background: rgba(0, 0, 0, 0.06);
  border-radius: 10px;
}
.blog-card-link {
  text-decoration: none;
  color: inherit;
  align-items: flex-start;
}

.blog-card-link strong {
  display: block;
  margin-bottom: 4px;
  font-size: 15px;
}

.blog-card-link small {
  display: block;
  color: var(--muted);
  line-height: 1.5;
  font-size: 13px;
}

.blog-list {
  align-items: stretch;
}

/* Blog / building-law landing page */
.blog-body {
  display: block;
  min-height: 100dvh;
  height: auto;
  overflow: auto;
  background: var(--paper);
}

.blog-page {
  width: min(100%, 980px);
  margin: 0 auto;
  padding: 36px 28px 56px;
}

.messages .blog-page {
  width: min(100%, 900px);
  padding: 6px 0 32px;
}

.blog-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding-bottom: 18px;
  border-bottom: 1px solid var(--line);
  font-size: 12px;
  color: var(--muted);
}

.back-link {
  color: var(--accent);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
}

.back-link::before {
  content: "←";
  margin-right: 6px;
}

.back-link:hover {
  color: var(--ink);
}

.blog-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 28px;
  padding: 42px 0 34px;
  border-bottom: 1px solid var(--line);
}

.blog-kicker {
  margin-bottom: 8px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.blog-hero h1,
.blog-note h2 {
  font-family: "Noto Serif TC", serif;
  color: var(--ink);
}

.blog-hero h1 {
  margin-bottom: 12px;
  font-size: clamp(30px, 5vw, 48px);
  font-weight: 700;
  line-height: 1.18;
}

.blog-lead {
  max-width: 660px;
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.9;
}

.blog-cta {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 16px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  white-space: nowrap;
  transition:
    background 0.15s,
    transform 0.15s;
}

.blog-cta:hover {
  background: var(--accent);
  color: white;
  transform: translateY(-1px);
}

.blog-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 24px;
}

.blog-search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  margin-top: 24px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.blog-search label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.08em;
}

.blog-search input {
  min-width: 0;
  border: 0;
  outline: none;
  color: var(--ink);
  font-size: 14px;
  background: transparent;
}

.blog-search input::placeholder {
  color: #b0a89a;
}

.blog-search:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(200, 82, 42, 0.1);
}

.blog-search span {
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.blog-card {
  min-height: 180px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  transition:
    border-color 0.15s,
    box-shadow 0.15s,
    transform 0.15s;
}

.blog-card:hover {
  border-color: var(--accent);
  box-shadow: 0 8px 24px rgba(90, 62, 34, 0.08);
  transform: translateY(-2px);
}

.blog-tag {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  margin-bottom: 18px;
  padding: 3px 9px;
  border: 1px solid rgba(200, 82, 42, 0.24);
  border-radius: 999px;
  background: #fff7f4;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
}

.blog-card h2 {
  margin-bottom: 10px;
  font-family: "Noto Serif TC", serif;
  font-size: 19px;
  font-weight: 700;
  line-height: 1.45;
}

.blog-card h2 a {
  color: var(--ink);
  text-decoration: none;
}

.blog-card h2 a:hover {
  color: var(--accent);
}

.blog-card p,
.blog-note p {
  margin: 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.8;
}

/* Featured Research index when loaded inside the chat shell */
.research-index {
  width: min(100%, 1120px);
  margin: 0 auto;
  padding: 34px 24px 72px;
}

.research-index .back-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 34px;
  margin-bottom: 0;
  color: var(--muted);
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
}

.research-index .back-link::before {
  content: none;
  margin-right: 0;
}

.research-index .back-link:hover {
  color: var(--accent);
}

.research-index .page-header {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: end;
  gap: 32px;
  padding: 42px 0 36px;
  border-bottom: 1px solid var(--line);
}

.research-index .hero-title {
  max-width: 760px;
  margin-bottom: 18px;
  color: var(--ink);
  font-family: "Noto Serif TC", Georgia, "Times New Roman", serif;
  font-size: clamp(36px, 5.6vw, 62px);
  font-weight: 800;
  letter-spacing: 0;
  line-height: 1.06;
}

.research-index .hero-sub {
  max-width: 700px;
  margin: 0;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.85;
}

.research-index .hero-stat {
  display: grid;
  gap: 4px;
  min-width: 170px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 250, 243, 0.72);
}

.research-index .hero-stat strong {
  color: var(--ink);
  font-size: 28px;
  line-height: 1;
}

.research-index .hero-stat span {
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.research-index .article-search-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-top: 24px;
}

.research-index .article-search {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 10px;
  min-height: 48px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf3;
  box-shadow: 0 10px 28px rgba(68, 45, 28, 0.06);
}

.research-index .article-search i {
  color: var(--accent);
  font-size: 16px;
}

.research-index .article-search input {
  width: 100%;
  min-width: 0;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--ink);
  font-size: 14px;
}

.research-index .article-search input::placeholder {
  color: #a69b8e;
}

.research-index .article-search:focus-within {
  border-color: rgba(200, 82, 42, 0.52);
  box-shadow: 0 0 0 3px rgba(200, 82, 42, 0.1);
}

.research-index .result-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 243, 0.72);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
}

.research-index .article-grid {
  margin-top: 28px;
}

.research-index .article-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 18px;
  height: 100%;
  min-height: 280px;
  margin-bottom: 0;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf3;
  box-shadow: 0 12px 32px rgba(68, 45, 28, 0.06);
  transition:
    border-color 0.16s ease,
    box-shadow 0.16s ease,
    transform 0.16s ease;
}

.research-index .article-card:hover {
  transform: translateY(-3px);
  border-color: rgba(200, 82, 42, 0.5);
  box-shadow: 0 16px 38px rgba(68, 45, 28, 0.1);
}

.research-index .article-tag {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  min-height: 26px;
  padding: 4px 10px;
  border: 1px solid rgba(200, 82, 42, 0.24);
  border-radius: 999px;
  background: #fff3ec;
  color: var(--accent);
  font-size: 12px;
  font-weight: 700;
}

.research-index .article-title {
  color: var(--ink);
  font-family: "Noto Serif TC", Georgia, "Times New Roman", serif;
  font-size: 25px;
  font-weight: 700;
  line-height: 1.3;
}

.research-index .article-desc {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.85;
}

.research-index .article-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  width: fit-content;
  margin-top: auto;
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0.02em;
  text-decoration: none;
}

.research-index .article-link:hover {
  color: var(--accent);
}

.research-index .article-link i {
  font-size: 15px;
  transition: transform 0.16s ease;
}

.research-index .article-link:hover i {
  transform: translateX(3px);
}

.research-index .loading-card {
  padding: 24px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  color: var(--muted);
  background: rgba(255, 250, 243, 0.6);
}

.research-index .powered-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 30px;
  margin-top: 28px;
  padding: 6px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 250, 243, 0.72);
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.research-index .powered-badge i {
  color: var(--accent);
  font-size: 13px;
}

.blog-note {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: 28px;
  margin-top: 24px;
  padding-top: 24px;
  border-top: 1px solid var(--line);
}

.blog-note h2 {
  margin: 0;
  font-size: 22px;
  font-weight: 700;
  line-height: 1.45;
}

.blog-note strong {
  color: var(--ink);
}

.article-page {
  max-width: 840px;
}

.article-body {
  padding-top: 42px;
}

.article-body h1 {
  margin-bottom: 14px;
  font-family: "Noto Serif TC", serif;
  font-size: clamp(30px, 4.5vw, 44px);
  font-weight: 700;
  line-height: 1.25;
}

.article-lead {
  max-width: 720px;
  margin-bottom: 34px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.9;
}

.article-body section {
  padding: 24px 0;
  border-top: 1px solid var(--line);
}

.article-body h2 {
  margin-bottom: 10px;
  font-family: "Noto Serif TC", serif;
  font-size: 22px;
  font-weight: 700;
}

.article-body p {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.9;
}

.article-card {
  margin-bottom: 18px;
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
}

.article-card h2 {
  margin-bottom: 12px;
  font-family: "Noto Serif TC", serif;
  font-size: 22px;
  font-weight: 700;
}

.article-card p,
.article-card li {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.85;
}

.article-card ul {
  margin-bottom: 0;
  padding-left: 1.25rem;
}

.formula {
  margin: 16px 0;
  padding: 14px 16px;
  border-left: 3px solid var(--accent);
  border-radius: 0 8px 8px 0;
  background: #faf7f2;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.75;
}

.example-box {
  margin-top: 16px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #faf7f2;
}

.article-card.warning {
  background: #fff7f4;
  border-color: rgba(200, 82, 42, 0.32);
}

.article-card.source {
  background: transparent;
}

.cta {
  margin-top: 24px;
  padding: 24px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
}

.cta h2,
.cta p {
  color: white;
}

.cta a {
  display: inline-flex;
  margin-top: 8px;
  color: white;
  font-weight: 700;
}
.typing-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.typing-text {
  font-size: 13px;
  color: var(--text-muted);
  opacity: 0.85;
}
@media (max-width: 760px) {
  .research-index {
    padding: 24px 16px 48px;
  }

  .research-index .page-header {
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 32px 0 28px;
  }

  .research-index .hero-stat {
    min-width: 0;
    width: 100%;
  }

  .research-index .article-search-wrap {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .research-index .article-card {
    min-height: 0;
    padding: 20px;
  }

  .blog-page {
    padding: 24px 16px 40px;
  }

  .messages .blog-page {
    padding-top: 0;
  }

  .blog-nav,
  .blog-hero,
  .blog-note {
    grid-template-columns: 1fr;
  }

  .blog-nav {
    align-items: flex-start;
  }

  .blog-hero {
    gap: 18px;
    padding: 30px 0 28px;
  }

  .blog-cta {
    width: 100%;
  }

  .blog-grid {
    grid-template-columns: 1fr;
  }

  .blog-search {
    grid-template-columns: 1fr;
  }

  .blog-card {
    min-height: 0;
  }

  .blog-note {
    gap: 12px;
  }

  .article-body {
    padding-top: 30px;
  }
}
@media (max-width: 600px) {
  .pricing-note {
    font-size: 12px;
    flex-wrap: wrap;
  }
}
