/* Leonardo Library -- Web Links shelf. Phone-first, mirrors the Poems/Quotes
   "qm-" design so the Library reads as one system. */

:root {
    --qm-ink:    #1d2330;
    --qm-muted:  #6b7280;
    --qm-line:   #e6e8ef;
    --qm-bg:     #f4f5f9;
    --qm-card:   #ffffff;
    --qm-accent: #1f6f8b;
    --qm-gold:   #f0a500;
    --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: #eef6f9; border-color: #bcd9e4; }
.qm-btn:active { transform: scale(.97); }
.qm-btn.primary { background: var(--qm-accent); border-color: var(--qm-accent); color: #fff; }
.qm-btn.primary:hover { background: #175a71; }
.qm-btn .ic { font-size: 15px; line-height: 1; }

/* ---- search + filter ---------------------------------------------------- */
.qm-searchbar {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 10px; background: #fff; border-bottom: 1px solid var(--qm-line);
    cursor: pointer; font-size: 13px; font-weight: 600; color: var(--qm-ink);
}
.qm-searchbar .chev { margin-left: auto; transition: transform .15s; color: var(--qm-muted); }
.qm-searchbar.open .chev { transform: rotate(180deg); }
.qm-searchbar .activedot { display: none; width: 8px; height: 8px; border-radius: 50%; background: var(--qm-accent); }
.qm-searchbar.filtered .activedot { display: inline-block; }

.qm-filters {
    display: none; flex-direction: column; gap: 10px;
    padding: 12px 10px; background: #fff; border-bottom: 1px solid var(--qm-line);
}
.qm-filters.open { display: flex; }
.qm-filters label { font-size: 11px; font-weight: 600; color: var(--qm-muted); margin-bottom: -4px; }
.qm-filters input, .qm-filters 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; outline: none;
}
.qm-filters input:focus, .qm-filters select:focus { border-color: var(--qm-accent); box-shadow: 0 0 0 3px rgba(31,111,139,.15); }
.qm-filters .favrow { display: flex; align-items: center; gap: 8px; }
.qm-filters .favrow input { width: 20px; height: 20px; }
.qm-filters .favrow label { margin: 0; font-size: 14px; color: var(--qm-ink); }
.qm-filters .clearrow { display: flex; justify-content: flex-end; gap: 8px; }
.qm-filters .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;
}

/* ---- group-by bar ------------------------------------------------------- */
.qm-groupbar { display: flex; align-items: center; gap: 8px; padding: 8px 10px; flex-wrap: wrap; }
.qm-groupbar .lbl { font-size: 12px; color: var(--qm-muted); }
.qm-seg { display: inline-flex; border: 1px solid var(--qm-line); border-radius: 999px; overflow: hidden; background: #fff; }
.qm-seg button { font: inherit; font-size: 12px; font-weight: 600; border: none; background: transparent; color: var(--qm-muted); padding: 6px 11px; cursor: pointer; }
.qm-seg button.on { background: var(--qm-accent); color: #fff; }
.qm-sortsel, .qm-groupbar .ps-select {
    font: inherit; font-size: 12px; font-weight: 600; color: var(--qm-ink);
    border: 1px solid var(--qm-line); border-radius: 999px; background: #fff;
    padding: 6px 11px; cursor: pointer; outline: none;
}
.qm-sortsel:focus, .qm-groupbar .ps-select:focus { border-color: var(--qm-accent); box-shadow: 0 0 0 3px rgba(31,111,139,.15); }

/* byline author + date sit alongside the type chip / host (flex, gap handles spacing) */
.qm-card .wl-author { font-weight: 600; color: var(--qm-ink); }
.qm-card .wl-date { color: var(--qm-muted); }

/* 1-5 star rating row under the byline */
.qm-card .wl-ratingrow { margin: -2px 0 6px; }
.qm-card .wl-rating { color: var(--qm-gold); font-size: 14px; letter-spacing: 1px; }

/* card action row: Open on the left, spacer pushes the icon buttons to the right */
.qm-card .wl-actionspacer { flex: 1 1 auto; }
.qm-card .wl-open { padding: 6px 12px; font-size: 12px; }
.qm-card .wl-open .ic { font-size: 13px; }

/* ---- body / groups / cards ---------------------------------------------- */
.qm-body { flex: 1; min-height: 0; overflow-y: auto; padding: 6px 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: #f5fafc; }
.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: var(--qm-accent); }
.qm-group-h .c { margin-left: auto; font-size: 11px; color: var(--qm-muted); background: #e2f0f5; padding: 1px 9px; border-radius: 999px; }
.qm-group-body { display: none; padding: 8px 10px 10px; }
.qm-group.open .qm-group-body { display: block; }

.qm-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);
}
.qm-card:last-child { margin-bottom: 0; }

.qm-card .wl-title { margin-bottom: 2px; word-break: break-word; }
.qm-card .wl-title a {
    font-size: 17px; font-weight: 700; color: var(--qm-accent); text-decoration: none;
}
.qm-card .wl-title a:hover { text-decoration: underline; }
.qm-card .wl-byline { font-size: 12.5px; color: var(--qm-muted); margin-bottom: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.qm-card .wl-type {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
    background: var(--qm-accent); color: #fff; padding: 2px 8px; border-radius: 999px;
}
.qm-card .wl-host { word-break: break-all; }
.qm-card .wl-notes { font-size: 13px; color: #3a3f4b; margin-top: 4px; white-space: pre-wrap; word-break: break-word; }

.qm-meta { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.qm-meta-right { display: flex; gap: 5px; flex-wrap: wrap; justify-content: flex-end; margin-left: auto; }
.qm-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; background: #e2f0f5; color: var(--qm-accent); 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: 19px; 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;
    text-decoration: none;
}
.qm-icobtn:hover { background: #eaf4f8; }
.qm-icobtn.star.on { color: var(--qm-gold); }
.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: #fff; font-size: 28px; line-height: 1;
    box-shadow: 0 6px 18px rgba(31,111,139,.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 12px; font-size: 17px; display: flex; align-items: center; gap: 8px; }

.qm-field { margin-top: 12px; }
.qm-field:first-of-type { margin-top: 4px; }
.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: 84px; line-height: 1.5; }
.qm-field input:focus, .qm-field select:focus, .qm-field textarea:focus { border-color: var(--qm-accent); box-shadow: 0 0 0 3px rgba(31,111,139,.15); }
.qm-field .hint { font-size: 11px; color: var(--qm-muted); margin-top: 4px; }
.qm-field .picker-wrap { position: relative; }

/* multi-select chip editors (Authors, Categories) -- mirrors the Quotes shelf */
.qm-tagedit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: 24px; }
.qm-tagedit .picked { display: inline-flex; align-items: center; gap: 5px; background: #e2f0f5; color: var(--qm-accent); font-size: 13px; font-weight: 600; padding: 5px 10px; border-radius: 999px; }
.qm-tagedit .picked .x { cursor: pointer; font-weight: 700; }
.qm-tagaddrow { display: flex; gap: 8px; margin-top: 8px; }
.qm-tagaddrow .picker-wrap { flex: 1; }
.qm-tagaddrow .picker-wrap input.picker-input { width: 100%; }
.qm-tagaddrow .qm-btn { flex: 0 0 auto; }
.qm-tagaddrow .voice-mic-wrap { display: block; width: 100%; }

/* PicassoVoice wraps text inputs in an inline-block .voice-mic-wrap span, which
   collapses width:100% to the intrinsic content width. Force the wrap to block
   in every Web Links form/filter context so fields truly span the full row. */
.qm-field .voice-mic-wrap,
.qm-filters .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; }
