/* Exomaly Geulbit: 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 hành tinh hình cầu xanh nhạt, logo dựng bằng tools/make_planet_logo.py). 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;
  --rose: #F7A8C4;        /* hồng nhạt: điểm nhấn phụ (thẻ từ biến đổi, nhãn từ của ngày) */
  --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-right: 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); }
.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 .planet { 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-bottom: 6px; font: 500 13px/1 var(--f-body); letter-spacing: .4em; color: var(--muted); }
.welcome .kicker { color: var(--muted); }
.welcome .planet { animation: planet-float 6s ease-in-out infinite; }
@keyframes planet-float { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-10px); } }

/* ---------- nền: dải ngân hà (ảnh WebP), sao nhấp nháy, sao nhỏ trôi chậm ----------
   Chỉ transform/opacity, ít phần tử . */
.sky { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
/* ảnh dải ngân hà (Midjourney, tests/make_sky_image.py: ngang cho máy tính, dọc cho điện thoại, chọn bằng <picture> trong index.html); cả lớp
   trôi/nghiêng/phóng chậm để dải di chuyển thấy được. scale ≥1.14 để góc không hở khi xoay + trôi; giữ mức phóng thấp cho ảnh nét.
   Giảm chuyển động: quy tắc prefers-reduced-motion cuối file tắt hoạt ảnh, ảnh đứng yên. */
.sky-img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; transform: scale(1.14); animation: milky-flow 34s ease-in-out infinite alternate; }
@keyframes milky-flow { from { transform: scale(1.14) translate(-2.5%, 2%) rotate(-1.8deg); } to { transform: scale(1.22) translate(2.5%, -2%) rotate(1.8deg); } }
.sky i { position: absolute; left: var(--x); top: var(--y); width: var(--s, 3px); height: var(--s, 3px); border-radius: 50%; background: #fff; box-shadow: 0 0 8px 2px var(--glow); opacity: .45; animation: twinkle var(--t, 4s) ease-in-out var(--d, 0s) infinite; }
/* sao lớn: lõi trắng, quầng rộng, tia 4 cánh */
.sky i.star-lg { --s: 5px; box-shadow: 0 0 14px 4px var(--glow), 0 0 30px 8px rgba(194, 232, 245, .25); }
.sky i.star-lg::before, .sky i.star-lg::after { content: ""; position: absolute; left: 50%; top: 50%; background: linear-gradient(90deg, transparent, var(--accent-hi), transparent); transform: translate(-50%, -50%); }
.sky i.star-lg::before { width: 26px; height: 1.5px; }
.sky i.star-lg::after { width: 1.5px; height: 26px; background: linear-gradient(transparent, var(--accent-hi), transparent); }
.sky b { position: absolute; left: var(--x); bottom: -40px; font: 400 var(--s, 16px)/1 var(--f-body); color: var(--accent-hi); opacity: 0; animation: drift var(--t, 30s) linear var(--d, 0s) infinite; }
.sky b::before { content: "✦"; }
@keyframes twinkle { 0%, 100% { opacity: .3; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.3); } }
@keyframes drift {
  0% { opacity: 0; transform: translate(0, 0); }
  8%, 85% { opacity: .22; }
  100% { opacity: 0; transform: translate(var(--sway, 20px), -112vh); }
}
/* lớp bọc ảnh nền: fx.js đặt --px/--py (nền xê dịch theo con trỏ hoặc nghiêng máy). Riêng lớp này mới có transform xê dịch, còn .sky-img giữ animation milky-flow của nó */
.sky-par { position: absolute; inset: 0; transform: translate3d(var(--px, 0px), var(--py, 0px), 0); }
/* sao băng: vệt sáng 2 px, đầu sáng ở bên phải rồi xoay 145° nên đầu hướng xuống bên trái; fx.js thả một vệt rồi dọn khi animationend */
.meteors { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; }
.meteor { position: absolute; left: var(--x); top: var(--y); width: var(--len, 140px); height: 2px; border-radius: 2px; opacity: 0;
  background: linear-gradient(90deg, transparent, rgba(227, 245, 251, .85) 82%, #fff); box-shadow: 0 0 8px 1px var(--glow); animation: meteor 1.3s ease-in forwards; }
@keyframes meteor { 0% { opacity: 0; transform: rotate(145deg) translateX(0); } 12% { opacity: 1; } 100% { opacity: 0; transform: rotate(145deg) translateX(520px); } }
/* hạt tim/sao (fx.js: tim khi chạm logo/nền): opacity 0 làm nền để khi tắt hoạt ảnh (giảm chuyển động) không có gì hiện ra */
.fx-layer { position: fixed; inset: 0; z-index: 30; pointer-events: none; overflow: hidden; }
.fx-p { position: absolute; left: var(--x); top: var(--y); font: 400 var(--s, 16px)/1 var(--f-body); color: var(--accent-hi); text-shadow: 0 0 8px var(--glow); opacity: 0; animation: fx-pop var(--dur, 1.6s) cubic-bezier(.2, .7, .3, 1) forwards; }
@keyframes fx-pop { 0% { opacity: 0; transform: translate(-50%, -50%) scale(.4); } 15% { opacity: 1; } 100% { opacity: 0; transform: translate(calc(-50% + var(--dx, 0px)), calc(-50% + var(--dy, -120px))) scale(1.1) rotate(var(--r, 0deg)); } }
/* hạt bung ra khi dịch xong: xen kẽ hồng, xanh baby, đào */
.fx-spark:nth-child(3n+2) { color: var(--accent-hi); text-shadow: 0 0 8px var(--glow); }
.fx-spark:nth-child(3n) { color: var(--peach); text-shadow: 0 0 8px rgba(243, 201, 184, .6); }
/* câu dịch hiện dần như đang gõ: chữ có đủ trong DOM, clip-path quét từ trái sang phải theo từng bước (app.js: FX.typeIn đặt --n, --type-ms).
   fit-content để câu ngắn không phải quét cả bề ngang khung; tắt hoạt ảnh (giảm chuyển động) thì clip-path không còn, chữ hiện đủ */
.typed { width: fit-content; max-width: 100%; animation: type-in var(--type-ms, 1s) steps(var(--n, 20), end) backwards; }
@keyframes type-in { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0 0 0 0); } }
.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(--muted); }  /* --muted (không phải --dim): đọc được cả khi nằm trên dải ngân hà */
.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); }
/* nhấn nút: thu nhỏ nhẹ rồi nảy lại */
.run, .btn, .gear, .tabs button, .seg label, .seg2 label, .linkbtn { transition: transform .14s cubic-bezier(.3, 1.6, .5, 1), filter .15s, box-shadow .2s, background-color .2s, border-color .2s, color .2s; }
.run:active, .btn:active:not(:disabled), .gear:active, .tabs button:active, .seg label:active, .seg2 label:active { transform: scale(.95); }
.run:active { filter: brightness(.95); }
.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); }
.tierbox { display: grid; gap: 6px; }
.tierbox .hint { margin: 0; text-align: center; }
.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, 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; }
.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; }
/* đang chờ AI/OCR (app.js: setStatus(..., busy)): viên thuốc xanh nhạt, ngôi sao nhấp nháy thay chấm tĩnh */
.status[data-busy] { padding: 9px 16px 9px 12px; border-radius: 999px; background: rgba(194, 232, 245, .08); border: 1px solid rgba(194, 232, 245, .28); color: var(--ink); }
.status[data-busy]::before { content: "✦"; width: auto; height: auto; border-radius: 0; background: none; box-shadow: none; font-size: 17px; line-height: 1; color: var(--accent-hi); text-shadow: 0 0 10px var(--glow); animation: busy-twinkle 1.4s ease-in-out infinite; }
@keyframes busy-twinkle { 0%, 100% { transform: scale(.85) rotate(0deg); opacity: .7; } 50% { transform: scale(1.25) rotate(45deg); opacity: 1; } }
.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; }
/* thẻ học bài: dùng chung cho từ vựng (.words) và từng dòng Hàn/Việt (.pairs: tab Chữ); vạch màu bên trái, hồng = có dạng gốc khác (data-infl) */
.pairs li, .words li, .grammar li { position: relative; overflow: hidden; display: grid; align-content: start; gap: 3px; min-width: 0; padding: 12px 14px 12px 17px; border-radius: 18px;
  background: linear-gradient(160deg, rgba(194, 232, 245, .09), rgba(6, 10, 24, .72) 55%); border: 1px solid rgba(194, 232, 245, .16); }
