/* papier – Oberfläche im fileee-Stil, Moonquito-Nachtpalette */
@font-face { font-family: "Fraunces"; src: url("/moonquito-theme/fraunces-display.woff2") format("woff2"); font-weight: 300 500; font-display: swap; }
@font-face { font-family: "Manrope"; src: url("/moonquito-theme/manrope.woff2") format("woff2"); font-weight: 400 700; font-display: swap; }

:root {
  --night: #141A2E; --night-2: #1A2140; --night-3: #10152A; --indigo: #2B3160;
  --amber: #F2B66D; --amber-2: #F6C687; --cream: #F4EDE0; --sage: #8FA88A; --rose: #E8A595;
  --text-2: rgba(244,237,224,0.72); --text-3: rgba(244,237,224,0.6); --line: rgba(244,237,224,0.12);
  --display: "Fraunces", Georgia, serif; --body: "Manrope", system-ui, -apple-system, sans-serif;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--night); color: var(--cream); font-family: var(--body); -webkit-text-size-adjust: 100%; }
a { color: var(--amber); text-decoration: none; }
button { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--amber); outline-offset: 2px; border-radius: 8px; }
::selection { background: var(--amber); color: var(--night); }
[hidden] { display: none !important; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Kopf */
.top { display: flex; flex-wrap: wrap; align-items: center; gap: 16px 24px; padding: 16px clamp(16px, 4vw, 40px); background: var(--night-3); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 10; }
.wordmark { font-family: var(--display); font-size: 30px; font-weight: 340; letter-spacing: -0.02em; line-height: 1; color: var(--cream); }
.wordmark span { color: var(--amber); }
.search { flex: 1 1 280px; display: flex; align-items: center; gap: 10px; min-height: 46px; padding: 0 18px; border-radius: 999px; background: rgba(244,237,224,0.06); border: 1px solid rgba(244,237,224,0.14); color: var(--text-2); }
.search input { flex: 1; min-width: 0; background: transparent; border: 0; outline: 0; color: var(--cream); font: 500 16px var(--body); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 44px; padding: 0 20px; border-radius: 999px; border: 0; cursor: pointer; font-weight: 600; font-size: 15px; }
.btn-primary { background: var(--amber); color: var(--night); }
.btn-primary:hover { background: var(--amber-2); }
.btn-ghost { background: rgba(244,237,224,0.06); border: 1px solid rgba(244,237,224,0.18); color: var(--cream); }
.icon-btn { width: 46px; height: 46px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; border: 1px solid rgba(244,237,224,0.2); background: transparent; color: var(--cream); cursor: pointer; flex: none; }
.icon-btn[aria-expanded="true"] { background: var(--indigo); }
.avatar { width: 44px; height: 44px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; background: var(--indigo); border: 1px solid rgba(244,237,224,0.2); color: var(--cream); font-weight: 700; cursor: pointer; }
.top .upload-desktop { display: inline-flex; }

/* Inhalt */
main { max-width: 1180px; margin: 0 auto; padding: 36px clamp(16px, 4vw, 40px) 120px; display: flex; flex-direction: column; gap: 40px; }
h1, h2 { font-family: var(--display); font-weight: 350; letter-spacing: -0.015em; margin: 0; }
h1 { font-size: clamp(30px, 4vw, 40px); line-height: 1.15; }
h2 { font-size: 24px; font-weight: 380; }
.lead { margin: 6px 0 0; color: var(--text-2); font-size: 16px; }
.section-head { display: flex; align-items: baseline; justify-content: space-between; gap: 16px; flex-wrap: wrap; margin-bottom: 16px; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 20px; }
.card { display: flex; flex-direction: column; background: var(--night-2); border: 1px solid rgba(244,237,224,0.1); border-radius: 18px; overflow: hidden; color: var(--cream); transition: border-color .15s, transform .15s; }
.card:hover { border-color: rgba(242,182,109,0.55); transform: translateY(-2px); }
.thumb { height: 160px; background: var(--indigo); display: flex; align-items: flex-end; justify-content: center; padding-top: 16px; overflow: hidden; }
.thumb img { width: 66%; height: 144px; object-fit: cover; object-position: top; border-radius: 6px 6px 0 0; background: var(--cream); }
.card-body { padding: 14px 16px 16px; display: flex; flex-direction: column; gap: 6px; }
.meta-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; font-size: 13px; color: var(--text-2); }
.card-title { font-size: 16px; font-weight: 600; line-height: 1.3; }
.small { font-size: 13px; color: var(--text-3); }
.chip { font-size: 12px; font-weight: 700; padding: 4px 10px; border-radius: 999px; white-space: nowrap; background: rgba(244,237,224,0.12); color: var(--cream); }
.chip.mp { background: var(--amber); color: var(--night); }

