/* Base */
:root {
  --bg: #f9f3ea;
  --panel: #fffdf9;
  --paper: #ffffff;
  --accent: #8b7355;
  --accent-dark: #6c5841;
  --text: #3f3127;
  --muted: #7a6a5f;
  --line: #e7dfd3;
  --gold: #d07a00;
  --shadow: 0 16px 40px rgba(96, 72, 45, 0.12);
}
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: "Noto Sans TC", "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background-color: #fbf5ed;
  background-image:
    linear-gradient(rgba(255, 252, 248, 0.76), rgba(255, 252, 248, 0.76)),
    url("capybara-bg.svg");
  background-repeat: repeat;
  background-size: auto, 180px 180px;
}

a { color: inherit; text-decoration: none; }

.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 28px;
  backdrop-filter: blur(10px);
  background: rgba(249, 243, 234, 0.78);
  border-bottom: 1px solid rgba(139,115,85,.12);
}
.logo {
  font-size: 22px;
  font-weight: 900;
  letter-spacing: .04em;
}
.nav { display: flex; gap: 18px; color: var(--muted); }
.nav a:hover { color: var(--text); }
.nav-cta, .btn, .tool-btn, .contact-card, .floating-btn {
  transition: .2s ease;
}
.nav-cta, .btn.primary, .btn.pay, .tool-btn, .contact-card, .floating-btn {
  background: var(--accent);
  color: white;
  border-radius: 999px;
  padding: 12px 18px;
  font-weight: 700;
  border: 0;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 16px rgba(139,115,85,.18);
}
.nav-cta:hover, .btn.primary:hover, .btn.pay:hover, .tool-btn:hover, .contact-card:hover, .floating-btn:hover { transform: translateY(-2px); background: var(--accent-dark); }
.btn.ghost { border: 1px solid var(--line); background: rgba(255,255,255,.7); color: var(--text); }
.btn.ghost:hover { background: white; }
.btn.pay {
  background: #0f766e;
  border: 0;
  min-height: 46px;
}
.btn.pay:disabled {
  cursor: not-allowed;
  opacity: .62;
  transform: none;
  background: #8a9a96;
}

main { max-width: 1240px; margin: 0 auto; padding: 30px 22px 80px; }
.section { margin-top: 28px; }
.section-head { margin-bottom: 18px; }
.section-head h2 { margin: 0 0 8px; font-size: 32px; }
.section-head p { margin: 0; color: var(--muted); }

.hero {
  display: grid;
  grid-template-columns: 1.4fr .8fr;
  gap: 24px;
  align-items: stretch;
  margin-top: 18px;
}
.hero-copy, .hero-card, .card, .estimate-shell {
  background: rgba(255,255,255,.82);
  border: 1px solid rgba(139,115,85,.12);
  border-radius: 24px;
  box-shadow: var(--shadow);
}
.hero-copy { padding: 38px; }
.hero-copy h1 { font-size: clamp(38px, 6vw, 70px); line-height: 1.02; margin: 14px 0; }
.hero-copy p { color: var(--muted); font-size: 18px; max-width: 58ch; }
.badge {
  display: inline-flex; padding: 8px 14px; border-radius: 999px; background: #f1e4d2; color: var(--accent-dark); font-weight: 800;
}
.hero-actions { display: flex; gap: 14px; margin-top: 22px; flex-wrap: wrap; }
.btn { padding: 12px 18px; border-radius: 999px; font-weight: 800; }
.hero-card { padding: 28px; display: flex; flex-direction: column; justify-content: center; }
.hero-card-title { font-size: 20px; font-weight: 900; margin-bottom: 12px; }
.hero-card ul { margin: 0; padding-left: 18px; color: var(--muted); line-height: 1.9; }

.grid { display: grid; gap: 18px; }
.grid.four { grid-template-columns: repeat(4, 1fr); }
.card { padding: 22px; }
.card h3, .card h2 { margin-top: 0; }
.card.large { min-height: 180px; }
.about-grid, .contact-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 18px; }

