/* Leonardo Library -- Movies shelf (Story 2295). Phone-first, mirrors the
   Poems/Books/Quotes "qm-" design so the Library reads as one system. A movie
   card shows the title + year, director, rating, a plot summary, and its genre
   and cast tags. */

:root {
    --qm-ink:    #1d2330;
    --qm-muted:  #6b7280;
    --qm-line:   #e6e8ef;
    --qm-bg:     #f4f5f9;
    --qm-card:   #ffffff;
    --qm-accent: #b5483d;   /* cinema red -- distinguishes Movies from Poems (purple) */
    --qm-accent2:#7a2f28;
    --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.
   100dvh (dynamic viewport height) is the one that matters on a phone: plain
   100vh is the URL-bar-EXPANDED height, so the shell overflows the visible
   viewport, the page itself scrolls, and the Leonardo Main Menu tool bar strip
   slides off the top. dvh tracks the real visible height; the 100vh line stays
   as the fallback for browsers that predate it. */
.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: #fbeeec; border-color: #e6c3bd; }
.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: var(--qm-accent2); }
.qm-btn .ic { font-size: 15px; line-height: 1; }
/* One tiny toggle instead of a pair of full-size Expand all / Collapse all
   buttons -- the group bar is a phone row and the pair ate most of it. */