.areas { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; }
.area { display: flex; justify-content: space-between; align-items: center; gap: 16px; padding: 26px; border-radius: 22px; background: var(--night-2); border: 1px solid var(--line); color: var(--cream); }
.area.mp { background: var(--indigo); border-color: rgba(242,182,109,0.35); }
.area-name { font-family: var(--display); font-size: 28px; font-weight: 350; }
.area-sub { font-size: 15px; color: var(--text-2); margin-top: 4px; }
.faces { display: flex; }
.faces span { width: 40px; height: 40px; border-radius: 999px; display: inline-flex; align-items: center; justify-content: center; font-weight: 700; color: var(--night); border: 2px solid var(--indigo); }
.faces span + span { margin-left: -10px; }

.list { display: flex; flex-direction: column; gap: 10px; }
.row { display: flex; align-items: center; gap: 14px; padding: 12px; border-radius: 16px; background: var(--night-2); color: var(--cream); border: 1px solid transparent; }
.row:hover { border-color: rgba(242,182,109,0.4); }
.row img { flex: none; width: 46px; height: 60px; object-fit: cover; object-position: top; border-radius: 6px; background: var(--cream); }
.row .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.row .t { font-size: 15px; font-weight: 600; line-height: 1.3; overflow: hidden; text-overflow: ellipsis; }
.empty { padding: 28px; border-radius: 18px; border: 1px dashed rgba(244,237,224,0.2); color: var(--text-2); text-align: center; }

/* Dokument */
.doc { display: flex; flex-wrap: wrap; gap: 36px; align-items: flex-start; }
.preview { flex: 1 1 460px; min-width: 0; background: var(--indigo); border-radius: 22px; padding: clamp(14px, 3vw, 32px); }
.preview iframe, .preview img { display: block; width: 100%; height: min(78vh, 900px); border: 0; border-radius: 8px; background: var(--cream); object-fit: contain; }
.side { flex: 1 1 360px; min-width: 0; display: flex; flex-direction: column; gap: 20px; }
.side-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; position: relative; }
.side-head .chip { align-self: flex-start; }
.side-head h1 { font-size: clamp(26px, 3vw, 34px); }
.facts { margin: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 20px; background: var(--night-2); border: 1px solid rgba(244,237,224,0.1); border-radius: 18px; padding: 20px; }
.facts dt { font-size: 13px; color: var(--text-3); }
.facts dd { margin: 4px 0 0; font-size: 16px; font-weight: 600; overflow-wrap: anywhere; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; }
.tags span { font-size: 13px; padding: 6px 12px; border-radius: 999px; background: rgba(244,237,224,0.08); }
.ai-note { display: flex; gap: 12px; align-items: flex-start; padding: 14px 16px; border-radius: 16px; background: rgba(242,182,109,0.1); border: 1px solid rgba(242,182,109,0.3); font-size: 14px; line-height: 1.5; color: rgba(244,237,224,0.85); }
.ai-note svg { flex: none; margin-top: 2px; }

