/* Quotes Manager (Story 2196) -- phone-first collection view, redesigned per
   Tony comments 3457/3458: id-based authors/topics, multi-category tags,
   collapsible groups, full-width stacked form fields, no title chrome. */

:root {
    --qm-ink:      #1d2330;
    --qm-muted:    #6b7280;
    --qm-line:     #e6e8ef;
    --qm-bg:       #f4f5f9;
    --qm-card:     #ffffff;
    --qm-accent:   #5b4bd6;
    --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 (no title/tagline -- just the nav band anchor + slim stats) ----- */
.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: #f3f1fd; border-color: #d7d0f7; }
.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: #4a3bc4; }
.qm-btn .ic { font-size: 15px; line-height: 1; }

/* ---- search + filter (collapsible, all full-width) ---------------------- */
.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(91,75,214,.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; }

/* ---- 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: #faf9ff;
}
.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: #efe9ff; 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 .qt {
    font-family: Georgia, "Times New Roman", serif;
    font-size: 16px; line-height: 1.5; color: #20242e;
    white-space: pre-wrap; word-break: break-word;
}

/* bottom meta line: author left, category badges right-aligned, same line */
.qm-meta {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 10px; flex-wrap: wrap; margin-top: 8px;
}
.qm-meta-left { font-size: 13px; color: #3a3f4b; }
.qm-meta-left .auth { font-weight: 700; }
.qm-meta-left .auth::before { content: "\2014 "; color: var(--qm-muted); font-weight: 400; }
.qm-meta-left .dot { color: var(--qm-line); margin: 0 6px; }
.qm-meta-left .dt, .qm-meta-left .src { font-size: 11px; color: var(--qm-muted); }
.qm-meta-left .src { font-style: italic; }
.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: #efe9ff; color: var(--qm-accent); padding: 2px 8px; border-radius: 999px;
}

/* actions on their own row -- never overlay the quote */
.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;          /* phone-friendly tap target */
    display: inline-flex; align-items: center; justify-content: center;
}
.qm-icobtn:hover { background: #f1eefc; }
.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(91,75,214,.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; }

/* every field on its own line, label above, control full width */
.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=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(--qm-line); border-radius: 10px; outline: none; background: #fff;
}
.qm-field textarea { resize: none; min-height: 56px; line-height: 1.5; overflow: hidden; }
.qm-field input:focus, .qm-field select:focus, .qm-field textarea:focus { border-color: var(--qm-accent); box-shadow: 0 0 0 3px rgba(91,75,214,.15); }
.qm-field .hint { font-size: 11px; color: var(--qm-muted); margin-top: 4px; }
.qm-field .addnew { margin-top: 8px; }

/* 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 Quotes form/filter context so fields truly span the full row. */
.qm-field .voice-mic-wrap,
.qm-filters .voice-mic-wrap,
.qm-tagaddrow .voice-mic-wrap { display: block; width: 100%; }

/* The PicassoPicker dropdown (the standard typeahead) sits in a full-width wrap;
   the category add row keeps its input flexible next to the Add button. */
.qm-filters .picker-wrap { width: 100%; }
.qm-tagaddrow .picker-wrap input.picker-input { width: 100%; }

/* category multi-tag editor */
.qm-tagedit { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.qm-tagedit .picked { display: inline-flex; align-items: center; gap: 5px; background: #efe9ff; 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 input { flex: 1; }
.qm-tagaddrow .qm-btn { flex: 0 0 auto; }

.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-modal-btns .qm-btn:disabled { opacity: .4; cursor: default; pointer-events: none; }

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

/* import preview */
.qm-imp-hint { font-size: 12px; color: var(--qm-muted); margin: 2px 0 8px; }
.qm-imp-summary { font-size: 13px; font-weight: 600; margin: 12px 0 6px; }
.qm-cand { border: 1px solid var(--qm-line); border-radius: 10px; padding: 10px; margin-bottom: 8px; background: #fcfcff; display: flex; gap: 10px; align-items: flex-start; }
.qm-cand.dup { background: #fff5f5; border-color: #f0c7cd; }
.qm-cand input[type=checkbox] { margin-top: 3px; width: 18px; height: 18px; }
.qm-cand .cbody { flex: 1; }
.qm-cand .ctext { font-family: Georgia, serif; font-size: 14px; line-height: 1.4; }
.qm-cand .cfields { display: flex; gap: 8px; margin-top: 6px; }
.qm-cand .cfields input { flex: 1; font-size: 12px; padding: 6px 8px; border: 1px solid var(--qm-line); border-radius: 8px; }
.qm-cand .dupflag { display: inline-block; font-size: 10px; font-weight: 700; color: var(--qm-danger); text-transform: uppercase; letter-spacing: .4px; }

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

/* ---- Leonardo Dictionary specifics --------------------------------------- */
.qm-card .lx-term {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 16px; font-weight: 700; color: var(--qm-accent); margin-bottom: 3px;
    word-break: break-word;
}
.qm-card .qt::before, .qm-card .qt::after { content: ""; }   /* no quote marks on definitions */
.qm-card .qt { font-size: 14.5px; color: #2a2f3a; }
.qm-spotlight .sterm { font-family: -apple-system, "Segoe UI", sans-serif; font-size: 18px; font-weight: 700; color: var(--qm-accent); margin-bottom: 8px; }

/* favorite star on the Surprise spotlight (Story 2227) */
.qm-spotlight { position: relative; }
.qm-spot-star {
    position: absolute; top: 0; right: 0;
    border: none; background: transparent; cursor: pointer;
    font-size: 24px; line-height: 1; padding: 4px 6px; color: var(--qm-muted);
    min-width: 40px; min-height: 40px;
}
.qm-spot-star.on { color: var(--qm-gold); }

/* manage-categories modal (Story 2227) */
.qm-cats-hint { font-size: 12px; color: var(--qm-muted); margin: 2px 0 6px; }
.qm-catlist { display: flex; flex-direction: column; gap: 6px; max-height: 60vh; overflow-y: auto; }
.qm-catrow {
    display: flex; align-items: center; gap: 10px;
    padding: 8px 10px; border: 1px solid var(--qm-line); border-radius: 10px; background: #fff;
}
.qm-catname { flex: 1; font-size: 14px; color: var(--qm-ink); word-break: break-word; }
.qm-catcount { font-size: 11px; color: var(--qm-muted); white-space: nowrap; }
/* 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; }
