/* Leonardo Library -- Review shelf (Story 2350). Phone-first, mirroring the
   Movies / Poems / Quotes "qm-" design so the Library reads as one system.

   A review card leads with the REVIEW's title and verdict, then names the WORK
   being reviewed and its author on a separate line -- the two are different
   things and the card never blurs them. Below that: the findings (conclusions),
   the tags, and the linked full text. */

:root {
    --qr-ink:     #1d2330;
    --qr-muted:   #6b7280;
    --qr-line:    #e6e8ef;
    --qr-bg:      #f4f5f9;
    --qr-card:    #ffffff;
    --qr-accent:  #8a5a2b;   /* review-desk sepia -- distinct from Movies red / Research indigo */
    --qr-accent2: #66401d;
    --qr-tint:    #f7efe5;
    --qr-gold:    #f0a500;
    --qr-danger:  #c2384a;
    --qr-work:    #2f6b5f;   /* the WORK being reviewed reads in a second colour */
}

* { box-sizing: border-box; }

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

/* Fixed-viewport shell: pins .qm-top (Leonardo Main Menu Tool Bar Strip + stats
   + filters); only .qm-body scrolls, so the chrome never scrolls off. 100dvh is
   the one that matters on a phone -- plain 100vh is the URL-bar-EXPANDED height,
   which overflows the visible viewport and slides the icon band off the top.
   The 100vh line stays as the fallback for browsers that predate dvh. */
.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: 52px; 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; }

