/* SarangSon Exomaly: giao diện điện thoại phương án B (mềm, bo tròn, thanh tab nổi), màu chủ đạo xanh baby #C2E8F5 trên nền navy
   (theo ảnh trái tim notes/arts/heart.png). Bản xem thử: notes/mockup/B.html. Kiểm tương phản: chữ navy #0B1033 trên nền xanh baby. */

/* ---------- base ---------- */
html { -webkit-text-size-adjust: 100%; text-size-adjust: 100%; }
body { margin: 0; }
img { max-width: 100%; }
[hidden] { display: none !important; }

/* ---------- tokens ---------- */
:root {
  color-scheme: dark;
  --bg: #060A18;
  --panel: #0E1630;
  --line: #18223D;
  --line-2: #27355A;
  --edge: rgba(194, 232, 245, .16);
  --ink: #E6F3FA;
  --title: #DCF2FB;
  --muted: #94A7C4;
  --dim: #62739A;
  --accent: #C2E8F5;
  --accent-hi: #E3F5FB;
  --accent-ink: #0B1033;  /* chữ navy trên nền xanh baby: chữ trắng trên #C2E8F5 gần như không đọc được */
  --accent-soft: rgba(194, 232, 245, .12);
  --glow: rgba(194, 232, 245, .45);
  --lilac: rgba(150, 140, 230, .22);
  --peach: #F3C9B8;
  --f-word: "Unbounded", "Chakra Petch", system-ui, sans-serif;
  --f-display: "Chakra Petch", "IBM Plex Sans", system-ui, sans-serif;
  --f-body: "IBM Plex Sans", system-ui, -apple-system, "Segoe UI", Roboto, "Malgun Gothic", "Apple SD Gothic Neo", sans-serif;
  --f-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
* { box-sizing: border-box; }
body {
  background: var(--bg); color: var(--ink); font: 400 15px/1.55 var(--f-body); -webkit-font-smoothing: antialiased;
  display: flex; flex-direction: column; min-height: 100vh; min-height: 100dvh;
  padding-bottom: calc(100px + env(safe-area-inset-bottom, 0px));
}
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(520px 420px at 85% 0%, var(--lilac), transparent 70%),
    radial-gradient(520px 420px at 0% 100%, rgba(243, 201, 184, .10), transparent 70%),
    radial-gradient(700px 500px at 0% 0%, rgba(194, 232, 245, .08), transparent 60%);
}
body[data-screen="welcome"] { padding-bottom: 0; }
body[data-screen="welcome"] .top, body[data-screen="welcome"] .tabs { display: none; }
button, input, textarea { font: inherit; color: inherit; }
a { color: var(--accent-hi); text-underline-offset: 3px; text-decoration-color: rgba(194, 232, 245, .45); }
a:hover { text-decoration-color: currentColor; }
.vh { position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: 2px; }
svg.i { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; flex: none; }

