/* The shared tools dialog only takes the guide layout while Help is open. */
#open-help { -webkit-tap-highlight-color: transparent; }

#tools-overlay:has(#help-panel:not([hidden])) {
  --guide-grain: url("paper-grain.png");
  --guide-edge: #af8b60;
  --guide-heading: "LXGW WenKai TC", "霞鶩文楷 TC", PMingLiU, "Noto Serif TC", serif;
  width: min(966px, calc(100% - 36px));
  max-width: none;
  max-height: calc(100dvh - 24px);
  color: #432d21;
  border-color: #946a47;
  border-radius: 8px;
  background: var(--guide-grain), radial-gradient(ellipse at 50% 23%, #f9edd4 18%, #f3e1be 77%, #dfc498);
  box-shadow: inset 0 0 0 3px #d7b684, inset 0 0 0 4px #ffedc3, 0 16px 50px #140b0699;
  overflow: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: #b28c62 #e9d3aa;
}

#tools-overlay:has(#help-panel:not([hidden]))::backdrop {
  background: #21171191;
  backdrop-filter: blur(3px) saturate(.8);
}

#tools-overlay:has(#help-panel:not([hidden])) .tools-panel {
  padding: 0 29px 18px;
}

#tools-overlay:has(#help-panel:not([hidden])) .tools-panel > header {
  position: sticky;
  z-index: 2;
  top: 0;
  padding: 16px 0 9px;
  margin-bottom: 18px;
  border-bottom: 1px solid #bc996c;
  background: var(--guide-grain), linear-gradient(90deg, #efdbb6, #f7e8c8 49%, #efdbb6);
}

#tools-overlay:has(#help-panel:not([hidden])) #tools-title {
  font: 700 30px/1.15 var(--guide-heading);
  letter-spacing: .075em;
}

#tools-overlay:has(#help-panel:not([hidden])) #close-tools {
  -webkit-tap-highlight-color: transparent;
  border-color: #a8865c;
  background: #f5e6c9;
  box-shadow: inset 0 1px #fff5da;
  color: #503526;
}

#tools-overlay:has(#help-panel:not([hidden])) #close-tools:hover { background: #fff0cf; }

#help-panel {
  --page-art: 156px;
  --tray-art: 80px;
  --art-gap: 12px;
  --book-label: 30px;
  --blank-art: 29px;
  --art-size: 15px;
}

.guide-spread {
  display: grid;
  grid-template-columns: minmax(0, 44fr) minmax(0, 56fr);
}

.guide-step {
  display: grid;
  min-width: 0;
  grid-template-rows: auto 1fr auto;
  padding-inline: 17px 24px;
}

.guide-step + .guide-step {
  border-inline-start: 1px solid #b18a5e70;
  padding-inline: 26px 14px;
}

.guide-step h3 {
  margin: 0 0 11px;
  font: 700 23px/1.25 var(--guide-heading);
  letter-spacing: .035em;
}

.guide-figure {
  display: grid;
  place-items: center;
  min-width: 0;
  margin: 0;
}

.guide-instruction {
  margin: 13px 0 0;
  min-height: 2.9em;
  font-size: 16px;
  line-height: 1.45;
}

.guide-method {
  display: inline-block;
  color: #614b35;
}

