/* Reset only for database page content, not global widgets */
.page-header,
.page-header *,
.schema-info,
.schema-info *,
.controls,
.controls *,
.table-tabs,
.table-tabs *,
.table-container,
.table-container *,
#rows-container,
#rows-container * {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary: #734ba1;
    --primary-light: #8B5AA9;
    --primary-dark: #5a4a7a;
    --bg-page: #f0f8ff;
    --bg-white: #ffffff;
    --bg-light: #f8f6ff;
    --text: #372e42;
    --text-dim: #5a4a7a;
    --border: #d0c7f0;
    --border-dark: #734ba1;
    --success: #4CAF50;
    --warning: #FFC107;
    --danger: #F44336;
    --info: #2196F3;
}

/* Scope body styles to database page only */
body.database-page {
    font-family: Arial, sans-serif;
    background: var(--bg-page);
    color: var(--text);
    line-height: 1.4;
}

.database-layout {
    display: flex;
    position: fixed;
    top: 80px;
    left: 0;
    right: 0;
    bottom: 64px; /* Account for drawer collapsed height */
    overflow: hidden;
    transition: bottom 0.3s ease;
}

/* When drawer is open, give it more space */
.drawer-container.open ~ .database-layout,
body.drawer-open .database-layout {
    bottom: 40vh;
}

.database-left-column {
    width: 240px;
    background: var(--bg-white);
    border-right: 3px solid #5a4a7a;
    padding: 20px;
    padding-bottom: 24px;
    overflow-y: auto;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}

.database-left-column::-webkit-scrollbar {
    width: 8px;
}

.database-left-column::-webkit-scrollbar-track {
    background: transparent;
}

.database-left-column::-webkit-scrollbar-thumb {
    background: rgba(115, 75, 161, 0.3);
    border-radius: 4px;
}

.database-left-column::-webkit-scrollbar-thumb:hover {
    background: rgba(115, 75, 161, 0.5);
}

.database-left-column {
    scrollbar-width: thin;
    scrollbar-color: rgba(115, 75, 161, 0.3) transparent;
}

.left-column-section {
    margin-bottom: 16px;
    flex-shrink: 0;
}

.left-column-section:last-child {
    margin-bottom: 0;
}

.mindscape-section {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid var(--border);
    flex-shrink: 0;
}

.mindscape-stats-row {
    display: flex;
    gap: 6px;
    margin-top: 6px;
}

.mindscape-stat-box {
    background: var(--bg-white);
    border: 2px solid var(--border);
    padding: 12px;
    text-align: center;
    flex: 1;
}

.mindscape-stat-box.large {
    padding: 16px;
}

.mindscape-stat-count {
    font-size: 1.6em;
    font-weight: 700;
    font-family: monospace;
    color: #4a4454;
    margin-bottom: 4px;
    letter-spacing: -1px;
}

.mindscape-stat-box.large .mindscape-stat-count {
    font-size: 2.0em;
    margin-bottom: 6px;
}

.mindscape-stat-label {
    font-size: 0.65em;
    font-weight: 600;
    font-family: monospace;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.section-title {
    font-size: 0.85em;
    font-weight: 700;
    font-family: monospace;
    color: var(--primary-dark);
    margin-bottom: 10px;
    padding-bottom: 6px;
    border-bottom: 1.5px solid var(--border);
}

.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-family: monospace;
    font-size: 0.82em;
}

.stat-label {
    color: var(--text-dim);
    font-weight: 500;
}

.stat-value {
    color: var(--primary);
    font-weight: 700;
    font-size: 1.1em;
}

.operations-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 6px 0;
    font-family: monospace;
    font-size: 0.75em;
}

.operations-label {
    color: var(--text-dim);
    font-weight: 500;
}

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

.operations-text {
    font-size: 0.9em;
    color: var(--text-dim);
    min-width: 60px;
    text-align: left;
}

.operations-light {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(148, 163, 184, 0.3);
    transition: all 0.3s ease;
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
}

.operations-light.active {
    background: #38bdf8;
    box-shadow: 0 0 8px #38bdf8, 0 0 16px rgba(56, 189, 248, 0.5);
    animation: pulse-blue-ops 2s ease-in-out infinite;
}

.operations-light.inactive {
    background: #fbbf24;
    box-shadow: 0 0 6px #fbbf24, 0 0 12px rgba(251, 191, 36, 0.4);
}

.operations-light.error {
    background: #fb923c;
    box-shadow: 0 0 8px #fb923c, 0 0 16px rgba(251, 146, 60, 0.5);
    animation: pulse-orange-ops 1s ease-in-out infinite;
}

