/* biblio.bond mobile companion — Light library theme */

/* =========================================
   CSS Variables
   ========================================= */
:root {
    --bg: #f5f5f5;
    --surface: #ffffff;
    --surface-hover: #fafafa;
    --border: #e8e8e8;
    --border-light: #f0f0f0;
    --text: #333333;
    --text-secondary: #666666;
    --text-muted: #999999;
    --primary: #4a90e2;
    --primary-light: #e8f0fe;
    --primary-dark: #3a7bd5;
    --success: #27ae60;
    --success-light: #e8f8f0;
    --warning: #f39c12;
    --warning-light: #fef9e7;
    --stamp: #9b59b6;
    --stamp-light: #f3e8f9;
    --book-brown: #8b7355;
    --book-light: #f5f0eb;
    --danger: #e74c3c;

    --tab-height: 56px;
    --status-height: 48px;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    --radius: 10px;
    --radius-sm: 6px;
    --radius-lg: 14px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.12);

    --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* =========================================
   Reset & Base
   ========================================= */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html, body {
    height: 100%;
    overflow: hidden;
    font-family: var(--font);
    font-size: 16px;
    line-height: 1.5;
    color: var(--text);
    background: var(--bg);
    -webkit-text-size-adjust: 100%;
    overscroll-behavior: none;
}

input, button, textarea, select {
    font-family: inherit;
    font-size: inherit;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* =========================================
   Status Bar (top)
   ========================================= */
#status-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: calc(var(--status-height) + var(--safe-top));
    padding-top: var(--safe-top);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-left: 14px;
    padding-right: 14px;
}

.status-left {
    display: flex;
    align-items: center;
    gap: 8px;
}

.status-logo {
    font-size: 1.25rem;
}

.status-title {
    font-weight: 700;
    font-size: 1.05rem;
    color: var(--text);
}

