/* PGS Studio
   Vocabulary: car-park signage for navigation (level plates, DIN lettering), drafting for the plan
   (hairlines, scale bar). Colour carries meaning only: plan objects use the colours of the PDF legend,
   yellow asks for a decision, red marks a broken rule. */
:root {
  --asphalt: #18212b;
  --asphalt-2: #2a3441;
  --concrete: #eef0f2;
  --paper: #ffffff;
  --kerb: #d5dae0;
  --kerb-2: #e6e9ed;
  --muted: #5d6877;
  --blue: #0b55b4;
  --blue-dark: #0a4796;
  --blue-tint: #e8f0fb;
  --yellow: #f5b301;
  --yellow-tint: #fff6d6;
  --green: #1e8e3e;
  --green-tint: #e6f4ea;
  --red: #c5221f;
  --red-tint: #fce8e6;
  --f-sign: "Bahnschrift", "DIN Alternate", "DIN 2014", "D-DIN", "Roboto Condensed", "Arial Narrow", "Helvetica Neue", Arial, sans-serif;
  --f-text: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", "Noto Sans", Arial, sans-serif;
  --bar: 48px;
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--concrete); color: var(--asphalt); font: 14px/1.45 var(--f-text); -webkit-text-size-adjust: 100%; }
h1, h2, h3 { font-family: var(--f-sign); font-stretch: 92%; font-weight: 600; margin: 0; letter-spacing: 0.005em; }
h1 { font-size: 28px; line-height: 1.15; }
h2 { font-size: 19px; line-height: 1.2; }
h3 { font-size: 15px; line-height: 1.25; }
p { margin: 0 0 10px; }
a { color: var(--blue); text-underline-offset: 2px; }
button, input, select { font: inherit; color: inherit; }
:focus-visible { outline: 2px solid var(--blue); outline-offset: 2px; }
.boot { padding: 80px 24px; text-align: center; color: var(--muted); }
.muted { color: var(--muted); }
.num { font-variant-numeric: tabular-nums; }
.hide { display: none !important; }