@keyframes pulse-blue-ops {
    0%, 100% {
        box-shadow: 0 0 8px #38bdf8, 0 0 16px rgba(56, 189, 248, 0.5);
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 12px #38bdf8, 0 0 24px rgba(56, 189, 248, 0.7);
        opacity: 0.9;
    }
}

@keyframes pulse-orange-ops {
    0%, 100% {
        box-shadow: 0 0 8px #fb923c, 0 0 16px rgba(251, 146, 60, 0.5);
        opacity: 1;
    }
    50% {
        box-shadow: 0 0 12px #fb923c, 0 0 24px rgba(251, 146, 60, 0.7);
        opacity: 0.9;
    }
}

.database-main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    overflow: hidden;
    background: var(--bg-white);
}

.page-header-fixed {
    background: var(--bg-white);
    padding: 10px 32px;
    border-bottom: 1.5px solid var(--border);
    display: flex;
    justify-content: flex-start;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    height: 52px;
}

.db-search-input {
    flex: 0 1 350px;
    min-width: 220px;
    padding: 6px 12px;
    border: 2px solid var(--border);
    border-radius: 0;
    background: var(--bg-white);
    color: var(--text);
    font-size: 0.85em;
    font-family: monospace;
    transition: border-color 0.2s;
    height: 32px;
    box-sizing: border-box;
}

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

.db-filter-dropdown {
    padding: 6px 28px 6px 10px;
    background: var(--bg-white);
    border: 2px solid var(--border);
    border-radius: 0;
    color: var(--text);
    font-size: 0.82em;
    font-family: monospace;
    font-weight: 600;
    letter-spacing: 0.3px;
    cursor: pointer;
    height: 32px;
    box-sizing: border-box;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg fill="%235a4a7a" height="16" viewBox="0 0 16 16" width="16" xmlns="http://www.w3.org/2000/svg"><path d="M4 6l4 4 4-4"/></svg>');
    background-repeat: no-repeat;
    background-position: right 6px center;
    transition: all 0.2s;
}

.db-filter-dropdown:hover {
    border-color: var(--primary);
    background: var(--bg-light);
}

.db-filter-dropdown:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

/* Style the dropdown list */
.db-filter-dropdown option {
    background: var(--bg-white);
    color: var(--text);
    font-family: monospace;
    font-size: 0.95em;
    font-weight: 500;
    padding: 8px 12px;
    letter-spacing: 0.2px;
    border: none;
}

.db-filter-dropdown option:hover,
.db-filter-dropdown option:checked {
    background: var(--bg-light);
    color: var(--primary);
    font-weight: 600;
}

.db-filter-dropdown optgroup {
    background: var(--bg-light);
    color: var(--primary-dark);
    font-family: monospace;
    font-size: 0.75em;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    padding: 6px 12px;
    margin-top: 4px;
}

.db-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-white);
    border: 2px solid var(--border);
    border-radius: 0;
    color: var(--text);
    font-size: 0.82em;
    font-family: monospace;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    height: 32px;
    box-sizing: border-box;
}

.db-btn:hover {
    background: var(--bg-light);
    border-color: var(--primary);
    color: var(--primary);
}

.db-btn .db-icon {
    width: 16px;
    height: 16px;
}