.guide-slip {
  display: grid;
  place-items: center;
  position: relative;
  isolation: isolate;
  width: min(100%, 362px);
  min-height: 116px;
  padding: 12px 9px;
  filter: drop-shadow(0 6px 5px #5b361f49);
}

.guide-slip::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 0;
  background: var(--guide-grain), radial-gradient(ellipse at 47% 38%, #f9eac7 20%, #ead3a6 71%, #c8a170);
  clip-path: polygon(1% 7%, 12% 3%, 29% 4%, 46% 1%, 68% 3%, 82% 1%, 97% 6%, 99% 16%, 98% 37%, 100% 63%, 98% 88%, 91% 94%, 74% 95%, 61% 99%, 42% 97%, 25% 99%, 6% 95%, 0 89%, 2% 73%, 0 45%, 2% 30%);
}

.guide-slip p {
  margin: 0;
  text-align: center;
  font: 650 clamp(17px, 2.15vw, 27px)/1.5 var(--guide-heading);
  white-space: nowrap;
}

.guide-term {
  display: inline-block;
  position: relative;
  padding: 0 .17em;
  --word-unit: 1px;
}

.guide-term .word-mark {
  inset: 5% 0 auto;
  height: 90%;
}

.guide-workflow {
  position: relative;
  display: grid;
  gap: var(--art-gap);
  width: min(100%, 385px);
  font-size: var(--art-size);
}

.guide-casebook {
  height: var(--page-art);
  padding: 4px 6px 8px 16px;
  border-radius: 6px 7px 7px 6px;
  background: var(--guide-grain), linear-gradient(100deg, #492d1e 2%, #765036 8%, #4f3021 97%);
  box-shadow: inset 0 0 0 1px #a6784e, 0 3px 7px #53331e65;
}

.guide-sheet {
  display: grid;
  grid-template-rows: var(--book-label) minmax(0, 1fr);
  height: 100%;
  min-width: 0;
  border: 1px solid #c49e72;
  border-radius: 2px 5px 5px 2px;
  background: var(--guide-grain), linear-gradient(90deg, #ddc094, #f7ead0 10% 90%, #ead2a7);
  box-shadow: 1px 3px 0 #b69a70, 1px 5px 0 #ddc49b;
}

.guide-book-label,
.guide-tray-label {
  padding-inline: .65em;
  font-family: var(--guide-heading);
  font-weight: 700;
}

.guide-book-label {
  align-content: center;
  border-bottom: 1px solid #c9a879;
  background: linear-gradient(0deg, #b8956125, transparent);
}

.guide-person {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 2.6fr);
  align-items: center;
  gap: 11px;
  min-height: 0;
  padding: 6px 10px;
}

.guide-portrait {
  display: block;
  justify-self: center;
  height: 100%;
  min-height: 0;
  max-height: 81px;
  width: 100%;
  border: 1px solid #c5a781;
  border-radius: 2px;
  background: var(--guide-grain), linear-gradient(145deg, #ead9b8, #d8bf96);
  fill: #947854;
}

.guide-portrait-detail { fill: none; stroke: #d9be97; stroke-width: 1.4; }

.guide-fields { display: grid; gap: 5px; }

.guide-fields > div {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  align-items: center;
  gap: 5px;
}

.guide-blank {
  height: var(--blank-art);
  border: 1px dashed #86a491;
  border-radius: 4px;
  background: #eaf0e5;
}

.guide-tray {
  display: grid;
  grid-template-rows: auto 1fr;
  height: var(--tray-art);
  border: 3px solid #765032;
  border-top-color: #a5784e;
  border-radius: 5px;
  background: var(--guide-grain), linear-gradient(#d9c5a1, #e5d4b4);
  box-shadow: inset 0 1px 3px #62412763, 0 2px 5px #4e301951;
}

.guide-tray-label {
  border-bottom: 1px solid #a9875c;
  background: var(--guide-grain), linear-gradient(#dfbf94, #cda676);
}

.guide-chips {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(4px, 1vw, 12px);
  padding: 2px;
  white-space: nowrap;
}

.guide-chip {
  padding: .11em .48em;
  border: 1px solid #a99471;
  border-radius: 4px;
  background: #faf1de;
  color: #314039;
  font-size: .93em;
  font-weight: 580;
}

.guide-chip-selected {
  border-color: #427658;
  background: #d7eadb;
  box-shadow: inset 0 0 0 1px #427658;
}

.guide-arrow {
  position: absolute;
  left: 52%;
  bottom: 14%;
  width: 36%;
  height: 54%;
  overflow: visible;
  pointer-events: none;
}

.guide-arrow path {
  fill: none;
  stroke: #785237;
  stroke-width: 2.1px;
  stroke-linecap: round;
  stroke-linejoin: round;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 0 1px #fff5df);
}

.guide-footer {
  margin-top: 5px;
  padding-top: 11px;
  border-top: 1px solid #bd9a70;
  text-align: center;
  color: #59412e;
}

.guide-footer p { margin: 0; font-size: 14px; line-height: 1.42; }
.guide-footer .guide-touch-hint { display: none; }
.guide-footer .guide-save-note { margin-top: 3px; color: #694f39; font-size: 12px; }
.guide-footer .chapter-save-status { color: #783423; }

.guide-footer kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid #a68156;
  border-radius: 4px;
  background: #f8ebcf;
  box-shadow: 0 1px #b38c5f;
  font: 650 .9em/1.15 system-ui, sans-serif;
}

.guide-touch-hint svg {
  width: 19px;
  height: 19px;
  flex: none;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.45px;
  stroke-linecap: round;
}

@media (any-pointer: coarse) {
  .guide-footer .guide-desktop-hint { display: none; }
  .guide-footer .guide-touch-hint { display: flex; justify-content: center; align-items: center; gap: 5px; }
}

@media (orientation: landscape) and (max-height: 520px) {
  #tools-overlay:has(#help-panel:not([hidden])) {
    width: min(852px, calc(100% - 24px));
    max-height: calc(100dvh - 12px);
  }

  #tools-overlay:has(#help-panel:not([hidden])) .tools-panel { padding: 0 14px 6px; }
  #tools-overlay:has(#help-panel:not([hidden])) .tools-panel > header { padding: 3px 0 3px; margin-bottom: 6px; }
  #tools-overlay:has(#help-panel:not([hidden])) #tools-title { font-size: 23px; }
  #help-panel {
    --page-art: clamp(85px, 27dvh, 125px);
    --tray-art: 49px;
    --art-gap: 7px;
    --book-label: 19px;
    --blank-art: 19px;
    --art-size: 13px;
  }
  .guide-step { padding-inline: 6px 12px; }
  .guide-step + .guide-step { padding-inline: 12px 5px; }
  .guide-step h3 { margin-bottom: 5px; font-size: 18px; }
  .guide-slip { min-height: 79px; }
  .guide-slip p { font-size: clamp(17px, 2.7vw, 23px); }
  .guide-instruction { margin-top: 5px; min-height: 2.8em; font-size: 14px; }
  .guide-person { gap: 7px; padding: 4px 7px; }
  .guide-fields { gap: 3px; }
  .guide-footer { margin-top: 2px; padding-top: 5px; }
}

@media (orientation: landscape) and (max-height: 350px) {
  .guide-footer { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 2px 12px; }
  .guide-footer .guide-save-note { margin-top: 0; }
}

@media (orientation: portrait) and (max-width: 580px) {
  #tools-overlay:has(#help-panel:not([hidden])) { width: calc(100% - 22px); }
  #tools-overlay:has(#help-panel:not([hidden])) .tools-panel { padding: 0 14px 13px; }
  #tools-overlay:has(#help-panel:not([hidden])) .tools-panel > header { padding: 6px 0 6px; margin-bottom: 12px; }
  #tools-overlay:has(#help-panel:not([hidden])) #tools-title { font-size: 25px; }
  #help-panel {
    --page-art: 124px;
    --tray-art: 59px;
    --art-gap: 8px;
    --book-label: 23px;
    --blank-art: 24px;
  }
  .guide-spread { grid-template-columns: minmax(0, 1fr); gap: 12px; }
  .guide-step, .guide-step + .guide-step { padding-inline: 3px; }
  .guide-step + .guide-step { border-inline-start: 0; border-top: 1px solid #b18a5e70; padding-top: 9px; }
  .guide-step h3 { margin-bottom: 6px; font-size: 20px; }
  .guide-slip { min-height: 80px; }
  .guide-slip p { font-size: 22px; }
  .guide-instruction { margin-top: 7px; min-height: 0; font-size: 15px; }
  .guide-footer { margin-top: 10px; padding-top: 7px; }
}

/* D80 V02 desktop enlargement */
@media (orientation: landscape) and (min-width: 1100px) and (min-height: 600px) and (pointer: fine) and (hover: hover) {
  #tools-overlay:has(#help-panel:not([hidden])) { width: min(1140px, calc(100% - 48px)); }
  #tools-overlay:has(#help-panel:not([hidden])) .tools-panel { padding: 0 34px 21px; }
  #tools-overlay:has(#help-panel:not([hidden])) .tools-panel > header { padding: 19px 0 11px; margin-bottom: 21px; }
  #tools-overlay:has(#help-panel:not([hidden])) #tools-title { font-size: 35px; }
  #tools-overlay:has(#help-panel:not([hidden])) #close-tools { width: 52px; height: 52px; font-size: 23px; }

  #help-panel {
    --page-art: 184px;
    --tray-art: 94px;
    --art-gap: 14px;
    --book-label: 35px;
    --blank-art: 34px;
    --art-size: 18px;
  }

  .guide-step { padding-inline: 20px 28px; }
  .guide-step + .guide-step { padding-inline: 31px 16px; }
  .guide-step h3 { margin-bottom: 13px; font-size: 27px; }
  .guide-instruction { margin-top: 15px; font-size: 19px; }
  .guide-slip { width: min(100%, 427px); min-height: 137px; padding: 14px 11px; }
  .guide-slip p { font-size: 32px; }
  .guide-workflow { width: min(100%, 454px); }
  .guide-casebook { padding: 5px 7px 9px 19px; }
  .guide-person { gap: 13px; padding: 7px 12px; }
  .guide-portrait { max-height: 96px; }
  .guide-fields, .guide-fields > div { gap: 6px; }
  .guide-chips { gap: 14px; }
  .guide-arrow path { stroke-width: 2.4px; }
  .guide-footer { margin-top: 6px; padding-top: 13px; }
  .guide-footer p { font-size: 17px; }
  .guide-footer .guide-save-note { font-size: 14px; }
}
