/* ════════════════════════════════════════════════════════════════════
   eBook Manager — lw2-Design (angeglichen an LeewayBlazor / CryptData)
   Hell/Dunkel über CSS-Variablen. Blau als Akzent, Systemschrift.
   ════════════════════════════════════════════════════════════════════ */

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

.lw2 {
    /* Helles Theme (Standard) */
    --bg:          #f6f7f4;
    --card:        #ffffff;
    --border:      #e7e8e3;
    --text:        #1a1d1a;
    --text-soft:   #6b6f6a;
    --accent:      #2563eb;
    --accent-soft: #eff4ff;
    --pos:         #16a34a;
    --neg:         #dc2626;
    --tag-bg:      #eef1ee;
    --shadow:      0 1px 2px rgba(0,0,0,.04);

    /* Aliase auf die alten Variablennamen der App (damit bestehende Seiten mitziehen) */
    --surface:      var(--card);
    --surface2:     var(--tag-bg);
    --text2:        var(--text-soft);
    --accent-light: var(--accent-soft);
    --accent-dark:  #1d4ed8;
    --danger:       var(--neg);
    --danger-light: #fdf0ee;
    --amber:        #d4780f;
    --radius:       8px;
    --radius-lg:    12px;

    min-height: 100vh;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, "Segoe UI", system-ui, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

.lw2-dark {
    --bg:          #0f1311;
    --card:        #181d1a;
    --border:      #2a302c;
    --text:        #e8ebe7;
    --text-soft:   #9aa39c;
    --accent:      #3b82f6;
    --accent-soft: #16223b;
    --pos:         #22c55e;
    --neg:         #ef4444;
    --tag-bg:      #232a25;
    --shadow:      0 1px 2px rgba(0,0,0,.3);

    --surface:      var(--card);
    --surface2:     var(--tag-bg);
    --text2:        var(--text-soft);
    --accent-light: var(--accent-soft);
    --accent-dark:  #60a5fa;
    --danger:       var(--neg);
    --danger-light: #2a1416;
}

html, body { height: 100%; }
body { background: var(--bg); color: var(--text); font-family: -apple-system, "Segoe UI", system-ui, sans-serif; }

/* ── lw2 Topbar ─────────────────────────────────────────────────────── */
.lw2-topbar {
    display: flex; align-items: center; gap: 1.5rem;
    padding: .7rem 1.5rem;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 50;
}
.lw2-brand { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }
.lw2-logo-svg { display: block; flex-shrink: 0; }
.lw2-brandname { font-weight: 700; font-size: 1.1rem; letter-spacing: -.01em; }

.lw2-topsearch { flex: 1; max-width: 420px; position: relative; }
.lw2-topsearch input {
    width: 100%; padding: .5rem .75rem .5rem 2rem;
    border: 1px solid var(--border); border-radius: 999px;
    font-size: .9rem; background: var(--bg); color: var(--text);
    outline: none; transition: border-color .15s, background .15s;
}
.lw2-topsearch input:focus { border-color: var(--accent); background: var(--card); }
.lw2-topsearch-icon { position: absolute; left: .7rem; top: 50%; transform: translateY(-50%); font-size: .8rem; color: var(--text-soft); pointer-events: none; }

.lw2-actions { display: flex; gap: .5rem; align-items: center; margin-left: auto; }
.lw2-newbtn {
    border: none; background: var(--accent); color: #fff;
    padding: .5rem 1rem; border-radius: 8px;
    font-size: .9rem; font-weight: 600; cursor: pointer;
    transition: background .15s;
}
.lw2-newbtn:hover { background: var(--accent-dark); }
.lw2-iconbtn {
    border: 1px solid var(--border); background: var(--card); color: var(--text);
    width: 38px; height: 38px; border-radius: 10px; cursor: pointer;
    font-size: 1.05rem; transition: background .15s;
}
.lw2-iconbtn:hover { background: var(--tag-bg); }

.lw2-user {
    display: flex; align-items: center; gap: .5rem;
    padding: .25rem .5rem .25rem .25rem; border-radius: 999px;
    background: var(--tag-bg); max-width: 200px;
}
.lw2-user-avatar {
    width: 28px; height: 28px; flex-shrink: 0; border-radius: 50%;
    background: var(--accent); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: .85rem; font-weight: 700;
}
.lw2-user-name { font-size: .85rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lw2-logout-btn {
    display: flex; align-items: center; gap: .4rem;
    padding: .35rem .7rem; border-radius: 8px;
    border: 1px solid var(--border); background: var(--card); color: var(--text);
    font-size: .85rem; font-weight: 600; text-decoration: none; cursor: pointer;
}
.lw2-logout-btn:hover { background: var(--tag-bg); border-color: var(--neg); color: var(--neg); }
.lw2-logout-icon { font-size: 1rem; line-height: 1; }

@media (max-width: 900px) {
    .lw2-user-name { display: none; }
    .lw2-user { background: transparent; padding: 0; }
    .lw2-logout-text { display: none; }
    .lw2-logout-btn { padding: .35rem .5rem; }
    .lw2-topsearch { max-width: none; }
}

/* ── Body: Sidebar + Main ───────────────────────────────────────────── */
.lw2-shellbody { }
.ebm-body { display: flex; align-items: flex-start; }

.ebm-sidebar {
    width: 230px; min-width: 230px; flex-shrink: 0;
    background: var(--card); border-right: 1px solid var(--border);
    padding: 1.25rem 0; min-height: calc(100vh - 56px);
    position: sticky; top: 56px;
    overflow-y: auto; max-height: calc(100vh - 56px);
}
.ebm-side-section { margin-bottom: 1.25rem; }
.ebm-side-label {
    font-size: 10px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase;
    color: var(--text-soft); padding: 0 1.2rem; margin-bottom: 4px;
}
.ebm-side-item {
    display: flex; align-items: center; justify-content: space-between;
    padding: .5rem 1.2rem; font-size: .9rem; cursor: pointer;
    color: var(--text-soft); border-left: 3px solid transparent;
    transition: background .12s, color .12s; user-select: none;
    text-decoration: none;
}
.ebm-side-item:hover { background: var(--tag-bg); color: var(--text); }
.ebm-side-item.active { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); }
.ebm-count {
    font-size: 11px; background: var(--tag-bg); color: var(--text-soft);
    border-radius: 999px; padding: 1px 8px;
}
.ebm-side-item.active .ebm-count { background: var(--card); color: var(--accent); }
/* NavLink aktiv (Werkzeuge) */
.ebm-side-item.active, .ebm-side-item:global(.active) { color: var(--accent); border-left-color: var(--accent); background: var(--accent-soft); }

.ebm-main { flex: 1; overflow-y: auto; padding: 1.5rem 1.75rem; min-width: 0; }

@media (max-width: 720px) {
    .ebm-body { flex-direction: column; }
    .ebm-sidebar { width: 100%; min-width: 0; position: static; max-height: none; min-height: 0;
                   border-right: none; border-bottom: 1px solid var(--border); }
}

/* ── Stats ──────────────────────────────────────────────────────────── */
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin-bottom: 1.25rem; }
.stat-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; text-align: center; }
.stat-num { font-size: 26px; font-weight: 700; color: var(--accent); }
.stat-label { font-size: 12px; color: var(--text-soft); margin-top: 2px; }

