:root {
  --bg: #f5efe3;
  --bg-strong: #ebe2d2;
  --surface: rgba(255, 252, 246, 0.9);
  --surface-strong: #fffdf9;
  --ink: #173425;
  --ink-soft: #4e6156;
  --accent: #2f6b4d;
  --accent-strong: #1f4e36;
  --accent-wash: rgba(47, 107, 77, 0.12);
  --user-bubble: linear-gradient(135deg, #2c6b4c, #1c4b34);
  --border: rgba(23, 52, 37, 0.12);
  --shadow: 0 24px 48px rgba(68, 54, 28, 0.12);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --radius-sm: 12px;
  --font-body: "Avenir Next", "PingFang SC", "Hiragino Sans GB", "Noto Sans CJK SC", sans-serif;
  --font-display: "Iowan Old Style", "Palatino Linotype", "Songti SC", serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font-body);
}

body {
  position: relative;
  overflow-x: hidden;
  overflow-y: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-frame {
  position: relative;
  height: 100svh;
  max-width: 480px;
  margin: 0 auto;
  padding: calc(env(safe-area-inset-top) + 8px) 14px calc(env(safe-area-inset-bottom) + 10px);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 0;
  overflow: hidden;
}

.ambient {
  position: fixed;
  inset: auto;
  width: 46vw;
  height: 46vw;
  border-radius: 999px;
  filter: blur(44px);
  pointer-events: none;
  opacity: 0.45;
  z-index: 0;
}

.ambient-left {
  top: -10vw;
  left: -8vw;
  background: rgba(136, 175, 102, 0.24);
}

.ambient-right {
  right: -12vw;
  bottom: 18vh;
  background: rgba(228, 179, 80, 0.18);
}

.topbar,
.chat-shell,
.composer-shell {
  position: relative;
  z-index: 1;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 12px 2px 10px;
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand-mark {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  border-radius: 14px;
  background: linear-gradient(135deg, #244f38, #5a8c6c);
  color: #f7f4ef;
  font-weight: 700;
  letter-spacing: 0.08em;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.24);
}

.eyebrow {
  margin: 0 0 2px;
  color: var(--ink-soft);
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.topbar h1,
.welcome-card h2,
.settings-panel h2,
.sheet-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: -0.02em;
}

.topbar h1 {
  font-size: 20px;
  line-height: 1.05;
}

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

.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 999px;
  background: rgba(255, 253, 249, 0.74);
  border: 1px solid var(--border);
  color: var(--ink-soft);
  font-size: 12px;
  backdrop-filter: blur(16px);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: #b9912d;
  box-shadow: 0 0 0 6px rgba(185, 145, 45, 0.1);
}

.status-pill.online .status-dot {
  background: #2f8a58;
  box-shadow: 0 0 0 6px rgba(47, 138, 88, 0.12);
}

.status-pill.error .status-dot {
  background: #b55347;
  box-shadow: 0 0 0 6px rgba(181, 83, 71, 0.12);
}

.icon-button,
.close-button {
  border: 0;
  background: rgba(255, 253, 249, 0.9);
  color: var(--accent-strong);
  border-radius: 14px;
  padding: 11px 14px;
  border: 1px solid var(--border);
  box-shadow: 0 8px 20px rgba(44, 37, 24, 0.08);
}

.chat-shell {
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding-bottom: 8px;
  -webkit-overflow-scrolling: touch;
}

.chat-log {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 8px 0 18px;
  min-height: 100%;
}

.message {
  max-width: 88%;
  animation: rise-in 340ms cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

.message.assistant {
  align-self: flex-start;
}

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

.bubble {
  padding: 14px 16px;
  border-radius: 20px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  line-height: 1.58;
  white-space: pre-wrap;
  word-break: break-word;
}

.assistant .bubble {
  background: var(--surface);
  backdrop-filter: blur(18px);
}

.user .bubble {
  background: var(--user-bubble);
  color: #f6f3ec;
  border-color: rgba(255, 255, 255, 0.08);
}

.message-meta {
  margin-top: 6px;
  padding: 0 8px;
  color: rgba(78, 97, 86, 0.75);
  font-size: 12px;
  line-height: 1.45;
}

.typing-indicator {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0 0 16px;
  padding: 12px 16px;
  border-radius: 999px;
  background: rgba(255, 252, 246, 0.74);
  border: 1px solid var(--border);
  width: fit-content;
  backdrop-filter: blur(16px);
}

.typing-indicator span {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--accent);
  animation: typing 1.2s infinite ease-in-out;
}

.typing-indicator span:nth-child(2) {
  animation-delay: 0.16s;
}

.typing-indicator span:nth-child(3) {
  animation-delay: 0.32s;
}

.hidden {
  display: none !important;
}

.composer-shell {
  padding: 8px 0 12px;
  background:
    linear-gradient(180deg, rgba(245, 239, 227, 0), rgba(245, 239, 227, 0.78) 24%, rgba(245, 239, 227, 1) 100%);
}

.composer-card {
  min-height: 74px;
  padding: 14px;
  border-radius: 24px;
  background: rgba(255, 252, 246, 0.9);
  border: 1px solid rgba(23, 52, 37, 0.1);
  box-shadow: 0 18px 40px rgba(68, 54, 28, 0.14);
  backdrop-filter: blur(22px);
}

.composer-card.sheet-mode {
  max-height: min(52svh, 460px);
  overflow-y: auto;
  overflow-x: hidden;
  background: rgba(255, 252, 246, 0.78);
  border-color: rgba(23, 52, 37, 0.12);
  box-shadow: 0 24px 46px rgba(68, 54, 28, 0.16);
  -webkit-overflow-scrolling: touch;
}

.composer-card.compact-mode {
  padding: 12px;
}

.composer-grid,
.text-composer,
.inline-form,
.range-composer,
.choice-sheet {
  display: grid;
  gap: 12px;
}

.choice-sheet {
  height: 100%;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  min-height: min-content;
  padding-bottom: 8px;
}

.range-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.range-label {
  color: var(--ink-soft);
  font-size: 13px;
  font-weight: 600;
}

.range-value {
  color: var(--accent-strong);
  font-family: var(--font-display);
  font-size: 28px;
  line-height: 1;
}

.range-input {
  width: 100%;
  accent-color: var(--accent);
}

.range-scale {
  display: flex;
  justify-content: space-between;
  color: var(--ink-soft);
  font-size: 12px;
}

.range-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.range-back {
  flex: 0 0 auto;
  min-width: 96px;
}

.range-adjuster {
  display: inline-grid;
  grid-template-columns: repeat(2, minmax(0, 72px));
  gap: 8px;
  margin-left: auto;
}

.range-step {
  min-height: 46px;
  border-radius: 14px;
  background: rgba(47, 107, 77, 0.08);
  color: var(--accent-strong);
}

.composer-helper {
  margin: -4px 0 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.55;
}

.input,
.field input,
.field select,
.inline-form input,
.inline-form select,
.inline-form textarea {
  width: 100%;
  border: 1px solid rgba(23, 52, 37, 0.12);
  background: #fffdf9;
  border-radius: 16px;
  padding: 14px 16px;
  color: var(--ink);
  outline: none;
  transition: border-color 180ms ease, transform 180ms ease;
}

.input:focus,
.field input:focus,
.field select:focus,
.inline-form input:focus,
.inline-form select:focus,
.inline-form textarea:focus {
  border-color: rgba(47, 107, 77, 0.45);
  transform: translateY(-1px);
}

.inline-form textarea {
  min-height: 96px;
  resize: vertical;
}

.field {
  display: grid;
  gap: 8px;
  color: var(--ink-soft);
  font-size: 14px;
}

.field span {
  color: var(--ink);
  font-size: 13px;
  font-weight: 600;
}

.inline-double {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.sheet-header {
  display: grid;
  gap: 6px;
}

.sheet-header h3 {
  font-size: 21px;
  line-height: 1.15;
}

.sheet-subtitle,
.choice-hint {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.5;
}

.choice-panel {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  min-height: 0;
  overflow: auto;
  padding-right: 2px;
  padding-bottom: 10px;
}

.choice-chip {
  display: grid;
  grid-template-columns: 36px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  border: 1px solid rgba(23, 52, 37, 0.12);
  background: rgba(255, 251, 244, 0.82);
  border-radius: 16px;
  padding: 12px;
  text-align: left;
  color: var(--ink);
  transition: transform 180ms ease, border-color 180ms ease, background 180ms ease;
}

.choice-index {
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border-radius: 12px;
  background: rgba(47, 107, 77, 0.08);
  color: var(--accent-strong);
  font-weight: 700;
}

.choice-copy {
  min-width: 0;
}

.choice-chip strong {
  display: block;
  margin: 0;
  line-height: 1.45;
  color: var(--accent-strong);
  font-size: 15px;
}

.choice-chip small {
  display: block;
  margin-top: 6px;
  color: var(--ink-soft);
  line-height: 1.45;
  font-size: 12px;
}

.choice-chip.selected {
  background: rgba(47, 107, 77, 0.16);
  border-color: rgba(47, 107, 77, 0.42);
  transform: translateY(-1px);
}

.choice-chip.selected .choice-index {
  background: rgba(47, 107, 77, 0.18);
}

.composer-action-stack {
  display: grid;
  gap: 10px;
}

.choice-actions,
.settings-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: stretch;
}

.choice-actions {
  position: sticky;
  bottom: 0;
  padding-top: 10px;
  padding-bottom: calc(6px + env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(255, 252, 246, 0), rgba(255, 252, 246, 0.92) 24%, rgba(255, 252, 246, 1) 100%);
}

.choice-actions.primary-row > .primary-button {
  flex: 1 1 100%;
}

.choice-actions.secondary-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.choice-actions.secondary-row > * {
  min-width: 0;
}

.primary-button,
.secondary-button,
.ghost-button,
.danger-button {
  border: 0;
  border-radius: 16px;
  padding: 14px 16px;
  min-height: 50px;
  flex: 1 1 0;
  white-space: normal;
}

.primary-button {
  background: linear-gradient(135deg, #2b6b4c, #1d4f37);
  color: #f8f4ee;
  box-shadow: 0 16px 30px rgba(31, 78, 54, 0.22);
}

.secondary-button {
  background: rgba(47, 107, 77, 0.1);
  color: var(--accent-strong);
}

.ghost-button {
  background: transparent;
  color: var(--ink-soft);
}

.danger-button {
  background: rgba(181, 83, 71, 0.12);
  color: #9f4438;
}

.welcome-card,
.report-card {
  border-radius: var(--radius-xl);
  padding: 20px;
  background:
    linear-gradient(180deg, rgba(255, 253, 249, 0.96), rgba(250, 244, 234, 0.92));
  border: 1px solid rgba(23, 52, 37, 0.08);
  box-shadow: 0 26px 46px rgba(68, 54, 28, 0.12);
}

.welcome-card p {
  color: var(--ink-soft);
  line-height: 1.7;
}

.report-card {
  display: grid;
  gap: 18px;
}

.report-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.report-header h3 {
  margin: 0;
  font-family: var(--font-display);
  font-size: 24px;
}

.report-stamp {
  white-space: nowrap;
  font-size: 12px;
  color: var(--ink-soft);
}

.report-section {
  display: grid;
  gap: 10px;
}

.report-section h4 {
  margin: 0;
  color: var(--accent-strong);
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.report-section p,
.report-section li {
  margin: 0;
  line-height: 1.65;
  color: var(--ink);
}

.report-section ul {
  padding-left: 18px;
  margin: 0;
  display: grid;
  gap: 8px;
}

.report-cta {
  display: grid;
  gap: 10px;
  padding-top: 10px;
  border-top: 1px dashed rgba(23, 52, 37, 0.16);
}

.report-products {
  gap: 14px;
}

.report-product-group {
  display: grid;
  gap: 10px;
}

.report-product-group-title {
  margin: 0;
  color: var(--accent-strong);
  font-size: 24px;
  font-family: var(--font-display);
  font-weight: 600;
}

.report-product-card {
  display: grid;
  gap: 8px;
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 253, 249, 0.72);
  border: 1px solid rgba(23, 52, 37, 0.1);
}

.report-product-name {
  margin: 0;
  color: var(--accent-strong);
  font-size: 18px;
  line-height: 1.35;
}

.report-product-detail {
  margin: 0;
  line-height: 1.7;
}

.report-product-detail strong {
  color: var(--accent-strong);
}

.report-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  border-radius: 16px;
  background: linear-gradient(135deg, #2b6b4c, #1d4f37);
  color: #f8f4ee;
  text-decoration: none;
  font-weight: 600;
}

.settings-dialog {
  width: min(92vw, 420px);
  border: 0;
  padding: 0;
  border-radius: 28px;
  background: transparent;
}

.settings-dialog::backdrop {
  background: rgba(23, 20, 13, 0.32);
  backdrop-filter: blur(12px);
}

.settings-panel {
  display: grid;
  gap: 18px;
  padding: 24px;
  border-radius: 28px;
  background: rgba(255, 252, 246, 0.96);
  box-shadow: 0 32px 60px rgba(68, 54, 28, 0.2);
}

.settings-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.settings-note,
.danger-zone p {
  margin: 0;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.65;
}

.danger-zone {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

hr {
  width: 100%;
  border: 0;
  border-top: 1px solid rgba(23, 52, 37, 0.08);
}

@keyframes rise-in {
  from {
    opacity: 0;
    transform: translateY(14px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes typing {
  0%,
  80%,
  100% {
    transform: translateY(0);
    opacity: 0.35;
  }

  40% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

@media (max-width: 480px) {
  .brand-lockup {
    align-items: flex-start;
  }

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

  .topbar h1 {
    font-size: 18px;
  }

  .topbar-actions {
    gap: 8px;
  }

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

  .message {
    max-width: 92%;
  }

  .bubble {
    font-size: 15px;
  }

  .composer-card.sheet-mode {
    max-height: min(58svh, 520px);
  }

  .choice-panel {
    min-height: 0;
  }

  .range-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .range-back {
    width: 100%;
    min-width: 0;
  }

  .range-adjuster {
    width: 100%;
    margin-left: 0;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .choice-chip {
    grid-template-columns: 32px minmax(0, 1fr);
    padding: 11px;
  }

  .choice-index {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    font-size: 13px;
  }

  .choice-chip strong {
    font-size: 14px;
  }

  .report-card {
    padding: 18px;
  }
}

@media (max-width: 380px) {
  .choice-panel,
  .inline-double {
    grid-template-columns: 1fr;
  }

  .topbar,
  .danger-zone {
    flex-direction: column;
    align-items: stretch;
  }

  .topbar-actions {
    width: 100%;
    justify-content: space-between;
  }

  .message {
    max-width: 94%;
  }

  .choice-actions.secondary-row {
    grid-template-columns: 1fr;
  }
}
