/* Eissistant - shared styles */
:root {
  --bg: #f6f3fb;
  --surface: #ffffff;
  --surface-2: #faf8fd;
  --text: #221b33;
  --muted: #625a75;
  --faint: #918aa3;
  --border: #e9e3f3;
  --border-strong: #d6cce6;
  --primary: #7356b8;
  --primary-hover: #61479f;
  --primary-soft: #efe9fb;
  --primary-text: #5b3fa0;
  --lavender: #b9a3e6;
  --danger: #c0262d;
  --danger-soft: #fdecec;
  --warning: #a35d06;
  --warning-soft: #fdf3dd;
  --success: #137a3a;
  --success-soft: #e3f6ea;
  --info: #4c55c9;
  --info-soft: #eceefd;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 2px rgba(45, 27, 84, .05), 0 1px 3px rgba(45, 27, 84, .08);
  --shadow-lg: 0 12px 32px rgba(45, 27, 84, .16);
  --nav-w: 232px;
  --header-h: 56px;
  --bottom-h: 64px;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0; font-family: var(--font); font-size: 15px; line-height: 1.5; color: var(--text);
  background: var(--bg); -webkit-font-smoothing: antialiased;
}
h1, h2, h3, h4 { margin: 0; line-height: 1.25; }
h1 { font-size: 1.5rem; font-weight: 700; letter-spacing: -.01em; }
h2 { font-size: 1.15rem; font-weight: 650; }
h3 { font-size: 1rem; font-weight: 650; }
p { margin: 0; }
a { color: var(--primary-text); }
button, input, select, textarea { font: inherit; color: inherit; }
img { max-width: 100%; }
[hidden] { display: none !important; }
.muted { color: var(--muted); }
.faint { color: var(--faint); }
.small { font-size: .85rem; }
.nowrap { white-space: nowrap; }
.num { font-variant-numeric: tabular-nums; text-align: right; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.icon { width: 20px; height: 20px; flex: none; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.icon.sm { width: 14px; height: 14px; vertical-align: -2px; }

/* ---------------------------------------------------------- shell */
.app { min-height: 100vh; }
.topbar {
  position: sticky; top: 0; z-index: 20; height: var(--header-h); display: flex; align-items: center; gap: 12px;
  padding: 0 16px; background: rgba(255,255,255,.92); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 10px; font-weight: 700; font-size: 1.05rem; text-decoration: none; color: var(--text); min-width: 0; }
.brand img { width: 30px; height: 30px; border-radius: 8px; }
.brand span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .spacer { flex: 1; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--faint); display: inline-block; }
.status-dot.on { background: #22a35a; }

.sidenav { display: none; }
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 30; display: flex; background: var(--surface);
  border-top: 1px solid var(--border); padding-bottom: env(safe-area-inset-bottom);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  height: var(--bottom-h); font-size: .7rem; font-weight: 600; color: var(--muted); text-decoration: none;
}
.bottomnav a .icon { width: 23px; height: 23px; }
.bottomnav a.active { color: var(--primary); }
.main { padding: 16px 14px calc(var(--bottom-h) + 28px + env(safe-area-inset-bottom)); max-width: 1240px; margin: 0 auto; }

@media (min-width: 900px) {
  .topbar { padding-left: calc(var(--nav-w) + 24px); }
  .topbar .brand { position: fixed; left: 18px; top: 13px; }
  .sidenav {
    display: flex; flex-direction: column; gap: 4px; position: fixed; top: 0; bottom: 0; left: 0; width: var(--nav-w);
    padding: calc(var(--header-h) + 14px) 12px 16px; background: var(--surface); border-right: 1px solid var(--border); z-index: 19;
  }
  .sidenav a {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; border-radius: 10px; color: var(--muted);
    text-decoration: none; font-weight: 600;
  }
  .sidenav a:hover { background: var(--surface-2); color: var(--text); }
  .sidenav a.active { background: var(--primary-soft); color: var(--primary-text); }
  .sidenav .nav-foot { margin-top: auto; font-size: .8rem; color: var(--faint); padding: 8px 12px; }
  .bottomnav { display: none; }
  .main { margin-left: var(--nav-w); padding: 24px 28px 48px; max-width: none; }
  .main > .view { max-width: 1180px; margin: 0 auto; }
}

/* ---------------------------------------------------------- page structure */
.page-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.page-head p { color: var(--muted); margin-top: 4px; }
.section { margin-top: 22px; }
.section-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.stack { display: flex; flex-direction: column; gap: 12px; }
.row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.row.end { justify-content: flex-end; }
.row.between { justify-content: space-between; }
.grow { flex: 1; min-width: 0; }
.grid-2 { display: grid; gap: 14px; grid-template-columns: 1fr; }
.grid-3 { display: grid; gap: 14px; grid-template-columns: 1fr; }
@media (min-width: 700px) { .grid-2 { grid-template-columns: 1fr 1fr; } .grid-3 { grid-template-columns: repeat(2, 1fr); } }
@media (min-width: 1100px) { .grid-3 { grid-template-columns: repeat(3, 1fr); } }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; }
.card.flat { box-shadow: none; }
.card.pad-lg { padding: 20px; }
.card-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 12px; }
.card-head h2, .card-head h3, .card > h2 { display: flex; align-items: center; gap: 8px; }
.divider { height: 1px; background: var(--border); margin: 14px 0; }

