/* Eight traditional trigrams, drawn in the same top-to-bottom order as the book. */
.lk-sign {
  display: inline-flex;
  flex: none;
  flex-direction: column;
  justify-content: center;
  gap: var(--lk-line-gap, 2px);
  width: var(--lk-sign-width, 24px);
}
.lk-sign > i {
  display: flex;
  justify-content: space-between;
  height: var(--lk-line-height, 4px);
}
.lk-sign b {
  display: block;
  width: 100%;
  height: 100%;
  background: var(--lk-fill);
  box-shadow: inset 0 0 0 1px var(--lk-edge);
}
.lk-sign i[data-line="0"] b { width: 40%; }
.lk-qian { --lk-fill: #fffdf4; --lk-edge: #726a57; }
.lk-dui  { --lk-fill: #c9cbca; --lk-edge: #656b69; }
.lk-li   { --lk-fill: #bb4638; --lk-edge: #a63c32; }
.lk-zhen { --lk-fill: #478360; --lk-edge: #35704d; }
.lk-xun  { --lk-fill: #a4b557; --lk-edge: #6d7d36; }
.lk-kan  { --lk-fill: #2d3839; --lk-edge: #263233; }
.lk-gen  { --lk-fill: #ecd474; --lk-edge: #998335; }
.lk-kun  { --lk-fill: #ddaa5e; --lk-edge: #936737; }
.lk-hex { flex: none; display: inline-flex; flex-direction: column; gap: 3px; }

.lk-heading {
  margin: 2px 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}
.lk-heading h1 { font: 650 clamp(28px, 4vw, 38px)/1.35 var(--serif); letter-spacing: .07em; }
.lk-modes { display: inline-flex; background: #eceee4; border-radius: 9px; padding: 3px; flex: none; }
.lk-modes button { min-height: 44px; padding: 0 14px; font-size: 14px; color: #4e5c51; border-radius: 7px; }
.lk-modes button[aria-pressed="true"] {
  color: #193d32;
  background: #fffef8;
  font-weight: 650;
  box-shadow: 0 1px 4px #1d35221b;
}
.lk-matrix {
  border: 1px solid #c8cfc0;
  border-radius: 13px;
  overflow: hidden;
  background: var(--card);
}
.lk-matrix table { width: 100%; border-collapse: separate; border-spacing: 0; table-layout: fixed; }
.lk-matrix th, .lk-matrix td { padding: 0; vertical-align: middle; text-align: center; font-weight: 500; }
.lk-matrix :is(th, td):not(:last-child) { border-right: 1px solid #d9ddcf; }
.lk-matrix thead :is(th, td), .lk-matrix tbody tr:not(:last-child) :is(th, td) { border-bottom: 1px solid #d9ddcf; }
.lk-matrix th, .lk-axes { background: #ebeee3; }
.lk-matrix thead th { height: 63px; }
.lk-matrix .lk-axes { width: 8.1%; color: #47584a; font-size: 12px; line-height: 1.8; }
.lk-axes span { display: block; white-space: nowrap; }
.lk-plate { display: inline-flex; align-items: center; justify-content: center; gap: 5px; }
.lk-matrix .lk-plate { flex-direction: column; gap: 4px; }
.lk-sign-name { color: var(--ink); font: 650 15px/1.2 var(--serif); white-space: nowrap; }
.lk-sign-name small { font: 400 12px/1.2 system-ui,sans-serif; margin-left: 3px; color: #546051; }
.lk-cell { width: 100%; min-height: 54px; padding: 2px 1px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; }
.lk-cell strong { font: 650 clamp(16px, 2.1vw, 20px)/1.25 var(--serif); }
.lk-cell .lk-full { font-size: 12px; color: #425747; line-height: 1.25; }
.lk-theme { font-size: 12px; line-height: 1.35; color: #526151; font-weight: 400; }
.lk-cell:focus-visible { position: relative; z-index: 1; outline-offset: -3px; }
@media (hover:hover) {
  .lk-cell:hover, .lk-choice:hover, .lk-entry:hover { background: #eaf1e6; }
}
@media (min-width: 850px) {
  .lk-cell { min-height: 68px; }
}
@media (min-width: 850px) and (max-height: 750px) {
  .lk-cell { min-height: 57px; padding: 3px 1px; }
}
.lk-search input { background: transparent; border: none; width: 100%; min-width: 0; }
.lk-search input:focus-visible { outline-offset: 1px; }
.lk-picker { display: none; }
.lk-fields, .lk-preview { min-width: 0; }
.lk-options { margin: 0 0 14px; padding: 10px 12px 12px; border: 1px solid var(--border); border-radius: 10px; background: var(--card); }
.lk-options legend { padding: 0 5px; font: 650 18px/1.3 var(--serif); }
.lk-choices { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.lk-choice { min-width: 0; min-height: 45px; border: 1px solid #e0e2d5; border-radius: 6px; background: #f8f8f1; }
.lk-choice[aria-pressed="true"] { background: #e4eee1; border-color: #567963; box-shadow: inset 0 0 0 1px #567963; }
.lk-choice .lk-plate { flex-wrap: wrap; padding: 4px; gap: 4px; }
.lk-choice .lk-sign { --lk-sign-width: 18px; --lk-line-height: 3px; }
.lk-preview-button {
  display: flex; align-items: center; justify-content: space-between; text-align: left;
  width: 100%; padding: 16px; gap: 8px; background: #e8eee2;
  border: 1px solid #c5d2bc; border-radius: 10px;
}
.lk-preview-main { display: flex; gap: 12px; align-items: center; }
.lk-preview-main .lk-hex { --lk-sign-width: 32px; }
.lk-preview-text { display: flex; flex-direction: column; gap: 2px; }
.lk-preview-text > small { font-size: 12px; color: #526151; }
.lk-preview-text strong { font: 650 23px/1.25 var(--serif); }
.lk-details { font-size: 13px; color: var(--teal); flex: none; }
@media (max-width: 599.98px) {
  .lk-heading { align-items: start; flex-wrap: wrap; gap: 8px; margin-bottom: 14px; }
  .lk-modes button { padding: 0 9px; font-size: 13px; }
  .lk-matrix { display: none; }
  .lk-picker { display: block; }
}
@media (max-width: 359px) {
  .lk-choice .lk-plate { flex-direction: column; }
}
/* On a book hinge the two facets of one lookup remain on separate panes. */
html[data-fold=vertical] .lk-matrix, html[data-fold=horizontal] .lk-matrix { display: none; }
html[data-fold=vertical] .lk-heading, html[data-fold=vertical] .lk-picker {
  display: grid; grid-template-columns: minmax(0, calc(var(--hinge-x) - var(--gutter) - 10px)) minmax(0,1fr);
  column-gap: calc(var(--hinge-w) + 20px); align-items: start;
}
html[data-fold=vertical] .lk-modes { justify-self: start; }
html[data-fold=vertical] .lk-choice .lk-plate { flex-direction: column; }
html[data-fold=vertical] .lk-preview-button { flex-wrap: wrap; }
html[data-fold=horizontal] .lk-picker { display: block; }
html[data-fold=horizontal] .lk-preview {
  position: fixed; top: calc(var(--hinge-y) + var(--hinge-h) + 8px);
  left: var(--gutter); right: var(--gutter);
}
/* Two lines retain the full hexagram name on a shallow unfolded screen. */
@media (min-width: 600px) and (max-height: 660px) {
  html:not([data-fold]) body[data-page=library] #page { padding-top: 8px; }
  .lk-heading { margin: 0 0 7px; }
  .lk-heading h1 { font-size: 28px; }
  .lk-matrix thead th { height: 45px; }
  .lk-matrix .lk-plate { gap: 2px; }
  .lk-cell { min-height: 44px; padding: 2px 1px; }
  .lk-cell strong { display: none; }
  .lk-cell .lk-full { font: 650 clamp(13px, 1.85vw, 17px)/1.23 var(--serif); color: var(--ink); }
  .lk-cell .lk-theme { line-height: 1.2; }
}

@media (min-width:600px) and (max-height:620px){
  html:not([data-fold]) body[data-page="library"] .bar-inner{height:48px}
  html:not([data-fold]) body[data-page="library"] #page{padding-top:8px}
  .lk-heading{margin-block:0 6px}
  .lk-matrix .lk-plate{display:flex}
  .lk-matrix thead th{height:42px}
  .lk-matrix thead .lk-plate{gap:2px}
}
