:root {
    --bg: #fafafa;
    --bg-card: #ffffff;
    --text: #1a1a1a;
    --text-muted: #666666;
    --accent: #2563eb;
    --border: #e5e5e5;
    --highlight-bg: #fffbeb;
    --highlight-border: #fcd34d;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #0a0a0a;
        --bg-card: #171717;
        --text: #fafafa;
        --text-muted: #a3a3a3;
        --accent: #3b82f6;
        --border: #262626;
        --highlight-bg: #1c1917;
        --highlight-border: #854d0e;
    }
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

header {
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

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

/* User Menu Styles */
.user-menu {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
}

.user-name {
    color: var(--text-muted);
}

.logout-link,
.login-link,
.profile-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    transition: color 0.15s, background-color 0.15s;
}

.logout-link:hover,
.login-link:hover,
.profile-link:hover {
    color: var(--accent);
    background-color: var(--border);
}

nav {
    margin-top: 0.5rem;
}

nav a {
    color: var(--text-muted);
    text-decoration: none;
    margin-right: 1rem;
    font-size: 0.875rem;
}

nav a:hover {
    color: var(--accent);
}

.stats-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.stats {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.download-all-btn {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-decoration: none;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}

.download-all-btn:hover {
    color: var(--accent);
    border-color: var(--accent);
    background-color: var(--bg-card);
}

.search-box {
    margin-bottom: 1.5rem;
}

.search-box input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--bg-card);
    color: var(--text);
    font-size: 1rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--accent);
}

.book-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.book-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.25rem;
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    transition: border-color 0.15s;
}

.book-cover-link {
    flex-shrink: 0;
}

.book-card-cover {
    width: 50px;
    height: 75px;
    object-fit: cover;
    border-radius: 0.25rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.12);
}

.book-card:hover {
    border-color: var(--accent);
}

.book-link {
    flex: 1;
    text-decoration: none;
    color: var(--text);
}

.download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    color: var(--text-muted);
    border-radius: 0.375rem;
    transition: color 0.15s, background-color 0.15s;
    text-decoration: none;
}

.download-btn:hover {
    color: var(--accent);
    background-color: var(--border);
}

.book-title {
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.book-author {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

.book-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.source-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    background: var(--border);
    color: var(--text-muted);
    border-radius: 0.25rem;
}

.book-header {
    margin-bottom: 2rem;
}

.book-header-top {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 1rem;
}

.book-header h2 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
    flex: 1;
}

.book-header .author {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.highlight {
    background: var(--bg-card);
    border-left: 3px solid var(--highlight-border);
    padding: 1rem 1.25rem;
    margin-bottom: 1rem;
    border-radius: 0 0.5rem 0.5rem 0;
}

.highlight-text {
    margin-bottom: 0.5rem;
    white-space: pre-wrap;
}

.highlight-note {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--border);
}

.highlight-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

.back-link {
    display: inline-block;
    color: var(--accent);
    text-decoration: none;
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
}

.back-link:hover {
    text-decoration: underline;
}

.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.htmx-request .htmx-indicator {
    display: inline;
}

.htmx-indicator {
    display: none;
}

.loading {
    color: var(--text-muted);
    padding: 1rem;
    text-align: center;
}

/* Settings Page Styles */
.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
}

.settings-section {
    margin-bottom: 2rem;
}

.settings-section h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.integration-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.25rem;
}

.integration-header {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    margin-bottom: 1rem;
}

.integration-icon {
    color: var(--accent);
    flex-shrink: 0;
}

.integration-info h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.integration-desc {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.integration-status {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.375rem;
    margin-bottom: 1rem;
}

.status-connected {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.status-disconnected {
    background: var(--bg);
    border: 1px solid var(--border);
}

.status-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #ef4444;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.status-dot.connected {
    background: #22c55e;
}

.status-dot.disconnected {
    background: var(--text-muted);
}

.status-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #ef4444;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.75rem;
    flex-shrink: 0;
}

.status-details {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
}

.status-text {
    font-weight: 500;
}