.menu { position: absolute; top: 56px; right: 0; z-index: 20; width: min(310px, 90vw); background: var(--night-2); border: 1px solid rgba(244,237,224,0.16); border-radius: 18px; padding: 8px; box-shadow: 0 20px 50px rgba(0,0,0,0.45); display: flex; flex-direction: column; }
.menu button, .menu a { display: flex; align-items: center; gap: 12px; min-height: 48px; padding: 0 14px; border: 0; border-radius: 12px; background: transparent; color: var(--cream); font: 500 15px var(--body); text-align: left; cursor: pointer; }
.menu button:hover, .menu a:hover { background: rgba(242,182,109,0.1); }
.menu .accent { font-weight: 600; }
.menu .danger { color: var(--rose); }
.menu hr { border: 0; height: 1px; background: rgba(244,237,224,0.1); margin: 6px 8px; }

/* Dialog */
dialog { background: var(--night-2); color: var(--cream); border: 1px solid rgba(244,237,224,0.16); border-radius: 22px; padding: 26px; width: min(460px, 92vw); }
dialog::backdrop { background: rgba(5,8,18,0.7); }
dialog form { display: flex; flex-direction: column; gap: 16px; }
dialog label { display: flex; flex-direction: column; gap: 6px; font-size: 14px; color: var(--text-2); }
dialog input, dialog select { min-height: 46px; padding: 0 14px; border-radius: 12px; border: 1px solid rgba(244,237,224,0.18); background: var(--night-3); color: var(--cream); font: 500 16px var(--body); }
dialog .actions { display: flex; justify-content: flex-end; gap: 10px; flex-wrap: wrap; }

#toast { position: fixed; left: 50%; bottom: 104px; transform: translateX(-50%); z-index: 50; max-width: 92vw; padding: 12px 20px; border-radius: 999px; background: var(--cream); color: var(--night); font-weight: 600; box-shadow: 0 10px 30px rgba(0,0,0,0.4); }

