:root {
  --bg: #fff8fa;
  --pink: #f4a6c1;
  --blush: #fce8ef;
  --burgundy-deep: #4a0e22;
  --surface: #ffffff;
  --text: #2a1017;
  --muted: #6b4a55;
  --border: #f0d3dc;
  --primary: #7b1e3a;
  --primary-ink: #ffffff;
  --accent-bg: #fce8ef;
  --warn-bg: #fff6e0;
  --warn-border: #c98a00;
  --danger: #b42318;
  --danger-bg: #fdecea;
  --focus: #c2185b;
  --low: #166534;
  --mod: #8a5a00;
  --high: #b42318;
  --radius: 12px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 2px 8px rgb(0 0 0 / 0.04);
  font-size: 100%;
  color-scheme: light dark;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1a0d12;
    --surface: #24131a;
    --text: #fbeef2;
    --muted: #d6b3bf;
    --border: #4a2a35;
    --primary: #f4a6c1;
    --primary-ink: #3a0a1c;
    --accent-bg: #3a1a26;
    --warn-bg: #33270b;
    --warn-border: #e0a526;
    --danger: #ff8a7a;
    --danger-bg: #3a1714;
    --focus: #ffd1de;
    --low: #4ade80;
    --mod: #fbbf24;
    --high: #ff8a7a;
  }
}

html.high-contrast {
  --bg: #000;
  --surface: #000;
  --text: #fff;
  --muted: #fff;
  --border: #fff;
  --primary: #ffff00;
  --primary-ink: #000;
  --accent-bg: #000;
  --warn-bg: #000;
  --danger-bg: #000;
  --focus: #00ffff;
}
html.large-text { font-size: 118.75%; }

* { box-sizing: border-box; }
[hidden] { display: none !important; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
}
a { color: var(--primary); }
html.high-contrast a { text-decoration: underline; }
img, video, canvas, svg { max-width: 100%; }
h1 { font-size: 1.85rem; line-height: 1.2; margin: 0.25rem 0 0.5rem; }
h2 { font-size: 1.3rem; margin: 0 0 0.75rem; }
h3 { font-size: 1.05rem; margin: 1.1rem 0 0.4rem; }
h4 { margin: 0.75rem 0 0.25rem; }
h1:focus, h2:focus, h3:focus { outline: none; }
h1:focus-visible, h2:focus-visible, h3:focus-visible { outline: 3px solid var(--focus); outline-offset: 4px; }

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

.sr-only {
  position: absolute !important;
  width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link { position: absolute; left: 0.5rem; top: -3rem; z-index: 100; background: var(--primary); color: var(--primary-ink); padding: 0.6rem 1rem; border-radius: 8px; }
.skip-link:focus { top: 0.5rem; }

.app-header {
  display: flex; align-items: center; justify-content: space-between; gap: 1rem;
  padding: 0.75rem 1rem; background: var(--surface); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.brand { display: flex; align-items: center; gap: 0.5rem; font-weight: 700; font-size: 1.2rem; }
.header-actions { display: flex; gap: 0.5rem; align-items: center; }
.menu-toggle { display: none; }

.layout { display: grid; grid-template-columns: 230px 1fr; max-width: 1200px; margin: 0 auto; }
.primary-nav ul { list-style: none; margin: 0; padding: 1rem 0.5rem; position: sticky; top: 4rem; }
.primary-nav a {
  display: block; padding: 0.6rem 0.85rem; border-radius: 8px; color: var(--text); text-decoration: none; min-height: 44px;
}
.primary-nav a:hover { background: var(--accent-bg); }
.primary-nav a[aria-current='page'] { background: var(--primary); color: var(--primary-ink); font-weight: 600; }

main { padding: 1rem 1.25rem 3rem; min-width: 0; }
main:focus { outline: none; }
.lead { color: var(--muted); font-size: 1.05rem; margin-top: 0; }
.muted { color: var(--muted); }
.small { font-size: 0.9rem; }
.req { color: var(--muted); font-weight: 400; font-size: 0.9rem; }

.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 1.1rem 1.25rem; margin: 1rem 0; box-shadow: var(--shadow);
}
.card-accent { border-left: 5px solid var(--primary); }
.card-warn { border-left: 5px solid var(--warn-border); background: var(--warn-bg); }
.grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 0 1.25rem; }
.grid-2 > .card { margin: 0.5rem 0; }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.4rem;
  min-height: 44px; padding: 0.55rem 1rem; border-radius: 10px; border: 1.5px solid var(--primary);
  background: var(--surface); color: var(--primary); font: inherit; font-weight: 600; cursor: pointer; text-decoration: none;
}
.btn:hover { background: var(--accent-bg); }
.btn-primary { background: var(--primary); color: var(--primary-ink); }
.btn-primary:hover { filter: brightness(1.08); background: var(--primary); }
.btn-ghost { border-color: transparent; }
.btn-danger { border-color: var(--danger); color: var(--danger); }
.btn-small { min-height: 38px; padding: 0.35rem 0.75rem; font-size: 0.92rem; }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
.btn-voice.listening, .btn[aria-pressed='true'] { background: var(--danger); border-color: var(--danger); color: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgb(180 35 24 / 0.25); } }
.btn-row { display: flex; flex-wrap: wrap; gap: 0.5rem; margin: 0.75rem 0; }
.file-btn { position: relative; }
.file-btn:focus-within { outline: 3px solid var(--focus); outline-offset: 2px; }

