html,
body {
  width: 100%;
  height: 100%;
  overflow: hidden;
}

#help {
  width: 100%;
  height: 100%;
  min-height: 100%;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr);
  background: var(--bg);
  color: var(--hud);
  overflow: hidden;
}

.icon-sprite {
  position: absolute;
  width: 0;
  height: 0;
  overflow: hidden;
}

#help-bar {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 12px;
  width: 100%;
  min-height: 48px;
  padding: 6px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--bar);
  z-index: 20;
}

#help-bar a.brand {
  display: block;
  min-width: 0;
  margin-right: auto;
  padding: 0;
  border: none;
  background: none;
  color: inherit;
  text-decoration: none;
  text-align: left;
  letter-spacing: inherit;
  font-size: inherit;
  font-weight: inherit;
  cursor: pointer;
}

#help-bar a.brand strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#help-bar a.brand:hover,
#help-bar a.brand:hover .kicker,
#help-bar a.brand:hover strong {
  color: var(--accent);
}

#help-bar .help-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

#help-bar button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--hud-dim);
  font-family: inherit;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.1em;
  padding: 5px 8px;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
}

#help-bar button:hover {
  border-color: var(--accent);
  color: var(--accent);
}

#help-bar .help-search-trigger {
  width: 160px;
  flex: 0 0 160px;
  height: 28px;
  gap: 6px;
  background: var(--input);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 0 8px;
  text-align: left;
}

.help-search-trigger svg {
  width: 14px;
  height: 14px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  flex-shrink: 0;
}

.help-search-trigger .hint {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: left;
}

.help-search-trigger kbd,
.search-kbd {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  font-weight: 400;
  letter-spacing: 0.04em;
  border: 1px solid var(--line);
  padding: 1px 4px;
  color: var(--hud-dim);
  margin-left: auto;
  flex-shrink: 0;
}

#help-bar .theme-toggle {
  width: 28px;
  height: 28px;
  padding: 0;
  flex-shrink: 0;
}

#help-bar .theme-toggle svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

#help-bar .theme-toggle .icon-sun {
  display: none;
}

html[data-theme='light'] #help-bar .theme-toggle .icon-sun {
  display: block;
}

html[data-theme='light'] #help-bar .theme-toggle .icon-moon {
  display: none;
}

#help-body {
  display: grid;
  grid-template-columns: minmax(200px, 240px) minmax(0, 1fr);
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

#help-nav {
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 16px 0 40px;
  overflow: auto;
  min-height: 0;
}

#help-nav .nav-kicker {
  display: block;
  padding: 0 18px 12px;
  font-size: 10px;
  letter-spacing: 0.28em;
  color: var(--accent);
  font-weight: 700;
}

#help-nav a {
  display: block;
  padding: 6px 18px;
  color: var(--hud-dim);
  text-decoration: none;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
}

#help-nav a:hover,
#help-nav a.on {
  color: var(--accent);
  background: color-mix(in srgb, var(--accent) 10%, transparent);
}

#help-main {
  width: 100%;
  max-width: none;
  padding: 32px 40px 96px;
  min-width: 0;
  min-height: 0;
  overflow: auto;
}

#help-main article {
  display: none;
}

#help-main article.on {
  display: block;
  max-width: 1080px;
}

#help-main h1 {
  font-size: 28px;
  letter-spacing: 0.08em;
  font-weight: 700;
  margin: 0 0 14px;
}

#help-main h2 {
  font-size: 15px;
  letter-spacing: 0.14em;
  color: var(--accent);
  margin: 22px 0 8px;
  font-weight: 700;
}

#help-main a {
  color: var(--accent);
}

#help-main p,
#help-main li {
  font-size: 15px;
  line-height: 1.55;
  color: var(--hud);
  margin: 0 0 10px;
}

#help-main ul,
#help-main ol {
  padding-left: 18px;
  margin: 0 0 12px;
}

#help-main code,
#help-main kbd {
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
}

#help-main kbd {
  border: 1px solid var(--line);
  padding: 1px 5px;
  color: var(--hud-dim);
}

#help-main .keys {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0 16px;
  font-size: 14px;
}

#help-main .keys th,
#help-main .keys td {
  text-align: left;
  padding: 6px 10px 6px 0;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}

#help-main .keys th {
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--accent);
}

#help-main .keys td:first-child {
  white-space: nowrap;
  width: 38%;
  color: var(--hud-dim);
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
}

.figure {
  margin: 14px 0 20px;
  border: 1px solid var(--line);
  background: var(--panel);
  overflow: hidden;
}