.status-account {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.status-warning {
    font-size: 0.75rem;
    color: #f59e0b;
}

.integration-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Task form inline layout */
.task-form {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.task-input {
    width: 8rem;
    padding: 0.5rem 0.75rem;
}

.task-action-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.task-id {
    font-family: monospace;
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    text-decoration: none;
}

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

.btn-primary:hover {
    background: #1d4ed8;
}

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

.btn-secondary:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.btn-danger {
    background: transparent;
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: #ef4444;
}

/* Callback Page Styles */
.callback-result {
    text-align: center;
    padding: 3rem 1rem;
}

.callback-success,
.callback-error {
    max-width: 400px;
    margin: 0 auto;
}

.callback-icon {
    margin-bottom: 1.5rem;
}

.callback-icon.success {
    color: #22c55e;
}

.callback-icon.error {
    color: #ef4444;
}

.callback-result h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.callback-result p {
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.account-id {
    font-family: monospace;
    font-size: 0.875rem;
}

.error-message {
    color: #ef4444 !important;
}

.redirect-notice {
    font-size: 0.875rem;
    margin-bottom: 1rem;
}

.callback-result .btn {
    margin-top: 1rem;
}

/* Spinner for loading states */
.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.75s linear infinite;
}

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

.htmx-indicator {
    display: none;
}

.htmx-request .htmx-indicator {
    display: inline-flex;
}

/* Active nav link */
nav a.active {
    color: var(--accent);
}

/* Import Result Styles */
.import-result {
    margin-top: 1rem;
    padding: 1rem;
    border-radius: 0.5rem;
}

.import-success {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.import-error {
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.import-result-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    margin-bottom: 0.75rem;
}

.import-success .import-result-header {
    color: #22c55e;
}

.import-error .import-result-header {
    color: #ef4444;
}

.import-stats {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

.import-stat {
    display: flex;
    flex-direction: column;
}

.stat-value {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

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

.import-warnings {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid rgba(34, 197, 94, 0.3);
    font-size: 0.875rem;
    color: var(--text-muted);
}

.import-warnings ul {
    margin: 0.5rem 0 0 1.25rem;
    padding: 0;
}

.import-warnings li {
    margin-bottom: 0.25rem;
}

.import-error-message {
    color: #ef4444;
    margin: 0;
}

/* File Upload Styles */
.file-upload-container {
    margin-bottom: 0.75rem;
}

.file-upload-container input[type="file"] {
    width: 100%;
    padding: 0.5rem;
    border: 1px dashed var(--border);
    border-radius: 0.375rem;
    background: var(--bg);
    color: var(--text);
    font-size: 0.875rem;
    cursor: pointer;
}

.file-upload-container input[type="file"]:hover {
    border-color: var(--accent);
}

.file-upload-container input[type="file"]:focus {
    outline: none;
    border-color: var(--accent);
    border-style: solid;
}

.file-upload-label {
    display: none;
}

/* Info status variant */
.status-info {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-dot.info {
    background: var(--accent);
}

/* Integration card spacing */
.integration-card + .integration-card {
    margin-top: 1rem;
}

/* Export Settings Form Styles */
.export-settings {
    margin-top: 0.5rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
    color: var(--text);
}

.form-input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg);
    color: var(--text);
    font-size: 0.875rem;
    font-family: monospace;
}

.form-input:focus {
    outline: none;
    border-color: var(--accent);
}

.form-help {
    display: block;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.375rem;
}

.input-with-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.input-with-badge .form-input {
    flex: 1;
}

/* Badge styles */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem;
    font-size: 0.625rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    border-radius: 0.25rem;
    white-space: nowrap;
}

.badge-success {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.badge-info {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

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

/* Checkbox styles */
.checkbox-group {
    margin-bottom: 1rem;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.875rem;
    color: var(--text);
}

.checkbox-label input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: var(--accent);
    cursor: pointer;
}

.checkbox-label span {
    font-weight: normal;
}

/* Book Metadata Styles */
.book-header-left {
    display: flex;
    gap: 1.25rem;
    flex: 1;
}

.book-cover {
    width: 100px;
    height: auto;
    border-radius: 0.375rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    flex-shrink: 0;
}

.book-header-info {
    flex: 1;
}

.book-details {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

.book-details span:not(:last-child)::after {
    content: "·";
    margin-left: 0.5rem;
}

.book-details .isbn {
    font-family: monospace;
}

.metadata-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.25rem;
    margin-bottom: 2rem;
}

.metadata-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.metadata-actions {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.isbn-form {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.isbn-input {
    max-width: 200px;
}

.enrichment-success {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.3);
    border-radius: 0.375rem;
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: #22c55e;
}

.enrichment-error {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.3);
    border-radius: 0.375rem;
    margin-top: 0.75rem;
    font-size: 0.875rem;
    color: #ef4444;
}

.enrichment-fields {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-muted);
}

@media (max-width: 600px) {
    .book-header-left {
        flex-direction: column;
        align-items: flex-start;
    }

    .book-cover {
        width: 80px;
    }

    .isbn-form {
        flex-direction: column;
        align-items: stretch;
    }

    .isbn-input {
        max-width: none;
    }
}

/* Sync Progress Styles */
.sync-progress {
    background: var(--bg-card);
    border: 1px solid var(--accent);
    border-radius: 0.5rem;
    padding: 1rem;
}

.sync-progress-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 500;
    margin-bottom: 0.75rem;
    color: var(--text);
}

.sync-progress-header .spinner {
    width: 16px;
    height: 16px;
    border-color: var(--accent);
    border-right-color: transparent;
}

.sync-progress-bar {
    width: 100%;
    height: 8px;
    background: var(--border);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.sync-progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 4px;
    transition: width 0.3s ease;
}

.sync-progress-details {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.sync-current-item {
    max-width: 200px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-style: italic;
}

.sync-progress-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.75rem;
}

.sync-progress-stats .stat-success {
    color: #22c55e;
}

.sync-progress-stats .stat-skip {
    color: var(--text-muted);
}

.sync-progress-stats .stat-fail {
    color: #ef4444;
}

/* Vertical Tabs for Settings */
.settings-tabs-container {
    display: flex;
    gap: 1.5rem;
}

.settings-tabs {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 180px;
    flex-shrink: 0;
}

.settings-tab {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    cursor: pointer;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    text-align: left;
    transition: background-color 0.15s, color 0.15s;
}

.settings-tab:hover {
    background: var(--bg-card);
    color: var(--text);
}

.settings-tab.active {
    background: var(--bg-card);
    color: var(--accent);
    border: 1px solid var(--border);
}

.settings-tab-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.settings-tab-content {
    flex: 1;
    min-width: 0;
}

.settings-tab-panel {
    display: none;
}

.settings-tab-panel.active {
    display: block;
}

.settings-version {
    margin-top: auto;
    padding: 0.75rem 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    opacity: 0.6;
}

@media (max-width: 700px) {
    .settings-tabs-container {
        flex-direction: column;
        gap: 1rem;
    }

    .settings-tabs {
        flex-direction: row;
        min-width: auto;
        overflow-x: auto;
        padding-bottom: 0.5rem;
        border-bottom: 1px solid var(--border);
    }

    .settings-tab {
        white-space: nowrap;
        flex-shrink: 0;
    }

    .settings-version {
        margin-top: 0;
        margin-left: auto;
        padding: 0.5rem 0.75rem;
    }
}

/* Tag Management Styles */
.tags-section {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.25rem;
    margin-bottom: 1.5rem;
}

.tags-section h3 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 1rem;
}

.tags-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    align-items: center;
}

