/* 天火字典 — 手札 (notebook) theme.
   Functional type scale, relative to the reader's browser font preference.
   Reading text stays 17px at a 16px default on both desktop and mobile. */
:root{
  font-size:100%;
  --type-caption:.8125rem;
  --type-small:.875rem;
  --type-ui:.9375rem;
  --type-body:1rem;
  --type-reading:1.0625rem;
  --type-definition:1.1875rem;
  --type-section:1.25rem;
  --type-word:1.75rem;
  --type-entry:3.25rem;
  --type-brand:1.5rem;
  --type-display:clamp(2rem,1.4rem + 2.5vw,3rem);
  --leading-reading:1.8;
  --reading-measure:68ch;
  --page-max:1180px;
  --gutter:32px;
  --radius-card:26px;
  --radius-field:14px;
  --radius-chip:999px;
  --font-latin:"Nunito","Noto Sans TC","TW Kai Fill",system-ui,-apple-system,"Segoe UI","Noto Sans JP","Noto Sans KR",sans-serif;
  --font-ui:"Noto Sans TC","TW Kai Fill",system-ui,-apple-system,"Segoe UI","Noto Sans JP","Noto Sans KR",sans-serif;
  --font-kai:"LXGW WenKai TC","TW Kai Fill","Kaiti TC","BiauKai","DFKai-SB","Noto Sans TC",serif;
}
@media(max-width:699px){:root{
  --type-definition:1.125rem;
  --type-word:1.625rem;
  --type-entry:2.625rem;
  --type-brand:1.3125rem;
  --type-display:2.125rem;
  --gutter:16px;
  --radius-card:22px;
}}
:root{
  color-scheme:light;
  --bg:#F6F8F4;--surface:#FFFFFF;--ink:#23302A;--muted:#56635C;--line:#DEE5DF;
  --sage:#2F6B57;--on-sage:#FFFFFF;--sage-soft:#E6EEE8;--hl:#FFE680;--hl-soft:#FFF4C2;
  --focus:#B4540F;--shadow:0 12px 32px rgba(35,48,42,.12);
}
:root[data-theme=dark]{
  color-scheme:dark;
  --bg:#121815;--surface:#1A221E;--ink:#E6ECE7;--muted:#A2B0A8;--line:#2C3832;
  --sage:#8FD0B4;--on-sage:#12201A;--sage-soft:#22302A;--hl:#5E5014;--hl-soft:#3A3312;
  --focus:#F2B25C;--shadow:0 12px 32px rgba(0,0,0,.5);
}

/* Base */
*,*::before,*::after{box-sizing:border-box;}
[hidden]{display:none !important;}
html{-webkit-text-size-adjust:100%;}
body{margin:0;background:var(--bg);color:var(--ink);font-family:var(--font-latin);font-size:var(--type-body);line-height:1.7;overflow-wrap:anywhere;}
a{color:var(--sage);text-decoration:none;}
a:hover{text-decoration:underline;text-underline-offset:4px;}
button,input,select{font:inherit;color:inherit;}
button,a,select,summary{-webkit-tap-highlight-color:transparent;}
button{cursor:pointer;}
summary{cursor:pointer;}
:focus-visible{outline:3px solid var(--focus);outline-offset:3px;border-radius:6px;}
h1,h2,h3,h4{margin:0;line-height:1.3;}
p{margin:0;}
img{max-width:100%;height:auto;}
.sr-only{position:absolute;width:1px;height:1px;padding:0;margin:-1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0;}
.skip{position:absolute;left:12px;top:-60px;z-index:100;padding:10px 16px;border-radius:12px;background:var(--sage);color:var(--on-sage);}
.skip:focus{top:12px;}
[lang|=zh],[lang=ja],[lang=ko]{font-family:var(--font-ui);}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation:none !important;transition:none !important;scroll-behavior:auto !important;}}

/* Shared controls */
.quiet-button{min-height:44px;padding:0 14px;border:0;border-radius:12px;background:transparent;color:var(--muted);font-family:var(--font-ui);font-size:var(--type-ui);}
.quiet-button:hover{color:var(--ink);background:var(--sage-soft);}
.icon-button{display:inline-grid;place-items:center;width:44px;height:44px;padding:0;border:0;border-radius:14px;background:var(--sage-soft);color:var(--ink);}
.icon{width:20px;height:20px;fill:none;stroke:currentColor;stroke-width:1.8;stroke-linecap:round;stroke-linejoin:round;}
.icon-fill{fill:currentColor;stroke:none;}
.theme-toggle .icon{display:none;}
:root[data-theme-pref=light] .theme-toggle .icon-light,
:root[data-theme-pref=dark] .theme-toggle .icon-dark{display:block;}
.text-link{display:inline-flex;align-items:center;min-height:44px;font-family:var(--font-ui);font-size:var(--type-ui);font-weight:500;}
.pos-mark{flex:none;white-space:nowrap;font-family:var(--font-kai);font-weight:700;color:var(--sage);letter-spacing:0;}