/* Liste mit Filtern */
.list-head { display: flex; flex-direction: column; gap: 20px; }
.lead .linkbtn { margin-left: 10px; }
.linkbtn { background: none; border: 0; padding: 0; color: var(--amber); cursor: pointer; font: 600 14px var(--body); }
.linkbtn:hover { text-decoration: underline; text-underline-offset: 3px; }
.filterbar { position: relative; display: flex; align-items: center; gap: 10px 16px; flex-wrap: wrap; padding: 10px; border-radius: 20px; background: rgba(244,237,224,0.03); border: 1px solid var(--line); }
.pills { flex: 1 1 auto; display: flex; flex-wrap: wrap; gap: 8px; min-width: 0; }
.pill { display: inline-flex; align-items: center; gap: 6px; min-height: 38px; padding: 0 14px; border-radius: 999px; border: 1px solid rgba(244,237,224,0.14); background: transparent; color: var(--text-2); font: 600 14px var(--body); cursor: pointer; white-space: nowrap; transition: background .15s, border-color .15s, color .15s; }
.pill:hover { border-color: rgba(242,182,109,0.5); color: var(--cream); }
.pill[aria-expanded="true"] { background: var(--indigo); border-color: rgba(242,182,109,0.5); color: var(--cream); }
.pill svg { opacity: .8; }
.pill-quiet { border-color: transparent; }
.pill-on { display: inline-flex; align-items: center; border-radius: 999px; background: rgba(242,182,109,0.14); border: 1px solid rgba(242,182,109,0.55); }
.pill-on .pill { border: 0; padding-right: 4px; color: rgba(246,198,135,0.85); background: transparent; }
.pill-on .pill b { color: var(--cream); font-weight: 700; max-width: 200px; overflow: hidden; text-overflow: ellipsis; }
.pill-x { width: 32px; height: 32px; margin-right: 3px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 999px; background: transparent; color: var(--amber); cursor: pointer; }
.pill-x:hover { background: rgba(242,182,109,0.2); }
.tools { display: flex; align-items: center; gap: 8px; margin-left: auto; }
.seg { display: inline-flex; padding: 3px; border-radius: 999px; border: 1px solid rgba(244,237,224,0.14); }
.seg button { width: 38px; height: 32px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 999px; background: transparent; color: var(--text-3); cursor: pointer; }
.seg button[aria-pressed="true"] { background: var(--indigo); color: var(--cream); }
.pop { position: absolute; z-index: 40; width: min(320px, 92vw); max-height: 400px; display: flex; flex-direction: column; gap: 6px; padding: 8px; background: var(--night-2); border: 1px solid rgba(244,237,224,0.16); border-radius: 18px; box-shadow: 0 24px 60px rgba(0,0,0,0.5); animation: pop-in .14s ease-out; }
.pop-head { padding: 8px 12px 2px; font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.pop-search { min-height: 42px; margin: 2px 4px 4px; padding: 0 14px; border-radius: 12px; border: 1px solid rgba(244,237,224,0.16); background: var(--night-3); color: var(--cream); font: 500 15px var(--body); outline: 0; }
.pop-search:focus { border-color: var(--amber); }
.opts { overflow-y: auto; display: flex; flex-direction: column; overscroll-behavior: contain; }
.opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-height: 44px; padding: 0 12px; border: 0; border-radius: 12px; background: transparent; color: var(--cream); font: 500 15px var(--body); text-align: left; cursor: pointer; }
.opt:hover, .opt:focus-visible { background: rgba(242,182,109,0.1); outline: 0; }
.opt[aria-selected="true"] { color: var(--amber); font-weight: 700; }
.opt-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.opt .count { flex: none; min-width: 26px; padding: 2px 8px; border-radius: 999px; background: rgba(244,237,224,0.07); color: var(--text-3); font-size: 12px; text-align: center; font-variant-numeric: tabular-nums; }
.pop-none { padding: 10px 12px; margin: 0; }
.pop-backdrop { display: none; }
.more { display: flex; justify-content: center; margin-top: 24px; }
@keyframes pop-in { from { opacity: 0; transform: translateY(-4px) scale(.98); } }
@keyframes sheet-in { from { transform: translateY(100%); } }
@media (prefers-reduced-motion: reduce) { .pop { animation: none !important; } }

