:root {
  color-scheme: dark;
  font-family:
    -apple-system, BlinkMacSystemFont, "SF Pro Text", "PingFang SC",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  color: #ececec;
  background: #171717;
  font-synthesis: none;
  --bg: #171717;
  --surface: #242424;
  --surface-strong: #303030;
  --border: #3a3a3a;
  --text: #ececec;
  --muted: #a9a9a9;
  --green: #56c59a;
  --green-dark: #10281f;
  --danger: #ffb4a8;
  --content: 720px;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  min-height: 100dvh;
  overflow: hidden;
  background: var(--bg);
}

button,
textarea {
  font: inherit;
}

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

button:focus-visible,
textarea:focus-visible,
summary:focus-visible,
a:focus-visible {
  outline: 3px solid rgba(86, 197, 154, 0.72);
  outline-offset: 3px;
}

.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;
}

.skip-link {
  position: fixed;
  z-index: 100;
  top: 8px;
  left: 8px;
  padding: 10px 14px;
  color: #0c1d17;
  background: var(--green);
  border-radius: 8px;
  transform: translateY(-140%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell,
.app-frame {
  width: 100%;
  height: 100dvh;
}

.app-frame {
  position: relative;
  display: grid;
  grid-template-rows: 64px minmax(0, 1fr);
  background: var(--bg);
}

.topbar {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 88px 1fr 88px;
  align-items: center;
  min-height: 64px;
  padding:
    max(8px, env(safe-area-inset-top))
    max(12px, env(safe-area-inset-right))
    8px
    max(12px, env(safe-area-inset-left));
  background: rgba(23, 23, 23, 0.96);
  border-bottom: 1px solid rgba(255, 255, 255, 0.07);
  backdrop-filter: blur(18px);
}

.topbar-button,
.plain-button,
.text-button {
  min-width: 44px;
  min-height: 44px;
  padding: 0 8px;
  color: var(--text);
  background: transparent;
  border: 0;
  border-radius: 10px;
  cursor: pointer;
}

.topbar-button:first-child {
  justify-self: start;
}

.topbar-button:last-child {
  justify-self: end;
}

.topbar-button:hover,
.plain-button:hover,
.text-button:hover {
  background: rgba(255, 255, 255, 0.07);
}

.brand-lockup {
  display: grid;
  justify-items: center;
  line-height: 1.15;
}

.brand-lockup strong {
  font-size: 15px;
  letter-spacing: 0.08em;
}

.brand-lockup span {
  margin-top: 3px;
  color: var(--muted);
  font-size: 11px;
}

.conversation {
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding:
    26px
    max(20px, env(safe-area-inset-right))
    calc(178px + env(safe-area-inset-bottom))
    max(20px, env(safe-area-inset-left));
}

.empty-state,
.thread,
.loading-row,
.error-banner {
  width: min(100%, var(--content));
  margin-inline: auto;
}

.empty-state {
  display: grid;
  min-height: calc(100dvh - 280px);
  align-content: center;
  padding-bottom: 24px;
  text-align: center;
}

.eyebrow,
.assistant-label,
.action-eyebrow {
  margin: 0;
  color: var(--green);
  font-size: 12px;
  font-weight: 750;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.empty-state h1 {
  margin: 14px 0 0;
  font-size: clamp(28px, 7vw, 40px);
  font-weight: 590;
  line-height: 1.18;
  letter-spacing: -0.035em;
}

.empty-state > p:not(.eyebrow) {
  max-width: 480px;
  margin: 14px auto 26px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.7;
}

.starter-list {
  display: grid;
  gap: 10px;
  width: min(100%, 520px);
  margin-inline: auto;
}

.starter-list button {
  min-height: 50px;
  padding: 13px 16px;
  color: #dddddd;
  background: #222;
  border: 1px solid #343434;
  border-radius: 14px;
  text-align: left;
  cursor: pointer;
}

.starter-list button:hover {
  background: #292929;
  border-color: #4a4a4a;
}

.thread {
  display: flex;
  flex-direction: column;
  gap: 32px;
}

.message-row {
  display: flex;
  width: 100%;
}

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

.user-message {
  max-width: min(82%, 560px);
  padding: 11px 15px;
  color: #f2f2f2;
  background: var(--surface-strong);
  border-radius: 20px;
  font-size: 15px;
  line-height: 1.6;
  white-space: pre-wrap;
}

.assistant-message {
  width: 100%;
}

.assistant-label {
  margin-bottom: 10px;
}

.verdict h2 {
  margin: 0;
  font-size: clamp(19px, 4.6vw, 23px);
  font-weight: 620;
  line-height: 1.55;
  letter-spacing: -0.02em;
}

.risk-copy {
  margin: 16px 0 0;
  color: #c9c9c9;
  font-size: 15px;
  line-height: 1.7;
}

.escalation-card {
  margin-top: 16px;
  padding: 14px 15px;
  color: #ffd7d1;
  background: #332421;
  border: 1px solid #60403a;
  border-radius: 13px;
  font-size: 14px;
  line-height: 1.6;
}

.escalation-card strong {
  color: var(--danger);
}

.escalation-card p {
  margin: 7px 0 0;
}

.support-line,
.support-contact {
  overflow-wrap: anywhere;
}

.action-card {
  margin-top: 24px;
  padding: 18px;
  background: #202522;
  border: 1px solid #34443d;
  border-radius: 16px;
}

.action-card h3 {
  margin: 10px 0 18px;
  font-size: 16px;
  font-weight: 620;
  line-height: 1.65;
}

.action-meta {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.action-meta > div {
  display: grid;
  gap: 5px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.035);
  border-radius: 11px;
}

.action-meta .wide {
  grid-column: 1 / -1;
}

.action-meta strong {
  color: var(--green);
  font-size: 12px;
  font-weight: 700;
}

.action-meta span {
  color: #dddddd;
  font-size: 14px;
  line-height: 1.55;
}

.action-meta .stop {
  background: rgba(255, 180, 168, 0.06);
}

.action-meta .stop strong {
  color: var(--danger);
}

.action-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.primary-action,
.secondary-action {
  min-height: 44px;
  padding: 10px 15px;
  border-radius: 11px;
  font-weight: 650;
  cursor: pointer;
}

.primary-action {
  color: var(--green-dark);
  background: var(--green);
  border: 1px solid var(--green);
}

.primary-action:hover {
  background: #6fd4ad;
}

.primary-action:disabled {
  color: #9b9b9b;
  background: #333;
  border-color: #444;
  cursor: default;
}

.secondary-action {
  color: var(--green);
  background: transparent;
  border: 1px solid rgba(86, 197, 154, 0.62);
}

.evidence-panel {
  margin-top: 14px;
  border-bottom: 1px solid var(--border);
}

.evidence-panel summary {
  min-height: 46px;
  display: flex;
  align-items: center;
  color: var(--green);
  cursor: pointer;
}

.evidence-content {
  padding: 2px 0 18px;
  color: #cfcfcf;
  font-size: 14px;
  line-height: 1.65;
}

.evidence-content h4 {
  margin: 18px 0 8px;
  color: var(--text);
  font-size: 14px;
}

.evidence-status {
  margin-top: 0;
}

.evidence-list {
  display: grid;
  grid-template-columns: max-content 1fr;
  gap: 6px 14px;
  margin: 0;
}

.evidence-list dt {
  color: var(--muted);
}

.evidence-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.calculation {
  padding: 10px 12px;
  background: #222;
  border-radius: 10px;
}

.policy-note {
  color: var(--muted);
  font-size: 12px;
}

.next-question {
  display: grid;
  gap: 9px;
  margin-top: 18px;
  padding: 16px;
  background: #222;
  border: 1px solid #353535;
  border-radius: 14px;
}

.next-question strong {
  line-height: 1.6;
}

.next-question .text-button {
  justify-self: start;
  margin-left: -8px;
  color: var(--green);
}

.answer-footer {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  justify-content: space-between;
  margin-top: 18px;
  color: #8f8f8f;
  font-size: 12px;
  line-height: 1.55;
}

.feedback-actions {
  display: flex;
  flex: 0 0 auto;
  gap: 2px;
}

.feedback-actions .text-button {
  min-height: 44px;
  color: #b9b9b9;
  font-size: 12px;
}

.feedback-thanks {
  display: inline-flex;
  min-height: 44px;
  align-items: center;
}

.loading-row {
  display: flex;
  gap: 5px;
  align-items: center;
  min-height: 48px;
}

.loading-row[hidden],
.error-banner[hidden],
.empty-state[hidden],
.thread[hidden],
.followup-hint[hidden] {
  display: none;
}

.loading-row > span:not(.sr-only) {
  width: 7px;
  height: 7px;
  background: #b7b7b7;
  border-radius: 50%;
  animation: thinking 1.1s ease-in-out infinite;
}

.loading-row > span:nth-child(2) {
  animation-delay: 130ms;
}

.loading-row > span:nth-child(3) {
  animation-delay: 260ms;
}

@keyframes thinking {
  0%,
  60%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  30% {
    opacity: 1;
    transform: translateY(-3px);
  }
}

.error-banner {
  margin-top: 18px;
  padding: 12px 14px;
  color: #ffd2cb;
  background: #362421;
  border: 1px solid #624039;
  border-radius: 12px;
  font-size: 14px;
  line-height: 1.55;
}

.composer-shell {
  position: absolute;
  z-index: 24;
  right: 0;
  bottom: 0;
  left: 0;
  padding:
    30px
    max(14px, env(safe-area-inset-right))
    max(10px, env(safe-area-inset-bottom))
    max(14px, env(safe-area-inset-left));
  background: linear-gradient(to bottom, rgba(23, 23, 23, 0), var(--bg) 28px);
}

.composer,
.followup-hint,
.media-status,
.attachment-tray,
.composer-note {
  width: min(100%, calc(var(--content) + 28px));
  margin-inline: auto;
}

.composer {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 8px;
  align-items: end;
  padding: 8px;
  background: #2d2d2d;
  border: 1px solid #444;
  border-radius: 26px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.32);
}

.composer-tools {
  display: flex;
  gap: 2px;
  align-items: center;
  min-height: 44px;
}

.composer-tool {
  display: grid;
  width: 40px;
  min-width: 40px;
  height: 40px;
  padding: 0;
  place-items: center;
  color: #b8b8b8;
  background: transparent;
  border: 0;
  border-radius: 20px;
  cursor: pointer;
}

.composer-tool:hover,
.composer-tool:focus-visible {
  color: var(--text);
  background: #3c3c3c;
}

.composer-tool[data-active="true"] {
  color: #fff;
  background: #b94a48;
  animation: voice-pulse 1.4s ease-in-out infinite;
}

.composer-tool svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.composer textarea {
  width: 100%;
  min-height: 42px;
  max-height: 144px;
  padding: 10px 0 7px;
  overflow-y: auto;
  resize: none;
  color: var(--text);
  background: transparent;
  border: 0;
  outline: 0;
  font-size: 15px;
  line-height: 1.5;
}

.media-status {
  margin-bottom: 8px;
  padding: 9px 12px;
  color: #d8d8d8;
  background: #252525;
  border: 1px solid #3b3b3b;
  border-radius: 12px;
  font-size: 12px;
  line-height: 1.5;
}

.attachment-tray {
  display: flex;
  gap: 8px;
  margin-bottom: 8px;
  overflow-x: auto;
}

.attachment-item {
  position: relative;
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
}

.attachment-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border: 1px solid #4a4a4a;
  border-radius: 12px;
}

.attachment-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  display: grid;
  width: 24px;
  min-width: 24px;
  height: 24px;
  padding: 0;
  place-items: center;
  color: #fff;
  background: #171717;
  border: 1px solid #606060;
  border-radius: 50%;
  font-size: 15px;
  line-height: 1;
  cursor: pointer;
}

