/* Shared viewer layout. The drawing gets the room; the thumb bar owns actions. */
body.app { height: 100dvh; overflow: hidden; }
.app .toolbar { flex-direction: row; align-items: center; gap: 8px; padding: 4px 12px; min-height: 52px; flex: none; border-bottom: 1px solid var(--rule); }
.toolbar .button, .toolbar select { min-height: 44px; }
/* #191: the layers' ☰, first in the bar, as big as the bar (gloves, G05) without making it taller. */
.toolbar .layers-open { flex: none; min-width: 56px; min-height: 56px; margin: -4px 0 -4px -4px; padding: 0; justify-content: center; border-color: transparent; }
.layers-open .icon { width: 26px; height: 26px; }
/* On the dark chrome it has the bar's buttons' edge (an edge at 3:1, dark-chrome suite). */
.dark-chrome .toolbar .layers-open { border-color: var(--rule); }
.toolbar .page-picker { min-width: 0; max-width: min(70vw, 28rem); flex: 1; }
.app .workspace { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr); }
.app .workspace.pro { grid-template-columns: minmax(0, 1fr) 410px; }
.app .stage { height: auto; min-height: 0; }
.stage:not(:has(.empty[hidden])) { background: var(--paper); }
.app .empty { border: 0; background: transparent; width: auto; display: flex; flex-direction: column; align-items: stretch; gap: 10px; }
.empty .button { min-height: 64px; padding: 12px 32px; font-size: 24px; justify-content: center; }
.empty .resume { max-width: 22rem; overflow-wrap: anywhere; } /* a long file name wraps */
/* The empty viewer is no dead end: the name, a link home and one line (W08). */
.empty .home-link { align-self: center; display: inline-flex; align-items: center; font: 400 26px/1.2 var(--lettering); color: var(--graphite); text-decoration: none; padding: 8px 12px; }
/* The logo's mark before the name (#200), larger with the larger name. */
.empty .home-link .brand-mark { width: 32px; height: 32px; margin-right: 10px; }
.empty .home-link:hover, .empty .home-link:focus-visible { text-decoration: underline; }
.empty .empty-line { align-self: center; margin: 0 0 8px; max-width: 22rem; text-align: center; color: var(--pencil); font-size: 15px; line-height: 1.4; }
.empty button { min-height: 48px; justify-content: center; }
/* Kept on this phone (E03, kept-list.js): what this browser keeps, each with its size, a tap to
   open it and Delete; under the empty viewer's Open and in More. The empty viewer scrolls once the
   list is long. */
.kept { text-align: left; padding: 12px 0; border-top: 1px solid var(--rule); }
.kept-more .kept { border-top: 0; border-bottom: 1px solid var(--rule); }
.kept h2 { margin: 0 0 4px; font-size: 18px; }
.kept .note { margin: 4px 0; color: var(--pencil); font-size: 14px; line-height: 1.4; }
.kept-list { list-style: none; margin: 8px 0; padding: 0; }
.kept-list li, .empty .kept-list li { display: flex; align-items: center; gap: 8px; min-height: 0; padding: 4px 0; border-bottom: 1px solid var(--rule); counter-increment: none; }
.empty .kept-list li::before { content: none; }
/* A button does not wrap (style.css): a long name (two revisions differ only at the end) wraps
   here inside the room Delete leaves, whole (review 1 of #173). */