/* ---- top bar */
.bar { height: var(--bar); background: var(--asphalt); color: #fff; display: flex; align-items: center; gap: 14px; padding: 0 16px; position: sticky; top: 0; z-index: 20; }
.brand { display: flex; align-items: center; gap: 9px; color: #fff; text-decoration: none; font-family: var(--f-sign); font-stretch: 92%; font-weight: 600; font-size: 17px; white-space: nowrap; }
.brand img { width: 24px; height: 24px; display: block; }
.crumbs { display: flex; align-items: center; gap: 8px; min-width: 0; flex: 1; font-size: 13.5px; }
.crumbs > * { min-width: 0; }
.crumbs .sep { flex: none; }
.crumbs a { color: #c9d2dc; text-decoration: none; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.crumbs a:hover { color: #fff; text-decoration: underline; }
.crumbs .sep { color: #5f6b7a; }
.crumbs .here { color: #fff; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.who { display: flex; align-items: center; gap: 4px; font-size: 13px; }
.who .name { color: #c9d2dc; margin-right: 6px; white-space: nowrap; }
.bar .link { background: none; border: 0; color: #c9d2dc; padding: 6px 8px; border-radius: 4px; cursor: pointer; text-decoration: none; }
.bar .link:hover { color: #fff; background: var(--asphalt-2); }
.busy { position: fixed; left: 0; right: 0; top: var(--bar); height: 3px; z-index: 30; overflow: hidden; background: transparent; }
.busy::before { content: ""; position: absolute; inset: 0; width: 35%; background: var(--yellow); animation: run 1.1s linear infinite; }
@keyframes run { from { transform: translateX(-100%); } to { transform: translateX(300%); } }
@media (prefers-reduced-motion: reduce) { .busy::before { animation: none; width: 100%; } }

/* ---- pages */
.page { max-width: 1280px; margin: 0 auto; padding: 28px 24px 60px; }
.head { display: flex; align-items: flex-end; gap: 16px; margin-bottom: 22px; flex-wrap: wrap; }
.head .grow { flex: 1; min-width: 220px; }
.head .sub { color: var(--muted); margin-top: 4px; }
.sheet { background: var(--paper); border: 1px solid var(--kerb); }
.sheet + .sheet { margin-top: 20px; }
.sheet > header { display: flex; align-items: center; gap: 12px; padding: 12px 16px; border-bottom: 1px solid var(--kerb); }
.sheet > header h2 { flex: 1; }
.sheet .pad { padding: 14px 16px; }
.empty { padding: 44px 24px; text-align: center; color: var(--muted); }
.empty h2 { color: var(--asphalt); margin-bottom: 6px; }
.empty .btn { margin-top: 14px; }
.cols { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.cols > * { min-width: 0; }
@media (max-width: 1040px) { .cols { grid-template-columns: minmax(0, 1fr); } }

/* ---- buttons and fields */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 6px; height: 34px; padding: 0 13px; border: 1px solid var(--kerb); border-radius: 4px; background: var(--paper); cursor: pointer; white-space: nowrap; text-decoration: none; color: var(--asphalt); }
.btn:hover { border-color: #aab3bf; background: #f7f8fa; }
.btn.primary { background: var(--blue); border-color: var(--blue); color: #fff; font-weight: 600; }
.btn.primary:hover { background: var(--blue-dark); border-color: var(--blue-dark); }
.btn.ok { border-color: var(--green); color: var(--green); }
.btn.ok:hover { background: var(--green-tint); }
.btn.danger { color: var(--red); }
.btn.danger:hover { background: var(--red-tint); border-color: var(--red); }
.btn.small { height: 28px; padding: 0 9px; font-size: 13px; }
.btn.on { background: var(--blue-tint); border-color: var(--blue); color: var(--blue-dark); }
.btn:disabled { opacity: 0.5; cursor: default; }
.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 13px; color: var(--muted); margin-bottom: 4px; }
.field input, .field select, .inline input, .inline select { width: 100%; height: 34px; padding: 0 9px; border: 1px solid var(--kerb); border-radius: 4px; background: var(--paper); }
.field input:focus, .field select:focus { border-color: var(--blue); }
.pair { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.inline { display: flex; align-items: center; gap: 8px; }
.inline input { width: 74px; }
.actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.actions.end { justify-content: flex-end; margin-top: 16px; }
td > .actions.tight { flex-wrap: nowrap; justify-content: flex-end; gap: 6px; }
.err { color: var(--red); margin: 8px 0 0; min-height: 1.2em; }
label.check { display: flex; gap: 8px; align-items: flex-start; cursor: pointer; padding: 3px 0; }
label.check input { margin-top: 3px; }

/* ---- level plates: the lettering of a car-park level sign */
.plate { display: inline-flex; align-items: center; justify-content: center; min-width: 46px; max-width: 150px; height: 30px; padding: 0 9px; background: var(--blue); color: #fff; border-radius: 4px; font-family: var(--f-sign); font-stretch: 88%; font-weight: 600; font-size: 15px; letter-spacing: 0.02em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.plate.big { height: 36px; font-size: 18px; min-width: 56px; }

/* ---- ruled tables */
table.grid { width: 100%; border-collapse: collapse; }
table.grid th { text-align: left; font-weight: 600; font-size: 12.5px; color: var(--muted); padding: 8px 10px; border-bottom: 1px solid var(--asphalt); white-space: nowrap; }
table.grid td { padding: 8px 10px; border-bottom: 1px solid var(--kerb-2); vertical-align: middle; }
table.grid tr:last-child td { border-bottom: 0; }
table.grid .r { text-align: right; font-variant-numeric: tabular-nums; }
table.grid tr.link { cursor: pointer; }
table.grid tr.link:hover td { background: #f6f8fb; }
table.grid tr.group td { font-family: var(--f-sign); font-stretch: 92%; font-weight: 600; font-size: 13px; color: var(--muted); padding-top: 14px; border-bottom: 1px solid var(--kerb); }
table.grid tr.total td { font-weight: 600; }
table.grid td.strong { font-weight: 600; }
table.grid .basis { display: block; font-size: 12px; color: var(--muted); margin-top: 1px; }
.scroll-x { overflow-x: auto; }
.tag { display: inline-block; padding: 1px 7px; border-radius: 3px; font-size: 12px; line-height: 18px; background: var(--concrete); color: var(--muted); white-space: nowrap; }
.tag.warn { background: var(--yellow-tint); color: #6b4e00; }
.tag.bad { background: var(--red-tint); color: var(--red); }
.tag.ok { background: var(--green-tint); color: var(--green); }
.pname { font-family: var(--f-sign); font-stretch: 92%; font-weight: 600; font-size: 17px; }

/* ---- sign-in */
.signin { min-height: 100vh; display: grid; grid-template-columns: minmax(0, 1fr) minmax(320px, 420px); }
.signin .art { background: var(--asphalt); position: relative; overflow: hidden; }
.signin .art svg { position: absolute; inset: 0; width: 100%; height: 100%; }
.signin form { background: var(--paper); padding: 56px 40px; display: flex; flex-direction: column; justify-content: center; }
.signin h1 { margin: 18px 0 6px; }
.signin .lead { color: var(--muted); margin-bottom: 26px; }
.signin .btn { width: 100%; height: 40px; margin-top: 6px; }
@media (max-width: 760px) { .signin { grid-template-columns: 1fr; } .signin .art { display: none; } .signin form { padding: 40px 24px; } }

/* ---- level editor */
.editor { height: calc(100vh - var(--bar)); display: grid; grid-template-columns: minmax(0, 1fr) 372px; grid-template-rows: auto minmax(0, 1fr); }
.steps { grid-column: 1 / -1; display: flex; align-items: center; gap: 14px; padding: 8px 16px; background: var(--paper); border-bottom: 1px solid var(--kerb); min-width: 0; }
.steps .title { display: flex; align-items: center; gap: 10px; min-width: 0; margin-right: 6px; }
.steps .title .file { color: var(--muted); font-size: 12.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.steps nav { display: flex; gap: 2px; flex: 1; min-width: 0; overflow-x: auto; }
.step { display: flex; align-items: center; gap: 8px; height: 34px; padding: 0 12px 0 8px; border: 0; background: none; border-radius: 4px; cursor: pointer; white-space: nowrap; color: var(--muted); }
.step .n { display: inline-flex; width: 20px; height: 20px; border-radius: 50%; align-items: center; justify-content: center; font-size: 12px; font-weight: 600; border: 1px solid currentColor; }
.step:hover { background: var(--concrete); color: var(--asphalt); }
.step[aria-current="step"] { background: var(--asphalt); color: #fff; }
.step[aria-current="step"] .n { background: #fff; color: var(--asphalt); border-color: #fff; }
.step .dot { width: 7px; height: 7px; border-radius: 50%; background: var(--yellow); }
.stage { position: relative; background: var(--paper); min-height: 0; overflow: hidden; }
.stage canvas { position: absolute; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.stage canvas.pick { cursor: pointer; }
.stage canvas.place { cursor: crosshair; }
.stage canvas.drag { cursor: grabbing; }
.tools { position: absolute; left: 12px; top: 12px; display: flex; flex-direction: column; gap: 6px; }
.tools .set { display: flex; flex-direction: column; background: var(--paper); border: 1px solid var(--kerb); border-radius: 4px; overflow: hidden; }
.tools button { width: 32px; height: 32px; border: 0; background: none; cursor: pointer; font-size: 17px; line-height: 1; color: var(--asphalt); }
.tools button + button { border-top: 1px solid var(--kerb-2); }
.tools button:hover { background: var(--concrete); }
.hint { position: absolute; left: 50%; top: 12px; transform: translateX(-50%); background: var(--asphalt); color: #fff; padding: 7px 12px; border-radius: 4px; font-size: 13px; pointer-events: none; white-space: nowrap; max-width: 90%; overflow: hidden; text-overflow: ellipsis; }
.legend { position: absolute; right: 12px; bottom: 10px; display: flex; gap: 12px; flex-wrap: wrap; justify-content: flex-end; font-size: 12px; color: var(--muted); background: rgba(255, 255, 255, 0.88); padding: 4px 8px; border-radius: 3px; max-width: 70%; }
.legend i { display: inline-block; width: 10px; height: 10px; margin-right: 5px; vertical-align: -1px; border: 1px solid transparent; }
.side { background: var(--paper); border-left: 1px solid var(--kerb); overflow-y: auto; min-height: 0; }
.side section { padding: 14px 16px; border-bottom: 1px solid var(--kerb-2); }
.side section:last-child { border-bottom: 0; }
.side h3 { margin-bottom: 8px; }
.side p { color: var(--muted); font-size: 13px; }
.figs { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 0; }
.figs.four { grid-template-columns: repeat(4, minmax(0, 1fr)); }
.fig { padding: 2px 10px 2px 0; }
.fig + .fig { padding-left: 10px; border-left: 1px solid var(--kerb-2); }
.fig b { display: block; font-family: var(--f-sign); font-stretch: 90%; font-weight: 600; font-size: 26px; line-height: 1.1; font-variant-numeric: tabular-nums; }
.fig span { font-size: 12.5px; color: var(--muted); }
.fig.warn b { color: #9a6b00; }
.fig.bad b { color: var(--red); }
.note { padding: 8px 10px; border-left: 3px solid var(--yellow); background: var(--yellow-tint); font-size: 13px; color: #4d3900; margin: 0 0 8px; }
.note.bad { border-color: var(--red); background: var(--red-tint); color: #7a1512; }
.note.info { border-color: var(--blue); background: var(--blue-tint); color: #0a3470; }
ul.rows { list-style: none; margin: 0; padding: 0; }
ul.rows li { display: flex; align-items: center; gap: 8px; padding: 7px 8px; margin: 0 -8px; border-radius: 4px; cursor: pointer; }
ul.rows li:hover { background: #f6f8fb; }
ul.rows li.sel { background: var(--blue-tint); }
ul.rows li .txt { flex: 1; min-width: 0; }
ul.rows li .txt b { font-weight: 600; }
ul.rows li .txt small { display: block; color: var(--muted); font-size: 12px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
ul.rows li .btn { flex: none; }
.swatch { width: 18px; height: 18px; border-radius: 3px; flex: none; display: inline-flex; align-items: center; justify-content: center; font: 600 11px var(--f-sign); }
details.more { margin-top: 2px; }
details.more summary { cursor: pointer; color: var(--blue); font-size: 13px; padding: 4px 0; }
details.more[open] summary { margin-bottom: 8px; }
.side table.grid th, .side table.grid td { padding: 6px 6px; font-size: 13px; }
.side table.grid td:first-child, .side table.grid th:first-child { padding-left: 0; }
.side table.grid td:last-child, .side table.grid th:last-child { padding-right: 0; }
.side table.grid tr.hot td { background: var(--blue-tint); }
@media (max-width: 900px) {
  .editor { height: auto; grid-template-columns: minmax(0, 1fr); grid-template-rows: auto 62vh auto; }
  .steps { flex-wrap: wrap; row-gap: 6px; }
  .steps nav { order: 3; flex-basis: 100%; }
  .side { border-left: 0; border-top: 1px solid var(--kerb); }
  .legend { display: none; }
}

/* ---- dialogs and toasts */
dialog { border: 1px solid var(--kerb); border-radius: 6px; padding: 0; width: min(460px, calc(100vw - 32px)); color: var(--asphalt); box-shadow: 0 18px 50px rgba(24, 33, 43, 0.28); }
dialog::backdrop { background: rgba(24, 33, 43, 0.45); }
dialog form { padding: 20px 22px; }
dialog h2 { margin-bottom: 14px; }
#toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; z-index: 50; align-items: center; pointer-events: none; }
.toast { background: var(--asphalt); color: #fff; padding: 9px 14px; border-radius: 4px; font-size: 13.5px; max-width: min(560px, 92vw); box-shadow: 0 6px 20px rgba(24, 33, 43, 0.25); }
.toast.bad { background: var(--red); }

/* ---- small screens */
@media (max-width: 640px) {
  .bar { gap: 8px; padding: 0 10px; }
  .brand { font-size: 0; gap: 0; }
  .who .name { display: none; }
  .bar .link { padding: 6px 5px; }
  .page { padding: 18px 12px 40px; }
  h1 { font-size: 23px; }
  .figs.four { grid-template-columns: repeat(2, minmax(0, 1fr)); row-gap: 10px; }
  .figs.four .fig:nth-child(3) { padding-left: 0; border-left: 0; }
}
