:root {
  --hy-ink: #17324d;
  --hy-navy: #143b57;
  --hy-jade: #16836f;
  --hy-jade-dark: #0d6658;
  --hy-gold: #d69a35;
  --hy-paper: #f7f6f1;
  --hy-surface: #ffffff;
  --hy-line: #d7e2df;
  --hy-muted: #61756f;
  --hy-danger: #aa493f;
  --hy-shadow: 0 12px 34px rgba(20, 59, 87, .09);
  color-scheme: light;
}

body {
  color: var(--hy-ink);
  background-color: var(--hy-paper) !important;
  background-image:
    radial-gradient(circle at 8% 5%, rgba(22, 131, 111, .08), transparent 24rem),
    linear-gradient(rgba(20, 59, 87, .025) 1px, transparent 1px),
    linear-gradient(90deg, rgba(20, 59, 87, .025) 1px, transparent 1px);
  background-size: auto, 28px 28px, 28px 28px;
}

.top {
  position: relative;
  background: linear-gradient(112deg, var(--hy-navy), #205d70 72%, var(--hy-jade)) !important;
  color: #fff !important;
  box-shadow: 0 5px 18px rgba(20, 59, 87, .16);
}

.top::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--hy-gold) 0 12%, transparent 12% 14%, #7cc4b5 14% 33%, transparent 33%);
}

.card, .panel {
  border-color: var(--hy-line) !important;
  box-shadow: var(--hy-shadow) !important;
}

button:not(.danger), .primary, button.green, button.success {
  background-color: var(--hy-jade) !important;
  background-image: linear-gradient(135deg, var(--hy-jade), var(--hy-jade-dark)) !important;
  border-radius: 10px !important;
  box-shadow: 0 4px 10px rgba(13, 102, 88, .13);
}

