/* LingoFruit Chinese · 灵果中文 — Shared Site Chrome & Base Components
 * Linked by every page after /tokens.css. */

*, *::before, *::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(rgba(19, 46, 38, 0.025) 1px, transparent 0);
  background-size: 24px 24px;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: 1.65;
  text-rendering: optimizeLegibility;
}

img, svg {
  max-width: 100%;
}

a {
  color: inherit;
  text-underline-offset: 3px;
  text-decoration-thickness: 1px;
}

/* ---- Skip link & focus ---- */
.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--surface);
  padding: 12px 18px;
  font-size: var(--text-sm);
  font-weight: 600;
  text-decoration: none;
  z-index: 100;
  border-radius: 0 0 var(--r-sm) 0;
}
.skip:focus {
  left: 0;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

[hidden] {
  display: none !important;
}

/* ---- Shared container widths ---- */
.site-header-inner,
.site-footer-inner,
main {
  width: 100%;
  max-width: var(--max-page);
  margin-inline: auto;
  padding-inline: var(--gutter);
}

body.page-home .site-header-inner,
body.page-home .site-footer-inner,
body.page-home main {
  max-width: var(--max-home);
}

main {
  flex: 1 0 auto;
  padding-bottom: var(--s-8);
}

/* ---- Header & Navigation ---- */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: rgba(246, 243, 235, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--rule);
}

.site-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  min-height: 72px;
  padding-block: var(--s-3);
  flex-wrap: nowrap;
}

.header-right {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-shrink: 0;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
  min-height: 44px;
}

.brand img {
  width: 32px;
  height: 32px;
  display: block;
  border-radius: var(--r-sm);
  flex-shrink: 0;
}

.brand-name {
  display: inline-flex;
  align-items: baseline;
  gap: 7px;
  letter-spacing: -0.02em;
  white-space: nowrap;
}

.brand-en {
  font-family: var(--font-display);
  font-size: 1.1875rem;
  font-weight: 700;
  color: var(--ink);
}

.brand-zh {
  font-family: var(--font-zh);
  font-size: 0.9375rem;
  font-weight: 500;
  color: var(--accent-mid);
}

.site-nav {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-wrap: nowrap;
}

.site-nav a {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  min-height: 44px;
  padding: 0 11px;
  align-items: center;
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  position: relative;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
  white-space: nowrap;
}

.site-nav a .nav-zh {
  font-family: var(--font-zh);
  font-size: 0.8125rem;
  color: var(--ink-3);
  font-weight: 400;
}

.site-nav a:hover {
  color: var(--ink);
  background: var(--surface-2);
}

.site-nav a[aria-current="page"] {
  color: var(--accent);
  font-weight: 650;
  background: var(--accent-soft);
}

.site-nav a[aria-current="page"] .nav-zh {
  color: var(--accent);
}

.site-nav a[aria-current="page"]::after {
  content: "";
  position: absolute;
  left: 11px;
  right: 11px;
  bottom: 4px;
  height: 2px;
  background: var(--accent);
  border-radius: 1px;
}

/* Pure-CSS "More / Tools" dropdown in nav */
.nav-more {
  position: relative;
}

.nav-more > summary {
  list-style: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  min-height: 44px;
  padding: 0 11px;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink-2);
  border-radius: var(--r-sm);
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.nav-more > summary::-webkit-details-marker {
  display: none;
}

.nav-more > summary:hover,
.nav-more[open] > summary {
  color: var(--ink);
  background: var(--surface-2);
}

.nav-more > summary .chev {
  width: 14px;
  height: 14px;
  transition: transform var(--t-fast) var(--ease);
}

.nav-more[open] > summary .chev {
  transform: rotate(180deg);
}

.nav-more.has-current > summary {
  color: var(--accent);
  font-weight: 650;
  background: var(--accent-soft);
}

.nav-menu {
  position: absolute;
  right: 0;
  top: calc(100% + 6px);
  min-width: 230px;
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  display: grid;
  gap: 2px;
  z-index: 50;
}

.nav-menu a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  min-height: 44px;
  padding: 0 12px;
  border-radius: var(--r-sm);
}

.nav-menu a[aria-current="page"]::after {
  display: none;
}

.lang-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--accent);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.lang-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

/* Mobile drawer menu (hidden on desktop) */
.mobile-nav {
  display: none;
}

.menu-btn {
  list-style: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 44px;
  min-width: 44px;
  padding: 0 12px;
  border: 1px solid var(--rule-strong);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--r-sm);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  cursor: pointer;
  user-select: none;
  white-space: nowrap;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.menu-btn::-webkit-details-marker {
  display: none;
}