.kept-open { flex: 1; min-width: 0; min-height: 56px; display: flex; flex-direction: column; align-items: flex-start; justify-content: center; gap: 2px; text-align: left; border: 0; background: transparent; white-space: normal; }
.empty .kept-open { justify-content: center; }
.kept-name, .kept-facts { max-width: 100%; white-space: normal; overflow-wrap: anywhere; }
.kept-name { font-weight: 600; }
.kept-facts { color: var(--pencil); font-size: 14px; }
.kept-delete { flex: none; min-height: 48px; min-width: 48px; }
.kept-total { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px; margin: 8px 0; font-size: 14px; }
.kept-total button { min-height: 48px; }
.kept-status { margin: 4px 0 0; font-size: 14px; }
.kept-status:empty { display: none; }
.app .empty:has(.kept:not([hidden])) { top: 50%; max-height: calc(100% - 24px); overflow-y: auto; }
.viewer-bar { flex: none; background: var(--paper); border-top: 1px solid var(--rule); padding: 0 12px max(6px, env(safe-area-inset-bottom)); }
.viewer-bar .status { display: block; height: 24px; line-height: 24px; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; transition: opacity .3s; }
.viewer-bar .readout { display: block; padding: 4px 0; white-space: normal; }
.status.faded { opacity: 0; }
.bar-actions { display: flex; gap: 8px; }
.bar-group { display: contents; }
.bar-actions button { justify-content: center; flex: 1; min-width: 0; min-height: 48px; font-size: 17px; white-space: normal; line-height: 1.15; }
.bar-actions .tool { border: 1px solid var(--graphite); background: var(--graphite); color: var(--paper); }
/* While measuring, More keeps its place at the end but gives the measuring buttons the room. */
.measuring #more { flex: 0 0 auto; padding-left: 12px; padding-right: 12px; }
.result-row { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 0 18px; }
.measure-results { display: flex; flex-wrap: wrap; gap: 6px 18px; padding: 2px 0 4px; }
.measure-results > span { display: flex; flex-direction: column; }
.result-label { font-size: 12px; color: var(--pencil); }
.measure-results strong { font: 400 18px/1.3 var(--lettering); white-space: nowrap; }
.result-scale { min-height: 44px; padding: 2px 8px; margin: 0 0 6px; font-size: 13px; }
.viewer-sheet { position: fixed; inset: auto 0 0; margin: 0 auto; width: min(100%, 44rem); max-height: 85dvh; padding: 0 18px max(18px, env(safe-area-inset-bottom)); border: 1px solid var(--rule); border-radius: 10px 10px 0 0; overflow-y: auto; }
.sheet-header { display: flex; justify-content: space-between; align-items: center; position: sticky; top: 0; background: var(--paper); padding: 12px 0; z-index: 1; border-bottom: 1px solid var(--rule); }
.sheet-header h2 { margin: 0; }
.sheet-setting { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 58px; border-bottom: 1px solid var(--rule); }
/* Convert to PDF: the whole drawing or a chosen area (B27), two buttons that open the converter. */
.convert-choices { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px; }
.viewer-sheet button, .viewer-sheet .button, .viewer-sheet .check { min-height: 44px; }
/* W19: every tap target at least 44 x 44 px: m, ft, EN and ET too. */
.viewer-sheet .choice button { min-width: 44px; justify-content: center; }
.viewer-sheet .panel { border: 0; overflow: visible; }
.viewer-sheet .panel > section { padding: 14px 0; }
.viewer-sheet details { padding: 14px 0; }
.viewer-sheet summary { cursor: pointer; }
/* More's own controls, like the viewer's chrome (#39): a double tap or long press on them selects no
   words (More opens under the finger, so the second tap lands on whatever row is there); a field in
   them stays selectable. */
