/* Tanro Dictionary — màu đỏ son của con dấu Nhật, nền giấy ấm */
:root {
  --bg: #faf8f4; --surface: #ffffff; --surface-2: #f3efe8; --text: #1f1d1a; --muted: #6f6a62;
  --line: #e7e1d7; --accent: #c2410c; --accent-2: #ef4444; --accent-soft: #fdeee6;
  --en: #2563eb; --ja: #c2410c; --vi: #15803d; --shadow: 0 1px 2px rgba(40,30,20,.05), 0 8px 24px rgba(40,30,20,.06);
  --radius: 16px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; color-scheme: light; }
body { margin: 0; background: var(--bg); color: var(--text);
       font: 16px/1.65 "Be Vietnam Pro", system-ui, "Segoe UI", "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", sans-serif; }
[lang="ja"] { font-family: "Noto Sans JP", "Hiragino Sans", "Yu Gothic UI", "Meiryo", sans-serif; }
a { color: var(--accent); text-underline-offset: 2px; }
h1, h2, h3 { line-height: 1.25; }
.wrap { max-width: 960px; margin: 0 auto; padding: 0 16px; }
.muted { color: var(--muted); }
.skip { position: absolute; left: -999px; } .skip:focus { left: 16px; top: 8px; z-index: 9; background: var(--surface); padding: 8px 12px; border-radius: 8px; }

/* ---------- Thanh trên ---------- */
.top { position: sticky; top: 0; z-index: 5; background: color-mix(in srgb, var(--surface) 88%, transparent);
       backdrop-filter: saturate(1.4) blur(10px); border-bottom: 1px solid var(--line); }
.top-in { display: flex; align-items: center; gap: 12px 24px; padding-top: 10px; padding-bottom: 10px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 10px; text-decoration: none; color: var(--text); flex-shrink: 0; }
.brand-text { display: inline-flex; flex-direction: column; line-height: 1; font-size: 20px; letter-spacing: -.01em; }
.brand-text b { font-weight: 800; color: var(--accent); }
/* "Dictionary" nằm dưới "Tanro", nhỏ và giãn chữ để logo hẹp, không đụng ô tìm */
.brand-text small { margin-top: 3px; font-size: .5em; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }

/* ---------- Ô tìm ---------- */
.search { position: relative; display: flex; align-items: center; gap: 6px; flex: 1 1 420px; min-width: 0;
          background: var(--surface); border: 1.5px solid var(--line); border-radius: 999px; padding: 4px 4px 4px 14px; transition: border-color .15s, box-shadow .15s; }
