/* =============================================================================
   gleason.css — ė.tv/gleason/ (every class carries the gls- prefix)
   =============================================================================
   The house sheet answers the chrome; this adds the viewer stage, the tool bar,
   the panels, the measurement table and the method section. Colours are house
   tokens, plus four gls- tokens redefined for the dark edition at the foot, so
   this file works in either edition wherever it is linked. The scan itself is
   never filtered or inverted: only the letterbox around it changes.
   ========================================================================== */
:root {
    --gls-letterbox: #E6E0D2;
    --gls-panel:     #FFFFFF;
    --gls-chip:      rgba(17, 22, 28, .9);
    --gls-focus:     #1D4ED8;
    --gls-focus-in:  #FFFFFF;
    --gls-bar-h:     64px;
}

.gls-hero .lede { max-width: 46rem; }
.gls-head { max-width: 52rem; }
.gls-head .lede { margin-top: .6rem; }

/* ------------------------------------------------------------ the stage -- */
/* An author display value beats the browser's own [hidden] rule, so a hidden
   flex box (the missing-tiles state) would still cover the scan. */
.gls-stage [hidden] { display: none !important; }
.gls-stage { position: relative; margin-top: 1.1rem; background: var(--gls-panel);
             scroll-margin-top: calc(var(--nav-h) + 6px); }
