:root {
  color-scheme: light;
  --ink: #13263a;
  --muted: #617386;
  --line: #dbe5ea;
  --surface: #ffffff;
  --surface-soft: #f4f8f8;
  --navy: #12354d;
  --teal: #087f78;
  --teal-soft: #e8f7f4;
  --green: #17745c;
  --amber: #a65c05;
  --amber-soft: #fff5df;
  --red: #b12c38;
  --red-soft: #fff0f1;
  --shadow: 0 24px 70px rgba(23, 55, 70, 0.12);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 2%, rgba(79, 180, 164, 0.18), transparent 32rem),
    linear-gradient(145deg, #eef6f5 0%, #f7f9fb 48%, #edf3f7 100%);
}

button,
textarea {
  font: inherit;
}

button,
a {
  -webkit-tap-highlight-color: transparent;
}

a {
  color: inherit;
}

.page-shell {
  width: min(1440px, 100%);
  min-height: 100vh;
  margin: 0 auto;
  padding: 0 32px 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 84px;
  border-bottom: 1px solid rgba(117, 143, 154, 0.24);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
  color: var(--navy);
  text-decoration: none;
}

.brand-mark,
.message-avatar {
  display: grid;
  place-items: center;
  color: white;
  background: linear-gradient(135deg, var(--navy), var(--teal));
  box-shadow: 0 8px 24px rgba(8, 127, 120, 0.2);
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.05rem;
  letter-spacing: -0.02em;
}

.brand small {
  margin-top: 2px;
  color: var(--muted);
  font-size: 0.75rem;
}

.topbar-actions,
.status-pill {
  display: flex;
  align-items: center;
}

.topbar-actions {
  gap: 18px;
}

.status-pill {
  gap: 8px;
  padding: 8px 12px;
  color: var(--muted);
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.8rem;
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #93a3af;
}

.status-ready .status-dot {
  background: #16a57a;
  box-shadow: 0 0 0 4px rgba(22, 165, 122, 0.12);
}

.status-error .status-dot {
  background: var(--red);
}

.text-link {
  color: var(--navy);
  font-size: 0.85rem;
  font-weight: 700;
  text-underline-offset: 4px;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 24px;
  align-items: start;
  padding-top: 28px;
}

.chat-panel,
.info-card {
  border: 1px solid rgba(196, 212, 219, 0.82);
  background: rgba(255, 255, 255, 0.9);
  box-shadow: var(--shadow);
  backdrop-filter: blur(16px);
}

.chat-panel {
  min-height: calc(100vh - 148px);
  padding: 28px;
  border-radius: 26px;
}

.chat-heading {
  display: flex;
  justify-content: space-between;
  gap: 24px;
  padding-bottom: 22px;
  border-bottom: 1px solid var(--line);
}

.eyebrow {
  margin: 0 0 7px;
  color: var(--teal);
  font-size: 0.73rem;
  font-weight: 800;
  letter-spacing: 0.13em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  color: var(--navy);
  font-size: clamp(1.55rem, 2.5vw, 2.2rem);
  letter-spacing: -0.04em;
}

.chat-heading p:last-child {
  max-width: 670px;
  margin-bottom: 0;
  color: var(--muted);
  line-height: 1.55;
}

.quiet-button,
.prompt-chip {
  color: var(--navy);
  border: 1px solid var(--line);
  background: var(--surface);
  cursor: pointer;
  transition: 160ms ease;
}

.quiet-button {
  align-self: start;
  flex: 0 0 auto;
  padding: 9px 13px;
  border-radius: 10px;
  font-size: 0.8rem;
  font-weight: 700;
}

.quiet-button:hover,
.prompt-chip:hover {
  border-color: rgba(8, 127, 120, 0.55);
  background: var(--teal-soft);
  transform: translateY(-1px);
}

