:root {
  --green: #7a9c59;
  --green-dark: #55713c;
  --ink: #1c2119;
  --muted: #667065;
  --line: #dfe7da;
  --soft: #f5f8f1;
  --paper: #ffffff;
  --danger: #a33d3d;
  --shadow: 0 10px 30px rgba(25, 35, 20, 0.08);
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
}

body {
  margin: 0;
  background: #eef1ea;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  overflow: hidden;
}

button,
input {
  font: inherit;
}

.app-shell {
  display: grid;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
  max-width: 448px;
  margin: 0 auto;
  background: var(--paper);
  box-shadow: var(--shadow);
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 62px;
  padding: 12px 16px 10px;
  border-bottom: 1px solid #f0f1ed;
  background: #ffffff;
}

.brand-row {
  display: flex;
  min-width: 0;
  align-items: center;
  gap: 10px;
}

.brand-logo {
  display: block;
  width: 112px;
  height: auto;
}

.brand-badge {
  border-radius: 999px;
  background: #edf3e7;
  color: #4f6a37;
  padding: 5px 8px;
  font-size: 12px;
  font-weight: 750;
}

.main {
  min-height: 0;
  overflow: hidden;
}

.panel,
.chat-view,
.plan-view {
  height: 100%;
  overflow: auto;
  padding: 18px 16px calc(92px + env(safe-area-inset-bottom));
}

.home-view {
  background:
    linear-gradient(180deg, #ffffff 0%, #f6f8f2 100%);
}

.panel h1,
.plan-view h1 {
  margin: 6px 0 14px;
  font-size: 25px;
  line-height: 1.12;
}

.lead {
  margin: 0 0 18px;
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}

.feature-list {
  display: grid;
  gap: 10px;
  margin: 18px 0 20px;
}

.feature-list div {
  display: grid;
  grid-template-columns: 34px 1fr;
  gap: 10px;
  align-items: center;
  padding: 12px;
  border: 1px solid #e3e8dc;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
}

.feature-list strong {
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border-radius: 999px;
  background: var(--green);
  color: white;
}

.feature-list span {
  color: var(--ink);
  font-size: 14px;
  line-height: 1.35;
}

.wide {
  width: 100%;
}

.panel h2 {
  margin: 0 0 8px;
  font-size: 17px;
}

.eyebrow {
  color: var(--green-dark);
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
}

.hidden {
  display: none !important;
}

.answer-grid {
  display: grid;
  gap: 12px;
}

.answer-grid button,
.primary-button,
.secondary-button,
.icon-button {
  min-height: 44px;
  border: 0;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease, color 120ms ease;
}

.answer-grid button:active,
.primary-button:active,
.secondary-button:active,
.icon-button:active,
.bottom-nav button:active {
  transform: translateY(1px);
}

.answer-grid button {
  min-height: 58px;
  padding: 15px 16px;
  border: 1px solid #e4e7df;
  background: white;
  color: var(--ink);
  text-align: left;
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 1px 5px rgba(25, 35, 20, 0.04);
}

.primary-button {
  padding: 0 16px;
  background: var(--green);
  color: white;
  font-weight: 750;
}

.primary-button:disabled,
.secondary-button:disabled,
button:disabled {
  opacity: 0.58;
  cursor: default;
}

.secondary-button,
.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  border: 1px solid var(--line);
  background: white;
  color: var(--ink);
  text-decoration: none;
  font-weight: 700;
}

.secondary-button.small {
  min-height: 36px;
  font-size: 13px;
}

.progress {
  height: 6px;
  margin-top: 18px;
  overflow: hidden;
  border-radius: 999px;
  background: #e6eddf;
}