.tag-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.625rem;
    background: var(--accent);
    color: white;
    font-size: 0.75rem;
    font-weight: 500;
    border-radius: 1rem;
    white-space: nowrap;
}

.tag-chip-small {
    padding: 0.125rem 0.5rem;
    font-size: 0.625rem;
}

.tag-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 0.75rem;
    cursor: pointer;
    margin-left: 0.125rem;
    transition: background-color 0.15s;
    line-height: 1;
}

.tag-remove:hover {
    background: rgba(255, 255, 255, 0.4);
}

.tag-add-form {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    position: relative;
}

.tag-input {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    background: var(--bg);
    color: var(--text);
    font-size: 0.75rem;
    width: 120px;
}

.tag-input:focus {
    outline: none;
    border-color: var(--accent);
}

.tag-input-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.625rem;
    width: 80px;
}

.tag-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 10;
    min-width: 150px;
    margin-top: 0.25rem;
}

.tag-dropdown {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.tag-suggestion {
    display: block;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    text-align: left;
    font-size: 0.75rem;
    color: var(--text);
    cursor: pointer;
    transition: background-color 0.1s;
}

.tag-suggestion:hover {
    background: var(--border);
}

.btn-small {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
}

/* Highlight Tags */
.highlight-tags-container {
    margin-top: 0.75rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.highlight-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
    align-items: center;
}

.tag-add-inline {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.tag-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    background: var(--border);
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.15s, color 0.15s;
}

.tag-add-btn:hover {
    background: var(--accent);
    color: white;
}

/* Tags Filter on Index Page */
.tags-filter {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
    padding: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    overflow-x: auto;
}

.tags-filter-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    flex-shrink: 0;
}