.menu-btn:hover,
.mobile-nav[open] > .menu-btn {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.menu-btn svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
}

.menu-btn .ico-close {
  display: none;
}

.mobile-nav[open] > .menu-btn .ico-menu {
  display: none;
}

.mobile-nav[open] > .menu-btn .ico-close {
  display: block;
}

/* closed drawer must not participate in layout (prevents 1-5px page overflow) */
.mobile-nav:not([open]) > .mobile-drawer { display: none; }

.mobile-drawer {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  background: var(--surface);
  border-bottom: 1px solid var(--rule-strong);
  box-shadow: var(--shadow-lg);
  max-height: calc(100dvh - 60px);
  overflow-y: auto;
  z-index: 45;
}

.mobile-drawer-inner {
  width: 100%;
  max-width: var(--max-page);
  margin-inline: auto;
  padding: var(--s-4) var(--gutter) var(--s-5);
  display: grid;
  gap: var(--s-4);
}

.drawer-primary,
.drawer-tools-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: var(--s-2);
}

.drawer-primary a,
.drawer-tools-grid a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2);
  min-height: 44px;
  padding: 8px 12px;
  border-radius: var(--r-sm);
  border: 1px solid var(--rule-soft);
  background: var(--paper);
  text-decoration: none;
  font-size: var(--text-sm);
  font-weight: 500;
  color: var(--ink);
  transition: background var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.drawer-primary a:hover,
.drawer-tools-grid a:hover {
  border-color: var(--accent-mid);
  background: var(--surface-2);
}

.drawer-primary a[aria-current="page"],
.drawer-tools-grid a[aria-current="page"] {
  background: var(--accent-soft);
  border-color: var(--accent-rule);
  color: var(--accent);
  font-weight: 650;
}

.drawer-primary a .nav-zh,
.drawer-tools-grid a .nav-zh {
  font-family: var(--font-zh);
  font-size: 0.8125rem;
  color: var(--ink-3);
  font-weight: 400;
}

.drawer-primary a[aria-current="page"] .nav-zh,
.drawer-tools-grid a[aria-current="page"] .nav-zh {
  color: var(--accent);
}

.drawer-tools {
  border-top: 1px solid var(--rule);
  padding-top: var(--s-4);
  display: grid;
  gap: var(--s-3);
}

.drawer-label {
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

/* ---- Editorial Typography Primitives ---- */
.kicker,
small.kicker {
  display: inline-block;
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.page-head {
  padding: clamp(32px, 5vw, 60px) 0 var(--s-5);
  border-bottom: 1px solid var(--rule);
  margin-bottom: var(--s-6);
}

.page-head h1 {
  font-family: var(--font-display);
  font-weight: 400;
  font-size: var(--text-h1);
  line-height: 1.06;
  letter-spacing: -0.03em;
  margin: var(--s-3) 0 var(--s-4);
  color: var(--ink);
}

.page-head h1 i,
.hero h1 i {
  font-style: italic;
  color: var(--accent-mid);
}

.lead {
  max-width: 56ch;
  color: var(--ink-2);
  font-size: var(--text-lead);
  line-height: 1.6;
  margin: 0;
}

.section-rule {
  border: 0;
  border-top: 1px solid var(--rule);
  margin: var(--s-7) 0 var(--s-5);
}

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 20px;
  background: var(--accent);
  color: var(--surface);
  border: 1px solid var(--accent);
  border-radius: var(--r-sm);
  text-decoration: none;
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: background var(--t-fast) var(--ease),
              border-color var(--t-fast) var(--ease),
              color var(--t-fast) var(--ease),
              transform var(--t-fast) var(--ease);
}

.btn:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn:active:not(:disabled) {
  transform: translateY(1px);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn.ghost {
  background: var(--surface);
  color: var(--accent);
  border-color: var(--rule-strong);
}

.btn.ghost:hover:not(:disabled) {
  background: var(--accent-soft);
  border-color: var(--accent-mid);
  color: var(--accent-hover);
}

.btn.small {
  min-height: 44px;
  padding: 8px 14px;
  font-size: var(--text-sm);
}

.btn svg,
button svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

/* ---- Form controls ---- */
input[type="text"],
input[type="search"],
select,
textarea {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  color: var(--ink);
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  min-height: 44px;
  padding: 10px 14px;
  max-width: 100%;
  transition: border-color var(--t-fast) var(--ease), box-shadow var(--t-fast) var(--ease);
}

textarea {
  line-height: 1.65;
  resize: vertical;
}

input[type="text"]:hover,
input[type="search"]:hover,
select:hover,
textarea:hover {
  border-color: var(--accent-mid);
}

input[type="text"]:focus,
input[type="search"]:focus,
select:focus,
textarea:focus {
  border-color: var(--accent);
}

/* ---- Utility inline cross-link banner ---- */
.ref-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-4);
  flex-wrap: wrap;
  padding: var(--s-3) var(--s-4);
  margin-top: var(--s-5);
  background: var(--surface-2);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  font-size: var(--text-sm);
  color: var(--ink-2);
}

