/* U2 visual system. Loaded after main.css on every public and admin page. */
html[data-theme="light"] {
  color-scheme: light;
  --green: #267b51;
  --green-dim: #1d6843;
  --green-dark: #dcecdf;
  --green-darker: #f0f7ed;
  --green-glow: none;
  --green-glow-lg: none;
  --green-bg-6: rgba(38,123,81,.06);
  --green-bg-8: rgba(38,123,81,.08);
  --green-bg-10: rgba(38,123,81,.10);
  --green-bg-15: rgba(38,123,81,.15);
  --green-bg-20: rgba(38,123,81,.20);
  --green-bg-30: rgba(38,123,81,.30);
  --green-bg-40: rgba(38,123,81,.40);
  --green-bg-50: rgba(38,123,81,.50);
  --green-bg-60: rgba(38,123,81,.60);
  --bg: #fcfdf9;
  --bg2: #ffffff;
  --bg3: #f3f7f0;
  --bg4: #e8f0e7;
  --bg5: #dce9dc;
  --border: #e0e9de;
  --border-hover: #80ad8d;
  --border-subtle: #e8eee6;
  --text: #17251c;
  --text-dim: #53665a;
  --text-dark: #687d6e;
  --radius: 9px;
  --radius-lg: 15px;
  --font-main: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --green: #b9e777;
  --green-dim: #a4d563;
  --green-dark: #29442f;
  --green-darker: #15231a;
  --green-glow: none;
  --green-glow-lg: none;
  --green-bg-6: rgba(185,231,119,.06);
  --green-bg-8: rgba(185,231,119,.08);
  --green-bg-10: rgba(185,231,119,.10);
  --green-bg-15: rgba(185,231,119,.15);
  --green-bg-20: rgba(185,231,119,.20);
  --green-bg-30: rgba(185,231,119,.30);
  --green-bg-40: rgba(185,231,119,.40);
  --green-bg-50: rgba(185,231,119,.50);
  --green-bg-60: rgba(185,231,119,.60);
  --bg: #101a16;
  --bg2: #1a2821;
  --bg3: #203027;
  --bg4: #294035;
  --bg5: #34513e;
  --border: #304339;
  --border-hover: #729c64;
  --border-subtle: #293a30;
  --text: #ecf4e9;
  --text-dim: #b5c5b5;
  --text-dark: #95aa98;
  --radius: 9px;
  --radius-lg: 15px;
  --font-main: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
}
html { scroll-padding-top: 90px; }
body { overflow-x: hidden; font-size: 14px; line-height: 1.65; }
body, button, input, select, textarea { font-family: var(--font-main); }
button, input, textarea, select { max-width: 100%; }
button { cursor: pointer; }
a:hover { color: var(--green-dim); text-shadow: none; }
:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }
::selection { background: var(--green-bg-30); color: var(--text); }
.skip-link {
  position: fixed; z-index: 1000; top: 8px; left: 8px; padding: 9px 15px;
  background: var(--green); color: var(--bg); border-radius: var(--radius);
  transform: translateY(-150%);
}
.skip-link:focus { transform: none; color: var(--bg); }

/* Shared navigation and page structure */
.navbar { height: 66px; background: var(--bg); border-bottom-color: var(--border); box-shadow: 0 1px 0 var(--border-subtle); }
.navbar-inner { max-width: 1440px; gap: clamp(12px, 2vw, 28px); }
.navbar-logo { color: var(--green); text-shadow: none; font-family: var(--font-main); font-weight: 850; letter-spacing: -.05em; }
.navbar-logo span { letter-spacing: -.025em; }
.navbar-nav { gap: 4px; min-width: 0; }
.navbar-nav a { border-radius: 9px; font-weight: 550; white-space: nowrap; }
.navbar-nav a.active { font-weight: 750; }
.navbar-search { min-width: 0; }
.navbar-search input { background: var(--bg2); border-radius: 10px; min-height: 38px; width: clamp(150px, 17vw, 230px); }
.navbar-search input:focus { width: clamp(175px, 20vw, 260px); box-shadow: 0 0 0 3px var(--green-bg-15); }
.theme-toggle, .lang-switch > summary { height: 38px; min-width: 38px; border-radius: 10px; }
.lang-switch > summary { padding: 0 9px; }
.theme-toggle:hover, .lang-switch > summary:hover { background: var(--green-bg-8); }
.main-wrap { max-width: 1440px; padding: 32px 24px 70px; gap: 26px; }
.content { min-width: 0; }
.sidebar { width: 210px; top: 90px; padding: 16px 12px; background: var(--bg2); border: 1px solid var(--border); border-radius: var(--radius-lg); }
.sidebar-header { padding: 0 8px 12px; }
.sidebar-title { font-size: 11px; font-weight: 750; color: var(--text-dark); }
.sidebar-nav a { border-left: 0; border-radius: 9px; min-height: 39px; font-weight: 550; }
.sidebar-nav a:hover, .sidebar-nav a.active { border-left-color: transparent; background: var(--green-bg-10); }
.sidebar-nav a.active { font-weight: 750; text-shadow: none; }
.sidebar-expand-btn { top: 84px; }
.section-header { flex-wrap: wrap; }
.section-title { font-family: var(--font-main); font-size: 19px; letter-spacing: -.025em; line-height: 1.35; }
.section-title-accent { text-shadow: none; }
.section-more { color: var(--green); font-weight: 700; white-space: nowrap; }

