/* Shared chrome for the main tools and the standalone planners. */
:root {
  --font: "IBM Plex Sans", "Helvetica Neue", sans-serif;
  --tool-display: "Jersey 10", "IBM Plex Sans", sans-serif;
  --control-line: #83917d; --seal: #397529; --selected: #e2ecd3;
  --danger-ink: #873c1c; --grass: #79a946;
}
html:is(:lang(zh), :lang(ja), :lang(ko), :lang(ru)) { --tool-display: var(--font); }
html:lang(zh) { --font: "IBM Plex Sans", "PingFang SC", "PingFang TC", "Microsoft YaHei", sans-serif; }
html:lang(zh-Hant) { --font: "IBM Plex Sans", "PingFang TC", "Microsoft JhengHei", sans-serif; }
html:lang(ja) { --font: "IBM Plex Sans", "Hiragino Kaku Gothic ProN", "Yu Gothic", sans-serif; }
html:lang(ko) { --font: "IBM Plex Sans", "Apple SD Gothic Neo", "Malgun Gothic", sans-serif; }
/* The language control stays discoverable; only its destinations collapse. */
.language-control { position: relative; grid-column: 2; grid-row: 1; justify-self: end; min-width: 0; }
.language-picker { position: relative; }
.language-picker summary {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  min-width: 154px;
  max-width: 190px;
  padding: 9px 10px;
  list-style: none;
  border: 1px solid var(--control-line);
  border-radius: 4px;
  background: var(--paper);
  color: var(--ink);
  font: 600 14px/1.35 var(--font);
  cursor: pointer;
  user-select: none;
  touch-action: manipulation;
  transition: transform 120ms cubic-bezier(.23, 1, .32, 1);
}
.language-picker summary::-webkit-details-marker { display: none; }
.language-picker summary:active { transform: scale(.98); }
.language-picker[open] summary { border-color: var(--seal); background: var(--selected); }
.language-picker .selected-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pixel-globe { width: 20px; height: 20px; flex: none; color: var(--seal); shape-rendering: crispEdges; }
.language-chevron { width: 10px; height: 10px; margin-left: auto; flex: none; transition: transform 180ms cubic-bezier(.23, 1, .32, 1); }
.language-picker[open] .language-chevron { transform: rotate(180deg); }
.language-panel {
  position: absolute;
  z-index: 2;
  right: 0;
  top: calc(100% + 12px);
  width: min(362px, calc(100vw - 40px));
  max-height: min(620px, calc(100dvh - 96px));
  padding: 16px;
  overflow: auto;
  overscroll-behavior: contain;
  border: 1px solid var(--control-line);
  border-top: 3px solid var(--seal);
  border-radius: 5px;
  color: var(--ink);
  background: var(--paper);
  box-shadow: 0 12px 28px rgb(35 56 32 / 15%), 0 2px 3px rgb(35 56 32 / 7%);
  transform-origin: top right;
  opacity: 1;
  transform: translateY(0) scale(1);
  transition: transform 180ms cubic-bezier(.23, 1, .32, 1), opacity 180ms cubic-bezier(.23, 1, .32, 1);
}
.language-panel-heading { display: flex; align-items: center; gap: 11px; margin-bottom: 14px; padding-inline: 1px; font: 600 16px/1.35 var(--font); }
.pixel-book { width: 35px; height: 31px; flex: none; overflow: visible; shape-rendering: crispEdges; }
.book-left, .book-right { transform-origin: 17px 15px; transform: rotateY(0deg); transition: transform 180ms cubic-bezier(.23, 1, .32, 1); }
@starting-style {
  .language-picker[open] .language-panel { opacity: 0; transform: translateY(-5px) scale(.97); }
  .language-picker[open] .book-left { transform: rotateY(55deg); }
  .language-picker[open] .book-right { transform: rotateY(-55deg); }
}
.language-switch { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 5px; font: 14px/1.4 var(--font); }
.language-switch > a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 5px;
  min-width: 0;
  min-height: 48px;
  padding: 8px 9px;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--ink);
  background: var(--paper);
  text-decoration: none;
  touch-action: manipulation;
}
.language-name { min-width: 0; overflow-wrap: anywhere; }
.language-check { flex: none; color: var(--seal); visibility: hidden; }
.language-switch > a[aria-current="true"] { border-color: #c9d9b8; background: var(--selected); font-weight: 600; }
.language-switch > a[aria-current="true"] .language-check { visibility: visible; }
.language-picker summary:focus-visible, .language-switch a:focus-visible { outline: 3px solid #508fba; outline-offset: 3px; }
.language-status { grid-column: 1 / -1; margin: 4px 0 0; padding: 10px; border-top: 1px solid var(--line); background: var(--paper); color: var(--danger-ink); overflow-wrap: anywhere; }
.language-status a { display: inline-flex; min-height: 44px; align-items: center; font-weight: 600; }
.language-picker[data-keyboard] :is(.language-panel, .book-left, .book-right, .language-chevron),
.language-control[data-keyboard] :is(.language-panel, .book-left, .book-right, .language-chevron) { transition: none; }
/* Original decorative cube. It never captures taps or changes page height. */
.language-discovery-cue { position: absolute; right: 0; top: calc(100% + 1px); width: 144px; height: 30px; pointer-events: none; z-index: 1; }
.language-discovery-cue[hidden] { display: none !important; }
.cue-art { display: block; width: 144px; height: 30px; overflow: visible; shape-rendering: crispEdges; }
.cue-cube, .cube-fragment, .cue-hand { transform-box: fill-box; transform-origin: center; }
.cube-whole, .cue-hand, .cube-fragment, .crack-one, .crack-two, .cue-label { opacity: 0; }
.cue-label { position: absolute; left: 80px; top: 7px; max-width: 64px; color: var(--accent); font: 600 10px/14px var(--font); white-space: nowrap; text-shadow: 0 1px var(--paper); }
@media (hover: hover) and (pointer: fine) {
  .language-picker summary:hover { background: var(--selected); }
  .language-switch > a:hover { border-color: var(--control-line); background: #eef2e4; }
}
@media (prefers-reduced-motion: reduce) {
  .language-discovery-cue { display: none !important; }
  .language-picker :is(.language-panel, .book-left, .book-right, .language-chevron) { transition: none; }
}
.site-header {
  --accent: #316b2a;
  position: relative;
  isolation: isolate;
  z-index: 30;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 16px;
  min-height: 88px;
  padding: 12px 8px;
}
.site-header::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}
.brand {
  display: flex;
  min-width: 0;
  justify-self: start;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  text-decoration: none;
  color: var(--ink);
}
.site-header .brand .brand-logo {
  display: block;
  width: 210px;
  max-width: 100%;
  height: auto;
}
.brand .tagline {
  display: none;
}
.nav {
  width: 100%;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  grid-column: 1 / -1;
  grid-row: 2;
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  font-family: var(--tool-display);
  font-size: 24px;
  font-weight: 400;
  font-synthesis: none;
  line-height: 1.1;
}
.nav a {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid transparent;
  border-radius: 4px;
  background: transparent;
  color: var(--ink);
  text-decoration: none;
  text-align: center;
  min-width: 0;
  white-space: normal;
  text-wrap: balance;
  transition: background-color 140ms ease, border-color 140ms ease;
}
.nav img { width: 24px; height: 24px; flex-shrink: 0; }
.nav a:hover {
  color: var(--accent);
  background: var(--selected);
}
.nav a[aria-current="page"] {
  color: var(--accent);
  background: var(--selected);
  border-color: transparent;
  box-shadow: inset 0 -3px var(--grass);
}

@media (max-width: 980px) {
  .site-header { grid-template-columns: minmax(0, 1fr) auto; gap: 12px; padding: 14px 0 12px; }
  .brand { grid-column: 1; grid-row: 1; justify-self: start; }
  .site-header .brand .brand-logo { width: 210px; }
  .language-control { grid-column: 2; grid-row: 1; }
  .language-discovery-cue { top: calc(100% - 2px); }
  .nav {
    grid-column: 1 / -1;
    grid-row: 2;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    justify-self: center;
    width: 100%;
    padding-top: 12px;
    border-top: 1px solid var(--line);
    font-size: 24px;
    gap: 6px;
  }
  .nav a { min-width: 0; min-height: 48px; padding: 8px 6px; gap: 8px; white-space: normal; text-wrap: balance; }
  .nav img { width: 20px; height: 20px; }
}
@media (max-width: 540px) {
  .site-header { gap: 12px 8px; }
  .site-header .brand .brand-logo { width: 170px; }
  .language-picker summary { min-width: 0; max-width: 168px; gap: 6px; padding-inline: 9px; font-size: 13px; }
  .language-picker .selected-name { max-width: 108px; }
  .pixel-globe { width: 18px; height: 18px; }
  /* Keep an inset even when desktop-style scrollbars reduce a narrow viewport. */
  .language-panel { width: min(344px, calc(100vw - 40px)); padding: 13px; top: calc(100% + 10px); max-height: calc(100dvh - 90px); }
  .language-switch { font-size: 13px; }
  .language-switch > a { padding: 8px; }
  .nav { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 2px; font-size: 22px; }
  .nav a { min-height: 44px; padding-inline: 4px; gap: 6px; }
  .nav img { width: 16px; height: 16px; }
}
@media (max-width: 360px) {
  .site-header .brand .brand-logo { width: 132px; }
  .language-picker summary { max-width: 142px; padding-inline: 7px; font-size: 12px; }
  .language-picker .selected-name { max-width: 86px; }
  .pixel-globe { width: 17px; height: 17px; }
  .language-panel { padding: 11px; }
  .language-panel-heading { font-size: 15px; }
  .language-switch { font-size: 12px; }
  .language-switch > a { padding: 7px 6px; gap: 3px; }
  .language-discovery-cue { width: 136px; }
  .cue-art { width: 136px; }
  .cue-label { left: 76px; font-size: 9px; }
}


.site-header .brand { grid-column: 1; grid-row: 1; }
.site-header .nav a:focus-visible { outline: 3px solid #508fba; outline-offset: 2px; }
html:is(:lang(zh), :lang(ja), :lang(ko), :lang(ru)) .nav { font-size: 18px; font-weight: 600; }
html:is(:lang(de), :lang(ru)) .nav a { overflow-wrap: anywhere; hyphens: auto; }
@media (max-width: 540px) {
  html:is(:lang(zh), :lang(ja), :lang(ko), :lang(ru)) .nav { font-size: 15px; }
}