.db-icon {
    stroke-linecap: round;
    stroke-linejoin: round;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
h1 {
    font-size: 1.4em;
    margin: 0;
    color: var(--primary-dark);
    font-family: monospace;
    display: flex;
    align-items: center;
    gap: 8px;
}
.subtitle {
    color: var(--text-dim);
    font-size: 0.75em;
    font-family: monospace;
}
.schema-info {
    background: var(--bg-white);
    padding: 8px 20px;
    border-bottom: 1.5px solid var(--border);
    display: flex;
    justify-content: flex-end;
    align-items: center;
}
.controls {
    display: flex;
    gap: 10px;
    padding: 10px 20px;
    background: var(--bg-white);
    border-bottom: 1.5px solid var(--border);
    flex-wrap: wrap;
    align-items: center;
}
.search-box {
    flex: 0 1 300px;
    min-width: 200px;
    position: relative;
}
.search-box input {
    width: 100%;
    padding: 8px 35px 8px 10px;
    border: 1.5px solid var(--border);
    border-radius: 0;
    background: var(--bg-white);
    color: var(--text);
    font-size: 0.85em;
    font-family: monospace;
    transition: all 0.3s;
}
.search-box input:focus {
    outline: none;
    border-color: var(--primary);
    background: var(--bg-light);
}
.search-icon {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-dim);
}
.btn:not(#spectrum-drawer .btn):not(#spectrum-drawer *) {
    padding: 8px 12px;
    border: 1.5px solid var(--border);
    border-radius: 0;
    cursor: pointer;
    font-size: 0.8em;
    font-weight: 600;
    font-family: monospace;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    white-space: nowrap;
}
.btn-primary:not(#spectrum-drawer .btn-primary):not(#spectrum-drawer *) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.btn-primary:not(#spectrum-drawer .btn-primary):not(#spectrum-drawer *):hover {
    background: var(--primary-dark);
}
.btn-secondary:not(#spectrum-drawer .btn-secondary):not(#spectrum-drawer *) {
    background: var(--bg-white);
    color: var(--text);
}
.btn-secondary:not(#spectrum-drawer .btn-secondary):not(#spectrum-drawer *):hover {
    background: var(--bg-light);
    border-color: var(--primary);
}
.btn-secondary.active:not(#spectrum-drawer .btn-secondary):not(#spectrum-drawer *) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.table-tabs {
    display: flex;
    gap: 0;
    overflow-x: auto;
    padding: 0;
    background: var(--bg-white);
    border-bottom: 1.5px solid var(--border);
    justify-content: flex-start;
}
.table-btn {
    padding: 16px 28px;
    background: var(--bg-light);
    border: none;
    border-right: 1px solid var(--border);
    border-bottom: 2px solid transparent;
    color: var(--text);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-size: 1em;
    font-family: monospace;
    font-weight: 600;
}
.table-btn:first-child {
    border-left: none;
    margin-left: 52px;
}
.table-btn:last-child {
    margin-right: 32px;
}
.table-btn:hover {
    background: var(--bg-white);
    color: var(--primary);
}
.table-btn.active {
    background: var(--bg-white);
    border-bottom-color: var(--primary);
    color: var(--primary);
}
.table-container {
    background: var(--bg-white);
    padding-left: 10px;
}
.table-header {
    padding: 10px 32px;
    border-bottom: 1.5px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: var(--bg-light);
}
.table-title {
    font-size: 1em;
    font-weight: bold;
    font-family: monospace;
    color: var(--primary-dark);
}
.table-count {
    color: var(--text-dim);
    font-size: 0.9em;
}
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85em;
    background: var(--bg-white);
}
thead {
    background: var(--bg-light);
    position: sticky;
    top: 56px;
    z-index: 10;
}
th {
    padding: 8px 10px;
    text-align: left;
    font-weight: 600;
    font-family: monospace;
    color: var(--text);
    border-bottom: 1.5px solid var(--border);
    cursor: pointer;
    user-select: none;
    font-size: 0.75em;
    text-transform: uppercase;
}
th:hover {
    background: var(--bg-page);
    color: var(--primary);
}
tbody tr {
    border-bottom: 1px solid var(--border);
    transition: all 0.15s;
}
tbody tr:hover {
    background: var(--bg-light);
}
td {
    padding: 6px 10px;
    color: var(--text);
    font-family: monospace;
    font-size: 0.85em;
}

/* Make links in table rows inherit the row's text color by default */
.row-entry a {
    color: inherit;
    text-decoration: none;
}

.row-entry a:hover {
    text-decoration: underline;
}

/* Ensure key and uri cells inherit row color */
.row-entry .cell.key,
.row-entry .cell.uri {
    color: inherit;
}

