/* WhatsApp Order Link Maker — ToolNest brand (design-spec tokens).
   Mobile-first, system fonts only, no external requests. */

:root {
  --bg: #F7F5F0;
  --surface: #FFFFFF;
  --surface-muted: #EFF2EE;
  --ink: #17211D;
  --muted: #4E5D55;
  --border: #D8DFD9;
  --primary: #0B6B57;
  --primary-dark: #084E3F;
  --primary-soft: #E2EFEA;
  --accent: #F2A93B;
  --success: #177245;
  --success-bg: #E5F3EA;
  --danger: #B3261E;
  --danger-bg: #FBEAE8;
  --warning: #8A5A00;
  --warning-bg: #FFF3DC;
  --focus: #0B6B57;
  --shadow: 0 1px 2px rgba(23, 33, 29, .06), 0 4px 16px rgba(23, 33, 29, .06);
  --radius-card: 16px;
  --radius-control: 10px;
}

* {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: .95em;
}

/* Header */

.site-header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  max-width: 1080px;
  margin: 0 auto;
  padding: 12px 16px;
}

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

.brand-mark {
  flex: none;
}

.brand-name {
  font-weight: 700;
  letter-spacing: -.01em;
  color: var(--ink);
}

.brand-tool {
  color: var(--muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.help-link {
  color: var(--primary);
  font-weight: 600;
  text-decoration: none;
  padding: 10px 8px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
}

.help-link:hover {
  text-decoration: underline;
}

/* Page layout */

.page {
  max-width: 1080px;
  margin: 0 auto;
  padding: 16px;
}

.intro h1 {
  font-size: 28px;
  line-height: 1.2;
  margin: 8px 0;
}

.intro-sub {
  color: var(--muted);
  margin: 0 0 12px;
  max-width: 62ch;
}

.intro-actions {
  margin: 0 0 4px;
}

.layout {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
  margin-top: 16px;
}

.col {
  display: flex;
  flex-direction: column;
  gap: 16px;
  min-width: 0;
}

@media (min-width: 720px) {
  .page {
    padding: 24px;
  }
  .intro h1 {
    font-size: 32px;
  }
}

@media (min-width: 1024px) {
  .layout {
    grid-template-columns: 1fr 1fr;
    align-items: start;
  }
  .col-side {
    position: sticky;
    top: 16px;
  }
}

/* Cards and steps */

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-card);
  box-shadow: var(--shadow);
  padding: 16px;
  min-width: 0;
}

@media (min-width: 720px) {
  .card {
    padding: 24px;
  }
}

.card h2 {
  font-size: 19px;
  line-height: 1.3;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 10px;
}

.card h3 {
  font-size: 16px;
  line-height: 1.35;
  font-weight: 600;
  margin: 20px 0 8px;
}

.step-chip {
  flex: none;
  width: 28px;
  height: 28px;
  border-radius: 999px;
  background: var(--primary);
  color: #FFFFFF;
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.card-purpose {
  color: var(--muted);
  margin: 0 0 16px;
}

.help-card {
  margin-top: 16px;
}

.site-footer {
  color: var(--muted);
  font-size: 14px;
  padding: 24px 0 8px;
}

/* Privacy line */

.privacy-line {
  display: flex;
  gap: 10px;
  background: var(--primary-soft);
  border-radius: var(--radius-control);
  padding: 12px;
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.45;
}

.privacy-line .icon {
  flex: none;
  color: var(--primary);
  margin-top: 1px;
}

/* Fields */

.field {
  margin: 0 0 16px;
  border: 0;
  padding: 0;
  min-width: 0;
}

.field:last-child {
  margin-bottom: 0;
}

label,
legend {
  display: block;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.4;
  margin: 0 0 6px;
}

.optional {
  color: var(--muted);
  font-weight: 400;
}

input[type="text"],
input[type="tel"],
textarea {
  width: 100%;
  min-height: 48px;
  font: inherit;
  font-size: 16px;
  color: var(--ink);
  background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-control);
  padding: 10px 12px;
}

