/* Match the reader's help overlay: a blurred backdrop and a quiet cheatsheet. */
#commands-btn,
.commands-dialog .icon-btn {
  width: 44px;
  height: 44px;
  justify-content: center;
  flex-shrink: 0;
}

.commands-dialog {
  --commands-secondary: var(--writer-secondary, rgba(var(--writer-text-rgb), 0.7));
  --commands-border: var(--writer-border, rgba(var(--writer-text-rgb), 0.12));
  width: min(48rem, calc(100vw - 3rem));
  max-height: calc(100dvh - 3rem);
  margin: auto;
  padding: 0 2rem;
  overflow-y: auto;
  background: transparent;
  border: none;
  color: var(--commands-secondary);
  font-family: 'Courier New', Courier, monospace;
  font-size: 0.88rem;
  font-weight: 400;
  line-height: 1.5;
  letter-spacing: -0.01em;
}

.commands-dialog::backdrop {
  background: rgba(147, 92, 66, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}

:root[data-theme="dark"] .commands-dialog::backdrop {
  background: rgba(30, 20, 15, 0.94);
}

.commands-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  margin-bottom: 1rem;
  padding: 0 2.75rem;
}

.commands-header h2 {
  font-family: 'Montserrat', sans-serif;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.6;
  text-transform: uppercase;
  letter-spacing: 0.18em;
  text-align: center;
}

.commands-header form {
  position: absolute;
  right: 0;
  top: 0;
}

.commands-header .icon-btn svg {
  width: 18px;
  height: 18px;
}

.commands-body {
  overflow-wrap: anywhere;
}

.commands-body p {
  margin: 0.8rem 0 1rem;
  font-size: 0.78rem;
  line-height: 1.5;
}

#commands-intro {
  text-align: center;
  margin: 0 0 1.75rem;
}

.commands-body details {
  padding: 0.9rem 0;
  border-top: 1px dashed var(--commands-border);
}

.commands-body summary {
  color: var(--writer-accent-hover);
  cursor: pointer;
  font-weight: 700;
  text-transform: lowercase;
}

.commands-body details[open] summary {
  margin-bottom: 0.8rem;
}

.commands-list {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  align-items: baseline;
  column-gap: 1.25rem;
}

.commands-list :is(dt, dd) {
  padding: 0.38rem 0;
}

.commands-list dt {
  color: var(--writer-accent-hover);
  font-weight: 700;
}

.commands-list dd {
  text-align: right;
}

.commands-body :is(code, kbd) {
  font: inherit;
}

.commands-body pre {
  margin: 0.6rem 0;
  padding-left: 0.8rem;
  border-left: 1px solid var(--commands-border);
  overflow-x: auto;
  color: var(--writer-accent-hover);
  font: inherit;
  font-size: 0.78rem;
  white-space: pre;
}

.commands-body h3 {
  margin-top: 1.3rem;
  font: inherit;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--writer-accent-hover);
}

.commands-dismiss {
  margin: 1.25rem 0 0.25rem;
  padding-top: 1rem;
  border-top: 1px dashed var(--commands-border);
  font-size: 0.72rem;
  text-align: center;
}

#commands-btn:focus-visible,
.commands-dialog :focus-visible {
  outline: 1px solid var(--writer-link);
  outline-offset: 3px;
}

@media (max-width: 480px) {
  .commands-dialog {
    padding: 0 0.25rem;
  }

  .commands-list {
    column-gap: 0.8rem;
    font-size: 0.8rem;
  }
}

@media (prefers-reduced-motion: no-preference) {
  .commands-dialog[open] {
    animation: commands-enter 0.25s ease-out;
  }

  @keyframes commands-enter {
    from { opacity: 0; transform: translateY(12px); }
    to { opacity: 1; transform: translateY(0); }
  }
}