.user-attachments {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 92px));
  gap: 6px;
  margin-bottom: 7px;
}

.user-attachments img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 10px;
}

@keyframes voice-pulse {
  50% {
    box-shadow: 0 0 0 5px rgba(185, 74, 72, 0.18);
  }
}

.composer textarea::placeholder {
  color: #9a9a9a;
}

.send-button {
  min-width: 58px;
  min-height: 44px;
  padding: 0 14px;
  color: var(--green-dark);
  background: var(--green);
  border: 0;
  border-radius: 22px;
  font-weight: 720;
  cursor: pointer;
}

.send-button:disabled {
  color: #888;
  background: #414141;
  cursor: wait;
}

.composer-note {
  margin-top: 7px;
  color: #808080;
  font-size: 11px;
  line-height: 1.5;
  text-align: center;
}

.followup-hint {
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
  padding: 9px 12px;
  color: #cfcfcf;
  background: #222;
  border: 1px solid #363636;
  border-radius: 12px;
  font-size: 12px;
}

.followup-hint button {
  flex: 0 0 auto;
  min-height: 44px;
  padding: 6px 9px;
  color: var(--green);
  background: transparent;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
}

.drawer-scrim {
  position: fixed;
  z-index: 39;
  inset: 0;
  padding: 0;
  background: rgba(0, 0, 0, 0.62);
  border: 0;
}