.form .field, .field { margin: 0.75rem 0; display: flex; flex-direction: column; gap: 0.3rem; }
.field.inline { flex-direction: row; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
label { font-weight: 600; }
.check { display: flex; gap: 0.6rem; align-items: flex-start; font-weight: 400; padding: 0.35rem 0; min-height: 44px; cursor: pointer; }
.check input { width: 1.25rem; height: 1.25rem; margin-top: 0.15rem; flex: none; accent-color: var(--primary); }
input:not([type='checkbox']):not([type='radio']):not([type='range']), select, textarea {
  font: inherit; padding: 0.6rem 0.7rem; border: 1.5px solid var(--border); border-radius: 8px;
  background: var(--surface); color: var(--text); min-height: 44px; width: 100%;
}
input[type='range'] { width: 100%; accent-color: var(--primary); min-height: 32px; }
fieldset { border: 1px solid var(--border); border-radius: 10px; margin: 1rem 0; padding: 0.5rem 1rem 0.75rem; }
legend { font-weight: 700; padding: 0 0.35rem; }
.options.cols-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 0 1rem; }
.options.inline { display: flex; flex-wrap: wrap; gap: 0 1rem; }
.hint { margin: 0; color: var(--muted); font-size: 0.9rem; font-weight: 400; }
.error { color: var(--danger); font-weight: 600; min-height: 1px; }
.inline-form { display: flex; gap: 0.5rem; }

.callout { background: var(--accent-bg); border-radius: 10px; padding: 0.75rem 1rem; margin: 0.75rem 0; }
.callout ul { margin: 0.25rem 0 0; padding-left: 1.2rem; }
.callout-danger { background: var(--danger-bg); border-left: 4px solid var(--danger); }

.badge { display: inline-block; padding: 0.1rem 0.55rem; border-radius: 999px; font-size: 0.85rem; font-weight: 700; border: 1.5px solid currentColor; }
.badge-low { color: var(--low); }
.badge-moderate { color: var(--mod); }
.badge-noticeable { color: var(--high); }

.meter { height: 10px; background: var(--border); border-radius: 999px; overflow: hidden; margin: 0.35rem 0; }
.meter span { display: block; height: 100%; background: var(--primary); border-radius: 999px; }
.concerns { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.25rem 1.5rem; }
.concern-head { display: flex; justify-content: space-between; gap: 0.5rem; }