.ref-banner a {
  color: var(--accent);
  font-weight: 600;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
}

.ref-banner a:hover {
  text-decoration: underline;
}

/* ---- Specimen card (shared motif for Chinese character display) ---- */
.specimen-frame {
  padding: var(--s-6);
  border: 1px solid var(--rule);
  border-radius: var(--r-lg);
  background: var(--surface-2);
  display: grid;
  place-items: center;
  min-height: 280px;
}

.specimen-sheet {
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-md);
  width: min(100%, 280px);
  padding: var(--s-5);
  text-align: center;
}

.tianzige {
  width: 112px;
  height: 112px;
  margin: var(--s-4) auto;
  display: grid;
  place-items: center;
  font-family: var(--font-zh);
  font-size: 68px;
  line-height: 1;
  color: var(--ink);
  border: 1px solid var(--gridline);
  border-radius: var(--r-sm);
  background:
    linear-gradient(90deg, transparent 49.5%, var(--gridline) 50%, transparent 50.5%),
    linear-gradient(transparent 49.5%, var(--gridline) 50%, transparent 50.5%),
    var(--surface);
}

/* ---- Footer ---- */
.site-footer {
  border-top: 1px solid var(--rule);
  background: var(--surface);
  margin-top: auto;
  color: var(--ink-3);
  font-size: var(--text-sm);
}

.site-footer-inner {
  padding-block: var(--s-7) var(--s-6);
}

.footer-grid {
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr;
  gap: var(--s-6);
  padding-bottom: var(--s-6);
}

.footer-brand p {
  margin: var(--s-3) 0 0;
  max-width: 34ch;
  color: var(--ink-3);
  line-height: 1.6;
}

.footer-col h2 {
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 650;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin: 0 0 var(--s-3);
}

.footer-col ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 2px;
}

.footer-col a {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  text-decoration: none;
  color: var(--ink-2);
  transition: color var(--t-fast) var(--ease);
}

.footer-col a:hover {
  color: var(--accent);
  text-decoration: underline;
}

.footer-bottom {
  border-top: 1px solid var(--rule);
  padding-top: var(--s-4);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  font-size: var(--text-xs);
  color: var(--ink-3);
}

.footer-credits {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s-2) var(--s-4);
}

.footer-credits a {
  color: var(--ink-2);
}

/* ---- Responsive ---- */
@media (max-width: 1020px) {
  .site-header-inner {
    height: 60px;
    min-height: 60px;
    padding-block: 0;
    gap: var(--s-2);
    flex-wrap: nowrap;
  }

  .brand {
    gap: 8px;
    min-width: 0;
  }

  .brand img {
    width: 28px;
    height: 28px;
  }

  .brand-en {
    font-size: 1.0625rem;
  }

  .brand-zh {
    font-size: 0.8125rem;
  }

  .site-nav {
    display: none;
  }

  .mobile-nav {
    display: block;
  }

  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: var(--s-5);
  }

  .footer-brand {
    grid-column: 1 / -1;
  }
}

@media (max-width: 560px) {
  .drawer-primary,
  .drawer-tools-grid {
    grid-template-columns: 1fr;
  }

  .footer-grid {
    grid-template-columns: 1fr;
    gap: var(--s-5);
  }
}

@media (max-width: 400px) {
  .site-header-inner {
    gap: 6px;
    padding-inline: 12px;
  }

  .header-right {
    gap: 6px;
  }

  .brand-name {
    gap: 5px;
  }

  .brand-en {
    font-size: 1rem;
  }

  .brand-zh {
    font-size: 0.75rem;
  }

  .lang-btn,
  .menu-btn {
    padding: 0 10px;
  }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}

/* ---- Print ---- */
@media print {
  .site-header,
  .site-footer,
  .skip,
  .ref-banner,
  .related-strip {
    display: none !important;
  }

  body {
    display: block !important;
    min-height: 0 !important;
    background: #fff !important;
    background-image: none !important;
    color: #000 !important;
  }

  main {
    display: block !important;
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }
}