.history-drawer {
  position: fixed;
  z-index: 40;
  top: 0;
  bottom: 0;
  left: 0;
  display: grid;
  grid-template-rows: auto auto auto minmax(0, 1fr) auto;
  width: min(86vw, 320px);
  padding:
    max(14px, env(safe-area-inset-top))
    12px
    max(16px, env(safe-area-inset-bottom));
  background: #202020;
  border-right: 1px solid #383838;
  box-shadow: 18px 0 48px rgba(0, 0, 0, 0.38);
  transform: translateX(-104%);
  visibility: hidden;
  pointer-events: none;
  transition: transform 180ms ease-out, visibility 0s linear 180ms;
}

.history-drawer[hidden] {
  display: none;
}

.history-drawer[data-open="true"] {
  transform: translateX(0);
  visibility: visible;
  pointer-events: auto;
  transition-delay: 0s;
}

.drawer-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 48px;
  padding: 0 4px 8px 10px;
}

.drawer-heading strong {
  font-size: 15px;
  letter-spacing: 0.07em;
}

.new-chat-row,
.history-row {
  width: 100%;
  min-height: 46px;
  padding: 10px 12px;
  color: #e5e5e5;
  background: transparent;
  border: 0;
  border-radius: 10px;
  text-align: left;
  cursor: pointer;
}