/* Header */
.site-header{display:flex;flex-wrap:wrap;align-items:center;gap:12px 24px;padding:12px max(var(--gutter),calc((100% - var(--page-max)) / 2 + var(--gutter)));background:var(--surface);border-bottom:1px solid var(--line);position:relative;z-index:20;}
.home-page .site-header{background:transparent;border-bottom-color:transparent;}
.brand{display:flex;align-items:center;gap:12px;color:var(--ink);flex-shrink:0;}
.brand:hover{text-decoration:none;}
.brand img{width:44px;height:44px;}
.brand-wordmark{font-family:var(--font-kai);font-weight:700;font-size:var(--type-brand);letter-spacing:.06em;}
.header-actions{display:flex;align-items:center;gap:6px;margin-left:auto;}
.site-menu>summary{display:flex;align-items:center;gap:6px;min-height:44px;padding:0 14px;border-radius:12px;list-style:none;font-family:var(--font-ui);font-size:var(--type-ui);}
.site-menu>summary::-webkit-details-marker{display:none;}
.site-menu>summary::after{content:"";width:8px;height:8px;border-right:2px solid currentColor;border-bottom:2px solid currentColor;transform:translateY(-2px) rotate(45deg);}
.site-menu>summary:hover,.site-menu[open]>summary{background:var(--sage-soft);}
.site-menu-panel{position:absolute;top:calc(100% + 6px);right:max(var(--gutter),calc((100% - var(--page-max)) / 2 + var(--gutter)));width:min(760px,calc(100% - 2 * var(--gutter)));display:grid;grid-template-columns:repeat(4,minmax(0,1fr));gap:20px;padding:22px;background:var(--surface);border:1px solid var(--line);border-radius:22px;box-shadow:var(--shadow);font-family:var(--font-ui);}
.site-menu-panel h2{font-size:var(--type-small);font-weight:500;color:var(--muted);margin-bottom:6px;}
.site-menu-panel a{display:block;padding:6px 0;color:var(--ink);font-size:var(--type-ui);}

/* Search */
.search-form{min-width:0;}
.query-control{display:flex;align-items:center;gap:8px;padding:4px 4px 4px 16px;background:var(--surface);border:2px solid var(--line);border-radius:16px;}
.query-control:focus-within{border-color:var(--sage);}
.query-control input{flex:1 1 auto;min-width:0;height:44px;border:0;background:transparent;font-family:var(--font-latin);font-size:var(--type-reading);font-weight:600;outline:none;}
.query-control input::placeholder{color:var(--muted);font-weight:400;}
.query-control input::-webkit-search-cancel-button{cursor:pointer;}
.search-button{flex:none;height:44px;padding:0 20px;border:0;border-radius:12px;background:var(--sage);color:var(--on-sage);font-family:var(--font-ui);font-size:var(--type-body);font-weight:700;}
.search-button:hover{filter:brightness(1.08);}
.header-search{flex:1 1 240px;max-width:620px;}
.hero-search{display:flex;flex-direction:column;gap:12px;max-width:720px;margin:28px 0 0;padding:16px;background:var(--surface);border-radius:var(--radius-card);box-shadow:var(--shadow);}
.hero-search .query-control input{height:52px;font-size:var(--type-section);}
.hero-search .search-button{height:52px;padding:0 26px;}
.dictionary-picker{position:relative;}
.dictionary-picker>summary{display:flex;flex-wrap:wrap;align-items:center;gap:4px 12px;min-height:46px;padding:8px 14px;border:2px solid var(--line);border-radius:var(--radius-field);list-style:none;font-family:var(--font-ui);}
.dictionary-picker>summary::-webkit-details-marker{display:none;}
.dictionary-picker>summary::after{content:"";margin-left:auto;width:8px;height:8px;border-right:2px solid currentColor;border-bottom:2px solid currentColor;transform:translateY(-2px) rotate(45deg);}
.picker-label{font-size:var(--type-small);color:var(--muted);}
.picker-current{font-weight:700;}
.picker-hint{font-size:var(--type-small);color:var(--muted);}
.picker-panel{position:absolute;z-index:15;top:calc(100% + 6px);left:0;right:0;max-height:min(420px,70vh);overflow:auto;margin:0;padding:8px;list-style:none;background:var(--surface);border:1px solid var(--line);border-radius:18px;box-shadow:var(--shadow);font-family:var(--font-ui);}
.picker-panel a{display:flex;flex-direction:column;padding:10px 12px;border-radius:12px;color:var(--ink);}
.picker-panel a:hover,.picker-panel a[aria-current=page]{background:var(--sage-soft);text-decoration:none;}
.picker-panel small,.dictionary-list small{color:var(--muted);font-size:var(--type-small);}

/* Dictionary tabs */
.tabs-bar{background:var(--surface);border-bottom:1px solid var(--line);}
.tabs-inner{display:flex;align-items:center;gap:8px;padding:0 max(var(--gutter),calc((100% - var(--page-max)) / 2 + var(--gutter)));}
.dictionary-tabs{position:relative;display:flex;gap:2px;flex:1 1 auto;min-width:0;overflow-x:auto;scrollbar-width:none;font-family:var(--font-ui);}
.dictionary-tabs::-webkit-scrollbar{display:none;}
.dictionary-tabs .tab{flex:none;display:flex;align-items:center;min-height:46px;padding:0 14px;border-bottom:3px solid transparent;color:var(--muted);font-size:var(--type-body);white-space:nowrap;}
.dictionary-tabs a.tab:hover{color:var(--ink);text-decoration:none;}
.dictionary-tabs .tab[aria-current=page]{color:var(--ink);font-weight:700;border-bottom-color:var(--sage);}
.speech-settings-open{flex:none;}
.script-switch{flex:none;display:flex;padding:3px;border-radius:var(--radius-chip);background:var(--sage-soft);font-family:var(--font-ui);font-size:var(--type-small);line-height:1;}
.script-switch>*{display:flex;align-items:center;min-height:32px;padding:0 12px;border-radius:var(--radius-chip);color:var(--muted);white-space:nowrap;}
.script-switch a:hover{color:var(--ink);text-decoration:none;}
.script-switch [aria-current]{background:var(--surface);color:var(--ink);font-weight:700;box-shadow:0 1px 2px rgba(0,0,0,.12);}