/* ---- account & live sync chip ---- */
.acct-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 40px;
  margin-left: var(--s-2);
  padding: 5px 11px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-sm);
  background: var(--surface);
  font-size: var(--text-xs);
  font-weight: 500;
  color: var(--ink-2);
  text-decoration: none;
  white-space: nowrap;
  flex-shrink: 0;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.acct-chip:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-hover);
}

.acct-chip[aria-current="page"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 600;
}

.acct-chip.is-member,
.acct-chip[data-plan="member"] {
  border-color: var(--ochre-rule);
  background: var(--ochre-soft);
  color: var(--ochre);
}

.acct-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ink-4);
  flex-shrink: 0;
  transition: background var(--t-fast) var(--ease);
}

.acct-dot[data-sync-state="synced"],
.acct-chip[data-sync="synced"] .acct-dot,
.acct-chip-m[data-sync="synced"] .acct-dot {
  background: var(--ok);
}

.acct-dot[data-sync-state="syncing"],
.acct-chip[data-sync="syncing"] .acct-dot,
.acct-chip-m[data-sync="syncing"] .acct-dot {
  background: var(--ochre);
  animation: lf-sync-pulse 1.1s ease-in-out infinite;
}

.acct-dot[data-sync-state="offline"],
.acct-chip[data-sync="offline"] .acct-dot,
.acct-chip-m[data-sync="offline"] .acct-dot {
  background: var(--ink-4);
}

@keyframes lf-sync-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.85); }
}

.acct-label {
  font-weight: 600;
}

.acct-meta {
  font-size: 0.6875rem;
  color: var(--ink-3);
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--surface-2);
  border: 1px solid var(--rule-soft);
}

.acct-chip[data-sync="synced"] .acct-meta,
.acct-chip-m[data-sync="synced"] .acct-meta {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: var(--ok-rule);
}

.acct-chip[data-sync="syncing"] .acct-meta,
.acct-chip-m[data-sync="syncing"] .acct-meta {
  background: var(--warn-bg);
  color: var(--warn);
  border-color: var(--warn-rule);
}

.acct-chip-m {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  background: var(--paper);
  font-size: var(--text-sm);
  color: var(--ink);
  text-decoration: none;
}

.acct-chip-m:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.acct-chip-m .acct-meta {
  margin-left: auto;
}

.acct-chip-compact {
  display: none;
}

@media (max-width: 1340px) {
  .site-header-inner {
    gap: var(--s-2);
  }

  .site-nav a,
  .nav-more > summary {
    padding: 0 8px;
  }

  .site-nav .acct-chip {
    margin-left: var(--s-1);
    padding: 4px 9px;
  }

  .site-nav .acct-chip .acct-meta {
    display: none;
  }
}

@media (max-width: 1020px) {
  .acct-chip-compact {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    min-height: 36px;
    padding: 4px 8px;
    margin-left: 0;
    font-size: 0.75rem;
    max-width: 120px;
    overflow: hidden;
  }

  .acct-chip-compact .acct-label {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .acct-chip-compact .acct-meta {
    display: none;
  }
}

@media (max-width: 400px) {
  .acct-chip-compact {
    padding: 4px 7px;
    max-width: 82px;
    font-size: 0.6875rem;
  }

  .menu-btn .menu-lbl {
    display: none;
  }
}

/* ---- Related contextual strip (bottom of detail views) ---- */
.related-strip {
  margin-top: var(--s-6);
  padding: var(--s-4) var(--s-5);
  background: var(--surface);
  border: 1px solid var(--rule);
  border-radius: var(--r-md);
}

.related-head {
  margin-bottom: var(--s-3);
}

.related-links {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: var(--s-2);
}

.related-link {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 10px 12px;
  min-height: 44px;
  border-radius: var(--r-sm);
  border: 1px solid var(--rule-soft);
  background: var(--paper);
  text-decoration: none;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease);
}

.related-link:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
}

.related-link .rl-en {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--accent);
  line-height: 1.3;
}

.related-link .rl-zh {
  font-family: var(--font-zh);
  font-size: var(--text-xs);
  color: var(--ink-3);
  line-height: 1.35;
}

/* ---- Clickable headwords & word chips ---- */
.word-link {
  color: inherit;
  text-decoration: none;
  border-bottom: 1px dashed var(--rule-strong);
  transition: color var(--t-fast) var(--ease), border-color var(--t-fast) var(--ease);
}