.estimate-shell { padding: 22px; }
.estimate-toolbar { display: flex; justify-content: flex-end; gap: 12px; flex-wrap: wrap; margin-bottom: 18px; }
.tool-btn { padding: 10px 16px; }
.tool-btn.secondary { background: #b49c83; }
.tool-btn.secondary:hover { background: #8d7459; }
.table-wrap { overflow-x: auto; border-radius: 18px; border: 1px solid var(--line); background: var(--paper); }
.estimate-table { width: 100%; border-collapse: collapse; table-layout: fixed; min-width: 0; }
.estimate-table th:nth-child(1), .estimate-table td:nth-child(1) { width: 118px; }
.estimate-table th:nth-child(3), .estimate-table td:nth-child(3) { width: 74px; }
.estimate-table th:nth-child(4), .estimate-table td:nth-child(4) { width: 112px; }
.estimate-table thead th {
  background: var(--accent);
  color: #fff;
  text-align: left;
  padding: 14px 16px;
  font-size: 15px;
}
.estimate-table tbody td {
  border-bottom: 1px solid #f0e7db;
  padding: 12px 14px;
  vertical-align: middle;
}
.estimate-table tbody tr:nth-child(odd) { background: #fffdfa; }
.category-cell { font-weight: 800; color: var(--accent-dark); white-space: normal; }
.prod-select, .qty-select {
  width: 100%;
  min-width: 0;
  border: 1px solid #d8cbbd;
  border-radius: 10px;
  background: #fff;
  padding: 10px 12px;
  font-size: 14px;
  color: var(--text);
}
.qty-select { max-width: 92px; }
.price-cell { text-align: right; color: var(--gold); font-weight: 900; font-size: 16px; white-space: nowrap; }
.shipping-control,
.service-control {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
  font-weight: 800;
}
.shipping-control input,
.service-control select {
  width: 76px;
  border: 1px solid #d8cbbd;
  border-radius: 10px;
  padding: 10px 12px;
  color: var(--text);
  font: inherit;
  font-weight: 800;
}
.service-control select { width: 178px; }
.service-control select:disabled {
  background: #f3ede5;
  color: #9b8978;
}
.summary-row {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  margin-top: 18px;
}
.total-box {
  display: flex; align-items: baseline; gap: 14px; padding: 16px 18px; background: #fff4e4; border-radius: 18px;
}
.total-box span { color: var(--muted); font-weight: 700; }
.total-box strong { color: var(--gold); font-size: 30px; }
.summary-actions { display: flex; gap: 12px; }
.payment-box {
  margin-top: 14px;
  padding: 14px 16px;
  border: 1px solid #d7c6ad;
  border-radius: 14px;
  background: #fff9ee;
  color: #4a392c;
  line-height: 1.6;
}
.payment-box.error {
  border-color: #d69a9a;
  background: #fff1f1;
  color: #763636;
}
.payment-box.success {
  border-color: #9bc9bf;
  background: #effaf7;
  color: #24564e;
}
.result-box {
  margin-top: 18px;
  padding: 18px;
  background: #f8f0e5;
  color: #4a392c;
  border-left: 5px solid var(--accent);
  border-radius: 14px;
  white-space: pre-wrap;
  line-height: 1.7;
}
.contact-grid { grid-template-columns: repeat(3, 1fr); }
.contact-card { padding: 18px; border-radius: 18px; text-align: center; }

.floating-contact-group {
  position: fixed;
  right: 18px;
  bottom: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 50;
}
.floating-btn { width: 54px; height: 54px; padding: 0; border-radius: 50%; font-size: 14px; }
.floating-btn.line { background: #05c755; }
.floating-btn.ig { background: linear-gradient(45deg, #f09433 0%, #e6683c 25%, #dc2743 50%, #cc2366 75%, #bc1888 100%); }

.ai-chat-widget {
  position: fixed;
  left: 18px;
  bottom: 18px;
  z-index: 55;
}
.ai-chat-toggle {
  border: 0;
  border-radius: 999px;
  padding: 14px 18px;
  background: #0f766e;
  color: #fff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(15, 118, 110, .22);
}
.ai-chat-panel {
  width: min(92vw, 380px);
  margin-bottom: 12px;
  overflow: hidden;
  border: 1px solid #d5c7b5;
  border-radius: 18px;
  background: #fffdf9;
  box-shadow: 0 18px 42px rgba(63, 49, 39, .18);
}
.ai-chat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  background: #0f766e;
  color: #fff;
}
.ai-chat-head strong,
.ai-chat-head span {
  display: block;
}
.ai-chat-head span {
  margin-top: 2px;
  font-size: 12px;
  opacity: .84;
}
.ai-chat-close {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255,255,255,.36);
  border-radius: 50%;
  background: rgba(255,255,255,.12);
  color: #fff;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
}
.ai-chat-messages {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 340px;
  overflow-y: auto;
  padding: 14px;
  background: #fffaf3;
}
.ai-msg {
  max-width: 86%;
  padding: 10px 12px;
  border-radius: 12px;
  line-height: 1.55;
  white-space: pre-wrap;
}
.ai-msg.bot {
  align-self: flex-start;
  background: #f0e7db;
}
.ai-msg.user {
  align-self: flex-end;
  background: #0f766e;
  color: #fff;
}
.ai-chat-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid #eadfce;
}
.ai-chat-form input,
.ai-chat-form button {
  min-height: 42px;
  border-radius: 12px;
  font: inherit;
}
.ai-chat-form input {
  min-width: 0;
  border: 1px solid #d8cbbd;
  padding: 0 12px;
}
.ai-chat-form button {
  border: 0;
  padding: 0 14px;
  background: #8b7355;
  color: #fff;
  font-weight: 900;
  cursor: pointer;
}
.ai-chat-form button:disabled {
  cursor: not-allowed;
  opacity: .6;
}

@media (max-width: 1080px) {
  .hero, .grid.four, .about-grid, .contact-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 780px) {
  .site-header { flex-wrap: wrap; justify-content: center; }
  .nav { order: 3; width: 100%; justify-content: center; flex-wrap: wrap; }
  .hero, .grid.four, .about-grid, .contact-grid { grid-template-columns: 1fr; }
  .hero-copy h1 { font-size: 42px; }
  main { padding-inline: 14px; }
  .estimate-shell { padding: 14px; border-radius: 16px; }
  .estimate-toolbar {
    display: grid;
    grid-template-columns: 1fr;
    justify-content: stretch;
    gap: 10px;
  }
  .tool-btn,
  .service-control,
  .shipping-control,
  .summary-actions,
  .summary-actions .btn {
    width: 100%;
  }
  .service-control,
  .shipping-control {
    justify-content: space-between;
    align-items: stretch;
    flex-direction: column;
    gap: 6px;
  }
  .service-control select,
  .shipping-control input {
    width: 100%;
    min-height: 44px;
  }
  .table-wrap {
    overflow: visible;
    border: 0;
    background: transparent;
  }
  .estimate-table,
  .estimate-table thead,
  .estimate-table tbody,
  .estimate-table tr,
  .estimate-table th,
  .estimate-table td {
    display: block;
    width: 100% !important;
  }
  .estimate-table {
    border-collapse: separate;
    border-spacing: 0 12px;
    table-layout: auto;
  }
  .estimate-table thead { display: none; }
  .estimate-table tbody tr {
    padding: 14px;
    background: var(--paper);
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(96, 72, 45, 0.08);
  }
  .estimate-table tbody tr:nth-child(odd) { background: var(--paper); }
  .estimate-table tbody td {
    border-bottom: 0;
    padding: 0;
  }
  .estimate-table tbody td + td { margin-top: 10px; }
  .category-cell {
    font-size: 17px;
    line-height: 1.35;
  }
  .prod-select,
  .qty-select {
    min-height: 46px;
    font-size: 16px;
  }
  .qty-select { max-width: none; }
  .price-cell {
    text-align: left;
    font-size: 18px;
  }
  .estimate-table tbody td:nth-child(2)::before,
  .estimate-table tbody td:nth-child(3)::before,
  .estimate-table tbody td:nth-child(4)::before {
    display: block;
    margin-bottom: 6px;
    color: var(--muted);
    font-size: 13px;
    font-weight: 800;
  }
  .estimate-table tbody td:nth-child(2)::before { content: "庫存品項"; }
  .estimate-table tbody td:nth-child(3)::before { content: "數量"; }
  .estimate-table tbody td:nth-child(4)::before { content: "小計"; }
  .summary-row { align-items: stretch; }
  .total-box {
    width: 100%;
    justify-content: space-between;
    border-radius: 12px;
  }
  .total-box strong { font-size: 28px; }
  .floating-contact-group {
    right: 12px;
    bottom: 12px;
  }
  .ai-chat-widget {
    left: 12px;
    bottom: 12px;
  }
  .ai-chat-panel {
    width: calc(100vw - 24px);
  }
}
