/* ============================================================
   LycheeScan - site có nav + landing + tool + placeholders
   Dials: DESIGN_VARIANCE 7 · MOTION_INTENSITY 5 · VISUAL_DENSITY 3
   Radius system: tương tác = pill · panel = 24/22px · nhỏ = 12px
   Tông màu quả vải giữ nguyên (đỏ tươi / xanh lá / hồng nhạt)
   ============================================================ */

:root {
  color-scheme: light;

  --lychee-red: #e63956;
  --lychee-red-deep: #b42440;
  --leaf-green: #3e9b4f;
  --pink-soft: #ffd9e2;
  --pink-bg: #fff1f4;
  --cream: #fff8f3;

  --ink: #2b1a1d;
  --ink-2: #5a4148;
  --ink-soft: #7a5c63;
  --line: #f0dde2;
  --card: #ffffff;

  --page-grad: linear-gradient(165deg, var(--cream) 0%, var(--pink-bg) 58%, #ffe9f0 100%);
  --nav-bg: rgba(255, 246, 248, 0.78);
  --nav-border: rgba(255, 255, 255, 0.7);
  --nav-hover: rgba(255, 255, 255, 0.6);
  --nav-menu-bg: rgba(255, 246, 248, 0.96);
  --surface-glass: rgba(255, 255, 255, 0.7);
  --surface-glass-2: rgba(255, 255, 255, 0.8);
  --surface-glass-3: rgba(255, 255, 255, 0.85);
  --surface-strong: rgba(255, 255, 255, 0.92);
  --surface-solid: #ffffff;
  --accent-soft: #fde6eb;
  --accent-line: #ffd0db;
  --accent-line-2: #ffe0e7;
  --icon-grad-red: linear-gradient(150deg, #ffe3ea, #ffd0db);
  --icon-grad-green: linear-gradient(150deg, #dff2dc, #c9e8c4);
  --green-soft-bg: #f4fbf2;
  --sheet-grad: linear-gradient(150deg, #dff0dc, #cde8c9);
  --sheet-line: #bfe0ba;
  --dz-border: #f0a3b3;
  --img-bg: #faf3f4;
  --divider: #f6e7ea;
  --hover-soft: #fbeef1;
  --step-dot: #e8c4cc;
  --toast-bg: var(--ink);
  --toast-fg: #ffffff;

  --radius-panel: 24px;
  --radius-sheet: 22px;
  --radius-sm: 12px;

  --shadow-card: 0 18px 50px -18px rgba(180, 36, 64, 0.22);
  --shadow-btn: 0 10px 24px -10px rgba(180, 36, 64, 0.5);
  --shadow-soft: 0 10px 30px -14px rgba(43, 26, 29, 0.2);
  --shadow-sheet: 0 16px 38px -16px rgba(43, 26, 29, 0.3);

  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);

  --nav-h: 68px;
  --maxw: 1120px;

  /* Theme mức chín (ghi đè trong #state-result[data-level]) */
  --level-accent: var(--lychee-red);
  --level-grad-from: #d92b4c;
  --level-grad-to: #a81f3c;
  --level-deep: var(--lychee-red-deep);
  --level-soft: #fde6eb;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  font-family: "Be Vietnam Pro", system-ui, -apple-system, "Segoe UI", sans-serif;
  color: var(--ink);
  min-height: 100dvh;
  background: var(--page-grad);
  overflow-x: hidden;
}

.container { width: 100%; max-width: var(--maxw); margin: 0 auto; padding: 0 22px; }
.main { padding: 36px 22px 64px; }

::selection { background: var(--lychee-red); color: #fff; }

/* ---------- Nền: blob lệch góc + grain ---------- */
.bg-decor { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(74px); opacity: 0.5; animation: blobFloat 18s ease-in-out infinite alternate; }
.blob-red   { width: 48vmax; height: 48vmax; background: #ffb9c9; top: -20vmax; right: -18vmax; }
.blob-green { width: 38vmax; height: 38vmax; background: #c6e8c2; bottom: -18vmax; left: -16vmax; animation-delay: -7s; }
.blob-pink  { width: 26vmax; height: 26vmax; background: #ffd0dc; top: 44%; left: 56%; animation-delay: -12s; opacity: 0.38; }
@keyframes blobFloat { from { transform: translate3d(0,0,0) scale(1); } to { transform: translate3d(4vmax,-3vmax,0) scale(1.1); } }

body[data-level="chua_chin"] .blob-red   { background: #bce4c0; }
body[data-level="chua_chin"] .blob-pink  { background: #d6eed6; }
body[data-level="chua_chin"] .blob-green { background: #a9d9a8; }
body[data-level="chin_ky"] .blob-red     { background: #e0b3a4; }
body[data-level="chin_ky"] .blob-pink    { background: #ecc8bb; }
body[data-level="chin_ky"] .blob-green   { background: #d9c2b4; }

body::after {
  content: ""; position: fixed; inset: 0; z-index: 80; pointer-events: none; opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ============================================================
   NAVIGATION
   ============================================================ */
.nav {
  position: sticky; top: 0; z-index: 70;
  background: var(--nav-bg);
  backdrop-filter: blur(16px) saturate(1.1);
  -webkit-backdrop-filter: blur(16px) saturate(1.1);
  border-bottom: 1px solid var(--nav-border);
}
.nav-inner {
  max-width: var(--maxw); margin: 0 auto;
  min-height: var(--nav-h); padding: 0 22px;
  display: flex; align-items: center; gap: 16px;
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); flex: none; }
.brand-mark { width: 38px; height: 38px; filter: drop-shadow(0 5px 10px rgba(230,57,86,.32)); }
.brand-text { font-size: 1.25rem; font-weight: 800; letter-spacing: -0.02em; }
.brand-text span { color: var(--lychee-red); }

.nav-menu { display: flex; align-items: center; gap: 2px; margin-left: auto; }
.nav-link {
  position: relative; text-decoration: none; color: var(--ink-2); font-weight: 600; font-size: 0.92rem;
  padding: 9px 13px; border-radius: 999px; white-space: nowrap;
  transition: color 0.2s, background 0.2s;
}
.nav-link:hover { color: var(--ink); background: var(--nav-hover); }
.nav-link.is-active { color: var(--lychee-red-deep); }
/* gạch chân active trượt vào (transform-only) */
.nav-link::after {
  content: ""; position: absolute; left: 13px; right: 13px; bottom: 5px; height: 2px; border-radius: 2px;
  background: var(--lychee-red); transform: scaleX(0); transform-origin: left center;
  transition: transform 0.3s var(--ease-spring);
}
.nav-link.is-active::after { transform: scaleX(1); }

/* Lang toggle (EN/VI) */
.lang-toggle {
  flex: none; display: inline-flex; gap: 2px; padding: 3px;
  background: var(--surface-glass); border: 1px solid var(--line); border-radius: 999px;
}
.lang-toggle button {
  appearance: none; border: none; background: transparent; cursor: pointer;
  font-family: inherit; font-weight: 800; font-size: 0.74rem; letter-spacing: 0.04em;
  color: var(--ink-soft); padding: 5px 11px; border-radius: 999px;
  transition: background 0.2s, color 0.2s, transform 0.18s var(--ease-spring);
}
.lang-toggle button[aria-pressed="true"] { background: var(--lychee-red); color: #fff; }
.lang-toggle button:not([aria-pressed="true"]):hover { color: var(--lychee-red-deep); }
.lang-toggle button:active { transform: scale(0.92); }

/* Back to dashboard */
.dashboard-link {
  flex: none; appearance: none; cursor: pointer; text-decoration: none;
  width: 38px; height: 38px; border-radius: 999px;
  display: grid; place-items: center; margin-left: 8px;
  background: var(--surface-glass); border: 1px solid var(--line); color: var(--ink-2);
  transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.18s var(--ease-spring);
}
.dashboard-link:hover { color: var(--lychee-red-deep); border-color: var(--accent-line); background: var(--surface-glass-2); }
.dashboard-link:active { transform: scale(0.9); }
.dashboard-link:focus-visible { outline: 2px solid var(--lychee-red); outline-offset: 2px; }
.dashboard-link svg { width: 18px; height: 18px; }

/* Theme toggle (sáng / tối) */
.theme-toggle {
  flex: none; appearance: none; cursor: pointer; font-family: inherit;
  width: 38px; height: 38px; border-radius: 999px;
  display: grid; place-items: center;
  background: var(--surface-glass); border: 1px solid var(--line); color: var(--ink-2);
  transition: color 0.2s, background 0.2s, border-color 0.2s, transform 0.18s var(--ease-spring);
}
.theme-toggle:hover { color: var(--lychee-red-deep); border-color: var(--accent-line); background: var(--surface-glass-2); }
.theme-toggle:active { transform: scale(0.9); }
.theme-toggle:focus-visible { outline: 2px solid var(--lychee-red); outline-offset: 2px; }
.theme-toggle svg { width: 19px; height: 19px; }
.theme-toggle .ico-sun { display: none; }
.theme-toggle .ico-moon { display: block; animation: iconIn 0.35s var(--ease-spring); }
html[data-theme="dark"] .theme-toggle .ico-sun { display: block; animation: iconIn 0.35s var(--ease-spring); }
html[data-theme="dark"] .theme-toggle .ico-moon { display: none; }
@keyframes iconIn { from { opacity: 0; transform: rotate(-70deg) scale(0.6); } to { opacity: 1; transform: rotate(0) scale(1); } }

/* Hamburger (mobile) */
.nav-toggle {
  display: none; flex: none; margin-left: auto;
  appearance: none; border: 1px solid var(--line); background: var(--surface-glass-2);
  width: 42px; height: 42px; border-radius: 12px; cursor: pointer;
  position: relative;
}
.nav-toggle span {
  position: absolute; left: 9px; right: 9px; height: 2px; border-radius: 2px; background: var(--ink);
  transition: transform 0.3s var(--ease-out), opacity 0.2s, top 0.3s;
}
.nav-toggle span:nth-child(1) { top: 13px; }
.nav-toggle span:nth-child(2) { top: 20px; }
.nav-toggle span:nth-child(3) { top: 27px; }
.nav-toggle[aria-expanded="true"] span:nth-child(1) { top: 20px; transform: rotate(45deg); }
.nav-toggle[aria-expanded="true"] span:nth-child(2) { opacity: 0; }
.nav-toggle[aria-expanded="true"] span:nth-child(3) { top: 20px; transform: rotate(-45deg); }

/* ============================================================
   VIEW SWITCHING
   ============================================================ */
.view { display: none; animation: viewIn 0.4s var(--ease-out) both; }
.view.is-active { display: block; }
@keyframes viewIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

/* Titling chung */
.page-head { margin: 8px 0 30px; max-width: 720px; }
.section-kicker { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--lychee-red-deep); }
.section-h { font-size: clamp(1.7rem, 4.4vw, 2.4rem); font-weight: 800; letter-spacing: -0.02em; line-height: 1.2; margin-top: 6px; }
.section-lede { margin-top: 10px; font-size: 1.02rem; line-height: 1.6; color: var(--ink-2); max-width: 60ch; }

/* ============================================================
   HERO (asymmetric split)
   ============================================================ */
.hero {
  position: relative;
  display: grid; grid-template-columns: 1.1fr 0.9fr; gap: 40px;
  align-items: center; padding: 28px 0 64px;
}
.hero-text { animation: riseIn 0.55s var(--ease-out) 0.05s both; }
.eyebrow {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 0.74rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--lychee-red-deep); background: var(--accent-soft); padding: 6px 13px; border-radius: 999px;
}
.hero-h1 {
  font-size: clamp(2.1rem, 6vw, 3.4rem); font-weight: 800; letter-spacing: -0.025em;
  line-height: 1.12; margin: 18px 0 0;
}
.hero-h1 strong { color: var(--lychee-red); font-weight: 800; }
.hero-h1 span, .hero-h1 strong { display: inline; }
.hero-sub { margin-top: 16px; font-size: 1.06rem; line-height: 1.6; color: var(--ink-2); max-width: 36ch; }
.hero-cta { margin-top: 26px; display: flex; flex-wrap: wrap; gap: 12px; }
.hero-glow {
  position: absolute; inset: -40px -10vw; z-index: -1; pointer-events: none;
  background: radial-gradient(ellipse 40% 50% at 78% 42%, rgba(230,57,86,0.18), transparent 70%);
}

/* Mini preview (real component of the product, values illustrative) */
.hero-art { animation: artIn 0.6s var(--ease-spring) 0.18s both; }
@keyframes artIn { from { opacity: 0; transform: rotate(-3deg) translateY(24px) scale(0.92); } to { opacity: 1; transform: rotate(-1.4deg) translateY(0) scale(1); } }
.art-caption { font-size: 0.74rem; font-weight: 600; color: var(--ink-soft); margin: 0 0 12px 4px; }
.preview-demo {
  position: relative; transform: rotate(-1.4deg);
  border-radius: var(--radius-panel); padding: 28px 22px 22px;
  color: #fff; overflow: visible;
  background: linear-gradient(150deg, #d92b4c 0%, #a81f3c 100%);
  box-shadow: 0 26px 60px -22px rgba(180,36,64,0.5);
}
.preview-demo::before {
  content: ""; position: absolute; inset: 0; border-radius: inherit; pointer-events: none;
  background-image: radial-gradient(rgba(255,255,255,0.14) 1.4px, transparent 1.4px); background-size: 20px 20px; opacity: 0.6;
}
.pd-thumb {
  position: absolute; top: -22px; right: 20px; width: 54px; height: 54px; border-radius: 14px; overflow: hidden;
  border: 3px solid #fff; box-shadow: 0 8px 18px rgba(0,0,0,0.25); transform: rotate(8deg); background: #fff;
}
.pd-thumb svg { width: 100%; height: 100%; }
.pd-badge {
  width: 60px; height: 60px; border-radius: 50%; background: rgba(255,255,255,0.16);
  border: 2px solid rgba(255,255,255,0.5); display: grid; place-items: center; margin-bottom: 12px; position: relative; z-index: 1;
}
.pd-badge svg { width: 36px; height: 36px; }
.pd-kicker { position: relative; z-index: 1; font-size: 0.7rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.9; }
.pd-label { position: relative; z-index: 1; font-size: 1.9rem; font-weight: 900; line-height: 1.1; margin: 2px 0 14px; text-shadow: 0 2px 10px rgba(0,0,0,0.2); }
.pd-ring { position: relative; width: 92px; height: 92px; }
.pd-ring svg { width: 100%; height: 100%; }
.pd-pct { position: absolute; inset: 0; display: grid; place-items: center; font-size: 1.35rem; font-weight: 900; }
.pd-bars { margin-top: 14px; display: flex; flex-direction: column; gap: 7px; }
.pd-bar { display: block; height: 6px; border-radius: 999px; background: rgba(255,255,255,0.28); overflow: hidden; position: relative; }
.pd-bar b { position: absolute; inset: 0; transform: scaleX(var(--v, 0)); transform-origin: left; background: #fff; border-radius: inherit; }

@keyframes riseIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* ---------- Project description section (trong trang chủ) ---------- */
.page-section { padding: 32px 0; border-top: 1px solid var(--line); }
.proj-desc { max-width: 100%; }
.desc-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 28px; margin-top: 18px; }
.desc-grid p { font-size: 0.98rem; line-height: 1.65; color: var(--ink-2); }
.chips { list-style: none; display: flex; flex-wrap: wrap; gap: 9px; margin-top: 24px; }
.chips li {
  font-size: 0.82rem; font-weight: 600; color: var(--ink-2);
  background: var(--surface-glass-2); border: 1px solid var(--line); padding: 8px 14px; border-radius: 999px;
}

/* ============================================================
   PRODUCT (tool)
   ============================================================ */
.product-shell { max-width: 540px; margin: 0 auto; display: flex; flex-direction: column; gap: 18px; }

.state { display: none; flex-direction: column; gap: 18px; }
.state.is-active { display: flex; animation: stateIn 0.45s var(--ease-out) both; }
@keyframes stateIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

.up-copy { padding: 4px 2px 0; animation: riseIn 0.5s var(--ease-out) 0.05s both; }
.up-title { font-size: clamp(1.6rem, 5vw, 2rem); font-weight: 800; letter-spacing: -0.025em; line-height: 1.18; }
.up-title strong { color: var(--lychee-red); font-weight: 800; }
.up-sub { margin-top: 8px; font-size: 0.94rem; line-height: 1.55; color: var(--ink-soft); max-width: 36ch; }

/* Dropzone (chồng thẻ xoay) */
.dz-stack { position: relative; margin-top: 4px; animation: riseIn 0.55s var(--ease-out) 0.16s both; }
.dz-sheet { position: absolute; inset: 0; border-radius: var(--radius-panel); background: var(--sheet-grad); border: 1.5px solid var(--sheet-line); transform: rotate(1.8deg) translate(7px, 9px); transition: transform 0.35s var(--ease-spring); }
.dropzone {
  position: relative; appearance: none; width: 100%; border: 2px dashed var(--dz-border);
  background: var(--surface-strong); border-radius: var(--radius-panel); padding: 24px 20px;
  display: flex; align-items: center; gap: 16px; text-align: left; cursor: pointer; font-family: inherit; color: var(--ink);
  transform: rotate(-1deg); overflow: hidden;
  transition: transform 0.3s var(--ease-spring), border-color 0.25s, background 0.25s, box-shadow 0.3s;
}
.dropzone:hover, .dropzone:focus-visible { transform: rotate(-0.2deg) translateY(-3px); border-color: var(--lychee-red); background: var(--surface-solid); box-shadow: 0 16px 36px -14px rgba(180,36,64,0.4); outline: none; }
.dz-stack:hover .dz-sheet { transform: rotate(2.6deg) translate(9px, 11px); }
.dropzone:active { transform: rotate(0) scale(0.985); }
.dropzone.is-dragover { transform: rotate(0) scale(1.02); border-color: var(--leaf-green); border-style: solid; background: var(--green-soft-bg); box-shadow: 0 0 0 5px rgba(62,155,79,0.16), 0 18px 40px -14px rgba(62,155,79,0.45); }
.dropzone.is-dragover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(105deg, transparent 30%, rgba(62,155,79,0.12) 50%, transparent 70%); animation: dzSweep 1.1s linear infinite; pointer-events: none; }
@keyframes dzSweep { from { transform: translateX(-100%); } to { transform: translateX(100%); } }
.dz-icon { flex: none; width: 58px; height: 58px; display: grid; place-items: center; border-radius: 18px; color: var(--lychee-red); background: var(--icon-grad-red); transform: rotate(-4deg); transition: transform 0.3s var(--ease-spring); }
.dropzone:hover .dz-icon, .dropzone.is-dragover .dz-icon { transform: rotate(0) scale(1.08); }
.dropzone.is-dragover .dz-icon { color: var(--leaf-green); background: var(--icon-grad-green); }
.dz-icon svg { width: 32px; height: 32px; }
.dz-text { display: flex; flex-direction: column; align-items: flex-start; gap: 3px; min-width: 0; }
.dz-title { font-size: 1.04rem; font-weight: 700; }
.dz-sub { font-size: 0.82rem; color: var(--ink-soft); }
.dz-hint { margin-top: 8px; font-size: 0.72rem; font-weight: 600; color: var(--lychee-red-deep); background: var(--accent-soft); padding: 5px 12px; border-radius: 999px; }

/* Chọn mô hình AI (nhanh vs chính xác) */
.model-select { display: flex; gap: 8px; margin-top: 14px; animation: riseIn 0.5s var(--ease-out) 0.1s both; }
.model-opt {
  flex: 1; appearance: none; cursor: pointer; font-family: inherit; text-align: left;
  background: var(--surface-glass-3); border: 1.5px solid var(--accent-line); border-radius: 16px;
  padding: 10px 14px; display: flex; flex-direction: column; gap: 2px;
  transition: transform 0.18s var(--ease-spring), border-color 0.2s, background 0.2s, box-shadow 0.25s;
}
.model-opt:hover { border-color: var(--lychee-red); }
.model-opt:active { transform: scale(0.97); }
.model-opt.is-active { background: linear-gradient(135deg, #d92b4c 0%, #c22444 55%, #a81f3c 100%); border-color: transparent; box-shadow: var(--shadow-btn); }
.model-opt-name { font-size: 0.86rem; font-weight: 800; color: var(--ink); }
.model-opt.is-active .model-opt-name { color: #fff; }
.model-opt-tag { font-size: 0.72rem; font-weight: 600; color: var(--ink-soft); }
.model-opt.is-active .model-opt-tag { color: rgba(255,255,255,0.85); }

.tips { list-style: none; display: flex; flex-wrap: wrap; gap: 8px; animation: riseIn 0.5s var(--ease-out) 0.26s both; }
.tips li { display: inline-flex; align-items: center; gap: 6px; font-size: 0.76rem; font-weight: 600; color: var(--ink-soft); background: var(--surface-glass-3); border: 1px solid var(--accent-line-2); padding: 7px 12px; border-radius: 999px; }
.tips svg { width: 15px; height: 15px; color: var(--leaf-green); flex: none; }

/* Preview image */
.preview-card { background: var(--card); border-radius: var(--radius-panel); padding: 14px; box-shadow: var(--shadow-card); animation: popIn 0.5s var(--ease-spring) both; }
.preview-card img { width: 100%; max-height: 44dvh; object-fit: contain; border-radius: 16px; background: var(--img-bg); display: block; }
.preview-meta { display: flex; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 6px 2px; font-size: 0.8rem; color: var(--ink-soft); }
.file-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.file-size { flex: none; font-variant-numeric: tabular-nums; }
@keyframes popIn { from { opacity: 0; transform: scale(0.92); } to { opacity: 1; transform: scale(1); } }

/* Buttons (đỏ đậm đạt AA cho chữ trắng) */
.actions { display: flex; flex-direction: column; gap: 10px; }
.btn { appearance: none; border: none; font-family: inherit; font-size: 1rem; font-weight: 700; padding: 15px 22px; border-radius: 999px; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; gap: 9px; white-space: nowrap; transition: transform 0.18s var(--ease-spring), box-shadow 0.25s, filter 0.2s, background 0.2s; -webkit-tap-highlight-color: transparent; text-decoration: none; }
.btn svg { width: 20px; height: 20px; flex: none; }
.btn:active { transform: scale(0.965); }
.btn-primary { color: #fff; background: linear-gradient(135deg, #d92b4c 0%, #c22444 55%, #a81f3c 100%); box-shadow: var(--shadow-btn); }
.btn-primary:hover { filter: brightness(1.07); transform: translateY(-1px); }
.btn-ghost { color: var(--lychee-red-deep); background: var(--surface-glass-3); border: 1.5px solid var(--accent-line); }
.btn-ghost:hover { background: var(--surface-solid); border-color: var(--lychee-red); }

/* Loading */
.scan-card { position: relative; background: var(--card); border-radius: var(--radius-panel); padding: 14px; box-shadow: var(--shadow-card); overflow: hidden; }
.scan-card img { width: 100%; max-height: 40dvh; object-fit: contain; border-radius: 16px; background: var(--img-bg); display: block; animation: scanPulse 2.2s ease-in-out infinite; }
@keyframes scanPulse { 0%,100% { filter: saturate(1); } 50% { filter: saturate(1.25) brightness(1.04); } }
.scan-line { position: absolute; left: 8%; right: 8%; height: 3px; border-radius: 3px; background: linear-gradient(90deg, transparent, #ff5c7c 20%, #ff8296 50%, #ff5c7c 80%, transparent); box-shadow: 0 0 18px 4px rgba(255,92,124,0.55); animation: scanMove 1.6s ease-in-out infinite; z-index: 2; }
@keyframes scanMove { 0% { top: 10%; opacity: 0; } 12% { opacity: 1; } 88% { opacity: 1; } 100% { top: 90%; opacity: 0; } }
.scan-grid { position: absolute; inset: 14px; border-radius: 16px; background-image: linear-gradient(rgba(230,57,86,0.08) 1px, transparent 1px), linear-gradient(90deg, rgba(230,57,86,0.08) 1px, transparent 1px); background-size: 26px 26px; z-index: 1; pointer-events: none; }
.steps { list-style: none; display: flex; flex-direction: column; gap: 9px; }
.steps li { display: flex; align-items: center; gap: 10px; font-size: 0.88rem; font-weight: 600; color: var(--ink-soft); opacity: 0.38; transition: opacity 0.35s, color 0.35s, transform 0.35s var(--ease-out); }
.steps li .dot { width: 10px; height: 10px; border-radius: 50%; background: var(--step-dot); flex: none; transition: background 0.3s, box-shadow 0.3s; }
.steps li.is-active { opacity: 1; color: var(--ink); transform: translateX(4px); }
.steps li.is-active .dot { background: var(--lychee-red); box-shadow: 0 0 0 5px rgba(230,57,86,0.18); animation: dotPulse 1s ease-in-out infinite; }
.steps li.is-done { opacity: 0.75; }
.steps li.is-done .dot { background: var(--leaf-green); }
@keyframes dotPulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.3); } }

/* ============================================================
   RESULT
   ============================================================ */
#state-result[data-level="chua_chin"] { --level-accent: #3e9b4f; --level-grad-from: #2b8341; --level-grad-to: #1c6530; --level-deep: #1f6e33; --level-soft: #e4f3e7; }
#state-result[data-level="chin_toi"]  { --level-accent: #e63956; --level-grad-from: #d92b4c; --level-grad-to: #a81f3c; --level-deep: #b42440; --level-soft: #fde6eb; }
#state-result[data-level="chin_ky"]   { --level-accent: #8a3b2e; --level-grad-from: #7c3529; --level-grad-to: #571f16; --level-deep: #5e2118; --level-soft: #f3e4dc; }

.result-panel { position: relative; margin-top: 26px; border-radius: var(--radius-panel); padding: 38px 22px 30px; color: #fff; background: linear-gradient(150deg, var(--level-grad-from) 0%, var(--level-grad-to) 100%); box-shadow: 0 20px 44px -16px var(--level-grad-to); overflow: visible; animation: riseIn 0.5s var(--ease-out) 0.05s both; transition: background 0.5s var(--ease-out); }
.result-panel::before { content: ""; position: absolute; inset: 0; border-radius: inherit; background-image: radial-gradient(rgba(255,255,255,0.15) 1.5px, transparent 1.5px); background-size: 22px 22px; pointer-events: none; }
.result-panel::after { content: ""; position: absolute; inset: 0; border-radius: inherit; background: radial-gradient(ellipse 60% 45% at 85% 0%, rgba(255,255,255,0.22), transparent 70%); pointer-events: none; }
.result-thumb { position: absolute; top: -24px; left: 18px; width: 60px; height: 60px; border-radius: 16px; overflow: hidden; border: 3px solid #fff; box-shadow: 0 10px 22px rgba(43,26,29,0.3); transform: rotate(-5deg); z-index: 2; animation: thumbIn 0.55s var(--ease-spring) 0.14s both; }
.result-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
@keyframes thumbIn { from { opacity: 0; transform: rotate(-16deg) translateY(-16px) scale(0.8); } to { opacity: 1; transform: rotate(-5deg); } }
.result-badge { position: absolute; top: -20px; right: 18px; width: 70px; height: 70px; border-radius: 50%; background: rgba(255,255,255,0.16); border: 2px solid rgba(255,255,255,0.5); display: grid; place-items: center; transform: rotate(4deg); z-index: 2; animation: badgePop 0.6s var(--ease-spring) 0.22s both; }
.result-badge svg { width: 40px; height: 40px; }
@keyframes badgePop { from { opacity: 0; transform: scale(0.3) rotate(40deg); } to { opacity: 1; transform: scale(1) rotate(4deg); } }
.result-kicker { position: relative; z-index: 1; font-size: 0.74rem; font-weight: 600; letter-spacing: 0.14em; text-transform: uppercase; opacity: 0.9; animation: riseIn 0.5s var(--ease-out) 0.28s both; }
.result-label { position: relative; z-index: 1; font-size: 2.4rem; font-weight: 900; letter-spacing: -0.01em; line-height: 1.15; margin-top: 3px; text-align: left; text-shadow: 0 3px 16px rgba(0,0,0,0.25); animation: riseIn 0.55s var(--ease-out) 0.34s both; }

.result-sheet { position: relative; z-index: 3; margin: -18px 8px 0; background: var(--card); border-radius: var(--radius-sheet); padding: 18px 18px 8px; box-shadow: var(--shadow-sheet); animation: sheetUp 0.55s var(--ease-out) 0.42s both; }
@keyframes sheetUp { from { opacity: 0; transform: translateY(28px); } to { opacity: 1; transform: translateY(0); } }
.sheet-top { display: flex; align-items: center; gap: 14px; }
.confidence { position: relative; flex: none; width: 104px; height: 104px; }
.ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring circle { fill: none; stroke-width: 11; stroke-linecap: round; }
.ring-bg { stroke: var(--level-soft); }
.ring-fg { stroke: var(--level-accent); stroke-dasharray: 326.7; stroke-dashoffset: 326.7; transition: stroke-dashoffset 1.2s var(--ease-out); }
.confidence-text { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; line-height: 1; }
.confidence-value { font-size: 1.6rem; font-weight: 900; color: var(--level-deep); font-variant-numeric: tabular-nums; }
.confidence-unit { font-size: 0.8rem; font-weight: 700; color: var(--level-deep); margin-top: -1px; }
.confidence-caption { font-size: 0.6rem; font-weight: 600; color: var(--ink-soft); margin-top: 5px; letter-spacing: 0.05em; }
.result-hint { flex: 1; min-width: 0; font-size: 0.82rem; font-weight: 500; line-height: 1.55; color: var(--level-deep); background: var(--level-soft); border-radius: var(--radius-sm); padding: 12px 14px; transition: color 0.4s, background 0.4s; }

.probs { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--divider); }
.probs h3 { font-size: 0.84rem; font-weight: 700; margin-bottom: 8px; }
.prob-row { display: grid; grid-template-columns: 92px 1fr 42px; align-items: center; gap: 10px; padding: 7px 0; font-size: 0.8rem; cursor: pointer; border-radius: 10px; transition: background 0.2s; }
.prob-row:hover { background: var(--hover-soft); }
.prob-row.is-cam-active { background: var(--accent-soft); }
.prob-name { display: inline-flex; align-items: center; gap: 5px; font-weight: 600; color: var(--ink-soft); }
.prob-check { width: 13px; height: 13px; flex: none; color: var(--level-accent); opacity: 0; transform: scale(0.4); transition: opacity 0.3s, transform 0.35s var(--ease-spring); }
.prob-row.is-winner .prob-check { opacity: 1; transform: scale(1); }
.prob-row.is-winner .prob-name { color: var(--ink); font-weight: 800; }
.prob-bar { height: 6px; border-radius: 999px; background: var(--level-soft); overflow: hidden; }
.prob-fill { display: block; height: 100%; width: 100%; border-radius: inherit; transform: scaleX(0); transform-origin: left center; transition: transform 1s var(--ease-out); }
.prob-row[data-key="chua_chin"] .prob-fill { background: linear-gradient(90deg, #6fc272, #3e9b4f); }
.prob-row[data-key="chin_toi"]  .prob-fill { background: linear-gradient(90deg, #f2607c, #e63956); }
.prob-row[data-key="chin_ky"]   .prob-fill { background: linear-gradient(90deg, #a9604f, #8a3b2e); }
.prob-value { text-align: right; font-weight: 700; font-variant-numeric: tabular-nums; }
.prob-row.is-winner .prob-value { color: var(--level-deep); }

/* Grad-CAM */
.gradcam { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--divider); animation: riseIn 0.5s var(--ease-out) 0.5s both; }
.gradcam-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.gradcam-head h3 { font-size: 0.84rem; font-weight: 700; }
.gradcam-switch { display: inline-flex; align-items: center; gap: 6px; font-size: 0.72rem; font-weight: 600; color: var(--ink-soft); cursor: pointer; user-select: none; }
.gradcam-switch input { accent-color: var(--lychee-red); width: 15px; height: 15px; cursor: pointer; }
.gradcam-frame { margin-top: 10px; border-radius: 16px; overflow: hidden; background: var(--img-bg); }
#cam-canvas { display: block; width: 100%; max-height: 260px; object-fit: contain; }
.gradcam-caption { margin-top: 8px; font-size: 0.72rem; line-height: 1.5; color: var(--ink-soft); }

#state-result .actions { animation: riseIn 0.5s var(--ease-out) 0.62s both; }

/* Error */
.error-card { background: var(--card); border-radius: var(--radius-panel); border: 1.5px solid var(--accent-line); padding: 32px 24px; text-align: center; box-shadow: var(--shadow-card); }
.error-icon { display: inline-grid; place-items: center; width: 62px; height: 62px; border-radius: 50%; color: var(--lychee-red); background: var(--accent-soft); margin-bottom: 14px; }
.error-icon svg { width: 30px; height: 30px; }
.error-card h2 { font-size: 1.2rem; font-weight: 800; margin-bottom: 8px; }
.error-card p { font-size: 0.88rem; color: var(--ink-soft); line-height: 1.55; }
.error-tip { margin-top: 10px; font-size: 0.78rem !important; }
.error-tip code { background: var(--accent-soft); color: var(--lychee-red-deep); padding: 2px 7px; border-radius: 6px; font-size: 0.76rem; }

/* ============================================================
   PLACEHOLDER PAGES
   ============================================================ */
.placeholder-layout { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.ph-block { background: var(--surface-glass); border: 1px solid var(--line); border-radius: var(--radius-panel); padding: 24px; }
.ph-icon { display: inline-grid; place-items: center; width: 48px; height: 48px; border-radius: 14px; color: var(--lychee-red); background: var(--accent-soft); margin-bottom: 14px; }
.ph-icon.sm { width: 38px; height: 38px; border-radius: 12px; }
.ph-icon svg { width: 24px; height: 24px; }
.ph-icon.sm svg { width: 19px; height: 19px; }
.ph-block h3, .idea-list h3, .timeline h3, .member-card h3 { font-size: 1.05rem; font-weight: 700; margin-bottom: 6px; }
.ph-block p, .idea-list p, .timeline p { font-size: 0.92rem; line-height: 1.6; color: var(--ink-2); }

/* Timeline */
.timeline { list-style: none; position: relative; padding-left: 26px; margin-top: 8px; }
.timeline::before { content: ""; position: absolute; left: 7px; top: 6px; bottom: 6px; width: 2px; background: linear-gradient(var(--pink-soft), var(--line)); border-radius: 2px; }
.timeline li { position: relative; padding: 14px 0; display: flex; gap: 16px; align-items: flex-start; }
.timeline li::before { content: ""; position: absolute; left: -23px; top: 20px; width: 12px; height: 12px; border-radius: 50%; background: var(--surface-solid); border: 2.5px solid var(--lychee-red); }
.t-date { flex: none; min-width: 64px; font-weight: 700; color: var(--lychee-red-deep); font-variant-numeric: tabular-nums; }

/* Future ideas */
.idea-list { list-style: none; display: grid; grid-template-columns: 1fr; gap: 12px; }
.idea-list li { display: flex; gap: 14px; align-items: flex-start; background: var(--surface-glass); border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 18px; }

/* Team */
.team-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; }
.member-card { background: var(--surface-glass); border: 1px solid var(--line); border-radius: var(--radius-panel); padding: 24px; text-align: center; }
.avatar { display: inline-grid; place-items: center; width: 72px; height: 72px; border-radius: 50%; color: var(--lychee-red); background: var(--icon-grad-red); margin-bottom: 14px; }
.avatar svg { width: 36px; height: 36px; }
.avatar img { width: 72px; height: 72px; object-fit: cover; border-radius: 50%; }
.member-card p { color: var(--ink-soft); }
.member-role { display: inline-block; font-size: 0.82rem; font-weight: 700; color: var(--lychee-red-deep); background: var(--accent-soft); padding: 4px 12px; border-radius: 999px; margin: 0 0 8px; }
.member-aff { font-size: 0.82rem; font-weight: 500; color: var(--ink-soft); margin: 0; line-height: 1.4; }
.member-aff:empty { display: none; }
.team-group + .team-group { margin-top: 32px; }
.team-subhead { font-size: 0.78rem; font-weight: 700; letter-spacing: 0.16em; text-transform: uppercase; color: var(--lychee-red-deep); margin: 0 0 14px; }
.team-grid.team-grid--adv { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.team-grid.team-grid--stu { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

/* Gallery — masonry layout hỗ trợ ảnh dọc lẫn ngang */
.gallery-grid { columns: 3; column-gap: 14px; }
.gal-tile { break-inside: avoid; margin: 0 0 14px; border-radius: var(--radius-sm); overflow: hidden; background: var(--surface-glass); border: 1px solid var(--line); }
.gal-tile img { display: block; width: 100%; height: auto; background: var(--level-soft); }
.gal-tile figcaption { padding: 10px 13px; font-size: 0.8rem; font-weight: 600; color: var(--ink-soft); }

/* ============================================================
   FOOTER & TOAST
   ============================================================ */
.footer { padding: 28px 22px 32px; text-align: center; font-size: 0.78rem; color: var(--ink-soft); opacity: 0.85; position: relative; z-index: 1; }

.toast { position: fixed; left: 50%; bottom: calc(22px + env(safe-area-inset-bottom)); transform: translateX(-50%) translateY(80px); background: var(--toast-bg); color: var(--toast-fg); font-size: 0.86rem; font-weight: 600; padding: 12px 20px; border-radius: 999px; box-shadow: 0 12px 30px rgba(0,0,0,0.3); opacity: 0; transition: transform 0.35s var(--ease-spring), opacity 0.3s; z-index: 100; max-width: min(90vw, 420px); text-align: center; pointer-events: none; }
.toast.is-visible { transform: translateX(-50%) translateY(0); opacity: 1; }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (min-width: 1024px) {
  .nav-toggle { display: none; }
}

@media (max-width: 1023px) {
  .lang-toggle { margin-left: auto; }
  .nav-toggle { display: grid; place-items: center; }
  .nav-menu {
    position: absolute; top: var(--nav-h); left: 0; right: 0;
    flex-direction: column; align-items: stretch; gap: 0;
    background: var(--nav-menu-bg);
    backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
    border-bottom: 1px solid var(--line);
    padding: 10px 22px calc(14px + env(safe-area-inset-bottom));
    box-shadow: 0 18px 40px -18px rgba(43,26,29,0.25);
    transform: translateY(-12px); opacity: 0; pointer-events: none;
    transition: transform 0.28s var(--ease-out), opacity 0.22s;
  }
  .nav-menu.is-open { transform: translateY(0); opacity: 1; pointer-events: auto; }
  .nav-link { padding: 13px 8px; border-radius: 12px; }
  .nav-link::after { display: none; }
  .nav-link.is-active { background: var(--accent-soft); }
}

/* Hero collapse */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; gap: 30px; padding: 16px 0 40px; }
  .hero-art { order: 2; }
  .hero-glow { inset: -20px -10vw; }
  .placeholder-layout, .team-grid { grid-template-columns: 1fr 1fr; }}
@media (max-width: 560px) {
  .main { padding: 26px 18px 52px; }
  .desc-grid { grid-template-columns: 1fr; gap: 16px; }
  .placeholder-layout, .team-grid, .team-grid--adv, .team-grid--stu { grid-template-columns: 1fr; }
  .gallery-grid { columns: 2; }
  .result-label { font-size: 2.05rem; }
  .preview-demo { transform: rotate(-0.6deg); }
  .preview-demo .pd-label { font-size: 1.7rem; }
}

@media (max-width: 410px) {
  .sheet-top { flex-direction: column; align-items: stretch; }
  .confidence { margin: 0 auto; }
  .gallery-grid { grid-template-columns: 1fr; }
}

/* Giảm chuyển động */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: 0.01ms !important; animation-iteration-count: 1 !important; transition-duration: 0.01ms !important; scroll-behavior: auto !important; }
}

/* ============================================================
   DARK THEME — mặc định light, bật qua nút toggle / localStorage
   Nền mận ấm (không dùng đen trắng tuyệt đối), đỏ vải giữ nhận diện
   ============================================================ */
html[data-theme="dark"] {
  color-scheme: dark;

  --lychee-red: #f2607c;
  --lychee-red-deep: #ff92a6;
  --leaf-green: #6fc272;
  --pink-soft: #4a2a33;
  --pink-bg: #211318;
  --cream: #1a0f13;

  --ink: #f6e9ec;
  --ink-2: #d9bfc6;
  --ink-soft: #b39aa2;
  --line: #3b252c;
  --card: #2a191e;

  --page-grad: linear-gradient(165deg, #191014 0%, #211318 58%, #27161c 100%);
  --nav-bg: rgba(26, 15, 19, 0.8);
  --nav-border: rgba(255, 255, 255, 0.08);
  --nav-hover: rgba(255, 255, 255, 0.07);
  --nav-menu-bg: rgba(26, 15, 19, 0.96);

  --surface-glass: rgba(255, 255, 255, 0.045);
  --surface-glass-2: rgba(255, 255, 255, 0.06);
  --surface-glass-3: rgba(255, 255, 255, 0.07);
  --surface-strong: rgba(42, 25, 30, 0.92);
  --surface-solid: #2e1b21;

  --accent-soft: rgba(242, 96, 124, 0.15);
  --accent-line: rgba(242, 96, 124, 0.3);
  --accent-line-2: rgba(242, 96, 124, 0.2);

  --icon-grad-red: linear-gradient(150deg, rgba(242, 96, 124, 0.24), rgba(242, 96, 124, 0.12));
  --icon-grad-green: linear-gradient(150deg, rgba(111, 194, 114, 0.24), rgba(111, 194, 114, 0.12));
  --green-soft-bg: rgba(111, 194, 114, 0.1);
  --sheet-grad: linear-gradient(150deg, #334b31, #2a3f29);
  --sheet-line: #4a6a46;
  --dz-border: rgba(242, 96, 124, 0.45);

  --img-bg: #211419;
  --divider: #3b252c;
  --hover-soft: rgba(255, 255, 255, 0.05);
  --step-dot: #6b4a52;

  --shadow-card: 0 18px 50px -18px rgba(0, 0, 0, 0.55);
  --shadow-btn: 0 10px 24px -10px rgba(0, 0, 0, 0.5);
  --shadow-soft: 0 10px 30px -14px rgba(0, 0, 0, 0.5);
  --shadow-sheet: 0 16px 38px -16px rgba(0, 0, 0, 0.55);

  --toast-bg: #4d2833;
  --toast-fg: #f6e9ec;

  --level-soft: rgba(242, 96, 124, 0.14);
  --level-deep: #ff92a6;
}

html[data-theme="dark"] .blob { opacity: 0.42; }
html[data-theme="dark"] .blob-red   { background: #5c1f2d; }
html[data-theme="dark"] .blob-green { background: #234322; }
html[data-theme="dark"] .blob-pink  { background: #4d2430; }
html[data-theme="dark"] body[data-level="chua_chin"] .blob-red   { background: #234a27; }
html[data-theme="dark"] body[data-level="chua_chin"] .blob-pink  { background: #2b4a2b; }
html[data-theme="dark"] body[data-level="chua_chin"] .blob-green { background: #1e3d1e; }
html[data-theme="dark"] body[data-level="chin_ky"] .blob-red     { background: #4d2a1e; }
html[data-theme="dark"] body[data-level="chin_ky"] .blob-pink    { background: #452a22; }
html[data-theme="dark"] body[data-level="chin_ky"] .blob-green   { background: #3d2b22; }

html[data-theme="dark"] body::after { filter: invert(1); opacity: 0.07; }
html[data-theme="dark"] ::selection { background: #f2607c; color: #1a0f13; }
html[data-theme="dark"] .lang-toggle button[aria-pressed="true"] { color: #2b1a1d; }
html[data-theme="dark"] .hero-glow { background: radial-gradient(ellipse 40% 50% at 78% 42%, rgba(242, 96, 124, 0.16), transparent 70%); }

html[data-theme="dark"] #state-result[data-level="chua_chin"] { --level-soft: rgba(111, 194, 114, 0.16); --level-deep: #8fd69b; }
html[data-theme="dark"] #state-result[data-level="chin_toi"]  { --level-soft: rgba(242, 96, 124, 0.16); --level-deep: #ff92a6; }
html[data-theme="dark"] #state-result[data-level="chin_ky"]   { --level-soft: rgba(196, 124, 99, 0.18); --level-deep: #dba190; }