/* Page body */
main{display:block;max-width:var(--page-max);margin:0 auto;padding:18px var(--gutter) 56px;}
.breadcrumbs{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px;margin-bottom:18px;font-family:var(--font-ui);font-size:var(--type-ui);color:var(--muted);}
.back-link{display:inline-flex;align-items:center;gap:6px;min-height:40px;padding:0 14px 0 10px;border-radius:var(--radius-chip);background:var(--sage-soft);color:var(--ink);}
.back-link::before{content:"";width:8px;height:8px;border-left:2px solid currentColor;border-bottom:2px solid currentColor;transform:rotate(45deg);}
.back-link:hover{text-decoration:none;filter:brightness(.97);}
.trail-steps{display:flex;flex-wrap:wrap;align-items:center;gap:4px 8px;}
.trail-steps a{color:var(--muted);}
.trail-steps [aria-current=page]{color:var(--ink);}
.hero{max-width:720px;margin:40px 0 0;}
.hero h1{font-family:var(--font-kai);font-weight:700;font-size:var(--type-display);line-height:1.35;letter-spacing:.02em;}
.hero-copy{margin-top:10px;color:var(--muted);font-family:var(--font-ui);font-size:var(--type-reading);line-height:1.7;}
.examples{margin-top:32px;}
.examples h2,.dictionary-list h2{font-family:var(--font-kai);font-size:var(--type-section);margin-bottom:12px;}
.example-chips{display:flex;flex-wrap:wrap;gap:8px;}
.example-chips a{display:inline-flex;align-items:center;min-height:44px;padding:0 18px;border-radius:var(--radius-chip);background:var(--sage-soft);color:var(--ink);font-weight:700;font-size:var(--type-body);}
.example-chips a[lang|=zh]{font-family:var(--font-kai);font-size:var(--type-reading);font-weight:400;}
.example-chips a:hover{text-decoration:none;filter:brightness(.96);}
.dictionary-list{margin-top:40px;}
.dictionary-list ul{display:grid;grid-template-columns:repeat(auto-fill,minmax(240px,1fr));gap:10px;margin:0;padding:0;list-style:none;font-family:var(--font-ui);}
.dictionary-list a{display:flex;flex-direction:column;gap:2px;min-height:64px;padding:12px 16px;border-radius:16px;background:var(--surface);color:var(--ink);}
.dictionary-list a span{font-weight:500;}
.dictionary-list a:hover{text-decoration:none;box-shadow:inset 0 0 0 2px var(--line);}

/* Layout with side column */
.lookup-layout{display:flex;flex-wrap:wrap;gap:28px;align-items:flex-start;}
.lookup-results{flex:999 1 560px;min-width:0;}
.lookup-sidebar{flex:1 1 300px;min-width:0;display:flex;flex-direction:column;gap:18px;font-family:var(--font-ui);}
@media(min-width:700px) and (max-width:1023px){
  .lookup-sidebar{flex-basis:100%;display:grid;grid-template-columns:repeat(2,minmax(0,1fr));align-items:start;}
}

/* Messages and notices */
.message{padding:28px;border-radius:var(--radius-card);background:var(--surface);font-family:var(--font-ui);}
.message h2,.message h3{font-family:var(--font-kai);font-size:var(--type-section);margin-bottom:8px;}
.message p{color:var(--muted);}
.data-notice,.source-line,.explanation{margin-top:16px;font-family:var(--font-ui);font-size:var(--type-small);color:var(--muted);line-height:1.7;}
.source-details{margin-top:10px;font-family:var(--font-ui);font-size:var(--type-small);color:var(--muted);}
.source-details summary{min-height:40px;display:flex;align-items:center;}
.context{margin-top:6px;color:var(--muted);font-size:var(--type-reading);line-height:var(--leading-reading);}
.revision-note{margin-top:6px;font-size:var(--type-small);color:var(--muted);}
.eyebrow{font-family:var(--font-ui);font-size:var(--type-small);color:var(--muted);}