.status-right {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.status-avatar {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    object-fit: cover;
}

.status-handle {
    max-width: 140px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.btn-header-login {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 0.82rem;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    white-space: nowrap;
}

.btn-header-login:active {
    background: var(--primary-dark);
}

.btn-header-login .bsky-butterfly {
    width: 16px;
    height: 14px;
    flex-shrink: 0;
}

.bsky-butterfly {
    vertical-align: middle;
    display: inline-block;
}

.btn-login .bsky-butterfly {
    width: 18px;
    height: 16px;
    margin-right: 4px;
    vertical-align: -2px;
}

/* =========================================
   Pull-to-refresh
   ========================================= */
.pull-indicator {
    position: fixed;
    top: calc(var(--status-height) + var(--safe-top));
    left: 0;
    right: 0;
    height: 0;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    background: var(--primary-light);
    color: var(--primary);
    font-size: 0.85rem;
    font-weight: 500;
    z-index: 90;
    transition: height 0.2s ease;
}

.pull-indicator.visible {
    height: 40px;
}

.pull-indicator.refreshing .pull-text {
    display: none;
}

.pull-spinner {
    width: 18px;
    height: 18px;
    border: 2px solid var(--primary-light);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    display: none;
}

.pull-indicator.refreshing .pull-spinner {
    display: block;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =========================================
   Pages
   ========================================= */
#pages {
    position: fixed;
    top: calc(var(--status-height) + var(--safe-top));
    bottom: calc(var(--tab-height) + var(--safe-bottom));
    left: 0;
    right: 0;
}

.page {
    position: absolute;
    inset: 0;
    display: none;
}

.page.active {
    display: flex;
    flex-direction: column;
}

.page-scroll {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

.page-scroll::-webkit-scrollbar {
    display: none;
}

.page-content {
    padding: 12px;
    padding-bottom: 24px;
}

/* =========================================
   Tab Bar (bottom)
   ========================================= */
#tab-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: calc(var(--tab-height) + var(--safe-bottom));
    padding-bottom: var(--safe-bottom);
    background: var(--surface);
    border-top: 1px solid var(--border);
    display: flex;
    align-items: stretch;
}

.tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 2px;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    position: relative;
    transition: color 0.15s ease;
    padding: 4px 0;
}

.tab.active {
    color: var(--primary);
}

.tab.active::before {
    content: '';
    position: absolute;
    top: 0;
    left: 20%;
    right: 20%;
    height: 2.5px;
    background: var(--primary);
    border-radius: 0 0 2px 2px;
}

.tab:active {
    background: var(--primary-light);
}

.tab-icon {
    width: 22px;
    height: 22px;
}

.tab-label {
    font-size: 0.65rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

/* =========================================
   Hero Card
   ========================================= */
.hero-card {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 18px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
}

.hero-text {
    font-size: 0.82rem;
    color: var(--text);
    line-height: 1.55;
    margin-bottom: 6px;
}

.hero-break-sm {
    display: block;
    height: 6px;
}

.hero-break-lg {
    display: block;
    height: 18px;
}

.hero-sub {
    font-size: 0.85rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

/* =========================================
   Sections
   ========================================= */
.section {
    margin-bottom: 20px;
}

.section-heading {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.section-icon {
    font-size: 1rem;
}

/* =========================================
   Content List (generic)
   ========================================= */
.content-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* =========================================
   Skeleton loading
   ========================================= */
.skeleton-block {
    height: 56px;
    background: linear-gradient(90deg, #eee 25%, #f5f5f5 50%, #eee 75%);
    background-size: 200% 100%;
    border-radius: var(--radius);
    animation: shimmer 1.5s infinite;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* =========================================
   Bond Rows (homepage)
   ========================================= */
.bond-row {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    box-shadow: var(--shadow);
}

.bond-info {
    flex: 1;
    min-width: 0;
}

.bond-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bond-author {
    font-size: 0.78rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bond-badge {
    flex-shrink: 0;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    white-space: nowrap;
}

.bond-badge-active {
    background: var(--primary-light);
    color: var(--primary);
}

.bond-badge-empty {
    background: var(--border-light);
    color: var(--text-muted);
}

/* =========================================
   List Cards
   ========================================= */
.list-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.1s ease;
}

.list-card:active {
    transform: scale(0.98);
}

.list-card-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 8px;
}

.list-card-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--border-light);
}

.list-card-meta {
    flex: 1;
    min-width: 0;
}

.list-card-title {
    font-size: 0.92rem;
    font-weight: 600;
    color: var(--text);
    line-height: 1.3;
}

.list-card-creator {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.list-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.list-card-stat {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.list-card-book-tag {
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    background: #ede7f6;
    color: #7c4dff;
}

.list-card-handle {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.list-card-countdown {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 2px 8px;
    border-radius: 20px;
    background: var(--warning-light);
    color: var(--warning);
}

.list-card-countdown.expired {
    background: var(--bg);
    color: var(--text-muted);
}

/* =========================================
   Book Cards
   ========================================= */
.book-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 12px 14px;
    box-shadow: var(--shadow);
    border-left: 3px solid var(--book-brown);
    position: relative;
}

.book-card.stamped {
    border-left-color: var(--stamp);
}

.book-card-main {
    display: flex;
    align-items: center;
    gap: 10px;
}

.book-card-info {
    flex: 1;
    min-width: 0;
}

.book-card-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.book-card-author {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.book-card-actions {
    flex-shrink: 0;
    display: flex;
    gap: 6px;
}

.book-card-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 6px;
}

.badge {
    font-size: 0.68rem;
    font-weight: 600;
    padding: 2px 7px;
    border-radius: 20px;
    white-space: nowrap;
}

.badge-stamp {
    background: var(--stamp-light);
    color: var(--stamp);
}

.badge-list {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-source {
    background: var(--border-light);
    color: var(--text-muted);
}

/* =========================================
   Profile Strip (compact)
   ========================================= */
.profile-strip {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 12px;
}

.profile-strip-avatar {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    background: var(--border-light);
}

.profile-strip-info {
    flex: 1;
    min-width: 0;
}

.profile-strip-name {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.profile-strip-handle {
    font-size: 0.78rem;
    color: var(--text-secondary);
}

.profile-strip-stats {
    display: flex;
    gap: 12px;
    flex-shrink: 0;
}

.stat-pill {
    text-align: center;
    line-height: 1.2;
}

.stat-num {
    display: block;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}

.stat-label {
    display: block;
    font-size: 0.62rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* =========================================
   Profile Card Full (Me tab)
   ========================================= */
.profile-card-full {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 20px 16px;
    margin-bottom: 16px;
    box-shadow: var(--shadow);
    text-align: center;
}

.profile-full-avatar {
    width: 72px;
    height: 72px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 10px;
    display: block;
    background: var(--border-light);
}

.profile-full-name {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
}

.profile-full-handle {
    font-size: 0.82rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.profile-full-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
}

/* =========================================
   Action Grid (Me tab)
   ========================================= */
.action-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 20px;
}

.action-tile {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    cursor: pointer;
    transition: transform 0.1s ease, border-color 0.15s ease;
}

.action-tile:active {
    transform: scale(0.96);
    border-color: var(--primary);
}

.action-icon {
    font-size: 1.5rem;
}

.action-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text);
}

.action-count {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* =========================================
   Buttons
   ========================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: 0.85rem;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    touch-action: manipulation;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:active {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: white;
}

.btn-stamp {
    background: var(--stamp);
    color: white;
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-outline {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-outline:active {
    background: var(--border-light);
}

.btn-sm {
    padding: 5px 10px;
    font-size: 0.78rem;
}

.btn-icon {
    width: 34px;
    height: 34px;
    padding: 0;
    border-radius: 50%;
    font-size: 1.1rem;
}

.btn-login {
    padding: 12px 20px;
    font-size: 0.95rem;
    border-radius: var(--radius);
    width: 100%;
    max-width: 300px;
}

.btn-login img {
    vertical-align: middle;
    margin-right: 2px;
}

.btn-add {
    width: 40px;
    height: 40px;
    padding: 0;
    font-size: 1.3rem;
    font-weight: 700;
    border-radius: var(--radius);
    flex-shrink: 0;
}

/* =========================================
   Inputs
   ========================================= */
.input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text);
    font-size: 16px; /* prevents iOS zoom */
    transition: border-color 0.15s ease;
    outline: none;
}

.input:focus {
    border-color: var(--primary);
}

.input-search {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23999' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='M21 21l-4.35-4.35'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: 10px center;
    background-size: 16px;
    padding-left: 34px;
}

.input-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23999' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 28px;
    cursor: pointer;
}

/* =========================================
   Quick Add Card
   ========================================= */
.quick-add-card {
    display: flex;
    align-items: stretch;
    gap: 0;
    margin-bottom: 10px;
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    overflow: hidden;
    border: 1px solid var(--border);
}

.quick-add-inputs {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0;
}

.quick-add-inputs .input {
    border: none;
    border-radius: 0;
    background: transparent;
    padding: 10px 14px;
    font-size: 0.85rem;
    box-shadow: none;
}

.quick-add-inputs .input:first-child {
    border-bottom: 1px solid var(--border-light);
}

.quick-add-inputs .input:focus {
    outline: none;
    background: var(--primary-light);
}

.quick-add-btn {
    width: 12%;
    min-width: 52px;
    border: none;
    border-left: 1px solid var(--border);
    border-radius: 0;
    background: var(--primary);
    color: #fff;
    font-size: 0.68rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    line-height: 1.2;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4px;
}

.quick-add-btn:active {
    background: var(--primary-dark);
}

/* =========================================
   Controls Bar
   ========================================= */
.controls-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 12px;
}

.controls-bar .input-search {
    flex: 1;
    min-width: 0;
}

.controls-bar .input-select {
    width: auto;
    min-width: 110px;
}

/* =========================================
   Login Prompt
   ========================================= */
.login-prompt {
    text-align: center;
    padding: 48px 20px;
}

.prompt-icon {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.login-prompt h3 {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 6px;
    color: var(--text);
}

.login-prompt p {
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 20px;
    line-height: 1.5;
}

.login-hint {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 10px;
}

/* =========================================
   Mobile Login Form (overlay)
   ========================================= */
.login-form-card {
    text-align: center;
    padding: 24px 8px 16px;
}

.login-form-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.login-form-title {
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 6px;
}

.login-form-sub {
    font-size: 0.82rem;
    color: var(--text-secondary);
    line-height: 1.5;
    margin-bottom: 20px;
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
}

.login-form-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 10px 14px;
    border-radius: var(--radius);
    font-size: 0.82rem;
    margin-bottom: 16px;
    text-align: left;
}

.login-form-label {
    display: block;
    text-align: left;
    font-size: 0.85rem;
    color: var(--text);
    margin-bottom: 6px;
    font-weight: 500;
}

.login-form-input {
    width: 100%;
    box-sizing: border-box;
    padding: 12px 14px;
    font-size: 1rem;
    margin-bottom: 4px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    transition: border-color 0.15s ease;
}

.login-form-input:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.15);
}

.login-form-hint {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: left;
    margin-bottom: 18px;
}

.login-form-btn {
    width: 100%;
    padding: 13px 20px;
    font-size: 0.95rem;
}

.login-form-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.login-form-atproto {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 16px;
}

.login-form-signup {
    font-size: 0.78rem;
    margin-top: 6px;
}

.login-form-signup a {
    color: var(--primary);
    text-decoration: none;
}

/* =========================================
   Readers Like You
   ========================================= */
.readers-row {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    padding-bottom: 4px;
    -webkit-overflow-scrolling: touch;
}

.readers-row::-webkit-scrollbar {
    display: none;
}

.reader-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 12px;
    min-width: 150px;
    max-width: 170px;
    flex-shrink: 0;
    box-shadow: var(--shadow);
    text-align: center;
    cursor: pointer;
    transition: transform 0.1s ease;
}

.reader-card:active {
    transform: scale(0.96);
}

.reader-card-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    margin: 0 auto 6px;
    display: block;
    background: var(--border-light);
}