textarea {
  min-height: 0;
  resize: vertical;
}

input[type="text"]:focus,
input[type="tel"]:focus,
textarea:focus {
  border-color: var(--primary);
  outline: 2px solid var(--focus);
  outline-offset: 1px;
}

input[aria-invalid="true"],
textarea[aria-invalid="true"] {
  border-color: var(--danger);
}

.mono-input {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 14px;
}

.hint {
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
  margin: 6px 0 0;
}

.field-error {
  color: var(--danger);
  font-size: 14px;
  line-height: 1.45;
  margin: 6px 0 0;
  font-weight: 600;
}

.confirm-line {
  color: var(--success);
  font-size: 14px;
  font-weight: 600;
  margin: 6px 0 0;
  overflow-wrap: anywhere;
}

.field-row {
  display: grid;
  grid-template-columns: 1fr;
  gap: 16px;
}

@media (min-width: 720px) {
  .field-row {
    grid-template-columns: 1fr 1fr;
  }
}

/* Checkbox and pills */

.check-label {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  cursor: pointer;
  font-weight: 600;
}

.check-label input[type="checkbox"] {
  width: 22px;
  height: 22px;
  flex: none;
  accent-color: var(--primary);
}

.pill-group {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 8px 14px;
  border: 1.5px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  cursor: pointer;
  font-weight: 600;
  margin: 0;
}

.pill input[type="radio"] {
  width: 20px;
  height: 20px;
  accent-color: var(--primary);
  flex: none;
}

.pill:has(input:checked) {
  background: var(--primary-soft);
  border-color: var(--primary);
}

.pill:has(input:focus-visible) {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

/* Buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  padding: 10px 18px;
  border-radius: var(--radius-control);
  border: 1.5px solid transparent;
  font: inherit;
  font-weight: 600;
  font-size: 16px;
  cursor: pointer;
  text-decoration: none;
  transition: background-color 120ms ease, color 120ms ease;
}

.btn .icon {
  flex: none;
}

.btn-primary {
  background: var(--primary);
  color: #FFFFFF;
}

.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: var(--surface);
  border-color: var(--border);
  color: var(--ink);
}

.btn-secondary:hover {
  background: var(--surface-muted);
}

.btn-danger-quiet {
  background: var(--surface);
  border-color: var(--border);
  color: var(--danger);
}

.btn-danger-quiet:hover {
  background: var(--danger-bg);
}

.btn-small {
  min-height: 44px;
  padding: 8px 14px;
  font-size: 15px;
}

.btn:disabled {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
}

.btn-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin: 12px 0;
}

a.btn[aria-disabled="true"] {
  background: var(--surface-muted);
  border-color: var(--border);
  color: var(--muted);
  cursor: not-allowed;
  pointer-events: none;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.add-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 12px 0 0;
}

.add-row .hint {
  margin: 0;
}

/* Confirm rows */

.confirm-row {
  background: var(--warning-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 12px;
  margin: 12px 0;
}

.confirm-row p {
  margin: 0 0 10px;
  font-weight: 600;
}

.confirm-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

/* Catalog rows */

.product-row {
  border: 1px solid var(--border);
  border-radius: var(--radius-control);
  padding: 12px;
  margin: 0 0 12px;
  background: var(--surface);
}

.product-fields {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: flex-end;
}

.product-name-field {
  flex: 1 1 150px;
  min-width: 0;
}

.product-price-field {
  flex: 0 1 130px;
  min-width: 0;
}

.product-row label {
  font-size: 13px;
  color: var(--muted);
  margin-bottom: 4px;
}

.remove-btn {
  flex: none;
  width: 44px;
  height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--danger);
  cursor: pointer;
}

.remove-btn:hover {
  background: var(--danger-bg);
}

.empty-state {
  background: var(--surface-muted);
  border-radius: var(--radius-control);
  padding: 16px;
  margin: 0 0 4px;
}

.empty-state p {
  margin: 0;
}

/* Preview rows and steppers */

.preview-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}