.tags-filter-list {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.tag-filter-chip {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
    text-decoration: none;
}

.tag-filter-chip:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.tag-filter-chip.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.tag-filter-item {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.5rem 0.25rem 0.75rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    transition: background-color 0.15s, border-color 0.15s, color 0.15s;
    white-space: nowrap;
}

.tag-filter-item:hover {
    border-color: var(--accent);
    color: var(--accent);
}

.tag-filter-item .tag-filter-chip {
    padding: 0;
    border: none;
    background: transparent;
    color: inherit;
    border-radius: 0;
}

.tag-filter-item .tag-filter-chip.active {
    background: transparent;
    color: inherit;
}

.tag-filter-item:has(.tag-filter-chip.active) {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.tag-filter-item:has(.tag-filter-chip.active) .tag-filter-delete {
    color: rgba(255, 255, 255, 0.7);
}

.tag-filter-item:has(.tag-filter-chip.active) .tag-filter-delete:hover {
    color: white;
    background: rgba(255, 255, 255, 0.3);
}

.tag-filter-delete {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: var(--text-muted);
    font-size: 0.875rem;
    font-weight: 300;
    cursor: pointer;
    margin-left: 0.375rem;
    transition: background-color 0.15s, color 0.15s;
    line-height: 1;
    padding: 0;
}


.tag-filter-delete:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

/* Delete Dropdown Styles */
.book-actions {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.delete-dropdown {
    position: relative;
}

.delete-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem;
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, background-color 0.15s;
}

.delete-btn:hover {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
}

.delete-btn-small {
    padding: 0.25rem;
    opacity: 0;
    transition: opacity 0.15s, color 0.15s, background-color 0.15s;
}

.highlight:hover .delete-btn-small,
.delete-dropdown.open .delete-btn-small {
    opacity: 1;
}

.delete-dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 100;
    min-width: 160px;
    margin-top: 0.25rem;
    padding: 0.375rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-8px);
    transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.delete-dropdown.open .delete-dropdown-menu {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.delete-option {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    padding: 0.5rem 0.75rem;
    background: none;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    color: var(--text);
    cursor: pointer;
    text-align: left;
    transition: background-color 0.1s;
}

.delete-option:hover {
    background: var(--border);
}

.delete-option-permanent {
    color: #ef4444;
}

.delete-option-permanent:hover {
    background: rgba(239, 68, 68, 0.1);
}

/* Highlight Header with Delete Button */
.highlight-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 0.5rem;
}

.highlight-header .highlight-text {
    flex: 1;
    margin-bottom: 0;
}

.highlight-header .delete-dropdown {
    flex-shrink: 0;
}

/* Book Card Tags */
.book-card-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.book-card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-top: 0.375rem;
}

.book-card-tag {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    background: var(--accent-bg);
    color: var(--accent);
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 500;
    white-space: nowrap;
    text-decoration: none;
    transition: background-color 0.15s, color 0.15s;
}

