:root {
  color-scheme: light;
  --bg: #f6f8f7;
  --paper: #ffffff;
  --ink: #17211d;
  --muted: #66736c;
  --soft: #eef4f1;
  --line: #dce5df;
  --green: #0f7a4f;
  --green-dark: #095f3b;
  --graphite: #111917;
  --silver: #eef2f0;
  --warning: #95640f;
  --danger: #b42318;
  --shadow: 0 20px 58px rgba(17, 25, 23, .10);
}

* {
  box-sizing: border-box;
  letter-spacing: 0;
}

html {
  min-height: 100%;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100dvh;
  color: var(--ink);
  background:
    linear-gradient(180deg, #f9fbfa 0%, #f4f7f5 42%, #ffffff 100%);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
textarea {
  font: inherit;
}

a {
  color: var(--green-dark);
}

.app-shell {
  width: min(1440px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
  margin-bottom: 14px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  color: var(--ink);
  text-decoration: none;
  min-width: 0;
}

.brand-mark {
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  color: #fff;
  background: linear-gradient(135deg, var(--green), #17211d);
  font-weight: 950;
  box-shadow: 0 12px 26px rgba(15, 122, 79, .18);
}

.brand strong {
  display: block;
  font-size: 18px;
  line-height: 1.1;
  font-weight: 950;
}

.brand small {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.2;
}

.top-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.top-actions a,
.top-actions button,
.ghost-button {
  min-height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: rgba(255, 255, 255, .78);
  color: var(--ink);
  text-decoration: none;
  font-size: 13px;
  font-weight: 850;
  cursor: pointer;
}

.workspace {
  min-height: calc(100dvh - 90px);
  display: grid;
  grid-template-columns: minmax(300px, 410px) minmax(0, 1fr);
  gap: 14px;
}

.side-panel,
.chat-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, .86);
  box-shadow: var(--shadow);
}

.side-panel {
  display: grid;
  align-content: start;
  gap: 12px;
  padding: 18px;
}

.intro-block {
  padding: 10px 0 8px;
}

.intro-block h1 {
  margin: 0;
  max-width: 10em;
  font-size: clamp(30px, 3.8vw, 48px);
  line-height: 1.05;
  font-weight: 950;
}

.intro-block p,
.qr-panel p,
.chat-header p {
  margin: 12px 0 0;
  color: var(--muted);
  line-height: 1.7;
  font-size: 14px;
}

.prompt-panel,
.package-panel,
.consult-panel,
.qr-panel {
  border-top: 1px solid var(--line);
  padding-top: 16px;
}

.prompt-panel h2,
.package-panel h2,
.consult-panel h2,
.qr-panel h2,
.chat-header h2 {
  margin: 0;
  font-size: 16px;
  line-height: 1.2;
  font-weight: 950;
}

.package-panel p,
.consult-panel p {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.6;
}

.quick-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.quick-grid button,
.package-grid button,
.consult-actions a,
.consult-actions button {
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
  text-align: left;
  font-size: 14px;
  font-weight: 850;
  cursor: pointer;
}

.quick-grid button:hover,
.quick-grid button.active,
.package-grid button:hover,
.package-grid button.active,
.consult-actions a:hover,
.consult-actions button:hover {
  border-color: rgba(15, 122, 79, .4);
  background: #edf7f2;
  color: var(--green-dark);
}

.package-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin-top: 12px;
}

.package-grid button {
  min-height: 68px;
  display: grid;
  align-content: center;
  gap: 4px;
}

.package-grid strong,
.package-grid span {
  display: block;
}

.package-grid strong {
  font-size: 14px;
}

.package-grid span {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.consult-actions {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
  margin-top: 12px;
}

.consult-actions a,
.consult-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 40px;
  text-align: center;
  text-decoration: none;
}

.consult-actions a {
  background: var(--green);
  border-color: var(--green);
  color: #fff;
}

.qr-panel {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 112px;
  gap: 14px;
  align-items: center;
}

.qr-panel img {
  display: block;
  width: 112px;
  height: 112px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.chat-panel {
  min-width: 0;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  overflow: hidden;
}

.chat-header {
  min-height: 74px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, .92);
}

.chat-header p {
  margin-top: 5px;
}

.messages {
  min-height: 0;
  overflow: auto;
  padding: 20px 18px;
  background:
    linear-gradient(180deg, rgba(238, 244, 241, .54), rgba(255, 255, 255, .9));
}

.message {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.avatar {
  flex: 0 0 auto;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border-radius: 8px;
  background: var(--graphite);
  color: #fff;
  font-size: 15px;
  font-weight: 950;
}

.bubble {
  max-width: min(820px, 100%);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
  background: #fff;
  box-shadow: 0 10px 24px rgba(17, 25, 23, .05);
}

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

.user-message .bubble {
  max-width: min(680px, 90%);
  border-color: rgba(15, 122, 79, .22);
  background: #e9f6ef;
  color: #0a3f29;
  font-weight: 760;
}

.message-body {
  color: var(--ink);
  font-size: 15px;
  line-height: 1.75;
  white-space: pre-wrap;
}

.message-body a {
  font-weight: 850;
}

.link-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.section-label {
  color: var(--green-dark);
  font-size: 13px;
  font-weight: 950;
}

.link-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  min-height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fbfdfc;
  text-decoration: none;
}

.link-item strong {
  display: block;
  color: var(--ink);
  font-size: 14px;
  line-height: 1.25;
}

.link-item span {
  display: block;
  margin-top: 3px;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.35;
}

.link-item svg {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  fill: var(--green);
}

.image-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 12px;
}