.pairs li::before, .words li::before, .grammar li::before { content: ""; position: absolute; left: 0; top: 14px; bottom: 14px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent); box-shadow: 0 0 10px var(--glow); }
.words li[data-infl] { border-color: rgba(247, 168, 196, .3); background: linear-gradient(160deg, rgba(247, 168, 196, .10), rgba(6, 10, 24, .72) 55%); }
.words li[data-infl]::before { background: var(--rose); box-shadow: 0 0 10px rgba(247, 168, 196, .5); }
.pairs .ko { font: 600 19px/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 .ko { font: 700 26px/1.2 var(--f-body); color: var(--title); overflow-wrap: anywhere; }
.words .rom { font: 400 12px/1.4 var(--f-mono); color: var(--accent); letter-spacing: .05em; overflow-wrap: anywhere; }
.words .vi { margin-top: 4px; font-size: 15px; line-height: 1.35; color: var(--ink); }
.words .lemma { justify-self: start; margin-top: 4px; padding: 2px 9px; border-radius: 999px; background: rgba(247, 168, 196, .13); color: var(--rose); font: 400 12px/1.4 var(--f-mono); overflow-wrap: anywhere; }
.words .rom:empty, .words .lemma:empty { display: none; }
/* khung xương trong lúc lấy từ vựng (div .sk-words, app.js bật/tắt bằng hidden) */
.sk-words i { position: relative; overflow: hidden; height: 118px; border-radius: 18px; background: rgba(6, 10, 24, .65); border: 1px solid rgba(194, 232, 245, .1); }
.sk-words i::after { content: ""; position: absolute; inset: 0; background: linear-gradient(100deg, transparent 20%, rgba(194, 232, 245, .14) 50%, transparent 80%); transform: translateX(-100%); animation: shimmer 1.5s ease-in-out infinite; }
.sk-words i:nth-child(2)::after { animation-delay: .15s; }
.sk-words i:nth-child(3)::after { animation-delay: .3s; }
.sk-words i:nth-child(4)::after { animation-delay: .45s; }
@keyframes shimmer { to { transform: translateX(100%); } }

/* ---------- ngữ pháp (nút "Giải thích ngữ pháp", tab Ảnh và tab Chữ): mẫu, đoạn trong câu, nghĩa, ví dụ ---------- */
#grammarGo, #tGrammarGo { width: 100%; }
.grammar-box .hint { margin: 0 0 8px; }
.grammar { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.grammar .gp { font: 700 21px/1.3 var(--f-body); color: var(--title); overflow-wrap: anywhere; }
.grammar .gf { justify-self: start; padding: 2px 9px; border-radius: 999px; background: rgba(194, 232, 245, .12); color: var(--accent); font: 400 14px/1.4 var(--f-body); overflow-wrap: anywhere; }
.grammar .gm { margin-top: 2px; font-size: 15px; line-height: 1.4; color: var(--ink); }
.grammar .gx { display: grid; gap: 1px; margin-top: 4px; padding-left: 10px; border-left: 2px solid rgba(247, 168, 196, .45); }
.grammar .gx .ko { font: 600 16px/1.4 var(--f-body); color: var(--title); }
.grammar .gx .vi { font-size: 14px; line-height: 1.4; color: var(--muted); }

/* kết quả hiện mượt: khung trượt lên + mờ dần vào, các thẻ hiện lần lượt (--i do app.js đặt).
   fill-mode backwards: tắt hoạt ảnh (prefers-reduced-motion) thì mọi thứ vẫn hiện đủ */
#viewer, #result, #tResult { animation: rise .55s cubic-bezier(.2, .8, .2, 1) backwards; }
.words li, #tLines li, .grammar li { animation: rise .45s cubic-bezier(.2, .8, .2, 1) backwards; animation-delay: calc(var(--i, 0) * 45ms); }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }

/* chuyển tab: màn mới mờ vào + trượt nhẹ; chỉ là hoạt ảnh vào (màn đã hiện ngay), nên Tabs.show không chậm; .enter do showScreen bật lại mỗi lần */
.screen.enter { animation: screen-in .3s cubic-bezier(.2, .8, .2, 1) backwards; }
@keyframes screen-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

/* lời chào theo giờ máy, trên màn chính */
.greet { margin: 2px 0 12px; font: 700 15px/1.3 var(--f-word); color: var(--title); }
.greet:empty { display: none; }

/* ---------- nghe phát âm (speech.js), thẻ từ vựng lật (app.js: flipCard), từ của ngày ---------- */
/* Nút nghe chỉ hiện khi trình duyệt có giọng Hàn: speech.js đặt data-tts trên <html> */
.speak { display: inline-grid; place-items: center; width: 36px; height: 36px; padding: 0; border-radius: 50%; border: 1px solid rgba(194, 232, 245, .28); background: rgba(6, 10, 24, .7); color: var(--accent-hi); cursor: pointer; vertical-align: middle; }
.speak svg { width: 18px; height: 18px; }
.speak:hover { border-color: var(--accent); }
.speak:active { transform: scale(.92); }
html:not([data-tts]) .speak { display: none; }
.words li .speak, .pairs li .speak { position: absolute; top: 8px; right: 8px; z-index: 2; }  /* span.ko không định vị nên nút tính theo li */
.words .ko, .pairs .ko { padding-right: 40px; }
.caption .speak { margin-left: 8px; }
/* nút đọc to cả đoạn (tiêu đề "Nguyên văn" / "Từng dòng"): hai biểu tượng, aria-pressed=true thì hiện nút dừng */
.speak-all .i-stop, .speak-all[aria-pressed="true"] .i-play { display: none; }
.speak-all[aria-pressed="true"] .i-stop { display: block; fill: currentColor; }
.speak-all[aria-pressed="true"] { border-color: var(--accent); }
/* Thẻ lật: mặc định mặt Hàn (nghĩa, phiên âm, chip dạng gốc ẩn bằng visibility, vẫn chiếm chỗ nên thẻ không đổi cao khi lật); li.turn xoay 90° rồi app.js đổi mặt */
.words li { cursor: pointer; transition: transform .16s ease-in; }
.words li.turn { transform: perspective(700px) rotateY(90deg); }
.words li:not([data-flip]) :is(.rom, .vi, .lemma) { visibility: hidden; }
.words li::after { content: "↻"; position: absolute; right: 13px; bottom: 8px; font-size: 15px; line-height: 1; color: var(--accent); opacity: .55; }
.flip { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; padding: 0; border: 0; border-radius: 18px; background: none; cursor: pointer; }
.flip:focus-visible { outline: 2px solid var(--accent-hi); outline-offset: -3px; }
/* Từ của ngày (tab Ảnh, dưới lời chào) */
.wotd { display: grid; gap: 4px; padding: 14px 16px; border-radius: 20px; background: linear-gradient(160deg, rgba(247, 168, 196, .10), rgba(14, 22, 48, .66) 55%); border: 1px solid rgba(247, 168, 196, .28); }
.wotd .label { color: var(--rose); }
.wotd-main { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.wotd .ko { font: 700 30px/1.2 var(--f-body); color: var(--title); overflow-wrap: anywhere; }
.wotd .rom { font: 400 12.5px/1.4 var(--f-mono); color: var(--accent); letter-spacing: .05em; }
.wotd .vi { font-size: 16px; color: var(--ink); }

/* ---------- 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); }

/* ---------- lịch sử ---------- */
.hist { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.hist:empty { display: none; }
.hist li { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: center; border-radius: 18px; min-width: 0;
  background: linear-gradient(160deg, rgba(194, 232, 245, .09), rgba(6, 10, 24, .72) 55%); border: 1px solid rgba(194, 232, 245, .16); }
.hist-open { display: grid; grid-template-columns: 56px minmax(0, 1fr); gap: 12px; align-items: center; min-width: 0; padding: 10px 4px 10px 10px;
  background: none; border: 0; color: inherit; text-align: left; font: inherit; cursor: pointer; }
.hist-thumb { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; background: rgba(6, 10, 24, .8); border: 1px solid var(--edge); }
.hist-txt { display: grid; place-items: center; font: 600 24px/1 var(--f-body); color: var(--accent); }
.hist-body { display: grid; gap: 3px; min-width: 0; }
.hist-body > span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hist-body .ko { font: 600 17px/1.35 var(--f-body); color: var(--title); }
.hist-body .vi { font-size: 14px; color: var(--ink); }
.hist-body .when { font-size: 12px; color: var(--muted); }
.hist-del { width: 44px; height: 44px; margin-right: 6px; display: grid; place-items: center; border: 0; border-radius: 22px; background: none; color: var(--muted); cursor: pointer; }
.hist-del:hover, .hist-del:focus-visible { color: var(--rose); background: rgba(247, 168, 196, .1); }
.hist-del svg { width: 20px; height: 20px; }
.switch { display: flex; align-items: center; gap: 12px; font-size: 15px; color: var(--ink); cursor: pointer; }
.switch input { width: 22px; height: 22px; flex: none; accent-color: var(--accent); }

/* ---------- 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) { *, *::before, *::after { animation: none !important; transition: none !important; } }  /* ::before/::after: sao chờ, vệt sáng khung xương */

/* chữ nhỏ nằm trên nền nhiều sao: bóng tối nhẹ cho dễ đọc */
.welcome h1 small, .kicker, .hint, .big .limit { text-shadow: 0 0 6px rgba(4, 7, 18, .95), 0 1px 3px rgba(4, 7, 18, .9); }

/* màn chào dễ đọc hơn trên nền nhiều sao: tấm mờ tối mềm sau cột chữ, chữ nhỏ sáng hơn --muted, chữ gợi ý trong ô nhập rõ hơn */
.welcome::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none; background: radial-gradient(ellipse 62% 56% at 50% 52%, rgba(3, 6, 16, .72), rgba(3, 6, 16, .38) 55%, transparent 80%); }
.welcome h1 small, .welcome .kicker { color: #D3E1F2; }
.welcome .kicker { font-weight: 500; }
.welcome .hint { color: #C3D2E8; font-size: 13.5px; font-weight: 500; }
.codebox input::placeholder { color: #A9BAD3; opacity: 1; }
.big .limit { color: var(--muted); }

/* dòng "Developed by" cuối trang; footer ngoài <main> chỉ hiện ở tab Ảnh và Chữ (Cài đặt có khung đầy đủ, màn chào có dòng riêng) */
.credit { margin: 22px 16px 0; text-align: center; font: 500 12.5px/1.4 var(--f-body); letter-spacing: .04em; color: #CBD8EA; text-shadow: 0 0 6px rgba(4, 7, 18, .95), 0 1px 3px rgba(4, 7, 18, .9); }
.credit strong { color: var(--ink); font-weight: 600; }
/* khung liên hệ ở màn chào: cùng kiểu khung "Developed by" của Cài đặt, rộng bằng cột nhập mã, chữ căn trái */
.welcome .dev { width: 100%; max-width: 340px; margin-top: 10px; text-align: left; }
body[data-screen="welcome"] > .credit, body[data-screen="settings"] > .credit { display: none; }

/* sau đăng nhập: ảnh nền tối hơn (màn chào giữ nguyên độ sáng) để chữ và khung đọc rõ; chuyển mượt khi đổi màn */
.sky-img { transition: opacity .5s ease; }
body:not([data-screen="welcome"]) .sky-img { opacity: .5; }
body:not([data-screen="welcome"]) .hint, body:not([data-screen="welcome"]) .small, body:not([data-screen="welcome"]) .limit { color: #C3D2E8; text-shadow: 0 0 6px rgba(4, 7, 18, .95), 0 1px 3px rgba(4, 7, 18, .9); }