.word-link:hover {
  color: var(--accent);
  border-bottom-color: var(--accent);
}

.word-chip-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
}

.word-chip {
  appearance: none;
  display: inline-flex;
  align-items: center;
  padding: 3px 8px;
  min-height: 30px;
  border: 1px solid var(--rule);
  border-radius: var(--r-sm);
  background: var(--paper);
  color: var(--ink);
  font-family: var(--font-zh);
  font-size: 0.9375rem;
  line-height: 1.25;
  cursor: pointer;
  text-decoration: none;
  transition: border-color var(--t-fast) var(--ease), background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}

.word-chip:hover,
.word-chip[aria-expanded="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.inline-action-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 3px 8px;
  min-height: 28px;
  border-radius: var(--r-sm);
  border: 1px solid var(--accent-rule);
  background: var(--accent-soft);
  white-space: nowrap;
}

.inline-action-link:hover {
  background: var(--accent);
  color: var(--surface);
  border-color: var(--accent);
}

/* ---- Shared Word Popover (/words.js) ---- */
.lf-word-popover {
  position: absolute;
  z-index: 90;
  background: var(--surface);
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-md);
  box-shadow: var(--shadow-lg);
  padding: 14px 16px;
  color: var(--ink);
  box-sizing: border-box;
}

.lf-wp-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 6px;
}

.lf-wp-hanzi {
  font-family: var(--font-zh);
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--ink);
  text-decoration: none;
  line-height: 1.2;
}

.lf-wp-hanzi:hover {
  color: var(--accent);
  text-decoration: underline;
}

.lf-wp-close {
  appearance: none;
  border: 1px solid var(--rule);
  background: var(--paper);
  color: var(--ink-2);
  width: 28px;
  height: 28px;
  border-radius: var(--r-sm);
  font-size: 1rem;
  line-height: 1;
  cursor: pointer;
  flex-shrink: 0;
}

.lf-wp-close:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lf-wp-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  margin-bottom: 8px;
}

.lf-wp-py {
  font-size: var(--text-sm);
  font-weight: 600;
  color: var(--ochre);
}

.lf-wp-lv {
  font-size: 0.6875rem;
  font-weight: 650;
  padding: 1px 6px;
  border-radius: 4px;
  background: var(--accent-soft);
  color: var(--accent);
  border: 1px solid var(--accent-rule);
}

.lf-wp-speak {
  appearance: none;
  margin-left: auto;
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  color: var(--ink-2);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--r-sm);
  cursor: pointer;
}

.lf-wp-speak:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.lf-wp-en {
  margin: 0 0 10px;
  font-size: var(--text-sm);
  color: var(--ink-2);
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.lf-wp-loading {
  font-size: var(--text-sm);
  color: var(--ink-3);
}

.lf-wp-actions {
  margin-bottom: 10px;
}

.lf-wp-save {
  width: 100%;
  appearance: none;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--surface);
  font-family: var(--font-sans);
  font-size: var(--text-xs);
  font-weight: 600;
  padding: 8px 12px;
  min-height: 36px;
  border-radius: var(--r-sm);
  cursor: pointer;
}

.lf-wp-save:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.lf-wp-save:disabled {
  background: var(--ok-bg);
  color: var(--ok);
  border-color: var(--ok-rule);
  cursor: default;
}

.lf-wp-links {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  border-top: 1px solid var(--rule-soft);
  padding-top: 8px;
}

.lf-wp-links a {
  flex: 1 1 auto;
  text-align: center;
  font-size: var(--text-xs);
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  padding: 5px 8px;
  border-radius: var(--r-sm);
  background: var(--paper);
  border: 1px solid var(--rule);
  white-space: nowrap;
}

.lf-wp-links a:hover {
  background: var(--accent-soft);
  border-color: var(--accent);
}

/* ---- Mobile accessibility floor: 44px targets, 13px minimum type ---- */
@media (max-width: 860px) {
  .acct-chip,
  .acct-chip-m,
  .menu-btn,
  .footer-links a,
  .inline-action-link,
  .word-chip,
  .btn.small,
  .chip,
  .level,
  .tab-btn,
  .gl-lv,
  .han-py {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }
  .acct-chip-m { display: flex; }
  .btn.small, .chip, .level, .tab-btn { padding-block: 10px; }
  .footer-links a, .inline-action-link, .word-chip { padding-block: 8px; }
  .acct-chip, .footer, .footer-links, .inline-action-link, .gl-lv, .han-py, .tag {
    font-size: 13px;
  }
}
