
* {
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    margin: 0;
    padding: 0;
    background: #0f0f0f;
    color: #e0e0e0;
    overflow: hidden;
    height: 100vh;
}

.container {
    display: flex;
    height: 100vh;
}

.viewer-section {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    background: #111111;
    position: relative;
    /* Performance optimizations */
    will-change: transform;
    transform: translateZ(0);
}

.controls-section {
    width: 320px;
    background: #1a1a1a;
    border-left: 1px solid #333333;
    padding: 20px;
    overflow-y: auto;
    /* Performance optimizations */
    will-change: transform;
    transform: translateZ(0);
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

.header {
    text-align: center;
    margin-bottom: 20px;
}

.header h1 {
    font-size: 22px;
    font-weight: 600;
    color: #ffffff;
    margin: 0;
    letter-spacing: -0.5px;
}

.header .subtitle {
    font-size: 12px;
    color: #888888;
    margin-top: 4px;
    font-weight: 300;
}

/* tab navigation */
.tab-container {
    margin-bottom: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tab-nav {
    display: flex;
    background: #1a1a1a;
    border-radius: 6px 6px 0 0;
    border: 1px solid #333333;
    border-bottom: none;
    overflow: hidden;
    width: fit-content;
}

.tab-button {
    padding: 12px 20px;
    background: #262626;
    color: #aaaaaa;
    border: none;
    cursor: pointer;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background-color 0.15s ease-out;
    border-right: 1px solid #333333;
    margin: 0;
    width: auto;
}

.tab-button:last-child {
    border-right: none;
}

.tab-button.active {
    background: #333333;
    color: #ffffff;
}

.tab-button:hover:not(.active) {
    background: #2f2f2f;
    color: #cccccc;
}

.tab-content {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tab-panel {
    display: none;
    height: 100%;
    flex: 1;
    min-height: 0;
}

.tab-panel.active {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

#viewer-container {
    flex: 1;
    background: #000000;
    border: 1px solid #333333;
    border-radius: 8px;
    position: relative;
    margin-bottom: 16px;
    height: 100%;
    min-height: 280px;
}

.control-panel {
    background: #1f1f1f;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 16px;
    margin-bottom: 12px;
}

.control-panel h2 {
    margin: 0 0 12px 0;
    font-size: 13px;
    color: #cccccc;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.control-group {
    margin-bottom: 12px;
}

label {
    display: block;
    font-size: 11px;
    color: #aaaaaa;
    margin-bottom: 6px;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

input, select {
    width: 100%;
    padding: 10px 12px;
    background: #262626;
    border: 1px solid #404040;
    border-radius: 4px;
    color: #e0e0e0;
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    transition: border-color 0.15s ease-out;
}

input:focus, select:focus {
    outline: none;
    border-color: #555555;
}

button {
    width: 100%;
    padding: 10px 12px;
    background: #2a2a2a;
    color: #ffffff;
    border: 1px solid #404040;
    border-radius: 4px;
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.15s ease-out;
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

button:hover {
    background: #333333;
    border-color: #555555;
}

button:active {
    background: #252525;
}

.file-input {
    position: relative;
}

.file-input input[type=file] {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
}

.file-input:focus-within .file-label {
    outline: 3px solid #ffdc55;
    outline-offset: 2px;
}

.file-label {
    display: block;
    width: 100%;
    padding: 10px 12px;
    background: #262626;
    border: 1px solid #404040;
    border-radius: 4px;
    color: #aaaaaa;
    text-align: center;
    cursor: pointer;
    transition: background-color 0.15s ease-out;
    font-size: 12px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.file-label:hover {
    background: #333333;
    border-color: #555555;
    color: #cccccc;
}

.file-name {
    font-size: 10px;
    color: #aaaaaa;
    margin-top: 4px;
    font-style: italic;
}

.status-display {
    background: #1a1a1a;
    padding: 12px;
    border-radius: 6px;
    font-size: 11px;
    color: #cccccc;
    text-align: center;
    border: 1px solid #2a2a2a;
    margin-top: auto;
}

.molecular-stats {
    background: #1a1a1a;
    border: 1px solid #2a2a2a;
    border-radius: 6px;
    padding: 12px;
    margin-bottom: 12px;
}

.stat-line {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
    font-size: 11px;
}

.stat-line:last-child {
    margin-bottom: 0;
}

.stat-value {
    color: #ffffff;
    font-weight: 500;
}

.quick-load {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}

.quick-load button {
    flex: 1;
    min-width: 60px;
    padding: 8px 6px;
    font-size: 10px;
    margin-bottom: 0;
    background: #333333;
    border-color: #555555;
}

.quick-load button:hover {
    background: #404040;
}

/* View controls */
.view-controls {
    display: flex;
    gap: 6px;
    margin-bottom: 8px;
}

.view-controls button {
    flex: 1;
    padding: 8px 6px;
    font-size: 10px;
    margin-bottom: 0;
}

/* Color scheme selector */
.color-scheme {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

.color-scheme button {
    flex: 1;
    padding: 8px 6px;
    font-size: 10px;
    margin-bottom: 0;
}

/* Amino acid modal */
.amino-acid-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #1a1a1a;
    border: 1px solid #333333;
    border-radius: 8px;
    width: 90%;
    max-width: 600px;
    max-height: 80vh;
    z-index: 1000;
    display: none;
    flex-direction: column;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.5);
}

.amino-acid-modal.active {
    display: flex;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #333333;
}

.modal-title {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
}

.modal-close {
    background: none;
    border: none;
    color: #aaaaaa;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: auto;
    height: auto;
    margin: 0;
}

.modal-close:hover {
    color: #ffffff;
    background: none;
}

.amino-acid-structure {
    height: 200px;
    background: #000000;
    border-bottom: 1px solid #333333;
    display: flex;
    align-items: center;
    justify-content: center;
}

#structure-placeholder {
    color: #666666;
    font-size: 14px;
}

.amino-acid-info {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.amino-acid-info h4 {
    margin: 0 0 12px 0;
    font-size: 14px;
    color: #ffffff;
    font-weight: 600;
}

.amino-acid-info .info-row {
    display: flex;
    margin-bottom: 8px;
    font-size: 12px;
}

.amino-acid-info .info-label {
    font-weight: 500;
    color: #aaaaaa;
    min-width: 120px;
    margin-right: 12px;
}

.amino-acid-info .info-value {
    color: #ffffff;
    font-weight: 400;
}

.amino-acid-description {
    padding: 0 20px 20px 20px;
    font-size: 12px;
    color: #cccccc;
    line-height: 1.4;
}

/* Validation and error styles */
.pdb-validation-indicator {
    margin-top: 8px;
    padding: 8px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    text-align: center;
    display: none;
}

.pdb-validation-indicator.valid {
    background: rgba(81, 207, 102, 0.1);
    border: 1px solid #51cf66;
    color: #51cf66;
    display: block;
}

.pdb-validation-indicator.invalid {
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid #ff6b6b;
    color: #ff6b6b;
    display: block;
}

.pdb-validation-indicator.checking {
    background: rgba(255, 199, 95, 0.1);
    border: 1px solid #ffc75f;
    color: #ffc75f;
    display: block;
}

.pdb-validation-indicator.checking::before {
    content: "🔍 ";
    animation: pulse 1.5s ease-in-out infinite;
}

.pdb-error-display {
    margin-top: 8px;
    padding: 8px 12px;
    background: rgba(255, 107, 107, 0.1);
    border: 1px solid #ff6b6b;
    border-radius: 4px;
    color: #ff6b6b;
    font-size: 11px;
    display: none;
    animation: errorSlideIn 0.3s ease-out;
}

.pdb-error-display.show {
    display: block;
}

@keyframes errorSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 0.6; }
    50% { opacity: 1; }
}

/* Literature tab styles */
.literature-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.literature-header {
    padding: 15px;
    background: #1a1a1a;
    border: 1px solid #333333;
    border-radius: 6px 6px 0 0;
    border-bottom: none;
}

.literature-title {
    font-size: 14px;
    font-weight: 600;
    color: #ffffff;
    margin-bottom: 8px;
}

.literature-info {
    font-size: 11px;
    color: #aaaaaa;
}

.papers-list {
    flex: 1;
    background: #000000;
    border: 1px solid #333333;
    border-radius: 0 0 6px 6px;
    overflow-y: auto;
    padding: 15px;
    /* Performance optimizations */
    contain: layout style paint;
    -webkit-overflow-scrolling: touch;
}

.paper-item {
    background: #1a1a1a;
    border: 1px solid #333333;
    border-radius: 6px;
    padding: 15px;
    margin-bottom: 12px;
    cursor: pointer;
    transition: background-color 0.15s ease-out;
}

.paper-item:hover {
    background: #262626;
    border-color: #555555;
}

.paper-title {
    font-size: 13px;
    font-weight: 500;
    color: #ffffff;
    margin-bottom: 8px;
    line-height: 1.3;
}

.paper-authors {
    font-size: 11px;
    color: #aaaaaa;
    margin-bottom: 6px;
}

.paper-journal {
    font-size: 11px;
    color: #888888;
    margin-bottom: 8px;
}

.paper-abstract {
    font-size: 10px;
    color: #cccccc;
    line-height: 1.4;
    max-height: 60px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 4;
    -webkit-box-orient: vertical;
}

.loading-literature {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #aaaaaa;
    font-size: 12px;
}

.no-literature {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #888888;
    font-size: 12px;
    text-align: center;
    flex-direction: column;
}

/* Raw PDB tab styles */
.rawpdb-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #0f0f0f;
    min-height: 0;
}

.rawpdb-header {
    padding: 15px 20px;
    border-bottom: 1px solid #333;
    background: #1a1a1a;
}

.rawpdb-title {
    font-size: 14px;
    font-weight: 500;
    color: #fff;
    margin-bottom: 5px;
}

.rawpdb-info {
    font-size: 11px;
    color: #888;
}

.rawpdb-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: auto;
    padding: 0;
    max-height: calc(100vh - 200px);
}

.no-rawpdb {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 200px;
    color: #888888;
    font-size: 12px;
    text-align: center;
    flex-direction: column;
}

.pdb-table {
    width: 100%;
    border-collapse: collapse;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    background: #0f0f0f;
    table-layout: fixed;
}

.pdb-table th {
    background: #2a2a2a;
    color: #fff;
    padding: 8px 6px;
    text-align: left;
    border-bottom: 1px solid #555;
    font-weight: 500;
    position: sticky;
    top: 0;
    z-index: 10;
}

.pdb-table th:nth-child(1) { width: 60px; }
.pdb-table th:nth-child(2) { width: 80px; }
.pdb-table th:nth-child(3) { width: calc(100% - 140px); }

.pdb-table td {
    padding: 4px 6px;
    border-bottom: 1px solid #333;
    color: #ddd;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.pdb-table tr:nth-child(even) {
    background: #1a1a1a;
}

.pdb-table tr:hover {
    background: #2a2a2a;
}

.record-type {
    font-weight: bold;
    color: #4a9eff;
}

.record-header {
    background: #333 !important;
    color: #fff !important;
    font-weight: bold;
}

.record-atom {
    color: #ffaa44;
}

.record-hetatm {
    color: #ff6b6b;
}

.record-conect {
    color: #51cf66;
}

.pdb-filters {
    padding: 8px 15px;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    display: flex;
    gap: 10px;
    align-items: center;
}

.pdb-filter-dropdown {
    background: #2a2a2a;
    border: 1px solid #555;
    color: #ddd;
    padding: 6px 12px;
    border-radius: 4px;
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background-color 0.15s ease-out;
    min-width: 140px;
    outline: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23888' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 8px center;
    background-repeat: no-repeat;
    background-size: 12px;
    padding-right: 32px;
    appearance: none;
}

.pdb-filter-dropdown:hover {
    background: #3a3a3a;
    border-color: #666;
}

.pdb-filter-dropdown:focus {
    border-color: #4a9eff;
}

.fast-grid-container {
    height: 100%;
    display: flex;
    flex-direction: column;
    background: #0f0f0f;
    position: relative;
    /* Performance optimizations */
    contain: layout style paint;
}

.fast-grid-header {
    display: flex;
    background: #2a2a2a;
    border-bottom: 2px solid #555;
    position: sticky;
    top: 0;
    z-index: 100;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    font-weight: 500;
}

.fast-grid-header-cell {
    padding: 8px 6px;
    color: #fff;
    border-right: 1px solid #555;
    display: flex;
    align-items: center;
}

.fast-grid-header-cell:nth-child(1) { width: 60px; min-width: 60px; }
.fast-grid-header-cell:nth-child(2) { width: 80px; min-width: 80px; }
.fast-grid-header-cell:nth-child(3) { flex: 1; }

.fast-grid-viewport {
    flex: 1;
    overflow: auto;
    position: relative;
    background: #0f0f0f;
    /* Better text rendering during transforms */
    will-change: transform;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    backface-visibility: hidden;
}

.fast-grid-content {
    position: relative;
}

.fast-grid-row {
    display: flex;
    position: absolute;
    left: 0;
    right: 0;
    height: 24px;
    border-bottom: 1px solid #333;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    transition: background-color 0.1s;
}

.fast-grid-row:nth-child(even) {
    background: #1a1a1a;
}

.fast-grid-row:hover {
    background: #2a2a2a !important;
}

.fast-grid-cell {
    padding: 4px 6px;
    color: #ddd;
    border-right: 1px solid #333;
    display: flex;
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.fast-grid-cell:nth-child(1) { width: 60px; min-width: 60px; }
.fast-grid-cell:nth-child(2) { width: 80px; min-width: 80px; }
.fast-grid-cell:nth-child(3) { flex: 1; }

.fast-grid-stats {
    padding: 8px 15px;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    font-size: 10px;
    color: #888;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.fast-grid-performance {
    font-size: 9px;
    color: #51cf66;
}

.line-number {
    color: #666;
    font-weight: 500;
    text-align: right;
}

.record-type {
    font-weight: bold;
    color: #4a9eff;
}

.record-content {
    font-family: 'Courier New', monospace;
    color: #ddd;
}

.record-header {
    background: #333 !important;
    color: #fff !important;
    font-weight: bold;
}

.record-atom {
    color: #ffaa44;
}

.record-hetatm {
    color: #ff6b6b;
}

.record-conect {
    color: #51cf66;
}

.record-end {
    color: #888;
    font-style: italic;
}

.pdb-zoom-controls {
    padding: 8px 15px;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    display: flex;
    gap: 10px;
    align-items: center;
}

.pdb-zoom-label {
    font-size: 11px;
    color: #aaa;
    font-weight: 500;
}

/* Atom controls */
.atom-controls {
    padding: 8px 15px;
    background: #1a1a1a;
    border-bottom: 1px solid #333;
    display: flex;
    gap: 10px;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
}

.atom-filter-group {
    display: flex;
    align-items: center;
    gap: 5px;
}

.atom-filter-label {
    font-size: 11px;
    color: #aaa;
    font-weight: 500;
    white-space: nowrap;
}

.atom-filter-select {
    background: #2a2a2a;
    border: 1px solid #555;
    color: #ddd;
    padding: 6px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: background-color 0.15s ease-out;
    min-width: 100px;
    outline: none;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23888' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
    background-position: right 8px center;
    background-repeat: no-repeat;
    background-size: 10px;
    padding-right: 24px;
    appearance: none;
}

.atom-filter-select:hover {
    background: #3a3a3a;
    border-color: #666;
}

.atom-filter-select:focus {
    border-color: #4a9eff;
}

.atom-filter-group:has(select) {
    cursor: pointer;
    min-width: 120px;
}

.atom-stats {
    margin-left: auto;
    font-size: 11px;
    color: #888;
}

.zoom-btn {
    background: #2a2a2a;
    border: 1px solid #555;
    color: #ddd;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    margin: 0 2px;
    transition: background-color 0.15s ease-out;
    min-width: auto;
    width: auto;
}

.zoom-btn:hover {
    background: #3a3a3a;
    border-color: #666;
}

.zoom-level {
    font-size: 10px;
    color: #888;
    margin-left: 5px;
    min-width: 40px;
    display: inline-block;
}

.atom-table-container {
    flex: 1;
    background: #0f0f0f;
    position: relative;
    contain: layout style paint;
}

.atom-table-header {
    display: flex;
    background: #2a2a2a;
    border-bottom: 2px solid #555;
    position: sticky;
    top: 0;
    z-index: 100;
    font-family: 'Courier New', monospace;
    font-size: 10px;
    font-weight: 600;
}

.atom-table-header-cell {
    padding: 8px 6px;
    color: #fff;
    border-right: 1px solid #555;
    display: flex;
    align-items: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.atom-table-header-cell:nth-child(1) { width: 80px; min-width: 80px; } /* Serial */
.atom-table-header-cell:nth-child(2) { width: 70px; min-width: 70px; } /* Type */
.atom-table-header-cell:nth-child(3) { width: 80px; min-width: 80px; } /* Atom */
.atom-table-header-cell:nth-child(4) { width: 70px; min-width: 70px; } /* Res */
.atom-table-header-cell:nth-child(5) { width: 60px; min-width: 60px; } /* Chain */
.atom-table-header-cell:nth-child(6) { width: 70px; min-width: 70px; } /* Res# */
.atom-table-header-cell:nth-child(7) { width: 90px; min-width: 90px; } /* X */
.atom-table-header-cell:nth-child(8) { width: 90px; min-width: 90px; } /* Y */
.atom-table-header-cell:nth-child(9) { width: 90px; min-width: 90px; } /* Z */
.atom-table-header-cell:nth-child(10) { width: 70px; min-width: 70px; } /* Occ */
.atom-table-header-cell:nth-child(11) { width: 70px; min-width: 70px; } /* B-fact */
.atom-table-header-cell:nth-child(12) { width: 60px; min-width: 60px; } /* Element */

.atom-table-viewport {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    background: #0f0f0f;
    height: 100%;
    min-height: 300px;
    max-height: calc(100vh - 300px);
    /* Force hardware acceleration */
    will-change: scroll-position, transform;
    transform: translateZ(0);
    -webkit-overflow-scrolling: touch;
    /* Better text rendering during transforms */
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    backface-visibility: hidden;
}

.atom-table-content {
    position: relative;
}

.atom-table-row {
    display: flex;
    position: absolute;
    left: 0;
    right: 0;
    height: 22px;
    border-bottom: 1px solid #333;
    font-family: 'Courier New', monospace;
    font-size: 9px;
    transition: background-color 0.1s;
}

.atom-table-row:nth-child(even) {
    background: #1a1a1a;
}

.atom-table-row:hover {
    background: #2a2a2a !important;
}

.atom-table-row.atom-type {
    border-left: 3px solid #4a9eff;
}

.atom-table-row.hetatm-type {
    border-left: 3px solid #ff6b6b;
}

.atom-table-cell {
    padding: 3px 6px;
    color: #ddd;
    border-right: 1px solid #333;
    display: flex;
    align-items: center;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.atom-table-cell:nth-child(1) { width: 80px; min-width: 80px; }
.atom-table-cell:nth-child(2) { width: 70px; min-width: 70px; }
.atom-table-cell:nth-child(3) { width: 80px; min-width: 80px; }
.atom-table-cell:nth-child(4) { width: 70px; min-width: 70px; }
.atom-table-cell:nth-child(5) { width: 60px; min-width: 60px; }
.atom-table-cell:nth-child(6) { width: 70px; min-width: 70px; }
.atom-table-cell:nth-child(7) { width: 90px; min-width: 90px; }
.atom-table-cell:nth-child(8) { width: 90px; min-width: 90px; }
.atom-table-cell:nth-child(9) { width: 90px; min-width: 90px; }
.atom-table-cell:nth-child(10) { width: 70px; min-width: 70px; }
.atom-table-cell:nth-child(11) { width: 70px; min-width: 70px; }
.atom-table-cell:nth-child(12) { width: 60px; min-width: 60px; }

.atom-serial { font-weight: 500; color: #88ccff; }
.atom-name { font-weight: 600; color: #ffaa44; }
.residue-name { color: #51cf66; font-weight: 500; }
.chain-id { color: #ff9f43; font-weight: 600; }
.coordinate { color: #feca57; text-align: right; font-family: 'Courier New', monospace; }
.factor { color: #ff6b9d; text-align: right; }
.element { color: #c44569; font-weight: 600; text-align: center; }

/* Paper viewer modal */
.paper-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 2000;
    display: none;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.paper-viewer.active {
    display: flex;
}

.paper-viewer-content {
    background: #1a1a1a;
    border-radius: 8px;
    border: 1px solid #333333;
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.paper-viewer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #333333;
}

.paper-viewer-title {
    font-size: 16px;
    font-weight: 600;
    color: #ffffff;
}

.paper-viewer-close {
    background: none;
    border: none;
    color: #aaaaaa;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: auto;
    height: auto;
    margin: 0;
}

.paper-viewer-close:hover {
    color: #ffffff;
    background: none;
}

.paper-viewer-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
    color: #e0e0e0;
    line-height: 1.6;
}

.paper-viewer-body h3 {
    color: #ffffff;
    margin-top: 0;
    margin-bottom: 12px;
}

.paper-viewer-body p {
    margin-bottom: 12px;
}

.paper-viewer-body a {
    color: #4a9eff;
    text-decoration: none;
}

.paper-viewer-body a:hover {
    text-decoration: underline;
} 

/* Keep all controls visible on short screens and narrow phones. */
.tab-container, .tab-content { min-height: 0; }
.viewer-section { min-width: 0; }
.control-panel p, #sequence-panel p { font-size: 12px; color: #bcbcbc; line-height: 1.5; }
#sequence-panel { flex: 0 0 auto; max-height: 190px; overflow: auto; border: 1px solid #555; border-radius: 6px; padding: 10px; }
#sequence-panel h2 { font-size: 14px; margin: 0; }
.sequence-chain { display: flex; align-items: center; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.sequence-chain > span { font-size: 12px; }
button.sequence-residue { width: auto; min-width: 44px; min-height: 36px; padding: 5px; margin: 0; font-family: monospace; }
button.sequence-residue[aria-pressed="true"] { color: #111; background: #ffdc55; }
:focus-visible { outline: 3px solid #ffdc55 !important; outline-offset: 2px; }
#distance-result { display: block; font-size: 13px; line-height: 1.5; overflow-wrap: anywhere; margin-top: 8px; }
.file-dragging .container { outline: 4px dashed #ffdc55; outline-offset: -5px; }
.header .subtitle, .stat-line, .atom-filter-label, .zoom-level { color: #bcbcbc; }
.controls-section { scrollbar-gutter: stable; }
@media (max-width: 760px), (max-height: 650px) {
    body { overflow: auto; height: auto; }
    .container { height: auto; min-height: 100vh; flex-direction: column; }
    .viewer-section { min-height: 650px; }
    #viewer-container { height: 350px; flex: 0 0 350px; }
    .controls-section { width: 100%; overflow: visible; border-left: 0; }
    .tab-button { padding: 12px; }
}
dialog[open] { display: flex; color: #e0e0e0; margin: 0; }
dialog::backdrop { background: #000a; }
.amino-acid-modal[open] { flex-direction: column; }