.search:focus-within { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft); }
.search-ico { width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex-shrink: 0; }
.search input { flex: 1; min-width: 0; border: 0; background: none; color: var(--text); font: inherit; padding: 8px 4px; outline: none; }
.search select { border: 0; background: var(--surface-2); color: var(--muted); font: inherit; font-size: 14px; padding: 7px 10px; border-radius: 999px; cursor: pointer; }
.search button { display: inline-flex; align-items: center; gap: 6px; border: 0; background: var(--accent); color: #fff; font: inherit; font-size: 15px; font-weight: 600; padding: 8px 16px; border-radius: 999px; cursor: pointer; white-space: nowrap; }
.search button:hover { filter: brightness(1.08); }
.search-big { padding: 6px 6px 6px 18px; box-shadow: var(--shadow); max-width: 720px; margin: 0 auto; }
.search-big input { font-size: 18px; padding: 10px 6px; }
.search-big button { padding: 10px 20px; font-size: 15.5px; }
.suggest { position: absolute; top: calc(100% + 6px); left: 0; right: 0; margin: 0; padding: 6px; list-style: none; z-index: 6;
           background: var(--surface); border: 1px solid var(--line); border-radius: 14px; box-shadow: var(--shadow); text-align: left; }
.suggest li { display: flex; justify-content: space-between; gap: 12px; padding: 8px 12px; border-radius: 10px; cursor: pointer; }
.suggest li small { color: var(--muted); }
.suggest li:hover, .suggest li.on { background: var(--surface-2); }

/* ---------- Trang chủ ---------- */
.hero { text-align: center; padding: 56px 0 28px; }
.hero h1 { font-size: clamp(30px, 5.5vw, 48px); margin: 0 0 14px; letter-spacing: -.02em; }
.hl { background: linear-gradient(90deg, var(--accent-2), var(--accent)); -webkit-background-clip: text; background-clip: text; color: transparent; }
.lead { color: var(--muted); font-size: 18px; max-width: 640px; margin: 0 auto 28px; }
.try { margin-top: 16px; color: var(--muted); font-size: 15px; }
.try a { display: inline-block; margin: 4px 3px; padding: 3px 12px; border: 1px solid var(--line); border-radius: 999px; text-decoration: none; color: var(--text); background: var(--surface); }
.try a:hover { border-color: var(--accent); color: var(--accent); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 20px 0 28px; }
.stats div { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px; text-align: center; }
.stats b { display: block; font-size: 26px; color: var(--accent); }
.stats span { color: var(--muted); font-size: 14px; }
.home-grid { display: grid; grid-template-columns: 1.6fr 1fr; gap: 16px; }
.card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.card h2 { margin: 0 0 12px; font-size: 19px; }
.tag-title { margin: 14px 0 8px; }
.pills { display: flex; flex-wrap: wrap; gap: 8px; }
.pill { padding: 5px 14px; border-radius: 999px; background: var(--surface-2); color: var(--text); text-decoration: none; font-size: 15px; }
.pill:hover { background: var(--accent-soft); color: var(--accent); }
.kd { display: flex; gap: 18px; align-items: center; }
.kd-char { font-size: 76px; line-height: 1; width: 108px; height: 108px; display: grid; place-items: center; border-radius: 18px;
           background: var(--accent-soft); color: var(--accent); flex-shrink: 0; }
.kd p { margin: 0 0 6px; }
.kd-hv { font-size: 22px; font-weight: 800; letter-spacing: .04em; }
.more { display: inline-block; margin-top: 12px; font-weight: 600; text-decoration: none; }
.features { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; margin: 28px 0 8px; }
.feat { padding: 4px 4px; }
.feat h3 { font-size: 17px; margin: 0 0 6px; }
.feat p { margin: 0; color: var(--muted); font-size: 15px; }

/* ---------- Kết quả ---------- */
main { padding-top: 24px; padding-bottom: 56px; min-height: 60vh; }
.result-head h1 { font-size: 24px; margin: 4px 0 2px; }
.result-head p { margin: 0 0 18px; }
.crumbs { font-size: 14px; color: var(--muted); margin: 16px 0 8px; }
.crumbs a { color: var(--muted); }
.word-title { font-size: clamp(26px, 4vw, 34px); margin: 0 0 6px; }
.word-lead { margin: 0 0 20px; text-align: left; max-width: none; font-size: 16px; }
.results { display: grid; gap: 16px; }
.entry { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px 22px; box-shadow: var(--shadow); }
.entry-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: flex-start; gap: 8px 16px; margin-bottom: 6px; }
.entry-word { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; }
.entry h2 { margin: 0; font-size: 30px; font-weight: 700; }
.entry h2 a { color: var(--text); text-decoration: none; } .entry h2 a:hover { color: var(--accent); }
.reading { font-size: 19px; color: var(--muted); }
.entry-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.tag { font-size: 12px; font-weight: 600; padding: 2px 10px; border-radius: 999px; letter-spacing: .01em; }
.tag-en { color: var(--en); background: color-mix(in srgb, var(--en) 11%, transparent); }
.tag-ja { color: var(--ja); background: color-mix(in srgb, var(--ja) 11%, transparent); }
.tag-vi { color: var(--vi); background: color-mix(in srgb, var(--vi) 11%, transparent); }
.chip { font-size: 13px; padding: 2px 10px; border-radius: 999px; background: var(--surface-2); color: var(--muted); }
.chip-ok { color: var(--vi); background: color-mix(in srgb, var(--vi) 12%, transparent); }
.chip-hv b { color: var(--text); letter-spacing: .03em; }
.ipa { color: var(--muted); font-size: 15px; }
.speak { border: 1px solid var(--line); background: var(--surface); border-radius: 999px; width: 32px; height: 32px; display: grid; place-items: center; cursor: pointer; padding: 0; }
.speak svg { width: 17px; height: 17px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.speak:hover { background: var(--accent-soft); }
.sense-group h3 { margin: 16px 0 6px; font-size: 12px; text-transform: uppercase; letter-spacing: .08em; color: var(--muted); font-weight: 700; }
.senses { margin: 0; padding-left: 22px; }
.senses li { padding: 3px 0; }
.senses li::marker { color: var(--muted); font-size: 14px; }
.pos { display: inline-block; font-size: 12px; padding: 0 7px; margin-right: 4px; border-radius: 5px; background: var(--surface-2); color: var(--muted); vertical-align: 2px; }
.src { font-size: 11px; color: var(--muted); opacity: .75; margin-left: 4px; white-space: nowrap; }
.src-ai { display: inline-flex; vertical-align: -2px; margin-left: 6px; color: #d97706; cursor: help; }
.src-ai svg { width: 16px; height: 16px; fill: currentColor; }
.examples { margin: 0; padding: 0; list-style: none; display: grid; gap: 8px; }
.examples li { padding: 8px 12px; border-left: 3px solid var(--accent-soft); background: var(--surface-2); border-radius: 0 10px 10px 0; }
.ex-tr { display: block; color: var(--muted); font-size: 15px; }
.kanji { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 10px; }
.k { display: flex; gap: 12px; border: 1px solid var(--line); border-radius: 12px; padding: 10px 12px; }
.k-char { font-size: 40px; line-height: 1; width: 60px; height: 60px; display: grid; place-items: center; background: var(--surface-2); border-radius: 10px; flex-shrink: 0; }
.k-info { display: flex; flex-direction: column; font-size: 14px; min-width: 0; }
.k-info b { font-size: 15px; letter-spacing: .03em; }
.k-mean, .k-stat { color: var(--muted); }
.related { margin-top: 20px; }
.empty { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 24px; }
.ad { margin: 4px 0; min-height: 100px; }

/* ---------- Trang tĩnh ---------- */
.prose { max-width: 760px; }
.prose h1 { font-size: 32px; margin: 4px 0 16px; }
.prose h2 { font-size: 21px; margin: 28px 0 8px; }
.prose li { margin: 4px 0; }
.tbl { width: 100%; border-collapse: collapse; margin: 8px 0 16px; font-size: 15px; }
.tbl th, .tbl td { text-align: left; padding: 9px 12px; border-bottom: 1px solid var(--line); vertical-align: top; }
.tbl th { background: var(--surface-2); }
code { background: var(--surface-2); padding: 1px 6px; border-radius: 5px; font-size: .92em; }
.contact-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 20px; }
.contact-card p { margin: 4px 0; }
.sources { display: grid; gap: 12px; max-width: 760px; margin-top: 8px; }
.sources h2 { font-size: 18px; }
.sources p { margin: 4px 0; }

/* ---------- Chân trang ---------- */
.foot { border-top: 1px solid var(--line); background: var(--surface); padding: 32px 0 20px; }
.foot-in { display: grid; grid-template-columns: 2fr 1fr 1fr; gap: 24px; }
.foot-brand p { color: var(--muted); margin: 8px 0 0; font-size: 15px; }
.foot-nav { display: flex; flex-direction: column; gap: 6px; }
.foot-nav a { color: var(--text); text-decoration: none; font-size: 15px; }
.foot-nav a:hover { color: var(--accent); }
.copy { color: var(--muted); font-size: 13px; margin-top: 24px; }
.cookie { position: fixed; left: 16px; right: 16px; bottom: 16px; z-index: 10; max-width: 640px; margin: 0 auto; display: flex; align-items: center; gap: 14px;
          background: var(--text); color: var(--bg); border-radius: 14px; padding: 12px 14px 12px 18px; box-shadow: var(--shadow); }
.cookie[hidden] { display: none; }
.cookie p { margin: 0; font-size: 14px; flex: 1; }
.cookie a { color: inherit; }
.cookie button { border: 0; background: var(--accent); color: #fff; font: inherit; font-weight: 600; border-radius: 999px; padding: 8px 16px; cursor: pointer; }

@media (max-width: 760px) {
  .home-grid, .features, .foot-in { grid-template-columns: 1fr; }
  .stats { grid-template-columns: 1fr 1fr 1fr; } .stats b { font-size: 20px; } .stats span { font-size: 12px; }
  .hero { padding-top: 32px; }
  .top-in { gap: 10px; }
  .top .search { flex-basis: 100%; }
}
@media (max-width: 520px) {
  .search select { max-width: 96px; font-size: 12px; padding: 7px 6px; }
  .search button { padding: 8px 14px; }
  .entry { padding: 16px; }
  .entry h2 { font-size: 26px; }
  .kd-char { width: 84px; height: 84px; font-size: 58px; }
}

/* ---------- Thanh xem / thích / chia sẻ (trang từ) ---------- */
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 0 0 18px; }
.act { display: inline-flex; align-items: center; gap: 6px; font: inherit; font-size: 14px; color: var(--muted);
       padding: 6px 14px; border-radius: 999px; border: 1px solid var(--line); background: var(--surface); }
.act b { color: var(--text); font-weight: 700; }
.act svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
button.act { cursor: pointer; }
button.act:hover { border-color: var(--accent); color: var(--accent); }
.act-like.on { color: var(--accent-2); border-color: var(--accent-2); background: color-mix(in srgb, var(--accent-2) 10%, var(--surface)); }
.act-like.on svg { fill: currentColor; }
.act-like.on b { color: var(--accent-2); }
.act-view { border-color: transparent; background: none; padding-left: 0; }
.share-wrap { position: relative; }
.share-menu { position: absolute; z-index: 4; top: calc(100% + 6px); left: 0; min-width: 220px; padding: 6px; display: grid;
              background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); }