.row-entry .cell.key a,
.row-entry .cell.uri a,
.row-entry .cell.key span,
.row-entry .cell.uri span {
    color: inherit;
}
.row-entry {
    display: flex;
    padding: 10px 0 10px 4px;
    border-bottom: 1px solid var(--border);
    font-family: monospace;
    font-size: 0.9em;
    line-height: 1.2;
    transition: background 0.15s;
    width: 100%;
    align-items: center;
    min-height: 40px;
}
/* Background colors handled by color-rows.css */
.row-entry:nth-child(even) {
    /* Alternating backgrounds handled by color-rows.css */
}
.row-entry:hover {
    /* Hover handled by color-rows.css or defaults */
}
.row-entry .cell {
    padding: 0 1px;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    display: flex;
    align-items: center;
    justify-content: center;
    white-space: nowrap;
}
.row-entry .cell:first-child {
    padding-left: 52px;
}
.row-entry .cell:last-child {
    padding-right: 32px;
}
.row-header {
    display: flex;
    padding: 0;
    background: var(--bg-light);
    border-bottom: 2px solid var(--border);
    font-family: monospace;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--primary-dark);
    position: sticky;
    top: 56px;
    z-index: 10;
    width: 100%;
    align-items: center;
}
.row-header .cell {
    padding: 15px 1px;
    flex: 1;
    min-width: 0;
    cursor: pointer;
    user-select: none;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.row-header .cell:hover {
    color: var(--primary);
    background: var(--bg-page);
}
.row-header .cell:first-child {
    padding-left: 52px;
}
.row-header .cell:last-child {
    padding-right: 32px;
}
.row-header .cell.sorted-asc::after {
    content: '▲';
}
.row-header .cell.sorted-desc::after {
    content: '▼';
}
.row-header .cell.avatar,
.row-entry .cell.avatar {
    flex: 0 0 20px;
    max-width: 20px;
    min-width: 20px;
    padding: 4px 1px;
    text-align: center;
    justify-content: center;
    margin-left: 32px;
}
.row-header .cell.name,
.row-entry .cell.name {
    flex: 0 0 102px;
    max-width: 102px;
    min-width: 102px;
}
.row-entry .cell.name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    justify-content: flex-start;
}
.row-header .cell.handle,
.row-entry .cell.handle {
    flex: 0 0 200px;
    max-width: 200px;
    min-width: 200px;
}
.row-header .cell.souvenirs,
.row-entry .cell.souvenirs {
    flex: 0 0 70px;
    max-width: 70px;
    min-width: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    gap: 2px;
}
.row-header .cell.spectrum,
.row-entry .cell.spectrum {
    flex: 0 0 242px;
    max-width: 242px;
    min-width: 242px;
    font-family: monospace;
    font-size: 1em;
}
.row-header .cell.octant,
.row-entry .cell.octant {
    flex: 0 0 120px;
    max-width: 120px;
    min-width: 120px;
    text-align: center;
    justify-content: center;
    font-size: 1em;
}
.row-header .cell.heading,
.row-entry .cell.heading {
    flex: 0 0 90px;
    max-width: 90px;
    min-width: 90px;
    text-align: center;
    justify-content: center;
    font-family: monospace;
    font-size: 1em;
    color: var(--primary);
}
.row-header .cell.last_change,
.row-entry .cell.last_change {
    flex: 0 0 90px;
    max-width: 90px;
    min-width: 90px;
    text-align: center;
    justify-content: center;
    font-family: monospace;
    font-size: 1em;
    color: var(--primary);
}
.row-header .cell.arrival,
.row-entry .cell.arrival {
    flex: 0 0 72px;
    max-width: 72px;
    min-width: 72px;
    font-size: 1em;
}
.row-header .cell.did,
.row-entry .cell.did {
    flex: 0 0 230px;
    max-width: 230px;
    min-width: 230px;
}
.row-entry .cell.did {
    font-size: 1em;
}
.row-header .cell.entropy,
.row-entry .cell.entropy,
.row-header .cell.oblivion,
.row-entry .cell.oblivion,
.row-header .cell.liberty,
.row-entry .cell.liberty,
.row-header .cell.authority,
.row-entry .cell.authority,
.row-header .cell.receptive,
.row-entry .cell.receptive,
.row-header .cell.skeptic,
.row-entry .cell.skeptic {
    flex: 0 0 50px;
    max-width: 50px;
    min-width: 50px;
    text-align: center;
    justify-content: center;
}
.row-header .cell.description,
.row-entry .cell.description {
    flex: 1;
    max-width: none;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.row-entry .cell.description span {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.row-header .cell.icon,
.row-entry .cell.icon {
    flex: 0 0 60px;
    max-width: 60px;
    min-width: 60px;
    text-align: center;
    justify-content: center;
    font-size: 1.5em;
}
.row-header .cell.phanera,
.row-entry .cell.phanera {
    flex: 0 0 80px;
    max-width: 80px;
    min-width: 80px;
    padding: 4px;
    text-align: center;
    justify-content: center;
}
.row-header .cell.key,
.row-entry .cell.key {
    flex: 0 0 120px;
    max-width: 120px;
    min-width: 120px;
    font-family: monospace;
    font-weight: 600;
}
.row-header .cell.category,
.row-entry .cell.category {
    flex: 0 0 100px;
    max-width: 100px;
    min-width: 100px;
}
.row-header .cell.keepers,
.row-entry .cell.keepers {
    flex: 0 0 80px;
    max-width: 80px;
    min-width: 80px;
    text-align: center;
    justify-content: center;
}
.row-header .cell.canon,
.row-entry .cell.canon {
    flex: 1 1 400px;
    max-width: none;
    min-width: 300px;
    justify-content: flex-start;
    padding-left: 32px;
}
.row-header .cell.event,
.row-entry .cell.event {
    flex: 1 1 300px;
    max-width: none;
    min-width: 250px;
}
.row-header .cell.epoch,
.row-entry .cell.epoch {
    flex: 0 0 110px;
    max-width: 110px;
    min-width: 110px;
    text-align: center;
    justify-content: center;
}
.row-header .cell.thread-arrow,
.row-entry .cell.thread-arrow {
    flex: 0 0 16px;
    max-width: 16px;
    min-width: 16px;
    text-align: center;
    justify-content: center;
    padding: 0;
}
.row-entry .cell.thread-arrow .thread-arrow-icon {
    color: var(--primary);
    font-size: 0.8em;
    opacity: 0.7;
}
.row-header .cell.type,
.row-entry .cell.type {
    flex: 0 0 100px;
    max-width: 100px;
    min-width: 100px;
    text-align: center;
    justify-content: center;
}
.row-header .cell.key,
.row-entry .cell.key {
    flex: 0 0 110px;
    max-width: 110px;
    min-width: 110px;
    text-align: center;
    justify-content: center;
    font-family: monospace;
    font-size: 0.85em;
    font-weight: 600;
}
.row-header .cell.uri,
.row-entry .cell.uri {
    flex: 0 0 95px;
    max-width: 95px;
    min-width: 95px;
    font-family: monospace;
    font-size: 0.9em;
}
.avatar-img,
.avatar-placeholder {
    width: 16px;
    height: 16px;
    border-radius: 50%;
    object-fit: cover;
    display: block;
    margin: 0 auto;
}
.avatar-placeholder {
    background: var(--bg-light);
    border: 2px solid var(--border);
}
.phanera-img {
    width: 70px;
    height: 70px;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

.handle-invalid {
    color: #e74c3c !important;
    font-weight: 600;
}
#rows-container {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    margin: 0;
    padding: 0;
    padding-bottom: 20px; /* Ensure last row is fully visible */
}

/* Modern scrollbar styling - overlay style */
#rows-container::-webkit-scrollbar {
    width: 8px;
}

#rows-container::-webkit-scrollbar-track {
    background: transparent;
}