/* Aufgaben */
.tasks-link { position: relative; display: inline-flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 16px; border-radius: 999px; border: 1px solid rgba(244,237,224,0.18); color: var(--cream); font-weight: 600; font-size: 15px; }
.tasks-link:hover, .tasks-link.on { border-color: rgba(242,182,109,0.6); }
.tasks-link.on { background: var(--indigo); }
.badge { min-width: 22px; height: 22px; padding: 0 7px; border-radius: 999px; background: var(--amber); color: var(--night); font-size: 12px; font-weight: 800; display: inline-flex; align-items: center; justify-content: center; font-variant-numeric: tabular-nums; }
.tasks { display: flex; flex-direction: column; gap: 8px; }
.task { display: flex; align-items: center; gap: 14px; padding: 12px 16px 12px 12px; border-radius: 16px; background: var(--night-2); border: 1px solid transparent; transition: border-color .15s, opacity .2s; }
.task:hover { border-color: rgba(242,182,109,0.35); }
.task-body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; color: var(--cream); }
.task-text { font-size: 15px; font-weight: 650; line-height: 1.35; }
.task-body .small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.task.done { opacity: .6; }
.task.done .task-text { text-decoration: line-through; text-decoration-color: rgba(244,237,224,0.4); }
.check { flex: none; width: 30px; height: 30px; border-radius: 999px; border: 2px solid rgba(244,237,224,0.35); background: transparent; color: transparent; display: inline-flex; align-items: center; justify-content: center; cursor: pointer; transition: background .15s, border-color .15s, color .15s, transform .1s; }
.check:hover { border-color: var(--amber); color: rgba(242,182,109,0.6); }
.check:active { transform: scale(.92); }
.check[aria-pressed="true"] { background: var(--sage); border-color: var(--sage); color: var(--night); }
.check:disabled { opacity: .5; }
.due { flex: none; display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; background: rgba(244,237,224,0.08); color: var(--text-2); }
.due.soon { background: rgba(242,182,109,0.16); color: var(--amber-2); }
.due.over { background: rgba(232,165,149,0.18); color: var(--rose); }
.card-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; flex-wrap: wrap; }
.row .due { margin-left: auto; }
.todo .tasks { max-width: 820px; }
.task-group { display: flex; flex-direction: column; gap: 12px; }
.group-title { font-family: var(--body); font-size: 13px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--text-3); }
.group-title span { margin-left: 6px; color: var(--text-3); font-weight: 600; }
.task-card { display: flex; align-items: flex-start; gap: 14px; padding: 16px 18px; border-radius: 18px; background: var(--night-2); border: 1px solid rgba(244,237,224,0.12); }
.task-card .grow { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.task-card.soon { border-color: rgba(242,182,109,0.5); background: rgba(242,182,109,0.08); }
.task-card.over { border-color: rgba(232,165,149,0.55); background: rgba(232,165,149,0.08); }
.task-card.done .task-text { text-decoration: line-through; opacity: .7; }
.task-kicker { font-size: 12px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--amber); }
.task-card.over .task-kicker { color: var(--rose); }
.task-card.done .task-kicker { color: var(--sage); }
.task-card .linkbtn { align-self: center; }
.seg-text { align-self: flex-start; }
.seg-text a { display: inline-flex; align-items: center; min-height: 34px; padding: 0 16px; border-radius: 999px; color: var(--text-2); font-weight: 600; font-size: 14px; }
.seg-text a[aria-selected="true"] { background: var(--indigo); color: var(--cream); }
dialog .actions .spacer { flex: 1; }
.danger-text { color: var(--rose) !important; }
#toast { display: flex; align-items: center; gap: 14px; }
#toast[hidden] { display: none; }
.toast-undo { border: 0; background: none; color: var(--indigo); font: 800 14px var(--body); cursor: pointer; text-decoration: underline; text-underline-offset: 3px; padding: 0; }
.tabbar .badge { position: absolute; transform: translate(14px, -8px); min-width: 18px; height: 18px; font-size: 11px; padding: 0 5px; }
.tabbar a { position: relative; }