/* ---------- header, layout ---------- */
.top { position: sticky; top: 0; z-index: 6; display: flex; align-items: center; gap: 10px; padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px; background: linear-gradient(var(--bg) 70%, transparent); }
.top img { width: 34px; height: auto; filter: drop-shadow(0 0 10px var(--glow)); }
.top .name { flex: 1; font: 800 17px/1 var(--f-word); color: var(--title); }
.top .name span { font: 500 11px/1 var(--f-body); color: var(--muted); letter-spacing: .12em; margin-left: 6px; }
.gear { width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center; background: rgba(14, 22, 48, .8); border: 1px solid var(--edge); color: var(--muted); cursor: pointer; }
.gear:hover { color: var(--accent-hi); border-color: var(--accent); }
main { position: relative; z-index: 1; width: 100%; max-width: 600px; margin: 0 auto; flex: 1; }
.wrap { padding: 6px 16px 28px; display: grid; grid-template-columns: minmax(0, 1fr); gap: 16px; }
.card { border-radius: 22px; background: rgba(14, 22, 48, .72); border: 1px solid var(--edge); padding: 16px; display: grid; gap: 12px; min-width: 0; }
.label { margin: 0; font: 600 12.5px/1 var(--f-body); letter-spacing: .1em; text-transform: uppercase; color: var(--accent); }
.block { display: grid; gap: 12px; min-width: 0; }
.row { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
h2 { margin: 0; font: 700 24px/1.2 var(--f-display); color: var(--title); }
p { margin: 0; }

/* ---------- màn chào + mã truy cập ---------- */
.welcome { position: relative; z-index: 1; min-height: 100vh; min-height: 100dvh; display: grid; align-content: center; justify-items: center; gap: 14px; padding: 28px 24px; text-align: center; }
.welcome .heart { width: 200px; height: auto; filter: drop-shadow(0 0 40px rgba(194, 232, 245, .55)); }
.welcome h1 { margin: 0; font: 800 30px/1.1 var(--f-word); color: var(--title); }
.welcome h1 small { display: block; margin-top: 6px; font: 500 13px/1 var(--f-body); letter-spacing: .4em; color: var(--muted); }
.welcome .kicker { color: var(--muted); }
.gift { max-width: 320px; margin: 6px 0; padding: 14px 16px; border-radius: 18px; border: 1px dashed var(--peach); color: var(--peach); background: rgba(243, 201, 184, .07); font-size: 15px; white-space: pre-line; }
.codebox { width: 100%; max-width: 320px; display: grid; gap: 10px; }
.codebox input, textarea, .field input { width: 100%; padding: 14px 16px; border-radius: 16px; border: 1px solid rgba(194, 232, 245, .22); background: rgba(6, 10, 24, .8); color: var(--ink); font: 400 17px/1.3 var(--f-body); }
.codebox input { text-align: center; }
.codebox input:focus, textarea:focus, .field input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.formerr { min-height: 1.4em; font-size: 13.5px; color: var(--peach); }
.hint { font-size: 12.5px; color: var(--dim); }
.welcome .hint { max-width: 300px; }
.linkbtn { background: none; border: 0; padding: 6px; color: var(--muted); font-size: 13px; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; }

/* ---------- buttons ---------- */
.run { min-height: 54px; border-radius: 28px; border: 0; background: var(--accent); color: var(--accent-ink); font: 700 17px/1 var(--f-display); display: flex; align-items: center; justify-content: center; gap: 10px; box-shadow: 0 12px 30px -10px var(--glow); cursor: pointer; width: 100%; }
.run:hover { filter: brightness(1.08); }
.run svg { width: 22px; height: 22px; }
.btn { min-height: 48px; padding: 0 16px; border-radius: 24px; display: inline-flex; align-items: center; justify-content: center; gap: 8px; border: 1px solid rgba(194, 232, 245, .22); background: rgba(11, 18, 36, .85); font: 500 15px/1 var(--f-body); color: var(--ink); cursor: pointer; text-align: center; }
.btn:hover, .btn:focus-within { border-color: var(--accent); }
.btn:disabled { opacity: .45; cursor: default; border-color: rgba(194, 232, 245, .22); }
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); font-weight: 600; box-shadow: 0 0 18px -6px var(--glow); }
.two { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.big { display: grid; gap: 4px; justify-items: center; padding: 22px 14px; border-radius: 22px; border: 1.5px dashed rgba(194, 232, 245, .35); background: var(--accent-soft); text-align: center; }
.big b { font: 600 19px/1.25 var(--f-display); }
.big span { color: var(--muted); font-size: 13px; }
.big .limit { margin-top: 4px; font: 500 11px/1.5 var(--f-mono); letter-spacing: .06em; color: var(--dim); }

/* ---------- loại chữ, kiểu hiển thị ---------- */
.seg { display: grid; grid-template-columns: 1fr 1fr; padding: 4px; border-radius: 22px; background: rgba(6, 10, 24, .8); border: 1px solid var(--edge); }
.seg input, .seg2 input { position: absolute; opacity: 0; width: 1px; height: 1px; pointer-events: none; }
.seg label { padding: 9px 8px; border-radius: 18px; text-align: center; display: grid; gap: 1px; cursor: pointer; }
.seg label b { font: 600 14.5px/1.2 var(--f-body); }
.seg label span { font-size: 11.5px; color: var(--muted); }
.seg input:checked + label { background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.seg input:checked + label b { color: var(--accent-hi); }
.seg2 { display: inline-flex; padding: 3px; border-radius: 20px; background: rgba(6, 10, 24, .8); border: 1px solid var(--edge); }
.seg2 label { padding: 7px 12px; border-radius: 16px; font: 500 13px/1 var(--f-body); color: var(--muted); cursor: pointer; }
.seg2 input:checked + label { background: var(--accent); color: var(--accent-ink); font-weight: 600; }
.seg input:focus-visible + label, .seg2 input:focus-visible + label { outline: 2px solid var(--accent-hi); outline-offset: 2px; }

/* ---------- ảnh, camera, kết quả ---------- */
.photo { position: relative; border-radius: 16px; overflow: hidden; border: 1px solid var(--edge); background: #000; }
#view { display: block; width: 100%; height: auto; cursor: pointer; touch-action: manipulation; }
.stage { height: min(62vh, 560px); }
.stage video, .stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; }
.stage video { object-fit: cover; }
.stage canvas { touch-action: manipulation; }
.caption { min-height: 3em; padding: 12px 14px; border-radius: 14px; background: rgba(6, 10, 24, .7); color: var(--muted); font-size: 14px; }
.caption .ko { display: block; font: 600 20px/1.35 var(--f-body); color: var(--title); }
.status { min-height: 1.5em; display: flex; gap: 8px; align-items: center; font-size: 13.5px; color: var(--muted); }
.status:empty { display: none; }
.status:not(:empty)::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--glow); flex: none; }
.ko-text { white-space: pre-wrap; font: 500 19px/1.55 var(--f-body); color: var(--title); }
.sentence { font: 500 17px/1.55 var(--f-body); }
.pairs { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.pairs:empty { display: none; }
.pairs li { padding: 10px 12px; border-radius: 14px; background: rgba(6, 10, 24, .65); border: 1px solid rgba(194, 232, 245, .1); display: grid; gap: 2px; }
.pairs .ko { font: 600 18px/1.35 var(--f-body); color: var(--title); }
textarea { min-height: 120px; font-size: 19px; line-height: 1.5; resize: vertical; }

/* ---------- từ vựng ---------- */
.words { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; }
.words:empty { display: none; }
.words li { padding: 10px 12px; border-radius: 14px; background: rgba(6, 10, 24, .65); border: 1px solid rgba(194, 232, 245, .1); display: grid; gap: 2px; min-width: 0; }
.words .ko { font: 600 18px/1.3 var(--f-body); color: var(--title); overflow-wrap: anywhere; }
.words .rom { font: 400 11.5px/1.4 var(--f-mono); color: var(--accent); letter-spacing: .04em; overflow-wrap: anywhere; }
.words .vi { font-size: 14px; color: var(--ink); }
.words .lemma { font: 400 11.5px/1.4 var(--f-mono); color: var(--dim); overflow-wrap: anywhere; }

/* ---------- cài đặt, người làm, chân trang ---------- */
.back { justify-self: start; display: inline-flex; align-items: center; gap: 4px; padding: 6px 0; background: none; border: 0; color: var(--accent-hi); font-size: 14px; cursor: pointer; }
.field { display: grid; gap: 6px; font-size: 13.5px; color: var(--muted); }
.field input { text-align: left; font-size: 15px; }
.dev .name { font: 700 22px/1.2 var(--f-display); color: var(--title); }
.dev p { color: var(--muted); font-size: 14px; }
.dev dl { margin: 0; display: grid; grid-template-columns: 78px minmax(0, 1fr); gap: 6px 10px; align-items: baseline; }
.dev dt { font-size: 12px; color: var(--dim); text-transform: uppercase; letter-spacing: .1em; }
.dev dd { margin: 0; min-width: 0; overflow-wrap: anywhere; }
.dev .mail { background: none; border: 0; padding: 0; cursor: pointer; color: var(--accent-hi); font: inherit; text-decoration: underline; text-underline-offset: 3px; text-decoration-color: rgba(194, 232, 245, .45); }
.copied { margin-left: 10px; font: 400 12px/1.6 var(--f-mono); color: var(--accent-hi); }
.small { margin: 0 6px; font-size: 12.5px; line-height: 1.6; color: var(--dim); }
.small a { color: inherit; }
.copy strong { font-weight: 500; color: var(--ink); }

/* ---------- thanh tab nổi ---------- */
.tabs {
  position: fixed; left: 14px; right: 14px; bottom: calc(12px + env(safe-area-inset-bottom, 0px)); z-index: 10;
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 4px; padding: 6px; max-width: 572px; margin-inline: auto;
  border-radius: 32px; background: rgba(14, 22, 48, .94); border: 1px solid rgba(194, 232, 245, .2);
  box-shadow: 0 14px 40px -8px rgba(0, 0, 0, .7); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
}
.tabs button { display: flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 0; border: 0; border-radius: 26px; background: none; color: var(--muted); font: 600 14px/1 var(--f-body); cursor: pointer; }
.tabs button svg { width: 22px; height: 22px; }
.tabs button[aria-current="page"] { background: var(--accent); color: var(--accent-ink); box-shadow: 0 6px 18px -6px var(--glow); }

@media (max-width: 400px) {
  .tabs button { flex-direction: column; gap: 4px; font-size: 11.5px; padding: 8px 0; }
}
@media (min-width: 900px) {
  body { padding-bottom: 110px; }
  main { max-width: 640px; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
