/* Preview editor UI – only loaded for logged-in users (and on the login page). */
#kp-ui, #kp-pins, .kp-draft { --kp-ink: #1d2730; --kp-accent: #d9783f; --kp-line: #e4ddd0; font: 500 13px/1.4 'Montserrat', system-ui, sans-serif; }

/* ── Toolbar ── */
.kp-toolbar { position: fixed; z-index: 1000; left: 50%; bottom: 18px; transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 6px; max-width: calc(100vw - 24px); background: var(--kp-ink); color: #fff; border-radius: 100px; box-shadow: 0 12px 34px rgba(0,0,0,.28); }
.kp-modes { display: flex; background: rgba(255,255,255,.1); border-radius: 100px; padding: 3px; }
.kp-toolbar button { font: inherit; color: inherit; background: none; border: 0; cursor: pointer; border-radius: 100px; padding: 8px 14px; white-space: nowrap; }
.kp-modes button.is-on { background: #fff; color: var(--kp-ink); }
.kp-panel-btn { display: inline-flex; align-items: center; gap: 6px; }
.kp-panel-btn:hover, .kp-modes button:not(.is-on):hover { background: rgba(255,255,255,.12); }
.kp-count:not(:empty) { min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center; border-radius: 10px; background: var(--kp-accent); font-size: 11px; font-weight: 700; }
.kp-user { display: flex; gap: 10px; align-items: center; padding: 0 12px 0 4px; color: rgba(255,255,255,.7); white-space: nowrap; }
.kp-user a { color: #fff; text-decoration: underline; text-underline-offset: 2px; }

/* ── Toast ── */
.kp-toast { position: fixed; z-index: 1001; left: 50%; bottom: 84px; transform: translate(-50%, 10px); max-width: calc(100vw - 32px); padding: 10px 16px; border-radius: 12px; background: #fff; color: var(--kp-ink); box-shadow: 0 8px 26px rgba(0,0,0,.18); opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; text-align: center; }
.kp-toast.is-on { opacity: 1; transform: translate(-50%, 0); }
.kp-toast.is-error { background: #b3261e; color: #fff; }

/* ── Edit mode ── */
.kp-mode-edit [contenteditable="true"] { outline: 1.5px dashed transparent; outline-offset: 3px; cursor: text; transition: outline-color .15s; }
.kp-mode-edit [contenteditable="true"]:hover { outline-color: rgba(217,120,63,.7); }
.kp-mode-edit [contenteditable="true"]:focus { outline: 2px solid var(--accent, #d9783f); }
.kp-mode-edit .strip-track, .kp-mode-edit .badge { animation-play-state: paused; }
.kp-mode-edit .fade, .kp-mode-comment .fade { opacity: 1 !important; transform: none !important; }
.kp-imglayer { position: absolute; top: 0; left: 0; width: 0; height: 0; z-index: 900; }
.kp-imgbtn { position: absolute; white-space: nowrap; padding: 7px 12px; border: 0; border-radius: 100px; background: rgba(29,39,48,.88); color: #fff; font: inherit; font-size: 12px; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.25); }
.kp-imgbtn::before { content: "📷 "; }
.kp-imgbtn:hover { background: var(--kp-accent); }

/* ── Comment mode + pins ── */
.kp-mode-comment body, .kp-mode-comment a, .kp-mode-comment summary { cursor: crosshair; }
#kp-pins { position: absolute; top: 0; left: 0; width: 0; height: 0; z-index: 950; }
.kp-pin { position: absolute; width: 28px; height: 28px; margin: -28px 0 0 -2px; padding: 0; border: 2px solid #fff; border-radius: 50% 50% 50% 0; background: var(--kp-accent); color: #fff; font: 700 12px/1 'Montserrat', sans-serif; cursor: pointer; box-shadow: 0 4px 12px rgba(0,0,0,.3); transition: transform .15s; }
.kp-pin:hover { transform: scale(1.15); }
.kp-pin.is-resolved { background: #8a949c; }
.kp-pin.is-flash { animation: kp-flash .5s 3; }
@keyframes kp-flash { 50% { transform: scale(1.4); } }

.kp-draft { position: absolute; z-index: 1002; width: 280px; padding: 12px; background: #fff; border-radius: 14px; box-shadow: 0 14px 40px rgba(0,0,0,.25); }
.kp-draft textarea { width: 100%; resize: vertical; padding: 10px; border: 1px solid var(--kp-line); border-radius: 10px; font: inherit; color: var(--kp-ink); }
.kp-draft-btns { display: flex; justify-content: flex-end; gap: 8px; margin-top: 8px; }
.kp-draft button, .kp-actions button { font: inherit; font-size: 12px; padding: 7px 12px; border-radius: 100px; border: 1px solid var(--kp-line); background: #fff; color: var(--kp-ink); cursor: pointer; }
.kp-draft button.is-primary { background: var(--kp-ink); border-color: var(--kp-ink); color: #fff; }

/* ── Side panel ── */
.kp-panel { position: fixed; z-index: 999; top: 0; right: 0; bottom: 0; width: 360px; max-width: 100vw; display: flex; flex-direction: column; background: #fff; color: var(--kp-ink); box-shadow: -12px 0 40px rgba(0,0,0,.14); transform: translateX(105%); transition: transform .25s ease; }
.kp-panel.is-open { transform: none; }
.kp-panel header { display: flex; justify-content: space-between; align-items: center; padding: 14px 14px 10px; border-bottom: 1px solid var(--kp-line); }
.kp-tabs { display: flex; gap: 4px; }
.kp-tabs button { font: inherit; padding: 8px 12px; border: 0; border-radius: 100px; background: none; color: var(--kp-ink); cursor: pointer; }
.kp-tabs button.is-on { background: #f3eee5; font-weight: 600; }
.kp-x { font-size: 24px; line-height: 1; width: 36px; height: 36px; border: 0; background: none; cursor: pointer; color: var(--kp-ink); }
.kp-panel-body { flex: 1; overflow-y: auto; padding: 12px 14px 100px; }
.kp-check { display: flex; gap: 6px; align-items: center; margin-bottom: 10px; color: #5c6670; font-size: 12px; }
.kp-list { display: grid; gap: 10px; }
.kp-panel [hidden] { display: none !important; }
.kp-item { border: 1px solid var(--kp-line); border-radius: 14px; padding: 12px; transition: background .3s; }
.kp-item.is-resolved { opacity: .6; }
.kp-item.is-flash { background: #fbeee5; }
.kp-meta { display: flex; justify-content: space-between; gap: 8px; font-size: 11px; color: #5c6670; margin-bottom: 6px; }
.kp-meta b { color: var(--kp-ink); font-size: 12px; }
.kp-text { margin: 0 0 10px; font-size: 13px; white-space: pre-wrap; cursor: pointer; }
.kp-diff { display: grid; gap: 4px; cursor: default; }
.kp-diff del { color: #a0525a; } .kp-diff ins { color: #2f6b45; text-decoration: none; }
.kp-note { margin: -4px 0 10px; font-size: 11px; color: #b3261e; }
.kp-thumb { width: 100%; max-height: 140px; object-fit: cover; border-radius: 10px; margin-bottom: 10px; }
.kp-actions { display: flex; gap: 6px; }
.kp-empty { color: #5c6670; font-size: 13px; }

@media (min-width: 1100px) { .kp-panel-open body { margin-right: 360px; } }

@media (max-width: 640px) {
  .kp-toolbar { left: 12px; right: 12px; transform: none; bottom: 12px; border-radius: 22px; flex-wrap: wrap; justify-content: center; gap: 4px; }
  .kp-toolbar button { padding: 8px 10px; }
  .kp-user { padding: 0 8px 0 2px; }
  .kp-toast { bottom: 128px; }
  .kp-panel { width: 100vw; top: 20vh; border-radius: 20px 20px 0 0; transform: translateY(105%); }
}

/* ── Login page ── */
.kp-login-body { min-height: 100vh; display: grid; place-items: center; padding: 24px 16px; background: #f3eee5; }
.kp-login { width: min(420px, 100%); background: #fff; border-radius: 28px; padding: 36px 32px; box-shadow: 0 20px 60px rgba(29,39,48,.1); }
.kp-login img { height: 80px; width: auto; margin: 0 auto 18px; }
.kp-login h1 { font-size: 2rem; text-align: center; margin-bottom: 8px; }
.kp-login > p { text-align: center; font-size: .88rem; }
.kp-login label { display: grid; gap: 6px; margin-top: 14px; font-size: .82rem; font-weight: 600; color: #1d2730; }
.kp-login label span { font-weight: 400; color: #5c6670; }
.kp-login input { height: 46px; padding: 0 14px; border: 1px solid #e4ddd0; border-radius: 12px; font: inherit; font-size: .95rem; }
.kp-login input:focus { outline: 2px solid #d9783f; border-color: transparent; }
.kp-login-error { color: #b3261e; min-height: 1.4em; margin: 12px 0 4px; font-size: .85rem; }
.kp-login button { width: 100%; border: 0; cursor: pointer; }