a.book-card-tag:hover {
    background: var(--accent);
    color: white;
}

.book-card-tag-more {
    background: var(--border);
    color: var(--text-muted);
}

/* Book Card Actions */
.book-card-actions {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    align-items: center;
}

.book-card .delete-btn-small {
    opacity: 0;
}

.book-card:hover .delete-btn-small {
    opacity: 1;
}

.book-card .delete-dropdown.open .delete-btn-small {
    opacity: 1;
}

/* Favourite Button Styles */
.favourite-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.25rem;
    background: transparent;
    border: none;
    border-radius: 0.375rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.15s, background-color 0.15s, transform 0.1s;
    opacity: 0;
}

.favourite-btn:hover {
    color: #ef4444;
    background-color: rgba(239, 68, 68, 0.1);
}

.favourite-btn:active {
    transform: scale(0.9);
}

.favourite-btn-active {
    color: #ef4444;
    opacity: 1;
}

.favourite-btn-active:hover {
    color: #dc2626;
}

.highlight:hover .favourite-btn {
    opacity: 1;
}

.highlight-actions {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    flex-shrink: 0;
}

/* Favourites Page Styles */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.page-header .page-title {
    margin-bottom: 0;
}

.favourites-book-group {
    margin-bottom: 1.5rem;
}

.favourites-book-header {
    display: block;
    padding: 0.75rem 1rem;
    margin-bottom: 0.75rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    text-decoration: none;
    color: var(--text);
    transition: border-color 0.15s;
}

.favourites-book-header:hover {
    border-color: var(--accent);
}

.favourites-book-header h3 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 0.125rem;
}

