/* DBDON LPO — application UI */
:root {
  --orange: #F7941D;
  --orange-d: #d97a0b;
  --orange-l: #fff3e4;
  --brown: #3E2415;
  --brown-2: #5a3a26;
  --cream: #faf6f1;
  --line: #eadfd3;
  --text: #2b1b10;
  --muted: #8a7766;
  --green: #1b7a3a;
  --green-l: #e7f5ec;
  --red: #c62828;
  --red-l: #fdecea;
  --blue: #1d4fbf;
  --blue-l: #e9f0ff;
  --amber-l: #fff8e1;
  --radius: 12px;
  --shadow: 0 1px 2px rgba(62,36,21,.06), 0 6px 22px rgba(62,36,21,.07);
}
* { box-sizing: border-box; }
html, body { margin: 0; }
body { font-family: Verdana, Geneva, Tahoma, sans-serif; font-size: 13px; color: var(--text); background: var(--cream); line-height: 1.5; }
button, input, select, textarea { font-family: Verdana, Geneva, Tahoma, sans-serif; font-size: 13px; color: var(--text); }
a { color: var(--brown-2); }
h1, h2, h3, h4 { color: var(--brown); line-height: 1.25; }
.muted { color: var(--muted); }
.nowrap { white-space: nowrap; }
.mobile-only { display: none !important; }
@media (max-width: 900px) { .mobile-only { display: inline-flex !important; } }
.tiny { font-size: 11px; }
.container { max-width: 1240px; margin: 0 auto; padding: 24px 20px 80px; }

