/* Flexible pavement design — on top of calc.css */
main.pv .tabs { grid-template-columns: repeat(3, 1fr); }
main.pv .stage-bar { justify-content: flex-start; gap: 8px; flex-wrap: wrap; }
main.pv .stage-bar .hist { margin-left: auto; }
#view { display: block; width: 100%; height: auto; user-select: none; touch-action: none; }
#view .hit { fill: transparent; stroke: none; }
#view .handle { cursor: grab; }
#view .handle.hy { cursor: ns-resize; }
#view .handle .knob { fill: var(--surface); stroke: var(--sel); stroke-width: 1.8; }
#view .handle:hover .knob, #view .handle:focus .knob { fill: var(--sel); }

/* the section */
.pv-asph { fill: var(--pv-asphalt, #55595f); } .pv-asphd { fill: var(--pv-asphalt-dot, #868a90); }
.pv-agg { fill: var(--x-e4dccb, #e4dccb); } .pv-aggd { fill: none; stroke: var(--x-a99f88, #a99f88); stroke-width: .8; }
.pv-sub { fill: var(--soil-2); } .pv-subd { fill: var(--x-bdb39b, #bdb39b); }
.pv-soil { fill: var(--x-ddd2bd, #ddd2bd); } .pv-soilh { stroke: var(--x-b7aa90, #b7aa90); stroke-width: 1; }
.pv-layer { stroke: none; }
.pv-hot { stroke: var(--sel); stroke-width: 2; }
.pv-if { fill: none; stroke: var(--x-6b6f75, #6b6f75); stroke-width: 1; }
.pv-top { fill: none; stroke: var(--ink); stroke-width: 1.6; }
.pv-cut { fill: none; stroke: var(--steel-550); stroke-width: .9; stroke-dasharray: 8 3 1.5 3; }
.pv-need { fill: none; stroke-width: 1.6; stroke-dasharray: 6 4; pointer-events: none; }
.pv-need.ok { stroke: var(--good); } .pv-need.short { stroke: var(--bad); }
.pv-tyre { fill: var(--pv-tyre, #3a3d42); stroke: var(--pv-tyre-line, #1f2125); stroke-width: 1; }
.pv-axle { fill: none; stroke: var(--steel-700); stroke-width: 2.2; }
.pv-load line { stroke: var(--load); stroke-width: 1.8; }
.pv-load path { fill: var(--load); stroke: none; }
.pv-name { font-size: 12.5px; font-weight: 600; fill: var(--text); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.pv-role { font-size: 11px; fill: var(--text-2); paint-order: stroke; stroke: var(--surface); stroke-width: 3px; stroke-linejoin: round; }
.pv-nm { cursor: text; }
.pv-nm:hover .pv-name, .pv-nm:focus .pv-name { fill: var(--sel); }
.pv-nm:focus { outline: none; }

/* pills */
#view .pill rect { fill: var(--surface); stroke: var(--steel-300); }
#view .pill text { font-size: 11.5px; font-weight: 500; fill: var(--text-2); font-variant-numeric: tabular-nums; }
#view .pill.load rect { stroke: color-mix(in srgb, var(--load) 40%, transparent); } #view .pill.load text { fill: var(--load-ink); font-weight: 600; }
#view .pill.es rect { stroke: color-mix(in srgb, var(--moment) 45%, transparent); } #view .pill.es text { fill: var(--x-2d4a8c, #2d4a8c); font-weight: 600; }
#view .pill.th text { fill: var(--text); font-weight: 600; }
#view .pill.sn.ok rect { stroke: color-mix(in srgb, var(--good) 50%, transparent); } #view .pill.sn.ok text { fill: var(--good-ink); font-weight: 600; }
#view .pill.sn.short rect { stroke: color-mix(in srgb, var(--bad) 50%, transparent); } #view .pill.sn.short text { fill: var(--bad-ink); font-weight: 600; }
#view .pill.editable { cursor: text; }
#view .pill.editable:hover rect, #view .pill.editable:focus rect { stroke: var(--sel); stroke-width: 1.4; }
#view .pill.editable:focus { outline: none; }

/* editors in the drawing */
.stage { position: relative; }
.pv-edit { position: absolute; transform: translate(-50%, -50%); z-index: 5; display: flex; align-items: center; gap: 4px; background: var(--surface); border: 1.5px solid var(--sel); border-radius: 9px; padding: 2px 8px 2px 4px; box-shadow: 0 6px 18px rgba(20, 22, 28, .14); }
.pv-edit input { width: 82px; border: 0; outline: none; font: inherit; font-size: 13px; text-align: right; font-variant-numeric: tabular-nums; padding: 3px 2px; background: transparent; color: var(--text); }
.pv-edit-name input { width: 180px; text-align: center; }
.pv-edit span { font-size: 11.5px; color: var(--text-3); white-space: nowrap; }

/* live strip and flags */
.pv-live { display: flex; flex-wrap: wrap; gap: 4px 18px; padding: 8px 14px; border-top: 1px solid var(--line); font-size: 12.5px; color: var(--text-2); font-variant-numeric: tabular-nums; min-height: 38px; align-items: center; }
.pv-live b { font-weight: 500; color: var(--text-3); margin-right: 5px; }
.pv-key { display: inline-flex; align-items: center; gap: 6px; color: var(--text-3); }
.pv-key i { display: inline-block; width: 22px; height: 0; border-top: 2px dashed var(--good); }
.pv-flags { display: inline-flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.pv-flags span { display: inline-flex; align-items: center; line-height: 1; font-size: 11.5px; color: var(--text-3); border: 1px solid var(--line); border-radius: 999px; padding: 4px 10px; white-space: nowrap; }
.pv-flags span.pv-err { color: var(--bad-ink); border-color: color-mix(in srgb, var(--bad) 35%, transparent); white-space: normal; }

/* panel */
.pv-seg { margin-bottom: 6px; }
.pv-ln { cursor: text; border-bottom: 1px dashed var(--line-2); }
.pv-ln:hover, .pv-ln:focus { color: var(--sel); border-color: var(--sel); outline: none; }
.pv-nmi { font: inherit; font-size: 12.5px; font-weight: 600; width: 100%; max-width: 220px; padding: 2px 6px; border: 1.5px solid var(--sel); border-radius: 6px; background: var(--surface); color: var(--text); }
.pv-check { display: flex; align-items: center; gap: 8px; font-size: 12.5px; color: var(--text-2); margin: 6px 0 4px; cursor: pointer; }
.pv-check input { margin: 0; }
.pv-add { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 6px; }
.pv-del { margin-top: 4px; font-size: 12px; color: var(--text-3); }
.pv-axh, .pv-axle { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr) minmax(0, .8fr) 26px; gap: 6px; align-items: center; }
.pv-axh { font-size: 11.5px; color: var(--text-3); margin: 6px 0 2px; }
.pv-axle { margin-bottom: 4px; }
.pv-axle select { width: 100%; min-width: 0; }
.pv-axle .num input { width: 100%; }
.pv-x { width: 26px; height: 26px; padding: 0; font-size: 15px; color: var(--text-3); }
#panel input.bad { color: var(--bad); }
#panel .num:has(input.bad) input { border-color: var(--bad); }
#panel.fade-b { -webkit-mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to bottom, #000 calc(100% - 32px), transparent); }
#panel.fade-t { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px); mask-image: linear-gradient(to bottom, transparent, #000 28px); }
#panel.fade-t.fade-b { -webkit-mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 32px), transparent); mask-image: linear-gradient(to bottom, transparent, #000 28px, #000 calc(100% - 32px), transparent); }

/* summary */
.pv-say { margin-top: 6px; font-size: 12.5px; color: var(--text-2); line-height: 1.4; max-width: 40ch; }
.pv-big { font-weight: 600; color: var(--x-2d4a8c, #2d4a8c); }
.pv-tag { display: inline-block; font-size: 10.5px; color: var(--text-3); border: 1px solid var(--line); border-radius: 999px; padding: 0 7px; margin-left: 4px; white-space: nowrap; line-height: 1.5; }

/* charts and tables */
.pv-two { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
#wChart, #mChart { touch-action: none; user-select: none; }
#wChart .cdrag, #mChart .cdrag { cursor: ew-resize; }
svg.fb-chart .ch-g { fill: var(--fill-1); }
#checks td.note { white-space: normal; min-width: 200px; line-height: 1.4; }
table.pv-ax { width: 100%; border-collapse: collapse; font-size: 12.5px; font-variant-numeric: tabular-nums; }
.pv-ax th { font-weight: 500; font-size: 11.5px; color: var(--text-3); text-align: right; padding: 6px 8px; border-bottom: 1px solid var(--line); }
.pv-ax td { text-align: right; padding: 5px 8px; border-bottom: 1px solid var(--line); }
.pv-ax .l { text-align: left; }
.pv-ax tr.tot td { font-weight: 600; color: var(--text); }

@media (max-width: 1100px) { .pv-two { grid-template-columns: minmax(0, 1fr); } }
@media (max-width: 760px) {
  #checks thead { display: none; }
  #checks, #checks tbody { display: block; width: 100%; }
  #checks tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 4px 10px; padding: 9px 0; border-bottom: 1px solid var(--line); }
  #checks td { display: block; border: 0; padding: 0; text-align: left; white-space: normal; }
  #checks td.chk { grid-column: 1; grid-row: 1; }
  #checks td:nth-child(5) { grid-column: 2; grid-row: 1; align-self: center; }
  #checks td:nth-child(2) { grid-column: 1; grid-row: 2; font-size: 12.5px; }
  #checks td:nth-child(3) { grid-column: 2; grid-row: 2; font-size: 12.5px; text-align: right; }
  #checks td:nth-child(2)::before { content: "provided "; color: var(--text-3); }
  #checks td:nth-child(3)::before { content: "required "; color: var(--text-3); }
  #checks td:nth-child(4) { grid-column: 1 / -1; grid-row: 3; font-size: 12px; color: var(--text-3); min-width: 0; }
  .pv-ax th, .pv-ax td { padding: 5px 4px; }
}
@media print { .pv-edit { display: none !important; } }

/* hold the drawing's place until app.js draws it (no layout shift) */
#view:empty { aspect-ratio: 1000 / 560; }
@media (max-width: 640px) { #view:empty { aspect-ratio: 375 / 600; } }

/* theme-auto:start · generated by scripts/theme/hexmap.py: dark values (the rule of scripts/theme/colour.py) for
   colours that are not tokens, written as var(--x-rrggbb, #rrggbb): light is the fallback, unchanged */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --x-2d4a8c: #84a1dd; --x-6b6f75: #82858a; --x-6e7177: #85827f; --x-a99f88: #655e4d; --x-b7aa90: #605744;
    --x-bdb39b: #57503f; --x-d9d2c0: #403c30; --x-ddd2bd: #423b2d; --x-e4dccb: #3a352a;
  }
}
@media screen {
  :root[data-theme="dark"] {
    --x-2d4a8c: #84a1dd; --x-6b6f75: #82858a; --x-6e7177: #85827f; --x-a99f88: #655e4d; --x-b7aa90: #605744;
    --x-bdb39b: #57503f; --x-d9d2c0: #403c30; --x-ddd2bd: #423b2d; --x-e4dccb: #3a352a;
  }
}
/* theme-auto:end */

/* theme-hand:start · dark values picked by hand (materials keep their real tone); they override the rule above */
@media screen and (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) { --pv-asphalt: #3b3a37; --pv-asphalt-dot: #5d5b56; --pv-tyre: #121211; --pv-tyre-line: #5a5853; --pv-asphalt-icon: #45433f; }   /* theme: keep */
}
@media screen {
  :root[data-theme="dark"] { --pv-asphalt: #3b3a37; --pv-asphalt-dot: #5d5b56; --pv-tyre: #121211; --pv-tyre-line: #5a5853; --pv-asphalt-icon: #45433f; }   /* theme: keep */
}
/* theme-hand:end */