.figure img {
  display: block;
  width: 100%;
  height: auto;
}

.figure.shot {
  display: block;
  width: fit-content;
  max-width: 100%;
}

.figure.shot img {
  width: auto;
  max-width: min(100%, 640px);
  max-height: 560px;
  margin: 0 auto;
}

.figure.rail img {
  width: 96px;
  max-height: none;
}

.figure img.pixel {
  image-rendering: pixelated;
  image-rendering: crisp-edges;
}

.figure figcaption {
  padding: 8px 12px 10px;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--hud-dim);
  border-top: 1px solid var(--line);
}

.tool-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(148px, 1fr));
  gap: 8px;
  margin: 12px 0 18px;
}

.tool-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  color: var(--hud);
}

.tool-chip kbd {
  margin-left: auto;
}

.tool-ico {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  stroke: var(--accent);
  fill: none;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.search-root {
  position: fixed;
  inset: 0;
  z-index: 80;
  display: grid;
  align-items: start;
  justify-items: center;
  padding: 12vh 16px 16px;
}

.search-root.hidden {
  display: none;
}

.search-backdrop {
  position: absolute;
  inset: 0;
  background: var(--overlay);
}

.search-panel {
  position: relative;
  z-index: 1;
  width: min(560px, 100%);
  max-height: min(70vh, 560px);
  display: flex;
  flex-direction: column;
  background: var(--modal);
  border: 1px solid var(--line);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.4);
}

.search-panel input {
  width: 100%;
  border: none;
  border-bottom: 1px solid var(--line);
  border-radius: 0;
  background: transparent;
  color: var(--hud);
  font-family: inherit;
  font-size: 16px;
  font-weight: 600;
  letter-spacing: 0.04em;
  padding: 14px 16px;
}

.search-panel input:focus {
  outline: none;
}

.search-results {
  overflow: auto;
  flex: 1;
  min-height: 120px;
  padding: 6px 0;
}

.search-hit {
  display: block;
  width: 100%;
  text-align: left;
  background: transparent;
  border: none;
  border-radius: 0;
  border-left: 2px solid transparent;
  color: var(--hud);
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0;
  padding: 8px 16px;
  cursor: pointer;
}

.search-hit:hover,
.search-hit.on {
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-left-color: var(--accent);
}

.search-hit .title {
  display: block;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.search-hit .snippet {
  display: block;
  margin-top: 2px;
  font-size: 12px;
  color: var(--hud-dim);
  line-height: 1.4;
}

.search-hit mark {
  background: color-mix(in srgb, var(--accent) 28%, transparent);
  color: inherit;
  padding: 0 1px;
}

.search-empty {
  padding: 18px 16px;
  color: var(--hud-dim);
  font-size: 14px;
}

.search-foot {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  padding: 8px 16px;
  border-top: 1px solid var(--line);
  color: var(--hud-dim);
  font-size: 11px;
  letter-spacing: 0.08em;
}

.search-foot kbd {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  border: 1px solid var(--line);
  padding: 0 4px;
}

@media (max-width: 700px) {
  #help-bar {
    padding: 6px 12px;
  }

  #help-main {
    padding: 24px 24px 80px;
  }
}

@media (max-width: 800px) {
  html,
  body,
  #help {
    height: 100%;
    overflow: hidden;
  }

  #help {
    grid-template-rows: auto auto minmax(0, 1fr);
  }

  #help-body {
    display: contents;
  }

  #help-main {
    overflow: auto;
    min-height: 0;
    height: auto;
  }

  #help-bar {
    position: relative;
  }

  #help-nav {
    position: relative;
    top: auto;
    height: auto;
    max-height: none;
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 4px;
    overflow-x: auto;
    padding: 8px 10px;
    border-right: none;
    border-bottom: 1px solid var(--line);
    -webkit-overflow-scrolling: touch;
  }

  #help-nav .nav-kicker {
    display: none;
  }

  #help-nav a {
    flex: 0 0 auto;
    padding: 6px 10px;
    border: 1px solid var(--line);
    white-space: nowrap;
  }

  #help-nav a.on {
    border-color: var(--accent);
  }
}

@media (max-width: 560px) {
  #help-bar .help-search-trigger .hint {
    display: none;
  }

  #help-bar .help-search-trigger {
    width: 112px;
    flex-basis: 112px;
  }

  #help-main {
    padding: 18px 14px 64px;
  }

  #help-main .keys td:first-child {
    white-space: normal;
    width: auto;
  }

  .tool-grid {
    grid-template-columns: 1fr 1fr;
  }
}