.new-chat-row {
  margin-bottom: 14px;
  border: 1px solid #3d3d3d;
}

.history-row:hover,
.history-row[data-active="true"] {
  background: #2d2d2d;
}

.drawer-label {
  margin: 0;
  padding: 0 12px 8px;
  color: #8c8c8c;
  font-size: 12px;
}

.history-list {
  overflow-y: auto;
}

.history-empty {
  padding: 0 12px;
  color: #898989;
  font-size: 13px;
}

.drawer-footer {
  padding: 12px 8px 0;
  border-top: 1px solid #333;
}

.drawer-link {
  display: flex;
  width: 100%;
  align-items: center;
  justify-content: space-between;
  margin: 0 0 14px;
  padding: 12px;
  color: #eeeeee;
  background: #292929;
  border: 1px solid #3a3a3a;
  border-radius: 12px;
  text-align: left;
  cursor: pointer;
}

.drawer-link:hover {
  background: #303030;
}

.drawer-status {
  color: var(--accent);
  font-size: 12px;
}

.drawer-footer .plain-button {
  padding: 0;
  color: #d8d8d8;
}

.drawer-footer p {
  margin: 4px 0 0;
  color: #858585;
  font-size: 11px;
  line-height: 1.5;
}

.boundary-dialog {
  width: min(calc(100% - 32px), 520px);
  max-height: min(760px, calc(100dvh - 32px));
  overflow-y: auto;
  padding: 22px;
  color: var(--text);
  background: #222;
  border: 1px solid #444;
  border-radius: 18px;
  box-shadow: 0 24px 72px rgba(0, 0, 0, 0.58);
}