.question-progress {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.progress span {
  display: block;
  height: 100%;
  width: 0;
  background: var(--green);
}

.chat-view {
  display: grid;
  grid-template-areas:
    "chat-header"
    "chat-context"
    "chat-messages"
    "chat-form";
  grid-template-rows: auto auto minmax(0, 1fr) auto;
  padding: 0;
}

.chat-header {
  grid-area: chat-header;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  border-bottom: 1px solid #f0f1ed;
  background: white;
}

.chat-heading {
  min-width: 0;
}

.chat-heading h1 {
  margin: 2px 0 0;
  font-size: 18px;
  line-height: 1.15;
}

.context-box {
  grid-area: chat-context;
  padding: 10px 12px;
  background: var(--soft);
  color: var(--muted);
  font-size: 13px;
  line-height: 1.4;
}

.messages {
  grid-area: chat-messages;
  min-height: 0;
  overflow: auto;
  padding: 14px 14px 18px;
  background: #fbfcf8;
}

.empty-chat,
.empty-plan {
  border: 1px dashed #cad7bf;
  border-radius: 8px;
  background: #ffffff;
  color: var(--muted);
  padding: 16px;
  line-height: 1.42;
}

.empty-chat {
  margin-top: 8px;
}

.empty-chat-title {
  margin-bottom: 5px;
  color: var(--ink);
  font-size: 17px;
  font-weight: 800;
}

.empty-chat p,
.empty-plan p {
  margin: 0;
}

.message {
  max-width: 92%;
  margin: 0 0 12px;
  padding: 12px 13px;
  border-radius: 12px;
  line-height: 1.42;
}

.message p,
.message ul {
  margin: 0 0 8px;
}

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

.message ul {
  padding-left: 18px;
}

.message li + li {
  margin-top: 4px;
}

.message.user {
  margin-left: auto;
  background: var(--green);
  color: white;
}

.message.assistant {
  background: #ffffff;
  border: 1px solid #e7ebe1;
}

.message.loading {
  color: var(--muted);
}

.tool-row {
  margin: -4px 0 10px;
  color: var(--muted);
  font-size: 12px;
}

.product-list,
.plan-items,
.visual-jobs {
  display: grid;
  gap: 10px;
}

.plan-search-panel {
  display: grid;
  gap: 10px;
  margin-bottom: 12px;
}

.plan-search-panel h2 {
  margin-bottom: 0;
}

.plan-search-control {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 44px;
  gap: 8px;
  align-items: center;
}

.plan-search-control input {
  min-width: 0;
  height: 46px;
  border: 1px solid #dce7d3;
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--ink);
  padding: 0 12px;
}

.plan-search-control input:focus {
  border-color: var(--green);
  outline: 2px solid rgba(122, 156, 89, 0.18);
}

.plan-search-control .icon-button {
  min-height: 46px;
  padding: 0;
  font-size: 22px;
}

.plan-search-results {
  display: grid;
  gap: 8px;
}

.plan-search-result {
  display: grid;
  grid-template-columns: 54px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 70px;
  border: 1px solid #e3e8dc;
  border-radius: 8px;
  background: #ffffff;
  color: var(--ink);
  padding: 8px;
  text-align: left;
  cursor: pointer;
}

.plan-search-result:disabled {
  background: #f5f8f1;
  color: var(--muted);
  cursor: default;
  opacity: 1;
}

.plan-search-thumb {
  overflow: hidden;
  width: 54px;
  height: 54px;
  border: 1px solid #dfe8d7;
  border-radius: 8px;
  background: #eef4e7;
}

.plan-search-thumb img,
.plan-search-thumb span {
  display: block;
  width: 100%;
  height: 100%;
}

.plan-search-thumb img {
  object-fit: cover;
}

.plan-search-thumb span {
  display: grid;
  place-items: center;
  color: #5e7448;
  font-size: 22px;
  font-weight: 850;
}

.plan-search-info {
  min-width: 0;
}

