/* Self-contained name keyboard for all territory pages, no third-party input method. */
body.name-keyboard-open { padding-bottom:calc(296px + env(safe-area-inset-bottom))!important; }
.street-page input[data-field="resident_name"] { cursor:pointer; }
.street-page input[data-field="resident_name"].name-keyboard-selected {
 outline:3px solid #28836c!important;outline-offset:0!important;
 background:#f0fff8!important;color:#122c23!important;
}
.name-keyboard[hidden] { display:none!important; }
.name-keyboard {
 position:fixed;bottom:0;left:0;right:0;z-index:100010;
 background:#e8edea;color:#18372c;border-top:2px solid #43856b;
 box-shadow:0 -8px 25px #0003;box-sizing:border-box;
 padding:6px 5px calc(6px + env(safe-area-inset-bottom));
 overscroll-behavior:contain;-webkit-user-select:none;user-select:none;
 font-family:system-ui,-apple-system,sans-serif;
}
.name-keyboard button {
 touch-action:manipulation;cursor:pointer;border-radius:7px;
 border:1px solid #b8c9c1;background:white;color:#18372c;
 font:700 16px system-ui,-apple-system,sans-serif;
 padding:0 3px;min-width:0;min-height:37px;
}
.name-keyboard button:focus-visible {outline:3px solid #4c94e6;outline-offset:1px}
.name-keyboard .nk-inner{max-width:630px;margin:auto;display:grid;gap:5px}
.name-keyboard .nk-head {display:flex;gap:6px;align-items:center;min-width:0;justify-content:space-between}
.name-keyboard .nk-context {font-size:12px;font-weight:700;max-width:45%;overflow:hidden;white-space:nowrap;text-overflow:ellipsis}
.name-keyboard .nk-preview {font-size:13px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;background:white;border-radius:6px;padding:5px 9px;min-width:0;flex:1;text-align:right;line-height:21px;box-shadow:inset 0 0 0 1px #c5d8ce}
.name-keyboard .nk-actions {display:grid;grid-template-columns:1.2fr 1.2fr 1fr 1fr;gap:5px}
.name-keyboard .nk-actions button {font-size:12px;min-height:34px;background:#eaf6f0;color:#14523b;border-color:#a9cdb9}
.name-keyboard .nk-actions .nk-save {background:#216a4a;color:white;border-color:#216a4a}
.name-keyboard .nk-row{display:flex;gap:3px;justify-content:center;min-width:0}
.name-keyboard .nk-row button{flex:1 1 0;max-width:58px;}
.name-keyboard .nk-row button.nk-wide{flex:1.5 1 0;max-width:90px;font-size:12px;background:#d4e0da}
.name-keyboard .nk-row button.nk-space{flex:5 1 0;max-width:240px;font-size:13px}
.name-keyboard .nk-status {font-size:11px;min-height:13px;color:#416558;text-align:center;line-height:1.1}
.name-keyboard .nk-status.error {color:#9d2020;font-weight:750}
@media(max-width:360px){.name-keyboard .nk-row button{font-size:14px}.name-keyboard .nk-actions button{font-size:11px}}


/* Avoid accidental page swipes while editing name rows; keep deliberate vertical scrolling. */
#streetPagesLive {overscroll-behavior-y:contain;-webkit-overflow-scrolling:touch;}
#streetPagesLive input, #streetPagesLive button, #streetPagesLive select {touch-action:manipulation;}
#streetPagesLive .street-page {overscroll-behavior-x:contain;}

.name-keyboard .nk-actions{grid-template-columns:1fr 1fr}
.name-keyboard .nk-bottom{display:grid;grid-template-columns:1fr 2fr 1fr;gap:5px}
.name-keyboard .nk-bottom button{font-size:12px;min-height:37px}
.name-keyboard .nk-bottom .nk-save{background:#216a4a;color:#fff;border-color:#216a4a}
.name-keyboard .nk-row button.nk-erase{flex:1.4 1 0;background:#d4e0da;font-size:21px;max-width:72px}
body.name-keyboard-open{padding-bottom:calc(270px + env(safe-area-inset-bottom))!important}

.street-page input[data-field="observations"].name-keyboard-selected{outline:3px solid #28836c!important;background:#f0fff8!important}

/* Expand long entries within the existing row, without changing stored values. */
#streetPagesLive .row-text-toggle{display:block;margin:2px 0 3px;padding:3px 7px;min-height:24px;border:0;border-radius:5px;background:#eaf4ee;color:#245b48;font:600 11px system-ui;touch-action:manipulation}
#streetPagesLive .row-text-toggle[hidden],#streetPagesLive .row-full-text[hidden]{display:none!important}
#streetPagesLive .row-full-text{white-space:pre-wrap;overflow-wrap:anywhere;word-break:normal;padding:10px 7px;border:1px solid #cbd8d1;border-radius:7px;background:#fff;color:#213e31;font:16px/1.45 system-ui;box-sizing:border-box;min-height:42px}
#streetPagesLive td.row-text-expanded>input{position:absolute!important;width:1px!important;height:1px!important;min-height:0!important;padding:0!important;border:0!important;opacity:0;pointer-events:none}
#streetPagesLive td.row-text-expanded{vertical-align:top}


/* Two lines automatically; the entire row shares the expanded height. */
#streetPagesLive tr.row-has-wrapped-text{height:var(--text-row-height,68px)!important}
#streetPagesLive tr.row-has-wrapped-text>td{position:relative;vertical-align:middle!important}
#streetPagesLive tr.row-has-wrapped-text>td>input,#streetPagesLive tr.row-has-wrapped-text .langwrap,#streetPagesLive tr.row-has-wrapped-text .langwrap select{height:var(--text-row-height,68px)!important;box-sizing:border-box!important}
#streetPagesLive .row-full-text{min-height:68px;padding:9px 6px 11px;font-size:16px;line-height:23px;display:-webkit-box;-webkit-box-orient:vertical;-webkit-line-clamp:2;max-height:68px;overflow:hidden}
#streetPagesLive td.row-text-show-all .row-full-text{-webkit-line-clamp:unset;max-height:none;padding-bottom:26px}
#streetPagesLive td.row-text-expanded>.row-text-toggle{position:absolute;right:4px;bottom:4px;z-index:2;margin:0;min-height:19px;padding:1px 5px;font-size:10px;box-shadow:0 0 3px #fff}
#streetPagesLive td.row-text-expanded>input{height:1px!important}
#streetPagesLive td.row-text-expanded:has(input.name-keyboard-selected) .row-full-text{outline:2px solid #28836c;background:#f0fff8}

/* Taller iPhone-style proportions while keeping the custom controls. */
.name-keyboard .nk-inner{gap:8px}
.name-keyboard .nk-row{gap:5px}
.name-keyboard .nk-row button{min-height:46px;border-radius:8px;font-size:20px}
.name-keyboard .nk-actions button{min-height:39px;font-size:13px}
.name-keyboard .nk-bottom{gap:6px}
.name-keyboard .nk-bottom button{min-height:46px;font-size:13px}
.name-keyboard .nk-preview{padding-top:8px;padding-bottom:8px}
body.name-keyboard-open{padding-bottom:calc(350px + env(safe-area-inset-bottom))!important}
@media(max-height:500px) and (orientation:landscape){.name-keyboard .nk-inner{gap:4px}.name-keyboard .nk-row button{min-height:32px;font-size:17px}.name-keyboard .nk-actions button,.name-keyboard .nk-bottom button{min-height:32px}.name-keyboard .nk-preview{padding-top:3px;padding-bottom:3px}body.name-keyboard-open{padding-bottom:calc(255px + env(safe-area-inset-bottom))!important}}

/* Reuse the removed preview space for larger keys. */
.name-keyboard .nk-row button{min-height:53px;font-size:22px}
.name-keyboard .nk-bottom button{min-height:51px;font-size:14px}
.name-keyboard .nk-actions button{min-height:43px;font-size:14px}
@media(max-height:500px) and (orientation:landscape){.name-keyboard .nk-row button{min-height:34px;font-size:18px}.name-keyboard .nk-bottom button,.name-keyboard .nk-actions button{min-height:34px}}

.name-keyboard button.nk-pressed{background:#bddbc9;box-shadow:inset 0 0 0 2px #43856b}

/* Visible insertion marker in the selected text box. */
#streetPagesLive .row-full-text.row-text-editing::after{content:"";display:inline-block;vertical-align:text-bottom;width:2px;height:1.05em;margin-left:1px;background:#245b48;animation:territory-caret 1s step-end infinite}
#streetPagesLive td.row-text-short .row-full-text{min-height:42px;max-height:none;-webkit-line-clamp:unset;display:block;padding:10px 6px}
#streetPagesLive .row-full-text{cursor:text}
@keyframes territory-caret{0%,100%{opacity:1}50%{opacity:0}}
@media(prefers-reduced-motion:reduce){#streetPagesLive .row-full-text.row-text-editing::after{animation:none}}

/* Compact column paste leaves room for a dedicated clear-text action. */
.name-keyboard .nk-actions{grid-template-columns:64px minmax(0,1fr) minmax(0,1.25fr);align-items:center;gap:5px}
.name-keyboard .nk-actions button[data-nk-action="paste-column"]{font-size:10px;min-height:31px;padding:0 4px;align-self:start}
.name-keyboard .nk-actions button[data-nk-action="clear-observation"]{font-size:12px;color:#a52b2b;background:#fff3f3;border-color:#d7b3b3;line-height:1.15;padding:4px}
.name-keyboard .nk-actions button[data-nk-action="date"]{font-size:12px;line-height:1.15;padding:4px}
@media(max-width:360px){.name-keyboard .nk-actions{grid-template-columns:55px minmax(0,1fr) minmax(0,1.15fr)}.name-keyboard .nk-actions button[data-nk-action="clear-observation"],.name-keyboard .nk-actions button[data-nk-action="date"]{font-size:11px}}

.name-keyboard .nk-actions button[data-nk-action="paste-column"]{display:flex;flex-direction:column;align-items:center;justify-content:center;line-height:1.1;gap:0}

/* Match the name-cell selection while the numeric keypad is active. */
#streetPagesLive input[data-field="house_number"].custom-keypad-active{
 outline:3px solid #28836c!important;outline-offset:0!important;
 background:#f0fff8!important;color:#122c23!important;
}