.boundary-dialog::backdrop {
  background: rgba(0, 0, 0, 0.72);
}

.dialog-heading {
  display: flex;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
}

.dialog-heading h2 {
  margin: 0;
  font-size: 20px;
}

.dialog-kicker {
  margin: 0 0 2px !important;
  color: var(--accent) !important;
  font-size: 11px !important;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.boundary-dialog p {
  color: #c8c8c8;
  font-size: 14px;
  line-height: 1.7;
}

.telemetry-choice {
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid #3a3a3a;
}

.telemetry-choice h3 {
  margin: 0;
  font-size: 16px;
}

.telemetry-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.integration-summary {
  margin: 18px 0;
  padding: 13px 14px;
  color: #d8f8e5;
  background: rgba(86, 209, 139, 0.1);
  border: 1px solid rgba(86, 209, 139, 0.25);
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.55;
}

.integration-groups {
  display: grid;
  gap: 22px;
}

.integration-group h3,
.configuration-guide h3 {
  margin: 0 0 10px;
  font-size: 15px;
}

.integration-card {
  margin-top: 10px;
  padding: 14px;
  background: #292929;
  border: 1px solid #3b3b3b;
  border-radius: 14px;
}

.integration-card[data-configured="true"] {
  border-color: rgba(86, 209, 139, 0.32);
}

.integration-card-heading,
.integration-config {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: space-between;
}

.integration-badge {
  flex: 0 0 auto;
  padding: 4px 8px;
  color: #bdbdbd;
  background: #363636;
  border-radius: 999px;
  font-size: 11px;
}

.integration-card[data-configured="true"] .integration-badge {
  color: #bdf3d1;
  background: rgba(86, 209, 139, 0.12);
}

.integration-purpose,
.integration-note,
.integration-verified {
  margin: 7px 0 !important;
  color: #aaaaaa !important;
  font-size: 12px !important;
  line-height: 1.55 !important;
}

.integration-config {
  margin-top: 11px;
  padding-top: 10px;
  border-top: 1px solid #383838;
}

.integration-config code {
  min-width: 0;
  overflow-wrap: anywhere;
  color: #d7d7d7;
  font-size: 11px;
}

.integration-config .plain-button {
  flex: 0 0 auto;
  color: var(--accent);
  font-size: 12px;
}

.configuration-guide {
  margin-top: 22px;
  padding-top: 18px;
  border-top: 1px solid #3a3a3a;
}

.configuration-guide ol {
  margin: 8px 0;
  padding-left: 20px;
  color: #c8c8c8;
  font-size: 13px;
  line-height: 1.8;
}

noscript {
  position: fixed;
  z-index: 200;
  inset: 16px;
  padding: 20px;
  color: #20110e;
  background: #ffd2cb;
  border-radius: 12px;
}

@media (max-width: 560px) {
  .topbar {
    grid-template-columns: 72px 1fr 72px;
  }

  .topbar-button {
    padding-inline: 4px;
    font-size: 13px;
  }

  .conversation {
    padding-inline: 16px;
  }

  .action-meta {
    grid-template-columns: 1fr;
  }

  .action-meta .wide {
    grid-column: auto;
  }

  .answer-footer {
    display: grid;
  }

  .feedback-actions {
    margin-left: -8px;
  }

  .composer-note {
    padding-inline: 8px;
  }
}

@media (min-width: 960px) {
  .app-frame {
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    border-left: 1px solid rgba(255, 255, 255, 0.05);
  }
}

@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;
  }
}