.plan-search-info div {
  overflow: hidden;
  color: var(--ink);
  font-size: 14px;
  font-weight: 750;
  line-height: 1.25;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.plan-search-info span,
.plan-search-state {
  color: var(--muted);
  font-size: 12px;
  line-height: 1.3;
}

.plan-search-action {
  justify-self: end;
  border-radius: 999px;
  background: var(--green);
  color: #ffffff;
  padding: 7px 9px;
  font-size: 12px;
  font-weight: 850;
  white-space: nowrap;
}

.plan-search-result:disabled .plan-search-action {
  background: #e1ebd8;
  color: var(--green-dark);
}

.plan-search-state {
  border: 1px dashed #cad7bf;
  border-radius: 8px;
  background: #ffffff;
  padding: 11px 12px;
}

.product-card,
.plan-card,
.visual-card,
.history-card,
.panel.soft {
  height: auto;
  overflow: visible;
  padding: 13px;
  border: 1px solid #e3e8dc;
  border-radius: 8px;
  background: white;
  box-shadow: 0 4px 16px rgba(25, 35, 20, 0.05);
}

.product-card.in-plan {
  border-color: #bfd1b1;
  background: #fbfdf8;
}

.product-card button:disabled {
  border-color: #cbd9c0;
  background: #edf3e7;
  color: var(--green-dark);
  cursor: default;
}

.product-card,
.plan-card {
  display: grid;
  grid-template-columns: 96px minmax(0, 1fr);
  gap: 12px;
  align-items: start;
}

.product-card-body,
.plan-card-body {
  min-width: 0;
}

.product-image-frame {
  position: relative;
  overflow: hidden;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid #e0e8d8;
  border-radius: 8px;
  background: #eef4e7;
}

.plan-image-frame {
  aspect-ratio: 1 / 1;
}

.product-image,
.product-image-placeholder {
  display: block;
  width: 100%;
  height: 100%;
}

.product-image {
  object-fit: cover;
}

.product-image-placeholder {
  display: grid;
  place-items: center;
  color: #5e7448;
  font-size: 28px;
  font-weight: 850;
}

.visual-preview {
  display: block;
  width: 100%;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft);
  aspect-ratio: 900 / 640;
  object-fit: cover;
}

.visual-revision {
  display: grid;
  gap: 7px;
  margin: 10px 0 12px;
}

.visual-revision label {
  color: var(--ink);
  font-size: 13px;
  font-weight: 800;
}

.visual-revision textarea {
  width: 100%;
  min-height: 86px;
  resize: vertical;
  border: 1px solid #dce7d3;
  border-radius: 8px;
  background: #fbfcf8;
  color: var(--ink);
  font: inherit;
  padding: 10px 11px;
}

.visual-revision textarea:focus {
  border-color: var(--green);
  outline: 2px solid rgba(122, 156, 89, 0.18);
}

.project-visual-list {
  display: grid;
  gap: 10px;
  margin: 8px 0 14px;
}

.project-visual {
  display: block;
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #f8faf5;
}

.error-text {
  margin: 8px 0 0;
  color: #9f2d2d;
  font-size: 13px;
  line-height: 1.35;
}

.product-card h3,
.plan-card h3 {
  margin: 0 0 4px;
  font-size: 16px;
  line-height: 1.2;
}

.sku-pill {
  display: inline-flex;
  align-items: center;
  min-height: 22px;
  margin-bottom: 6px;
  padding: 0 7px;
  border-radius: 999px;
  background: #edf3e7;
  color: #4f6a37;
  font-size: 11px;
  font-weight: 850;
  letter-spacing: 0;
}

.meta {
  color: var(--muted);
  font-size: 13px;
}

.latin {
  margin: -1px 0 5px;
  color: #71786f;
  font-size: 13px;
  font-style: italic;
}

.price {
  margin-top: 8px;
  color: var(--green-dark);
  font-weight: 800;
}

.product-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-top: 8px;
}

.product-card-footer .price {
  margin: 0;
}