.reader-card-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.reader-card-shared {
    font-size: 0.72rem;
    color: var(--primary);
    font-weight: 500;
}

/* =========================================
   Overlays
   ========================================= */
.overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: calc(var(--tab-height) + var(--safe-bottom));
    z-index: 90;
    background: var(--bg);
    display: none;
    flex-direction: column;
}

.overlay.open {
    display: flex;
}

.overlay-header {
    height: calc(var(--status-height) + var(--safe-top));
    padding-top: var(--safe-top);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding-left: 4px;
    padding-right: 14px;
    gap: 8px;
}

.overlay-back {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.9rem;
    font-weight: 600;
    padding: 8px 10px;
    cursor: pointer;
    touch-action: manipulation;
    display: flex;
    align-items: center;
    gap: 4px;
}

.back-arrow {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.overlay-back:active {
    opacity: 0.6;
}

.overlay-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--text);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overlay-scroll {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-y: contain;
}

.overlay-scroll::-webkit-scrollbar {
    display: none;
}

.overlay-content {
    padding: 12px;
    padding-bottom: 32px;
}

/* =========================================
   List Detail (overlay content)
   ========================================= */
.list-detail-librarian {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 12px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.list-detail-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--border-light);
}

.list-detail-meta {
    flex: 1;
    min-width: 0;
}

