:root {
  color-scheme: light;
  --ink: #202020;
  --muted: #6e6a65;
  --line: #e2ded8;
  --soft: #f7f5f2;
  --paper: #fff;
  --orange: #f48120;
  --orange-dark: #c95905;
  --orange-soft: #fff1e5;
  --blue-soft: #eef4ff;
  --blue: #215ea8;
  --green: #177245;
  --red: #b42318;
  --shadow: 0 16px 42px rgba(35, 29, 23, 0.08);
  font-family:
    Inter, ui-sans-serif, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 90% 0%, rgba(244, 129, 32, 0.11), transparent 28rem),
    #faf9f7;
  line-height: 1.5;
}

button,
input,
textarea {
  font: inherit;
}

button,
label {
  cursor: pointer;
}

a {
  color: var(--blue);
}

[hidden] {
  display: none !important;
}

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

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 66px;
  padding: 0 4vw;
  background: rgba(255, 255, 255, 0.9);
  border-bottom: 1px solid rgba(226, 222, 216, 0.9);
  backdrop-filter: blur(16px);
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 750;
  text-decoration: none;
}

.brand-mark,
.assistant-avatar {
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--orange);
  font-weight: 800;
}

.brand-mark {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  font-size: 0.72rem;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.local-state {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--muted);
  font-size: 0.77rem;
}

.local-dot,
.online-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #2ba36a;
  border-radius: 50%;
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 9px;
  font-weight: 750;
  text-decoration: none;
}

.button-small {
  min-height: 34px;
  padding: 0 11px;
  font-size: 0.77rem;
}

.button-ghost {
  color: #4b4742;
  background: transparent;
  border-color: var(--line);
}

.button-primary {
  color: #fff;
  background: var(--orange-dark);
}

.button-secondary {
  color: var(--ink);
  background: #fff;
  border-color: #c9c4bd;
}

.button-wide {
  width: 100%;
  margin-top: 9px;
}

.language-menu {
  position: relative;
}

.language-menu-toggle {
  gap: 6px;
}

.language-menu-popover {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  z-index: 30;
  display: grid;
  min-width: 150px;
  padding: 6px;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 10px;
  box-shadow: var(--shadow);
}

.language-menu-popover button {
  padding: 9px 10px;
  color: var(--ink);
  text-align: left;
  background: transparent;
  border: 0;
  border-radius: 7px;
}

.language-menu-popover button:hover,
.language-menu-popover button.active {
  color: var(--orange-dark);
  background: var(--orange-soft);
}

main {
  width: min(1260px, 94vw);
  margin: 0 auto;
}

.intro {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 30px;
  padding: 48px 0 28px;
}

.eyebrow,
.panel-label {
  margin: 0 0 4px;
  color: var(--orange-dark);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.intro h1 {
  max-width: 720px;
  margin: 0;
  font-size: clamp(2rem, 4.3vw, 3.7rem);
  line-height: 1.04;
  letter-spacing: -0.048em;
}

.intro p:not(.eyebrow) {
  max-width: 680px;
  margin: 14px 0 0;
  color: #55514c;
  font-size: 1.03rem;
}

.privacy-chip {
  max-width: 380px;
  padding: 12px 14px;
  color: #5c4e42;
  background: var(--orange-soft);
  border: 1px solid #f1d2b7;
  border-radius: 11px;
  font-size: 0.8rem;
}

.privacy-chip span {
  margin-right: 6px;
  color: var(--orange);
}

.app-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 22px;
  align-items: start;
  padding-bottom: 70px;
}

.chat-card,
.case-panel {
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
}

.chat-card {
  display: grid;
  grid-template-rows: auto minmax(430px, 62vh) auto auto auto;
  overflow: hidden;
  border-radius: 18px;
}

.chat-header {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--line);
}

.assistant-avatar {
  width: 39px;
  height: 39px;
  border-radius: 12px;
  font-size: 0.72rem;
}

.chat-header h2,
.chat-header p {
  margin: 0;
}

.chat-header h2 {
  font-size: 0.95rem;
}

.chat-header p {
  color: var(--muted);
  font-size: 0.72rem;
}

.messages {
  display: flex;
  flex-direction: column;
  gap: 18px;
  overflow-y: auto;
  padding: 24px;
  scroll-behavior: smooth;
}

.message-row {
  display: flex;
  align-items: flex-start;
  gap: 9px;
  max-width: 86%;
}

.message-row.user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-avatar {
  display: grid;
  flex: 0 0 auto;
  place-items: center;
  width: 27px;
  height: 27px;
  color: var(--orange-dark);
  background: var(--orange-soft);
  border-radius: 8px;
  font-size: 0.62rem;
  font-weight: 850;
}

.message-row.user .message-avatar {
  color: #fff;
  background: #68635d;
}

.message-content {
  min-width: 0;
}

.bubble {
  padding: 11px 14px;
  background: var(--soft);
  border-radius: 4px 13px 13px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  font-size: 0.89rem;
}

.message-row.user .bubble {
  color: #fff;
  background: #3d3a37;
  border-radius: 13px 4px 13px 13px;
}

.message-time {
  display: block;
  margin-top: 4px;
  color: #99938c;
  font-size: 0.65rem;
}

.message-row.user .message-time {
  text-align: right;
}

.guidance-card,
.diagnosis-card,
.critical-card {
  margin-top: 8px;
  padding: 11px 13px;
  border-radius: 10px;
  font-size: 0.78rem;
  white-space: pre-wrap;
}

.guidance-card {
  color: #4c5f78;
  background: var(--blue-soft);
  border: 1px solid #cfdef4;
}

.guidance-card strong,
.diagnosis-card strong,
.critical-card strong {
  display: block;
  margin-bottom: 3px;
}