#rows-container::-webkit-scrollbar-thumb {
    background: rgba(115, 75, 161, 0.4);
    border-radius: 4px;
}

#rows-container::-webkit-scrollbar-thumb:hover {
    background: rgba(115, 75, 161, 0.6);
}

/* Firefox scrollbar */
#rows-container {
    scrollbar-width: thin;
    scrollbar-color: rgba(115, 75, 161, 0.4) transparent;
}
.no-data {
    padding: 40px 20px;
    text-align: center;
    color: var(--text-dim);
    font-size: 0.9em;
    font-family: monospace;
}
.badge {
    display: inline-block;
    padding: 2px 6px;
    border-radius: 0;
    font-size: 0.7em;
    font-weight: 600;
    border: 1px solid currentColor;
}
.badge-primary {
    background: var(--primary);
    color: white;
}
.badge-success {
    background: var(--success);
    color: white;
}
.badge-warning {
    background: var(--warning);
    color: black;
}
.badge-info {
    background: var(--info);
    color: white;
}
.loader {
    border: 4px solid var(--bg-light);
    border-top: 4px solid var(--primary);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    animation: spin 1s linear infinite;
    margin: 50px auto;
}
@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
.error {
    background: var(--danger);
    color: white;
    padding: 10px 20px;
    font-size: 0.85em;
    font-family: monospace;
    border-bottom: 1.5px solid var(--border);
}
.hidden {
    display: none !important;
}
.truncate {
    max-width: 300px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}
.link:hover {
    text-decoration: underline;
}
.json-view {
    background: var(--bg-light);
    padding: 12px;
    border: 1.5px solid var(--border);
    font-family: 'Courier New', monospace;
    font-size: 0.75em;
    max-height: 400px;
    overflow: auto;
    white-space: pre-wrap;
    word-break: break-all;
}
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal.active {
    display: flex;
}
.modal-content {
    background: var(--bg-white);
    border: 1.5px solid var(--border);
    border-radius: 0;
    padding: 20px;
    max-width: 700px;
    max-height: 85vh;
    overflow: auto;
    position: relative;
}
.modal-close {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--bg-light);
    border: 1.5px solid var(--border);
    color: var(--text);
    width: 28px;
    height: 28px;
    border-radius: 0;
    cursor: pointer;
    font-size: 1em;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: monospace;
}
.modal-close:hover {
    background: var(--danger);
    color: white;
    border-color: var(--danger);
}
/* Mindscape Log Styles - Uniform Grey with Subtle Hover */
.log-entry {
    font-size: 0.85rem;
    margin: 0;
    padding: 3px 8px;
    text-align: left;
    font-family: monospace;
    line-height: 1.3;
    color: #666;
}