.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(--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(181,72,61,.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; }

/* ---- 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: #fdf4f3; }
.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: #f6e2df; 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; }

/* Collapsible title cards -- the "Group by None" view. The title row is the
   toggle; a closed card shows only that row, an open one shows the full card. */
.qm-card.mv-col .mv-colh { display: flex; align-items: center; gap: 8px; cursor: pointer; user-select: none; }
.qm-card.mv-col .mv-colh .chev { flex: 0 0 auto; transition: transform .15s; color: var(--qm-accent); font-size: 12px; }
.qm-card.mv-col.open .mv-colh .chev { transform: rotate(90deg); }
.qm-card.mv-col .mv-colh .mv-title { margin-bottom: 0; }
.qm-card.mv-col:not(.open) .mv-byline,
.qm-card.mv-col:not(.open) .mv-summary,
.qm-card.mv-col:not(.open) .mv-more,
.qm-card.mv-col:not(.open) .mv-notes,
.qm-card.mv-col:not(.open) .mv-watched,
.qm-card.mv-col:not(.open) .mv-tagrows,
.qm-card.mv-col:not(.open) .qm-cardactions { display: none; }
/* A closed card is a single tight title row -- drop the extra bottom padding. */
.qm-card.mv-col:not(.open) { padding-bottom: 12px; }

.mv-title {
    font-size: 17px; font-weight: 700; color: var(--qm-accent); margin-bottom: 2px;
    word-break: break-word;
}
.mv-title .yr { color: var(--qm-muted); font-weight: 600; font-size: 14px; }
.mv-byline { font-size: 13px; color: #3a3f4b; margin-bottom: 6px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mv-byline .dir { font-weight: 700; }
.mv-byline .dir::before { content: "\2014 "; color: var(--qm-muted); font-weight: 400; }
.mv-byline .stars { color: var(--qm-gold); letter-spacing: 1px; }

.mv-summary {
    font-size: 14.5px; line-height: 1.5; color: #20242e;
    white-space: pre-wrap; word-break: break-word;
    max-height: 6.5em; overflow: hidden; position: relative;
    transition: max-height .2s ease;
}
.mv-summary.expanded { max-height: 4000px; }
.mv-summary.clipped::after {
    content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 2.2em;
    background: linear-gradient(rgba(255,255,255,0), #fff);
}
.mv-more {
    display: none; margin-top: 4px; font-size: 12px; font-weight: 700; color: var(--qm-accent);
    background: none; border: none; cursor: pointer; padding: 4px 0;
}
.mv-more.show { display: inline-block; }

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

/* Dates watched: one line on the card, a list in the view, chips in the editor. */
.mv-watched { font-size: 12px; color: var(--qm-muted); margin-top: 6px; }
.mv-watched b { color: #3a3f4b; font-weight: 700; }
.mv-watchadd { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; }
.mv-watchadd input[type="date"] { flex: 1 1 150px; min-width: 0; }
.mv-watchlist { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.mv-watchlist:empty { display: none; }
.mv-watchchip { display: inline-flex; align-items: center; gap: 4px; font-size: 12px; font-weight: 600; background: #eef1f7; color: #40506a; padding: 3px 4px 3px 10px; border-radius: 999px; }
.mv-watchchip button { border: none; background: none; color: #8a93a6; font-size: 14px; line-height: 1; cursor: pointer; padding: 2px 6px; }
.pv-watched { display: flex; flex-direction: column; gap: 2px; font-size: 13.5px; color: #20242e; }

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

.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;
}
.qm-icobtn:hover { background: #fbeeec; }
.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(181,72,61,.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 input[type=number], .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: 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(--qm-line); border-radius: 10px; background: #fff;
}
.qm-field .ps-select:focus, .qm-field .ps-select.is-open { border-color: var(--qm-accent); box-shadow: 0 0 0 3px rgba(181,72,61,.15); }
.qm-field input:focus, .qm-field select:focus, .qm-field textarea:focus { border-color: var(--qm-accent); box-shadow: 0 0 0 3px rgba(181,72,61,.15); }
.qm-field .hint { font-size: 11px; color: var(--qm-muted); margin-top: 4px; }
.qm-field label .req {
    font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: .4px;
    color: var(--qm-accent); margin-left: 4px;
}
/* Field-level validation message -- hidden until the save is blocked. */
.qm-fielderr { display: none; margin-top: 6px; font-size: 12px; font-weight: 600; color: var(--qm-danger); }
.qm-fielderr.show { display: block; }
.pt-wrap.invalid .pt-box { border-color: var(--qm-danger); box-shadow: 0 0 0 3px rgba(194,56,74,.14); }

/* two fields side by side (Year + Rating) */
.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 the wrap to block
   in every Movies 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; }

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

/* ---- read-only movie view ----------------------------------------------- */
.pv-scroll { padding: 4px 2px 2px; }
.pv-head { text-align: center; border-bottom: 1px solid var(--qm-line); padding-bottom: 14px; margin-bottom: 16px; }
.pv-title { font-size: 22px; font-weight: 800; color: var(--qm-accent); line-height: 1.25; word-break: break-word; }
.pv-title .yr { color: var(--qm-muted); font-weight: 600; font-size: 17px; }
.pv-fav { color: var(--qm-gold); font-size: 18px; }
.pv-byline { font-size: 14px; color: #3a3f4b; margin-top: 6px; }
.pv-byline .dir { font-weight: 700; }
.pv-rating { color: var(--qm-gold); font-size: 15px; letter-spacing: 2px; margin-top: 6px; }
.pv-section { margin-top: 14px; }
.pv-section .h { font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: .5px; color: var(--qm-muted); margin-bottom: 4px; }
.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(--qm-muted); font-style: italic; }
.pv-src { font-size: 12px; color: var(--qm-muted); font-style: italic; }
.pv-tags { display: flex; gap: 5px; flex-wrap: wrap; }

/* spotlight (random) */
.qm-spotlight { text-align: center; padding: 8px 6px 4px; }
.qm-spotlight .sa { font-size: 17px; font-weight: 700; color: var(--qm-accent); }
.qm-spotlight .st { font-size: 12px; color: var(--qm-muted); margin-top: 4px; }
.qm-spotlight .sq { font-size: 15px; line-height: 1.55; color: #20242e; margin: 10px 0; white-space: pre-wrap; text-align: left; }

.qm-statusbar { background: #232733; color: #aeb4c2; padding: 5px 12px; font-size: 11px; }
/* 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; }