.reason {
  margin: 8px 0 10px;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.danger-soft {
  color: var(--danger);
}

.quantity-control {
  display: inline-grid;
  grid-template-columns: 38px 54px 38px;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
}

.quantity-button,
.quantity-input {
  height: 38px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  color: var(--ink);
  text-align: center;
  font-weight: 800;
}

.quantity-button {
  cursor: pointer;
}

.quantity-input {
  width: 54px;
  padding: 0 4px;
}

.history-list {
  display: grid;
  gap: 10px;
}

.history-card p {
  margin: 6px 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.history-card button {
  margin-top: 10px;
}

.history-title {
  color: var(--ink);
  font-weight: 800;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: end center;
  padding: 18px 12px calc(18px + env(safe-area-inset-bottom));
  background: rgba(20, 28, 17, 0.42);
}

.modal-panel {
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  width: min(100%, 620px);
  max-height: min(82vh, 760px);
  overflow: hidden;
  border: 1px solid #dce7d3;
  border-radius: 8px;
  background: #ffffff;
  box-shadow: 0 24px 60px rgba(20, 28, 17, 0.22);
}

.modal-header {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 16px 12px;
  border-bottom: 1px solid #edf1e8;
}

.modal-header h2 {
  margin: 2px 0 0;
  font-size: 20px;
  line-height: 1.12;
}

.modal-header .icon-button {
  width: 42px;
  min-width: 42px;
  padding: 0;
  font-size: 24px;
  line-height: 1;
}

.modal-body {
  overflow: auto;
  padding: 14px 16px 18px;
}

.modal-body > p {
  margin: 0 0 8px;
  color: var(--ink);
  line-height: 1.45;
}

.modal-body strong {
  display: block;
  margin: 16px 0 8px;
}

.history-item-list {
  display: grid;
  gap: 10px;
}

.history-item {
  display: grid;
  grid-template-columns: 74px minmax(0, 1fr);
  gap: 10px;
  align-items: start;
  padding: 10px;
  border: 1px solid #e7ebe1;
  border-radius: 8px;
  background: #fbfcf8;
}

.history-item h3 {
  margin: 0 0 5px;
  font-size: 15px;
  line-height: 1.2;
}

.history-image-frame {
  aspect-ratio: 1 / 1;
}

.chat-form {
  grid-area: chat-form;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
  border-top: 1px solid #f0f1ed;
  background: white;
}

.chat-form input {
  min-width: 0;
  height: 44px;
  padding: 0 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.primary-button.send {
  height: 44px;
  min-height: 44px;
}

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

.button-row {
  justify-content: flex-start;
  flex-wrap: wrap;
}

.plan-view {
  display: grid;
  align-content: start;
  gap: 12px;
  background: #fbfcf8;
}

.yard-panel {
  display: grid;
  grid-template-columns: 1fr;
  align-items: start;
  gap: 10px;
}

.yard-panel h2 {
  margin: 0 0 5px;
}

.file-input {
  display: none;
}

.upload-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-height: 42px;
  padding: 0 14px;
  border: 0;
  border-radius: 8px;
  background: var(--green);
  color: white;
  cursor: pointer;
  font-weight: 800;
  white-space: nowrap;
}

.yard-preview {
  overflow: hidden;
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid #dce7d3;
  border-radius: 8px;
  background: #edf3e7;
}

.yard-preview img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.bottom-nav {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  border-top: 1px solid #f0f1ed;
  background: white;
  padding: 10px 10px calc(10px + env(safe-area-inset-bottom));
}

.bottom-nav button {
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: #f3f4f1;
  color: #8a9087;
  font-weight: 750;
}

.bottom-nav button.active {
  background: #1f241c;
  color: white;
  box-shadow: none;
}

@media (min-width: 449px) {
  .app-shell {
    height: calc(100vh - 24px);
    margin-top: 12px;
    border: 1px solid #e4e7df;
    border-radius: 12px;
    overflow: hidden;
  }
}

@media (max-width: 380px) {
  .product-card,
  .plan-card {
    grid-template-columns: 82px minmax(0, 1fr);
    gap: 10px;
  }

  .brand-logo {
    width: 96px;
  }

}