.chat-log {
  min-height: 330px;
  max-height: 51vh;
  padding: 26px 4px 18px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.message {
  display: flex;
  gap: 12px;
  margin-bottom: 22px;
}

.message-avatar {
  flex: 0 0 34px;
  width: 34px;
  height: 34px;
  border-radius: 11px;
  font-size: 0.72rem;
  font-weight: 800;
}

.message-content {
  max-width: min(780px, 88%);
}

.message-label,
.message-label-row {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.message-label {
  margin-bottom: 6px;
}

.message-label-row {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-bottom: 6px;
}

.message-label-row .message-label {
  margin: 0;
}

.message-bubble {
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: 5px 17px 17px;
  background: var(--surface-soft);
  line-height: 1.62;
  overflow-wrap: anywhere;
}

.message-bubble p:last-child {
  margin-bottom: 0;
}

.answer-text {
  white-space: pre-wrap;
}

.user-message {
  justify-content: flex-end;
}

.user-message .message-content {
  max-width: min(680px, 78%);
}

.user-message .message-label {
  text-align: right;
}

.user-message .message-bubble {
  color: white;
  border-color: var(--navy);
  border-radius: 17px 5px 17px 17px;
  background: var(--navy);
}

.tone-danger .message-avatar {
  background: var(--red);
}

.tone-danger .message-bubble {
  border-color: #f2c5ca;
  background: var(--red-soft);
}

.tone-warning .message-bubble {
  border-color: #efd6a8;
  background: var(--amber-soft);
}

.result-badge {
  padding: 3px 7px;
  color: var(--green);
  border-radius: 999px;
  background: var(--teal-soft);
  font-size: 0.65rem;
  font-weight: 800;
}

.tone-danger .result-badge {
  color: var(--red);
  background: var(--red-soft);
}

.tone-warning .result-badge {
  color: var(--amber);
  background: var(--amber-soft);
}

.inline-citation {
  color: var(--teal);
  font-weight: 800;
  text-decoration: none;
}

.inline-citation:hover {
  text-decoration: underline;
}

.citation-list,
.safety-resources {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 9px;
}

.citation-list > span {
  width: 100%;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 750;
  text-transform: uppercase;
}

.citation-list a,
.safety-resources a {
  padding: 7px 10px;
  color: var(--teal);
  border: 1px solid var(--line);
  border-radius: 9px;
  background: white;
  font-size: 0.74rem;
  font-weight: 700;
  text-decoration: none;
}

.safety-resources a {
  color: var(--red);
  border-color: #f2c5ca;
}

.response-details {
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.73rem;
}

.response-details summary {
  width: fit-content;
  cursor: pointer;
  font-weight: 700;
}

.response-details dl {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 5px 12px;
  max-width: 560px;
  margin: 10px 0 0;
  padding: 10px 12px;
  border-radius: 10px;
  background: #eef3f5;
}

.response-details dt {
  font-weight: 750;
}

.response-details dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.loading-bubble {
  display: flex;
  gap: 5px;
  align-items: center;
  color: var(--muted);
}

.loading-bubble span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--teal);
  animation: pulse 1s infinite ease-in-out;
}

.loading-bubble span:nth-child(2) {
  animation-delay: 120ms;
}

.loading-bubble span:nth-child(3) {
  animation-delay: 240ms;
}

.loading-bubble em {
  margin-left: 5px;
  font-size: 0.8rem;
  font-style: normal;
}