button.secondary, .secondary {
  background-color: #2d6f9f !important;
  background-image: linear-gradient(135deg, #397fac, #245d89) !important;
  color: #fff !important;
  border-color: #245d89 !important;
}

button:disabled, button[aria-disabled="true"], .disabled {
  background-color: #a8b2ba !important;
  background-image: none !important;
  color: #eef1f3 !important;
  border-color: #a8b2ba !important;
  box-shadow: none !important;
  cursor: not-allowed !important;
  opacity: .72 !important;
}

button.danger, .danger {
  background-color: var(--hy-danger) !important;
}

button:hover:not(:disabled) { filter: brightness(1.06); }
button:active:not(:disabled) { transform: translateY(1px); }
button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible, a:focus-visible {
  outline: 3px solid rgba(214, 154, 53, .5) !important;
  outline-offset: 2px;
}

h1, h2, h3 { text-wrap: balance; }
h2 { color: var(--hy-ink); }
.muted, .small, .hint { color: var(--hy-muted) !important; }
.tag { background: #e5f2ee !important; color: var(--hy-jade-dark) !important; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; transition: none !important; animation: none !important; }
}

/* DEV58 responsive foundation: every page must stay inside the viewport. */
html { max-width: 100%; overflow-x: hidden; -webkit-text-size-adjust: 100%; }
body { max-width: 100%; overflow-x: hidden; }
*, *::before, *::after { box-sizing: border-box; }
img, video, canvas, svg { max-width: 100%; height: auto; }
audio { max-width: 100%; }
pre, code, .transcript, .result, .definition, .passage { overflow-wrap: anywhere; word-break: break-word; }
input, select, textarea { max-width: 100%; min-width: 0; }
textarea { resize: vertical; }
.wrap, .shell, main, .container { width: min(100%, 1240px); max-width: 100%; }
.row, .grid, .form-grid, .public-grid, .download-grid, .bank-grid { min-width: 0; }
.card, .panel, .task, .question { min-width: 0; max-width: 100%; }
.list, .table-wrap, .table-scroll { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { max-width: 100%; }
.modal { padding: max(12px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)) !important; overflow-y: auto; }
.modal .dialog, .dialog { width: min(100%, 760px) !important; max-width: 100% !important; max-height: calc(100dvh - 24px); overflow-y: auto; margin: auto !important; }

@media (max-width: 767px) {
  body { background-size: auto, 20px 20px, 20px 20px; padding-bottom: env(safe-area-inset-bottom); }
  .top { padding: 13px 14px !important; font-size: 18px !important; line-height: 1.35; }
  .wrap, .shell, main.container { width: 100% !important; margin: 0 auto !important; padding: 10px !important; }
  .card, .panel { margin-bottom: 10px !important; padding: 14px !important; border-radius: 12px !important; }
  h1 { font-size: clamp(20px, 6vw, 26px) !important; }
  h2 { font-size: clamp(18px, 5vw, 22px) !important; }
  h3 { font-size: 16px !important; }
  p { line-height: 1.65; }
  .row { display: flex !important; flex-wrap: wrap !important; gap: 8px !important; align-items: stretch !important; }
  .grid, .form-grid, .public-grid, .download-grid, .bank-grid, .question { grid-template-columns: minmax(0,1fr) !important; }
  .row > input, .row > select, .row > textarea, .row > label, .row > .grow { flex: 1 1 100% !important; width: 100% !important; }
  label input, label select, label textarea, .field { width: 100% !important; }
  button, .primary, .secondary, a.button { min-height: 44px; padding: 10px 13px !important; touch-action: manipulation; }
  .row > button { flex: 1 1 auto; }
  nav.card { position: sticky; top: 0; z-index: 20; overflow-x: auto; flex-wrap: nowrap !important; background: rgba(255,255,255,.96); backdrop-filter: blur(8px); }
  nav.card button { flex: 0 0 auto !important; white-space: nowrap; }
  .brand { align-items: flex-start !important; gap: 10px; flex-wrap: wrap; }
  .brand > div:first-child { flex: 1 1 100%; }
  .brand button { flex: 1 1 auto; }
  table.responsive-table, .responsive-table thead, .responsive-table tbody, .responsive-table tr, .responsive-table th, .responsive-table td { display: block; width: 100%; }
  table.responsive-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  table.responsive-table tr { margin: 0 0 10px; padding: 10px; border: 1px solid var(--hy-line); border-radius: 10px; background: #fff; }
  table.responsive-table td { border: 0 !important; padding: 5px 0 !important; white-space: normal !important; overflow-wrap: anywhere; }
  table.responsive-table td::before { content: attr(data-label); display: inline-block; min-width: 6em; margin-right: 6px; color: var(--hy-muted); font-weight: 600; }
  table:not(.responsive-table) { display: block; width: 100%; max-width: 100%; min-width: 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
  .list table:not(.responsive-table), .table-wrap table:not(.responsive-table), .table-scroll table:not(.responsive-table) { min-width: 640px; }
  .contact-layout { grid-template-columns: 1fr !important; }
  .contact-qr { width: min(72vw, 280px) !important; display: block; margin: auto; }
  details > summary { min-height: 44px; display: flex; align-items: center; }
  #home > nav.card {
    position: fixed !important; left: 0; right: 0; top: auto; bottom: 0; z-index: 100;
    display: grid !important; grid-template-columns: repeat(4,minmax(0,1fr)) !important;
    gap: 4px !important; margin: 0 !important; padding: 7px max(7px,env(safe-area-inset-right)) max(7px,env(safe-area-inset-bottom)) max(7px,env(safe-area-inset-left)) !important;
    border-radius: 14px 14px 0 0 !important; box-shadow: 0 -5px 22px rgba(20,59,87,.16) !important;
  }
  #home > nav.card button { width: 100%; min-width: 0; min-height: 48px; padding: 6px 3px !important; font-size: 13px; line-height: 1.2; white-space: normal; }
  #home:has(> nav.card) { padding-bottom: calc(78px + env(safe-area-inset-bottom)); }
}

@media (max-width: 420px) {
  .wrap, .shell, main.container { padding: 8px !important; }
  .card, .panel { padding: 12px !important; }
  .row > button { flex: 1 1 100%; width: 100%; }
  .badge, .tag { white-space: normal !important; }
}

.site-record-footer {
  width: 100%;
  box-sizing: border-box;
  padding: 22px 12px calc(22px + env(safe-area-inset-bottom));
  text-align: center;
  color: var(--hy-muted, #66788a);
  font-size: 13px;
  line-height: 1.6;
}

.site-record-footer a {
  color: inherit;
  text-decoration: none;
}

.site-record-footer a:hover,
.site-record-footer a:focus-visible {
  color: var(--hy-primary, #176b87);
  text-decoration: underline;
}

@media (max-width: 760px) {
  body:has(#home > nav.card) .site-record-footer {
    padding-bottom: calc(92px + env(safe-area-inset-bottom));
  }
}

/* DEV71: unified application shell and long-content ergonomics */
[hidden] { display: none !important; }

.yzh-app-bar {
  position: sticky;
  top: 0;
  z-index: 950;
  min-height: 54px;
  display: grid;
  grid-template-columns: minmax(148px, auto) minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  padding: 8px max(16px, calc((100vw - 1180px) / 2));
  color: #fff;
  background: rgba(8, 65, 91, .96);
  border-bottom: 1px solid rgba(255, 255, 255, .2);
  box-shadow: 0 6px 18px rgba(8, 51, 70, .18);
  backdrop-filter: blur(12px);
}

.yzh-app-bar a,
.yzh-app-bar button {
  min-height: 38px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 7px 12px;
  color: #fff;
  background: rgba(255, 255, 255, .12);
  border: 1px solid rgba(255, 255, 255, .28);
  border-radius: 10px;
  text-decoration: none;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.yzh-app-bar a:hover,
.yzh-app-bar button:hover,
.yzh-app-bar a:focus-visible,
.yzh-app-bar button:focus-visible {
  background: rgba(255, 255, 255, .22);
  outline: 3px solid rgba(255, 218, 116, .7);
  outline-offset: 1px;
}

.yzh-page-title {
  min-width: 0;
  overflow: hidden;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.yzh-redundant-back { display: none !important; }

.yzh-section-directory {
  position: sticky;
  top: 54px;
  z-index: 900;
  display: flex;
  gap: 8px;
  max-width: 1180px;
  margin: 0 auto 12px;
  padding: 8px 12px;
  overflow-x: auto;
  background: rgba(249, 252, 252, .96);
  border: 1px solid #d4e4e9;
  border-top: 0;
  border-radius: 0 0 12px 12px;
  box-shadow: 0 5px 14px rgba(16, 64, 78, .08);
  scrollbar-width: thin;
}

.yzh-section-directory a {
  flex: 0 0 auto;
  padding: 6px 10px;
  color: #174e63;
  border-radius: 8px;
  text-decoration: none;
  font-size: 14px;
  font-weight: 700;
}

.yzh-section-directory a:hover,
.yzh-section-directory a:focus-visible { background: #e3f3f0; }

.yzh-list-tools {
  position: sticky;
  top: 102px;
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  margin: 10px 0 0;
  background: #f7fbfc;
  border: 1px solid #d5e5e9;
  border-radius: 10px 10px 0 0;
}

.yzh-list-tools label { display: inline-flex; align-items: center; gap: 6px; margin: 0; }
.yzh-list-tools input { width: min(300px, 38vw); }
.yzh-list-tools select { width: auto; }
.yzh-list-tools .yzh-page-info { margin-left: auto; color: #49646d; white-space: nowrap; }
.yzh-list-tools button { padding: 7px 11px; }

.yzh-long-list {
  max-height: min(62vh, 660px);
  overflow: auto;
  border: 1px solid #d5e5e9;
  border-top: 0;
  border-radius: 0 0 10px 10px;
  overscroll-behavior: contain;
}

.yzh-long-list table { margin: 0; }
.yzh-long-list thead th { position: sticky; top: 0; z-index: 2; background: #edf6f8; }
.yzh-long-list.yzh-all-rows { max-height: none; overflow: visible; }

.yzh-back-top {
  position: fixed;
  right: 18px;
  bottom: 20px;
  z-index: 960;
  min-height: 42px;
  padding: 8px 13px;
  color: #fff;
  background: #176b87;
  border: 0;
  border-radius: 999px;
  box-shadow: 0 6px 18px rgba(9, 55, 72, .25);
  opacity: 0;
  pointer-events: none;
  transform: translateY(12px);
  transition: opacity .18s ease, transform .18s ease;
}

.yzh-back-top.is-visible { opacity: 1; pointer-events: auto; transform: none; }

.yzh-core-layout {
  display: grid;
  grid-template-columns: minmax(280px, .85fr) minmax(420px, 1.5fr);
  align-items: start;
  gap: 16px;
}

.yzh-word-browser {
  position: sticky;
  top: 112px;
  max-height: calc(100vh - 132px);
  overflow: auto;
}

.yzh-word-browser #wordGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.yzh-word-detail { min-width: 0; }
.yzh-word-toggle { display: none; }

@media (min-width: 761px) {
  #home > nav.card.yzh-sticky-tabs {
    position: sticky;
    top: 62px;
    z-index: 80;
    box-shadow: 0 8px 18px rgba(12, 63, 80, .12);
  }
}

@media (max-width: 760px) {
  .yzh-app-bar {
    min-height: 50px;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 6px;
    padding: 6px 8px;
  }

  .yzh-app-bar a,
  .yzh-app-bar button { min-height: 38px; padding: 7px 9px; font-size: 13px; }
  .yzh-back span { display: none; }
  .yzh-back { min-width: 40px; font-size: 24px !important; }
  .yzh-section-directory { display: none; top: 50px; margin-bottom: 8px; border-radius: 0; }
  .yzh-section-directory.is-open { display: flex; }

  .yzh-list-tools {
    position: static;
    display: grid;
    grid-template-columns: minmax(0, 1fr) auto auto;
    gap: 7px;
  }

  .yzh-list-tools label:first-child { grid-column: 1 / -1; }
  .yzh-list-tools input { width: 100%; }
  .yzh-list-tools .yzh-page-info { grid-column: 1 / -1; grid-row: 2; margin: 0; }
  .yzh-list-tools label:nth-child(2) { display: none; }
  .yzh-long-list { max-height: none; overflow: visible; border: 0; }

  table.yzh-responsive-table thead { display: none; }
  table.yzh-responsive-table,
  table.yzh-responsive-table tbody,
  table.yzh-responsive-table tr,
  table.yzh-responsive-table td { display: block; width: 100%; }
  table.yzh-responsive-table tr {
    margin: 0 0 10px;
    padding: 8px 10px;
    background: #fff;
    border: 1px solid #d7e5e9;
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(24, 68, 82, .06);
  }
  table.yzh-responsive-table td {
    display: grid;
    grid-template-columns: minmax(82px, 34%) minmax(0, 1fr);
    gap: 9px;
    padding: 7px 0;
    border: 0;
    border-bottom: 1px dashed #e3ecef;
    text-align: left;
    overflow-wrap: anywhere;
  }
  table.yzh-responsive-table td:last-child { border-bottom: 0; }
  table.yzh-responsive-table td::before {
    content: attr(data-label);
    color: #526b74;
    font-weight: 700;
  }
  table.yzh-responsive-table td[colspan] { display: block; }
  table.yzh-responsive-table td[colspan]::before { content: none; }

  .yzh-core-layout { display: flex; flex-direction: column; }
  .yzh-word-detail { order: 1; width: 100%; }
  .yzh-word-browser { display: none; order: 2; position: static; width: 100%; max-height: 62vh; }
  .yzh-word-browser.is-open { display: block; }
  .yzh-word-browser #wordGrid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .yzh-word-toggle { display: inline-flex; margin: 0 0 10px; }
  .yzh-back-top { bottom: calc(88px + env(safe-area-inset-bottom)); }
}