/* ---------- Top bar ---------- */
.topbar { position: sticky; top: 0; z-index: 50; display: flex; align-items: center; gap: 18px; padding: 0 20px; height: 62px; background: var(--brown); color: #fff; box-shadow: 0 2px 10px rgba(0,0,0,.15); }
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; color: #fff; font-size: 15px; letter-spacing: .3px; white-space: nowrap; }
.brand img { width: 40px; height: 40px; background: #fff; border-radius: 50%; padding: 2px; }
.brand b { color: var(--orange); }
.mainnav { display: flex; gap: 4px; flex: 1; overflow-x: auto; scrollbar-width: none; }
.mainnav a { display: flex; align-items: center; gap: 7px; padding: 8px 12px; color: #e9dccf; text-decoration: none; border-radius: 8px; white-space: nowrap; font-size: 12.5px; transition: background .15s, color .15s; }
.mainnav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.mainnav a.active { background: var(--orange); color: #fff; }
.usermenu { display: flex; align-items: center; gap: 10px; }
.avatar { width: 34px; height: 34px; border-radius: 50%; background: var(--orange); color: #fff; display: grid; place-items: center; text-decoration: none; font-weight: bold; }
.logout { color: #e9dccf; font-size: 12px; text-decoration: none; }
.logout:hover { color: #fff; }
.nav-toggle { display: none; background: none; border: 0; color: #fff; font-size: 22px; cursor: pointer; }

/* ---------- Buttons & forms ---------- */
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 7px; padding: 9px 15px; border-radius: 9px; border: 1px solid var(--line); background: #fff; color: var(--brown); cursor: pointer; text-decoration: none; font-size: 12.5px; white-space: nowrap; transition: transform .08s, background .15s, border-color .15s, box-shadow .15s; }
.btn:hover { border-color: #d8c5b2; background: #fffaf4; }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--orange); border-color: var(--orange); color: #fff; font-weight: bold; }
.btn-primary:hover { background: var(--orange-d); border-color: var(--orange-d); }
.btn-dark { background: var(--brown); border-color: var(--brown); color: #fff; }
.btn-dark:hover { background: var(--brown-2); }
.btn-danger { color: var(--red); }
.btn-danger:hover { background: var(--red-l); border-color: #f3c3bf; }
.btn-ghost { border-color: transparent; background: transparent; }
.btn-sm { padding: 6px 10px; font-size: 11.5px; border-radius: 7px; }
.btn-block { width: 100%; }
.icon-btn { width: 30px; height: 30px; display: inline-grid; place-items: center; border-radius: 8px; border: 1px solid transparent; background: transparent; color: var(--muted); cursor: pointer; font-size: 14px; }
.icon-btn:hover { background: #f4ebe1; color: var(--brown); }
.icon-btn.danger:hover { background: var(--red-l); color: var(--red); }

.field { display: block; margin-bottom: 12px; }
.field > span { display: block; font-size: 11px; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .4px; }
input:not([type]), input[type=text], input[type=email], input[type=date], input[type=number], input[type=search], input[type=password], select, textarea {
  width: 100%; padding: 9px 11px; border: 1px solid var(--line); border-radius: 8px; background: #fff; outline: none; transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(247,148,29,.15); }
textarea { resize: vertical; min-height: 70px; }
.hint { font-size: 11px; color: var(--muted); margin: -6px 0 12px; }
.hint.warn { color: #a65a00; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }

.alert { padding: 10px 14px; border-radius: 9px; margin-bottom: 14px; font-size: 12.5px; }
.alert-error { background: var(--red-l); color: var(--red); border: 1px solid #f5c6c2; }
.alert-ok { background: var(--green-l); color: var(--green); border: 1px solid #bfe3cb; }
.alert-warn { background: var(--amber-l); color: #8a5a00; border: 1px solid #f3dc9a; }
.alert-info { background: var(--blue-l); color: var(--blue); border: 1px solid #c9d8fb; }

/* ---------- Cards / tables ---------- */
.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); box-shadow: var(--shadow); padding: 18px; }
.page-title { display: flex; align-items: center; justify-content: space-between; gap: 14px; margin-bottom: 20px; flex-wrap: wrap; }
.page-title h1 { margin: 0; font-size: 22px; }
.page-title p { margin: 4px 0 0; color: var(--muted); }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 14px; margin-bottom: 20px; }
.stat { background: #fff; border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: var(--shadow); position: relative; overflow: hidden; text-decoration: none; color: inherit; transition: transform .15s; }
.stat:hover { transform: translateY(-2px); }
.stat::after { content: ""; position: absolute; right: -18px; top: -18px; width: 70px; height: 70px; border-radius: 50%; background: var(--orange-l); }
.stat .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .5px; }
.stat .v { font-size: 24px; font-weight: bold; color: var(--brown); margin-top: 4px; position: relative; z-index: 1; }
.stat .s { font-size: 11px; color: var(--muted); }

.toolbar { display: flex; gap: 10px; align-items: center; margin-bottom: 14px; flex-wrap: wrap; }
.toolbar input[type=search] { max-width: 320px; }
.tabs { display: flex; gap: 4px; background: #f1e8de; padding: 4px; border-radius: 10px; flex-wrap: wrap; }
.tabs a { padding: 6px 12px; border-radius: 7px; text-decoration: none; color: var(--brown-2); font-size: 12px; }
.tabs a.active { background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.08); color: var(--brown); font-weight: bold; }

.table-wrap { overflow-x: auto; }
table.list { width: 100%; border-collapse: collapse; }
table.list th { text-align: left; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .4px; font-weight: normal; padding: 10px 12px; border-bottom: 1px solid var(--line); white-space: nowrap; }
table.list td { padding: 12px; border-bottom: 1px solid #f3ebe2; vertical-align: middle; }
table.list tr:hover td { background: #fffaf4; }
table.list .num { text-align: right; white-space: nowrap; }
table.list a.lpo-link { font-weight: bold; color: var(--brown); text-decoration: none; }
table.list a.lpo-link:hover { color: var(--orange-d); }
.actions { display: flex; gap: 4px; justify-content: flex-end; }
.empty { text-align: center; padding: 50px 20px; color: var(--muted); }
.empty img { width: 90px; opacity: .5; }

.badge { display: inline-block; padding: 3px 9px; border-radius: 20px; font-size: 10.5px; font-weight: bold; white-space: nowrap; }
.badge.draft { background: #efe9e3; color: #6d5a49; }
.badge.pending { background: var(--amber-l); color: #9a6a00; }
.badge.approved { background: var(--green-l); color: var(--green); }
.badge.sent { background: var(--blue-l); color: var(--blue); }
.badge.cancelled { background: var(--red-l); color: var(--red); }
.badge.invited { background: var(--amber-l); color: #9a6a00; }
.badge.signed { background: var(--green-l); color: var(--green); }
.badge.declined { background: var(--red-l); color: var(--red); }
.badge.ext { background: #fff0e0; color: #a65a00; }

/* ---------- Modal ---------- */
.modal-back { position: fixed; inset: 0; background: rgba(43,27,16,.45); display: flex; align-items: center; justify-content: center; z-index: 400; padding: 16px; opacity: 0; transition: opacity .2s; backdrop-filter: blur(2px); }
.modal-back.show { opacity: 1; }
.modal { background: #fff; border-radius: 14px; width: 100%; max-width: 560px; max-height: calc(100vh - 32px); overflow: auto; box-shadow: 0 20px 60px rgba(0,0,0,.25); transform: translateY(14px) scale(.98); transition: transform .22s; }
.modal-back.show .modal { transform: none; }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 20px; border-bottom: 1px solid var(--line); }
.modal-head h3 { margin: 0; font-size: 16px; }
.modal-body { padding: 18px 20px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 14px 20px; border-top: 1px solid var(--line); background: #fdfaf6; border-radius: 0 0 14px 14px; flex-wrap: wrap; }

/* Signature pad */
.sig-tabs { display: flex; gap: 6px; margin-bottom: 12px; }
.sig-tabs button { flex: 1; padding: 9px; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; }
.sig-tabs button.active { background: var(--brown); color: #fff; border-color: var(--brown); }
.pad-wrap { position: relative; background: #fff; border: 2px dashed #d9c7b4; border-radius: 10px; touch-action: none; }
.pad-wrap canvas { display: block; width: 100%; height: 220px; cursor: crosshair; border-radius: 8px; }
.pad-line { position: absolute; left: 7%; right: 7%; bottom: 52px; border-bottom: 1px solid #cdbba8; pointer-events: none; }
.pad-x { position: absolute; left: 7%; bottom: 56px; color: #c0ab95; font-size: 18px; pointer-events: none; }
.pad-hint { position: absolute; inset: 0; display: grid; place-items: center; color: #c0ab95; pointer-events: none; font-size: 14px; transition: opacity .2s; }
.pad-tools { display: flex; gap: 8px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.pad-tools .swatch { width: 22px; height: 22px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--line); cursor: pointer; }
.pad-tools .swatch.active { box-shadow: 0 0 0 2px var(--orange); }
.upload-drop { border: 2px dashed #d9c7b4; border-radius: 10px; padding: 26px; text-align: center; cursor: pointer; background: #fffcf8; transition: background .15s, border-color .15s; }
.upload-drop:hover, .upload-drop.drag { background: var(--orange-l); border-color: var(--orange); }
.upload-preview { margin-top: 12px; text-align: center; background: repeating-conic-gradient(#f3f3f3 0 25%, #fff 0 50%) 0 0/16px 16px; border-radius: 8px; padding: 10px; display: none; }
.upload-preview img { max-width: 100%; max-height: 140px; }
.check { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 12.5px; }

/* ---------- Toasts ---------- */
#toasts { position: fixed; left: 50%; bottom: 22px; transform: translateX(-50%); z-index: 600; display: flex; flex-direction: column; gap: 8px; align-items: center; pointer-events: none; }
.toast { background: var(--brown); color: #fff; padding: 10px 16px; border-radius: 10px; box-shadow: 0 8px 26px rgba(0,0,0,.2); font-size: 12.5px; animation: toastIn .25s ease-out; pointer-events: auto; max-width: 90vw; }
.toast.err { background: var(--red); }
.toast.ok { background: var(--green); }
@keyframes toastIn { from { opacity: 0; transform: translateY(10px); } }

/* ---------- Login ---------- */
.login-page { background: radial-gradient(circle at 15% 20%, #fde3c2 0, transparent 40%), radial-gradient(circle at 85% 80%, #f1d9c8 0, transparent 45%), var(--cream); min-height: 100vh; }
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { display: grid; grid-template-columns: 1fr 1fr; background: #fff; border-radius: 18px; overflow: hidden; box-shadow: 0 30px 80px rgba(62,36,21,.18); max-width: 880px; width: 100%; }
.login-art { background: var(--brown); color: #f3e6d8; padding: 40px; position: relative; overflow: hidden; }
.login-art::before { content: ""; position: absolute; width: 320px; height: 320px; border-radius: 50%; border: 40px solid rgba(247,148,29,.12); right: -120px; bottom: -120px; }
.login-art img { width: 110px; background: #fff; border-radius: 50%; padding: 4px; }
.login-art h1 { color: var(--orange); margin: 18px 0 8px; font-size: 26px; }
.login-points { padding: 0; list-style: none; margin: 22px 0 0; }
.login-points li { padding: 6px 0 6px 26px; position: relative; }
.login-points li::before { content: "✓"; position: absolute; left: 0; color: var(--orange); font-weight: bold; }
.login-form { padding: 44px 40px; }
.login-form h2 { margin: 0 0 4px; }
.login-form .muted { margin: 0 0 22px; }

/* ---------- Editor ---------- */
.editor { display: grid; grid-template-columns: 420px 1fr; height: calc(100vh - 62px); }
.ed-side { background: #fff; border-right: 1px solid var(--line); overflow-y: auto; overflow-x: hidden; display: flex; flex-direction: column; min-width: 0; }
.ed-side input, .ed-side select, .ed-side textarea { min-width: 0; }
.ed-top { position: sticky; top: 0; z-index: 5; background: #fff; border-bottom: 1px solid var(--line); padding: 12px 14px; }
.ed-top .row1 { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.ed-top h2 { margin: 0; font-size: 15px; }
.save-state { font-size: 11px; color: var(--muted); display: flex; align-items: center; gap: 6px; }
.save-state .dot { width: 7px; height: 7px; border-radius: 50%; background: #bbb; }
.save-state.saved .dot { background: var(--green); }
.save-state.saving .dot { background: var(--orange); animation: blink .8s infinite; }
.save-state.error .dot { background: var(--red); }
@keyframes blink { 50% { opacity: .2; } }
.ed-actions { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }

.sec { border-bottom: 1px solid #f1e8de; }
.sec-head { display: flex; align-items: center; gap: 10px; padding: 13px 14px; cursor: pointer; user-select: none; }
.sec-head:hover { background: #fffaf4; }
.sec-head .num { width: 24px; height: 24px; border-radius: 50%; background: var(--orange-l); color: var(--orange-d); display: grid; place-items: center; font-size: 11px; font-weight: bold; flex: none; }
.sec-head h3 { margin: 0; font-size: 13px; flex: 1; }
.sec-head .chev { transition: transform .2s; color: var(--muted); }
.sec.open .sec-head .chev { transform: rotate(90deg); }
.sec-body { display: none; padding: 4px 14px 16px; }
.sec.open .sec-body { display: block; animation: fadeIn .2s; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-4px); } }

.tpl-pick { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; margin-bottom: 12px; }
.tpl-card { border: 2px solid var(--line); border-radius: 10px; padding: 6px; cursor: pointer; text-align: center; font-size: 11px; background: #fff; transition: border-color .15s, transform .15s; }
.tpl-card:hover { transform: translateY(-2px); }
.tpl-card.active { border-color: var(--orange); box-shadow: 0 0 0 3px rgba(247,148,29,.15); }
.tpl-thumb { height: 74px; border-radius: 6px; background: #fff; border: 1px solid #eee; margin-bottom: 5px; position: relative; overflow: hidden; }
.tpl-thumb i { position: absolute; display: block; border-radius: 2px; }

.kv { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.4fr) 28px; gap: 6px; align-items: center; margin-bottom: 6px; }
.kv input { padding: 7px 9px; font-size: 12px; }
.kv input.lbl { background: #fbf7f2; color: var(--brown-2); font-size: 11.5px; }
.kv.fixed input.lbl { background: transparent; border-color: transparent; padding-left: 0; }
.add-field { display: flex; gap: 6px; margin-top: 8px; }
.add-field select { flex: 1; font-size: 12px; padding: 7px; }

.item-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; background: #fffdfb; position: relative; }
.item-card .ihead { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.item-card .ihead b { font-size: 11px; color: var(--muted); flex: 1; }
.item-card textarea { min-height: 44px; font-size: 12px; padding: 7px 9px; }
.item-card .grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(70px, 1fr)); gap: 6px; margin-top: 6px; }
.item-card .grid label { font-size: 10px; color: var(--muted); }
.item-card .grid input { padding: 6px 7px; font-size: 12px; }
.item-card .amt { text-align: right; font-weight: bold; color: var(--brown); margin-top: 6px; font-size: 12px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
.chip { display: inline-flex; align-items: center; gap: 5px; padding: 5px 10px; border: 1px solid var(--line); border-radius: 20px; cursor: pointer; font-size: 11.5px; background: #fff; user-select: none; }
.chip input { margin: 0; accent-color: var(--orange); }
.chip.on { background: var(--orange-l); border-color: #f6cf9f; }
.totals-box { background: #fbf6f0; border-radius: 10px; padding: 10px 12px; margin-top: 10px; font-size: 12px; }
.totals-box div { display: flex; justify-content: space-between; padding: 2px 0; }
.totals-box .grand { font-weight: bold; font-size: 14px; color: var(--brown); border-top: 1px solid var(--line); margin-top: 4px; padding-top: 6px; }

.list-edit .li { display: flex; gap: 6px; align-items: flex-start; margin-bottom: 6px; }
.list-edit .li span.n { width: 20px; padding-top: 8px; color: var(--muted); font-size: 11px; text-align: right; flex: none; }
.list-edit textarea { min-height: 40px; font-size: 12px; padding: 7px 9px; }

.sig-card { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; background: #fffdfb; }
.sig-card .shead { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; }
.sig-card .shead input { font-weight: bold; }
.sig-card .sbtns { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.sig-state { font-size: 11px; margin-top: 6px; }

.toggle { position: relative; display: inline-block; width: 42px; height: 24px; flex: none; }
.toggle input { opacity: 0; width: 0; height: 0; }
.toggle span { position: absolute; inset: 0; background: #d9cbbd; border-radius: 24px; transition: background .2s; cursor: pointer; }
.toggle span::before { content: ""; position: absolute; width: 18px; height: 18px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: transform .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.toggle input:checked + span { background: var(--orange); }
.toggle input:checked + span::before { transform: translateX(18px); }
.trow { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 7px 0; }
.color-pick { display: flex; gap: 8px; }
.color-pick button { flex: 1; padding: 9px; border-radius: 8px; border: 2px solid var(--line); background: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 6px; }
.color-pick button i { width: 14px; height: 14px; border-radius: 50%; display: inline-block; }
.color-pick button.active { border-color: var(--brown); }
input[type=range] { width: 100%; accent-color: var(--orange); }

.ed-stage { overflow: auto; background: #e9e1d8; background-image: radial-gradient(#d9cdbf 1px, transparent 1px); background-size: 18px 18px; position: relative; }
.stage-bar { position: sticky; top: 0; z-index: 4; display: flex; align-items: center; justify-content: center; gap: 8px; padding: 8px; background: rgba(233,225,216,.9); backdrop-filter: blur(4px); }
.stage-bar .zoom { font-size: 11px; color: var(--brown-2); min-width: 44px; text-align: center; }
.stage-inner { padding: 10px 30px 60px; display: flex; justify-content: center; }
.page-fit { position: relative; flex: none; }
.page-scaler { transform-origin: top left; }

.drag-tip { position: fixed; z-index: 300; background: var(--brown); color: #fff; font-size: 11px; padding: 5px 9px; border-radius: 6px; pointer-events: none; }

/* ---------- Activity ---------- */
.timeline { list-style: none; padding: 0; margin: 0; }
.timeline li { position: relative; padding: 0 0 14px 22px; font-size: 12px; }
.timeline li::before { content: ""; position: absolute; left: 5px; top: 5px; width: 9px; height: 9px; border-radius: 50%; background: var(--orange); }
.timeline li::after { content: ""; position: absolute; left: 9px; top: 16px; bottom: 0; width: 1px; background: var(--line); }
.timeline li:last-child::after { display: none; }
.timeline .when { font-size: 10.5px; color: var(--muted); }

/* ---------- Sign page / view page ---------- */
.public-bar { position: sticky; top: 0; z-index: 50; background: var(--brown); color: #fff; padding: 10px 18px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap; }
.public-bar img { width: 38px; height: 38px; background: #fff; border-radius: 50%; padding: 2px; }
.public-bar .t { flex: 1; min-width: 200px; }
.public-bar .t b { color: var(--orange); }
.public-bar .t small { display: block; color: #d9c8b6; font-size: 11px; }
.view-stage { padding: 26px 16px 80px; display: flex; justify-content: center; overflow-x: auto; }
.sign-banner { max-width: 820px; margin: 18px auto 0; padding: 0 16px; }
.done-card { max-width: 520px; margin: 60px auto; text-align: center; }
.done-card .big { font-size: 54px; }

.sign-arrow { position: absolute; z-index: 60; pointer-events: none; width: 64px; height: 84px; animation: arrowBounce 1s cubic-bezier(.45,0,.55,1) infinite; filter: drop-shadow(0 4px 8px rgba(0,0,0,.25)); transition: left .6s ease, top .6s ease; }
.sign-arrow svg { display: block; }
.sign-arrow .lbl { position: absolute; left: 50%; transform: translateX(-50%); top: -30px; background: var(--brown); color: #fff; font-weight: bold; font-size: 12px; padding: 5px 12px; border-radius: 20px; white-space: nowrap; }
@keyframes arrowBounce { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(14px); } }

/* ---------- Chat assistant ---------- */
.chat-tab { position: fixed; right: 0; bottom: 110px; z-index: 210; width: 26px; height: 58px; background: var(--brown); color: var(--orange); border-radius: 12px 0 0 12px; border: 0; cursor: pointer; display: grid; place-items: center; box-shadow: -3px 4px 14px rgba(0,0,0,.2); transition: width .2s, background .2s; font-size: 16px; }
.chat-tab:hover { width: 32px; background: var(--brown-2); }
.chat-tab.hide { transform: translateX(40px); }
.chat-tab { transition: transform .35s cubic-bezier(.2,.9,.3,1.2), width .2s; }
.chat-fab { position: fixed; right: 22px; bottom: 96px; z-index: 211; width: 62px; height: 62px; border-radius: 50%; border: 0; cursor: pointer; background: linear-gradient(135deg, var(--orange), #f26b1d); color: #fff; box-shadow: 0 10px 28px rgba(242,107,29,.45); transform: translateX(120px) scale(.6); opacity: 0; transition: transform .45s cubic-bezier(.2,1.3,.3,1), opacity .3s; display: grid; place-items: center; }
.chat-fab.in { transform: none; opacity: 1; }
.chat-fab svg { width: 30px; height: 30px; }
.chat-fab .pulse { position: absolute; inset: -6px; border-radius: 50%; border: 2px solid var(--orange); animation: ring 2.2s infinite; }
@keyframes ring { 0% { transform: scale(.85); opacity: .9; } 100% { transform: scale(1.35); opacity: 0; } }
.chat-fab .tuck { position: absolute; top: -4px; left: -4px; width: 20px; height: 20px; border-radius: 50%; background: var(--brown); color: #fff; font-size: 11px; display: grid; place-items: center; border: 2px solid #fff; opacity: 0; transition: opacity .2s; }
.chat-fab:hover .tuck { opacity: 1; }
.chat-panel { position: fixed; right: 22px; bottom: 96px; z-index: 212; width: 370px; max-width: calc(100vw - 24px); height: 540px; max-height: calc(100vh - 120px); background: #fff; border-radius: 18px; box-shadow: 0 24px 70px rgba(43,27,16,.3); display: flex; flex-direction: column; overflow: hidden; transform-origin: bottom right; transform: scale(.4) translateY(40px); opacity: 0; pointer-events: none; transition: transform .35s cubic-bezier(.2,1.2,.3,1), opacity .25s; }
.chat-panel.open { transform: none; opacity: 1; pointer-events: auto; }
.chat-head { background: var(--brown); color: #fff; padding: 14px 16px; display: flex; align-items: center; gap: 10px; }
.chat-head .av { width: 38px; height: 38px; border-radius: 50%; background: #fff; padding: 2px; position: relative; }
.chat-head .av img { width: 100%; height: 100%; border-radius: 50%; }
.chat-head .av::after { content: ""; position: absolute; right: 0; bottom: 0; width: 10px; height: 10px; border-radius: 50%; background: #3ccf6e; border: 2px solid var(--brown); }
.chat-head .nm { flex: 1; }
.chat-head .nm b { display: block; font-size: 13.5px; }
.chat-head .nm small { color: #d9c8b6; font-size: 11px; }
.chat-head button { background: none; border: 0; color: #fff; cursor: pointer; font-size: 18px; opacity: .8; }
.chat-body { flex: 1; overflow-y: auto; padding: 14px; background: #fbf7f2; scroll-behavior: smooth; }
.msg { display: flex; margin-bottom: 10px; animation: msgIn .3s ease-out; }
@keyframes msgIn { from { opacity: 0; transform: translateY(8px); } }
.msg .bub { max-width: 86%; padding: 9px 13px; border-radius: 14px; font-size: 12.5px; line-height: 1.5; }
.msg.bot .bub { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg.me { justify-content: flex-end; }
.msg.me .bub { background: var(--orange); color: #fff; border-bottom-right-radius: 4px; }
.typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.typing i { width: 7px; height: 7px; border-radius: 50%; background: #c9b39d; animation: typing 1s infinite; }
.typing i:nth-child(2) { animation-delay: .15s; }
.typing i:nth-child(3) { animation-delay: .3s; }
@keyframes typing { 0%, 60%, 100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-5px); opacity: 1; } }
.qr { display: flex; flex-wrap: wrap; gap: 6px; margin: 2px 0 12px; animation: msgIn .3s ease-out; }
.qr button { background: #fff; border: 1px solid #f2c48c; color: var(--orange-d); padding: 6px 11px; border-radius: 16px; cursor: pointer; font-size: 11.5px; transition: background .15s; }
.qr button:hover { background: var(--orange-l); }
.chat-list { margin-top: 8px; display: flex; flex-direction: column; gap: 6px; }
.chat-list a { display: block; padding: 8px 10px; border: 1px solid var(--line); border-radius: 9px; text-decoration: none; color: var(--text); background: #fffdfb; transition: border-color .15s; }
.chat-list a:hover { border-color: var(--orange); }
.chat-list a b { color: var(--brown); font-size: 12px; }
.chat-list a small { display: block; color: var(--muted); font-size: 10.5px; }
.chat-foot { border-top: 1px solid var(--line); padding: 10px; display: flex; gap: 8px; background: #fff; }
.chat-foot input { flex: 1; border-radius: 20px; padding: 9px 14px; }
.chat-foot button { width: 38px; height: 38px; border-radius: 50%; border: 0; background: var(--orange); color: #fff; cursor: pointer; flex: none; }
.chat-menu-btn { background: #f4ebe1 !important; color: var(--brown) !important; }

/* ---------- Tour ---------- */
.tour-mask { position: fixed; z-index: 500; border-radius: 10px; box-shadow: 0 0 0 9999px rgba(43,27,16,.6); transition: all .35s cubic-bezier(.3,.9,.3,1); pointer-events: none; }
.tour-mask::after { content: ""; position: absolute; inset: -4px; border: 2px solid var(--orange); border-radius: 12px; animation: ring2 1.6s infinite; }
@keyframes ring2 { 50% { inset: -8px; opacity: .4; } }
.tour-block { position: fixed; inset: 0; z-index: 499; }
.tour-pop { position: fixed; z-index: 501; width: 320px; max-width: calc(100vw - 24px); background: #fff; border-radius: 14px; box-shadow: 0 20px 60px rgba(0,0,0,.3); padding: 18px; transition: top .35s, left .35s, opacity .2s; }
.tour-pop h4 { margin: 0 0 6px; font-size: 14.5px; }
.tour-pop p { margin: 0 0 14px; font-size: 12.5px; color: #5a4636; }
.tour-pop .tfoot { display: flex; align-items: center; gap: 8px; }
.tour-pop .dots { flex: 1; display: flex; gap: 4px; }
.tour-pop .dots i { width: 7px; height: 7px; border-radius: 50%; background: #e3d6c8; }
.tour-pop .dots i.on { background: var(--orange); width: 18px; border-radius: 4px; }
.tour-pop .x { position: absolute; top: 10px; right: 12px; background: none; border: 0; font-size: 18px; color: var(--muted); cursor: pointer; }
.tour-pop .skip { background: none; border: 0; color: var(--muted); cursor: pointer; font-size: 11.5px; text-decoration: underline; }
.tour-welcome { text-align: center; }
.tour-welcome img { width: 74px; }

/* ---------- Responsive ---------- */
@media (max-width: 1100px) {
  .editor { grid-template-columns: 360px 1fr; }
}
@media (max-width: 900px) {
  .stats { grid-template-columns: repeat(2, 1fr); }
  .nav-toggle { display: block; margin-left: auto; }
  .mainnav { position: fixed; top: 62px; left: 0; right: 0; background: var(--brown); flex-direction: column; padding: 10px; display: none; }
  body.nav-open .mainnav { display: flex; }
  .usermenu .logout { display: none; }
  .editor { grid-template-columns: 1fr; height: auto; }
  .ed-side { max-height: none; border-right: 0; }
  .ed-stage { min-height: 80vh; }
  .login-card { grid-template-columns: 1fr; }
  .login-art { padding: 28px; }
  .login-points { display: none; }
}
@media (max-width: 560px) {
  .container { padding: 16px 12px 80px; }
  .stats { grid-template-columns: 1fr 1fr; gap: 8px; }
  .stat .v { font-size: 19px; }
  .login-form { padding: 28px 22px; }
  .brand span { display: none; }
}

/* ---------- Print: hide all app chrome ---------- */
@media print {
  .no-print, .topbar, .ed-side, .stage-bar, .chat-tab, .chat-fab, .chat-panel, #toasts, .public-bar, .sign-banner, .sign-arrow, .tour-mask, .tour-pop, .tour-block { display: none !important; }
  body, .ed-stage, .view-stage { background: #fff !important; }
  .editor { display: block; height: auto; }
  .ed-stage, .view-stage, .stage-inner { padding: 0 !important; overflow: visible !important; display: block !important; }
  .page-scaler, .page-fit { transform: none !important; width: auto !important; height: auto !important; }
  main.container { padding: 0; max-width: none; }
}