.list-detail-name {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}

.list-detail-handle {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.list-detail-countdown {
    font-size: 0.72rem;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 20px;
    background: var(--warning-light);
    color: var(--warning);
    flex-shrink: 0;
}

.required-book-row {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    box-shadow: var(--shadow);
}

.required-book-info {
    flex: 1;
    min-width: 0;
}

.required-book-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: var(--text);
}

.required-book-author {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.participant-row {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    cursor: pointer;
}

.participant-row:last-child {
    border-bottom: none;
}

.participant-card {
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 8px;
    overflow: hidden;
}

.participant-chevron {
    font-size: 1.1rem;
    color: var(--text-muted);
    transition: transform 0.2s ease;
    flex-shrink: 0;
    margin-left: 4px;
}

.participant-chevron.expanded {
    transform: rotate(90deg);
}

.participant-details {
    border-top: 1px solid var(--border-light);
    padding: 6px 12px 10px;
    background: var(--bg);
}

.participant-book-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    font-size: 0.8rem;
}

.participant-book-icon {
    font-size: 0.85rem;
    flex-shrink: 0;
    width: 18px;
    text-align: center;
}

.participant-book-title {
    color: var(--text);
    flex: 1;
    min-width: 0;
}

.required-book-status {
    flex-shrink: 0;
}

.badge-submitted {
    background: var(--success-light);
    color: var(--success);
    font-size: 0.68rem;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 20px;
}

.badge-unread {
    background: var(--bg);
    color: var(--text-muted);
    font-size: 0.68rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 20px;
    border: 1px solid var(--border);
}

.badge-action {
    background: var(--accent);
    color: #fff;
    border: 1.5px solid var(--accent);
    cursor: pointer;
    font-weight: 700;
    font-size: 0.72rem;
    padding: 5px 12px;
    transition: opacity 0.15s, transform 0.1s;
}
.badge-action:active { opacity: 0.7; transform: scale(0.95); }
.badge-action.loading { opacity: 0.5; pointer-events: none; }