/* Entries */
.result-list{display:flex;flex-direction:column;gap:20px;}
.entry,.result,.concept,.cwn-head{background:var(--surface);border-radius:var(--radius-card);padding:32px 40px 24px;}
.entry-head{margin-bottom:6px;}
.headword-row{display:flex;flex-wrap:wrap;align-items:center;gap:10px 14px;}
.headword{font-family:var(--font-latin);font-weight:800;font-size:var(--type-entry);line-height:1.15;letter-spacing:-.01em;}
.headword a{color:var(--ink);background:linear-gradient(transparent 58%,var(--hl) 58%,var(--hl) 90%,transparent 90%);padding:0 6px;}
.headword[lang|=zh],.headword[lang=ja],.headword[lang=ko]{font-family:var(--font-kai);font-weight:700;}
.headword a:hover{text-decoration:none;}
.result .headword,.result h2,.result h3{font-size:var(--type-word);}
.pronunciation-row{display:flex;flex-wrap:wrap;align-items:center;gap:6px 16px;margin-top:10px;}
.entry-phonetics{display:flex;flex-wrap:wrap;gap:4px 18px;margin:0;font-size:var(--type-body);}
.entry-phonetics>div{display:flex;gap:6px;align-items:baseline;}
.entry-phonetics dt{color:var(--muted);font-family:var(--font-ui);font-size:var(--type-small);}
.entry-phonetics dd{margin:0;font-weight:700;}
.phonetics{margin-top:8px;color:var(--muted);}
.pos-group{margin-top:26px;}
.pos-heading{display:flex;align-items:baseline;gap:6px;margin-bottom:4px;font-weight:400;}
.pos-heading .pos-mark{font-size:var(--type-section);}
.pos-name{font-family:var(--font-ui);font-size:var(--type-ui);color:var(--muted);}
.sense{display:grid;grid-template-columns:34px minmax(0,1fr);gap:0 10px;padding:16px 0;border-bottom:2px dashed var(--line);}
.sense:last-child{border-bottom:0;}
.sense-number{font-weight:800;font-size:var(--type-section);color:var(--sage);line-height:1.5;}
.sense-body{min-width:0;}
.definition-line{display:flex;align-items:flex-start;gap:8px;}
.definition{font-size:var(--type-definition);line-height:1.6;max-width:var(--reading-measure);}
.definition[lang|=zh],.definition-line .definition[lang|=zh]{font-family:var(--font-kai);}
.matched{margin-top:8px;font-size:var(--type-reading);}
.matched>span:first-child{margin-right:6px;font-family:var(--font-ui);font-size:var(--type-small);color:var(--muted);}
.sense-examples{margin-top:12px;}
.sense-examples h4{font-family:var(--font-ui);font-size:var(--type-small);font-weight:500;color:var(--muted);margin-bottom:4px;}
.sense-examples ol{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:10px;}
.sense-example p{font-size:var(--type-reading);line-height:var(--leading-reading);}
.sense-example p+p,.sense-example details p{color:var(--muted);}
.example-language{margin-right:8px;font-family:var(--font-ui);font-size:var(--type-caption);color:var(--muted);}
.example-translations>summary,.more-examples>summary,.other-definitions>summary,.native-examples>summary,.more-chips>summary,.lookup-tools>summary,.character-lookup>summary,.text-alternatives>summary{display:flex;align-items:center;gap:8px;min-height:40px;font-family:var(--font-ui);font-size:var(--type-ui);color:var(--sage);}
.other-languages{margin:6px 0 0;}
.other-languages>div{display:grid;grid-template-columns:4em minmax(0,1fr);gap:8px;padding:4px 0;}
.other-languages dt{font-family:var(--font-ui);font-size:var(--type-small);color:var(--muted);}
.other-languages dd{margin:0;font-size:var(--type-reading);}
.pagination{display:flex;justify-content:space-between;gap:12px;margin-top:18px;font-family:var(--font-ui);}
.pagination a{display:inline-flex;align-items:center;min-height:44px;padding:0 18px;border-radius:var(--radius-chip);background:var(--sage-soft);color:var(--ink);}

/* Older result cards (phrases, idioms, classical) */
.result-top{display:flex;flex-wrap:wrap;align-items:center;gap:8px 12px;}
.pos{font-family:var(--font-ui);font-size:var(--type-small);color:var(--muted);}
.match-type{display:none;}
.phrase-results{display:flex;flex-direction:column;gap:16px;margin-bottom:20px;}
.phrase-results>h2{font-family:var(--font-kai);font-size:var(--type-section);}
.idiom-fields>div{padding:10px 0;border-bottom:2px dashed var(--line);}
.idiom-fields dt{font-family:var(--font-ui);font-size:var(--type-small);color:var(--muted);}
.idiom-fields dd{margin:4px 0 0;font-size:var(--type-reading);line-height:var(--leading-reading);}
.idiom-glyph{height:1.2em;width:auto;vertical-align:-.2em;}
.explore-links{display:flex;flex-wrap:wrap;gap:8px;margin-top:14px;font-family:var(--font-ui);}
.explore-links a{display:inline-flex;align-items:center;min-height:40px;padding:0 14px;border-radius:var(--radius-chip);background:var(--sage-soft);color:var(--ink);}

/* ⋯ exploration menus */
.term-lookup{display:inline-block;position:relative;flex:none;}
.term-lookup>summary{list-style:none;}
.term-lookup>summary::-webkit-details-marker{display:none;}
.lookup-trigger{display:inline-grid;place-items:center;width:40px;height:32px;border-radius:16px;background:var(--sage-soft);color:var(--ink);font-weight:800;line-height:1;}
.headword-row .lookup-trigger{width:46px;height:46px;border-radius:23px;}
.lookup-trigger:hover{filter:brightness(.95);}
.term-lookup[open]>.lookup-panel{position:absolute;z-index:12;top:calc(100% + 8px);left:0;width:min(300px,80vw);}
.term-lookup:not([open])>.lookup-panel{display:none;}
.lookup-panel,.lookup-dialog{padding:14px 16px 16px;background:var(--surface);color:var(--ink);border:1px solid var(--line);border-radius:18px;box-shadow:var(--shadow);font-family:var(--font-ui);}
.lookup-dialog{position:fixed;margin:0;width:min(320px,calc(100vw - 24px));max-height:calc(100vh - 24px);overflow:auto;}
.lookup-dialog::backdrop{background:rgba(18,24,21,.18);}
.lookup-dialog-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:6px;font-size:var(--type-small);color:var(--muted);}
.lookup-close{width:40px;height:40px;border:0;border-radius:20px;background:transparent;color:var(--muted);font-size:1.4rem;}
.lookup-group+.lookup-group{margin-top:12px;}
.lookup-group h3{font-family:var(--font-latin);font-size:var(--type-reading);font-weight:800;margin-bottom:8px;}
.lookup-choices{display:grid;grid-template-columns:repeat(2,minmax(0,1fr));gap:6px;}
.lookup-choices a{display:flex;align-items:center;min-height:40px;padding:0 10px;border-radius:10px;background:var(--sage-soft);color:var(--ink);font-size:var(--type-ui);}
.lookup-choices a:hover{text-decoration:none;filter:brightness(.96);}
.more-phonetics .lookup-trigger{width:36px;height:30px;}