/* Notizen, Schnellaktionen */
.factlink { color: var(--cream); text-decoration: none; border-bottom: 1px dashed rgba(242,182,109,0.5); }
.factlink:hover { color: var(--amber-2); border-bottom-color: var(--amber); }
.factlink span { color: var(--amber); font-weight: 700; }
.btn-sm { min-height: 38px; padding: 0 14px; font-size: 14px; }
.quick { display: flex; flex-wrap: wrap; gap: 8px; }
.notes { display: flex; flex-direction: column; gap: 10px; scroll-margin-top: 96px; }
.note { padding: 12px 14px; border-radius: 14px; background: var(--night-2); border: 1px solid rgba(244,237,224,0.08); }
.note-head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; font-size: 13px; }
.note-head .small { flex: 1; }
.note-text { font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.note-del { width: 28px; height: 28px; display: inline-flex; align-items: center; justify-content: center; border: 0; border-radius: 999px; background: transparent; color: var(--text-3); cursor: pointer; }
.note-del:hover { color: var(--rose); background: rgba(232,165,149,0.12); }
.note-del svg { width: 14px; height: 14px; }
.note-form { display: flex; gap: 8px; align-items: flex-end; }
.note-form textarea, .ki-form textarea { flex: 1; min-height: 44px; padding: 11px 14px; border-radius: 14px; border: 1px solid rgba(244,237,224,0.16); background: var(--night-3); color: var(--cream); font: 500 15px/1.4 var(--body); resize: vertical; outline: 0; }
.note-form textarea:focus, .ki-form textarea:focus { border-color: var(--amber); }
.notes-jump { display: inline-flex; align-items: center; gap: 6px; color: var(--text-2); margin-top: 2px; }
.notes-jump svg { width: 15px; height: 15px; }
.note-count { display: inline-flex; align-items: center; gap: 3px; margin-left: 6px; font-size: 12px; color: var(--text-3); font-weight: 600; vertical-align: middle; }
.note-count svg { width: 13px; height: 13px; }

/* Überweisung & Mail */
dialog.wide { width: min(720px, 94vw); }
dialog textarea { min-height: 120px; padding: 12px 14px; border-radius: 12px; border: 1px solid rgba(244,237,224,0.18); background: var(--night-3); color: var(--cream); font: 500 15px/1.5 var(--body); resize: vertical; }
.pay-grid { display: flex; flex-wrap: wrap; gap: 20px; }
.pay-fields { flex: 1 1 300px; display: flex; flex-direction: column; gap: 12px; }
.pay-qr { flex: 0 1 230px; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; }
.qr { width: 210px; height: 210px; border-radius: 16px; background: #fff; display: flex; align-items: center; justify-content: center; padding: 6px; }
.qr svg { width: 100%; height: 100%; }
.qr .small { color: #555; }
.copyrow { display: flex; gap: 6px; }
.copyrow input { flex: 1; min-width: 0; }
.icon-mini { flex: none; width: 46px; border-radius: 12px; border: 1px solid rgba(244,237,224,0.18); background: transparent; color: var(--text-2); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; }
.icon-mini:hover { color: var(--amber); border-color: var(--amber); }
input.invalid { border-color: var(--rose) !important; }
.warn { margin: 0; padding: 10px 14px; border-radius: 12px; background: rgba(232,165,149,0.12); border: 1px solid rgba(232,165,149,0.35); color: var(--rose); font-size: 13px; line-height: 1.45; }
dialog .actions a.btn { text-decoration: none; }

/* KI-Assistent */
.ki-fab { position: fixed; right: 24px; bottom: 24px; z-index: 45; display: inline-flex; align-items: center; gap: 8px; min-height: 52px; padding: 0 20px 0 16px; border-radius: 999px; border: 1px solid rgba(242,182,109,0.6); background: var(--indigo); color: var(--cream); font: 700 15px var(--body); cursor: pointer; box-shadow: 0 14px 40px rgba(0,0,0,0.45); }
.ki-fab:hover { background: #343B72; }
.ki-panel { position: fixed; right: 24px; bottom: 24px; z-index: 46; width: min(430px, calc(100vw - 32px)); height: min(680px, calc(100vh - 120px)); display: flex; flex-direction: column; background: var(--night-2); border: 1px solid rgba(244,237,224,0.16); border-radius: 22px; box-shadow: 0 30px 80px rgba(0,0,0,0.55); overflow: hidden; animation: pop-in .16s ease-out; }
.ki-panel header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 14px 12px 18px; border-bottom: 1px solid var(--line); }
.ki-panel header > div:first-child { display: flex; flex-direction: column; }
.ki-panel header b { font-family: var(--display); font-weight: 380; font-size: 22px; }
.ki-head-actions { display: flex; align-items: center; gap: 10px; }
.ki-head-actions .icon-btn { width: 40px; height: 40px; }
.ki-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.msg { max-width: 88%; padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.5; overflow-wrap: anywhere; }
.msg.me { align-self: flex-end; background: var(--amber); color: var(--night); border-bottom-right-radius: 6px; font-weight: 600; }
.msg.bot { align-self: flex-start; background: var(--night-3); border: 1px solid var(--line); border-bottom-left-radius: 6px; }
.msg.bot ul { margin: 6px 0; padding-left: 18px; }
.msg.step { align-self: flex-start; padding: 2px 6px; font-size: 13px; color: var(--text-3); }
.doc-chip { display: inline-block; margin: 2px 0; padding: 1px 8px; border-radius: 8px; background: rgba(242,182,109,0.14); color: var(--amber-2); font-weight: 600; text-decoration: none; }
.doc-chip:hover { background: rgba(242,182,109,0.26); }
.typing { display: inline-flex; gap: 5px; }
.typing span { width: 7px; height: 7px; border-radius: 99px; background: var(--text-3); animation: blink 1.2s infinite ease-in-out; }
.typing span:nth-child(2) { animation-delay: .2s; } .typing span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
.ki-empty { margin: auto 0; display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center; color: var(--text-2); font-size: 14px; line-height: 1.5; padding: 0 12px; }
.ki-empty svg { width: 34px; height: 34px; }
.ki-sugg { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 16px 12px; }
.ki-sugg .pill { min-height: 34px; font-size: 13px; white-space: normal; text-align: left; }
.ki-form { display: flex; gap: 8px; padding: 12px; border-top: 1px solid var(--line); }
.ki-form textarea { resize: none; max-height: 160px; }
.ki-send { width: 46px; min-height: 46px; padding: 0; flex: none; }
@media (prefers-reduced-motion: reduce) { .ki-panel, .typing span { animation: none !important; } }

/* Handy-Navigation */
.tabbar { display: none; }
@media (max-width: 720px) {
  .top { gap: 12px; }
  .top .upload-desktop, .top .tasks-link { display: none; }
  .search { order: 3; flex-basis: 100%; }
  main { gap: 30px; padding-top: 24px; }
  .thumb { height: 130px; } .thumb img { height: 116px; }
  .tabbar { display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; justify-content: space-around; align-items: center; padding: 10px 12px calc(14px + env(safe-area-inset-bottom)); background: var(--night-3); border-top: 1px solid var(--line); }
  .tabbar a, .tabbar label { display: flex; flex-direction: column; align-items: center; gap: 4px; min-width: 56px; min-height: 44px; justify-content: center; color: var(--text-2); font-size: 12px; font-weight: 600; cursor: pointer; }
  .tabbar a[aria-current="page"] { color: var(--amber); }
  .tabbar .scan { width: 66px; height: 66px; margin-top: -38px; border-radius: 999px; background: var(--amber); color: var(--night); border: 4px solid var(--night); box-shadow: 0 10px 30px rgba(242,182,109,0.35); }
  .preview iframe, .preview img { height: 62vh; }
  .filterbar { padding: 0; border: 0; background: none; }
  .pills { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; margin: 0 calc(-1 * clamp(16px, 4vw, 40px)); padding: 0 clamp(16px, 4vw, 40px); }
  .pills::-webkit-scrollbar { display: none; }
  .tools { margin-left: 0; width: 100%; justify-content: space-between; }
  .pop { position: fixed; left: 0 !important; right: 0 !important; top: auto !important; bottom: 0; width: auto; max-height: 72vh; border-radius: 24px 24px 0 0; padding: 10px 12px calc(18px + env(safe-area-inset-bottom)); animation: sheet-in .2s ease-out; }
  .pop::before { content: ""; align-self: center; width: 40px; height: 4px; border-radius: 4px; background: rgba(244,237,224,0.25); margin-bottom: 4px; }
  .pop-backdrop:not([hidden]) { display: block; position: fixed; inset: 0; z-index: 35; background: rgba(5,8,18,0.6); }
  .opt { min-height: 50px; }
  .ki-fab { right: 14px; bottom: calc(96px + env(safe-area-inset-bottom)); min-height: 46px; padding: 0 16px 0 12px; font-size: 14px; }
  .ki-panel { inset: 0; right: 0; bottom: 0; width: 100%; height: 100%; border-radius: 0; border: 0; z-index: 60; padding-bottom: env(safe-area-inset-bottom); }
  .note-form { flex-direction: column; align-items: stretch; }
  .pay-qr { flex-basis: 100%; }
}