.participant-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--border-light);
    flex-shrink: 0;
}

.participant-info {
    flex: 1;
    min-width: 0;
}

.participant-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text);
}

.participant-handle {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.participant-progress {
    font-size: 0.72rem;
    color: var(--text-muted);
}

/* =========================================
   Bulk Add
   ========================================= */
.bulk-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 12px;
    line-height: 1.5;
}

.bulk-hint code {
    background: var(--border-light);
    padding: 1px 5px;
    border-radius: 3px;
    font-size: 0.82rem;
}

.bulk-input {
    min-height: 180px;
    resize: vertical;
    margin-bottom: 12px;
    font-family: 'SF Mono', 'Menlo', 'Monaco', monospace;
    font-size: 14px;
    line-height: 1.6;
}

.bulk-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
    margin-bottom: 16px;
}

.bulk-progress {
    margin-bottom: 12px;
}

.progress-bar {
    height: 6px;
    background: var(--border-light);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 6px;
}

.progress-fill {
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

.progress-text {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.bulk-result-item {
    padding: 8px 10px;
    border-radius: var(--radius-sm);
    margin-bottom: 4px;
    font-size: 0.82rem;
}

.bulk-result-success {
    background: var(--success-light);
    color: var(--success);
}

.bulk-result-skip {
    background: var(--warning-light);
    color: var(--warning);
}

.bulk-result-error {
    background: #fde8e8;
    color: var(--danger);
}

/* =========================================
   Toast
   ========================================= */
.toast {
    position: fixed;
    bottom: calc(var(--tab-height) + var(--safe-bottom) + 12px);
    left: 16px;
    right: 16px;
    background: var(--text);
    color: white;
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    font-weight: 500;
    text-align: center;
    z-index: 300;
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.25s ease, transform 0.25s ease;
    pointer-events: none;
}

.toast.visible {
    opacity: 1;
    transform: translateY(0);
}

/* =========================================
   Stamps
   ========================================= */
.stamp-list-group {
    background: var(--surface);
    border-radius: var(--radius-lg);
    padding: 14px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.stamp-list-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
    cursor: pointer;
}

.stamp-list-title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--text);
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.stamp-list-title.clickable {
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
    text-decoration-color: transparent;
    transition: text-decoration-color 0.2s;
}
.stamp-list-title.clickable:active {
    text-decoration-color: var(--accent);
}

.stamp-list-badge {
    font-size: 0.72rem;
    font-weight: 700;
    padding: 3px 10px;
    border-radius: 20px;
    flex-shrink: 0;
    margin-left: 8px;
}

.stamp-list-badge.complete {
    background: var(--stamp-light);
    color: var(--stamp);
}

.stamp-list-badge.in-progress {
    background: var(--primary-light);
    color: var(--primary);
}

.stamp-book-row {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 0;
    border-top: 1px solid var(--border-light);
}

.stamp-book-icon {
    font-size: 0.9rem;
    flex-shrink: 0;
}

.stamp-book-title {
    font-size: 0.82rem;
    color: var(--text);
    flex: 1;
    min-width: 0;
}

.stamp-book-date {
    font-size: 0.7rem;
    color: var(--text-muted);
    flex-shrink: 0;
}

.stamp-participants {
    display: flex;
    gap: -4px;
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid var(--border-light);
}

.stamp-participant-avatar {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--surface);
    margin-left: -6px;
    background: var(--border-light);
}

.stamp-participant-avatar:first-child {
    margin-left: 0;
}

/* =========================================
   Info Card
   ========================================= */
.info-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.info-step {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    font-size: 0.85rem;
    color: var(--text);
    line-height: 1.4;
}

.step-num {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    font-size: 0.72rem;
    font-weight: 700;
    flex-shrink: 0;
}

.info-note {
    font-size: 0.78rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid var(--border-light);
    line-height: 1.5;
}

/* =========================================
   Logout Section
   ========================================= */
.logout-section {
    text-align: center;
    padding: 8px 0 12px;
}

.logout-section .btn-outline {
    margin-bottom: 12px;
    width: 200px;
}