.viewer-sheet :is(.sheet-header, .sheet-setting, details), .layers { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
:is(.viewer-sheet :is(.sheet-header, .sheet-setting, details), .layers) :is(input, textarea, select) { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
/* #191: the layers panel. On a phone it comes over the drawing from the left, the edge beside it left
   to tap; on a computer (panel.js, 1024 px and wider) it is the workspace's first column, above the bar, and the
   drawing keeps its place on the screen as the canvas narrows (app.js resize). */
.layers { position: fixed; inset: 0 auto 0 0; width: min(calc(100% - 56px), 24rem); max-width: none; height: 100dvh; max-height: none; margin: 0; padding: 0 16px max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); border: 0; border-right: 1px solid var(--rule); border-radius: 0; overflow-y: auto; overscroll-behavior: contain; }
.layers .sheet-header { gap: 8px; padding-top: max(12px, env(safe-area-inset-top)); }
.layers .sheet-header h2 { flex: 1; min-width: 0; font-size: 18px; }
.layers :is(button, .check) { min-height: 44px; }
@media (min-width: 1024px) {
  .layers:not(:modal) { position: static; width: auto; height: auto; padding-top: 0; min-height: 0; }
  .layers:not(:modal) .sheet-header { padding-top: 12px; }
  .app .workspace:has(> .layers[open]:not(:modal)) { grid-template-columns: 20rem minmax(0, 1fr); }
  .app .workspace.pro:has(> .layers[open]:not(:modal)) { grid-template-columns: 20rem minmax(0, 1fr) 410px; }
}
.pro-secondary { flex: none; border-bottom: 1px solid var(--rule); padding: 4px 12px; align-items: center; }
.pro-secondary .pro-tools { padding: 0; margin: 0; border: 0; }
.pro-secondary .pro-tool > button { min-height: 44px; }
/* The question never pushes its own buttons off screen: Cancel sits by the question, the typed
   scale or length above the presets, and only the presets scroll. */
#scale-step { display: flex; flex-direction: column; max-height: min(62dvh, 34rem); padding-top: 6px; }
.scale-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.scale-head button { flex: none; min-height: 44px; }
#scale-note { margin: 6px 0 0; font-size: 15px; color: var(--graphite); }
#scale-step .row { margin: 8px 0 0; }
.scale-presets { display: flex; flex-wrap: wrap; gap: 8px; margin: 10px 0 6px; min-height: 52px; overflow-y: auto; overscroll-behavior: contain; }
.scale-presets:empty { display: none; }
.scale-presets button { flex: 1 0 20%; min-height: 48px; justify-content: center; }
#scale-step h2 { font-size: 18px; margin: 0; }
#scale-step input { min-height: 44px; }
#scale-known-read { flex-basis: 100%; }
@media (max-height: 500px) {
  #scale-step { max-height: 58dvh; }
  .scale-presets button { flex-basis: 15%; min-height: 44px; }
}
@media (min-width: 901px) {
  .bar-actions { max-width: 40rem; margin: 0 auto; }
  .result-row, .measure-results { justify-content: center; }
  .viewer-bar { text-align: center; }
  .scale-presets { max-width: 48rem; margin: 10px auto; }
}
@media (max-width: 900px) {
  .app .workspace.pro { grid-template-columns: minmax(0, 1fr); grid-template-rows: minmax(0, 1fr) minmax(0, 30dvh); }
  .pro-secondary .pro-tools { flex-basis: auto; border-top: 0; }
  .pro-secondary { flex-wrap: nowrap; overflow: auto; padding: 3px 6px; }
  .app .toolbar { padding: 4px 8px; }
  .viewer-bar { padding-left: 8px; padding-right: 8px; }
  .bar-actions button { font-size: 16px; padding: 5px 8px; }
  .measure-results { gap: 3px 12px; }
  .measure-results strong { font-size: 17px; }
}
/* A 360 px phone: five buttons in Calibrate, "Katkesta" whole beside "Rohkem" (the measuring suite at 360 px). */
@media (max-width: 380px) {
  .bar-actions button, .measuring #more { padding-left: 4px; padding-right: 4px; font-size: 15px; }
  .measuring #more { min-width: 44px; }
}
@media (any-pointer: coarse), (hover: none) {
  .tip, .desktop-only { display: none !important; }
  kbd { display: none; }
}
@media (prefers-reduced-motion: reduce) { .viewer-bar .status { transition: none; } }
@media print { .viewer-bar, .pro-secondary, .viewer-sheet { display: none !important; } }

/* Loading is the whole screen: the only primary action is Cancel, or Close after an error. In the
   chrome's colours: dark grey with the Black background (style.css, .dark-chrome). */
.loading-screen { position: fixed; inset: 0; width: 100%; max-width: none; height: 100dvh; max-height: none; margin: 0; padding: max(24px, env(safe-area-inset-top)) max(20px, env(safe-area-inset-right)) max(24px, env(safe-area-inset-bottom)) max(20px, env(safe-area-inset-left)); border: 0; border-radius: 0; background: var(--paper); color: var(--graphite); overflow-y: auto; }
.loading-screen[open] { display: flex; align-items: center; justify-content: center; }
.loading-content { width: min(100%, 32rem); text-align: center; margin: auto; }
/* What is being done ("Opening your drawing…") above the file's name and the stage; on a failure the
   stage line is the heading instead (loading-screen.js error(), .failed). */
.loading-content h1 { font-size: clamp(26px, 5vw, 34px); line-height: 1.2; text-wrap: balance; }
.loading-file { margin: 10px 0 0; color: var(--pencil); font-size: 16px; overflow-wrap: anywhere; }
.loading-content > .loading-step { margin: 22px 0 0; font-size: 20px; font-weight: 600; line-height: 1.4; }
.loading-time { margin-left: 0.4em; font-variant-numeric: tabular-nums; }
.loading-time:empty { display: none; }
.loading-screen.failed .loading-step { margin-top: 0; font-size: clamp(25px, 5vw, 32px); line-height: 1.2; text-wrap: balance; }
.loading-screen.failed .loading-file { margin: 0 0 18px; }
.loading-content > p:not(.loading-file, .loading-step) { font-size: 18px; line-height: 1.5; margin: 18px 0 0; }
.loading-content > p.loading-hint { font-size: 16px; color: var(--pencil); margin-top: 12px; }
.loading-motion { width: 40px; height: 40px; margin: 0 auto 24px; border: 3px solid var(--rule); border-top-color: var(--graphite); border-radius: 50%; animation: loading-turn 1.4s linear infinite; }
.loading-content progress { display: block; width: 100%; height: 12px; margin: 28px 0 0; accent-color: var(--graphite); }
.loading-content progress.idle { visibility: hidden; }
.loading-content > :is(button, .button) { width: 100%; justify-content: center; min-height: 54px; font-size: 19px; margin-top: 32px; }
.loading-content > :is(button, .button):not([hidden]) ~ :is(button, .button) { margin-top: 12px; }
.loading-content details { margin-top: 22px; text-align: left; font-size: 14px; color: var(--pencil); }
.loading-content summary { cursor: pointer; width: fit-content; margin: 0 auto; padding: 8px; }
.loading-content pre { font: inherit; white-space: pre-wrap; overflow-wrap: anywhere; padding: 12px; border: 1px solid var(--rule); }
@keyframes loading-turn { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .loading-motion { animation: none; } }
@media print { .loading-screen { display: none !important; } }

/* A long press on the drawing or model measures: it never selects the page's text or opens iOS's
   callout or magnifier (ViewerShell also stops the touch's default on the canvas). Fields and the
   measured results stay selectable. */
.toolbar, .stage, .viewer-bar { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }
:is(.toolbar, .stage, .viewer-bar) :is(input, textarea, select, .measure-results, .readout) { -webkit-user-select: text; user-select: text; -webkit-touch-callout: default; }
