/* Leonardo Library -- Favorites Shelf. Phone-first, reuses the shared "qm-"
   design (from Poems/Quotes) so the Library reads as one system. A favorite is
   just a link to an item on another shelf, grouped by that shelf. */

:root {
    --qm-ink:    #1d2330;
    --qm-muted:  #6b7280;
    --qm-line:   #e6e8ef;
    --qm-bg:     #f4f5f9;
    --qm-card:   #ffffff;
    --qm-accent: #c9a227;   /* library gold -- Favorites is the "keeper" shelf */
    --qm-accent2:#5b4bd6;
    --qm-danger: #c2384a;
}

* { box-sizing: border-box; }

body {
    background: var(--qm-bg);
    color: var(--qm-ink);
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Fixed-viewport shell: pins .qm-top (Leonardo menu band + stats + filters);
   only .qm-body scrolls, so the chrome never scrolls off. Ref compensation.html. */
.qm-shell { display: flex; flex-direction: column; height: 100vh; height: 100dvh; overflow: hidden; }

/* ---- top ---------------------------------------------------------------- */
.qm-top { background: #2f2a52; color: #fff; flex: 0 0 auto; }
.lw-nav { min-height: 6px; }

.qm-stats { display: flex; gap: 0; padding: 6px 8px; }
.qm-stat {
    flex: 1 1 0; min-width: 56px; text-align: center;
    padding: 3px 2px; border-right: 1px solid rgba(255,255,255,.16);
}
.qm-stat:last-child { border-right: none; }
.qm-stat .n { font-size: 16px; font-weight: 700; display: block; line-height: 1.1; }
.qm-stat .l { font-size: 9px; text-transform: uppercase; letter-spacing: .5px; color: #cfc9f2; }

/* ---- action buttons ----------------------------------------------------- */
.qm-actions {
    display: flex; gap: 7px; padding: 9px 10px; flex-wrap: wrap;
    background: #fff; border-bottom: 1px solid var(--qm-line);
}
.qm-btn {
    font: inherit; font-size: 13px; font-weight: 600;
    border: 1px solid var(--qm-line); border-radius: 999px;
    background: #fff; color: var(--qm-ink);
    padding: 8px 13px; cursor: pointer;
    display: inline-flex; align-items: center; gap: 6px;
    transition: background .12s, border-color .12s, transform .05s;
    text-decoration: none;
}
.qm-btn:hover { background: #faf4de; border-color: #e6d69a; }
.qm-btn:active { transform: scale(.97); }
.qm-btn.primary { background: var(--qm-accent); border-color: var(--qm-accent); color: #3a2f04; }
.qm-btn.primary:hover { background: #b8931f; }
.qm-btn .ic { font-size: 15px; line-height: 1; }

/* ---- body / groups / cards ---------------------------------------------- */
.qm-body { flex: 1; min-height: 0; overflow-y: auto; padding: 8px 10px 90px; }

.qm-group { border: 1px solid var(--qm-line); border-radius: 12px; background: #fff; margin-bottom: 10px; overflow: hidden; }
.qm-group-h { display: flex; align-items: center; gap: 8px; padding: 12px 14px; cursor: pointer; user-select: none; background: #fbf8ec; }
.qm-group-h .chev { transition: transform .15s; color: var(--qm-accent); font-size: 12px; }
.qm-group.open .qm-group-h .chev { transform: rotate(90deg); }
.qm-group-h .t { font-size: 14px; font-weight: 800; color: #8a6d10; }
.qm-group-h .c { margin-left: auto; font-size: 11px; color: var(--qm-muted); background: #f3ecd3; padding: 1px 9px; border-radius: 999px; }
.qm-group-body { display: none; padding: 8px 10px 10px; }
.qm-group.open .qm-group-body { display: block; }

.fav-card {
    background: var(--qm-card);
    border: 1px solid var(--qm-line);
    border-left: 4px solid var(--qm-accent);
    border-radius: 10px;
    padding: 12px 14px 8px;
    margin: 0 0 9px;
    box-shadow: 0 1px 2px rgba(20,20,50,.04);
}
.fav-card:last-child { margin-bottom: 0; }

/* Story 5757: a card folds to its title line by its head; Fold All in the action row. */
.fav-head { display: flex; align-items: baseline; gap: 6px; cursor: pointer; }
.fav-chev { flex: 0 0 auto; width: 14px; color: var(--qm-accent); font-size: 11px; user-select: none; }
.fav-card.collapsed { padding-bottom: 12px; }
.fav-card.collapsed .fav-body { display: none; }
.qm-foldall[hidden] { display: none; }
.fav-card.missing { border-left-color: #b9b9c2; opacity: .82; }

.fav-title {
    display: inline-block;
    font-size: 16px; font-weight: 700; color: var(--qm-accent2);
    text-decoration: none; word-break: break-word; line-height: 1.3;
}
.fav-title:hover { text-decoration: underline; }
.fav-sub { font-size: 13px; color: #3a3f4b; margin-top: 3px; line-height: 1.45; word-break: break-word; }
.fav-notes { font-size: 12px; color: var(--qm-muted); font-style: italic; margin-top: 8px; }
.fav-missing { display: inline-block; margin-top: 6px; font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; background: #f1eef6; color: #7a7690; padding: 2px 8px; border-radius: 999px; }

.qm-cardactions { display: flex; gap: 6px; justify-content: flex-end; margin-top: 6px; padding-top: 6px; border-top: 1px dashed #eef0f6; }
.qm-icobtn {
    border: none; background: transparent; cursor: pointer;
    font-size: 18px; line-height: 1; padding: 8px 11px; border-radius: 8px; color: var(--qm-muted);
    min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center;
}
.qm-icobtn:hover { background: #f4f0e2; }
.qm-icobtn.del:hover { background: #fdecef; color: var(--qm-danger); }

.qm-empty { text-align: center; color: var(--qm-muted); padding: 50px 20px; font-size: 14px; }
.qm-empty .big { font-size: 40px; display: block; margin-bottom: 8px; opacity: .5; }

/* ---- floating add ------------------------------------------------------- */
.qm-fab {
    position: fixed; right: 18px; bottom: 22px; z-index: 60;
    width: 56px; height: 56px; border-radius: 50%; border: none; cursor: pointer;
    background: var(--qm-accent); color: #3a2f04; font-size: 28px; line-height: 1;
    box-shadow: 0 6px 18px rgba(201,162,39,.45);
}
.qm-fab:active { transform: scale(.94); }

/* ---- modal -------------------------------------------------------------- */
.qm-overlay { position: fixed; inset: 0; z-index: 100; background: rgba(20,18,40,.55); display: none; align-items: flex-end; justify-content: center; }
.qm-overlay.show { display: flex; }
.qm-modal { background: #fff; width: 100%; max-width: 620px; max-height: 92vh; overflow-y: auto; border-radius: 18px 18px 0 0; padding: 16px 16px 22px; box-shadow: 0 -8px 30px rgba(0,0,0,.25); }
@media (min-width: 640px) { .qm-overlay { align-items: center; } .qm-modal { border-radius: 16px; } }
.qm-modal h2 { margin: 2px 0 6px; font-size: 17px; }
.fav-help { margin: 0 0 6px; font-size: 12px; color: var(--qm-muted); line-height: 1.5; }

.qm-field { margin-top: 12px; }
.qm-field label { display: block; font-size: 12px; font-weight: 600; color: var(--qm-muted); margin-bottom: 5px; }
.qm-field input[type=text], .qm-field select, .qm-field textarea {
    width: 100%; box-sizing: border-box;
    padding: 11px 12px; font: inherit; font-size: 15px;
    border: 1px solid var(--qm-line); border-radius: 10px; outline: none; background: #fff;
}
.qm-field textarea { resize: vertical; min-height: 64px; line-height: 1.5; }
.qm-field .ps-select {
    width: 100%; box-sizing: border-box; padding: 11px 12px; font: inherit; font-size: 15px;
    border: 1px solid var(--qm-line); border-radius: 10px; background: #fff;
}
.qm-field .ps-select:focus, .qm-field .ps-select.is-open { border-color: var(--qm-accent2); box-shadow: 0 0 0 3px rgba(91,75,214,.15); }
.qm-field input:focus, .qm-field select:focus, .qm-field textarea:focus { border-color: var(--qm-accent2); box-shadow: 0 0 0 3px rgba(91,75,214,.15); }
.qm-field .hint { font-size: 11px; color: var(--qm-muted); margin-top: 4px; }

/* PicassoVoice wraps text inputs in an inline-block .voice-mic-wrap span, which
   collapses width:100% to intrinsic width. Force block in this form's contexts. */
.qm-field .voice-mic-wrap { display: block; width: 100%; }

.qm-dupwarn { display: none; margin-top: 10px; padding: 10px 12px; background: #fff5e0; border: 1px solid #f0d28a; border-radius: 10px; font-size: 13px; color: #8a5b00; }
.qm-dupwarn.show { display: block; }

.qm-modal-btns { display: flex; gap: 8px; margin-top: 16px; }
.qm-modal-btns .qm-btn { flex: 1; justify-content: center; padding: 11px; }

.qm-statusbar { background: #232733; color: #aeb4c2; padding: 5px 12px; font-size: 11px; }