/* ---------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 40px; padding: 8px 14px;
  border-radius: 10px; border: 1px solid var(--border-strong); background: var(--surface); color: var(--text);
  font-weight: 600; cursor: pointer; text-decoration: none; white-space: nowrap; transition: background .12s, border-color .12s;
  -webkit-tap-highlight-color: transparent;
}
.btn:hover { background: var(--surface-2); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn.primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn.primary:hover { background: var(--primary-hover); }
.btn.danger { color: var(--danger); }
.btn.danger.solid { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn.ghost { border-color: transparent; background: transparent; }
.btn.ghost:hover { background: rgba(115, 86, 184, .08); }
.btn.sm { min-height: 32px; padding: 4px 10px; font-size: .85rem; border-radius: 8px; }
.btn.sm .icon { width: 16px; height: 16px; }
.btn.icon-only { padding: 0; width: 40px; flex: none; }
.btn.sm.icon-only { width: 32px; }
.btn.block { width: 100%; }
.btn.recording { background: var(--danger); border-color: var(--danger); color: #fff; }
.link-btn { border: 0; background: none; color: var(--primary-text); font-weight: 600; cursor: pointer; padding: 0; }

/* ---------------------------------------------------------- forms */
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span, .label { font-size: .85rem; font-weight: 600; color: var(--muted); }
.input, select.input, textarea.input {
  width: 100%; min-height: 42px; padding: 9px 12px; border: 1px solid var(--border-strong); border-radius: 10px;
  background: var(--surface); outline: none; font-size: 16px; /* 16px stops iPhone zooming in */
}
textarea.input { resize: vertical; min-height: 96px; line-height: 1.45; }
.input:focus { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(115, 86, 184, .18); }
.input.sm { min-height: 34px; padding: 5px 8px; font-size: 14px; border-radius: 8px; }
@media (max-width: 899px) { .input.sm { font-size: 16px; } }
.input-group { display: flex; gap: 8px; }
.check { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.check input { width: 18px; height: 18px; accent-color: var(--primary); }
.switch { position: relative; display: inline-flex; align-items: center; gap: 10px; cursor: pointer; }
.switch input { position: absolute; opacity: 0; }
.switch .track { width: 40px; height: 24px; border-radius: 12px; background: var(--border-strong); position: relative; transition: background .15s; flex: none; }
.switch .track::after { content: ""; position: absolute; top: 3px; left: 3px; width: 18px; height: 18px; border-radius: 50%; background: #fff; box-shadow: var(--shadow); transition: transform .15s; }
.switch input:checked + .track { background: var(--primary); }
.switch input:checked + .track::after { transform: translateX(16px); }
.switch input:focus-visible + .track { outline: 2px solid var(--primary); outline-offset: 2px; }

/* ---------------------------------------------------------- tabs, chips, badges */
.tabs { display: inline-flex; gap: 4px; padding: 4px; background: #ece6f6; border-radius: 12px; max-width: 100%; overflow-x: auto; }
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tabs a, .tabs button {
  padding: 7px 14px; border-radius: 9px; font-weight: 600; color: var(--muted); text-decoration: none; white-space: nowrap;
  border: 0; background: transparent; cursor: pointer; display: inline-flex; align-items: center; gap: 6px;
}
@media (max-width: 420px) { .tabs a, .tabs button { padding: 7px 10px; } }
.tabs a.active, .tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow); }
.tabs .count { background: var(--primary); color: #fff; border-radius: 10px; padding: 0 7px; font-size: .75rem; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; padding: 5px 12px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface); font-size: .85rem; font-weight: 600; cursor: pointer; color: var(--text);
}
.chip.active { background: var(--text); border-color: var(--text); color: #fff; }
.chip .n { opacity: .7; }
.chip.suggest { border-style: dashed; border-color: var(--primary); color: var(--primary-text); background: var(--primary-soft); }
.chip.done { border-style: solid; background: var(--success-soft); border-color: transparent; color: var(--success); cursor: default; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: .75rem; font-weight: 700; white-space: nowrap; }
.badge.matched, .badge.success { background: var(--success-soft); color: var(--success); }
.badge.different, .badge.danger, .badge.high { background: var(--danger-soft); color: var(--danger); }
.badge.missing, .badge.warning { background: var(--warning-soft); color: var(--warning); }
.badge.info, .badge.review { background: var(--info-soft); color: var(--info); }
.badge.neutral, .badge.low, .badge.normal { background: #eef1f5; color: var(--muted); }

/* ---------------------------------------------------------- tiles & lists */
.tiles { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .tiles { grid-template-columns: repeat(4, 1fr); } }
.tile { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; text-align: left; cursor: pointer; box-shadow: var(--shadow); }
.tile .k { font-size: .8rem; color: var(--muted); font-weight: 600; display: flex; align-items: center; gap: 6px; }
.tile .v { font-size: 1.6rem; font-weight: 750; margin-top: 2px; font-variant-numeric: tabular-nums; }
.tile.matched .v { color: var(--success); } .tile.different .v { color: var(--danger); }
.tile.missing .v { color: var(--warning); } .tile.review .v { color: var(--info); }
.tile.active { outline: 2px solid var(--text); }
.quick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
@media (min-width: 700px) { .quick { grid-template-columns: repeat(3, 1fr); } }
.quick a {
  display: flex; align-items: center; gap: 12px; padding: 14px; border-radius: var(--radius); background: var(--surface);
  border: 1px solid var(--border); box-shadow: var(--shadow); color: var(--text); text-decoration: none; font-weight: 600;
}
.quick a .ico { width: 38px; height: 38px; border-radius: 10px; background: var(--primary-soft); color: var(--primary); display: grid; place-items: center; flex: none; }
.list { display: flex; flex-direction: column; }
.list-item { display: flex; align-items: flex-start; gap: 12px; padding: 12px 0; border-top: 1px solid var(--border); }
.list-item:first-child { border-top: 0; }
.list-item .body { flex: 1; min-width: 0; }
.list-item .title { font-weight: 600; overflow-wrap: anywhere; }
.list-item.done .title { text-decoration: line-through; color: var(--faint); }
.list-item .meta { font-size: .82rem; color: var(--muted); display: flex; gap: 8px; flex-wrap: wrap; margin-top: 2px; }
.list-item .meta .overdue { color: var(--danger); font-weight: 650; }
.empty { text-align: center; color: var(--muted); padding: 28px 16px; }
.empty .icon { width: 36px; height: 36px; color: var(--faint); margin-bottom: 8px; }
.notice { display: flex; gap: 12px; align-items: flex-start; padding: 12px 14px; border-radius: var(--radius); background: var(--info-soft); color: #2b2f78; font-size: .9rem; }
.notice.warning { background: var(--warning-soft); color: #6b3d03; }
.notice.danger { background: var(--danger-soft); color: #7d1a1e; }
.notice.success { background: var(--success-soft); color: #0e5129; }
.notice .icon { margin-top: 1px; }
.notice > .btn { margin: -6px -6px -6px 0; color: inherit; }

/* ---------------------------------------------------------- drop zone */
.drop {
  border: 2px dashed var(--border-strong); border-radius: var(--radius); padding: 22px 16px; text-align: center; background: var(--surface);
  cursor: pointer; transition: border-color .12s, background .12s; display: block;
}
.drop:hover, .drop.over { border-color: var(--primary); background: var(--primary-soft); }
.drop .icon { width: 30px; height: 30px; color: var(--primary); }
.drop strong { display: block; margin-top: 6px; }
.drop input { display: none; }

/* ---------------------------------------------------------- tables */
.table-wrap { overflow: auto; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface); max-height: 70vh; }
table.data { border-collapse: separate; border-spacing: 0; width: 100%; font-size: .9rem; }
table.data th, table.data td { padding: 8px 10px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
table.data th { position: sticky; top: 0; background: var(--surface-2); font-size: .78rem; text-transform: uppercase; letter-spacing: .03em; color: var(--muted); z-index: 2; white-space: nowrap; }
table.data tr:last-child td { border-bottom: 0; }
table.data td.sticky, table.data th.sticky { position: sticky; left: 0; background: var(--surface); z-index: 1; min-width: 150px; max-width: 280px; }
table.data th.sticky { z-index: 3; background: var(--surface-2); }
table.data tr.total td { font-weight: 700; background: var(--surface-2); position: sticky; bottom: 0; }
table.data td .alias { display: block; font-size: .78rem; color: var(--muted); }
table.data .pick { border: 1px solid transparent; background: none; border-radius: 6px; padding: 2px 6px; cursor: pointer; font: inherit; font-variant-numeric: tabular-nums; }
table.data .pick:hover { border-color: var(--border-strong); background: var(--surface-2); }
table.data .pick.chosen { border-color: var(--primary); background: var(--primary-soft); color: var(--primary-text); font-weight: 700; }
table.data input.input.sm { min-width: 90px; }
table.preview { font-size: .8rem; }
table.preview td, table.preview th { padding: 4px 8px; max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
table.preview .hl-key { background: #eef6ff; }
table.preview .hl-amount { background: #effaf3; }
table.preview .hl-cat { background: #fbf3ff; }
table.preview tr.header-row td { font-weight: 700; background: #fff8e6; }

/* ---------------------------------------------------------- toasts & modals */
.toasts { position: fixed; z-index: 100; left: 50%; transform: translateX(-50%); top: calc(env(safe-area-inset-top) + 10px); display: flex; flex-direction: column; gap: 8px; width: min(92vw, 440px); pointer-events: none; }
@media (min-width: 900px) { .toasts { top: calc(var(--header-h) + 12px); left: auto; right: 24px; transform: none; } }
.toast { cursor: pointer; }
.toast { background: #2a2140; color: #fff; padding: 12px 14px; border-radius: 10px; box-shadow: var(--shadow-lg); font-size: .92rem; pointer-events: auto; display: flex; gap: 10px; align-items: flex-start; animation: pop .18s ease-out; }
.toast.error { background: #8f1d22; } .toast.success { background: #11612f; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } to { transform: none; opacity: 1; } }
.modal-back { position: fixed; inset: 0; z-index: 90; background: rgba(34, 27, 51, .45); display: flex; align-items: flex-end; justify-content: center; }
@media (min-width: 700px) { .modal-back { align-items: center; padding: 24px; } }
.modal { background: var(--surface); width: 100%; max-width: 560px; max-height: 92vh; display: flex; flex-direction: column; border-radius: 16px 16px 0 0; box-shadow: var(--shadow-lg); }
.modal.wide { max-width: 900px; }
@media (min-width: 700px) { .modal { border-radius: 16px; } }
.modal-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 14px 16px; border-bottom: 1px solid var(--border); }
.modal-body { padding: 16px; overflow: auto; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; padding: 12px 16px calc(12px + env(safe-area-inset-bottom)); border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ---------------------------------------------------------- spinners */
.spinner { width: 18px; height: 18px; border: 2.5px solid rgba(115, 86, 184, .25); border-top-color: var(--primary); border-radius: 50%; animation: spin .8s linear infinite; display: inline-block; flex: none; }
.btn.primary .spinner { border-color: rgba(255,255,255,.35); border-top-color: #fff; }
@keyframes spin { to { transform: rotate(360deg); } }
.loading { display: flex; align-items: center; gap: 10px; color: var(--muted); padding: 18px 4px; }

/* ---------------------------------------------------------- rich text (AI answers) */
.md { overflow-wrap: anywhere; }
.md > * + * { margin-top: .6em; }
.md h1, .md h2, .md h3, .md h4 { font-size: 1rem; margin-top: 1em; }
.md ul, .md ol { padding-left: 1.3em; margin-bottom: 0; }
.md li + li { margin-top: .2em; }
.md code { background: #eef1f5; padding: 1px 5px; border-radius: 5px; font-size: .88em; }
.md pre { background: #0f172a; color: #e2e8f0; padding: 12px; border-radius: 10px; overflow: auto; font-size: .85rem; }
.md pre code { background: none; padding: 0; color: inherit; }
.md table { border-collapse: collapse; font-size: .88rem; display: block; overflow-x: auto; }
.md th, .md td { border: 1px solid var(--border); padding: 5px 8px; text-align: left; }
.md th { background: var(--surface-2); }
.md blockquote { margin: 0; padding-left: 12px; border-left: 3px solid var(--border-strong); color: var(--muted); }

/* ---------------------------------------------------------- messages (inbox) */
.msg-card { display: flex; flex-direction: column; gap: 10px; }
.msg-card.done { opacity: .72; }
.msg-head { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.msg-head .who { font-weight: 700; }
.msg-summary { font-weight: 600; }
.msg-text { white-space: pre-wrap; color: #2c3546; background: var(--surface-2); border-radius: 10px; padding: 10px 12px; font-size: .93rem; max-height: 220px; overflow: auto; }
.msg-actions { display: flex; flex-wrap: wrap; gap: 6px; }
.reply-box { border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px; background: #fbfcfd; }
.reply-box p { white-space: pre-wrap; }
audio { width: 100%; height: 40px; }
.recorder { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.rec-time { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--danger); }
.pulse { width: 10px; height: 10px; border-radius: 50%; background: var(--danger); animation: pulse 1s infinite; }
@keyframes pulse { 50% { opacity: .3; } }

/* ---------------------------------------------------------- chat */
.chat-layout { display: grid; grid-template-columns: 1fr; gap: 16px; height: calc(100vh - var(--header-h) - var(--bottom-h) - 40px - env(safe-area-inset-bottom)); min-height: 420px; }
@media (min-width: 1000px) { .chat-layout { grid-template-columns: 260px 1fr; height: calc(100vh - var(--header-h) - 48px); } }
.chat-list { display: none; }
@media (min-width: 1000px) { .chat-list { display: flex; flex-direction: column; gap: 6px; overflow: auto; } }
.chat-list .item { text-align: left; padding: 10px 12px; border-radius: 10px; border: 0; background: transparent; cursor: pointer; display: flex; gap: 6px; align-items: center; }
.chat-list .item:hover { background: var(--surface); }
.chat-list .item.active { background: var(--surface); box-shadow: var(--shadow); font-weight: 600; }
.chat-list .item .t { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-main { display: flex; flex-direction: column; min-height: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow); overflow: hidden; }
.chat-top { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--border); }
.chat-top .t { flex: 1; font-weight: 650; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-scroll { flex: 1; overflow: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 14px; }
.bubble { max-width: 88%; padding: 10px 14px; border-radius: 16px; line-height: 1.5; }
.bubble.user { align-self: flex-end; background: var(--primary); color: #fff; border-bottom-right-radius: 4px; white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.user .files { font-size: .8rem; opacity: .9; margin-bottom: 4px; display: flex; gap: 6px; flex-wrap: wrap; }
.bubble.assistant { align-self: flex-start; background: var(--surface-2); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble.error { background: var(--danger-soft); color: #7d1a1e; border-color: transparent; }
.bubble .status { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: .85rem; }
.bubble .sources { margin-top: 10px; font-size: .82rem; display: flex; flex-direction: column; gap: 2px; }
.bubble .sources a { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tool-card { margin-top: 10px; background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 12px; display: flex; flex-direction: column; gap: 8px; }
.tool-card .k { font-size: .75rem; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700; display: flex; align-items: center; gap: 6px; }
.composer { border-top: 1px solid var(--border); padding: 10px; display: flex; flex-direction: column; gap: 8px; background: var(--surface); }
.composer textarea { min-height: 44px; max-height: 180px; resize: none; overflow-y: hidden; }
.composer .attachments { display: flex; flex-wrap: wrap; gap: 6px; }
.suggestions { display: grid; gap: 8px; grid-template-columns: 1fr; margin-top: 8px; }
@media (min-width: 700px) { .suggestions { grid-template-columns: 1fr 1fr; } }
.suggestions button { text-align: left; padding: 12px; border-radius: 12px; border: 1px solid var(--border); background: var(--surface); cursor: pointer; color: var(--text); }
.suggestions button:hover { border-color: var(--primary); }

/* ---------------------------------------------------------- match & budget */
.source-card { display: flex; flex-direction: column; gap: 12px; }
.source-card .fields { display: grid; gap: 10px; grid-template-columns: 1fr 1fr; }
@media (min-width: 800px) { .source-card .fields { grid-template-columns: repeat(5, 1fr); } }
.source-card .fields .wide { grid-column: span 2; }
@media (min-width: 800px) { .source-card .fields .wide { grid-column: span 1; } }
.ref-pill { font-size: .75rem; font-weight: 700; color: var(--primary-text); background: var(--primary-soft); padding: 2px 8px; border-radius: 999px; }
.bars { display: flex; flex-direction: column; gap: 8px; }
.bar-row { display: grid; grid-template-columns: minmax(90px, 160px) 1fr auto; gap: 10px; align-items: center; font-size: .88rem; }
.bar-row .bar { height: 10px; border-radius: 6px; background: #e8edf3; overflow: hidden; }
.bar-row .bar span { display: block; height: 100%; background: var(--primary); border-radius: 6px; }
.save-state { font-size: .82rem; color: var(--muted); display: inline-flex; align-items: center; gap: 6px; }

/* ---------------------------------------------------------- catalogue editor */
.cat-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); }
.cat-card { overflow: hidden; padding: 0; display: flex; flex-direction: column; cursor: pointer; }
.cat-card .cover { aspect-ratio: 16 / 10; background: #edf1f6 center / cover no-repeat; display: grid; place-items: center; color: var(--faint); }
.cat-card .info { padding: 12px 14px; display: flex; flex-direction: column; gap: 4px; }
.editor { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 1100px) { .editor { grid-template-columns: minmax(420px, 1fr) minmax(0, 1.15fr); align-items: start; } }
.editor .preview-pane { position: sticky; top: calc(var(--header-h) + 16px); }
.preview-frame { background: #e9edf2; border-radius: var(--radius); padding: 14px; max-height: calc(100vh - var(--header-h) - 90px); overflow: auto; border: 1px solid var(--border); }
.preview-frame .cat { box-shadow: var(--shadow); }
@media (max-width: 1099px) { .editor.show-preview .edit-pane { display: none; } .editor:not(.show-preview) .preview-pane { display: none; } .preview-frame { max-height: none; padding: 8px; } }
@media (min-width: 1100px) { .preview-toggle { display: none !important; } }
.prod-list { display: flex; flex-direction: column; }
.prod { display: grid; grid-template-columns: 56px 1fr auto; gap: 10px; padding: 10px 0; border-top: 1px solid var(--border); align-items: start; }
.prod:first-child { border-top: 0; }
.thumb { width: 56px; height: 56px; border-radius: 10px; background: #eef1f5 center / cover no-repeat; border: 1px dashed var(--border-strong); display: grid; place-items: center; color: var(--faint); cursor: pointer; padding: 0; }
.thumb.has { border-style: solid; border-color: var(--border); }
.prod .fields { display: grid; gap: 6px; grid-template-columns: 1fr 1fr; }
.prod .fields .name { grid-column: 1 / -1; font-weight: 600; }
.prod .fields .desc { grid-column: 1 / -1; min-height: 34px; }
.pics { display: grid; gap: 10px; grid-template-columns: repeat(auto-fill, minmax(110px, 1fr)); }
.pic { border: 1px solid var(--border); border-radius: 10px; overflow: hidden; background: var(--surface); display: flex; flex-direction: column; }
.pic .img { aspect-ratio: 1; background: #eef1f5 center / contain no-repeat; }
.pic .cap { padding: 6px 8px; font-size: .75rem; display: flex; flex-direction: column; gap: 4px; }
.pic .cap .fn { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); }
.pic.unused { border-color: #e9b949; }
.swatches { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.swatch { width: 30px; height: 30px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border-strong); cursor: pointer; padding: 0; }
.swatch.active { box-shadow: 0 0 0 2px var(--text); }
.picker-grid { display: grid; gap: 8px; grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
.picker-grid button { border: 2px solid transparent; border-radius: 10px; padding: 0; background: #eef1f5 center / contain no-repeat; aspect-ratio: 1; cursor: pointer; }
.picker-grid button:hover, .picker-grid button.active { border-color: var(--primary); }

/* ---------------------------------------------------------- catalogue editor extras */
.cat-editor-head { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; margin-bottom: 14px; }
.cat-editor-head .title-input { flex: 1 1 260px; font-size: 1.25rem; font-weight: 700; }
.prod .fields .full { grid-column: 1 / -1; }
.prod .fields > * { align-self: start; }
.field > .tabs { align-self: flex-start; }
.steps { margin: 6px auto 0; max-width: 560px; padding-left: 22px; color: var(--muted); display: flex; flex-direction: column; gap: 8px; }
.steps strong { color: var(--text); }
.menu-list { display: flex; flex-direction: column; gap: 6px; }
.menu-item { display: flex; gap: 12px; align-items: flex-start; text-align: left; width: 100%; padding: 12px; border: 1px solid var(--border); border-radius: var(--radius-sm); background: var(--surface); cursor: pointer; font: inherit; color: var(--text); }
.menu-item:hover { border-color: var(--primary); background: var(--primary-soft); }
.menu-item .icon { flex: none; margin-top: 2px; color: var(--primary); }
.menu-item span { display: flex; flex-direction: column; gap: 2px; }
.menu-item small { color: var(--muted); }
.menu-item.danger .icon, .menu-item.danger strong { color: var(--danger); }
.menu-item.danger:hover { border-color: var(--danger); background: #fdf0f0; }
.change-list { display: flex; flex-direction: column; max-height: 55vh; overflow: auto; border: 1px solid var(--border); border-radius: var(--radius-sm); }
.change-row { display: flex; gap: 10px; align-items: flex-start; padding: 10px 12px; border-top: 1px solid var(--border); cursor: pointer; }
.change-row:first-child { border-top: 0; }
.change-row input { margin-top: 4px; width: 18px; height: 18px; accent-color: var(--primary); flex: none; }
.change-row .before { color: var(--faint); text-decoration: line-through; overflow-wrap: anywhere; }
.change-row .after { font-weight: 600; overflow-wrap: anywhere; }
.color-input { width: 34px; height: 34px; border: 1px solid var(--border-strong); border-radius: 50%; padding: 0; background: none; cursor: pointer; }
.color-input::-webkit-color-swatch-wrapper { padding: 2px; }
.color-input::-webkit-color-swatch { border: 0; border-radius: 50%; }

/* ---------------------------------------------------------- login */
.login-wrap { min-height: 100vh; display: grid; place-items: center; padding: 20px; }
.login-card { width: min(400px, 100%); }
.login-card .brand { margin-bottom: 16px; }

/* ---------------------------------------------------------- the little heart and its page */
.love-link { color: #e0679a; }
.love-link .icon { fill: currentColor; stroke: none; width: 18px; height: 18px; transition: transform .2s; }
.love-link:hover { background: #fdeef5; }
.love-link:hover .icon { transform: scale(1.18); }
body.love-open { overflow: hidden; }
.love-page {
  position: fixed; inset: 0; z-index: 1000; overflow: hidden; display: grid; place-items: center;
  padding: calc(env(safe-area-inset-top) + 64px) 22px calc(env(safe-area-inset-bottom) + 40px);
  background: radial-gradient(circle at 50% 42%, #fff6fb 0%, #f6ecff 42%, #e6d8fb 100%);
}
.love-hearts { position: absolute; inset: 0; pointer-events: none; }
.love-heart {
  position: absolute; left: var(--x); bottom: -60px; width: var(--size); height: var(--size); opacity: 0;
  animation: love-rise var(--dur) linear forwards; will-change: transform, opacity;
}
.love-heart svg { display: block; width: 100%; height: 100%; animation: love-sway var(--sway) ease-in-out infinite alternate; }
.love-heart.still { animation: none; bottom: auto; top: var(--y); opacity: var(--alpha); transform: rotate(var(--rot)); }
.love-heart.still svg { animation: none; }
@keyframes love-rise {
  0% { transform: translateY(0) rotate(var(--rot)); opacity: 0; }
  8% { opacity: var(--alpha); }
  85% { opacity: var(--alpha); }
  100% { transform: translateY(calc(-100vh - 140px)) rotate(calc(var(--rot) * -1)); opacity: 0; }
}
@keyframes love-sway { from { transform: translateX(calc(var(--drift) * -1)); } to { transform: translateX(var(--drift)); } }
.love-content { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 30px; width: min(640px, 100%); text-align: center; }
.love-card {
  background: rgba(255, 255, 255, .84); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, .95); border-radius: 22px; padding: 26px 30px 28px;
  box-shadow: 0 18px 50px rgba(115, 86, 184, .22);
}
.love-card svg { display: block; width: 28px; height: 28px; margin: 0 auto 12px; }
.love-card p { margin: 0; font-family: Georgia, "Times New Roman", serif; font-size: clamp(1.05rem, 2.4vw, 1.3rem); line-height: 1.7; color: #3a2a55; }
.love-big {
  margin: 0; font-size: clamp(2.6rem, 11vw, 5.6rem); font-weight: 900; letter-spacing: .04em; line-height: 1.05; text-wrap: balance;
  background: linear-gradient(90deg, #d94f7c, #a35bd0, #7356b8); -webkit-background-clip: text; background-clip: text; color: transparent;
  filter: drop-shadow(0 6px 18px rgba(217, 79, 124, .25)); animation: love-beat 1.8s ease-in-out infinite;
}
@keyframes love-beat { 0%, 100% { transform: scale(1); } 14% { transform: scale(1.05); } 28% { transform: scale(1); } 42% { transform: scale(1.035); } 70% { transform: scale(1); } }
.love-back {
  position: absolute; z-index: 2; top: calc(env(safe-area-inset-top) + 14px); left: 14px;
  background: rgba(255, 255, 255, .8); border-color: rgba(115, 86, 184, .25); color: var(--primary-text);
}
@media (prefers-reduced-motion: reduce) { .love-big { animation: none; } }
