/* ABL Reader shell. Same accessibility rules as the reader itself:
   no dimmed text ever (hierarchy from size/weight), focus visible
   everywhere, 24px minimum targets, honors prefers-reduced-motion. */

:root {
    --bg: #101418;
    --surface: #1a2129;
    --surface-2: #232d38;
    --text: #f2f5f8;
    --accent: #35c5f0;
    --accent-strong: #7fdcf7;
    --danger: #ff7a85;
    --border: #46545f;
}

* { box-sizing: border-box; }

/* Author display rules (e.g. .login-wrap's flex) override the UA's
   [hidden]{display:none} — hidden must always win. */
[hidden] { display: none !important; }

/* Material Icons (Apache-2.0, bundled): the reader UI builds its buttons as
   Material Icons ligatures — inside Jellyfin the web client provided this
   font; standalone, the shell must. letter-spacing/transform resets keep
   reading-comfort settings from garbling the ligatures. */
@font-face {
    font-family: 'Material Icons';
    font-style: normal;
    font-weight: 400;
    src: url(/fonts/MaterialIcons-Regular.woff2) format('woff2');
}

.material-icons {
    font-family: 'Material Icons';
    font-weight: normal;
    font-style: normal;
    font-size: 24px;
    line-height: 1;
    letter-spacing: normal;
    text-transform: none;
    display: inline-block;
    white-space: nowrap;
    word-wrap: normal;
    direction: ltr;
    -webkit-font-feature-settings: 'liga';
    font-feature-settings: 'liga';
    -webkit-font-smoothing: antialiased;
}

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    line-height: 1.5;
}

button, input {
    font: inherit;
    color: inherit;
}

button {
    min-height: 40px;
    padding: 8px 16px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    cursor: pointer;
}

button:hover { background: #2c3946; }

:focus-visible {
    outline: 3px solid var(--accent-strong);
    outline-offset: 2px;
}

input:not([type="checkbox"]) {
    min-height: 40px;
    padding: 8px 10px;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: var(--bg);
    width: 100%;
    max-width: 320px;
}

input[type="checkbox"] { width: 20px; height: 20px; }

.visually-hidden {
    position: absolute;
    width: 1px; height: 1px;
    padding: 0; margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ── Login ─────────────────────────────────────────────────────────── */
.login-wrap {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.login-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 32px;
    width: 100%;
    max-width: 380px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.login-card h1 { margin: 0 0 4px; font-size: 1.6rem; }
.login-tag { margin: 0 0 16px; font-size: 0.95rem; }
.login-card label { font-weight: 600; margin-top: 8px; }
.login-card button { margin-top: 16px; background: var(--accent); color: #05252f; font-weight: 700; border: none; }
.login-card button:hover { background: var(--accent-strong); }
.login-error { color: var(--danger); font-weight: 600; min-height: 1.5em; margin: 8px 0 0; }

/* ── Shelf ─────────────────────────────────────────────────────────── */
.shelf-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    padding: 14px 20px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.shelf-header h1 { margin: 0; font-size: 1.25rem; }

.shelf-actions {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.who { font-weight: 600; }

.shelf-status { min-height: 1.5em; margin: 8px 20px 0; font-weight: 600; }

.shelf-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 18px;
    padding: 16px 20px 40px;
}

.book-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.book-open {
    display: block;
    width: 100%;
    padding: 0;
    border: none;
    border-radius: 0;
    background: none;
    text-align: left;
    cursor: pointer;
    min-height: 0;
}

.book-cover {
    width: 100%;
    aspect-ratio: 2 / 3;
    object-fit: cover;
    display: block;
    background: var(--surface-2);
}

.book-cover-fallback {
    width: 100%;
    aspect-ratio: 2 / 3;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px;
    background: linear-gradient(160deg, #24435a, #172834);
    text-align: center;
}

.book-cover-fallback .t { font-weight: 700; font-size: 1rem; overflow-wrap: anywhere; }
.book-cover-fallback .a { font-size: 0.85rem; }

.book-meta { padding: 10px 12px 6px; }
.book-meta .t { font-weight: 700; font-size: 0.95rem; overflow-wrap: anywhere; }
.book-meta .a { font-size: 0.85rem; }

.book-actions { display: flex; justify-content: flex-end; padding: 0 8px 8px; }
.book-del {
    min-height: 32px;
    padding: 4px 10px;
    font-size: 0.85rem;
    border-color: var(--danger);
    color: var(--danger);
    background: none;
}
.book-del:hover { background: rgba(255, 122, 133, 0.12); }

.shelf-empty { padding: 40px 20px; text-align: center; font-size: 1.05rem; }

/* ── Admin ─────────────────────────────────────────────────────────── */
.admin-main { padding: 16px 20px 60px; max-width: 1000px; margin: 0 auto; }
.admin-main section { margin-bottom: 40px; }

.table-wrap { overflow-x: auto; }

.admin-table { width: 100%; border-collapse: collapse; }
.admin-table th, .admin-table td {
    text-align: left;
    padding: 8px 10px;
    border-bottom: 1px solid var(--border);
}

.admin-table th.sortable { cursor: pointer; user-select: none; }
.admin-table th.sortable.sort-asc .sort-icon::after { content: " ▲"; font-size: 0.75em; }
.admin-table th.sortable.sort-desc .sort-icon::after { content: " ▼"; font-size: 0.75em; }

.user-create {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    max-width: 380px;
}
.user-create h3 { margin: 0 0 4px; }
.user-create label { font-weight: 600; margin-top: 6px; }
.user-create label.check { display: flex; align-items: center; gap: 8px; }
.user-create button { margin-top: 10px; align-self: flex-start; }

.badge {
    font-size: 0.75rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    vertical-align: middle;
}
.badge.on { background: rgba(53, 197, 240, 0.18); color: var(--accent-strong); border-color: var(--accent); }

.voice-toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
}
.voice-toolbar h3 { margin: 0; }
.voice-toolbar label { font-weight: 600; }
.voice-toolbar input { max-width: 260px; }

.voice-name-sub { display: block; font-size: 0.8em; }

.row-danger { color: var(--danger); font-weight: 600; }

@media (prefers-reduced-motion: reduce) {
    * { animation: none !important; transition: none !important; }
}