.log-entry a {
    color: #666;
    text-decoration: none;
    transition: color 0.2s ease;
}

.log-entry a:hover {
    color: #999;
}

.log-entry code {
    font-size: 0.7rem;
    color: #666;
    cursor: pointer;
    font-family: monospace;
    transition: color 0.2s ease;
}

.log-entry code:hover {
    color: #999;
}

/* User listing box below mindscape log */
#mindscape-user-listing-container .log-entry {
    background-color: #f5f5f5;
    text-align: center;
    border-top: 1px solid white;
    padding: 8px;
    margin-bottom: 10px;
}

#mindscape-user-listing-container .log-entry strong {
    color: #666;
}

#mindscape-user-listing-container .log-entry a {
    color: #666;
    text-decoration: none;
    transition: color 0.2s ease;
}

#mindscape-user-listing-container .log-entry a:hover {
    color: #999;
}

@media (max-width: 768px) {
    /* Database layout - stack vertically on mobile */
    .database-layout {
        flex-direction: column;
        top: 70px; /* Smaller header on mobile */
        bottom: 64px; /* Still respect drawer */
    }
    
    /* Left column becomes top stats bar on mobile */
    .database-left-column {
        width: 100%;
        flex-shrink: 0;
        max-height: 200px;
        overflow-y: auto;
        border-right: none;
        border-bottom: 2px solid #5a4a7a;
        padding: 12px 16px;
    }
    
    /* Hide the mindscape section on mobile to save space */
    .mindscape-section {
        display: none;
    }
    
    /* Compact stats on mobile */
    .stat-item {
        padding: 4px 0;
        font-size: 0.75em;
    }
    
    /* Main content fills remaining space */
    .database-main-content {
        flex: 1;
        min-height: 0;
    }
    
    /* Compact header bar */
    .page-header-fixed {
        padding: 8px 12px;
        gap: 6px;
        height: 44px;
        flex-wrap: wrap;
    }
    
    .db-search-input {
        flex: 1 1 120px;
        min-width: 100px;
        font-size: 0.8em;
        height: 28px;
    }
    
    .db-filter-dropdown {
        font-size: 0.75em;
        height: 28px;
        padding: 4px 24px 4px 8px;
    }
    
    .db-btn {
        height: 28px;
        padding: 4px 6px;
    }
    
    /* Hide epoch on very small screens */
    #current-epoch {
        display: none;
    }
    
    /* Enable horizontal scroll for event rows */
    #rows-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Compact rows on mobile */
    .row-entry {
        padding: 8px 12px;
        min-width: auto;
        font-size: 0.85em;
    }
    
    .row-entry .cell:first-child {
        padding-left: 12px;
    }
    
    .row-entry .cell:last-child {
        padding-right: 12px;
    }
    
    /* Hide less critical columns on mobile */
    .row-header .cell.type,
    .row-entry .cell.type,
    .row-header .cell.key,
    .row-entry .cell.key,
    .row-header .cell.uri,
    .row-entry .cell.uri {
        display: none;
    }
    
    /* Adjust column widths for mobile */
    .row-header .cell.epoch,
    .row-entry .cell.epoch {
        flex: 0 0 70px;
        max-width: 70px;
        min-width: 70px;
        font-size: 0.75em;
    }
    
    .row-header .cell.avatar,
    .row-entry .cell.avatar {
        flex: 0 0 20px;
        max-width: 20px;
        min-width: 20px;
        margin-left: 8px;
    }
    
    .row-header .cell.canon,
    .row-entry .cell.canon {
        flex: 1;
        min-width: 150px;
        padding-left: 12px;
    }
}

