/* ═══════════════════════════════════════════
   DICTIONARY v2.0
═══════════════════════════════════════════ */
:root {
    --dr: #dc2626; --dr-lt: #fef2f2; --dr-md: #fecaca;
    --ink: #0f172a; --muted: #64748b; --subtle: #94a3b8;
    --border: #e8edf3; --bg: #f8fafc;
    --t1: #dc2626; --t2: #d97706; --t3: #16a34a; --t4: #2563eb; --t0: #94a3b8;
}

/* ── Base ─────────────────────────────── */
.dict-main {
    min-height: 100vh; background: var(--bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    padding-top: 76px; /* navbar height */
}

/* ── Hero ─────────────────────────────── */
.dict-hero {
    background: linear-gradient(135deg, #7f1d1d 0%, #dc2626 45%, #ef4444 75%, #f97316 100%);
    padding: 52px 16px 72px;
    text-align: center; position: relative; overflow: hidden;
    transition: padding .35s cubic-bezier(.4,0,.2,1);
}
.dict-hero::before {
    content: '词';
    position: absolute; top: -30px; right: 20px;
    font-size: 220px; font-weight: 900;
    color: rgba(255,255,255,.05); pointer-events: none; line-height: 1;
    font-family: 'Noto Serif SC', serif;
}
.dict-hero.compact { padding: 18px 16px 36px; }
.dict-hero-title {
    display: flex; align-items: center; justify-content: center;
    gap: 14px; margin: 0 0 6px;
    transition: all .3s; overflow: hidden;
}
.dict-hero.compact .dict-hero-title,
.dict-hero.compact .dict-hero-sub { display: none; }
.dict-hero.compact .dict-quick-tags { display: none; }

.dict-hero-zh { font-size: 40px; font-weight: 900; color: #fff; font-family: 'Noto Serif SC', serif; text-shadow: 0 2px 16px rgba(0,0,0,.3); }
.dict-hero-vi { font-size: 23px; font-weight: 800; color: rgba(255,255,255,.88); letter-spacing: -.01em; }
.dict-hero-sub { color: rgba(255,255,255,.7); font-size: 14.5px; margin: 0 0 30px; }

/* ── Search ───────────────────────────── */
.dict-search-wrap { position: relative; max-width: 620px; margin: 0 auto; }
.dict-search-box {
    display: flex; align-items: center;
    background: #fff; border-radius: 50px;
    box-shadow: 0 20px 60px -10px rgba(0,0,0,.35), 0 0 0 1px rgba(255,255,255,.2);
    padding: 0 6px 0 20px; gap: 10px;
    transition: box-shadow .2s;
}
.dict-search-box:focus-within { box-shadow: 0 20px 60px -10px rgba(0,0,0,.45), 0 0 0 3px rgba(255,255,255,.4); }

.dict-lang-flag {
    font-size: 18px; line-height: 1; flex-shrink: 0;
    transition: opacity .2s;
}
.dict-search-input {
    flex: 1; border: none; outline: none; background: transparent;
    font-size: 16px; color: var(--ink); padding: 17px 0;
    font-family: inherit;
}
.dict-search-input::placeholder { color: var(--subtle); }
.dict-search-clear {
    background: none; border: none; cursor: pointer;
    color: var(--subtle); font-size: 14px; padding: 8px 12px;
    border-radius: 50%; transition: background .15s, color .15s;
}
.dict-search-clear:hover { background: #f1f5f9; color: var(--dr); }
.dict-search-btn {
    background: var(--dr); color: #fff; border: none;
    border-radius: 40px; padding: 10px 20px; cursor: pointer;
    font-size: 14px; font-weight: 700; font-family: inherit;
    transition: background .15s; flex-shrink: 0; margin: 4px;
}
.dict-search-btn:hover { background: #b91c1c; }

/* ── Quick tags ───────────────────────── */
.dict-quick-tags {
    display: flex; align-items: center; justify-content: center;
    flex-wrap: wrap; gap: 8px; margin-top: 18px;
}
.dict-qt-label { color: rgba(255,255,255,.55); font-size: 12.5px; }
.dict-qt {
    background: rgba(255,255,255,.14); border: 1px solid rgba(255,255,255,.28);
    color: #fff; border-radius: 50px; padding: 5px 14px;
    font-size: 13.5px; cursor: pointer; font-family: inherit;
    transition: background .15s, transform .1s;
}
.dict-qt:hover { background: rgba(255,255,255,.26); transform: translateY(-1px); }

/* ── Result count bar ─────────────────── */
.dict-result-meta {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 14px; font-size: 13px; color: var(--muted); font-weight: 500;
}
.dict-result-meta strong { color: var(--ink); }

/* ── Body ─────────────────────────────── */
.dict-body { padding: 28px 16px 80px; }
.dict-container { max-width: 780px; margin: 0 auto; }
.dict-results-area { display: flex; flex-direction: column; gap: 12px; }

/* ── Welcome ──────────────────────────── */
.dict-welcome {
    text-align: center; padding: 52px 24px;
    background: #fff; border-radius: 20px;
    border: 1px solid var(--border);
    box-shadow: 0 4px 24px rgba(15,23,42,.05);
}
.dict-welcome-icon { font-size: 54px; margin-bottom: 14px; }
.dict-welcome h3 { font-size: 20px; font-weight: 800; color: var(--ink); margin: 0 0 8px; }
.dict-welcome p { color: var(--muted); font-size: 14.5px; margin: 0 0 24px; line-height: 1.65; }
.dict-feat-grid { display: grid; grid-template-columns: repeat(3,1fr); gap: 10px; max-width: 560px; margin: 0 auto; }
.dict-feat-item {
    padding: 16px 12px; background: var(--bg); border-radius: 14px;
    border: 1px solid var(--border); text-align: center;
}
.dict-feat-icon { font-size: 22px; margin-bottom: 6px; }
.dict-feat-label { font-size: 12.5px; font-weight: 600; color: var(--muted); }

/* ── Result Card ──────────────────────── */
@keyframes dict-in { from { opacity:0; transform:translateY(10px); } to { opacity:1; transform:translateY(0); } }

.dict-card {
    background: #fff; border-radius: 18px;
    border: 1px solid var(--border);
    box-shadow: 0 2px 16px rgba(15,23,42,.05);
    overflow: hidden;
    animation: dict-in .28s ease both;
    border-left: 4px solid transparent;
}
.dict-card.hsk-1 { border-left-color: #16a34a; }
.dict-card.hsk-2 { border-left-color: #2563eb; }
.dict-card.hsk-3 { border-left-color: #7c3aed; }
.dict-card.hsk-4 { border-left-color: #d97706; }
.dict-card.hsk-5 { border-left-color: #dc2626; }
.dict-card.hsk-6 { border-left-color: #0f172a; }
.dict-card.hsk-0 { border-left-color: #94a3b8; }

/* Card header */
.dict-card-head {
    display: flex; align-items: flex-start;
    padding: 22px 24px 16px; gap: 20px;
}
.dict-card-hz-col { flex-shrink: 0; text-align: center; min-width: 72px; }
.dict-card-hz {
    font-size: 58px; font-weight: 900; line-height: 1; display: block;
    color: var(--dr); font-family: 'Noto Serif SC', 'Noto Sans SC', serif, sans-serif;
    cursor: pointer; transition: opacity .15s;
    user-select: none;
}
.dict-card-hz:hover { opacity: .8; }
.dict-card-speak-hint { font-size: 10.5px; color: var(--subtle); margin-top: 5px; }

.dict-card-info { flex: 1; min-width: 0; }
.dict-card-badges { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 10px; }
.dict-badge {
    padding: 2px 9px; border-radius: 50px; font-size: 10.5px; font-weight: 700;
}
.dict-badge-hsk { color: #fff; }
.dict-badge-hsk.hsk-1 { background: #16a34a; }
.dict-badge-hsk.hsk-2 { background: #2563eb; }
.dict-badge-hsk.hsk-3 { background: #7c3aed; }
.dict-badge-hsk.hsk-4 { background: #d97706; }
.dict-badge-hsk.hsk-5 { background: #dc2626; }
.dict-badge-hsk.hsk-6 { background: #0f172a; }
.dict-badge-type { background: #f1f5f9; color: #475569; }
.dict-badge-api { background: #ecfdf5; color: #059669; }

/* Pinyin with tone colors */
.dict-pinyin { font-size: 20px; font-weight: 600; margin-bottom: 10px; line-height: 1.3; }
.dict-pinyin .t1 { color: var(--t1); }
.dict-pinyin .t2 { color: var(--t2); }
.dict-pinyin .t3 { color: var(--t3); }
.dict-pinyin .t4 { color: var(--t4); }
.dict-pinyin .t0 { color: var(--t0); }

/* Tone legend */
.dict-tone-legend {
    display: flex; gap: 10px; flex-wrap: wrap; margin-top: 4px;
    font-size: 11px; font-weight: 600;
}
.dict-tone-legend span { opacity: .75; }

/* Meaning */
.dict-card-meaning-wrap { margin-top: 6px; }
.dict-meaning-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--subtle); margin-bottom: 5px; }
.dict-meaning { font-size: 16px; font-weight: 700; color: var(--ink); line-height: 1.5; }

/* English meaning (secondary) */
.dict-meaning-en {
    font-size: 13px; color: var(--muted); line-height: 1.55;
    padding: 6px 10px; background: var(--bg); border-radius: 8px;
    margin-top: 4px; border-left: 2px solid var(--border);
}

/* Speak action on card */
.dict-card-actions-top {
    margin-left: auto; display: flex; gap: 6px; flex-shrink: 0;
}
.dict-icon-btn {
    width: 34px; height: 34px; border-radius: 50%;
    border: 1px solid var(--border); background: #fff;
    cursor: pointer; font-size: 14px; color: var(--muted);
    display: flex; align-items: center; justify-content: center;
    transition: background .15s, color .15s, border-color .15s;
}
.dict-icon-btn:hover { background: var(--dr-lt); border-color: var(--dr-md); color: var(--dr); }
.dict-icon-btn.speaking { background: var(--dr-lt); color: var(--dr); border-color: var(--dr-md); animation: dict-pulse .6s ease infinite alternate; }
@keyframes dict-pulse { from{opacity:.7} to{opacity:1} }

/* Example section */
.dict-card-example {
    margin: 0 24px 16px;
    background: var(--bg); border-radius: 12px;
    padding: 14px 16px;
    border-left: 3px solid var(--dr-md);
}
.dict-ex-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--subtle); margin-bottom: 8px; }
.dict-ex-zh { font-size: 17px; font-weight: 700; color: var(--ink); margin-bottom: 4px; line-height: 1.4; }
.dict-ex-vi { font-size: 13px; color: var(--muted); line-height: 1.5; }

/* Breakdown section */
.dict-breakdown {
    margin: 0 24px 16px;
}
.dict-breakdown-label { font-size: 10.5px; text-transform: uppercase; letter-spacing: .06em; font-weight: 700; color: var(--subtle); margin-bottom: 10px; }
.dict-breakdown-chars { display: flex; gap: 8px; flex-wrap: wrap; }
.dict-char-chip {
    display: flex; align-items: center; gap: 10px;
    padding: 10px 14px; background: var(--bg);
    border: 1px solid var(--border); border-radius: 12px;
    cursor: pointer; transition: background .15s, border-color .15s;
    min-width: 0;
}
.dict-char-chip:hover { background: var(--dr-lt); border-color: var(--dr-md); }
.dict-char-chip-hz { font-size: 26px; font-weight: 900; color: var(--dr); font-family: 'Noto Serif SC', serif; line-height: 1; }
.dict-char-chip-info { min-width: 0; }
.dict-char-chip-py { font-size: 12px; color: var(--subtle); }
.dict-char-chip-vi { font-size: 13px; font-weight: 600; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 140px; }
.dict-char-chip-loading { font-size: 12px; color: var(--subtle); }

/* Card footer */
.dict-card-footer {
    display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
    padding: 12px 24px; border-top: 1px solid #f1f5f9; background: #fafafa;
}
.dict-copy-btn {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 6px 14px; border-radius: 50px;
    font-size: 12px; font-weight: 600; cursor: pointer;
    border: 1px solid var(--border); background: #fff;
    color: var(--muted); transition: all .15s; font-family: inherit;
}
.dict-copy-btn:hover { background: var(--dr-lt); border-color: var(--dr-md); color: var(--dr); }
.dict-copy-btn.ok { background: #f0fdf4; border-color: #bbf7d0; color: #16a34a; }
.dict-api-note { margin-left: auto; font-size: 11.5px; color: var(--subtle); display: flex; align-items: center; gap: 5px; }

/* Compact secondary cards */
.dict-card-compact .dict-card-head { padding: 14px 20px; gap: 14px; }
.dict-card-compact .dict-card-hz { font-size: 40px; }
.dict-card-compact .dict-card-hz-col { min-width: 52px; }
.dict-card-compact .dict-pinyin { font-size: 16px; }
.dict-card-compact .dict-meaning { font-size: 14px; }
.dict-card-compact .dict-card-example { margin: 0 20px 12px; }
.dict-card-compact .dict-card-footer { padding: 10px 20px; }

/* Source note */
.dict-source-note { text-align: center; font-size: 12px; color: var(--subtle); padding: 10px; }

/* ── Empty / Loading ──────────────────── */
.dict-empty {
    text-align: center; padding: 56px 24px;
    background: #fff; border-radius: 18px; border: 1px solid var(--border);
}
.dict-empty-icon { font-size: 46px; margin-bottom: 14px; }
.dict-empty h3 { font-size: 18px; font-weight: 700; color: var(--ink); margin: 0 0 6px; }
.dict-empty p { color: var(--muted); font-size: 14px; margin: 0; line-height: 1.6; }

.dict-skel {
    background: #fff; border-radius: 18px; border: 1px solid var(--border);
    padding: 22px 24px; animation: dict-in .2s ease both;
}
.dict-skel-row { display: flex; gap: 18px; }
.dict-skel-hz { width: 58px; height: 68px; border-radius: 10px; background: #f1f5f9; animation: sk-pulse 1.4s infinite; flex-shrink: 0; }
.dict-skel-lines { flex: 1; padding-top: 6px; }
.dict-skel-line { height: 11px; border-radius: 6px; background: #f1f5f9; margin-bottom: 10px; animation: sk-pulse 1.4s infinite; }
.dict-skel-line.w30{width:30%} .dict-skel-line.w60{width:60%} .dict-skel-line.w80{width:80%} .dict-skel-line.w45{width:45%}
@keyframes sk-pulse { 0%,100%{opacity:1} 50%{opacity:.45} }

/* ── Recent ───────────────────────────── */
.dict-recent { margin-top: 24px; background: #fff; border-radius: 18px; border: 1px solid var(--border); overflow: hidden; }
.dict-recent-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 13px 20px; border-bottom: 1px solid #f1f5f9;
    font-size: 12.5px; font-weight: 700; color: var(--muted);
}
.dict-recent-header button {
    background: none; border: none; cursor: pointer;
    color: var(--subtle); font-size: 12px; font-family: inherit; font-weight: 600;
    display: flex; align-items: center; gap: 5px; transition: color .15s;
}
.dict-recent-header button:hover { color: var(--dr); }
.dict-recent-list { display: flex; flex-wrap: wrap; gap: 8px; padding: 14px 20px; }
.dict-recent-chip {
    padding: 5px 13px; border-radius: 50px; border: 1px solid var(--border);
    background: var(--bg); font-size: 14px; cursor: pointer; font-family: inherit;
    color: var(--ink); transition: all .12s;
}
.dict-recent-chip:hover { background: var(--dr-lt); border-color: var(--dr-md); color: var(--dr); }

/* ── Tone legend in hero ──────────────── */
.dict-tone-guide {
    display: flex; align-items: center; justify-content: center;
    gap: 12px; margin-top: 14px; flex-wrap: wrap;
    font-size: 12px;
}
.dict-tg-item { display: flex; align-items: center; gap: 4px; color: rgba(255,255,255,.75); }
.dict-tg-dot { width: 8px; height: 8px; border-radius: 50%; }

/* ── Global popup ─────────────────────── */
#dictPopup {
    position: fixed; z-index: 9000;
    background: #fff; border-radius: 16px;
    box-shadow: 0 24px 64px -8px rgba(15,23,42,.28), 0 0 0 1px rgba(226,232,240,.8);
    padding: 16px 20px; max-width: 300px; min-width: 200px;
    pointer-events: auto;
}
#dictPopup.loading { display: flex; align-items: center; justify-content: center; min-height: 64px; }
.dict-popup-hz { font-size: 32px; font-weight: 900; color: var(--dr); display: block; line-height: 1; margin-bottom: 3px; font-family: 'Noto Serif SC', serif; }
.dict-popup-pinyin { font-size: 14px; margin-bottom: 8px; font-weight: 500; }
.dict-popup-vi { font-size: 14.5px; font-weight: 700; color: var(--ink); line-height: 1.45; }
.dict-popup-footer {
    display: flex; align-items: center; justify-content: space-between;
    margin-top: 12px; padding-top: 10px; border-top: 1px solid #f1f5f9;
}
.dict-popup-more { font-size: 12px; font-weight: 700; color: var(--dr); text-decoration: none; display: flex; align-items: center; gap: 4px; }
.dict-popup-more:hover { text-decoration: underline; }
.dict-popup-actions { display: flex; gap: 6px; }
.dict-popup-btn {
    width: 28px; height: 28px; border-radius: 50%; border: 1px solid var(--border);
    background: #fff; cursor: pointer; font-size: 12px; color: var(--muted);
    display: flex; align-items: center; justify-content: center; transition: all .15s;
}
.dict-popup-btn:hover { background: var(--dr-lt); color: var(--dr); border-color: var(--dr-md); }
.dict-spin { width: 22px; height: 22px; border: 3px solid #f1f5f9; border-top-color: var(--dr); border-radius: 50%; animation: dict-spin .65s linear infinite; }
@keyframes dict-spin { to{transform:rotate(360deg)} }
@keyframes dict-in { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }

/* ── Responsive ───────────────────────── */
@media(max-width:600px) {
    .dict-hero { padding: 38px 16px 56px; }
    .dict-hero.compact { padding: 14px 16px 28px; }
    .dict-hero-zh { font-size: 30px; }
    .dict-hero-vi { font-size: 18px; }
    .dict-hero-title { flex-direction: column; gap: 4px; }
    .dict-card-head { padding: 16px 16px 12px; gap: 14px; }
    .dict-card-hz { font-size: 48px; }
    .dict-card-hz-col { min-width: 58px; }
    .dict-card-example, .dict-breakdown { margin-left: 16px; margin-right: 16px; }
    .dict-card-footer { padding: 10px 16px; }
    .dict-feat-grid { grid-template-columns: 1fr 1fr; }
    .dict-search-btn span { display: none; }
    .dict-search-btn { padding: 10px 14px; }
}