.image-list .section-label {
  grid-column: 1 / -1;
}

.image-card {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #fff;
}

.image-card a {
  display: block;
  color: inherit;
  text-decoration: none;
}

.image-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 5;
  object-fit: cover;
  background: var(--silver);
}

.image-meta {
  padding: 9px;
}

.image-meta strong {
  display: block;
  color: var(--ink);
  font-size: 12px;
  line-height: 1.35;
}

.image-meta span,
.image-meta small {
  display: block;
  margin-top: 5px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.35;
}

.image-meta small {
  color: var(--green-dark);
  font-weight: 850;
}

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

.message-actions button {
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0 10px;
  background: #fff;
  color: var(--ink);
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.message-actions .feedback-button {
  color: var(--muted);
}

.message-actions .feedback-button[data-feedback="needs-human"] {
  color: var(--green-dark);
  border-color: rgba(15, 122, 79, .25);
}

.message-actions .feedback-button[data-feedback="inaccurate"] {
  color: var(--warning);
}

.message-actions .feedback-button.submitted {
  background: #edf7f2;
  color: var(--green-dark);
}

.composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 96px;
  gap: 10px;
  padding: 14px;
  border-top: 1px solid var(--line);
  background: #fff;
}

.composer textarea {
  width: 100%;
  min-height: 54px;
  max-height: 146px;
  resize: vertical;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 13px;
  color: var(--ink);
  background: #fbfdfc;
  outline: none;
  line-height: 1.55;
}

.composer textarea:focus {
  border-color: rgba(15, 122, 79, .45);
  box-shadow: 0 0 0 4px rgba(15, 122, 79, .08);
}

.composer button {
  min-height: 54px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: #fff;
  font-size: 15px;
  font-weight: 950;
  cursor: pointer;
}

.composer button:disabled {
  opacity: .55;
  cursor: not-allowed;
}

.composer svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
}

.typing {
  display: inline-flex;
  gap: 4px;
  align-items: center;
  min-height: 24px;
}

.typing i {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--green);
  animation: bounce 1s infinite ease-in-out;
}

.typing i:nth-child(2) {
  animation-delay: .15s;
}

.typing i:nth-child(3) {
  animation-delay: .3s;
}

@keyframes bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.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) {
  .app-shell {
    padding: 10px;
  }

  .topbar {
    align-items: flex-start;
  }

  .top-actions {
    max-width: 45%;
  }

  .workspace {
    min-height: calc(100dvh - 76px);
    grid-template-columns: 1fr;
  }

  .side-panel {
    box-shadow: none;
  }

  .intro-block h1 {
    max-width: 12em;
    font-size: 30px;
  }

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

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

@media (max-width: 640px) {
  .topbar {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .top-actions {
    max-width: none;
    justify-content: flex-start;
  }

  .top-actions a,
  .top-actions button {
    min-height: 34px;
    font-size: 12px;
  }

  .brand strong {
    font-size: 17px;
  }

  .brand small {
    font-size: 11px;
  }

  .workspace {
    gap: 10px;
  }

  .side-panel {
    padding: 14px;
  }

  .intro-block h1 {
    font-size: 28px;
  }

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

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

  .qr-panel {
    grid-template-columns: 1fr 90px;
  }

  .qr-panel img {
    width: 90px;
    height: 90px;
  }

  .chat-header {
    min-height: 62px;
    padding: 13px;
  }

  .messages {
    padding: 14px 10px;
  }

  .message {
    gap: 8px;
  }

  .avatar {
    width: 30px;
    height: 30px;
    font-size: 13px;
  }

  .bubble {
    padding: 12px;
  }

  .image-list {
    grid-template-columns: 1fr;
  }

  .composer {
    grid-template-columns: 1fr;
    padding: 10px;
  }

  .composer button {
    min-height: 46px;
  }
}

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