.row-entry.header-row {
    background: var(--primary-dark);
    color: white;
    font-weight: 700;
    border-bottom: 3px solid var(--primary);
    min-height: 45px;
    font-size: 0.85em;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.row-entry.header-row:hover {
    background: var(--primary-dark);
}
.row-entry.book-row {
    background: var(--bg-light);
    font-weight: 600;
    border-top: 2px solid var(--border-dark);
    border-bottom: 2px solid var(--border-dark);
    min-height: 60px;
}
.row-entry.book-row:hover {
    background: #e8e0f5;
}
.row-entry.chapter-row {
    background: var(--bg-white);
    padding-left: 0;
    min-height: 35px;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
}
.row-entry.chapter-row:nth-child(even) {
    background: #fafafa;
}
.row-entry.chapter-row:hover {
    background: var(--bg-light);
}
.row-header .cell.cover,
.row-entry .cell.cover {
    flex: 0 0 60px;
    max-width: 60px;
    min-width: 60px;
    padding: 4px;
    text-align: center;
    justify-content: center;
    margin-left: 32px;
}

.row-entry .cell.cover img {
    border-radius: 0;
}

.row-header .cell.title,
.row-entry .cell.title {
    flex: 1 1 350px;
    min-width: 250px;
}
.row-entry.chapter-row .cell.title {
    flex: 1;
    max-width: none;
    padding-left: 35px;
    font-size: 0.9em;
    justify-content: flex-start;
}
.row-entry.chapter-row .cell.author {
    flex: 0 0 60px;
    max-width: 60px;
    min-width: 60px;
    padding-left: 40px;
    font-weight: 600; 
    color: #333; 
    font-size: 0.9em; 
}
.row-header .cell.author,
.row-entry .cell.author {
    flex: 0 0 150px;
    max-width: 150px;
    min-width: 150px;
    font-size: 0.85em;
}
.row-header .cell.pages,
.row-entry .cell.pages {
    flex: 0 0 70px;
    max-width: 70px;
    min-width: 70px;
    text-align: center;
    justify-content: center;
}
.row-header .cell.release,
.row-entry .cell.release {
    flex: 0 0 90px;
    max-width: 90px;
    min-width: 90px;
    text-align: center;
    justify-content: center;
}
.row-header .cell.epub,
.row-entry .cell.epub {
    flex: 0 0 100px;
    max-width: 100px;
    min-width: 100px;
    text-align: center;
    justify-content: center;
}
.timeline-spectrum-controls {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 15px;
    padding: 15px;
    background: var(--bg-light);
    border: 1px solid var(--border);
}
.view-control-section {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
}
.control-btn:not(#spectrum-drawer .control-btn):not(#spectrum-drawer *) {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-white);
    border: 1.5px solid var(--border);
    color: var(--text);
    cursor: pointer;
    font-family: monospace;
    font-size: 0.85em;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}
.control-btn:not(#spectrum-drawer .control-btn):not(#spectrum-drawer *):hover {
    background: var(--bg-light);
    border-color: var(--primary);
    color: var(--primary);
}
.control-btn.active:not(#spectrum-drawer .control-btn):not(#spectrum-drawer *) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}
.control-btn .icon:not(#spectrum-drawer *) {
    font-size: 1em;
}
.control-btn .label:not(#spectrum-drawer *) {
    font-size: 0.9em;
}
.view-btn:not(#spectrum-drawer .view-btn):not(#spectrum-drawer *) {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: var(--bg-white);
    border: 1.5px solid var(--border);
    color: var(--text);
    cursor: pointer;
    font-family: monospace;
    font-size: 0.9em;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}
.view-btn:not(#spectrum-drawer .view-btn):not(#spectrum-drawer *):hover {
    background: var(--bg-light);
    border-color: var(--primary);
    color: var(--primary);
}
.view-btn.active:not(#spectrum-drawer .view-btn):not(#spectrum-drawer *) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Spectrum score hover tooltips */
.spectrum-score {
    position: relative;
    padding: 2px 4px;
    cursor: help;
    transition: all 0.2s;
    border-radius: 3px;
}
.spectrum-score:hover {
    background: var(--primary-light);
    color: var(--primary);
    font-weight: 600;
}
.spectrum-score::after {
    content: attr(data-label);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 8px;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    font-size: 0.75em;
    font-family: var(--font-sans);
    border-radius: 4px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    margin-bottom: 4px;
    z-index: 1000;
}
.spectrum-score:hover::after {
    opacity: 1;
}

@media (max-width: 768px) {
    .timeline-spectrum-controls {
        padding: 10px;
    }
    .view-control-section {
        flex-direction: column;
    }
    .control-btn,
    .view-btn {
        width: 100%;
        justify-content: center;
    }
}

/* Reaction row styling - layout only, colors in color-rows.css */
.row-entry.reaction-row {
    opacity: 0.95;
}

.row-entry.reaction-row:hover {
    opacity: 1;
}

.row-entry.reaction-row .cell.avatar {
    position: relative;
}

/* Add left padding to reaction row's epoch cell for indentation */
.row-entry.reaction-row .cell.epoch {
    padding-left: 40px;
}

/* Canon row styling - uses custom properties set inline per row */
.row-entry.canon-row {
    background: linear-gradient(
        to right,
        rgba(var(--canon-color-rgb), 0.25) 0%,
        rgba(var(--canon-color-rgb), 0.15) 30%,
        rgba(var(--canon-color-rgb), 0.08) 70%,
        rgba(var(--canon-color-rgb), 0.03) 100%
    ) !important;
    border-left: 4px solid var(--canon-color) !important;
    border-top: 1px solid rgba(var(--canon-color-rgb), 0.3) !important;
    border-bottom: 1px solid rgba(var(--canon-color-rgb), 0.3) !important;
    box-shadow: inset 0 0 8px rgba(var(--canon-color-rgb), 0.15), 
                0 1px 3px rgba(var(--canon-color-rgb), 0.2);
    color: var(--canon-color) !important;
}

.row-entry.canon-row:hover {
    background: linear-gradient(
        to right,
        rgba(var(--canon-color-rgb), 0.35) 0%,
        rgba(var(--canon-color-rgb), 0.22) 30%,
        rgba(var(--canon-color-rgb), 0.12) 70%,
        rgba(var(--canon-color-rgb), 0.05) 100%
    ) !important;
    box-shadow: inset 0 0 12px rgba(var(--canon-color-rgb), 0.2),
                0 2px 4px rgba(var(--canon-color-rgb), 0.3);
}

.row-entry.canon-row:nth-child(even) {
    background: linear-gradient(
        to right,
        rgba(var(--canon-color-rgb), 0.28) 0%,
        rgba(var(--canon-color-rgb), 0.18) 30%,
        rgba(var(--canon-color-rgb), 0.10) 70%,
        rgba(var(--canon-color-rgb), 0.04) 100%
    ) !important;
}

.row-entry.canon-row:nth-child(even):hover {
    background: linear-gradient(
        to right,
        rgba(var(--canon-color-rgb), 0.38) 0%,
        rgba(var(--canon-color-rgb), 0.25) 30%,
        rgba(var(--canon-color-rgb), 0.14) 70%,
        rgba(var(--canon-color-rgb), 0.06) 100%
    ) !important;
}

.row-entry.canon-row .cell {
    color: var(--canon-color) !important;
}

.row-entry.canon-row .cell.epoch,
.row-entry.canon-row .cell.type,
.row-entry.canon-row .cell.key {
    font-weight: 600;
}

.row-entry.canon-row .cell.canon a {
    color: var(--canon-color) !important;
    font-weight: 700;
    text-shadow: 0 0 1px rgba(var(--canon-color-rgb), 0.3);
}

.row-entry.canon-row .cell.canon span {
    color: var(--canon-color) !important;
}

/* Dream row styling - similar to canon but with dream-specific colors */
.row-entry.dream-row {
    background: linear-gradient(
        to right,
        rgba(var(--dream-color-rgb), 0.20) 0%,
        rgba(var(--dream-color-rgb), 0.12) 30%,
        rgba(var(--dream-color-rgb), 0.06) 70%,
        rgba(var(--dream-color-rgb), 0.02) 100%
    ) !important;
    border-left: 3px solid var(--dream-color) !important;
    border-top: 1px solid rgba(var(--dream-color-rgb), 0.25) !important;
    border-bottom: 1px solid rgba(var(--dream-color-rgb), 0.25) !important;
    box-shadow: inset 0 0 6px rgba(var(--dream-color-rgb), 0.12), 
                0 1px 2px rgba(var(--dream-color-rgb), 0.15);
}

.row-entry.dream-row:hover {
    background: linear-gradient(
        to right,
        rgba(var(--dream-color-rgb), 0.30) 0%,
        rgba(var(--dream-color-rgb), 0.18) 30%,
        rgba(var(--dream-color-rgb), 0.09) 70%,
        rgba(var(--dream-color-rgb), 0.03) 100%
    ) !important;
    box-shadow: inset 0 0 10px rgba(var(--dream-color-rgb), 0.18),
                0 2px 3px rgba(var(--dream-color-rgb), 0.2);
}

.row-entry.dream-row .cell {
    color: var(--dream-color) !important;
}

.row-entry.dream-row .cell.type,
.row-entry.dream-row .cell.key {
    font-weight: 600;
    text-shadow: 0 0 1px rgba(var(--dream-color-rgb), 0.3);
}

/* Dream-specific styles */
.row-entry.dream-flawed {
    --dream-color: #454545;
    --dream-color-rgb: 69, 69, 69;
}

.row-entry.dream-flawed .cell,
.row-entry.dream-flawed img {
    filter: blur(2.5px) !important;
    animation: clarityTimer 15s ease-in-out infinite !important;
    transition: filter 0.4s ease-out !important;
}

.row-entry.dream-flawed:hover .cell,
.row-entry.dream-flawed:hover img {
    filter: blur(0px) !important;
    animation: none !important;
}

@keyframes clarityTimer {
    0%, 90% {
        filter: blur(2.5px);
    }
    93%, 97% {
        filter: blur(0px);
    }
    100% {
        filter: blur(2.5px);
    }
}
