.instructions-workspace {
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  color: var(--ink);
  font-family: Manrope, 'Segoe UI', sans-serif;
}
.instructions-workspace *, .instructions-panel * { box-sizing: border-box; }
.instructions-toolbar, .instructions-section-heading, .instructions-pagination,
.instructions-panel-heading, .instructions-editor-footer, .instructions-selected-file,
.instructions-existing-resource { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
.instructions-toolbar { margin-bottom: 24px; flex-wrap: wrap; }
.instructions-toolbar p { margin: 0; color: var(--muted); font-size: 13px; }
.instructions-toolbar button { flex-shrink: 0; }
.instructions-workspace button, .instructions-panel button { min-height: 40px; }
.instructions-workspace button:focus-visible, .instructions-panel :focus-visible {
  outline: 2px solid var(--focus, var(--accent)); outline-offset: 3px;
}
.instructions-search { width: 100%; max-width: none; margin: 0 0 20px; }
.instructions-search > label { display: block; font-size: 12px; font-weight: 700; margin-bottom: 8px; }
.instructions-search > div { display: flex; align-items: center; gap: 8px; }
.instructions-search input { flex: 1; min-width: 0; max-width: 560px; width: 100%; }
.instructions-result-count, .instructions-meta, .instructions-muted, .instructions-link-note {
  color: var(--muted); font-size: 12px; line-height: 1.6;
}
.instructions-result-count { margin: 0 0 8px; }
.instructions-list, .instructions-resources ul, .instructions-selected-list { list-style: none; padding: 0; margin: 0; }
.instructions-topic { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 20px; align-items: start; padding: 20px 0; border-bottom: 1px solid var(--line); }
.instructions-topic:last-child { border-bottom: 0; }
.instructions-topic h2 { margin: 0; font-size: 15px; line-height: 1.6; }
.instructions-workspace .instructions-topic-title {
  display: inline; padding: 0; min-height: 0; border: 0; border-radius: 0;
  background: transparent; color: var(--ink); font: inherit; font-weight: 800;
  text-align: left; white-space: normal; overflow-wrap: anywhere; cursor: pointer;
}
.instructions-workspace .instructions-topic-title:hover { color: var(--accent); text-decoration: underline; text-underline-offset: 3px; }
.instructions-excerpt { max-width: 80ch; margin: 6px 0 8px; color: var(--muted); font-size: 13px; line-height: 1.65; overflow-wrap: anywhere; }
.instructions-meta { display: flex; flex-wrap: wrap; gap: 4px 16px; margin: 8px 0 0; }
.instructions-count { padding: 4px 8px; margin-top: 4px; border: 1px solid var(--teal-line, var(--line)); border-radius: 5px; background: var(--teal-bg, var(--soft)); color: var(--accent); font-size: 11px; font-weight: 700; white-space: nowrap; }
.instructions-empty { padding: 32px 0; text-align: center; }
.instructions-empty h2 { margin: 0 0 8px; font-size: 16px; }
.instructions-empty p { margin: 0; font-size: 13px; color: var(--muted); }
.instructions-pagination { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); flex-wrap: wrap; }
.instructions-pagination > div { display: flex; gap: 8px; }
.instructions-error { background: var(--rose-bg, var(--soft)); border: 1px solid var(--rose, var(--line)); border-radius: 8px; color: var(--rose, var(--ink)); padding: 12px 16px; margin: 16px 0; overflow-wrap: anywhere; }
.instructions-error p { margin: 0 0 12px; }
.instructions-panel {
  position: fixed; z-index: 80; top: 16px; right: 16px; bottom: 16px;
  width: min(760px, calc(100vw - 32px)); overflow-y: auto; overscroll-behavior: contain;
  border: 1px solid var(--line); border-radius: 18px; background: var(--surface);
  color: var(--ink); font-family: Manrope, 'Segoe UI', sans-serif;
  box-shadow: 0 12px 32px #092b4226; scrollbar-gutter: stable;
}
.instructions-panel-heading { position: sticky; top: 0; z-index: 1; padding: 20px 24px; background: var(--surface); border-bottom: 1px solid var(--line); align-items: flex-start; }
.instructions-panel-heading > div { min-width: 0; }
.instructions-panel-heading h2 { margin: 0; font-size: 20px; font-weight: 800; line-height: 1.45; overflow-wrap: anywhere; }
.instructions-panel-heading > button { flex-shrink: 0; }
.instructions-panel-body { padding: 24px; }
.instructions-panel-body > .instructions-meta { margin-top: 0; }
.instructions-actions { display: flex; gap: 8px; margin-top: 16px; }
.instructions-body { white-space: pre-wrap; overflow-wrap: anywhere; font-size: 14px; line-height: 1.8; margin: 24px 0; }
.instructions-resources, .instructions-editor-section { margin-top: 24px; padding-top: 20px; border-top: 1px solid var(--line); }
.instructions-panel h3 { font-size: 14px; font-weight: 800; margin: 0 0 12px; }
.instructions-resource { margin: 0 0 12px; padding: 16px; background: var(--soft); border: 1px solid var(--line); border-radius: 10px; overflow-wrap: anywhere; }
.instructions-resource a { color: var(--accent); font-weight: 700; font-size: 13px; }
.instructions-resource > .instructions-muted, .instructions-link-note { display: block; margin-top: 4px; font-weight: 400; }
.instructions-resource figure { margin: 0 0 12px; }
.instructions-resource figcaption { font-size: 13px; font-weight: 700; margin-bottom: 12px; }
.instructions-resource video, .instructions-selected-file video { display: block; width: 100%; max-height: 420px; margin-top: 8px; background: var(--soft); border: 1px solid var(--line); border-radius: 8px; }
.instructions-history { padding-top: 20px; margin-top: 24px; border-top: 1px solid var(--line); }
.instructions-history > summary { cursor: pointer; font-size: 13px; font-weight: 700; }
.instructions-history article { padding: 20px 0; border-bottom: 1px solid var(--line); }
.instructions-history article .instructions-body { margin-bottom: 0; font-size: 13px; }
.instructions-panel .instructions-editor { max-width: none; width: 100%; margin: 0; }
.instructions-editor > label, .instructions-editor-section > label, .instructions-link-row > label { display: block; margin: 16px 0; font-size: 12px; font-weight: 700; }
.instructions-editor label input, .instructions-editor label textarea { display: block; width: 100%; margin-top: 8px; font-family: inherit; font-weight: 400; }
.instructions-editor textarea { min-height: 180px; resize: vertical; }
.instructions-section-heading h3 { margin: 0; }
.instructions-editor-section > .instructions-muted { margin: 12px 0; }
.instructions-link-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); gap: 0 12px; margin-top: 16px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; background: var(--soft); }
.instructions-link-row > label { min-width: 0; margin: 0; }
.instructions-link-row > button { grid-column: 1 / -1; justify-self: end; margin-top: 4px; }
.instructions-selected-file, .instructions-existing-resource { align-items: flex-start; padding: 12px 0; border-bottom: 1px solid var(--line); }
.instructions-selected-file > div, .instructions-existing-resource > div { min-width: 0; flex: 1; }
.instructions-selected-file strong, .instructions-existing-resource strong { display: block; font-size: 13px; overflow-wrap: anywhere; }
.instructions-selected-file > button, .instructions-existing-resource > button { flex-shrink: 0; font-size: 12px; }
.instructions-selected-file .instructions-muted, .instructions-existing-resource .instructions-muted { display: block; margin-top: 4px; }
.instructions-pending-removal strong { text-decoration: line-through; color: var(--muted); }
.instructions-editor-footer { position: sticky; bottom: 0; justify-content: flex-end; padding: 16px 24px; margin: 24px -24px -24px; background: var(--surface); border-top: 1px solid var(--line); }
@media (max-width: 650px) {
  .instructions-workspace { padding: 16px; }
  .instructions-toolbar { margin-bottom: 20px; align-items: flex-start; }
  .instructions-search > div { flex-wrap: wrap; }
  .instructions-search input { flex-basis: 100%; max-width: none; }
  .instructions-topic { grid-template-columns: minmax(0, 1fr); gap: 8px; padding: 16px 0; }
  .instructions-count { justify-self: start; margin-top: 0; }
  .instructions-panel { top: 0; right: 0; bottom: 0; width: 100%; border-radius: 0; }
  .instructions-panel-heading, .instructions-panel-body { padding: 16px; }
  .instructions-panel-heading { gap: 12px; }
  .instructions-panel-heading h2 { font-size: 18px; }
  .instructions-link-row { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .instructions-selected-file, .instructions-existing-resource { flex-wrap: wrap; }
  .instructions-selected-file > div, .instructions-existing-resource > div { flex-basis: 100%; }
  .instructions-editor-footer { margin-inline: -16px; margin-bottom: -16px; padding-inline: 16px; }
}
@media (prefers-reduced-motion: reduce) {
  .instructions-workspace *, .instructions-panel * { transition: none; scroll-behavior: auto; }
}

.instructions-link-actions { display: flex; align-items: center; justify-content: space-between; gap: 1rem; flex-wrap: wrap; }
.instructions-link-actions > a { flex: 1 1 12rem; min-width: 0; }
.instructions-link-actions > button { flex: 0 0 auto; }
.instructions-resources > .instructions-section-heading { flex-wrap: wrap; margin-bottom: 1rem; }
.instructions-copy-manual { display: block; font-size: .875rem; }
.instructions-copy-manual[hidden] { display: none; }
.instructions-copy-manual textarea { display: block; width: 100%; margin-top: .5rem; resize: vertical; font: inherit; }