@keyframes pulse {
  0%,
  100% {
    opacity: 0.3;
    transform: translateY(0);
  }
  50% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.prompt-section {
  padding: 14px 0;
  border-top: 1px solid var(--line);
}

.prompt-section > span {
  display: block;
  margin-bottom: 9px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 750;
}

.prompt-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.prompt-chip {
  padding: 8px 11px;
  border-radius: 999px;
  font-size: 0.76rem;
}

.composer {
  padding: 13px;
  border: 1px solid #bdced5;
  border-radius: 17px;
  background: white;
  box-shadow: 0 12px 28px rgba(23, 55, 70, 0.08);
  transition: 160ms ease;
}

.composer:focus-within {
  border-color: var(--teal);
  box-shadow: 0 0 0 4px rgba(8, 127, 120, 0.09);
}

.composer textarea {
  width: 100%;
  min-height: 72px;
  padding: 3px 5px;
  color: var(--ink);
  border: 0;
  outline: 0;
  resize: vertical;
  line-height: 1.5;
}

.composer textarea::placeholder {
  color: #8b9aa5;
}

.composer-footer {
  display: flex;
  gap: 12px;
  align-items: center;
  padding-top: 9px;
  color: var(--muted);
  border-top: 1px solid #edf1f3;
  font-size: 0.7rem;
}

.keyboard-hint {
  margin-left: auto;
}

.send-button {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 9px 14px;
  color: white;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--teal), #086a72);
  box-shadow: 0 8px 20px rgba(8, 127, 120, 0.2);
  cursor: pointer;
  font-size: 0.78rem;
  font-weight: 800;
}

.send-button:disabled {
  cursor: wait;
  opacity: 0.64;
}

.privacy-note {
  margin: 10px 2px 0;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
}

.info-panel {
  display: grid;
  gap: 16px;
}

.info-card {
  padding: 20px;
  border-radius: 19px;
  box-shadow: 0 14px 38px rgba(23, 55, 70, 0.08);
}

.info-card h2 {
  margin-bottom: 12px;
  color: var(--navy);
  font-size: 0.96rem;
}

.info-card p:last-child {
  margin-bottom: 0;
  color: var(--muted);
  font-size: 0.79rem;
  line-height: 1.55;
}

.mode-badge {
  width: fit-content;
  margin-bottom: 10px;
  padding: 7px 10px;
  color: var(--muted);
  border-radius: 8px;
  background: #edf2f4;
  font-size: 0.76rem;
  font-weight: 800;
}

.mode-local {
  color: var(--green);
  background: var(--teal-soft);
}

.mode-external {
  color: var(--amber);
  background: var(--amber-soft);
}

.mode-error {
  color: var(--red);
  background: var(--red-soft);
}

.flow-list {
  display: grid;
  gap: 10px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.flow-list li {
  display: grid;
  grid-template-columns: 25px 1fr;
  gap: 9px;
  align-items: center;
  color: var(--muted);
  font-size: 0.77rem;
  line-height: 1.35;
}

.flow-list span {
  display: grid;
  place-items: center;
  width: 25px;
  height: 25px;
  color: var(--teal);
  border-radius: 8px;
  background: var(--teal-soft);
  font-size: 0.7rem;
  font-weight: 850;
}

.safety-card {
  border-color: #efc5ca;
  background: rgba(255, 245, 246, 0.93);
}

.safety-card h2 {
  color: var(--red);
}

.compact-card {
  background: rgba(244, 248, 248, 0.92);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 980px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .info-panel {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .mode-card,
  .safety-card {
    grid-column: span 1;
  }
}

@media (max-width: 680px) {
  .page-shell {
    padding: 0 14px 20px;
  }

  .topbar {
    min-height: 72px;
  }

  .brand small,
  .text-link,
  .keyboard-hint {
    display: none;
  }

  .status-pill {
    padding: 7px 9px;
  }

  .workspace {
    padding-top: 14px;
  }

  .chat-panel {
    min-height: auto;
    padding: 18px 14px;
    border-radius: 20px;
  }

  .chat-heading {
    display: block;
  }

  .quiet-button {
    margin-top: 14px;
  }

  .chat-log {
    max-height: 52vh;
  }

  .message-content,
  .user-message .message-content {
    max-width: 88%;
  }

  .composer-footer {
    flex-wrap: wrap;
  }

  .send-button {
    margin-left: auto;
  }

  .info-panel {
    grid-template-columns: 1fr;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