.camera-wrap { position: relative; max-width: 560px; border-radius: var(--radius); overflow: hidden; background: #000; margin-bottom: 0.5rem; }
.camera-wrap video { display: block; width: 100%; transform: scaleX(-1); }
.guide-oval {
  position: absolute; left: 30%; top: 14%; width: 40%; height: 68%;
  border: 3px dashed rgb(255 255 255 / 0.9); border-radius: 50%;
  box-shadow: 0 0 0 9999px rgb(0 0 0 / 0.35);
}
.camera-hint { position: absolute; bottom: 0.25rem; left: 0; right: 0; text-align: center; color: #fff; margin: 0; text-shadow: 0 1px 3px #000; }

.result-grid { display: grid; grid-template-columns: minmax(200px, 340px) 1fr; gap: 1.25rem; align-items: start; }
.result-photo { margin: 0; }
.result-canvas { width: 100%; border-radius: 10px; }
.tone { display: flex; gap: 1rem; align-items: center; }
.swatch { width: 72px; height: 72px; border-radius: 50%; border: 2px solid var(--border); flex: none; }
.kv { display: grid; grid-template-columns: auto 1fr; gap: 0.15rem 0.75rem; margin: 0; }
.kv dt { color: var(--muted); }
.kv dd { margin: 0; font-weight: 600; }

.routine { padding-left: 1.2rem; }
.routine li { margin: 0.5rem 0; }
.routine li strong { display: block; }
.chips { list-style: none; padding: 0; display: flex; flex-wrap: wrap; gap: 0.4rem; }
.chips li { background: var(--accent-bg); padding: 0.25rem 0.7rem; border-radius: 999px; font-size: 0.92rem; }
.chips-warn li { background: var(--danger-bg); }
.ing-list li { margin: 0.5rem 0; }

.checklist { margin: 0.5rem 0; }
.banner { display: flex; align-items: center; justify-content: space-between; gap: 1rem; background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: var(--radius); padding: 0.5rem 1rem; margin-bottom: 0.5rem; }
.banner p { margin: 0; }

.table { width: 100%; border-collapse: collapse; margin: 0.5rem 0; font-size: 0.95rem; }
.table th, .table td { text-align: left; padding: 0.45rem 0.5rem; border-bottom: 1px solid var(--border); }
.table caption { text-align: left; font-weight: 600; padding-bottom: 0.25rem; }
section > .table, .card > .table { display: block; overflow-x: auto; }

.compare { position: relative; max-width: 560px; border-radius: 10px; overflow: hidden; }
.compare img { display: block; width: 100%; }
.compare-after { position: absolute; inset: 0; }
.compare-after img { width: 100%; height: 100%; object-fit: cover; }
.compare-line { position: absolute; top: 0; bottom: 0; width: 3px; background: #fff; box-shadow: 0 0 4px #000; transform: translateX(-50%); }
.side-by-side { display: grid; grid-template-columns: 1fr 1fr; gap: 0.75rem; }
.side-by-side figure, .gallery figure { margin: 0; }
.side-by-side img { width: 100%; border-radius: 10px; }
.gallery { list-style: none; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 1rem; }
.gallery img { width: 100%; aspect-ratio: 3 / 4; object-fit: cover; border-radius: 10px; }
.gallery figcaption { font-size: 0.88rem; color: var(--muted); }

.chart { margin: 0.5rem 0; }
.chart svg { width: 100%; height: auto; }
.chart .bar { fill: var(--primary); }
.chart .axis, .chart .val { fill: var(--muted); font-size: 10px; }
.chart figcaption { font-size: 0.9rem; color: var(--muted); }

.voice-controls { display: flex; flex-wrap: wrap; gap: 0.25rem 1.5rem; align-items: center; }
.chat-log { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; max-height: 55vh; min-height: 200px; overflow-y: auto; }
.msg { margin: 0.5rem 0; display: flex; }
.msg p { margin: 0; padding: 0.6rem 0.9rem; border-radius: 14px; max-width: 85%; }
.msg-user { justify-content: flex-end; }
.msg-user p { background: var(--primary); color: var(--primary-ink); }
.msg-bot p { background: var(--accent-bg); }
.msg-urgent p { background: var(--danger-bg); border: 2px solid var(--danger); }
.chat-form { display: flex; gap: 0.5rem; margin: 0.75rem 0; }
.chat-form input { flex: 1; }
.suggestions { display: flex; flex-wrap: wrap; gap: 0.4rem; margin-bottom: 0.75rem; }
.chip-btn { font: inherit; font-size: 0.92rem; padding: 0.4rem 0.8rem; min-height: 38px; border-radius: 999px; border: 1px solid var(--border); background: var(--surface); color: var(--text); cursor: pointer; }
.chip-btn:hover { border-color: var(--primary); }

.steps li { margin: 0.4rem 0; }
.tips summary, details summary { cursor: pointer; font-weight: 600; min-height: 32px; }

.app-footer { border-top: 1px solid var(--border); padding: 1rem 1.25rem 2rem; color: var(--muted); font-size: 0.9rem; max-width: 1200px; margin: 0 auto; }

.toasts { position: fixed; bottom: 1rem; right: 1rem; display: flex; flex-direction: column; gap: 0.5rem; z-index: 50; max-width: min(420px, calc(100vw - 2rem)); }
.toast { background: var(--text); color: var(--bg); padding: 0.75rem 1rem; border-radius: 10px; box-shadow: var(--shadow); }
.toast-error { background: var(--danger); color: #fff; }

dialog { border: none; border-radius: var(--radius); max-width: 560px; padding: 1.5rem; background: var(--surface); color: var(--text); }
dialog::backdrop { background: rgb(0 0 0 / 0.55); }

kbd { border: 1px solid var(--border); border-bottom-width: 2px; border-radius: 4px; padding: 0 0.3rem; font-size: 0.9em; }

@media (max-width: 800px) {
  .layout { grid-template-columns: 1fr; }
  .menu-toggle { display: inline-flex; }
  .primary-nav { display: none; border-bottom: 1px solid var(--border); background: var(--surface); }
  .primary-nav.open { display: block; }
  .primary-nav ul { position: static; display: grid; grid-template-columns: 1fr 1fr; }
  .result-grid { grid-template-columns: 1fr; }
  main { padding: 1rem; }
  .btn-voice { padding: 0.5rem 0.75rem; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

@media (max-width: 480px) {
  .hide-sm { display: none; }
  .brand-name { font-size: 1.05rem; }
}

/* Animated droplet icon (js/icon.js) */
.droplets { display: block; overflow: visible; }
.droplets .drop { animation: drop-float 4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.droplets .fizz { animation: fizz 2.6s ease-in-out infinite; }
@keyframes drop-float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(calc(var(--drift, 1) * 2.5px), -5px) scale(1.04); }
}
@keyframes fizz {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50% { opacity: 0.9; transform: translateY(-1.5px); }
}
.droplets.busy .drop { animation-duration: 1.4s !important; }
.brand .droplets { flex: none; }

.hero {
  position: relative; overflow: hidden; border-radius: 18px; margin: 0.5rem 0 1rem;
  background: linear-gradient(135deg, #4a0e22 0%, #7b1e3a 45%, #d9557f 80%, #f7b6c8 100%);
  color: #fff; padding: 1.5rem 1.5rem 1.25rem; display: grid; grid-template-columns: 1.1fr 1fr; align-items: center; gap: 1rem;
}
.hero h1 { color: #fff; margin: 0 0 0.25rem; }
.hero p { margin: 0; color: #fde7ee; }
.hero .droplets-banner { max-height: 170px; }
html.high-contrast .hero { background: #000; border: 2px solid #fff; }
@media (max-width: 640px) { .hero { grid-template-columns: 1fr; } .hero .droplets-banner { max-height: 110px; } }

.loader { display: flex; align-items: center; gap: 0.75rem; }
.msg-bot { gap: 0.5rem; align-items: flex-start; }
.msg-bot .droplets { margin-top: 0.3rem; }

@media (prefers-reduced-motion: reduce) {
  .droplets .drop, .droplets .fizz { animation: none !important; }
}