/* ── Toolbar ────────────────────────────────────────────────────────── */
.toolbar { display: flex; align-items: center; gap: 10px; margin-bottom: 1.25rem; }
.toolbar-title { font-size: 17px; font-weight: 700; flex: 1; }
.sort-select { padding: 6px 10px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 13px; background: var(--card); color: var(--text); cursor: pointer; outline: none; }
.view-toggle { display: flex; gap: 2px; background: var(--tag-bg); border-radius: var(--radius); padding: 3px; }
.view-btn { width: 30px; height: 28px; display: flex; align-items: center; justify-content: center; border-radius: 6px; cursor: pointer; font-size: 14px; color: var(--text-soft); border: none; background: transparent; }
.view-btn.active { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }

/* ── Grid ───────────────────────────────────────────────────────────── */
.books-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(175px, 1fr)); gap: 1.1rem; }
.book-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); overflow: hidden; cursor: pointer; transition: box-shadow 0.15s, transform 0.15s; display: flex; flex-direction: column; }
.book-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.1); transform: translateY(-2px); }
.book-cover { height: 195px; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
.book-cover img { width: 100%; height: 100%; object-fit: cover; }
.book-cover-letter { font-size: 54px; font-weight: 700; opacity: 0.85; }
.book-info { padding: 11px; flex: 1; display: flex; flex-direction: column; gap: 3px; }
.book-title { font-size: 13px; font-weight: 700; line-height: 1.3; }
.book-author { font-size: 12px; color: var(--text-soft); }
.book-rating { display: flex; gap: 1px; margin-top: 2px; }
.star { font-size: 12px; color: #d4c49a; }
.star.filled { color: var(--amber); }
.book-tags { display: flex; flex-wrap: wrap; gap: 3px; margin-top: 4px; }
.tag { font-size: 10px; padding: 2px 7px; border-radius: 10px; background: var(--accent-soft); color: var(--accent); }
.progress-bar { background: var(--tag-bg); border-radius: 4px; height: 5px; overflow: hidden; margin-top: 5px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 4px; transition: width 0.3s; }
.read-badge { position: absolute; top: 7px; right: 7px; background: var(--accent); color: white; font-size: 10px; padding: 2px 7px; border-radius: 10px; }
.reading-badge { background: var(--amber) !important; }

/* ── List ───────────────────────────────────────────────────────────── */
.books-list { display: flex; flex-direction: column; gap: 7px; }
.book-row { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 11px 14px; display: flex; align-items: center; gap: 12px; cursor: pointer; transition: all 0.12s; }
.book-row:hover { box-shadow: var(--shadow); border-color: var(--accent); }
.book-row-thumb { width: 36px; height: 46px; border-radius: 4px; display: flex; align-items: center; justify-content: center; flex-shrink: 0; font-size: 17px; font-weight: 700; }
.book-row-info { flex: 1; min-width: 0; }
.book-row-title { font-size: 14px; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.book-row-meta { font-size: 12px; color: var(--text-soft); margin-top: 1px; }
.book-row-tags { display: flex; gap: 3px; margin-top: 4px; }
.book-row-actions { display: flex; gap: 5px; flex-shrink: 0; }

/* Cover-Farben (unverändert) */
.color-0 { background: #e8f4ee; color: #1a4a35; }
.color-1 { background: #e6f1fb; color: #0c447c; }
.color-2 { background: #faeeda; color: #633806; }
.color-3 { background: #fbeaf0; color: #72243e; }
.color-4 { background: #eeedfe; color: #3c3489; }
.color-5 { background: #e1f5ee; color: #085041; }
.color-6 { background: #faece7; color: #712b13; }
.color-7 { background: #eaf3de; color: #27500a; }

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn { padding: 7px 14px; border-radius: var(--radius); font-size: 13px; cursor: pointer; border: 1px solid var(--border); background: var(--card); color: var(--text); transition: all 0.12s; }
.btn:hover { background: var(--tag-bg); }
.btn-primary { background: var(--accent); color: white; border-color: var(--accent); }
.btn-primary:hover { background: var(--accent-dark); border-color: var(--accent-dark); }
.btn-danger { color: var(--danger); border-color: #f5c6c2; }
.btn-danger:hover { background: var(--danger-light); }

/* ── Modal ──────────────────────────────────────────────────────────── */
.modal-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,0.5); z-index: 500; display: flex; align-items: center; justify-content: center; padding: 1rem; }
.modal { background: var(--card, #ffffff); color: var(--text, #1a1a1a); border-radius: var(--radius-lg); width: 100%; max-width: 560px; max-height: 90vh; overflow-y: auto; box-shadow: 0 8px 40px rgba(0,0,0,0.2); }
.modal-header { padding: 1.1rem 1.4rem; border-bottom: 1px solid var(--border); display: flex; align-items: center; justify-content: space-between; }
.modal-title { font-size: 16px; font-weight: 700; }
.modal-close { width: 28px; height: 28px; border-radius: 50%; border: none; background: var(--tag-bg); font-size: 14px; cursor: pointer; display: flex; align-items: center; justify-content: center; color: var(--text-soft); }
.modal-close:hover { background: var(--border); }
.modal-body { padding: 1.25rem; display: flex; flex-direction: column; gap: 0.9rem; }
.modal-footer { padding: 0.9rem 1.4rem; border-top: 1px solid var(--border); display: flex; justify-content: flex-end; gap: 8px; }

/* ── Formulare ──────────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 4px; }
.form-group label { font-size: 12px; font-weight: 600; color: var(--text-soft); }
.form-group input, .form-group select, .form-group textarea {
    padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius);
    font-size: 14px; background: var(--bg); color: var(--text); outline: none;
    font-family: inherit;
}
.form-group input:focus, .form-group select:focus, .form-group textarea:focus { border-color: var(--accent); background: var(--card); }

/* Klappentext/Abstract: gut lesbar, zeigt die Absatz-Umbrüche aus StripHtml. */
.form-group textarea.synopsis-area {
    min-height: 180px; line-height: 1.55; white-space: pre-wrap;
    resize: vertical; font-size: 13.5px;
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem; }

/* ── Diverses (aus Alt-CSS übernommen, an Variablen angepasst) ──────── */
.ei-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.25rem; }
.ei-card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 1rem; }
.ei-icon { font-size: 28px; }
.ei-card-title { font-size: 16px; font-weight: 700; }
.ei-card-sub { font-size: 12px; color: var(--text-soft); }
.ei-action-btn { width: 100%; justify-content: center; margin-top: 4px; }
.ei-msg { padding: 10px 14px; border-radius: var(--radius); font-size: 13px; margin-top: 10px; background: var(--accent-soft); color: var(--accent); }
.ei-msg-ok { background: #e1f5ee; color: #085041; }
.isbn-row { display: flex; gap: 8px; }
.isbn-row input { flex: 1; padding: 8px 11px; border: 1px solid var(--border); border-radius: var(--radius); font-size: 14px; background: var(--bg); color: var(--text); outline: none; }
.isbn-btn { white-space: nowrap; }
.format-toggle { display: flex; gap: 2px; background: var(--tag-bg); border-radius: var(--radius); padding: 3px; }
.fmt-btn { flex: 1; padding: 7px 10px; border-radius: 6px; cursor: pointer; font-size: 13px; color: var(--text-soft); border: none; background: transparent; }
.fmt-btn.active { background: var(--card); color: var(--accent); box-shadow: var(--shadow); }

.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0,0,0,0); border: 0; }
.empty { text-align: center; color: var(--text-soft); padding: 3rem 1rem; }
.muted { color: var(--text-soft); }

/* PCloud-spezifisch */
.pcloud-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1rem; padding-bottom: .8rem; border-bottom: 1px solid var(--border); }
.pcloud-breadcrumb { display: flex; align-items: center; flex-wrap: wrap; margin-bottom: 1rem; font-size: 14px; }
.bc-link { color: var(--accent); cursor: pointer; }
.bc-link:hover { text-decoration: underline; }
.pcloud-file-list { display: flex; flex-direction: column; gap: 4px; }
.pcloud-file-row { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border: 1px solid var(--border); border-radius: var(--radius); cursor: pointer; background: var(--card); transition: all .12s; }
.pcloud-file-row:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.pcloud-file-icon { font-size: 20px; }
.pcloud-file-info { flex: 1; min-width: 0; }
.pcloud-file-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pcloud-file-meta { font-size: 12px; color: var(--text-soft); }
.pdf-row-highlight { border-color: var(--accent-soft); }

/* ── PCloud Verbindungsstatus ───────────────────────────────────────── */
.pcloud-status {
    display: flex; align-items: center; gap: .6rem;
    padding: .7rem 1rem; border-radius: var(--radius);
    border: 1px solid var(--border); background: var(--card);
    font-size: .9rem; font-weight: 600; margin-bottom: 1rem;
}
.pcloud-status-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.pcloud-status.connected .pcloud-status-dot { background: var(--pos); box-shadow: 0 0 0 3px rgba(22,163,74,.2); box-shadow: 0 0 0 3px color-mix(in srgb, var(--pos) 20%, transparent); }
.pcloud-status.disconnected .pcloud-status-dot { background: var(--text-soft); }
.pcloud-status.connected { border-color: #86c9a0; border-color: color-mix(in srgb, var(--pos) 40%, var(--border)); }
.btn-sm { padding: 4px 10px; font-size: 12px; }

/* ── Bibliothek verwalten ───────────────────────────────────────────── */
.lib-manage { max-width: 900px; }
.lib-header { margin-bottom: 1.25rem; }
.lib-title { font-size: 22px; font-weight: 700; }
.lib-sub { color: var(--text-soft); font-size: 14px; margin-top: 4px; }

.phase-counts { display: grid; grid-template-columns: repeat(7, 1fr); gap: 8px; margin-bottom: 1.5rem; }
.pc-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 6px; text-align: center; }
.pc-num { font-size: 22px; font-weight: 700; color: var(--accent); }
.pc-label { font-size: 11px; color: var(--text-soft); margin-top: 2px; }
@media (max-width: 720px) { .phase-counts { grid-template-columns: repeat(3, 1fr); } }

.phase-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 1.1rem 1.25rem; margin-bottom: 12px; }
.phase-card-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 1rem; }
.phase-step { font-size: 11px; font-weight: 700; letter-spacing: 1px; text-transform: uppercase; color: var(--accent); }
.phase-name { font-size: 16px; font-weight: 700; margin-top: 2px; }
.phase-desc { font-size: 13px; color: var(--text-soft); margin-top: 4px; max-width: 560px; }
.phase-status { margin-top: 10px; font-size: 13px; color: var(--text-soft); font-style: italic; }
.phase-card-disabled { opacity: 0.55; }

.scan-live { display: flex; flex-wrap: wrap; gap: 16px; margin-top: 10px; padding: 10px 12px;
             background: var(--accent-soft); border-radius: var(--radius); font-size: 13px; color: var(--text); }
.scan-live span { white-space: nowrap; }

/* ── Ordner-Wahl & Browser ─────────────────────────────────────────── */
.btn-ghost {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border);
}
.btn-ghost:hover:not(:disabled) { background: var(--accent-soft); }

.folder-select { margin-top: 14px; }
.folder-current {
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
    padding: 10px 12px; background: var(--card);
    border: 1px solid var(--border); border-radius: 8px;
}
.fc-label { color: var(--text-soft); font-size: 13px; }
.fc-path {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px; color: var(--text); font-weight: 600;
    flex: 1; word-break: break-all;
}

.folder-browser {
    margin-top: 10px; border: 1px solid var(--border);
    border-radius: 8px; overflow: hidden; background: var(--card);
}
.fb-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; flex-wrap: wrap;
    padding: 10px 12px; background: var(--accent-soft);
    border-bottom: 1px solid var(--border);
}
.fb-here {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 13px; font-weight: 600; color: var(--text);
    word-break: break-all;
}
.fb-actions { display: flex; gap: 8px; }

.fb-loading, .fb-empty, .fb-error { padding: 14px; font-size: 14px; color: var(--text-soft); }
.fb-error { color: #a93226; }

.fb-list { list-style: none; margin: 0; padding: 0; max-height: 320px; overflow-y: auto; }
.fb-item {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 12px; cursor: pointer;
    border-bottom: 1px solid var(--border);
}
.fb-item:last-child { border-bottom: none; }
.fb-item:hover { background: var(--accent-soft); }
.fb-icon { font-size: 15px; }
.fb-name { flex: 1; font-size: 14px; color: var(--text); }
.fb-enter { color: var(--text-soft); }

/* ── Phase 2: ISBN prüfen ──────────────────────────────────────────── */
.isbn-page { display: flex; flex-direction: column; height: 100%; }
.isbn-header { margin-bottom: 12px; }

.isbn-split {
    display: grid; grid-template-columns: minmax(360px, 1fr) 1.2fr;
    gap: 16px; flex: 1; min-height: 0;
}
@media (max-width: 900px) { .isbn-split { grid-template-columns: 1fr; } }

.isbn-left {
    display: flex; flex-direction: column; min-height: 0;
    border: 1px solid var(--border); border-radius: 10px;
    background: var(--card); overflow: hidden;
}
.isbn-list-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 12px; border-bottom: 1px solid var(--border);
    font-size: 13px; color: var(--text-soft);
}
.isbn-books { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; }
.isbn-book { border-bottom: 1px solid var(--border); }
.isbn-book.active { background: var(--accent-soft); }

.ib-row { display: flex; align-items: center; gap: 10px; padding: 10px 12px; cursor: pointer; }
.ib-row:hover { background: var(--accent-soft); }
.ib-status { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; background: var(--text-soft); }
.ib-status.ib-erfasst   { background: #9aa0a6; }
.ib-status.ib-zupruefen { background: #e8a13a; }
.ib-status.ib-keineisbn { background: #d9534f; }
.ib-name { font-size: 14px; color: var(--text); word-break: break-all; }

.ib-detail { padding: 4px 12px 14px 32px; }
.ib-analyzing { padding: 10px 0; color: var(--text-soft); font-size: 14px; }

.cand-label { font-size: 12px; color: var(--text-soft); margin: 10px 0 6px; font-weight: 600; }
.cand {
    border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 10px; margin-bottom: 8px; background: var(--bg);
}
.cand-main { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.cand-type {
    font-size: 11px; font-weight: 700; color: var(--accent);
    background: var(--accent-soft); padding: 2px 6px; border-radius: 4px;
}
.cand-value {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 14px; font-weight: 600; color: var(--text); flex: 1;
}
.cand-context {
    margin-top: 6px; font-size: 11px; color: var(--text-soft);
    font-style: italic; word-break: break-word;
}
.cand-none { color: var(--text-soft); font-size: 14px; padding: 8px 0; }

.cand-manual { display: flex; gap: 6px; align-items: center; margin-top: 10px; flex-wrap: wrap; }
.cand-input {
    flex: 1; min-width: 160px; padding: 6px 10px; font-size: 13px;
    border: 1px solid var(--border); border-radius: 6px;
    background: var(--card); color: var(--text);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
}

.isbn-right {
    border: 1px solid var(--border); border-radius: 10px;
    overflow: hidden; background: var(--card); min-height: 400px;
    display: flex;
}
.isbn-frame { width: 100%; height: 100%; border: 0; min-height: 400px; }
.isbn-frame-empty {
    margin: auto; text-align: center; color: var(--text-soft);
    padding: 2rem; font-size: 14px;
}
.isbn-frame-empty .empty-icon { font-size: 40px; margin-bottom: 10px; }

/* ── Phase 2: Diagnose Roh-Text ────────────────────────────────────── */
.raw-diag { margin-top: 12px; border-top: 1px dashed var(--border); padding-top: 8px; }
.raw-hint { font-size: 11px; color: var(--text-soft); margin: 6px 0; }
.raw-text {
    max-height: 260px; overflow: auto; margin: 0;
    padding: 10px; border-radius: 6px;
    background: var(--bg); border: 1px solid var(--border);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px; line-height: 1.5; color: var(--text);
    white-space: pre-wrap; word-break: break-word;
}

/* ── Phase 3: Metadaten ────────────────────────────────────────────── */
.ib-isbn {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px; color: var(--text-soft); margin-left: auto;
}
.meta-hit {
    border: 1px solid var(--border); border-radius: 8px;
    padding: 8px 10px; margin-bottom: 8px; background: var(--bg); cursor: pointer;
}
.meta-hit.sel { border-color: var(--accent); box-shadow: 0 0 0 1px var(--accent); }
.meta-hit:hover { border-color: var(--accent); }
.mh-top { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.mh-title { font-weight: 600; font-size: 14px; color: var(--text); }
.mh-sub { font-size: 12px; color: var(--text-soft); margin: 4px 0 8px; }

.meta-preview { display: flex; gap: 18px; padding: 18px; overflow-y: auto; }
.mp-cover { flex-shrink: 0; width: 160px; }
.mp-cover img { width: 100%; border-radius: 8px; box-shadow: 0 2px 12px rgba(0,0,0,.15); }
.mp-nocover {
    width: 160px; height: 220px; display: flex; align-items: center; justify-content: center;
    background: var(--bg); border: 1px dashed var(--border); border-radius: 8px;
    color: var(--text-soft); font-size: 13px;
}
.mp-info { flex: 1; min-width: 0; }
.mp-info h2 { margin: 0 0 2px; font-size: 20px; color: var(--text); }
.mp-subtitle { color: var(--text-soft); font-size: 14px; margin-bottom: 12px; }
.mp-table { width: 100%; border-collapse: collapse; font-size: 13px; margin-bottom: 12px; }
.mp-table th {
    text-align: left; color: var(--text-soft); font-weight: 500;
    padding: 4px 12px 4px 0; vertical-align: top; white-space: nowrap; width: 1%;
}
.mp-table td { padding: 4px 0; color: var(--text); word-break: break-word; }
.mp-desc {
    font-size: 13px; line-height: 1.6; color: var(--text);
    border-top: 1px solid var(--border); padding-top: 12px;
    max-height: 240px; overflow-y: auto;
}

.meta-diag {
    margin-top: 8px; padding: 8px 10px; border-radius: 6px;
    background: var(--bg); border: 1px solid var(--border);
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 11px; color: var(--text-soft); word-break: break-word;
}

.meta-btns { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 4px; }

/* Amazon-Button (Canopy) – dezent orange, damit er sich von den ISBN-Quellen abhebt. */
.meta-amazon {
    border-color: #f59e0b !important;
    color: #b45309 !important;
}
.meta-amazon:hover:not(:disabled) { background: #fff7ed !important; }

.meta-asin-line {
    margin: 4px 0; font-size: 12px; color: var(--text-soft);
}
.meta-asin-line code, .meta-asin-hint code {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    background: var(--bg); padding: 1px 5px; border-radius: 4px;
    border: 1px solid var(--border);
}
.meta-asin-hint {
    margin: 4px 0; font-size: 11px; color: var(--text-soft); font-style: italic;
}

/* QS Key-Check: fehlende ISBN/ASIN dezent rot markieren */
.qs-key-missing { color: #b91c1c; font-size: 12px; font-style: italic; }

/* ── Phase 4: Meine Bibliothek ─────────────────────────────────────── */
.mylib-controls {
    display: flex; gap: 10px; flex-wrap: wrap; align-items: center;
    margin-bottom: 20px;
}
.mylib-search {
    flex: 1; min-width: 240px; padding: 9px 14px; font-size: 14px;
    border: 1px solid var(--border); border-radius: 8px;
    background: var(--card); color: var(--text);
}
.mylib-filter {
    padding: 9px 12px; font-size: 13px; border: 1px solid var(--border);
    border-radius: 8px; background: var(--card); color: var(--text); cursor: pointer;
}

.mylib-grid {
    display: grid; gap: 20px;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
}
.book-card {
    position: relative; background: var(--card);
    border: 1px solid var(--border); border-radius: 10px; overflow: hidden;
    display: flex; flex-direction: column; transition: box-shadow .15s, transform .15s;
}
.book-card:hover { box-shadow: 0 6px 20px rgba(0,0,0,.12); transform: translateY(-2px); }

.bc-cover {
    position: relative; aspect-ratio: 2/3; background: var(--bg);
    cursor: pointer; overflow: hidden;
}
.bc-cover img { width: 100%; height: 100%; object-fit: cover; display: block; }
.bc-nocover {
    width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    padding: 12px; text-align: center; font-size: 13px; color: var(--text-soft);
}
.bc-open {
    position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
    background: rgba(0,0,0,.55); color: #fff; font-size: 14px; font-weight: 600;
    opacity: 0; transition: opacity .15s;
}
.bc-cover:hover .bc-open { opacity: 1; }

.bc-info { padding: 10px 12px; flex: 1; }
.bc-title {
    font-size: 14px; font-weight: 600; color: var(--text); line-height: 1.3;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.bc-author { font-size: 12px; color: var(--text-soft); margin-top: 3px;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bc-meta { font-size: 11px; color: var(--text-soft); margin-top: 4px; display: flex; gap: 4px; }

.bc-fav {
    position: absolute; top: 8px; right: 8px; z-index: 2;
    width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
    background: rgba(255,255,255,.9); color: #e8a13a; font-size: 18px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.bc-fav.on { color: #e8a13a; }
.bc-fav:hover { transform: scale(1.1); }

/* ── PDF-Viewer ────────────────────────────────────────────────────── */
.viewer-shell {
    display: flex; flex-direction: column;
    height: calc(100vh - 90px);   /* volle Höhe minus Topbar */
    min-height: 500px;
}
.viewer-toolbar {
    display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
    padding: 10px 4px 12px; border-bottom: 1px solid var(--border);
}
.viewer-book-info { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.viewer-title { font-size: 15px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.viewer-author { font-size: 12px; color: var(--text-soft); }
.viewer-actions { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.viewer-back-btn { white-space: nowrap; }
.progress-inline { display: flex; align-items: center; gap: 6px; }
.viewer-saved-msg { padding: 8px 4px; color: #2d6a4f; font-size: 13px; }

.viewer-frame-wrap {
    flex: 1; min-height: 0;    /* WICHTIG: erlaubt dem iframe, den Rest zu füllen */
    margin-top: 12px;
    border: 1px solid var(--border); border-radius: 8px; overflow: hidden;
    background: var(--card);
}
.viewer-frame {
    width: 100%; height: 100%; border: 0; display: block;
}

.meta-noisbn { font-size: 12px; color: #d9534f; margin-bottom: 6px; font-weight: 600; }
.meta-search { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 6px; }
.meta-search .cand-input { flex: 1; min-width: 120px; }

.bc-edit {
    position: absolute; top: 8px; left: 8px; z-index: 2;
    width: 32px; height: 32px; border-radius: 50%; border: none; cursor: pointer;
    background: rgba(255,255,255,.9); font-size: 15px; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.bc-edit:hover { transform: scale(1.1); }

.cand-finish {
    margin-top: 10px; padding-top: 10px; border-top: 1px dashed var(--border);
    display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
}
.cand-hint { font-size: 11px; color: var(--text-soft); }

/* ── BookModal: Metadaten-Bereich ──────────────────────────────────── */
.meta-box { background: var(--bg); border: 1px solid var(--border); border-radius: 8px; padding: 12px; }
.meta-title-row { display: flex; gap: 8px; margin-top: 8px; }
.meta-title-row input { flex: 1; min-width: 0; }
.meta-src-row { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; margin-top: 8px; }
.meta-src-label { font-size: 12px; color: var(--text-soft); margin-right: 2px; }
.isbn-btn { white-space: nowrap; }

.meta-hits { margin-top: 10px; max-height: 280px; overflow-y: auto;
    border: 1px solid var(--border); border-radius: 8px; background: var(--card); }
.meta-hit-row { display: flex; align-items: center; gap: 10px; padding: 8px 10px;
    border-bottom: 1px solid var(--border); cursor: pointer; }
.meta-hit-row:last-child { border-bottom: none; }
.meta-hit-row:hover { background: var(--accent-soft); }
.mh-thumb { width: 36px; height: 52px; object-fit: cover; border-radius: 3px; flex-shrink: 0; }
.mh-text { flex: 1; min-width: 0; }
.mh-t { font-size: 13px; font-weight: 600; color: var(--text);
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mh-a { font-size: 11px; color: var(--text-soft); }
.mh-src { display: inline-block; margin-left: 6px; padding: 1px 6px; border-radius: 4px;
    background: var(--accent-soft); color: var(--accent); font-size: 10px; font-weight: 600; }
.mh-pick { font-size: 11px; color: var(--accent); white-space: nowrap; }

.bc-shop { font-size: 11px; color: var(--text-soft); margin-top: 4px; }

.ib-shop { margin-left: auto; font-size: 11px; color: var(--text-soft); white-space: nowrap; padding-left: 8px; }

/* ── ISBN prüfen: Sortierung & Gruppierung ─────────────────────────── */
.isbn-sort { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; font-size: 12px; color: var(--text-soft); }
.isbn-sort select { padding: 4px 8px; border: 1px solid var(--border); border-radius: 6px;
    background: var(--card); color: var(--text); font-size: 12px; }
.isbn-group-toggle { display: flex; align-items: center; gap: 4px; cursor: pointer; white-space: nowrap; }
.isbn-group-head { list-style: none; padding: 8px 10px 4px; font-size: 12px; font-weight: 700;
    color: var(--accent); border-top: 1px solid var(--border); margin-top: 4px; position: sticky; top: 0;
    background: var(--bg); }
.isbn-group-count { color: var(--text-soft); font-weight: 400; }

.ib-name-wrap { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.ib-path { font-size: 10px; color: var(--text-soft); opacity: .8; white-space: nowrap;
    overflow: hidden; text-overflow: ellipsis; font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }

.meta-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin-bottom: 10px;
    padding-bottom: 10px; border-bottom: 1px dashed var(--border); }

/* ── ISBN prüfen: Cover-Thumbnail pro Kandidat ─────────────────────── */
.cand-main { display: flex; align-items: center; gap: 10px; }
.cand-cover { width: 40px; height: 58px; object-fit: cover; border-radius: 3px;
    background: var(--bg); border: 1px solid var(--border); flex-shrink: 0; }
.cand-cover-none { visibility: hidden; position: relative; }
.cand-cover-none::after { content: "?"; visibility: visible; position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    color: var(--text-soft); font-size: 18px; background: var(--bg);
    border: 1px dashed var(--border); border-radius: 3px; }
.cand-info { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }

.cover-upload { display: block; margin-top: 4px; font-size: 13px; }

/* ── Meine Bibliothek: Tabellenansicht (Syncfusion Grid) ───────────── */
.mylib-viewtoggle { margin-left: auto; }
.mylib-table { margin-top: 8px; }
.grid-cover { width: 32px; height: 46px; object-fit: cover; border-radius: 3px;
    border: 1px solid var(--border); display: block; }
.grid-cover-none { display: flex; align-items: center; justify-content: center;
    color: var(--text-soft); background: var(--bg); font-size: 14px; }

/* ── Lesestatus-Badge in der Tabellenansicht ──────────────────────── */
.status-badge {
    display: inline-block; padding: .15rem .55rem; border-radius: 999px;
    font-size: .78rem; font-weight: 600; white-space: nowrap;
}
.status-unread  { background: #e5e7eb; color: #374151; }
.status-reading { background: #dbeafe; color: #1d4ed8; }
.status-read    { background: #dcfce7; color: #15803d; }
.lw2-dark .status-unread  { background: #374151; color: #d1d5db; }
.lw2-dark .status-reading { background: #1e3a5f; color: #93c5fd; }
.lw2-dark .status-read    { background: #14532d; color: #86efac; }

/* ── "Weitere Treffer laden" bei der Titelsuche ───────────────────── */
.meta-loadmore {
    display: block; width: 100%; margin-top: 8px;
    border: 1px dashed var(--border, #cbd5e1); background: transparent;
}
.meta-loadmore:hover:not(:disabled) { border-style: solid; }

/* ── Nachgeladener Buchtitel beim ISBN-Kandidaten ─────────────────── */
.cand-booktitle {
    display: block; margin-top: 3px; font-size: 13px; font-weight: 600;
    color: var(--text, #1f2937);
}

/* ── QS (Qualitätssicherung): Bücher ohne Cover ────────────────────── */
.qs-bar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; margin: 8px 0 14px; }
.qs-count { font-size: 13px; color: var(--text-soft); margin-left: auto; }
.qs-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.qs-table thead th { text-align: left; padding: 8px 10px; border-bottom: 2px solid var(--border);
    color: var(--text-soft); font-weight: 600; white-space: nowrap; }
.qs-th-sort { cursor: pointer; user-select: none; }
.qs-th-sort:hover { color: var(--accent); }
.qs-table tbody td { padding: 8px 10px; border-bottom: 1px solid var(--border); vertical-align: middle; }
.qs-table tbody tr:hover { background: var(--accent-soft); }
.qs-title { font-weight: 600; color: var(--text); max-width: 460px;
    overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ── QS: Reiter-Umschaltung + Duplikate ────────────────────────────── */
.qs-tabs { display: flex; gap: 8px; margin: 6px 0 14px; }
.qs-tab { padding: 6px 14px; border: 1px solid var(--border); border-radius: 8px;
    background: var(--card); color: var(--text-soft); cursor: pointer; font-size: 13px; }
.qs-tab:hover { color: var(--accent); }
.qs-tab.active { background: var(--accent); color: #fff; border-color: var(--accent); }

.qs-dupe-group { border: 1px solid var(--border); border-radius: 10px; margin-bottom: 14px; overflow: hidden; }
.qs-dupe-head { display: flex; align-items: center; gap: 10px; padding: 8px 12px;
    background: var(--accent-soft); border-bottom: 1px solid var(--border); }
.qs-dupe-reason { font-weight: 700; font-size: 12px; color: var(--accent);
    background: var(--card); padding: 2px 8px; border-radius: 6px; }
.qs-dupe-key { font-size: 13px; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qs-dupe-count { margin-left: auto; font-size: 12px; color: var(--text-soft); white-space: nowrap; }
.qs-dupe-path { font-size: 11px; color: var(--text-soft); font-family: ui-monospace, monospace;
    max-width: 260px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.qs-dupe-group .qs-table tbody tr:last-child td { border-bottom: none; }

/* ── Sidebar: einklappbare Genres/Tags ─────────────────────────────── */
.ebm-side-collapsible { margin-top: 6px; border-top: 1px solid var(--border); padding-top: 6px; }
.ebm-side-summary { cursor: pointer; user-select: none; list-style: none; display: flex;
    align-items: center; gap: 6px; padding: 4px 0; }
.ebm-side-summary::-webkit-details-marker { display: none; }
.ebm-side-summary::before { content: "▸"; font-size: 11px; transition: transform .15s; color: var(--text-soft); }
.ebm-side-collapsible[open] > .ebm-side-summary::before { transform: rotate(90deg); }
.ebm-side-summary:hover { color: var(--accent); }

/* ── Meine Bibliothek: 3-Wege-Umschalter ───────────────────────────── */
.mylib-viewtoggle { display: inline-flex; margin-left: auto; border: 1px solid var(--border);
    border-radius: 8px; overflow: hidden; }
.mylib-viewbtn { border: none; background: var(--card); color: var(--text-soft);
    padding: 5px 12px; font-size: 13px; cursor: pointer; border-right: 1px solid var(--border); }
.mylib-viewbtn:last-child { border-right: none; }
.mylib-viewbtn:hover { color: var(--accent); }
.mylib-viewbtn.active { background: var(--accent); color: #fff; }

/* ── Kleine-Bilder-Ansicht (nur Cover) ─────────────────────────────── */
.mylib-smallgrid { display: grid; gap: 10px; margin-top: 8px;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr)); }
.sc-item { cursor: pointer; aspect-ratio: 2 / 3; border-radius: 6px; overflow: hidden;
    border: 1px solid var(--border); background: var(--bg); transition: transform .12s, box-shadow .12s; }
.sc-item:hover { transform: translateY(-2px); box-shadow: 0 4px 12px rgba(0,0,0,.18); }
.sc-item img { width: 100%; height: 100%; object-fit: cover; display: block; }
.sc-nocover { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center;
    text-align: center; font-size: 11px; padding: 6px; color: var(--text-soft); overflow: hidden; }

/* ── Metadaten-Treffer: passenden Titel hervorheben ────────────────── */
.meta-hit-match { background: var(--accent-soft); border-left: 3px solid var(--accent); }
.meta-hit-match .mh-t, .meta-hit-match .mh-title { font-weight: 700; color: var(--accent); }

.qs-isbn { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; color: var(--text-soft); white-space: nowrap; }

/* ── Treffer-ISBN + Abgleich mit gesuchter ISBN ────────────────────── */
.mh-isbn { font-size: 11px; font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: var(--text-soft); margin-top: 2px; }
.mh-isbn-none { font-style: italic; }
.mh-isbn-match { color: #16a34a; font-weight: 700; }
.mh-isbn-match span { margin-left: 6px; }