/* Entry and listing pages */
.hero {
  max-width: 1392px; margin: 28px auto 0; padding: clamp(34px, 5vw, 68px);
  text-align: left; border: 1px solid var(--border); border-radius: 22px;
  background: radial-gradient(circle at 85% 20%, var(--green-bg-15), transparent 28%), linear-gradient(110deg, var(--green-darker), var(--bg) 75%);
}
.hero::before { display: none; }
.hero-eyebrow { margin-bottom: 13px; color: var(--green); font-size: 11px; font-weight: 800; letter-spacing: .18em; }
.hero-title { max-width: 900px; font-family: var(--font-main); font-size: clamp(35px, 5vw, 61px); letter-spacing: -.06em; line-height: 1.17; }
.hero-brand { display: block; margin-bottom: 12px; color: var(--green); font-size: .39em; font-weight: 800; letter-spacing: -.025em; }
.hero-title .accent { text-shadow: none; }
.hero-title span[style] { display: block; margin-top: 13px; font-size: .35em !important; line-height: 1.4; letter-spacing: 0 !important; }
.hero-subtitle { max-width: 700px; margin: 0 0 24px; font-size: 15px; line-height: 1.7; }
.hero-search { max-width: 650px; margin: 0 0 17px; border-radius: 13px; background: var(--bg2); box-shadow: 0 10px 24px rgba(24,50,34,.06); }
.hero-search:focus-within { box-shadow: 0 0 0 3px var(--green-bg-15); }
.hero-search input { min-width: 0; }
.hero-search-btn { border-radius: 9px; background: var(--green); color: var(--bg) !important; min-height: 40px; }
.hero-search-btn:hover { background: var(--green-dim); box-shadow: none; }
html[data-theme="dark"] .hero-search-btn { color: #142118 !important; }
.hero-tags { justify-content: flex-start; }
.hero-tags a { background: var(--bg2); border-radius: 20px; padding: 6px 12px; color: var(--text-dim); }
.tools-grid { grid-template-columns: repeat(auto-fill, minmax(225px, 1fr)); gap: 14px; }
.tool-card, .article-card, .ai-card, .res-card, .res-cat-tile { background: var(--bg2); border-radius: var(--radius-lg); }
.tool-card { min-height: 142px; padding: 19px; }
.tool-card:hover, .article-card:hover, .ai-card:hover, .res-card:hover, .res-cat-tile:hover {
  transform: translateY(-2px); box-shadow: 0 12px 30px rgba(20,55,29,.10);
}
html[data-theme="dark"] .tool-card:hover,
html[data-theme="dark"] .article-card:hover,
html[data-theme="dark"] .ai-card:hover,
html[data-theme="dark"] .res-card:hover { box-shadow: 0 12px 30px rgba(0,0,0,.23); }
.tool-card::before, .article-card::before { display: none; }
.tool-card-icon { width: 39px; height: 39px; border: 0; border-radius: 11px; background: var(--green-bg-10); }
.tool-card:hover .tool-card-icon { box-shadow: none; }
.tool-card-name { font-size: 15px; font-weight: 750; flex-wrap: wrap; overflow-wrap: anywhere; }
.tool-card-summary { font-size: 12.5px; color: var(--text-dim); }
.category-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 21px; }
.category-chips a { display: inline-flex; align-items: center; min-height: 35px; padding: 6px 12px; border: 1px solid var(--border); border-radius: 20px; background: var(--bg2); color: var(--text-dim); font-size: 12px; }
.category-chips a:hover, .category-chips a[aria-current="page"] { color: var(--green); background: var(--green-bg-10); border-color: var(--border-hover); }
.category-search { margin: 0 0 20px; max-width: 460px; }
.category-search label { display: block; margin-bottom: 7px; font-size: 12px; font-weight: 700; color: var(--text-dim); }
.category-search input { width: 100%; min-height: 42px; padding: 9px 13px; border: 1px solid var(--border); border-radius: 10px; background: var(--bg2); color: var(--text); }
.category-empty-filter { padding: 24px; margin-bottom: 18px; border: 1px solid var(--border); border-radius: 11px; color: var(--text-dim); }
.tool-card[hidden], .category-empty-filter[hidden] { display: none !important; }
.badge { border-radius: 5px; }
.badge-hot { color: #b84929; background: #fff0e8; border-color: #f0cfbe; }
html[data-theme="dark"] .badge-hot { color: #ffb89c; background: #4a302b; border-color: #60433a; }

/* Tool workspace: keep all existing tool-specific controls intact */
.tool-breadcrumb, .article-breadcrumb { color: var(--text-dark); flex-wrap: wrap; overflow-wrap: anywhere; }
.tool-breadcrumb a, .article-breadcrumb a { color: var(--text-dim); }
.tool-page-header { align-items: center; gap: 15px; margin-bottom: 21px; padding-bottom: 0; border-bottom: 0; }
.tool-page-icon { width: 50px; height: 50px; border: 0; border-radius: 13px; background: var(--green-bg-10); }
.tool-page-title { font-family: var(--font-main); font-size: clamp(24px, 3vw, 32px); font-weight: 820; letter-spacing: -.04em; line-height: 1.3; overflow-wrap: anywhere; }
.tool-page-summary { font-size: 13.5px; line-height: 1.6; color: var(--text-dim); }
.tool-workspace { padding: clamp(16px, 2.5vw, 27px); border-radius: 17px; box-shadow: 0 10px 30px rgba(20,55,29,.04); }
.tool-workspace .math-grid > * { min-width: 0; }
.tool-table-scroll { max-width: 100%; overflow-x: auto; }
.kinship-rel-grid { min-width: 0; }
.tool-intro { border-left: 1px solid var(--border); padding: clamp(18px, 2.5vw, 27px); }
.tool-intro h3 { font-family: var(--font-main); font-size: 18px; color: var(--text); }
.tool-intro h4 { margin: 18px 0 8px; font-size: 15px; }
.tool-intro p, .tool-intro li { font-size: 14px; line-height: 1.8; }
.form-control { background: var(--bg); border-radius: 10px; min-height: 41px; }
textarea.form-control { min-height: 100px; line-height: 1.65; }
.form-label { color: var(--text); font-size: 13px; font-weight: 650; }
.btn, .copy-btn { border-radius: 9px; min-height: 38px; }
.btn-primary { color: var(--bg) !important; }
html[data-theme="dark"] .btn-primary { color: #142118 !important; }
.tabs { gap: 7px; }
.tabs .tab { border-radius: 8px; cursor: pointer; }
.tab:focus-visible { outline-offset: -3px; }

/* Reading, AI directory and resource catalog */
.article-list { grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.article-card { padding: 22px; }
.article-card-title { font-size: 17px; line-height: 1.45; }
.article-card-summary { color: var(--text-dim); }
.article-detail-header { border-bottom-color: var(--border); }
.article-detail-title { font-family: var(--font-main); font-size: clamp(27px, 3.5vw, 38px); letter-spacing: -.04em; line-height: 1.28; overflow-wrap: anywhere; }
.article-detail-summary { max-width: 850px; margin: 10px 0 15px; color: var(--text-dim); font-size: 15px; line-height: 1.75; }
.article-content { max-width: 850px; font-size: 16px; line-height: 1.92; padding: clamp(20px, 4vw, 44px); border-radius: 16px; overflow-wrap: anywhere; }
.article-content h2 { font-size: 23px; margin-top: 38px; }
.article-content h3 { font-size: 19px; }
.article-content p { margin-bottom: 1.15em; }
.article-content pre, .article-content table { max-width: 100%; overflow-x: auto; }
.article-content blockquote { border-radius: 0 10px 10px 0; }
.article-toc { max-width: 850px; margin: 0 0 18px; padding: 12px 17px; border: 1px solid var(--border); border-radius: 12px; background: var(--bg2); }
.article-toc[hidden] { display: none; }
.article-toc summary { color: var(--text); font-size: 13px; font-weight: 750; cursor: pointer; }
.article-toc nav { display: grid; gap: 8px; margin-top: 12px; }
.article-toc a { color: var(--text-dim); font-size: 12.5px; line-height: 1.5; }
.article-toc a:hover { color: var(--green); }
.article-toc a.subsection { padding-left: 15px; }
.ai-topbar { background: var(--green-darker); border: 1px solid var(--border); border-radius: 18px; max-width: 1392px; margin: 28px auto 0; }
.ai-h1, .res-hero-title { color: var(--text); text-shadow: none; font-family: var(--font-main); font-size: clamp(25px, 3vw, 35px); letter-spacing: -.035em; }
.ai-search input, .res-search input { background: var(--bg2); border-radius: 10px; min-height: 44px; }
.ai-search button, .res-search button { border-radius: 10px; box-shadow: none !important; }
.ai-card, .res-card { overflow: hidden; }
.ai-card-main { padding: 18px; }
.ai-card-ico { border-radius: 10px; }
.ai-card-name, .res-card-title { overflow-wrap: anywhere; }
.ai-about { max-width: 900px; }
.ai-faq-item { padding: 15px 17px; border: 1px solid var(--border); border-radius: 11px; background: var(--bg2); }
.ai-faq-item h3 { font-size: 14px; }
.ai-faq-item p { font-size: 13px; }
.res-hero { padding: clamp(24px, 4vw, 45px); background: linear-gradient(110deg, var(--green-darker), var(--bg) 75%); border-radius: 18px; }
.res-cat-tile, .res-card { border-radius: 14px; }
.res-detail-title, .ai-detail-title { font-family: var(--font-main); letter-spacing: -.03em; overflow-wrap: anywhere; }
.res-content, .ai-block { line-height: 1.85; }
.res-content { overflow-wrap: anywhere; }
.footer { border-top-color: var(--border); }

/* Admin shares the same palette, with usable navigation and forms. */
.admin-wrap { max-width: 1440px !important; padding: 28px 24px 70px !important; }
.admin-nav { flex-wrap: wrap; }
.admin-form-group input, .admin-form-group textarea, .admin-form-group select { background: var(--bg2) !important; border-radius: 9px !important; min-height: 40px; }
.admin-btn { min-height: 38px; border-radius: 9px !important; }
.admin-table { background: var(--bg2); }
.admin-table th { background: var(--bg3) !important; }

/* Language, touch and responsive behavior */
html[lang|="en"] .hero-title, html[lang|="en"] .tool-page-title, html[lang|="en"] .article-detail-title { letter-spacing: -.025em; }
html[lang|="en"] .navbar-nav a { padding-inline: 9px; }
html[lang|="en"] .tool-card-name, html[lang|="en"] .article-card-title { line-height: 1.5; }
.tool-card-name, .section-title, .res-card-title, .ai-card-name { overflow-wrap: anywhere; }
@media (max-width: 1180px) {
  .navbar-inner { gap: 10px; padding-inline: 16px; }
  .navbar-nav a { padding-inline: 8px; }
  .navbar-search input { width: 155px; }
  .navbar-search input:focus { width: 170px; }
}
@media (max-width: 1024px) {
  .main-wrap { padding-inline: 18px; }
  .sidebar { display: none; }
  .hero, .ai-topbar { margin-inline: 18px; }
}
@media (max-width: 768px) {
  .navbar { height: 58px; }
  .navbar-mobile { top: 58px; background: var(--bg) !important; }
  .navbar-mobile a { min-height: 35px; display: inline-flex; align-items: center; }
  .main-wrap { padding: 22px 14px 55px; }
  .hero { margin: 16px 14px 0; padding: 27px 22px; border-radius: 16px; }
  .hero-title { font-size: clamp(32px, 8vw, 44px); }
  .hero-subtitle { font-size: 13.5px; }
  .tools-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
  .tool-card { min-height: 138px; padding: 15px; }
  .tool-card-name { font-size: 13px; }
  .tool-card-summary { font-size: 11.5px; }
  .article-content { padding: 20px !important; }
  .ai-topbar { margin: 16px 14px 0; }
  .res-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .admin-wrap { padding-inline: 14px !important; }
  .admin-nav { overflow-x: auto; flex-wrap: nowrap; }
  .admin-table { display: block; overflow-x: auto; }
}
@media (max-width: 520px) {
  .navbar-inner { gap: 7px; padding-inline: 12px; }
  .navbar-logo { font-size: 17px; }
  .navbar-search input { width: 100%; }
  .navbar-search input:focus { width: 100%; }
  .hero-search { margin-bottom: 14px; }
  .hero-search input { padding-inline: 9px; font-size: 12px; }
  .hero-search-btn { padding-inline: 13px; }
  .section-title { font-size: 17px; }
  .section-line { display: none; }
  .article-list, .ai-grid, .res-grid, .res-grid-full, .res-grid-home { grid-template-columns: 1fr; }
  .article-detail-title { font-size: 27px; }
  .article-breadcrumb > span:last-child,
  .article-breadcrumb > .article-breadcrumb-sep:nth-last-child(2) { display: none; }
  .tool-page-header { align-items: flex-start; }
  .tool-workspace { padding: 15px; }
  .json-editor-wrap textarea { height: 220px; }
  .tool-workspace .math-grid { grid-template-columns: minmax(0, 1fr) !important; }
  .screenshot-wrap, .collage-wrap { grid-template-columns: minmax(0, 1fr) !important; }
  .screenshot-panel, .screenshot-preview-area, .collage-panel, .collage-preview-area { min-width: 0; max-width: 100%; }
  .kinship-rel-grid { grid-template-columns: repeat(4, minmax(0, 1fr)) !important; }
  .btn-group { flex-wrap: wrap; }
  .res-detail-layout { display: block; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