.share-menu[hidden] { display: none; }
.share-menu a, .share-menu button { text-align: left; font: inherit; font-size: 15px; color: var(--text); text-decoration: none;
              background: none; border: 0; padding: 8px 12px; border-radius: 8px; cursor: pointer; }
.share-menu a:hover, .share-menu button:hover { background: var(--surface-2); }
.share-menu small { color: var(--muted); }
.trend-meta { color: var(--muted); font-size: 12px; margin-left: 4px; }
.note p { margin: 0 0 10px; line-height: 1.65; }
.note-rel { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.note-rel b { margin-right: 4px; }

/* ---------- Thanh trên: liên kết trang ---------- */
.top-nav { display: flex; gap: 22px; margin-left: auto; font-size: 15px; }
.top-nav a { color: var(--text); text-decoration: none; }
.top-nav a:hover { color: var(--accent); }
@media (max-width: 760px) { .top-nav { display: none; } }

/* ---------- Trang chủ ---------- */
.home main.wrap { max-width: 1080px; }
.hx { position: relative; width: 100vw; margin-left: calc(50% - 50vw); margin-top: -1px; overflow: hidden;
      background: #fbf3ea; color: #1f1d1a; }
.hx-bg { position: absolute; inset: 0 0 0 40%; }
.hx-img { position: absolute; inset: 0; background: var(--img) center / cover no-repeat; opacity: 0; transition: opacity 1.6s ease;
          -webkit-mask-image: linear-gradient(to right, transparent 0, rgba(0,0,0,.35) 25%, #000 55%); mask-image: linear-gradient(to right, transparent 0, rgba(0,0,0,.35) 25%, #000 55%); }
.hx-img.on { opacity: 1; }
.hx-in { position: relative; max-width: 1080px; padding-top: 64px; padding-bottom: 44px; }
.hx-title { font-weight: 800; font-size: clamp(34px, 5vw, 56px); line-height: 1.12;
            letter-spacing: -.03em; margin: 0 0 18px; }
.hx-title span { color: #c2410c; }
.hx-lead { font-size: clamp(17px, 2vw, 21px); color: #4a4540; margin: 0 0 30px; max-width: 34em; }
.hx .search { margin: 0; max-width: 700px; padding: 8px 8px 8px 22px; border: 0; box-shadow: 0 10px 30px rgba(80,40,10,.12); background: #fff; }
.hx .search input { font-size: 17px; padding: 12px 6px; color: #1f1d1a; }
.hx .search select { background: #f3efe8; color: #4a4540; }
.hx .search button { padding: 11px 22px; font-size: 16px; }
.hx-try { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin: 18px 0 0; max-width: 820px; font-size: 15px; color: #4a4540; }
.hx-try > span { margin-right: 4px; }
.hx-dirs { border-top: 1px solid rgba(80,40,10,.12); padding-top: 16px; }
.chip-a { padding: 6px 15px; border-radius: 999px; background: rgba(255,255,255,.88); border: 1px solid #ebe3d8; color: #1f1d1a;
          text-decoration: none; backdrop-filter: blur(4px); }
.chip-a:hover { border-color: #c2410c; color: #c2410c; }
.hx-card { position: absolute; right: 16px; bottom: 44px; display: flex; flex-direction: column; gap: 2px; min-width: 190px;
           padding: 18px 22px; border-radius: 16px; background: rgba(255,255,255,.72); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px); box-shadow: 0 12px 32px rgba(40,20,5,.18);
           color: #1f1d1a; text-decoration: none; transition: opacity .5s; }
.hx-card.fade { opacity: 0; }
.hx-dir { display: flex; align-items: center; gap: 6px; color: #c2410c; font-weight: 600; font-size: 14px; }
.hx-dir svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.hx-word { font-size: 30px; font-weight: 700; line-height: 1.3; }
.hx-sub { font-size: 17px; color: #4a4540; }
.hx-mean { color: #6f6a62; font-size: 15px; }

.hx-stats { display: grid; grid-template-columns: repeat(3, 1fr); margin: 0 0 28px; padding: 22px 0; border-bottom: 1px solid var(--line); }
.hx-stats > div { display: flex; align-items: center; justify-content: center; gap: 16px; }
.hx-stats > div + div { border-left: 1px solid var(--line); }
.hx-stats i, .hx-feats i { flex-shrink: 0; width: 58px; height: 58px; border-radius: 50%; display: grid; place-items: center;
            background: var(--accent-soft); color: var(--accent); font-style: normal; }
.hx-stats i svg, .hx-feats i svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.hx-stats i.t { font-size: 26px; font-family: "Noto Sans JP", sans-serif; }
.hx-stats p { margin: 0; line-height: 1.2; }
.hx-stats b { display: block; font-size: 30px; color: var(--accent); }
.hx-stats span { color: var(--muted); }

.hx-grid { display: grid; grid-template-columns: 1.75fr 1fr; gap: 18px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; }
.card-head h2 { display: flex; align-items: center; gap: 10px; margin: 0; font-size: 21px; line-height: 1.2; }
.card-head .more { font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.explore-cols { display: grid; grid-template-columns: repeat(3, 1fr); }
.explore-cols > div { padding: 0 16px; }
.explore-cols > div:first-child { padding-left: 0; }
.explore-cols > div + div { border-left: 1px solid var(--line); }
.explore-cols .tag { display: inline-block; margin-bottom: 8px; }
.explore-cols ul { list-style: none; margin: 0; padding: 0; }
.explore-cols li { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 9px 0; border-bottom: 1px solid var(--line); }
.explore-cols li:last-child { border-bottom: 0; }
.explore-cols li a { color: var(--text); text-decoration: none; font-weight: 500; font-size: 17px; }
.explore-cols li a:hover { color: var(--accent); }
.explore-cols li span { color: var(--muted); font-size: 13px; text-align: right; }
.kd-ico { display: inline-grid; place-items: center; width: 28px; height: 28px; border-radius: 6px; background: var(--accent); color: #fff;
          font-size: 16px; line-height: 1; font-family: "Noto Sans JP", sans-serif; }
.kanji-day .kd-char { background: var(--accent-soft); color: var(--accent); }
.kd-mean { border-top: 1px solid var(--line); padding-top: 12px; margin: 14px 0 8px; color: var(--muted); }
.kd-mean b, .kd b { color: var(--text); }
.trend { margin-top: 18px; }
.hx-feats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 18px; margin: 18px 0 8px; }
.hx-feats .feat { display: flex; gap: 16px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow); }
.hx-feats h3 { margin: 4px 0 6px; font-size: 17px; }
.hx-feats p { margin: 0; color: var(--muted); font-size: 14.5px; }

@media (max-width: 900px) {
  .hx-card { display: none; }
  .hx-grid, .hx-feats { grid-template-columns: 1fr; }
}
@media (max-width: 760px) {
  .hx-bg { inset: 0; }
  .hx-img { background-image: var(--img-sm); -webkit-mask-image: none; mask-image: none; }
  .hx-bg::after { content: ""; position: absolute; inset: 0; background: linear-gradient(rgba(251,243,234,.88), rgba(251,243,234,.95)); }
  .hx-in { padding-top: 36px; padding-bottom: 28px; }
  .hx .search { flex-wrap: wrap; border-radius: 22px; padding: 8px; }
  .hx .search input { flex: 1 1 100%; padding-left: 4px; }
  .hx .search select { flex: 0 1 auto; max-width: 62%; -webkit-appearance: none; appearance: none; font-size: 13px; padding: 7px 28px 7px 12px; border: 1px solid var(--line); background: #faf7f2 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' fill='none' stroke='%23857a6e' stroke-width='1.6' stroke-linecap='round'/%3E%3C/svg%3E") no-repeat right 11px center; text-overflow: ellipsis; }
  .hx .search button { flex: 0 0 auto; margin-left: auto; padding: 7px 14px; font-size: 14px; }
  .hx .search button svg { width: 14px; height: 14px; }
  .hx .search .search-ico { display: none; }
  .hx-stats { grid-template-columns: 1fr; gap: 14px; }
  .hx-stats > div { justify-content: flex-start; }
  .hx-stats > div + div { border-left: 0; }
  .explore-cols { grid-template-columns: 1fr; gap: 14px; }
  .explore-cols > div { padding: 0; }
  .explore-cols > div + div { border-left: 0; }
}

/* ---------- Trang từ ---------- */
.word-page main.wrap { max-width: 1080px; }
.w-layout { display: grid; grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr); gap: 24px; align-items: start; margin-top: 10px; }
.w-head { margin-bottom: 18px; }
.w-word { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 18px; margin: 6px 0 2px; font-size: clamp(44px, 7vw, 72px); font-weight: 800; letter-spacing: -.01em; line-height: 1.1; }
.w-read { font-size: .45em; font-weight: 400; color: var(--muted); }
.w-speak { width: 46px; height: 46px; }
.w-hv { margin: 0; font-size: 22px; font-weight: 700; letter-spacing: .08em; color: var(--muted); }
.w-ipa { margin: 0; color: var(--muted); }
.w-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-top: 14px; }
.w-bar .actions { margin: 0 0 0 auto; }
.w-lead { margin: 14px 0 0; color: var(--muted); font-size: 15px; }
.w-card { padding: 8px 28px 20px; }
.w-sec { padding-top: 18px; }
.w-sec + .w-sec { margin-top: 6px; }
.w-sec h2 { display: flex; align-items: center; gap: 10px; font-size: 20px; margin: 0 0 12px; }
.wi { width: 24px; height: 24px; flex-shrink: 0; fill: none; stroke: var(--accent); stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.w-senses { margin: 0; padding-left: 28px; }
.w-senses li { padding: 6px 0; font-size: 17px; }
.w-senses li::marker { color: var(--muted); }
.w-senses .pos { margin: 0 0 0 10px; }
.w-senses .src { margin-left: 8px; }
.w-usage p { margin: 0 0 10px; line-height: 1.75; }
.w-ex { list-style: none; counter-reset: ex; margin: 0; padding: 0; display: grid; gap: 10px; }
.w-ex li { counter-increment: ex; position: relative; background: var(--surface-2); border-radius: 12px; padding: 14px 16px 14px 62px; }
.w-ex li::before { content: counter(ex); position: absolute; left: 16px; top: 50%; transform: translateY(-50%); width: 32px; height: 32px;
                   border-radius: 50%; background: var(--surface); display: grid; place-items: center; font-weight: 700; font-size: 15px; }
.w-ex p { margin: 0; }
.w-ex-t { font-size: 18px; display: flex; align-items: center; gap: 6px; }
.w-ex-t .speak { flex-shrink: 0; }
.w-ex-t .speak { width: 28px; height: 28px; border: 0; background: none; vertical-align: -6px; }
.w-ex-tr { color: var(--muted); }
.w-others { font-size: 18px; margin: 26px 0 12px; }
.w-readings { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 8px; margin: 10px 0 2px; font-size: 14px; }
.w-readings-l { color: var(--muted); }
.w-rd { display: inline-flex; align-items: baseline; gap: 6px; padding: 4px 11px; border: 1px solid var(--line); border-radius: 999px; background: var(--surface); color: var(--text); text-decoration: none; }
.w-rd:hover { border-color: var(--accent); }
.w-rd b { font-weight: 700; }
.w-rd span { color: var(--muted); }
.w-rd i { font-style: normal; font-size: 12px; color: var(--muted); }
.w-rd i.ok { color: var(--vi); }
.w-rd.is-cur { border-color: var(--accent); background: var(--accent-soft); }
.w-rd.is-rare { opacity: .8; }
.chip-rare { color: var(--muted); background: var(--surface-2); }

.w-side { display: grid; gap: 18px; }
.w-art { margin: 0; border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow); aspect-ratio: 1 / 1; }
.w-photo img { display: block; width: 100%; height: 100%; object-fit: cover; }
.w-paper { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 6px; padding: 24px; text-align: center;
           background: radial-gradient(circle at 78% 22%, rgba(244,114,182,.22), transparent 38%),
                       radial-gradient(circle at 18% 85%, rgba(251,146,60,.20), transparent 42%), linear-gradient(160deg, #fdf3e7, #f8e4d2);
           color: #3b2a1e; aspect-ratio: 4 / 3; }
.w-paper-word { font-weight: 800; line-height: 1.1; overflow-wrap: anywhere; }
.w-paper-read { font-size: 22px; color: #7a5a44; }
.w-paper-hv { font-size: 15px; font-weight: 700; letter-spacing: .12em; color: #c2410c; }
.w-box h2 { display: flex; align-items: center; gap: 10px; font-size: 19px; }
.w-kanji { display: grid; grid-template-columns: 78px 1fr 18px; gap: 14px; align-items: center; padding: 14px; margin-top: 10px;
           border: 1px solid var(--line); border-radius: 12px; color: var(--text); text-decoration: none; }
.w-kanji:hover { border-color: var(--accent); }
.w-kanji-ch { font-size: 50px; line-height: 78px; text-align: center; background: var(--surface-2); border-radius: 10px; }
.w-kanji-info { display: flex; flex-direction: column; font-size: 14px; color: var(--muted); line-height: 1.55; }
.w-kanji-info b { color: var(--text); font-size: 16px; }
.go { width: 18px; height: 18px; fill: none; stroke: var(--accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.w-rel { list-style: none; margin: 0; padding: 0; }
.w-rel li + li { border-top: 1px solid var(--line); }
.w-rel a { display: grid; grid-template-columns: 34px auto auto minmax(0, 1fr) 18px; align-items: center; gap: 12px; padding: 11px 4px; color: var(--text); text-decoration: none; }
.w-rel a:hover b { color: var(--accent); }
.w-rel b { font-size: 17px; }
.w-rel-read { color: var(--muted); font-size: 14px; }
.w-rel-g { color: var(--muted); font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-rel-g em { font-style: normal; font-size: 12px; color: var(--accent); }
.w-rel .go { align-self: center; }
.w-src p { margin: 0 0 6px; }
.w-src a { font-size: 14px; font-weight: 600; text-decoration: none; }
@media (max-width: 900px) {
  .w-layout { grid-template-columns: 1fr; }
  .w-art { max-width: 420px; }
  .w-photo { aspect-ratio: 16 / 10; max-width: none; }
}
@media (max-width: 520px) {
  .w-card { padding: 4px 18px 16px; }
  .w-bar .actions { margin-left: 0; }
  .w-ex li { padding-left: 54px; }
  .w-ex li::before { left: 12px; }
}

/* ---------- Trang kết quả ---------- */
.r-layout .result-head h1 { font-size: 28px; margin: 6px 0 2px; }
.r-layout .result-head { margin-bottom: 16px; }
.r-list { display: grid; gap: 14px; }
.r-card { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 18px 22px; box-shadow: var(--shadow); }
.r-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; margin-bottom: 10px; }
.r-word { display: flex; align-items: center; flex-wrap: wrap; gap: 4px 12px; margin: 0; font-size: 30px; font-weight: 800; }
.r-word a { color: var(--text); text-decoration: none; }
.r-word a:hover { color: var(--accent); }
.r-read { font-size: 17px; font-weight: 400; color: var(--muted); }
.r-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.r-group { display: flex; gap: 12px; padding: 4px 0; }
.r-gl { flex-shrink: 0; width: 30px; height: 22px; margin-top: 2px; border-radius: 999px; font-size: 11px; font-weight: 600; display: grid; place-items: center; }
.r-gl-vi { color: var(--vi); background: color-mix(in srgb, var(--vi) 11%, transparent); }
.r-gl-en { color: var(--en); background: color-mix(in srgb, var(--en) 11%, transparent); }
.r-gl-ja { color: var(--ja); background: color-mix(in srgb, var(--ja) 11%, transparent); }
.r-group ol { margin: 0; padding-left: 20px; }
.r-group li { padding: 2px 0; }
.r-group li::marker { color: var(--muted); }
.r-group .pos { margin-left: 8px; }
.r-foot { display: flex; flex-wrap: wrap; align-items: baseline; justify-content: space-between; gap: 6px 16px; margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--line); }
.r-ex { margin: 0; font-size: 15px; flex: 1 1 300px; }
.r-more { margin-left: auto; font-size: 14px; font-weight: 600; text-decoration: none; white-space: nowrap; }
.r-dirs { display: flex; flex-wrap: wrap; gap: 8px; }
.r-dirs .chip-a { font-size: 14px; }
.chip-a.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.r-tips ul { margin: 0 0 8px; padding-left: 18px; color: var(--muted); font-size: 14.5px; }
.r-tips li { padding: 3px 0; }
.r-tips > a { font-size: 14px; font-weight: 600; text-decoration: none; }
@media (max-width: 900px) { .r-layout .w-side { order: 2; } }
.r-foot-min { border-top: 0; padding-top: 0; margin-top: 0; }
.search button svg { width: 17px; height: 17px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }
.r-layout { margin-top: 22px; }

.w-rel-ico { width: 34px; height: 34px; border-radius: 10px; display: grid; place-items: center; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 16px; }
.foot { margin-top: 56px; }
.kd { align-items: center; }

/* ---------- Điện thoại: gọn lại ---------- */
@media (max-width: 600px) {
  /* thanh trên: không dính khi cuộn để nhường chỗ cho nội dung */
  .top { position: static; }
  .top-in { padding-top: 8px; padding-bottom: 10px; gap: 8px; }
  .brand img { width: 30px; height: 30px; }
  .brand-text { font-size: 18px; }
  .top .search { padding: 3px 3px 3px 12px; }
  .top .search select { font-size: 13px; padding: 6px 6px; max-width: 92px; }
  .top .search button { padding: 7px 12px; font-size: 14px; }

  /* trang chủ */
  .hx-in { padding-top: 26px; padding-bottom: 22px; }
  .hx-title { font-size: 32px; margin-bottom: 10px; }
  .hx-lead { font-size: 15px; margin-bottom: 18px; }
  .hx-try { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin-top: 12px; padding-bottom: 2px;
            margin-right: -16px; padding-right: 16px; font-size: 14px; }
  .hx-try::-webkit-scrollbar { display: none; }
  .hx-try > * { flex-shrink: 0; }
  .hx-dirs { padding-top: 12px; }
  .chip-a { padding: 5px 12px; }
  .hx-stats { grid-template-columns: repeat(3, 1fr); gap: 0; padding: 14px 0; margin-bottom: 18px; }
  .hx-stats > div { flex-direction: column; justify-content: center; gap: 0; text-align: center; }
  .hx-stats > div + div { border-left: 1px solid var(--line); }
  .hx-stats i { display: none; }
  .hx-stats b { font-size: 20px; }
  .hx-stats span { font-size: 13px; }
  .card { padding: 16px; }
  .card-head h2 { font-size: 17px; gap: 8px; }
  .explore .card-head h2 > span { display: none; }
  .card-head .more { font-size: 13px; }
  .explore-cols { gap: 10px; }
  .explore-cols li { padding: 7px 0; }
  .explore-cols li:nth-child(n+4) { display: none; }
  .explore-cols li a { font-size: 16px; }
  .kanji-day .kd-char { width: 84px; height: 84px; font-size: 56px; }
  .hx-feats { gap: 12px; }
  .hx-feats .feat { padding: 16px; gap: 12px; }
  .hx-feats i { width: 42px; height: 42px; }
  .hx-feats i svg { width: 20px; height: 20px; }
  .hx-feats p { font-size: 14px; }
  .foot { margin-top: 36px; }
  .foot-in { grid-template-columns: 1fr 1fr; }
  .foot-brand { grid-column: 1 / -1; }

  /* trang kết quả */
  .r-layout { margin-top: 14px; }
  .r-layout .result-head h1 { font-size: 23px; }
  .r-list { gap: 12px; }
  .r-card { padding: 14px 16px; }
  .r-word { font-size: 25px; }
  .r-read { font-size: 15px; }
  .r-group { gap: 8px; }
  .r-gl { width: 26px; font-size: 10px; }
  .r-group ol { padding-left: 18px; font-size: 15.5px; }
  .r-group .pos { margin-left: 4px; }
  .r-ex { font-size: 14px; }

  /* trang từ */
  .crumbs { margin-top: 10px; font-size: 13px; }
  .w-word { font-size: 46px; gap: 4px 12px; }
  .w-speak { width: 40px; height: 40px; }
  .w-hv { font-size: 18px; }
  .w-lead { font-size: 14px; }
  .w-card { padding: 2px 16px 16px; }
  .w-sec h2 { font-size: 18px; }
  .w-senses { padding-left: 22px; }
  .w-senses li { font-size: 16px; padding: 4px 0; }
  .w-ex li { padding: 12px 12px 12px 50px; }
  .w-ex li::before { left: 10px; width: 28px; height: 28px; font-size: 14px; }
  .w-ex-t { font-size: 16px; }
  .w-ex-tr { font-size: 14px; }
  .w-side { gap: 14px; }
  .w-photo { aspect-ratio: 16 / 9; }
  .w-paper { aspect-ratio: 16 / 9; padding: 16px; }
  .w-kanji { grid-template-columns: 64px 1fr 16px; padding: 12px; gap: 12px; }
  .w-kanji-ch { font-size: 40px; line-height: 64px; }
  .w-rel a { grid-template-columns: 30px auto minmax(0, 1fr) 16px; gap: 10px; }
  .w-rel-ico { width: 30px; height: 30px; font-size: 14px; }
  .w-rel-read { display: none; }
}

/* ---------- Menu ☰, nút xoá, tab (ẩn trên máy tính) ---------- */
.nav-toggle, .q-clear, .explore-tabs, .nav-m, .ex-read { display: none; }
.q-clear { flex-shrink: 0; width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--muted); cursor: pointer; padding: 0; place-items: center; }
.q-clear svg { width: 14px; height: 14px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; }

/* ---------- Điện thoại: bố cục theo mock ---------- */
@media (max-width: 600px) {
  /* thanh trên: logo · ô tìm gọn · ☰ */
  .top-in { flex-wrap: nowrap; gap: 10px; position: relative; }
  .brand-text { font-size: 17px; }
  .top .search { flex: 1 1 auto; padding: 2px 6px 2px 12px; }
  .top .search select, .top .search button[type=submit] { display: none; }
  .top .search input { padding: 8px 4px; font-size: 15px; }
  .q-clear:not([hidden]) { display: grid; }
  .nav-toggle { display: grid; place-items: center; flex-shrink: 0; width: 40px; height: 40px; margin-left: auto; border: 0; background: none; color: var(--text); cursor: pointer; padding: 0; }
  .nav-toggle svg { width: 26px; height: 26px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }
  .top-nav { display: none; position: absolute; right: 12px; top: 100%; z-index: 20; flex-direction: column; gap: 0; min-width: 190px;
             background: var(--surface); border: 1px solid var(--line); border-radius: 12px; box-shadow: var(--shadow); padding: 6px 0; }
  .nav-open .top-nav { display: flex; }
  .top-nav a { padding: 10px 16px; }
  .nav-m { display: block; }

  /* trang chủ */
  .hx-stats { grid-template-columns: repeat(3, 1fr); gap: 8px; border: 0; padding: 0; margin: 16px 0; }
  .hx-stats > div { flex-direction: row; justify-content: flex-start; gap: 8px; padding: 12px 10px; background: var(--surface);
                    border: 1px solid var(--line); border-radius: 12px; text-align: left; }
  .hx-stats > div + div { border-left: 1px solid var(--line); }
  .hx-stats i { display: grid; width: 34px; height: 34px; }
  .hx-stats i svg { width: 18px; height: 18px; }
  .hx-stats i.t { font-size: 17px; }
  .hx-stats b { font-size: 17px; }
  .hx-stats span { font-size: 12px; }
  .explore-tabs { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-bottom: 6px; }
  .explore-tabs button { border: 0; border-radius: 999px; padding: 8px 0; background: var(--surface-2); color: var(--text); font: inherit; font-weight: 600; cursor: pointer; }
  .explore-tabs button[aria-selected=true] { background: var(--accent); color: #fff; }
  .explore-cols > div { display: none; }
  .explore-cols > div.on { display: block; }
  .explore-cols .tag { display: none; }
  .explore-cols li:nth-child(n+4) { display: grid; }
  .explore-cols li { display: grid; grid-template-columns: 1fr 1fr 1fr; align-items: baseline; gap: 8px; }
  .explore-cols li span { text-align: left; font-size: 14px; }
  .explore-cols > div:not([data-pane=ja]) li { grid-template-columns: 1fr 1fr; }
  .ex-read { display: block; font-style: normal; color: var(--muted); font-size: 13px; }

  /* trang từ: mỗi mục một thẻ riêng */
  .w-card { background: none; border: 0; box-shadow: none; padding: 0; display: grid; gap: 12px; }
  .w-sec { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 14px 16px; }
  .w-sec + .w-sec { margin-top: 0; }
  .w-layout { gap: 12px; }
  .w-photo { aspect-ratio: 2.2 / 1; }
  .w-paper { aspect-ratio: 2.4 / 1; }
  .w-side { display: contents; }
  .w-head { order: -2; margin-bottom: 0; }
  .w-art { order: -1; }
  .w-main { display: contents; }
  .w-kanji-box { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
  .w-kanji-box h2 { grid-column: 1 / -1; margin-bottom: 0; }
  .w-kanji-box .w-kanji { grid-template-columns: 1fr; margin-top: 0; padding: 10px; gap: 6px; text-align: left; }
  .w-kanji-box .w-kanji-ch { width: 52px; font-size: 32px; line-height: 52px; }
  .w-kanji-box .go { display: none; }
  .w-kanji-box small { display: none; }
}
.search .q-clear { background: var(--surface-2); color: var(--muted); padding: 0; width: 26px; height: 26px; border-radius: 50%; }
.q-clear[hidden] { display: none !important; }
.hx .search .q-clear { display: none !important; }
@media (max-width: 600px) {
  .w-paper { display: none; }
}

/* tra nhiều từ một lúc: mỗi từ một nhóm */
.r-group { margin: 0 0 22px; }
.r-group-h { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; margin: 0 0 10px; padding-bottom: 6px; border-bottom: 1px solid var(--line); font-size: 20px; }
.r-group-h a { color: var(--text); text-decoration: none; }
.r-group-h .r-group-more { font-size: 14px; font-weight: 500; color: var(--accent); }

/* lịch sử tra cứu (lưu trên trình duyệt) */
.suggest .suggest-h { display: flex; justify-content: space-between; align-items: center; cursor: default; background: none; }
.suggest .suggest-h small { color: var(--muted); }
.suggest .suggest-h button, .hx-recent-clear { border: 0; background: none; color: var(--accent); font: inherit; font-size: 13px; cursor: pointer; padding: 2px 4px; }
.suggest .suggest-hist span::before { content: "↺ "; color: var(--muted); }
.hx-recent[hidden] { display: none !important; }
.k-ext { font-size: 13px; color: var(--accent); text-decoration: none; margin-top: 4px; }
.k-ext:hover { text-decoration: underline; }
