/* ConnoSITE 2 — calm slate and azure. Written for Safari 15 and later (no CSS nesting, :has, dvh or color-mix). */
:root {
  --azure: #2563eb; --azure-d: #1d4ed8; --azure-l: #e8f0fe;
  --ink: #17243a; --muted: #64748b; --line: #dce3ed; --soft: #f4f7fb; --paper: #e8edf4;
  --danger: #c2410c; --danger-l: #fff1ea; --ok: #15803d;
  --top: env(safe-area-inset-top, 0px); --bot: env(safe-area-inset-bottom, 0px);
  --left: env(safe-area-inset-left, 0px); --right: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--soft); color: var(--ink);
  font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  -webkit-text-size-adjust: 100%; overscroll-behavior: none; }
#app { position: fixed; top: 0; left: 0; right: 0; bottom: 0; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-user-select: none; user-select: none; }
button:disabled { cursor: default; opacity: .45; }
input, textarea, select { font: inherit; color: var(--ink); }
[hidden] { display: none !important; }
svg { flex: none; }
.muted { color: var(--muted); } .small { font-size: 13px; } .pad { padding: 16px; }

/* ---------- buttons ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 8px 16px;
  border: 1px solid var(--line); border-radius: 10px; background: #fff; font-weight: 600; }
.btn:active { background: var(--soft); }
.btn.primary { background: var(--azure); border-color: var(--azure); color: #fff; }
.btn.primary:active { background: var(--azure-d); }
.btn.danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { background: #fff; }
.btn.ghost.danger { color: var(--danger); border-color: #f3c7b2; background: #fff; }
.btn.small { min-height: 36px; padding: 4px 12px; font-size: 14px; border-radius: 8px; }
.btn.big { min-height: 56px; font-size: 17px; padding: 12px 22px; }
.btn.wide { width: 100%; margin-top: 10px; }
.link { background: none; border: 0; color: var(--azure); padding: 8px 4px; font-weight: 600; }
.x { width: 44px; height: 44px; border: 0; background: none; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: none; }
.x:active { background: var(--soft); }
.row { display: flex; gap: 10px; margin-top: 18px; } .row.end { justify-content: flex-end; }
.row2 { display: flex; gap: 12px; } .row2 > * { flex: 1; min-width: 0; }

/* ---------- form fields ---------- */
.field { display: block; margin: 12px 0; }
.field > span { display: block; font-size: 13px; font-weight: 600; color: var(--muted); margin-bottom: 5px; }
.field input, .field textarea { width: 100%; border: 1px solid #cbd5e1; border-radius: 10px; padding: 11px 12px; background: #fff; font-size: 16px; }
.field textarea { resize: vertical; min-height: 90px; }
.field input:focus, .field textarea:focus, .psearch input:focus, .otitle:focus { outline: 2px solid #93b4fc; outline-offset: 0; border-color: var(--azure); }
.field input.bad { border-color: var(--danger); }
.toggle { display: flex; align-items: center; gap: 12px; padding: 14px 0; font-weight: 600; }
.toggle input { width: 22px; height: 22px; accent-color: var(--azure); }
.sectionTitle { margin: 20px 0 8px; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.sectionTitle small { font-weight: 600; margin-left: 4px; color: #94a3b8; }

/* ---------- screens ---------- */
.screen { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; flex-direction: column; }

/* start */
#start { overflow-y: auto; -webkit-overflow-scrolling: touch; padding: calc(var(--top) + 24px) calc(var(--right) + 20px) calc(var(--bot) + 12px) calc(var(--left) + 20px); }
.startInner { flex: 1; width: 100%; max-width: 1000px; margin: 0 auto; display: flex; flex-direction: column; justify-content: center; }
.logo { width: 290px; max-width: 80%; height: auto; display: block; margin: 0 auto; }
.tag { text-align: center; color: var(--muted); margin: 10px 0 34px; }
.cards { display: flex; gap: 18px; }
.card { flex: 1; display: flex; flex-direction: column; align-items: flex-start; gap: 6px; text-align: left; min-height: 190px; padding: 26px 24px;
  border: 1px solid var(--line); border-radius: 18px; background: #fff; box-shadow: 0 1px 2px rgba(15,23,42,.05), 0 6px 20px rgba(15,23,42,.05); }
.card:active:not(:disabled) { transform: scale(.985); }
.card b { font-size: 21px; margin-top: auto; }
.card .csub { color: var(--muted); font-size: 15px; }
.card .csub strong { color: var(--ink); }
.cicon { width: 52px; height: 52px; border-radius: 14px; background: var(--azure-l); color: var(--azure); display: flex; align-items: center; justify-content: center; }
.cicon svg { width: 28px; height: 28px; }
.card.primary { background: var(--azure); border-color: var(--azure); color: #fff; }
.card.primary .csub { color: #dbe7ff; }
.card.primary .cicon { background: rgba(255,255,255,.18); color: #fff; }
.installTip { margin: 26px auto 0; max-width: 640px; display: flex; align-items: center; gap: 14px; padding: 12px 16px; background: #fff; border: 1px dashed #b9c9e2; border-radius: 12px; color: var(--muted); font-size: 14px; }
.installTip span { flex: 1; }
.startFoot { text-align: center; color: var(--muted); font-size: 13px; padding-top: 18px; display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 8px; }
.footBtns { width: 100%; display: flex; justify-content: center; gap: 10px; margin-top: 8px; flex-wrap: wrap; }
.footBtns .btn { font-size: 15px; color: var(--azure); }
.about .aboutLogo { display: block; width: 240px; max-width: 70%; margin: 4px auto 18px; }
.aboutRow { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px solid #eef2f7; }
.aboutRow span { color: var(--muted); }
.aboutRow b { text-align: right; font-weight: 600; }
.okText { color: var(--ok); }
.about .btn.big { margin-top: 18px; }
.offState.ok { color: var(--ok); font-weight: 600; }
@media (max-width: 700px) {
  .cards { flex-direction: column; gap: 12px; }
  .card { min-height: 0; flex-direction: row; flex-wrap: wrap; align-items: center; padding: 18px; column-gap: 16px; }
  .card b { margin-top: 0; font-size: 19px; flex: 1; }
  .card .csub { width: 100%; padding-left: 68px; margin-top: -8px; }
  .tag { margin-bottom: 22px; }
}

/* ---------- workspace ---------- */
.topbar { flex: none; display: flex; align-items: center; gap: 6px; padding: calc(var(--top) + 4px) calc(var(--right) + 8px) 4px calc(var(--left) + 6px);
  background: #fff; border-bottom: 1px solid var(--line); min-height: 54px; z-index: 5; }
.tb { min-height: 44px; border: 0; background: none; border-radius: 10px; padding: 6px 10px; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; min-width: 0; }
.tb:active { background: var(--soft); }
.tb.icon { width: 44px; padding: 0; justify-content: center; }
.tb.icon svg { width: 24px; height: 24px; }
.insName { font-size: 16px; max-width: 34%; }
.insName span, .drawSwitch span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.drawSwitch { border: 1px solid var(--line); background: var(--soft); font-weight: 500; max-width: 40%; }
.spacer { flex: 1; }
.saveState { font-size: 13px; color: var(--ok); font-weight: 600; white-space: nowrap; padding: 0 6px; }
.saveState.saving { color: var(--muted); }
.saveState.error { color: var(--danger); }
.tb.report { background: var(--azure); color: #fff; padding: 6px 18px; }
@media (max-width: 560px) {
  .insName { display: none; }
  .drawSwitch { max-width: 52%; }
  .tb.report { padding: 6px 12px; }
}

.body { flex: 1; min-height: 0; position: relative; display: flex; }
.stage { flex: 1; min-width: 0; position: relative; overflow: hidden; }
.view { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: var(--paper); overflow: hidden; touch-action: none; cursor: grab; -webkit-user-select: none; user-select: none; }
.view.placing { cursor: crosshair; }
.sheet { position: absolute; left: 0; top: 0; transform-origin: 0 0; background: #fff; box-shadow: 0 2px 14px rgba(15,23,42,.18); will-change: transform; }
.sheet canvas.base { display: block; width: 100%; height: 100%; }
.sheet canvas.detail { position: absolute; display: none; }
.view .pins { position: absolute; top: 0; left: 0; right: 0; bottom: 0; pointer-events: none; }
.pin { position: absolute; left: 0; top: 0; pointer-events: auto; width: 0; height: 0; }
.pin span { position: absolute; left: -17px; top: -44px; min-width: 34px; height: 34px; padding: 0 4px; border-radius: 17px; background: var(--azure); color: #fff;
  font: 700 15px/34px -apple-system, "Segoe UI", Roboto, sans-serif; text-align: center; border: 2px solid #fff; box-shadow: 0 2px 6px rgba(15,23,42,.35); }
.pin.wide span { left: -21px; min-width: 42px; }
.pin span::after { content: ""; position: absolute; left: 50%; bottom: -10px; margin-left: -7px; border: 7px solid transparent; border-top: 9px solid var(--azure); border-bottom: 0; }
.pin::before { content: ""; position: absolute; left: -24px; top: -50px; width: 48px; height: 56px; } /* larger touch target */
.pin.sel span { background: #0f2a5c; transform: scale(1.18); transform-origin: 50% 130%; box-shadow: 0 0 0 4px rgba(37,99,235,.35), 0 3px 8px rgba(15,23,42,.4); }
.pin.sel span::after { border-top-color: #0f2a5c; }
.pin.sel { z-index: 2; }
.vmsg { position: absolute; left: 50%; top: 40%; transform: translate(-50%, -50%); background: #fff; border: 1px solid var(--line); border-radius: 12px; padding: 14px 20px; color: var(--muted); font-weight: 600; box-shadow: 0 4px 16px rgba(15,23,42,.08); max-width: 80%; text-align: center; }
.vmsg.err { color: var(--danger); }

.viewTools { position: absolute; right: calc(var(--right) + 12px); top: 12px; display: flex; flex-direction: column; gap: 8px; z-index: 3; }
.vt { width: 46px; height: 46px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.96); display: flex; align-items: center; justify-content: center; box-shadow: 0 1px 4px rgba(15,23,42,.08); }
.vt svg { width: 24px; height: 24px; }
.vt:active { background: var(--soft); }

.placeHint { position: absolute; top: 12px; left: 50%; transform: translateX(-50%); z-index: 4; display: flex; align-items: center; gap: 12px;
  background: var(--ink); color: #fff; border-radius: 14px; padding: 8px 8px 8px 18px; font-weight: 600; box-shadow: 0 6px 20px rgba(15,23,42,.25); max-width: calc(100% - 90px); }
.placeHint .btn { background: rgba(255,255,255,.14); border-color: transparent; color: #fff; }

.empty { position: absolute; top: 0; left: 0; right: 0; bottom: 0; display: flex; align-items: center; justify-content: center; padding: 20px; z-index: 2; background: var(--paper); }
.emptyCard { background: #fff; border: 1px solid var(--line); border-radius: 18px; padding: 30px; max-width: 440px; text-align: center; box-shadow: 0 6px 24px rgba(15,23,42,.06); }
.emptyCard h2 { margin: 0 0 8px; font-size: 22px; }
.emptyCard p { color: var(--muted); margin: 0 0 22px; }
.emptyCard .btn { width: 100%; }
.emptyCard .link { margin-top: 10px; font-size: 14px; }

/* bottom bar */
.bottombar { flex: none; display: flex; background: #fff; border-top: 1px solid var(--line); padding: 6px calc(var(--right) + 8px) calc(var(--bot) + 6px) calc(var(--left) + 8px); gap: 6px; z-index: 6; }
.bb { flex: 1; min-height: 62px; border: 0; border-radius: 14px; background: none; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; font-size: 13px; font-weight: 600; color: #334155; }
.bb svg { width: 30px; height: 30px; }
.bb:active { background: var(--soft); }
.bb.on, .bb.active { background: var(--azure-l); color: var(--azure); }
#bPin { color: var(--azure); }
#bPin.on { background: var(--azure); color: #fff; }
@media (min-width: 760px) { .bottombar { justify-content: center; } .bb { flex: 0 1 170px; flex-direction: row; gap: 10px; font-size: 16px; } }

/* ---------- panel: side on tablets/desktop, sliding sheet on phones ---------- */
.panel { background: #fff; display: flex; flex-direction: column; min-height: 0; z-index: 5; }
.panelBody { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.grab { display: none; }
@media (min-width: 760px) {
  .panel { width: 390px; border-left: 1px solid var(--line); display: none; padding-right: var(--right); }
  .panel.open { display: flex; }
}
@media (min-width: 760px) and (max-width: 999px) { .panel { width: 330px; } }
@media (max-width: 759px) {
  .panel { position: absolute; left: 0; right: 0; bottom: 0; height: 58%; border-radius: 18px 18px 0 0; box-shadow: 0 -6px 28px rgba(15,23,42,.18);
    transform: translateY(105%); transition: transform .26s ease, height .26s ease; visibility: hidden; }
  .panel.open { transform: translateY(0); visibility: visible; }
  .panel.full { height: calc(100% - 10px); }
  .panel.peek { transform: translateY(calc(100% - 70px)); }
  .grab { display: flex; justify-content: center; padding: 8px 0 2px; flex: none; touch-action: none; }
  .grab span { width: 46px; height: 5px; border-radius: 3px; background: #cbd5e1; }
}
.phead { flex: none; display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 16px; border-bottom: 1px solid var(--line); }
.phead h2 { flex: 1; margin: 0; font-size: 18px; }
.phead h2 small { color: var(--muted); font-weight: 600; margin-left: 6px; }
.otitle { flex: 1; min-width: 0; border: 1px solid transparent; border-radius: 8px; padding: 9px 8px; font-size: 17px; font-weight: 700; background: none; }
.otitle:hover { border-color: var(--line); }
.badge { flex: none; min-width: 30px; height: 30px; padding: 0 6px; border-radius: 15px; background: var(--azure); color: #fff; font-weight: 700; font-size: 14px; display: inline-flex; align-items: center; justify-content: center; }
.badge.big { min-width: 38px; height: 38px; border-radius: 19px; font-size: 17px; }
.pscroll { flex: 1; min-height: 0; overflow-y: auto; -webkit-overflow-scrolling: touch; padding: 4px 16px 16px; overscroll-behavior: contain; }
.psearch { flex: none; padding: 10px 16px 4px; }
.psearch input { width: 100%; border: 1px solid #cbd5e1; border-radius: 10px; padding: 10px 12px; font-size: 16px; background: var(--soft); -webkit-appearance: none; }
.pfoot { flex: none; border-top: 1px solid var(--line); padding: 8px 16px calc(8px); }
.pfoot .btn.wide { margin: 0; }
.pfoot.nav { display: flex; align-items: center; justify-content: space-between; color: var(--muted); font-size: 14px; }
.orow { display: flex; width: 100%; gap: 12px; align-items: flex-start; text-align: left; padding: 12px 4px; border: 0; border-bottom: 1px solid #eef2f7; background: none; }
.orow:active { background: var(--soft); }
.otext { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.otext b { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.otext b.muted { font-weight: 500; font-style: italic; }
.otext span { color: var(--muted); font-size: 13px; }
.photos { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.thumb { position: relative; padding: 0; border: 1px solid var(--line); border-radius: 10px; overflow: hidden; background: var(--soft); aspect-ratio: 1 / 1; min-height: 88px; }
.thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.thumb .cap { position: absolute; left: 0; right: 0; bottom: 0; background: rgba(15,23,42,.62); color: #fff; font-size: 11px; padding: 2px 6px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; text-align: left; }
.thumb.off img { opacity: .4; }
.thumb.add { display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px; color: var(--azure); font-size: 12px; font-weight: 600; border-style: dashed; border-color: #b9c9e2; background: #fff; }
.pinrow { display: flex; align-items: center; gap: 6px; padding: 6px 0; border-bottom: 1px solid #eef2f7; }
.pinrow .ptext { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 14px; }
.pdot { flex: none; width: 24px; height: 24px; border-radius: 12px; background: var(--azure); color: #fff; font-size: 12px; font-weight: 700; display: inline-flex; align-items: center; justify-content: center; }
.pinrow .btn.small { padding: 4px 9px; font-size: 13px; }

/* ---------- dialogs ---------- */
.modal { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 50; display: flex; align-items: center; justify-content: center; padding: 20px; }
.scrim { position: absolute; top: 0; left: 0; right: 0; bottom: 0; background: rgba(15,23,42,.42); opacity: 0; transition: opacity .2s; }
.dialog { position: relative; width: 100%; max-width: 540px; max-height: 88%; overflow-y: auto; -webkit-overflow-scrolling: touch; background: #fff; border-radius: 18px;
  box-shadow: 0 20px 50px rgba(15,23,42,.3); transform: translateY(16px); opacity: 0; transition: transform .2s, opacity .2s; }
.modal.in .scrim { opacity: 1; } .modal.in .dialog { transform: none; opacity: 1; }
.modal.small .dialog { max-width: 440px; }
.modal.wide .dialog { max-width: 720px; }
.dhead { position: -webkit-sticky; position: sticky; top: 0; background: #fff; display: flex; align-items: center; padding: 10px 8px 6px 22px; z-index: 1; }
.dhead h2 { flex: 1; margin: 0; font-size: 19px; }
.dbody { padding: 4px 22px 22px; }
.ctext { margin: 6px 0; }
.choices { display: flex; flex-direction: column; gap: 10px; margin-top: 14px; }
.choice { text-align: left; padding: 14px 16px; border: 1px solid var(--line); border-radius: 12px; background: #fff; display: flex; flex-direction: column; }
.choice span { color: var(--muted); font-size: 14px; }
.choice.danger b { color: var(--danger); }
@media (max-width: 600px) {
  .modal { padding: 0; align-items: flex-end; }
  .dialog { max-width: none !important; border-radius: 18px 18px 0 0; max-height: 92%; padding-bottom: var(--bot); transform: translateY(40px); }
}
.ilist, .dlist { margin-top: 6px; }
.irow, .drow { display: flex; align-items: center; gap: 10px; border-bottom: 1px solid #eef2f7; padding: 4px 0; flex-wrap: wrap; }
.iopen, .dopen { flex: 1; min-width: 220px; text-align: left; border: 0; background: none; padding: 10px 4px; display: flex; flex-direction: column; border-radius: 10px; }
.iopen:active, .dopen:active { background: var(--soft); }
.iopen b, .dopen b { font-size: 16px; }
.iopen span, .dopen span { color: var(--muted); font-size: 14px; }
.iopen .meta { font-size: 12px; }
.drow.cur .dopen b::before { content: "● "; color: var(--azure); }
.dacts { display: flex; gap: 6px; flex-wrap: wrap; }
.openFiles { margin-top: 18px; }

/* photo viewer */
.modal.photo { padding: 0; }
.modal.photo .dialog { max-width: none !important; width: 100%; height: 100%; max-height: none; border-radius: 0; background: #0b1220; }
.modal.photo .dbody { padding: 0; height: 100%; }
.pv { display: flex; height: 100%; }
.pvimg { flex: 1; min-width: 0; position: relative; display: flex; align-items: center; justify-content: center; padding-top: var(--top); }
.pvimg img { max-width: 100%; max-height: 100%; object-fit: contain; }
.pvnav { position: absolute; top: 50%; margin-top: -30px; width: 56px; height: 60px; border: 0; border-radius: 12px; background: rgba(255,255,255,.14); color: #fff; font-size: 36px; line-height: 1; }
.pvnav.prev { left: calc(var(--left) + 10px); } .pvnav.next { right: 10px; }
.pvside { width: 360px; background: #fff; padding: calc(var(--top) + 8px) calc(var(--right) + 18px) calc(var(--bot) + 18px) 18px; overflow-y: auto; }
.pvhead { display: flex; align-items: center; gap: 8px; } .pvhead b { flex: 1; }
@media (max-width: 760px) { .pv { flex-direction: column; } .pvimg { flex: 1; } .pvside { width: auto; max-height: 48%; } }

/* toast and busy */
.toast { position: fixed; left: 50%; top: calc(var(--top) + 66px); transform: translate(-50%, -12px); background: var(--ink); color: #fff; padding: 12px 18px; border-radius: 12px; font-weight: 600;
  opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 80; max-width: calc(100% - 32px); box-shadow: 0 8px 24px rgba(15,23,42,.3); }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
@media (min-width: 760px) { .toast { top: auto; bottom: calc(var(--bot) + 96px); transform: translate(-50%, 12px); } .toast.show { transform: translate(-50%, 0); } }
.toast.err { background: var(--danger); }
.busy { position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 90; background: rgba(15,23,42,.28); display: flex; align-items: center; justify-content: center; }
.busy > div { background: #fff; border-radius: 14px; padding: 18px 24px; display: flex; align-items: center; gap: 14px; font-weight: 600; box-shadow: 0 12px 30px rgba(15,23,42,.25); }
.spin { width: 22px; height: 22px; border: 3px solid var(--azure-l); border-top-color: var(--azure); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