.favourites-book-author {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.favourite-highlight {
    margin-left: 1rem;
}

.empty-state-hint {
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Vocabulary Page Styles */
.vocab-stats {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.vocab-stats .stat {
    padding: 0.25rem 0.625rem;
    border-radius: 0.375rem;
    font-size: 0.75rem;
    font-weight: 500;
    background: var(--border);
    color: var(--text-muted);
}

.stat-pending {
    background: rgba(251, 191, 36, 0.15) !important;
    color: #d97706 !important;
}

.stat-enriched {
    background: rgba(34, 197, 94, 0.15) !important;
    color: #22c55e !important;
}

.stat-failed {
    background: rgba(239, 68, 68, 0.15) !important;
    color: #ef4444 !important;
}

.vocab-actions {
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.vocab-actions .search-box {
    flex: 1;
    min-width: 200px;
    margin-bottom: 0;
}

.word-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1rem;
}

.word-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1rem;
    transition: border-color 0.15s;
}

.word-card:hover {
    border-color: var(--accent);
}

.word-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.word-text {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text);
}

.word-status {
    font-size: 0.625rem;
    font-weight: 600;
    padding: 0.125rem 0.5rem;
    border-radius: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.status-pending {
    background: rgba(251, 191, 36, 0.15);
    color: #d97706;
}

.status-enriched {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
}

.status-failed {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
}

.word-definitions {
    margin: 0.5rem 0;
}

.definition {
    margin: 0.375rem 0;
    font-size: 0.875rem;
    line-height: 1.4;
}

.definition .pos {
    font-style: italic;
    color: var(--accent);
    margin-right: 0.375rem;
    font-size: 0.75rem;
}

.definition .def-text {
    color: var(--text);
}

.more-defs {
    font-size: 0.75rem;
    color: var(--text-muted);
    font-style: italic;
}

.pending-text,
.failed-text {
    font-size: 0.75rem;
    font-style: italic;
}

.pending-text {
    color: var(--text-muted);
}

.failed-text {
    color: #ef4444;
}

.word-source {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid var(--border);
}

.word-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.75rem;
    flex-wrap: wrap;
}

.btn-audio {
    padding: 0.25rem 0.5rem;
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.btn-audio:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* Word Selection Popover */
.word-popover {
    z-index: 1000;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    padding: 0.75rem;
}

.popover-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.popover-word {
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
}

/* Toast Notification */
.notification {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: var(--text);
    color: var(--bg);
    padding: 0.75rem 1.5rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    z-index: 1001;
    animation: slideIn 0.3s ease;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.notification-success {
    background: #22c55e;
    color: white;
}

.notification-error {
    background: #ef4444;
    color: white;
}

.notification-info {
    background: var(--accent);
    color: white;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Word Detail Page */
.word-detail {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    padding: 1.5rem;
}

.word-detail h2 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

.definitions-full {
    margin-top: 1rem;
}

.definition-full {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border);
}

.definition-full:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.def-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.def-header .pos {
    font-style: italic;
    color: var(--accent);
    font-weight: 500;
}

.def-header .pronunciation {
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.def-text {
    margin-bottom: 0.375rem;
}

.def-example {
    font-style: italic;
    color: var(--text-muted);
    font-size: 0.875rem;
}

.word-context {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
}

.word-context h4 {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

@media (max-width: 600px) {
    .word-grid {
        grid-template-columns: 1fr;
    }

    .vocab-actions {
        flex-direction: column;
        align-items: stretch;
    }

    .vocab-actions .search-box {
        min-width: auto;
    }
}

/* Profile Page Styles */
.profile-cards {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.profile-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 0.75rem;
    padding: 1.5rem;
}

.profile-card-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.profile-card-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: rgba(37, 99, 235, 0.1);
    border-radius: 0.5rem;
    color: var(--accent);
    flex-shrink: 0;
}

.profile-card-header h3 {
    font-size: 1.125rem;
    font-weight: 600;
    margin: 0;
}

.profile-card-description {
    font-size: 0.875rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.profile-card-actions {
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

/* Profile Info Grid */
.profile-info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.profile-info-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.profile-info-label {
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.profile-info-value {
    font-size: 0.9375rem;
    color: var(--text);
}

/* Role Badge */
.role-badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: capitalize;
    border-radius: 1rem;
    background: var(--border);
    color: var(--text-muted);
}

.role-admin {
    background: rgba(147, 51, 234, 0.15);
    color: #9333ea;
}

.role-user {
    background: rgba(59, 130, 246, 0.15);
    color: #3b82f6;
}

/* Token Status */
.token-status {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    font-weight: 500;
}

.token-status-active {
    background: rgba(34, 197, 94, 0.1);
    border: 1px solid rgba(34, 197, 94, 0.2);
    color: #22c55e;
}

.token-status-active .token-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #22c55e;
}

.token-status-inactive {
    background: var(--bg);
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.token-status-inactive .token-indicator {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-muted);
}

/* Form Row (side by side fields) */
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Token Display */
.token-display {
    display: block;
    padding: 0.75rem 1rem;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 0.375rem;
    font-family: monospace;
    font-size: 0.8125rem;
    word-break: break-all;
    margin: 0.75rem 0;
}

.token-warning {
    font-size: 0.8125rem;
    color: #f59e0b;
    margin-top: 0.5rem;
}

@media (max-width: 600px) {
    .profile-info-grid {
        grid-template-columns: 1fr;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .profile-card-actions {
        flex-direction: column;
    }

    .profile-card-actions .btn {
        width: 100%;
    }
}

/* Demo Mode Banner */
.demo-banner {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.demo-banner-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
    justify-content: center;
}

.demo-banner-icon {
    display: flex;
    align-items: center;
    flex-shrink: 0;
}

.demo-banner-icon svg {
    stroke: #ffffff;
}

.demo-banner-text {
    font-size: 0.875rem;
    font-weight: 500;
    text-align: center;
}

.demo-banner-close {
    background: transparent;
    border: none;
    color: #ffffff;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0 0.25rem;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
    flex-shrink: 0;
}

.demo-banner-close:hover {
    opacity: 1;
}

@media (prefers-color-scheme: dark) {
    .demo-banner {
        background: linear-gradient(135deg, #b45309 0%, #92400e 100%);
    }
}

@media (max-width: 600px) {
    .demo-banner {
        padding: 0.625rem 0.75rem;
    }

    .demo-banner-text {
        font-size: 0.8125rem;
    }
}