/* ---- toolbar / options -------------------------------------------------- */
.qm-actions {
    display: flex; gap: 7px; padding: 9px 10px; flex-wrap: wrap;
    background: #fff; border-bottom: 1px solid var(--qr-line);
}
.qm-btn {
    font: inherit; font-size: 13px; font-weight: 600;
    border: 1px solid var(--qr-line); border-radius: 999px;
    background: #fff; color: var(--qr-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: var(--qr-tint); border-color: #ddc6a8; }
.qm-btn:active { transform: scale(.97); }
.qm-btn.primary { background: var(--qr-accent); border-color: var(--qr-accent); color: #fff; }
.qm-btn.primary:hover { background: var(--qr-accent2); }
.qm-btn .ic { font-size: 15px; line-height: 1; }
.qm-btn.tiny { font-size: 11px; padding: 4px 10px; gap: 4px; }
.qm-btn.tiny .ic { font-size: 12px; }

/* ---- search + filter ---------------------------------------------------- */
.qm-searchbar {
    display: flex; align-items: center; gap: 8px;
    padding: 9px 10px; background: #fff; border-bottom: 1px solid var(--qr-line);
    cursor: pointer; font-size: 13px; font-weight: 600; color: var(--qr-ink);
}
.qm-searchbar .chev { margin-left: auto; transition: transform .15s; color: var(--qr-muted); }
.qm-searchbar.open .chev { transform: rotate(180deg); }
.qm-searchbar .activedot { display: none; width: 8px; height: 8px; border-radius: 50%; background: var(--qr-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(--qr-line);
}
.qm-filters.open { display: flex; }
.qm-filters label { font-size: 11px; font-weight: 600; color: var(--qr-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(--qr-line); border-radius: 10px; background: #fff; outline: none;
}
.qm-filters input:focus, .qm-filters select:focus { border-color: var(--qr-accent); box-shadow: 0 0 0 3px rgba(138,90,43,.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(--qr-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(--qr-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(--qr-muted); }
.qm-seg { display: inline-flex; border: 1px solid var(--qr-line); border-radius: 999px; overflow: hidden; background: #fff; flex-wrap: wrap; }
.qm-seg button { font: inherit; font-size: 12px; font-weight: 600; border: none; background: transparent; color: var(--qr-muted); padding: 6px 11px; cursor: pointer; }
.qm-seg button.on { background: var(--qr-accent); color: #fff; }

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

.qm-group { border: 1px solid var(--qr-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: var(--qr-tint); }
.qm-group-h .chev { transition: transform .15s; color: var(--qr-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(--qr-accent); }
.qm-group-h .c { margin-left: auto; font-size: 11px; color: var(--qr-muted); background: #eedfc9; 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(--qr-card);
    border: 1px solid var(--qr-line);
    border-left: 4px solid var(--qr-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; }

.rv-title {
    font-size: 17px; font-weight: 700; color: var(--qr-accent); margin-bottom: 2px;
    word-break: break-word; cursor: pointer; user-select: none;
}
/* Grouped, the title is not a toggle -- normal cursor, and text stays selectable. */
.rv-title[data-nofold] { cursor: default; user-select: text; }
.rv-stars { color: var(--qr-gold); letter-spacing: 1px; font-size: 14px; margin-left: 6px; }

/* A folded card shows nothing but its own title row -- the chevron points
   right when folded and down when open, matching the group bands. */
.rv-title .fchev {
    display: inline-block; width: 12px; margin-right: 6px; font-size: 11px;
    color: var(--qr-accent); transform: rotate(90deg); transition: transform .15s;
}
.qm-card.folded .rv-title .fchev { transform: rotate(0deg); }
/* Screen only -- print always renders the whole review, folded or not, so the
   hidden rows must not carry into the print stylesheet. */
@media screen {
    .qm-card.folded { padding-bottom: 12px; }
    .qm-card.folded > *:not(.rv-title) { display: none; }
    .qm-card.folded .rv-title { margin-bottom: 0; }
}

/* The verdict is the one-line judgment -- the card's hook. */
.rv-verdict { font-size: 14px; line-height: 1.45; color: #20242e; font-style: italic; margin: 4px 0 8px; word-break: break-word; }

/* The WORK being reviewed gets its own tinted strip so it never reads as part
   of the review's own title. */
.rv-work {
    background: #f1f7f5; border-left: 3px solid var(--qr-work); border-radius: 0 8px 8px 0;
    padding: 6px 10px; margin-bottom: 8px;
}
.rv-work .wt { font-size: 13.5px; font-weight: 700; color: var(--qr-work); word-break: break-word; }
.rv-work .wm { font-size: 11.5px; color: var(--qr-muted); margin-top: 1px; }
.rv-work .wm .sep { opacity: .5; margin: 0 5px; }

.rv-byline { font-size: 12px; color: var(--qr-muted); margin-bottom: 6px; }
.rv-byline .who { font-weight: 700; color: #3a3f4b; }

/* ---- conclusions on the card -------------------------------------------- */
.rv-conclusions { margin-top: 8px; border-top: 1px dashed #eef0f6; padding-top: 8px; }
.rv-conclusions .ch {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
    color: var(--qr-muted); margin-bottom: 5px; display: flex; align-items: center; gap: 6px;
}
.rv-conclusions .ch .n { background: #eedfc9; color: var(--qr-accent2); padding: 1px 7px; border-radius: 999px; }
.rv-conc { display: flex; gap: 7px; align-items: flex-start; padding: 3px 0; font-size: 13.5px; line-height: 1.45; }
.rv-conc .bul { color: var(--qr-accent); flex: 0 0 auto; line-height: 1.45; }
.rv-conc.starred .bul { color: var(--qr-gold); }
.rv-conc .tx { word-break: break-word; }
.rv-conc .cf {
    font-size: 9px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
    padding: 1px 6px; border-radius: 999px; margin-left: 5px; white-space: nowrap;
    background: #eef1f7; color: #40506a; vertical-align: middle;
}
.rv-conc .cf.certain   { background: #e3f3ea; color: #1f6b45; }
.rv-conc .cf.confident { background: #e8f0fb; color: #274c86; }
.rv-conc .cf.leaning   { background: #fdf1de; color: #8a5b00; }
.rv-conc .cf.tentative { background: #f3eef7; color: #5c4b7a; }
.rv-more {
    display: inline-block; margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--qr-accent);
    background: none; border: none; cursor: pointer; padding: 4px 0;
}

.rv-notes { font-size: 12px; color: var(--qr-muted); font-style: italic; margin-top: 8px; }

.rv-tagrows { margin-top: 8px; display: flex; flex-direction: column; gap: 4px; }
.rv-tagline { display: flex; gap: 5px; flex-wrap: wrap; align-items: baseline; }
.rv-tagline .k { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; color: var(--qr-muted); min-width: 62px; }
.qm-tag { font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px; background: #eedfc9; color: var(--qr-accent2); padding: 2px 8px; border-radius: 999px; }
.qm-tag.who { background: #eef1f7; color: #40506a; }

/* ---- linked files ------------------------------------------------------- */
.rv-files { margin-top: 8px; display: flex; flex-wrap: wrap; gap: 6px; }
/* A button, not a link -- the Leonardo Files endpoint is authenticated, so the
   file is fetched through LWAuth rather than navigated to. font/cursor have to
   be set explicitly because a <button> does not inherit them. */
.rv-file {
    display: inline-flex; align-items: center; gap: 6px; text-decoration: none;
    font: inherit; font-size: 12px; font-weight: 600; color: var(--qr-accent2);
    background: var(--qr-tint); border: 1px solid #e4d3ba; border-radius: 999px; padding: 4px 11px;
    max-width: 100%; cursor: pointer; text-align: left;
}
.rv-file:hover { background: #f0e2cd; }
.rv-file .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 220px; }

.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(--qr-muted);
    min-width: 40px; min-height: 40px; display: inline-flex; align-items: center; justify-content: center;
}
.qm-icobtn:hover { background: var(--qr-tint); }
.qm-icobtn.star.on { color: var(--qr-gold); }
.qm-icobtn.del:hover { background: #fdecef; color: var(--qr-danger); }

.qm-empty { text-align: center; color: var(--qr-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(--qr-accent); color: #fff; font-size: 28px; line-height: 1;
    box-shadow: 0 6px 18px rgba(138,90,43,.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: 660px; 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; }

/* A labelled band inside the editor, so "the review" and "the work being
   reviewed" are visibly two different sections of the same form. */
.qm-fieldset { border: 1px solid var(--qr-line); border-radius: 12px; padding: 4px 12px 14px; margin-top: 14px; }
.qm-fieldset > legend {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .6px;
    color: var(--qr-muted); padding: 0 6px;
}
.qm-fieldset.work { border-color: #cfe3dd; background: #fbfefd; }
.qm-fieldset.work > legend { color: var(--qr-work); }

.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(--qr-muted); margin-bottom: 5px; }
.qm-field input[type=text], .qm-field input[type=date], .qm-field select, .qm-field textarea {
    width: 100%; box-sizing: border-box;
    padding: 11px 12px; font: inherit; font-size: 15px;
    border: 1px solid var(--qr-line); border-radius: 10px; outline: none; background: #fff;
}
.qm-field textarea { resize: vertical; min-height: 90px; 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(--qr-line); border-radius: 10px; background: #fff;
}
.qm-field .ps-select:focus, .qm-field .ps-select.is-open { border-color: var(--qr-accent); box-shadow: 0 0 0 3px rgba(138,90,43,.15); }
.qm-field input:focus, .qm-field select:focus, .qm-field textarea:focus { border-color: var(--qr-accent); box-shadow: 0 0 0 3px rgba(138,90,43,.15); }
.qm-field .hint { font-size: 11px; color: var(--qr-muted); margin-top: 4px; }
.qm-field label .req {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
    color: var(--qr-accent); margin-left: 4px;
}
.qm-fielderr { display: none; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--qr-danger); }
.qm-fielderr.show { display: block; }
.pt-wrap.invalid .pt-box { border-color: var(--qr-danger); box-shadow: 0 0 0 3px rgba(194,56,74,.14); }

.qm-fieldrow { display: flex; gap: 10px; margin-top: 12px; }
.qm-fieldrow .qm-field { flex: 1; margin-top: 0; }

/* PicassoVoice wraps text inputs in an inline-block .voice-mic-wrap span, which
   collapses width:100% to the intrinsic content width. Force it to block in
   every Review 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; }

.rv-checkline { display: flex; align-items: center; gap: 8px; font-size: 14px; color: var(--qr-ink); }
.rv-checkline input { width: 18px; height: 18px; }

/* ---- read-only review view ---------------------------------------------- */
.pv-scroll { padding: 4px 2px 2px; }
.pv-head { text-align: center; border-bottom: 1px solid var(--qr-line); padding-bottom: 14px; margin-bottom: 16px; }
.pv-title { font-size: 22px; font-weight: 800; color: var(--qr-accent); line-height: 1.25; word-break: break-word; }
.pv-fav { color: var(--qr-gold); font-size: 18px; }
.pv-verdict { font-size: 15px; font-style: italic; color: #20242e; margin-top: 8px; line-height: 1.5; }
.pv-rating { color: var(--qr-gold); font-size: 15px; letter-spacing: 2px; margin-top: 6px; }
.pv-section { margin-top: 16px; }
.pv-section .h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--qr-muted); margin-bottom: 5px; }
.pv-summary { font-size: 15.5px; line-height: 1.55; color: #20242e; white-space: pre-wrap; word-break: break-word; }
.pv-notes { font-size: 13px; color: var(--qr-muted); font-style: italic; }
.pv-tags { display: flex; gap: 5px; flex-wrap: wrap; }

/* the reviewed work, in the read-only view */
.pv-work { background: #f1f7f5; border-left: 3px solid var(--qr-work); border-radius: 0 10px 10px 0; padding: 10px 12px; }
.pv-work .wt { font-size: 16px; font-weight: 700; color: var(--qr-work); word-break: break-word; }
.pv-work .wr { font-size: 12.5px; color: var(--qr-muted); margin-top: 3px; }
.pv-work .wr b { color: #3a3f4b; font-weight: 700; }

/* conclusion rows in the view + the manage-conclusions editor */
.pv-conc { display: flex; gap: 9px; align-items: flex-start; padding: 8px 0; border-bottom: 1px dashed #eef0f6; }
.pv-conc:last-child { border-bottom: none; }
.pv-conc .bul { color: var(--qr-accent); font-size: 15px; line-height: 1.45; flex: 0 0 auto; }
.pv-conc.starred .bul { color: var(--qr-gold); }
.pv-conc .bd { flex: 1; min-width: 0; }
.pv-conc .tx { font-size: 14.5px; line-height: 1.5; color: #20242e; word-break: break-word; }
.pv-conc .dt { font-size: 12.5px; line-height: 1.5; color: var(--qr-muted); margin-top: 3px; white-space: pre-wrap; word-break: break-word; }
.pv-conc .rowacts { display: flex; gap: 2px; flex: 0 0 auto; }
.pv-conc .rowacts .qm-icobtn { font-size: 15px; min-width: 32px; min-height: 32px; padding: 5px 7px; }

.rv-conclist { max-height: 46vh; overflow-y: auto; border: 1px solid var(--qr-line); border-radius: 10px; padding: 4px 10px; }
.rv-conclist .qm-empty { padding: 22px 10px; }

/* Arrange the findings (Story 5757): grips only while arranging; rows shrink to their text. */
.rv-conc-h { display: flex; align-items: center; gap: 8px; }
.rv-conc-h .rv-arrange { margin-left: auto; font-size: 12px; padding: 5px 11px; }
.rv-conc-h .rv-arrange[hidden] { display: none; }
.rv-conc-h .rv-arrange.on { background: var(--qr-accent); border-color: var(--qr-accent); color: #fff; }
.pv-conc .rv-grip { display: none; }
.rv-arranging .pv-conc .rv-grip {
    display: inline-flex; align-items: center; justify-content: center; flex: 0 0 auto;
    min-width: 30px; min-height: 30px; cursor: grab; color: var(--qr-muted);
    touch-action: none; user-select: none; font-size: 15px; letter-spacing: -3px;
}
.rv-arranging .pv-conc .dt,
.rv-arranging .pv-conc .rowacts { display: none; }
.rv-arranging .pv-conc { align-items: center; padding: 5px 0; }
.pv-conc.rv-dragging-source { background: var(--qr-tint); opacity: .85; }
body.rv-dragging { user-select: none; cursor: grabbing; }

/* linked-file rows in the view */
.pv-filerow { display: flex; align-items: center; gap: 8px; padding: 7px 0; border-bottom: 1px dashed #eef0f6; }
.pv-filerow:last-child { border-bottom: none; }
.pv-filerow .fn { flex: 1; min-width: 0; font-size: 13.5px; font-weight: 600; color: var(--qr-accent2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pv-filerow .cap { font-size: 11px; color: var(--qr-muted); font-weight: 400; }

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

/* Print: drop every control and print the reviews as a document. */
@media print {
    .qm-top, .qm-toolbar, .qm-options, .qm-searchbar, .qm-filters,
    .qm-statusbar, .qm-fab, .qm-cardactions, .rv-more { display: none !important; }
    .qm-shell { height: auto; overflow: visible; }
    .qm-body { overflow: visible; padding: 0; }
    .qm-card { break-inside: avoid; box-shadow: none; }
    .rv-title .fchev { display: none; }
}
/* Story 6820: Reader and Listen buttons */
.pr-btns { display: inline-flex; gap: 6px; flex-wrap: wrap; }
.qm-cardactions .pr-btns { margin-left: 6px; }
.qm-readbtn { border: 1px solid #d8d4e6; background: #fff; border-radius: 7px; padding: 4px 9px; font-size: 12px; font-weight: 600; cursor: pointer; color: inherit; }