.diagnosis-card {
  color: #315849;
  background: #edf7f1;
  border: 1px solid #c8e2d3;
}

.critical-card {
  color: #74231c;
  background: #fff0ee;
  border: 1px solid #f0c6c0;
}

.quick-replies {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding: 10px 20px;
  border-top: 1px solid var(--line);
}

.quick-replies button {
  flex: 0 0 auto;
  min-height: 34px;
  padding: 0 12px;
  color: var(--orange-dark);
  background: var(--orange-soft);
  border: 1px solid #edc7a6;
  border-radius: 999px;
  font-size: 0.77rem;
  font-weight: 750;
}

.attachment-preview {
  align-items: center;
  justify-content: space-between;
  margin: 0 20px 8px;
  padding: 8px 10px;
  background: var(--soft);
  border-radius: 8px;
  font-size: 0.74rem;
}

.attachment-preview:not([hidden]) {
  display: flex;
}

.attachment-preview button {
  color: var(--muted);
  background: transparent;
  border: 0;
  font-size: 1.1rem;
}

.composer {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 9px;
  align-items: end;
  padding: 14px 18px;
  border-top: 1px solid var(--line);
}

.attach-button {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  color: var(--muted);
  background: var(--soft);
  border-radius: 10px;
  font-size: 1.2rem;
}

.composer textarea {
  width: 100%;
  max-height: 140px;
  padding: 9px 2px;
  resize: none;
  color: var(--ink);
  background: transparent;
  border: 0;
  outline: none;
}

.send-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  padding: 0 14px;
  color: #fff;
  background: var(--orange-dark);
  border: 0;
  border-radius: 10px;
  font-weight: 750;
}

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

.composer-status {
  min-height: 19px;
  margin: 0;
  padding: 0 20px 9px;
  color: var(--muted);
  font-size: 0.7rem;
}

.case-panel {
  position: sticky;
  top: 82px;
  overflow: hidden;
  border-radius: 16px;
}

.panel-section {
  padding: 20px;
  border-bottom: 1px solid var(--line);
}

.panel-section:last-child {
  border-bottom: 0;
}

.panel-heading,
.section-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-heading h2,
.panel-section h3 {
  margin: 0;
}

.panel-heading h2 {
  font-size: 1.35rem;
}

.panel-section h3 {
  font-size: 0.86rem;
}

.section-title-row > span {
  color: var(--muted);
  font-size: 0.68rem;
}

.progress-ring {
  position: relative;
  width: 45px;
  height: 45px;
  background: conic-gradient(var(--orange) 0%, #ebe8e3 0);
  border-radius: 50%;
}

.progress-ring::after {
  content: "";
  position: absolute;
  inset: 6px;
  background: #fff;
  border-radius: inherit;
}

.progress-bar {
  height: 6px;
  margin: 14px 0 9px;
  overflow: hidden;
  background: #ebe8e3;
  border-radius: 999px;
}

.progress-bar span {
  display: block;
  width: 0;
  height: 100%;
  background: var(--orange);
  transition: width 180ms ease;
}

.readiness-copy,
.draft-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.73rem;
}

.collected-list {
  display: grid;
  gap: 10px;
  margin: 15px 0 0;
}

.collected-list div:not(.empty-state) {
  display: grid;
  grid-template-columns: 92px 1fr;
  gap: 8px;
  font-size: 0.72rem;
}

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

.collected-list dd {
  margin: 0;
  overflow-wrap: anywhere;
  font-weight: 650;
}

.empty-state {
  color: #99938c;
  font-size: 0.74rem;
}

.evidence-panel ul {
  display: grid;
  gap: 7px;
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
}

.evidence-panel li {
  display: grid;
  grid-template-columns: 14px 1fr;
  gap: 6px;
  color: #5c5752;
  font-size: 0.72rem;
}

.evidence-panel li::before {
  content: "○";
  color: var(--orange-dark);
}

.ready-badge {
  padding: 3px 7px;
  color: var(--green) !important;
  background: #e7f4ec;
  border-radius: 999px;
  font-weight: 800;
}

.draft-panel textarea {
  width: 100%;
  margin-top: 12px;
  padding: 10px;
  resize: vertical;
  border: 1px solid #cbc6bf;
  border-radius: 8px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.68rem;
  line-height: 1.45;
}

.draft-note {
  margin-top: 9px;
}

footer {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 22px 4vw;
  color: var(--muted);
  background: #f2efeb;
  border-top: 1px solid var(--line);
  font-size: 0.75rem;
}

@media (max-width: 930px) {
  .intro {
    display: block;
  }

  .privacy-chip {
    max-width: none;
    margin-top: 16px;
  }

  .app-layout {
    grid-template-columns: 1fr;
  }

  .case-panel {
    position: static;
  }

  .chat-card {
    grid-template-rows: auto minmax(430px, 58vh) auto auto auto;
  }
}

@media (max-width: 620px) {
  .topbar {
    padding: 0 12px;
  }

  .brand > span:last-child,
  .local-state {
    display: none;
  }

  main {
    width: min(100% - 20px, 1260px);
  }

  .intro {
    padding: 33px 3px 19px;
  }

  .intro h1 {
    font-size: 2.25rem;
  }

  .chat-card,
  .case-panel {
    border-radius: 13px;
  }

  .messages {
    padding: 18px 14px;
  }

  .message-row {
    max-width: 94%;
  }

  .composer {
    padding: 11px;
  }

  .send-button span:first-child {
    display: none;
  }

  .send-button {
    width: 40px;
    padding: 0;
    justify-content: center;
  }

  footer {
    flex-direction: column;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition: none !important;
  }
}