/* Related words row (phones and tablets; desktop shows the side column) */
.related-strip{display:flex;align-items:center;gap:6px;margin-top:14px;overflow-x:auto;scrollbar-width:none;font-family:var(--font-ui);}
.related-strip::-webkit-scrollbar{display:none;}
.related-strip-label{flex:none;font-size:var(--type-small);color:var(--muted);}
.related-strip a{flex:none;display:inline-flex;align-items:baseline;gap:4px;min-height:36px;padding:4px 12px;border:1.5px solid var(--line);border-radius:var(--radius-chip);color:var(--ink);font-family:var(--font-latin);font-weight:600;font-size:var(--type-ui);}
.related-strip a small{font-family:var(--font-ui);font-weight:400;font-size:var(--type-caption);color:var(--muted);}
.related-strip a.related-strip-all{border-color:transparent;background:var(--sage-soft);font-family:var(--font-ui);font-weight:400;}
@media(min-width:1024px){.related-strip{display:none;}}

/* Read aloud */
.speech-button{display:inline-grid;place-items:center;width:34px;height:34px;margin-left:4px;padding:0;border:0;border-radius:17px;background:transparent;color:var(--muted);vertical-align:middle;}
.speech-button:hover,.speech-button.is-speaking{background:var(--sage-soft);color:var(--sage);}
.speech-icon{display:inline-block;width:18px;height:18px;background:currentColor;-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9v6h4l5 4V5L8 9H4z'/%3E%3Cpath d='M16.5 8.5a5 5 0 0 1 0 7'/%3E%3Cpath d='M19 6a8.5 8.5 0 0 1 0 12'/%3E%3C/svg%3E") center/contain no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9v6h4l5 4V5L8 9H4z'/%3E%3Cpath d='M16.5 8.5a5 5 0 0 1 0 7'/%3E%3Cpath d='M19 6a8.5 8.5 0 0 1 0 12'/%3E%3C/svg%3E") center/contain no-repeat;}
.is-reading{background:var(--hl-soft);border-radius:6px;box-shadow:0 0 0 4px var(--hl-soft);}
.recording{display:inline-flex;align-items:center;}
.recording audio{height:40px;max-width:260px;}
.recording.is-enhanced audio{display:none;}
.recording-button{display:inline-flex;align-items:center;gap:8px;min-height:46px;padding:0 18px 0 14px;border:0;border-radius:23px;background:var(--sage);color:var(--on-sage);font-family:var(--font-ui);font-size:var(--type-ui);font-weight:500;}
.recording-button[aria-pressed=true]{filter:brightness(1.1);}
.speech-player{position:fixed;z-index:50;left:50%;bottom:max(16px,env(safe-area-inset-bottom));transform:translateX(-50%);width:min(640px,calc(100% - 20px));display:flex;align-items:center;gap:12px;padding:10px 10px 10px 16px;background:var(--surface);color:var(--ink);border:1px solid var(--line);border-radius:22px;box-shadow:var(--shadow);font-family:var(--font-ui);}
.speech-player-icon{flex:none;width:22px;height:22px;background:var(--sage);-webkit-mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9v6h4l5 4V5L8 9H4z'/%3E%3Cpath d='M16.5 8.5a5 5 0 0 1 0 7'/%3E%3Cpath d='M19 6a8.5 8.5 0 0 1 0 12'/%3E%3C/svg%3E") center/contain no-repeat;mask:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M4 9v6h4l5 4V5L8 9H4z'/%3E%3Cpath d='M16.5 8.5a5 5 0 0 1 0 7'/%3E%3Cpath d='M19 6a8.5 8.5 0 0 1 0 12'/%3E%3C/svg%3E") center/contain no-repeat;}
.speech-player-body{flex:1 1 auto;min-width:0;display:flex;flex-direction:column;gap:4px;}
.speech-player-label{font-size:var(--type-caption);color:var(--muted);}
.speech-player-text{font-family:var(--font-latin);font-size:var(--type-ui);white-space:nowrap;overflow:hidden;text-overflow:ellipsis;}
.speech-progress{display:block;height:4px;border-radius:2px;background:var(--line);overflow:hidden;}
#speech-progress-bar{display:block;height:4px;width:0;background:var(--sage);transition:width .2s linear;}
.speech-player.is-indeterminate #speech-progress-bar{width:35% !important;animation:speech-wait 1.3s ease-in-out infinite;}
@keyframes speech-wait{0%{transform:translateX(-100%);}100%{transform:translateX(290%);}}
@media(prefers-reduced-motion:reduce){.speech-player.is-indeterminate #speech-progress-bar{width:100% !important;opacity:.45;}}
.speech-stop{flex:none;display:grid;place-items:center;width:44px;height:44px;border:0;border-radius:22px;background:var(--sage);color:var(--on-sage);}
.stop-icon{width:14px;height:14px;border-radius:3px;background:currentColor;}
.speech-settings-dialog{width:min(440px,calc(100vw - 24px));padding:20px 22px;border:1px solid var(--line);border-radius:22px;background:var(--surface);color:var(--ink);box-shadow:var(--shadow);font-family:var(--font-ui);}
.speech-settings-dialog::backdrop{background:rgba(18,24,21,.3);}
.dialog-header{display:flex;align-items:center;justify-content:space-between;margin-bottom:12px;}
.dialog-header h2{font-family:var(--font-kai);font-size:var(--type-section);}
.speech-options{display:grid;gap:12px;}
.speech-options label{display:grid;gap:4px;font-size:var(--type-small);color:var(--muted);}
.speech-options select{min-height:44px;padding:0 10px;border:2px solid var(--line);border-radius:12px;background:var(--surface);color:var(--ink);font-size:var(--type-ui);}
.speech-note{margin-top:14px;font-size:var(--type-small);color:var(--muted);line-height:1.7;}

/* Side column sections */
.related-section,.lookup-tools{padding:20px 22px;border-radius:24px;background:var(--surface);}
.related-section h2{display:flex;align-items:baseline;gap:8px;font-family:var(--font-kai);font-size:var(--type-section);margin-bottom:10px;}
.related-section h2 span{font-family:var(--font-ui);font-size:var(--type-small);color:var(--muted);}
.related-phrases,.related-idioms{background:var(--sage-soft);}
.related-section ul{display:flex;flex-direction:column;gap:6px;margin:0;padding:0;list-style:none;}
.related-section li a{display:block;padding:9px 14px;border-radius:12px;background:var(--surface);font-family:var(--font-latin);font-weight:600;font-size:var(--type-body);}
.related-section li a[lang|=zh]{font-family:var(--font-kai);font-weight:400;font-size:var(--type-reading);}
.related-more{display:inline-flex;margin-top:10px;font-size:var(--type-ui);}
.relation-preview-head{display:flex;align-items:baseline;justify-content:space-between;gap:12px;}
.relation-preview-head h2{margin-bottom:0;}
.relation-preview-head a{font-size:var(--type-small);}
.relation-meaning{margin-top:14px;padding-top:12px;border-top:2px dashed var(--line);}
.relation-gloss{display:flex;gap:4px;align-items:baseline;margin-bottom:6px;font-size:var(--type-small);line-height:1.55;color:var(--muted);}
.relation-gloss .pos-mark{flex:none;font-size:var(--type-body);}
.relation-groups{margin:0;}
.relation-groups>div,.word-groups>div,.other-relations>div{display:grid;grid-template-columns:4.5em minmax(0,1fr);gap:6px;align-items:start;margin-top:6px;}
.relation-groups dt,.word-groups dt,.other-relations dt{padding-top:6px;font-family:var(--font-ui);font-size:var(--type-caption);color:var(--muted);}
.relation-groups dd,.word-groups dd,.other-relations dd,.chips{display:flex;flex-wrap:wrap;gap:6px;margin:0;}
.relation-groups a,.word-groups a,.other-relations a,.chips a{display:inline-flex;align-items:center;min-height:34px;padding:2px 12px;border:1.5px solid var(--line);border-radius:var(--radius-chip);color:var(--ink);font-family:var(--font-latin);font-weight:600;font-size:var(--type-ui);}
.relation-groups a[lang|=zh],.relation-groups a[lang=ja],.word-groups a[lang|=zh],.word-groups a[lang=ja],.chips a[lang|=zh],.other-relations a[lang|=zh]{font-family:var(--font-ui);font-weight:400;}
.relation-groups a:hover,.word-groups a:hover,.other-relations a:hover,.chips a:hover{border-color:var(--sage);text-decoration:none;}

/* Text lookup tools */
.lookup-tools>summary{font-family:var(--font-kai);font-size:var(--type-section);color:var(--ink);}
.text-lookup-heading{display:flex;align-items:baseline;justify-content:space-between;gap:12px;}
.text-lookup-heading h2{font-family:var(--font-kai);font-size:var(--type-body);}
.text-lookup-heading span,.text-lookup-note{font-size:var(--type-small);color:var(--muted);}
.text-spans{margin:10px 0;font-size:var(--type-reading);line-height:2;}
.text-spans a{padding:2px 4px;border-radius:6px;background:var(--hl-soft);color:var(--ink);}
.text-term-list{margin:10px 0 0;padding:0;list-style:none;display:flex;flex-direction:column;gap:10px;}
.text-term-links,.text-other-links{display:flex;flex-wrap:wrap;gap:6px;margin-top:4px;}
.text-term-links a,.text-other-links a{display:inline-flex;align-items:center;min-height:36px;padding:0 12px;border-radius:var(--radius-chip);background:var(--sage-soft);color:var(--ink);font-size:var(--type-small);}
.character-lookup{margin-top:12px;}
.character-lookup>summary span{color:var(--muted);}
.character-list{display:flex;flex-direction:column;gap:6px;margin:8px 0 0;padding:0;list-style:none;}
.character-list li{display:flex;align-items:center;gap:6px;}
.character-link{display:inline-grid;place-items:center;min-width:44px;height:44px;border-radius:12px;background:var(--sage-soft);color:var(--ink);font-family:var(--font-kai);font-size:var(--type-section);}
.character-source{display:inline-flex;align-items:center;min-height:36px;padding:0 10px;border-radius:var(--radius-chip);border:1.5px solid var(--line);font-size:var(--type-small);}

/* Related-words pages */
.relation-layout{display:flex;flex-wrap:wrap;gap:24px;align-items:flex-start;margin-top:18px;}
.meaning-list{flex:1 1 280px;min-width:0;padding:18px 12px 12px;border-radius:24px;background:var(--surface);font-family:var(--font-ui);}
.meaning-list h2{margin:0 10px 8px;font-family:var(--font-kai);font-size:var(--type-section);}
.meaning-list ol{margin:0;padding:0;list-style:none;}
.meaning-list a{display:block;padding:10px;border-radius:14px;color:var(--ink);}
.meaning-list a:hover{background:var(--sage-soft);text-decoration:none;}
.meaning-head{display:flex;align-items:baseline;gap:2px;font-family:var(--font-latin);font-weight:700;}
.meaning-list small{display:block;margin-top:2px;color:var(--muted);font-size:var(--type-small);line-height:1.5;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;}
.meaning-details{flex:999 1 560px;min-width:0;display:flex;flex-direction:column;gap:18px;}
.concept{scroll-margin-top:16px;}
.concept:target{box-shadow:0 0 0 3px var(--sage);}
.concept-head{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px;margin-bottom:8px;}
.concept-head .pos-mark{font-size:var(--type-section);}
.concept-head .headword{font-size:var(--type-word);}
.concept-source{font-family:var(--font-ui);font-size:var(--type-small);color:var(--muted);}
.concept.facet{margin-left:24px;}
.lexical-definition{margin-top:10px;}
.lexical-definition .eyebrow{display:block;margin-bottom:2px;}
.native-examples blockquote{margin:8px 0 0;font-size:var(--type-reading);line-height:var(--leading-reading);}
.native-examples blockquote+blockquote{color:var(--muted);}
.wordnet-examples{margin:6px 0 0;padding-left:1.2em;font-size:var(--type-reading);line-height:var(--leading-reading);}
.word-groups{margin:14px 0 0;}
/* Chinese ↔ Japanese/Korean reverse lookups: the matched meaning leads, English is the bridge. */
.pivot-entry{padding-top:12px;padding-bottom:12px;}
.pivot-sense{padding:18px 0;border-bottom:2px dashed var(--line);scroll-margin-top:16px;}
.pivot-sense:last-child{border-bottom:0;}
.pivot-sense:target{background:var(--hl-soft);border-radius:12px;}
.pivot-source{margin:0 0 6px;font-family:var(--font-kai);font-size:var(--type-word);font-weight:700;line-height:1.4;}
.pivot-entry .definition-line .definition{font-size:var(--type-section);font-weight:600;}
.pivot-via{margin:8px 0 0;font-family:var(--font-ui);font-size:var(--type-ui);color:var(--muted);}
.pivot-via-label{display:inline-block;margin-right:4px;padding:0 7px;border-radius:6px;background:var(--sage-soft);color:var(--sage);font-size:var(--type-small);font-weight:700;}
.pivot-via a{font-weight:700;}
.pivot-gloss{margin-left:6px;}
/* Chinese WordNet entry (chinese.cdict.info): readable sizes for Chinese labels and examples. */
.cwn-entry .pos-group:first-of-type{margin-top:20px;}
.cwn-relations{margin-top:12px;}
.cwn-relations>div{grid-template-columns:5.5em minmax(0,1fr);}
.cwn-relations dt{font-size:var(--type-ui);padding-top:5px;}
.cwn-relations a{font-size:var(--type-body);}
.cwn-example{margin:12px 0 0;font-size:var(--type-reading);line-height:var(--leading-reading);}
.cwn-example::before{content:"例";display:inline-block;margin-right:8px;padding:0 7px;border-radius:6px;background:var(--sage-soft);color:var(--sage);font-family:var(--font-ui);font-size:var(--type-small);font-weight:700;vertical-align:2px;}
.example-word{color:var(--sage);font-weight:700;}
.usage-note{display:inline-block;margin-left:6px;padding:0 9px;border-radius:var(--radius-chip);background:var(--sage-soft);font-family:var(--font-ui);font-size:var(--type-small);vertical-align:3px;}
.cwn-facets{list-style:none;margin:14px 0 0;padding:0;}
.cwn-facets>li{display:grid;grid-template-columns:2.8em minmax(0,1fr);gap:0 8px;margin-top:12px;padding-top:12px;border-top:1px solid var(--line);}
.facet-number{font-weight:700;color:var(--sage);font-size:var(--type-reading);line-height:1.6;}
.facet-body{min-width:0;}
.facet-body .definition{font-size:var(--type-reading);}
.facet-pos{display:block;font-family:var(--font-ui);font-size:var(--type-small);color:var(--muted);}
.sense-anchor{display:block;height:0;}
.cwn-sense,.cwn-facets>li{scroll-margin-top:16px;}
.cwn-sense:target,.cwn-facets>li:target{background:var(--hl-soft);border-radius:12px;}
.hierarchy{display:flex;flex-direction:column;align-items:center;gap:0;margin-top:20px;padding:20px 18px;border-radius:20px;background:var(--bg);text-align:center;}
.hierarchy-up,.hierarchy-down{display:flex;flex-direction:column;align-items:center;gap:8px;}
.hierarchy-up p,.hierarchy-down p{font-family:var(--font-ui);font-size:var(--type-small);color:var(--muted);}
.hierarchy .chips{justify-content:center;}
.hierarchy .chips a{background:var(--surface);}
.hierarchy-self{position:relative;margin:30px 0;padding:8px 22px;border-radius:16px;background:var(--sage);color:var(--on-sage);font-weight:800;font-size:var(--type-section);}
.hierarchy-self::before,.hierarchy-self::after{content:"";position:absolute;left:50%;width:2px;height:22px;background:var(--sage);}
.hierarchy-self::before{bottom:100%;margin-bottom:4px;}
.hierarchy-self::after{top:100%;margin-top:4px;}
.hierarchy-self:first-child{margin-top:0;}.hierarchy-self:first-child::before{display:none;}
.hierarchy-self:last-child{margin-bottom:0;}.hierarchy-self:last-child::after{display:none;}
.more-chips{margin-top:8px;}
.other-relations{margin:16px 0 0;}

/* Advertising */
.advertisement{display:block;margin:20px 0;padding:10px 0;min-height:120px;}
.advertisement-label{display:block;margin-bottom:6px;font-family:var(--font-ui);font-size:var(--type-caption);color:var(--muted);}
.advertisement:has(ins.adsbygoogle[data-ad-status="unfilled"]){display:none;}

/* Footer */
.site-footer{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:20px 40px;padding:32px max(var(--gutter),calc((100% - var(--page-max)) / 2 + var(--gutter))) 120px;background:var(--surface);border-top:1px solid var(--line);font-family:var(--font-ui);font-size:var(--type-ui);color:var(--muted);}
.footer-brand{grid-column:1/-1;display:flex;flex-wrap:wrap;align-items:baseline;justify-content:space-between;gap:8px;}
.footer-brand span:first-child{font-family:var(--font-kai);font-size:var(--type-section);font-weight:700;color:var(--ink);}
.dictionary-sites{display:flex;flex-wrap:wrap;gap:6px 18px;align-content:flex-start;}
.dictionary-sites a{display:inline-flex;align-items:center;min-height:40px;}
.friend-sites h2{font-size:var(--type-small);font-weight:500;margin-bottom:6px;}
.friend-sites ul{margin:0;padding:0;list-style:none;display:flex;flex-direction:column;gap:6px;}
.friend-sites small{display:block;color:var(--muted);font-size:var(--type-small);}
.footer-policy{grid-column:1/-1;margin:0;font-size:var(--type-small);}
.policy{max-width:760px;font-family:var(--font-ui);}
.policy h1{font-family:var(--font-kai);font-size:var(--type-display);line-height:1.35;margin:0 0 4px;}
.policy h2{font-family:var(--font-kai);font-size:var(--type-section);margin:28px 0 8px;}
.policy p,.policy li{line-height:1.8;}
.policy ul{padding-left:1.3em;}
.policy-updated{color:var(--muted);font-size:var(--type-small);margin-top:0;}
.font-credit{grid-column:1/-1;margin:0;font-size:var(--type-caption);color:var(--muted);}

/* Phones */
@media(max-width:699px){
  .site-header{padding-top:10px;padding-bottom:10px;gap:10px;}
  .brand img{width:38px;height:38px;}
  .lookup-page .brand-wordmark{display:none;}
  .lookup-page .header-search{order:2;flex-basis:100%;max-width:none;}
  .lookup-page .header-actions{order:1;}
  .site-menu>summary{padding:0 10px;}
  .site-menu-panel{left:var(--gutter);right:var(--gutter);width:auto;grid-template-columns:repeat(2,minmax(0,1fr));padding:18px;}
  .hero{margin-top:22px;}
  .hero-search{padding:12px;}
  .hero-search .query-control{flex-wrap:wrap;padding:4px;}
  .hero-search .query-control input{padding:0 10px;}
  .hero-search .search-button{flex-basis:100%;}
  .entry,.result,.concept,.cwn-head{padding:22px 18px 16px;}
  .sense{grid-template-columns:24px minmax(0,1fr);gap:0 8px;}
  .site-footer{grid-template-columns:minmax(0,1fr);}
  .concept.facet{margin-left:0;}
  /* Dictionary tabs keep the whole first row; display options move to a second row. */
  .tabs-inner{flex-wrap:wrap;column-gap:8px;}
  .dictionary-tabs{flex-basis:100%;}
  .script-switch{margin:6px 0 8px;}
  .speech-settings-open{margin:2px 0 4px auto;}
}

/* Touch screens: every control reaches the 44px target. */
@media(pointer:coarse){
  .lookup-trigger,.more-phonetics .lookup-trigger{min-width:44px;min-height:44px;}
  .script-switch>*{min-height:44px;}
  .speech-button{width:44px;height:44px;border-radius:22px;}
  .relation-groups a,.word-groups a,.other-relations a,.chips a,.related-strip a,.text-term-links a,.text-other-links a,.character-source,.lookup-choices a{min-height:44px;}
  .back-link,.explore-links a,.example-translations>summary,.more-examples>summary,.other-definitions>summary,.native-examples>summary{min-height:44px;}
}