.desktop-link {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* =========================================
   Empty states
   ========================================= */
.empty-state {
    text-align: center;
    padding: 32px 16px;
    color: var(--text-muted);
    font-size: 0.88rem;
}

.empty-state-icon {
    font-size: 2rem;
    margin-bottom: 8px;
}

/* =========================================
   Confirm dialog (inline)
   ========================================= */
.confirm-bar {
    display: flex;
    gap: 6px;
    align-items: center;
}

/* =========================================
   Edit Modal Shadowbox
   ========================================= */
.modal-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(255,255,255,0.95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.15s ease;
}
.modal-backdrop.open {
    display: flex;
}
.modal-card {
    background: var(--card);
    border-radius: 16px;
    width: 90%;
    max-width: 360px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.35);
    overflow: hidden;
    animation: modalSlideUp 0.2s ease;
}
@keyframes modalSlideUp {
    from { opacity:0; transform: translateY(30px); }
    to { opacity:1; transform: translateY(0); }
}
.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid var(--border-light);
}
.modal-title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text);
}
.modal-close {
    background: none;
    border: none;
    font-size: 1.2rem;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
}
.modal-close:active { background: var(--bg); }
.modal-body {
    padding: 16px 20px;
}
.modal-label {
    display: block;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
.modal-input {
    width: 100%;
    padding: 10px 12px;
    font-size: 0.95rem;
    border: 1.5px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    margin-bottom: 12px;
    box-sizing: border-box;
    transition: border-color 0.15s;
}
.modal-input:focus {
    border-color: var(--accent);
    outline: none;
}
.modal-actions {
    display: flex;
    gap: 10px;
    padding: 0 20px 16px;
    justify-content: flex-end;
}
.modal-actions .btn {
    min-width: 80px;
}

/* =========================================
   Create List Bar
   ========================================= */
.create-list-bar {
    display: flex;
    justify-content: center;
    padding: 12px 0 4px;
}
.create-list-btn {
    width: 100%;
    font-size: 0.95rem;
    font-weight: 600;
    padding: 12px;
    border-radius: 12px;
}

/* =========================================
   Form Groups (overlays)
   ========================================= */
.form-group {
    margin-bottom: 16px;
}
.form-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    padding-top: 8px;
}
.form-actions .btn {
    min-width: 100px;
}

/* =========================================
   My List Owner Actions
   ========================================= */
.my-list-actions {
    display: flex;
    gap: 8px;
    padding-top: 6px;
}
.my-list-actions .btn {
    flex: 1;
    font-size: 0.8rem;
    padding: 7px 0;
    border-radius: 8px;
    text-align: center;
}
.btn-danger {
    background: var(--danger);
    color: #fff;
    border: none;
    cursor: pointer;
}
.btn-danger:active {
    opacity: 0.8;
}

/* =========================================
   Stamps Book Actions
   ========================================= */
.stamp-book-row {
    display: flex;
    align-items: center;
    gap: 8px;
}
.stamp-book-action {
    margin-left: auto;
    font-size: 0.72rem;
    padding: 4px 10px;
    border-radius: 8px;
    white-space: nowrap;
    cursor: pointer;
}

/* =========================================
   Library Overlay: Discuss Button
   ========================================= */
.discuss-btn {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.75rem;
    padding: 4px 10px;
    border-radius: 8px;
    background: var(--accent);
    color: #fff;
    border: none;
    cursor: pointer;
    text-decoration: none;
    white-space: nowrap;
}
.discuss-btn:active {
    opacity: 0.8;
}

/* =========================================
   Delete List Modal
   ========================================= */
#delete-list-modal-backdrop .modal-card {
    max-width: 320px;
}

/* =========================================
   Shared book highlight
   ========================================= */
.book-card.shared {
    border-left-color: var(--success);
    background: var(--success-light);
}

/* =========================================
   Animations
   ========================================= */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.fade-in {
    animation: fadeInUp 0.25s ease forwards;
}

/* =========================================
   Very narrow screens (iPhone SE)
   ========================================= */
@media (max-width: 380px) {
    .quick-add-bar {
        flex-wrap: wrap;
    }

    .quick-add-bar .input {
        flex-basis: 100%;
    }

    .profile-strip-stats {
        gap: 8px;
    }

    .stat-num {
        font-size: 0.88rem;
    }

    .action-grid {
        gap: 6px;
    }
}

/* =========================================
   Reduced motion
   ========================================= */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
