/* dict-popup — bottom-sheet word detail. Uses host page tokens (practice.css /
   grammar.css …): --ink-2 --ink-3 --line --text --muted --jade --coral --e3
   --r --s*. Fallbacks keep it usable if a host page lacks a token. */

.dpop-overlay {
  position: fixed; inset: 0; z-index: 120;
  background: rgba(0, 0, 0, .55);
  display: flex; align-items: flex-end; justify-content: center;
  opacity: 0; visibility: hidden; transition: opacity .18s ease;
}
.dpop-overlay.open { opacity: 1; visibility: visible; }

.dpop-sheet {
  position: relative;
  width: 100%; max-width: 560px;
  max-height: 85vh; overflow-x: hidden; overflow-y: auto;
  overflow-wrap: anywhere; word-break: break-word;
  background: var(--ink-2, #fff);
  border-radius: var(--r, 20px) var(--r, 20px) 0 0;
  box-shadow: var(--e3, 0 14px 32px rgba(0,0,0,.18));
  padding: 0 var(--s5, 24px) calc(var(--s5, 24px) + env(safe-area-inset-bottom));
  transform: translateY(100%); transition: transform .26s cubic-bezier(.2,.8,.2,1);
}
.dpop-overlay.open .dpop-sheet { transform: translateY(0); }
@media (min-width: 640px) {
  .dpop-overlay { align-items: center; }
  .dpop-sheet { border-radius: var(--r, 20px); max-height: 88vh; }
}

.dpop-grip {
  width: 40px; height: 4px; border-radius: 999px;
  background: var(--line, #ccc); margin: 10px auto 4px;
}
.dpop-x {
  position: absolute; top: 8px; right: 8px;
  width: 44px; height: 44px; border: 0; border-radius: 999px;
  background: var(--ink-3, #eee); color: var(--muted, #666);
  font-size: 14px; cursor: pointer; line-height: 1;
  display: flex; align-items: center; justify-content: center;
}
.dpop-x:hover { background: var(--line, #ddd); color: var(--text, #222); }

.dpop-load, .dpop-empty {
  padding: var(--s6, 36px) var(--s2, 8px); text-align: center;
  color: var(--muted, #666); font-size: 14px;
}
.dpop-empty .han { font-size: 22px; color: var(--text, #222); }

.han { font-family: 'Noto Serif SC', serif; }

/* head */
.dpop-head {
  display: flex; align-items: center; gap: var(--s4, 16px);
  padding: var(--s2, 8px) 0 var(--s4, 16px);
  border-bottom: 1px solid var(--line, #eee);
}
.dpop-hz { font-size: 46px; font-weight: 700; line-height: 1.1; color: var(--text, #222); }
.dpop-meta { flex: 1; min-width: 0; }
.dpop-py { font-family: 'Be Vietnam Pro', sans-serif; font-style: italic; font-size: 16px; color: var(--jade, #1A7A35); }
.dpop-hv { font-size: 14px; color: var(--text, #222); margin-top: 2px; }
.dpop-badges { margin-top: 6px; display: flex; gap: 6px; flex-wrap: wrap; }
.dpop-hsk, .dpop-tier {
  font-size: 10px; font-weight: 700; letter-spacing: .04em;
  padding: 2px 7px; border-radius: 999px;
}
.dpop-hsk { background: var(--jade-dim, rgba(26,122,53,.1)); color: var(--jade, #1A7A35); }
.dpop-tier { background: var(--ink-3, #eee); color: var(--muted, #666); }
.dpop-audio {
  flex-shrink: 0; width: 44px; height: 44px; border: 0; border-radius: 999px;
  background: var(--jade-dim, rgba(26,122,53,.1)); cursor: pointer; font-size: 20px;
}
.dpop-audio:hover { background: var(--jade-soft, #E3F1E7); }
.dpop-audio:active { transform: scale(.94); }

/* meaning */
.dpop-mean { padding: var(--s4, 16px) 0; }
.dpop-pos {
  display: inline-block; font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .06em; color: var(--muted, #666); margin-bottom: 4px;
}
.dpop-vi { font-size: 15px; line-height: 1.6; color: var(--text, #222); }
.dpop-en { font-size: 13px; line-height: 1.5; color: var(--muted, #666); margin-top: 4px; }

/* sections */
.dpop-sec { padding: var(--s4, 16px) 0; border-top: 1px solid var(--line, #eee); }
.dpop-sec-h {
  font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .08em;
  color: var(--jade, #1A7A35); margin-bottom: var(--s3, 12px);
}
.dpop-sec-h small { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted, #666); }

/* strokes — sân khấu lớn trên lưới 米字格, KHÔNG viền (depth lo bằng elevation) */
.hw { display: flex; gap: 16px; flex-wrap: wrap; align-items: flex-start; }
.hw-stage {
  width: 220px; height: 220px; flex: 0 0 220px; position: relative; cursor: pointer;
  border-radius: var(--r-sm, 12px); background: var(--jade-soft, #E8F5EB);
  box-shadow: 0 1px 2px rgba(27,43,37,.05);
  display: flex; align-items: center; justify-content: center;
}
.hw-mizi { position: absolute; inset: 0; width: 100%; height: 100%; }
.hw-target { position: relative; line-height: 0; }
.hw-side { flex: 1; min-width: 170px; display: flex; flex-direction: column; gap: 10px; }
.hw-chips { display: flex; gap: 8px; flex-wrap: wrap; }
.hw-chip {
  appearance: none; border: 0; cursor: pointer; width: 56px; height: 56px;
  font-family: "Noto Serif SC", "Songti SC", serif; font-size: 26px; color: var(--text, #1B2B25);
  border-radius: var(--r-sm, 12px); background: var(--ink-2, #fff);
  box-shadow: 0 1px 2px rgba(27,43,37,.05);
}
.hw-chip.active { background: var(--jade-dim, rgba(26,122,53,.10)); color: var(--jade, #1A7A35); }
.hw-ctrl { display: flex; gap: 8px; flex-wrap: wrap; }
.hw-btn {
  appearance: none; border: 0; cursor: pointer; font-family: inherit; font-size: 13px; font-weight: 700;
  min-height: 40px; padding: 0 15px; border-radius: 9999px; color: var(--text, #1B2B25);
  background: var(--ink-2, #fff); box-shadow: 0 1px 2px rgba(27,43,37,.05);
  display: inline-flex; align-items: center; gap: 6px;
}
.hw-btn.on { background: var(--jade, #1A7A35); color: #fff; box-shadow: 0 4px 14px rgba(26,122,53,.26); }
.hw-chip:focus-visible, .hw-btn:focus-visible {
  outline: none; box-shadow: 0 0 0 2px var(--ink-2, #fff), 0 0 0 4px rgba(26,122,53,.4);
}
.hw-note { font-size: 12.5px; color: var(--muted, #6B8581); line-height: 1.6; margin: 0; }
@media (max-width: 599px) {
  .hw-stage { width: 160px; height: 160px; flex: 0 0 160px; }
}

/* char breakdown */
.dpop-char { padding: var(--s2, 8px) 0; }
.dpop-char + .dpop-char { border-top: 1px dashed var(--line, #eee); }
.dpop-char-top { display: flex; align-items: baseline; gap: 8px; }
.dpop-char-top .han { font-size: 22px; color: var(--text, #222); }
.dpop-char-hv { font-size: 13px; font-style: italic; color: var(--jade, #1A7A35); }
.dpop-char-mn { font-size: 13px; color: var(--muted, #666); }
.dpop-char-detail { font-size: 12px; line-height: 1.6; color: var(--muted, #666); margin-top: 4px; }

/* examples */
.dpop-ex { padding: var(--s3, 12px) 0; }
.dpop-ex + .dpop-ex { border-top: 1px dashed var(--line, #eee); }
.dpop-ex-py { font-family: 'Be Vietnam Pro', sans-serif; font-style: italic; font-size: 12px; color: var(--jade, #1A7A35); }
.dpop-ex-zh { font-size: 16px; line-height: 1.5; color: var(--text, #222); margin: 2px 0; }
.dpop-ex-vi { font-size: 12px; color: var(--muted, #666); }

/* clickable hanzi in host content */
.hz { cursor: pointer; border-radius: 3px; transition: background .12s, color .12s; }
.hz:hover { background: var(--jade-dim, rgba(26,122,53,.12)); color: var(--jade, #1A7A35); }

/* Biến thể inline (desktop 2 cột) — cùng nội dung, khác vỏ: không overlay, không sheet */
.dpop-inline { display: block; }
.dpop-inline .dpop-body {
  background: var(--ink-2, #fff); border-radius: var(--r, 20px);
  box-shadow: var(--e3, 0 12px 28px rgba(27,43,37,.12));
  padding: 24px 20px; max-height: none; overflow: visible;
}
