/* Hara and back diagnosis dock (hara-dock.js): beside the treatment panel on a computer, over the page on a phone.
   The findings scroll; "Clear all" and "Use in the treatment" stay pinned at the foot (hara-dock-mockup.html, option 1). */
/* The meridian list steps aside while the dock is open: the findings table names the meridians, and the channels
   the list draws are hidden under the zones anyway. The body gets the room. */
.app.hara-on:not(.exam) { grid-template: "bar bar bar" 60px "stage hara aside" minmax(0, 1fr) / minmax(0, 1fr) 360px 420px; }
.app.hara-on.anat-open:not(.exam) { grid-template: "bar bar bar bar" 60px "dock stage hara aside" minmax(0, 1fr) / 280px minmax(0, 1fr) 360px 420px; }
/* Laying the zones on the body (progressBar): a plain bar over the stage, which takes the taps until it lifts. */
.hd-load { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: inherit; pointer-events: auto; transition: opacity .2s ease; }
.hd-load.out { opacity: 0; }
.hd-load > div { width: min(260px, 70%); text-align: center; }
.hd-load p { margin: 0 0 10px; font: 600 14px "Plus Jakarta Sans", system-ui, sans-serif; color: var(--muted, #646b7a); }
[data-bg="dark"] .hd-load p { color: #aab; }
.hd-load i { display: block; height: 6px; border-radius: 9px; background: #8a90a033; overflow: hidden; }
.hd-load b { display: block; height: 100%; width: 0; border-radius: inherit; background: var(--indigo, #4b5bdc); animation: hd-fill var(--dur) linear forwards; }
@keyframes hd-fill { to { width: 100%; } }
@media (min-width: 861px) {
  .app.hara-on:not(.exam) .rail { display: none; }
  /* The treatment panel shows the reading so far in place of the "open the map" card (plan.js). */
  .app.hara-on .hara-wait { display: none; }
  .app.hara-on .hara-live { display: grid; }
}
@media (max-width: 1280px) and (min-width: 861px) {
  .app.hara-on:not(.exam) { grid-template-columns: minmax(0, 1fr) 330px 380px; }
  .app.hara-on.anat-open:not(.exam) { grid-template-columns: 250px minmax(0, 1fr) 330px 380px; }
}
.hara-live { display: none; gap: 16px; --kyo: #2563eb; --jitsu: #dc2626; --even: #6b7280; }
.hara-live h1 { margin: 0; }
#haraLive { display: grid; gap: 16px; }
#haraLive > p { margin: 0; color: var(--muted); }
#haraLive .hd-prog { display: flex; align-items: center; gap: 10px; font-size: 13px; color: var(--muted); }
#haraLive .hd-prog div { flex: 1; height: 6px; border-radius: 99px; background: #edeff3; overflow: hidden; }
#haraLive .hd-prog i { display: block; height: 100%; background: var(--indigo); border-radius: inherit; }
#haraLive .hd-result { border-radius: 14px; padding: 16px; background: var(--indigo-soft); }
#haraLive .hd-result .k { display: none; } /* the bar above already counts the zones */
#haraLive .hd-result dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 8px 14px; font-size: 15px; }
#haraLive .hd-result dt { color: var(--muted); } #haraLive .hd-result dd { margin: 0; font-weight: 800; }
#haraLive .hd-result p { margin: 12px 0 0; }
#haraLive .hd-felt { display: flex; flex-wrap: wrap; gap: 6px; }
#haraLive .hd-felt button { min-height: 36px; padding: 0 10px; border: 1px solid var(--line); border-radius: 999px; background: #fff; font: inherit; font-size: 12.5px; font-weight: 700; color: var(--ink); display: inline-flex; align-items: center; gap: 6px; cursor: pointer; }
#haraLive .hd-felt button:hover { background: var(--indigo-soft); }
#haraLive .hd-felt i { width: 9px; height: 9px; border-radius: 50%; background: var(--r); flex: none; }

.hara-dock { grid-area: hara; display: flex; flex-direction: column; min-height: 0; padding: 0; overflow: hidden;
  --kyo: #2563eb; --jitsu: #dc2626; --even: #6b7280; }
.hara-dock[hidden] { display: none !important; } /* .app.exam aside (exam.css) would otherwise lay the closed dock into the grid */
.hara-dock .hd-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 18px 20px 6px; }
.hara-dock h2 { margin: 0; font-size: 18px; }
.hara-dock .hd-x { flex: none; width: 40px; height: 40px; border: 1px solid var(--line); background: #fff; border-radius: 10px; font-size: 16px; cursor: pointer; }
/* The list's top and bottom edges shade while there is more to scroll to. */
.hara-dock .hd-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 20px 16px; display: flex; flex-direction: column; gap: 16px;
  background: linear-gradient(var(--panel, #fff) 30%, #fff0) top / 100% 30px no-repeat local, linear-gradient(#fff0, var(--panel, #fff) 70%) bottom / 100% 30px no-repeat local,
    linear-gradient(#0002, #0000) top / 100% 10px no-repeat scroll, linear-gradient(#0000, #0002) bottom / 100% 10px no-repeat scroll; }
.hara-dock .hd-hint { margin: 0; font-size: 13px; color: var(--muted); }
.hara-dock .k { margin: 0 0 6px; font: 700 10.5px "JetBrains Mono", monospace; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); }
.hara-dock .hd-card { border: 1px solid var(--line); border-radius: 14px; padding: 14px; }
.hara-dock .hd-card h3 { margin: 0; font-size: 16px; display: flex; align-items: center; gap: 8px; }
.hara-dock .hd-card h3 i { width: 12px; height: 12px; border-radius: 50%; background: var(--c); flex: none; }
.hara-dock .hd-card p { margin: 6px 0 12px; color: var(--muted); font-size: 13.5px; }
.hara-dock .hd-card p.hd-tip { margin: 10px 0 0; font-size: 12px; }
.hara-dock .hd-rate { display: grid; grid-template-columns: repeat(5, 1fr); gap: 4px; }
/* Every rating is the same shape: its mark, then its name. Colour shows only on the chosen one. */
.hara-dock .hd-rate button { min-height: 52px; padding: 4px 1px; border: 1px solid var(--line); background: #fff; border-radius: 10px; display: grid; align-content: center; justify-items: center; gap: 1px; font: inherit; font-weight: 700; font-size: 10.5px; line-height: 1.15; color: var(--ink); cursor: pointer; }
.hara-dock .hd-rate button b { font: 700 14px "JetBrains Mono", monospace; }
.hara-dock .hd-rate button[aria-checked="true"].hd-kyo { background: var(--kyo); border-color: var(--kyo); color: #fff; }
.hara-dock .hd-rate button[aria-checked="true"].hd-even { background: var(--even); border-color: var(--even); color: #fff; }
.hara-dock .hd-rate button[aria-checked="true"].hd-jitsu { background: var(--jitsu); border-color: var(--jitsu); color: #fff; }
.hara-dock .hd-unrate { margin-top: 8px; min-height: 36px; padding: 0 10px; border: 0; background: none; border-radius: 8px; font: inherit; font-weight: 700; font-size: 13px; color: var(--indigo); cursor: pointer; }
.hara-dock .hd-unrate:hover { background: var(--indigo-soft); }
.hara-dock table { width: 100%; border-collapse: collapse; font-size: 13px; table-layout: fixed; }
.hara-dock :is(th, td):not(:first-child) { width: 88px; text-align: center; }
.hara-dock td:not(:first-child) button { justify-content: center; }
.hara-dock th { text-align: start; font: 700 10.5px "JetBrains Mono", monospace; letter-spacing: .06em; text-transform: uppercase; color: var(--muted); padding: 0 6px 6px; }
.hara-dock td { padding: 0; border-top: 1px solid var(--line); }
.hara-dock td button { width: 100%; min-height: 36px; padding: 4px 6px; border: 0; background: none; font: inherit; text-align: start; display: flex; align-items: center; gap: 8px; cursor: pointer; }
.hara-dock td button:hover { background: var(--indigo-soft); }
.hara-dock td button i { width: 10px; height: 10px; border-radius: 50%; background: var(--c); flex: none; }
.hara-dock tr.hd-cur td { background: var(--indigo-soft); }
.hara-dock tr.hd-cur td:first-child button { font-weight: 800; }
.hara-dock td.hd-at button { box-shadow: inset 0 0 0 2px var(--indigo); border-radius: 8px; }
.hara-dock .hd-none { color: #b6bcc8; }
/* A long rating name ("Very jitsu" in Russian or Hebrew) wraps inside its chip rather than being cut. */
.hara-dock .hd-chip { padding: 2px 8px; border-radius: 11px; font-weight: 700; font-size: 11.5px; line-height: 1.15; text-align: center; color: #fff; }
.hara-dock .hd-chip.hd-kyo { background: var(--kyo); }
.hara-dock .hd-chip.hd-jitsu { background: var(--jitsu); }
.hara-dock .hd-chip.hd-even { background: var(--even); }
.hara-dock .hd-result { border-radius: 14px; padding: 14px; background: var(--indigo-soft); }
.hara-dock .hd-result dl { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 6px 12px; }
.hara-dock .hd-result dt { color: var(--muted); } .hara-dock .hd-result dd { margin: 0; font-weight: 700; }
.hara-dock .hd-result p { margin: 10px 0 0; font-size: 13px; } .hara-dock .hd-result p:only-child { margin: 0; }
/* Pinned foot: Clear all beside the main button, which takes the rest of the row. */
.hara-dock .hd-foot { display: flex; flex-wrap: wrap; gap: 8px; padding: 10px 20px 16px; border-top: 1px solid var(--line); background: var(--panel, #fff); }
.hara-dock .hd-foot button { min-height: 44px; border-radius: 10px; font: inherit; font-weight: 700; cursor: pointer; }
.hara-dock .hd-why { flex: 0 0 100%; margin: 0; font-size: 12.5px; color: var(--muted); }
.hara-dock .hd-why:empty { display: none; }
.hara-dock .hd-clear { padding: 0 14px; border: 1px solid var(--line); background: #fff; }
.hara-dock .hd-use { flex: 1; padding: 0 16px; border: 0; background: var(--indigo); color: #fff; }
.hara-dock .hd-use[hidden] { display: none; }
.hara-dock .hd-clear:only-child, .hara-dock .hd-use[hidden] ~ .hd-clear { flex: 1; }
.hara-dock .hd-foot button:disabled { opacity: .5; cursor: default; }
[dir="rtl"] .hara-dock :is(.k, th) { font-family: inherit; letter-spacing: 0; }

/* Over the stage while the dock is open: the zone labels and which side of the patient is which. */
.hara-dock .hd-area { display: flex; gap: 2px; margin: 8px 20px 4px; padding: 3px; border-radius: 999px; background: var(--bg, #eceef2); border: 1px solid var(--line); }
.hd-sides[hidden] { display: none; }
.hara-dock .hd-area button { flex: 1; min-height: 40px; padding: 0 20px; border: 0; background: none; border-radius: 999px; font: inherit; font-weight: 700; color: var(--muted); cursor: pointer; }
.hara-dock .hd-area button[aria-checked="true"] { background: var(--indigo); color: #fff; }
/* Seen from the front the patient's right is on the viewer's left, whatever the page direction. */
/* The body tools sit in the stage's top corner at the end of the line: the labels keep clear of them. */
.hd-sides { position: absolute; top: 14px; inset-inline: 14px 84px; z-index: 2; display: flex; justify-content: space-between; align-items: start; gap: 8px; direction: ltr; font-weight: 700; font-size: 13px; line-height: 1.25; pointer-events: none; }
[dir="rtl"] .hd-sides { inset-inline: 84px 14px; }
.hd-sides span { max-width: calc(50% - 4px); padding: 6px 12px; border-radius: 14px; background: #fffffff0; border: 1px solid var(--line); color: var(--ink); }
[data-bg="dark"] .hd-sides span { background: #ffffff1f; border-color: #ffffff40; color: #fff; }
.hd-tag { padding: 1px 6px; border-radius: 6px; background: #fffffff2; border: 1px solid var(--line); font: 700 12px "JetBrains Mono", monospace; white-space: nowrap; color: #1b1f27; pointer-events: none; }
.hd-tag.hd-kyo { background: #2563eb; border-color: #2563eb; color: #fff; }
.hd-tag.hd-jitsu { background: #dc2626; border-color: #dc2626; color: #fff; }
.hd-tag.hd-even { background: #6b7280; border-color: #6b7280; color: #fff; }
.hd-tag.hd-on { outline: 2px solid var(--indigo); outline-offset: 1px; }

/* Phone: the dock slides up over the lower part of the page; the body stays visible above it. */
@media (max-width: 860px) {
  .hara-dock { position: fixed; inset: auto 0 0; z-index: 30; max-height: 56svh; border: 0; border-top: 1px solid var(--line);
    border-radius: 18px 18px 0 0; box-shadow: 0 -10px 30px #0003; background: var(--panel, #fff); animation: hd-up .25s ease; }
  .hara-dock .hd-head { padding: 14px 16px 4px; }
  .hara-dock .hd-scroll { padding: 4px 16px 12px; }
  .hara-dock .hd-foot { padding: 10px 16px calc(12px + env(safe-area-inset-bottom)); }
  .hara-dock .hd-area { margin: 6px 16px 2px; }
  .hd-sides { top: 10px; inset-inline: 10px 64px; font-size: 12px; }
  [dir="rtl"] .hd-sides { inset-inline: 64px 10px; }
  .hd-tag { padding: 1px 5px; font-size: 10.5px; } /* the zones are small on a phone: larger labels would cover them */
}
@keyframes hd-up { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .hara-dock { animation: none; } }