.gls-view  { position: relative; background: var(--gls-letterbox); overflow: hidden; }
.gls-osd   { position: absolute; inset: 0; }
.gls-osd .openseadragon-canvas:focus-visible { outline: 0; }
/* OpenSeadragon's own canvases cover an inset outline: draw the ring on a layer above them. */
.gls-view::after { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.gls-view:has(.openseadragon-canvas:focus-visible)::after {
    box-shadow: inset 0 0 0 3px var(--gls-focus), inset 0 0 0 5px var(--gls-focus-in); }
/* A canvas with only inset:0 stays 300x150: the size is explicit. */
.gls-cv    { position: absolute; left: 0; top: 0; width: 100%; height: 100%; pointer-events: none; }

.gls-cross { position: absolute; left: 50%; top: var(--gls-cy, 50%); width: 34px; height: 34px; margin: -17px 0 0 -17px;
             pointer-events: none; display: none; }
.gls-cross::before, .gls-cross::after { content: ""; position: absolute; background: #111827;
             box-shadow: 0 0 0 1.5px rgba(255, 255, 255, .95); }
.gls-cross::before { left: 16px; top: 0; width: 2px; height: 34px; }
.gls-cross::after  { top: 16px; left: 0; height: 2px; width: 34px; }
.gls-stage.is-kbd .gls-view:focus-within .gls-cross { display: block; }

.gls-chip { position: absolute; left: 10px; top: 10px; margin: 0; max-width: calc(100% - 80px);
            padding: .45rem .7rem; border-radius: 8px; background: var(--gls-chip); color: #fff;
            font-size: .75rem; font-weight: 600; line-height: 1.3; pointer-events: none; }

.gls-zoom { position: absolute; right: 10px; top: 10px; display: flex; flex-direction: column; gap: 6px; }
.gls-ib { display: inline-flex; align-items: center; justify-content: center; min-width: 44px; min-height: 44px;
          padding: 0; border: 1px solid var(--line); border-radius: 10px; background: var(--paper); color: var(--ink);
          font-family: inherit; font-weight: 600; font-size: 1.25rem; line-height: 1; cursor: pointer; }
.gls-zoom .gls-ib { box-shadow: 0 2px 10px rgba(0, 0, 0, .14); }
.gls-ib:hover:not([disabled]) { border-color: var(--ink); }
.gls-ib[disabled] { opacity: .45; cursor: not-allowed; }
.gls-ib svg { width: 20px; height: 20px; }

.gls-loading { position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%); margin: 0;
               padding: .5rem .9rem; border-radius: 8px; background: var(--gls-chip); color: #fff; font-size: .8rem; }

.gls-state { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center;
             justify-content: center; gap: .5rem; padding: 24px; text-align: center; background: var(--gls-letterbox); }
.gls-state__h { margin: 0; font-weight: 700; font-size: 1.05rem; color: var(--ink); }
.gls-state p:last-child { margin: 0; max-width: 34rem; font-size: .9rem; line-height: 1.55; color: var(--ink-77); }

.gls-noscript { position: absolute; inset: 0; display: flex; flex-direction: column; }
.gls-noscript img { flex: 1 1 auto; min-height: 0; width: 100%; object-fit: contain; }
.gls-noscript p { margin: 0; padding: .6rem .8rem; font-size: .85rem; background: var(--gls-panel); color: var(--ink-77); }

/* ------------------------------------------------------------- the bar -- */
.gls-side { background: var(--gls-panel); color: var(--ink); }
.gls-bar { display: grid; grid-template-columns: repeat(6, minmax(0, 1fr)); background: var(--gls-panel); }
.gls-tab { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center;
           gap: 3px; min-height: 56px; min-width: 44px; padding: 6px 2px; border: 0; border-top: 3px solid transparent;
           background: none; color: var(--ink-77); font-family: inherit; font-weight: 600; font-size: .7rem; line-height: 1.1; letter-spacing: .02em; cursor: pointer; }
.gls-tab svg { width: 22px; height: 22px; }
.gls-tab:hover { color: var(--ink); }
.gls-tab.is-on { color: var(--ink); border-top-color: var(--accent); }
.gls-tab[aria-pressed="true"] svg { color: var(--accent); }
.gls-tab:focus-visible, .gls-ib:focus-visible, .gls-hit__go:focus-visible, .gls-spot:focus-visible,
.gls-seg button:focus-visible, .gls-toggle:focus-visible { outline: 3px solid var(--gls-focus); outline-offset: -3px; }
.gls-count { position: absolute; top: 4px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px;
             border-radius: 9px; background: var(--accent); color: #fff; font-size: .62rem; line-height: 18px; }

.gls-sheet { display: flex; flex-direction: column; min-height: 0; }
.gls-sheet__head { display: flex; align-items: center; justify-content: space-between; gap: .5rem;
                   padding: .35rem .5rem .35rem 1rem; border-bottom: 1px solid var(--line-soft); }
.gls-sheet__t { margin: 0; font-size: .78rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
.gls-sheet__x { border-color: transparent; background: transparent; }
.gls-sheet__body { overflow: auto; padding: .8rem 1rem 1.2rem; overscroll-behavior: contain; }
.gls-panel > :first-child { margin-top: 0; }

/* ------------------------------------------------------------- panels -- */
.gls-h4 { margin: 1.1rem 0 .5rem; font-size: .72rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink-77); }
.gls-note, .gls-legend, .gls-status, .gls-msg { font-size: .78rem; line-height: 1.5; color: var(--ink-77); }
.gls-read { margin: 0; display: grid; gap: .55rem; }
.gls-read div { display: grid; gap: .1rem; }
.gls-read dt { font-size: .68rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-55); }
.gls-read dd { margin: 0; font-size: .88rem; font-variant-numeric: tabular-nums; color: var(--ink); }

.gls-spots { display: flex; flex-wrap: wrap; gap: .4rem; }
.gls-spot, .gls-toggle { min-height: 44px; padding: .45rem .75rem; border: 1px solid var(--line); border-radius: 10px;
            background: var(--paper); color: var(--ink); font-family: inherit; font-weight: 500; font-size: .8rem; line-height: 1.3; text-align: left; cursor: pointer; }
.gls-spot:hover, .gls-toggle:hover { border-color: var(--ink); }
.gls-toggles { display: grid; gap: .45rem; }
.gls-toggle { display: flex; align-items: center; gap: .6rem; width: 100%; }
.gls-toggle::before { content: ""; flex: 0 0 auto; width: 18px; height: 18px; border-radius: 4px; border: 2px solid var(--ink-55); }
.gls-toggle[aria-pressed="true"]::before { background: var(--accent); border-color: var(--accent);
            box-shadow: inset 0 0 0 2px var(--paper); }

.gls-seg { display: inline-flex; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; margin: .2rem 0 .6rem; }
.gls-seg button { min-width: 56px; min-height: 44px; padding: 0 .8rem; border: 0; border-right: 1px solid var(--line);
                  background: var(--paper); color: var(--ink); font-family: inherit; font-weight: 600; font-size: .8rem; line-height: 1; cursor: pointer; }
.gls-seg button:last-child { border-right: 0; }
.gls-seg button[aria-pressed="true"] { background: var(--ink); color: var(--paper); }
.gls-seg button[aria-pressed="true"]:focus-visible { outline-color: var(--paper); box-shadow: inset 0 0 0 5px var(--gls-focus); }

.gls-sum { margin: 0 0 .5rem; font-size: .88rem; font-weight: 600; line-height: 1.45; color: var(--ink); }
.gls-empty { font-size: .82rem; line-height: 1.5; color: var(--ink-77); }

.gls-plist { list-style: none; margin: .4rem 0; padding: 0; display: grid; gap: .4rem; }
.gls-pt { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: .55rem; align-items: start;
          padding: .5rem; border: 1px solid var(--line-soft); border-radius: 10px; }
.gls-pt__n { display: inline-flex; align-items: center; justify-content: center; width: 24px; height: 24px; margin-top: 2px;
             border-radius: 50%; background: #111827; color: #fff; font-size: .72rem; font-weight: 700; }
.gls-pt__name { display: block; font-size: .88rem; overflow-wrap: anywhere; }
.gls-pt__sub { display: block; font-size: .7rem; color: var(--ink-55); }
.gls-pt__ll { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: .4rem; margin-top: .35rem; }
.gls-ll { display: grid; gap: .15rem; min-width: 0; font-size: .68rem; color: var(--ink-77); }
.gls-num { width: 100%; min-width: 0; min-height: 44px; padding: .3rem .5rem; font-variant-numeric: tabular-nums; }
.gls-addform .gls-num { width: 7.5rem; }
.gls-pt__rm { font-size: 1.3rem; }

.gls-addform { margin: .8rem 0 .2rem; }
.gls-addform fieldset { margin: 0; padding: .6rem .7rem .7rem; border: 1px solid var(--line-soft); border-radius: 10px;
                        display: flex; flex-wrap: wrap; align-items: flex-end; gap: .5rem; }
.gls-addform legend { padding: 0 .3rem; font-size: .72rem; font-weight: 700; color: var(--ink-77); }
.gls-addform label { display: grid; gap: .2rem; font-size: .72rem; color: var(--ink-77); }
.gls-addform .btn { min-height: 44px; }
.gls-acts { display: flex; flex-wrap: wrap; gap: .4rem; margin: .6rem 0; }
.gls-acts .btn { min-height: 44px; }

.gls-tw { overflow-x: auto; margin: .6rem 0; border: 1px solid var(--line); border-radius: 10px; }
/* Auto width: the columns shrink to their longest word before the box scrolls, so the leg, both
   distances and the ratio fit a phone or the 25rem panel and only the bearings may need a scroll. */
.gls-tbl { width: auto; min-width: 100%; border-collapse: collapse; font-size: .76rem; font-variant-numeric: tabular-nums; }
.gls-tbl caption { caption-side: top; text-align: left; padding: .5rem .6rem; font-weight: 700; font-size: .75rem; color: var(--ink-77); }
.gls-tbl th, .gls-tbl td { padding: .45rem .5rem; border-top: 1px solid var(--line-soft); text-align: right; vertical-align: top; }
.gls-tbl th:first-child { text-align: left; min-width: 5.5rem; }
.gls-tbl td { min-width: 4.6rem; }
.gls-tbl thead th { font-size: .68rem; font-weight: 700; color: var(--ink-77); background: var(--tint); }
.gls-tbl small { display: block; font-size: .66rem; font-weight: 400; color: var(--ink-55); }
.gls-tbl .gls-v { font-weight: 700; color: var(--ink); white-space: nowrap; }
.gls-tbl tfoot th, .gls-tbl tfoot td { border-top: 2px solid var(--line); }

.gls-key { display: inline-block; width: 22px; height: 0; margin: 0 .25rem .2rem 0; vertical-align: middle; border-top: 3px solid; }
.gls-key--paper { border-color: #0B3D91; }
.gls-key--globe { border-top-style: dashed; border-color: #B3261E; }

.gls-q-wrap { display: grid; gap: .35rem; }
.gls-q-wrap label { font-size: .78rem; font-weight: 600; color: var(--ink-77); }
.gls-q-wrap .field { min-height: 44px; width: 100%; }
.gls-hits { list-style: none; margin: .5rem 0; padding: 0; display: grid; gap: .3rem; }
.gls-hit { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: .3rem; }
.gls-hit__go { min-height: 44px; padding: .4rem .6rem; border: 1px solid var(--line-soft); border-radius: 10px;
               background: var(--paper); color: var(--ink); text-align: left; font: inherit; cursor: pointer; }
.gls-hit__go:hover { border-color: var(--ink); }
.gls-hit__go b { display: block; font-size: .88rem; overflow-wrap: anywhere; }
.gls-hit__go small { display: block; font-size: .7rem; color: var(--ink-55); overflow-wrap: anywhere; }
.gls-card { margin: .6rem 0; padding: .7rem .8rem; border: 1px solid var(--line); border-left: 4px solid #0B6E4F; border-radius: 10px; }
.gls-card b { display: block; font-size: .95rem; }
.gls-card p { margin: .25rem 0 .5rem; font-size: .75rem; line-height: 1.5; color: var(--ink-77); }
.gls-card .btn { min-height: 44px; }

.gls-link { width: 100%; min-height: 44px; font-size: .78rem; }

/* ------------------------------------------------ time, layers, export -- */
.gls-osd { -webkit-touch-callout: none; }
.gls-range { display: block; width: 100%; min-height: 44px; margin: 0; accent-color: var(--accent); }
.gls-arm { display: grid; gap: .3rem; margin: .6rem 0; padding: .55rem .7rem .7rem; border: 1px solid var(--line-soft);
           border-left: 4px solid #9A3412; border-radius: 10px; }
.gls-arm--b { border-left-color: #1E3A8A; }
.gls-arm label { font-size: .78rem; font-weight: 700; color: var(--ink); }
.gls-arm output { font-size: .8rem; font-variant-numeric: tabular-nums; color: var(--ink-77); }
.gls-arm .btn { justify-self: start; min-height: 44px; }
.gls-addform input[type="date"], .gls-addform input[type="time"] { min-height: 44px; max-width: 100%; }
.gls-addform .btn[aria-pressed="true"] { box-shadow: inset 0 0 0 2px var(--accent); }
.gls-bands { list-style: none; margin: .7rem 0; padding: 0; display: grid; gap: .3rem; font-size: .75rem; line-height: 1.35; color: var(--ink-77); }
.gls-bands li { display: flex; align-items: center; gap: .5rem; }
.gls-bands i { flex: 0 0 auto; width: 22px; height: 14px; border: 1px solid var(--line); border-radius: 3px; background: #E6E0D2; }
.gls-bands .gls-b1 { background: #BAB6B0; }
.gls-bands .gls-b2 { background: #9C9A99; }
.gls-bands .gls-b3 { background: #838385; }
.gls-bands .gls-b4 { background: #6A6C71; }
.gls-op { margin-top: .8rem; }
.gls-here p { margin: .2rem 0 .3rem; }
.gls-print { display: none; }
@media print {
    body.gls-printing > * { display: none !important; }
    body.gls-printing > .gls-print { display: block !important; margin: 0; }
    .gls-print img { display: block; width: 100%; height: auto; }
}

/* --------------------------------------------------- phone and tablet -- */
@media (max-width: 899.98px) {
    .gls-stage { height: calc(100svh - var(--nav-h) - 12px); min-height: 460px; max-height: 980px;
                 margin-inline: calc(var(--gutter) * -1); border-block: 1px solid var(--line); }
    .gls-view { position: absolute; left: 0; right: 0; top: 0; bottom: var(--gls-bar-h); }
    .gls-side { position: absolute; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column-reverse;
                max-height: 100%; }
    .gls-bar { height: var(--gls-bar-h); border-top: 1px solid var(--line); }
    .gls-tab { min-height: calc(var(--gls-bar-h) - 1px); }
    .gls-sheet { max-height: min(46svh, 460px); border-top: 1px solid var(--line); border-radius: 14px 14px 0 0;
                 box-shadow: 0 -8px 24px rgba(0, 0, 0, .12); background: var(--gls-panel); }
    .gls-stage:not(.is-sheet) .gls-sheet { display: none; }
    .gls-stage[data-js="0"] .gls-view { bottom: 0; }
}
@media (max-width: 899.98px) and (min-width: 560px) and (max-height: 500px) and (orientation: landscape) {
    .gls-stage { display: grid; grid-template-columns: minmax(0, 1fr) min(20rem, 45vw); height: calc(100svh - var(--nav-h) - 8px);
                 min-height: 260px; max-height: none; }
    .gls-view { position: relative; left: auto; right: auto; top: auto; bottom: auto; height: 100%; }
    .gls-side { position: static; display: flex; flex-direction: column; min-height: 0; max-height: none; border-left: 1px solid var(--line); }
    .gls-bar { height: auto; border-top: 0; border-bottom: 1px solid var(--line); }
    .gls-tab { min-height: 48px; }
    .gls-sheet, .gls-stage:not(.is-sheet) .gls-sheet { display: flex; flex: 1 1 auto; max-height: none; border-top: 0; border-radius: 0; box-shadow: none; }
    .gls-sheet__x { display: none; }
    .gls-stage[data-js="0"] { grid-template-columns: minmax(0, 1fr); }
}
@media (min-width: 900px) {
    .gls-stage { display: grid; grid-template-columns: minmax(0, 1fr) 25rem;
                 height: clamp(560px, calc(100vh - var(--nav-h) - 40px), 940px);
                 border: 1px solid var(--line); border-radius: 12px; overflow: hidden; }
    .gls-view { height: 100%; }
    .gls-side { display: flex; flex-direction: column; min-height: 0; border-left: 1px solid var(--line); }
    .gls-bar { border-bottom: 1px solid var(--line); }
    .gls-sheet { flex: 1 1 auto; }
    .gls-sheet__x { display: none; }
    .gls-stage[data-js="0"] { grid-template-columns: minmax(0, 1fr); }
}
.gls-stage[data-js="0"] .gls-side, .gls-stage[data-js="0"] .gls-zoom, .gls-stage[data-js="0"] .gls-loading { display: none; }

.gls-keys { margin: .7rem 0 0; font-size: .8rem; line-height: 1.55; color: var(--ink-77); max-width: 60rem; }
.gls-keys kbd { font: 600 .72rem/1 ui-monospace, SFMono-Regular, Menlo, monospace; padding: .12rem .3rem;
                border: 1px solid var(--line); border-radius: 4px; background: var(--tint); color: var(--ink); }

/* ------------------------------------------------------------- method -- */
.gls-method { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 19rem), 1fr)); gap: 1.6rem 2.2rem; margin-top: 1.6rem; }
.gls-mh { font-size: .8rem; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; color: var(--ink); margin: 0 0 .4rem; }
.gls-mh2 { font-size: 1.15rem; font-weight: 700; margin: 2.6rem 0 .6rem; color: var(--ink); }
.gls-md { margin: 0 0 .8rem; font-size: .92rem; line-height: 1.65; color: var(--ink-77); max-width: 62rem; }
.gls-md a { color: var(--ink); overflow-wrap: anywhere; }
.gls-rtw { overflow-x: auto; margin: 1rem 0 1.2rem; border: 1px solid var(--line); border-radius: 10px; }
.gls-rtbl { width: 100%; min-width: 38rem; border-collapse: collapse; font-size: .82rem; font-variant-numeric: tabular-nums; }
.gls-rtbl caption { caption-side: top; text-align: left; padding: .55rem .7rem; font-weight: 700; font-size: .78rem; color: var(--ink-77); }
.gls-rtbl th, .gls-rtbl td { padding: .42rem .7rem; border-top: 1px solid var(--line-soft); text-align: right; }
.gls-rtbl th:first-child, .gls-rtbl td:first-child { text-align: left; }
.gls-rtbl thead th { font-size: .7rem; color: var(--ink-77); background: var(--tint); }
.gls-rtbl tr.is-hi td, .gls-rtbl tr.is-hi th { color: var(--ink); font-weight: 700; }
.gls-terms { margin: .8rem 0 1rem; padding: .8rem 1rem; border-left: 4px solid var(--accent); background: var(--tint); }
.gls-terms p { margin: 0 0 .5rem; font-size: .9rem; line-height: 1.6; color: var(--ink); }
.gls-terms p:last-child { margin-bottom: 0; }
.gls-list { margin: .4rem 0 1rem; padding-left: 1.2rem; font-size: .9rem; line-height: 1.65; color: var(--ink-77); max-width: 62rem; }
.gls-sha { font: .72rem/1.4 ui-monospace, SFMono-Regular, Menlo, monospace; overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
    .gls-stage *, .gls-stage *::before, .gls-stage *::after { transition: none !important; animation: none !important; }
}

/* ---------------------------------------------------- the dark edition --
   Tokens only. The house dark.css answers the chrome; these four answer the
   stage. The scan is untouched. */
html[data-dark] {
    --gls-letterbox: #080B0F;
    --gls-panel:     #0F141A;
    --gls-chip:      rgba(0, 0, 0, .86);
    --gls-focus:     #93C5FD;
    --gls-focus-in:  #0B1220;
}
/* The few literals that sit on the PANEL, not on the scan (K6, measured on #0F141A):
   the point badge #111827 was 1.04:1 and the legend keys 1.84:1 (paper) and 2.83:1
   (globe). The keys stand on a chip of the scan's own paper colour, so they show the
   line exactly as it is drawn on the map (7.6:1 and 5.0:1 there); the badge takes the
   same chip. The overlay itself is unchanged: it is drawn on the scan. */
html[data-dark] .gls-key { box-shadow: 0 0 0 3px #E6E0D2; background: #E6E0D2; }
html[data-dark] .gls-pt__n { background: #E6E0D2; color: #111827; }
html[data-dark] .gls-count { color: var(--on-accent); }
html[data-dark] .gls-card { border-left-color: #34D399; }
html[data-dark] .gls-arm { border-left-color: #FB923C; }
html[data-dark] .gls-arm--b { border-left-color: #93C5FD; }