.preview-row:last-child {
  border-bottom: 0;
}

.preview-info {
  flex: 1 1 130px;
  min-width: 0;
}

.preview-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.preview-unit {
  color: var(--muted);
  font-size: 14px;
}

.stepper {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  flex: none;
}

.step-btn {
  width: 44px;
  height: 44px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.step-btn:hover {
  background: var(--surface-muted);
}

.step-btn:disabled {
  color: var(--muted);
  background: var(--surface-muted);
  cursor: not-allowed;
}

.qty-input {
  width: 64px;
  min-height: 44px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  padding: 8px 4px;
}

.preview-line-total {
  flex: none;
  min-width: 92px;
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.preview-error {
  flex: 1 1 100%;
  margin: 0;
}

/* Totals */

.totals {
  margin: 16px 0 4px;
  border-top: 1px solid var(--border);
  padding-top: 12px;
}

.totals-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 3px 0;
}

.totals-row dt {
  color: var(--muted);
}

.totals-row dd {
  margin: 0;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}

.totals-grand {
  font-size: 18px;
}

.totals-grand dt {
  color: var(--ink);
  font-weight: 700;
}

.totals-grand dd {
  font-weight: 700;
}

/* Chat bubble */

.bubble-wrap {
  background: var(--surface-muted);
  border-radius: 12px;
  padding: 16px 12px;
}

.bubble {
  background: var(--primary-soft);
  border: 1px solid var(--border);
  border-radius: 12px 12px 12px 4px;
  padding: 12px 14px;
  max-width: 92%;
}

.bubble-text {
  margin: 0;
  font: inherit;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble-text.placeholder {
  color: var(--muted);
  font-style: italic;
}

/* Output panel */

.counts-line {
  color: var(--muted);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
  margin: 0 0 12px;
}

.banner {
  display: flex;
  gap: 10px;
  border-radius: var(--radius-control);
  padding: 12px;
  margin: 0 0 16px;
  font-size: 14px;
  line-height: 1.45;
}

.banner p {
  margin: 0;
}

.banner .icon {
  flex: none;
  margin-top: 1px;
}

.banner-warning {
  background: var(--warning-bg);
  color: var(--warning);
}

.banner-warning p {
  color: var(--ink);
}

.reason-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.reason-list li {
  margin: 0;
}

.reason-btn {
  width: 100%;
  text-align: left;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  min-height: 44px;
  padding: 10px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-control);
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 15px;
  cursor: pointer;
}

.reason-btn:hover {
  background: var(--surface-muted);
}

.reason-btn .icon {
  flex: none;
  color: var(--danger);
  margin-top: 2px;
}

.test-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 12px;
  margin: 4px 0 16px;
}

.test-row .hint {
  margin: 0;
  flex: 1 1 200px;
}

.share-text {
  font-size: 15px;
  line-height: 1.5;
}

.copy-feedback {
  min-height: 24px;
  margin: 8px 0 0;
  font-size: 14px;
  font-weight: 600;
  color: var(--success);
}

.copy-feedback.fallback {
  color: var(--warning);
}

.clear-zone {
  border-top: 1px solid var(--border);
  margin-top: 20px;
  padding-top: 4px;
}

/* Help */

.help-card details {
  border-bottom: 1px solid var(--border);
  padding: 4px 0;
}

.help-card details:last-child {
  border-bottom: 0;
}

.help-card summary {
  font-weight: 600;
  cursor: pointer;
  padding: 12px 4px;
  min-height: 44px;
  display: flex;
  align-items: center;
}

.help-card details p {
  margin: 0 0 14px;
  color: var(--ink);
  max-width: 70ch;
}

/* Reduced motion */

@media (prefers-reduced-motion: reduce) {
  .btn {
    transition: none;
  }
}
