/* Nhịp Mặn — tokens & shared components. Palette lifted from the delta: silt, river jade, salt paper, flag vermilion. */
:root {
  --bg: #efe9dd;        /* muối — salt paper */
  --bg2: #e5ddcc;       /* phù sa nhạt — pale silt */
  --card: #f8f4eb;
  --ink: #17231e;       /* nước sâu — deep river */
  --ink2: #44514a;
  --ink3: #5b665f;
  --line: rgba(23, 35, 30, .11);
  --man: #c23f1a;       /* cờ hiệu — flag vermilion, the ONE action colour */
  --man-2: #a8340f;
  --on-man: #fff;
  --song: #2d5b57;      /* sông — river jade */
  --phusa: #8a6537;     /* phù sa — silt ochre */
  --lo: #2b6d5e; --lo-bg: #dbe7de;
  --mid: #93610a; --mid-bg: #f1e2c2;
  --hi: #b83a16; --hi-bg: #f4d6c8;
  --night: #0d1512; --night-2: #17231e; --night-ink: #efe8da;
  --f-d: 'Phudu', 'Be Vietnam Pro', system-ui, sans-serif;
  --f-b: 'Be Vietnam Pro', system-ui, sans-serif;
  --e: cubic-bezier(.2, .8, .2, 1);
  --e-s: cubic-bezier(.34, 1.4, .5, 1);
  --r: 14px; --r-s: 10px;
  color-scheme: light;
}
[data-theme="dark"] {
  --bg: #0d1512; --bg2: #121c18; --card: #17231e;
  --ink: #ede6d8; --ink2: #bdb9ac; --ink3: #a09f93;
  --line: rgba(237, 230, 216, .1);
  --man: #e0582c; --man-2: #f06a3d; --on-man: #1a0d07;
  --song: #6fa59c; --phusa: #c79a5d;
  --lo: #7cc0aa; --lo-bg: #173229;
  --mid: #e6ad45; --mid-bg: #33280f;
  --hi: #f27c52; --hi-bg: #3a1c12;
  color-scheme: dark;
}
*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 80px; }
body { margin: 0; background: var(--bg); color: var(--ink); font: 400 16px/1.6 var(--f-b); -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility; overflow-x: hidden; }
body::before { /* faint paper grain */
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0; opacity: .5; mix-blend-mode: multiply;
  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 baseFrequency='.8' numOctaves='2' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .28 0 0 0 0 .18 0 0 0 .07 0'/%3E%3C/filter%3E%3Crect width='160' height='160' filter='url(%23n)'/%3E%3C/svg%3E");
}
[data-theme="dark"] body::before { mix-blend-mode: screen; opacity: .25; }
main { position: relative; z-index: 1; }
img { display: block; max-width: 100%; }
img.miss { opacity: 0; }
a { color: inherit; }
button, input, select, textarea { font: inherit; color: inherit; }
h1, h2, h3 { margin: 0; font-weight: 600; letter-spacing: -.01em; }
p { margin: 0; }
.sr { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip { position: fixed; left: 12px; top: -60px; z-index: 100; background: var(--ink); color: var(--bg); padding: 12px 16px; border-radius: 8px; text-decoration: none; }
.skip:focus { top: 12px; }
:focus-visible { outline: 3px solid var(--man); outline-offset: 3px; border-radius: 6px; }
.ic { width: 22px; height: 22px; flex: none; }
.eyebrow { font: 600 13px/1.3 var(--f-b); letter-spacing: .14em; text-transform: uppercase; color: var(--ink3); }
.lnk { color: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; display: inline-flex; align-items: center; gap: 4px; }
.lnk .ic { width: 18px; height: 18px; }
[hidden] { display: none !important; }

/* logo */
.logo { display: inline-flex; align-items: center; gap: 10px; font: 700 21px/1 var(--f-d); letter-spacing: .01em; color: var(--ink); }
.logo svg { width: 34px; height: 34px; }

/* buttons */
.btn { --bh: 46px; display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: var(--bh); padding: 0 20px; border-radius: 999px; border: 0; cursor: pointer; text-decoration: none; font-weight: 600; font-size: 15.5px; line-height: 1.2; transition: transform .2s var(--e), background-color .2s, color .2s, box-shadow .2s; white-space: nowrap; }
.btn:active { transform: scale(.97); }
.btn.big { --bh: 56px; padding: 0 26px; font-size: 17px; }
.btn.pri { background: var(--man); color: var(--on-man); }
.btn.pri:hover { background: var(--man-2); }
.btn.line { background: transparent; color: var(--ink); box-shadow: inset 0 0 0 1.5px currentColor; }
.btn.line:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); }
.btn.ghost { background: transparent; color: var(--ink2); padding: 0 14px; }
.btn.ghost:hover { background: color-mix(in srgb, var(--ink) 7%, transparent); color: var(--ink); }
.btn.danger { background: var(--hi); color: #fff; }
.btn.danger-t { color: var(--hi); }
.btn.on-dark { color: var(--night-ink); }
.btn.line.on-dark { box-shadow: inset 0 0 0 1.5px rgba(239, 232, 218, .55); }
.btn:disabled { opacity: .55; cursor: default; transform: none; }
.btn.busy { position: relative; }
.btn.busy .ic { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.ib { width: 44px; height: 44px; display: inline-grid; place-items: center; border-radius: 999px; border: 0; background: transparent; color: var(--ink2); cursor: pointer; transition: background-color .2s, color .2s, transform .2s var(--e); }
.ib:hover { background: color-mix(in srgb, var(--ink) 8%, transparent); color: var(--ink); }
.ib:active { transform: scale(.94); }
.ib.on { color: var(--man); }
.ib-t { font: 700 13px/1 var(--f-b); letter-spacing: .06em; }
.ib.on-dark { color: rgba(239, 232, 218, .85); }
.ib.on-dark:hover { background: rgba(239, 232, 218, .12); color: #fff; }
.ib.lg { width: 52px; height: 52px; background: var(--bg2); }

/* salinity levels */
.lv-lo { --lv: var(--lo); --lv-bg: var(--lo-bg); }
.lv-mid { --lv: var(--mid); --lv-bg: var(--mid-bg); }
.lv-hi { --lv: var(--hi); --lv-bg: var(--hi-bg); }
.chip { display: inline-flex; align-items: center; gap: 6px; padding: 6px 12px; border-radius: 999px; font-size: 13.5px; font-weight: 600; background: var(--lv-bg, var(--bg2)); color: var(--lv, var(--ink2)); white-space: nowrap; }
.chip::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: currentColor; }
.dotv { display: inline-grid; place-items: center; min-width: 52px; height: 40px; padding: 0 10px; border-radius: 10px; background: var(--lv-bg); color: var(--lv); font: 700 18px/1 var(--f-d); font-variant-numeric: tabular-nums; }
.dotv.lg { min-width: 64px; height: 52px; font-size: 24px; flex-direction: column; gap: 0; }
.dotv small { font: 600 11.5px/1 var(--f-b); opacity: .85; margin-top: 2px; }
.av { display: inline-grid; place-items: center; width: 40px; height: 40px; border-radius: 50%; background: var(--song); color: #fff; font: 700 16px/1 var(--f-d); flex: none; }
.av.sm { width: 32px; height: 32px; font-size: 14px; }

/* form bits */
.fld { display: grid; gap: 8px; border: 0; margin: 0; padding: 0; min-width: 0; }
.fld > span, .fld > legend { font-weight: 600; font-size: 15px; color: var(--ink2); padding: 0; margin-bottom: 8px; }
.fld > span { margin-bottom: 0; }
.fld input:not([type=radio]):not([type=checkbox]):not([type=range]), .fld select, .fld textarea { width: 100%; min-height: 52px; padding: 12px 16px; border-radius: var(--r-s); border: 0; background: var(--bg2); color: var(--ink); font-size: 16px; box-shadow: inset 0 0 0 1px var(--line); transition: box-shadow .2s; }
.fld textarea { resize: vertical; line-height: 1.5; }
.fld input:focus, .fld select:focus, .fld textarea:focus { outline: none; box-shadow: inset 0 0 0 2px var(--man); }
.fld [aria-invalid="true"] { box-shadow: inset 0 0 0 2px var(--hi) !important; }
.err { color: var(--hi); font-style: normal; font-size: 14px; font-weight: 500; }
.fld-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.chips { display: flex; flex-wrap: wrap; gap: 10px; }
.chips.scroll { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 -20px; padding: 2px 20px 4px; }
.chips.scroll::-webkit-scrollbar { display: none; }
.chipr { position: relative; cursor: pointer; }
.chipr input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.chipr span { display: inline-flex; flex-direction: column; justify-content: center; min-height: 48px; padding: 8px 18px; border-radius: 12px; background: var(--bg2); font-weight: 600; font-size: 15.5px; line-height: 1.25; transition: background-color .2s, color .2s, transform .2s var(--e); }
.chipr small { font-weight: 500; font-size: 13px; opacity: .8; }
.chipr.sm span { min-height: 44px; padding: 8px 14px; font-size: 14.5px; }
.chipr input:checked + span { background: var(--ink); color: var(--bg); }
.chipr input:focus-visible + span { outline: 3px solid var(--man); outline-offset: 2px; }
.chipr:active span { transform: scale(.97); }
.chipb { min-height: 44px; padding: 0 18px; border-radius: 999px; border: 0; background: var(--bg2); font-weight: 600; font-size: 15px; cursor: pointer; white-space: nowrap; transition: background-color .2s, color .2s; }
.chipb.on { background: var(--ink); color: var(--bg); }
.seg { display: inline-flex; background: var(--bg2); border-radius: 12px; padding: 4px; gap: 2px; }
.seg button, .seg label span { display: inline-flex; align-items: center; min-height: 40px; padding: 0 16px; border-radius: 9px; border: 0; background: transparent; font-weight: 600; font-size: 14.5px; cursor: pointer; color: var(--ink2); transition: background-color .2s, color .2s; }
.seg label { position: relative; }
.seg label input { position: absolute; opacity: 0; inset: 0; cursor: pointer; }
.seg .on, .seg label input:checked + span { background: var(--card); color: var(--ink); box-shadow: 0 1px 2px rgba(0, 0, 0, .08); }
.seg label input:focus-visible + span { outline: 3px solid var(--man); }
.tg { display: flex; align-items: center; gap: 14px; cursor: pointer; min-height: 48px; position: relative; }
.tg input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.tg-s { width: 52px; height: 32px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 22%, transparent); position: relative; flex: none; transition: background-color .25s; }
.tg-s::after { content: ""; position: absolute; left: 4px; top: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .3s var(--e-s); box-shadow: 0 1px 3px rgba(0, 0, 0, .2); }
.tg input:checked + .tg-s { background: var(--man); }
.tg input:checked + .tg-s::after { transform: translateX(20px); }
.tg input:focus-visible + .tg-s { outline: 3px solid var(--man); outline-offset: 2px; }
.tg b { display: block; font-size: 16px; }
.tg small { display: block; color: var(--ink3); font-size: 14px; line-height: 1.4; }
.tg span:last-child { font-weight: 500; }
.sw { display: inline-flex; align-items: center; gap: 10px; min-height: 44px; padding: 0 4px; border: 0; background: none; cursor: pointer; font-weight: 600; font-size: 15px; color: var(--ink2); }
.sw-k { width: 52px; height: 32px; border-radius: 999px; background: var(--lo); position: relative; transition: background-color .25s; }
.sw-k::after { content: ""; position: absolute; left: 4px; top: 4px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .3s var(--e-s); }
.sw.on .sw-k { background: var(--mid); }
.sw.on .sw-k::after { transform: translateX(20px); }
.sw-l { min-width: 44px; text-align: left; }

/* stepper */
.step { display: flex; align-items: stretch; gap: 10px; }
.step input { text-align: center; font: 700 22px/1 var(--f-d) !important; }
.step-b { width: 56px; min-height: 56px; border-radius: 14px; border: 0; background: var(--bg2); display: grid; place-items: center; cursor: pointer; color: var(--ink); flex: none; transition: transform .2s var(--e); }
.step-b:active { transform: scale(.94); }
.step-b .ic { width: 26px; height: 26px; }
.step.xl .step-b { width: 72px; min-height: 96px; border-radius: 18px; }
.step-v { flex: 1; display: flex; align-items: baseline; justify-content: center; gap: 6px; background: var(--lv-bg, var(--bg2)); border-radius: 18px; padding: 0 10px; transition: background-color .3s; }
.step.xl .step-v input { background: transparent !important; box-shadow: none !important; font-size: 56px !important; width: 3.2ch; padding: 0 !important; min-height: 96px; color: var(--lv, var(--ink)); }
.step-v span { font: 600 18px/1 var(--f-d); color: var(--ink3); }
.step[data-lv="lo"] { --lv: var(--lo); --lv-bg: var(--lo-bg); }
.step[data-lv="mid"] { --lv: var(--mid); --lv-bg: var(--mid-bg); }
.step[data-lv="hi"] { --lv: var(--hi); --lv-bg: var(--hi-bg); }

/* dialog */
.dlg { border: 0; padding: 0; background: transparent; color: var(--ink); max-width: min(560px, calc(100vw - 24px)); width: 100%; max-height: calc(100dvh - 32px); overflow: visible; }
.dlg.sm { max-width: 440px; }
.dlg.md { max-width: 560px; }
.dlg.lg { max-width: 920px; }
.dlg::backdrop { background: rgba(9, 14, 12, .52); opacity: 0; transition: opacity .3s; }
.dlg.in::backdrop { opacity: 1; }
.dlg-in { background: var(--card); border-radius: 20px; padding: 28px; display: grid; gap: 20px; max-height: calc(100dvh - 32px); overflow: auto; transform: translateY(16px) scale(.98); opacity: 0; transition: transform .4s var(--e), opacity .3s; box-shadow: 0 24px 60px rgba(0, 0, 0, .22); }
.dlg.in .dlg-in { transform: none; opacity: 1; }
.dlg-t { font: 600 26px/1.15 var(--f-d); }
.dlg-p { color: var(--ink2); font-size: 16px; }
.dlg-a { display: flex; gap: 10px; justify-content: flex-end; flex-wrap: wrap; align-items: center; }
.dlg-a .sp { flex: 1; }
.dlg-row { display: flex; gap: 10px; }

/* toast */
.toasts, .ph-toasts { position: fixed; left: 50%; bottom: 28px; transform: translateX(-50%); z-index: 90; display: grid; gap: 10px; justify-items: center; pointer-events: none; width: min(460px, calc(100vw - 24px)); }
.toast { display: flex; align-items: center; gap: 12px; padding: 14px 16px 14px 18px; border-radius: 14px; background: var(--ink); color: var(--bg); font-weight: 500; font-size: 15px; line-height: 1.4; box-shadow: 0 12px 32px rgba(0, 0, 0, .22); transform: translateY(14px) scale(.98); opacity: 0; transition: transform .4s var(--e-s), opacity .3s; pointer-events: auto; }
.toast.in { transform: none; opacity: 1; }
.toast .ic { color: var(--lo-bg); }
.toast.warn .ic { color: var(--mid-bg); }
.toast-u { margin-left: 6px; border: 0; background: rgba(255, 255, 255, .14); color: inherit; padding: 8px 12px; border-radius: 8px; font-weight: 600; cursor: pointer; min-height: 36px; }
[data-theme="dark"] .toast-u { background: rgba(0, 0, 0, .12); }

/* empty, skeleton */
.empty { display: grid; justify-items: center; text-align: center; gap: 10px; padding: 28px 16px; }
.empty-i { width: 100%; max-width: 280px; aspect-ratio: 4/3; object-fit: cover; border-radius: 14px; margin-bottom: 8px; filter: saturate(.85); background: var(--bg2); }
.empty h3 { font: 600 21px/1.25 var(--f-d); }
.empty p { color: var(--ink3); max-width: 34ch; }
.skl { display: block; height: 16px; border-radius: 6px; background: linear-gradient(90deg, var(--bg2) 0%, color-mix(in srgb, var(--bg2) 50%, var(--card)) 50%, var(--bg2) 100%) 0 0 / 200% 100%; animation: shim 1.3s linear infinite; }
.skl.w30 { width: 30%; } .skl.w40 { width: 40%; } .skl.w50 { width: 50%; } .skl.w60 { width: 60%; }
@keyframes shim { to { background-position: -200% 0; } }

/* 3D stage shared */
.r3-cv { position: absolute; inset: 0; width: 100% !important; height: 100% !important; display: block; opacity: 0; transition: opacity 1.2s var(--e); }
.r3-live .r3-cv { opacity: 1; }
.r3-labels { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.r3-lb { position: absolute; left: 0; top: 0; display: inline-flex; align-items: center; gap: 6px; padding: 5px 10px 5px 8px; margin: -38px 0 0 -14px; border-radius: 8px; background: rgba(13, 21, 18, .82); color: #efe8da; font: 500 13px/1.2 var(--f-b); white-space: nowrap; border: 0; pointer-events: auto; will-change: transform; transition: background-color .2s; }
.r3-lb b { font: 700 14px/1 var(--f-d); }
.r3-lb[data-lvl="hi"] b { color: #ff9b6e; }
.r3-lb[data-lvl="mid"] b { color: #f0c463; }
.r3-lb[data-lvl="lo"] b { color: #9fd6c3; }
button.r3-lb { cursor: pointer; min-height: 32px; }
button.r3-lb:hover { background: rgba(13, 21, 18, .95); }
.r3-pin { position: absolute; left: 0; top: 0; display: inline-flex; align-items: center; gap: 8px; margin: -12px 0 0 -12px; }
.r3-pin i { width: 24px; height: 24px; border-radius: 50%; background: var(--man); box-shadow: 0 0 0 5px rgba(224, 88, 44, .28); }
.r3-pin b { background: var(--man); color: #fff; font: 600 13px/1 var(--f-b); padding: 6px 10px; border-radius: 7px; white-space: nowrap; }
.r3-fail .r3-labels { display: none; }

/* reveal */
.rv { opacity: 0; transform: translateY(22px); transition: opacity .6s var(--e), transform .6s var(--e); }
.rv.in { opacity: 1; transform: none; }
.clip { clip-path: inset(12% 0 12% 0 round 4px); transition: clip-path 1.1s var(--e); }
.clip.in { clip-path: inset(0 0 0 0 round 4px); }
.calm *, .calm *::before, .calm *::after { animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation-duration: .001ms !important; transition-duration: .001ms !important; } }
::view-transition-old(root), ::view-transition-new(root) { animation-duration: .38s; animation-timing-function: cubic-bezier(.2, .8, .2, 1); }
