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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    background: #f0f0f0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Top bar */
.topbar {
    background: #1a1a1a;
    padding: 10px 24px;
    display: flex;
    align-items: center;
    position: relative;
}

.topbar-title {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
}

.topbar-title {
    color: #fff;
    font-size: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-decoration: none;
}

.topbar-title:hover {
    opacity: 0.8;
}

.topbar-help {
    color: #999;
    font-size: 14px;
    font-weight: 600;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-left: auto;
}

.topbar-help:hover {
    color: #fff;
}

.container {
    max-width: 1120px;
    margin: 0 auto;
    background: white;
    border-radius: 0;
    padding: 36px 40px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
    flex: 1;
    width: 100%;
}

/* Common */
h2 {
    color: #444;
    margin-bottom: 15px;
    font-size: 20px;
}

.section {
    margin-bottom: 24px;
}

/* Buttons */
button {
    background: #1a1a1a;
    color: white;
    border: none;
    padding: 10px 24px;
    border-radius: 5px;
    font-size: 15px;
    cursor: pointer;
    margin-right: 10px;
    transition: background 0.2s;
}

button:hover {
    background: #333;
}

button:active {
    transform: translateY(1px);
}

button:disabled {
    background: #999;
    cursor: not-allowed;
}

button:disabled:hover {
    background: #999;
}

button:disabled:active {
    transform: none;
}

.secondary-btn {
    background: #6c757d;
}

.secondary-btn:hover {
    background: #555;
}

/* Link-style actions */
.link-action {
    color: #1a73e8;
    text-decoration: none;
    font-size: 14px;
    cursor: pointer;
}

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

.link-action.small {
    font-size: 12px;
}

/* Inputs */
input[type="number"] {
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    width: 60px;
    text-align: center;
    font-size: 14px;
}

input[type="number"]:focus {
    outline: none;
    border-color: #333;
}

select {
    padding: 6px 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 13px;
    background: white;
    cursor: pointer;
}

select:focus {
    outline: none;
    border-color: #333;
}

/* Groups header */
.groups-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

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

.groups-heading {
    font-size: 16px;
    font-weight: 600;
    color: #333;
}

.groups-or {
    color: #999;
    font-size: 14px;
}

.add-group-btn {
    background: none;
    color: #1a73e8;
    border: 1px solid #1a73e8;
    padding: 6px 16px;
    font-size: 13px;
    border-radius: 4px;
    margin-right: 0;
}

.add-group-btn:hover {
    background: #e8f0fe;
    color: #1a73e8;
}

/* Add group row (below cards) */
.add-group-row {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 8px;
}

/* Upload status */
#upload-status {
    margin-bottom: 16px;
    padding: 8px 10px;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
}

#upload-status:empty {
    display: none;
}

/* Status badges */
.status-info {
    background: #e8f0fe;
    color: #1a5276;
}

.status-success {
    background: #e8f5e9;
    color: #2e7d32;
}

.status-warning {
    background: #fff3e0;
    color: #e65100;
}

.status-error {
    background: #fce4e4;
    color: #c0392b;
}

/* ---- Group cards ---- */
.group-card {
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    margin-bottom: 12px;
    background: #fafafa;
    overflow: hidden;
}

.group-card.has-data {
    border-color: #c8e6c9;
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    background: #f4f4f4;
    border-bottom: 1px solid #e0e0e0;
}

.has-data .card-header {
    background: #f1f8f2;
    border-bottom-color: #c8e6c9;
}

.card-name-input {
    font-weight: 600;
    font-size: 14px;
    color: #222;
    border: 1px solid transparent;
    background: transparent;
    padding: 4px 8px;
    border-radius: 4px;
    min-width: 100px;
    max-width: 200px;
}

.card-name-input:hover {
    border-color: #ddd;
}

.card-name-input:focus {
    outline: none;
    border-color: #999;
    background: white;
}

.card-name-display {
    font-weight: 600;
    font-size: 14px;
    color: #222;
    padding: 4px 8px;
}

.card-meta {
    color: #888;
    font-size: 12px;
    flex: 1;
}

.card-header-right {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.threshold-inline {
    display: flex;
    align-items: center;
    gap: 4px;
}

.threshold-inline label {
    font-size: 12px;
    color: #888;
    font-weight: 500;
}

.threshold-inline .unit {
    color: #888;
    font-size: 13px;
}

.card-badge {
    font-size: 11px;
    font-weight: 500;
    color: #1a5276;
    background: #e8f0fe;
    padding: 2px 8px;
    border-radius: 3px;
    flex: 1;
}

.card-remove {
    background: none;
    color: #999;
    font-size: 20px;
    padding: 0 6px;
    margin: 0;
    line-height: 1;
    border-radius: 3px;
}

.card-remove:hover {
    background: #eee;
    color: #d44;
}

.card-body {
    padding: 12px 16px;
    display: flex;
    gap: 16px;
}

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

.card-col-right {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.card-row {
    display: flex;
    align-items: flex-start;
    flex-direction: column;
    gap: 6px;
    margin-bottom: 10px;
}

.card-row:last-child {
    margin-bottom: 0;
}

.card-row > label {
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.card-row .unit {
    color: #666;
    font-size: 14px;
}

.card-row .rep-select {
    width: 100%;
    min-width: 0;
}

/* FASTA input area within card */
.card-fasta-input {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
}

.fasta-input-label {
    font-size: 13px;
    font-weight: 500;
    color: #555;
}

.fasta-textarea {
    width: 100%;
    flex: 1;
    font-family: 'Menlo', 'Consolas', 'Courier New', monospace;
    font-size: 12px;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    resize: vertical;
    background: white;
}

.fasta-textarea:focus {
    outline: none;
    border-color: #999;
}

.fasta-input-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.fasta-or {
    color: #999;
    font-size: 13px;
    font-style: italic;
    flex-shrink: 0;
}

.fasta-file-input {
    padding: 5px 8px;
    font-size: 13px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
}
.load-fasta-btn {
    padding: 6px 16px;
    font-size: 13px;
}

/* Disabled PDB controls */
.pdb-controls.disabled {
    opacity: 0.4;
    pointer-events: none;
}

/* Card loading overlay */
.card-fasta-input {
    position: relative;
}

.card-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(250, 250, 250, 0.85);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #888;
    font-size: 13px;
    border-radius: 4px;
}

/* PDB controls within a card */
.pdb-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.pdb-controls input[type="file"] {
    padding: 5px 8px;
    font-size: 13px;
    border: 1px solid #ddd;
    border-radius: 4px;
    cursor: pointer;
    max-width: 180px;
}

.pdb-or-divider {
    color: #999;
    font-size: 13px;
    font-style: italic;
    flex-shrink: 0;
}

.pdb-id-input {
    width: 70px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
    text-transform: uppercase;
    font-family: monospace;
    text-align: center;
    flex-shrink: 0;
}

.pdb-id-input:focus {
    outline: none;
    border-color: #333;
}

.pdb-id-input::placeholder {
    text-transform: none;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    font-style: italic;
    color: #aaa;
}

.pdb-fetch-btn {
    padding: 6px 12px;
    font-size: 13px;
    flex-shrink: 0;
}

.chain-select {
    flex-shrink: 0;
}

.pdb-item-status {
    font-size: 12px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 3px;
    flex-shrink: 0;
}

/* Cross-alignment card */
.cross-card {
    border-color: #b8d4f0;
    background: #f5f9fe;
}

.cross-card .card-header {
    background: #eaf2fb;
    border-bottom-color: #b8d4f0;
}

/* Action section */
#action-section {
    margin: 20px 0;
    display: flex;
    gap: 10px;
}

/* Spinner */
.spinner {
    border: 3px solid #eee;
    border-top: 3px solid #1a1a1a;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 0.8s linear infinite;
    margin: 20px auto;
}

.small-spinner {
    width: 18px;
    height: 18px;
    border-width: 2px;
    margin: 0;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Result */
#svg-container {
    margin: 20px 0;
    padding: 20px;
    background: #fafafa;
    border-radius: 5px;
    overflow-x: auto;
    border: 1px solid #e0e0e0;
    min-width: 100%;
}

#svg-container svg {
    height: auto;
    display: block;
    margin: 0 auto;
}

.button-group {
    margin-top: 20px;
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* Analysis details table */
#analysis-details {
    margin: 16px 0 0;
}

.analysis-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 8px;
    font-size: 13px;
}

.analysis-table th,
.analysis-table td {
    text-align: left;
    padding: 6px 10px;
    border-bottom: 1px solid #e8e8e8;
}

.analysis-table th {
    color: #666;
    font-weight: 500;
}

.analysis-table td {
    color: #444;
}

/* About page */
.about-page h1 {
    font-size: 24px;
    color: #222;
    margin-bottom: 20px;
}

.about-page h2 {
    font-size: 17px;
    color: #333;
    margin: 28px 0 12px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 6px;
}

.about-page p {
    color: #444;
    line-height: 1.7;
    margin-bottom: 12px;
}

.about-page ol,
.about-page ul {
    color: #444;
    line-height: 1.8;
    margin: 0 0 16px 24px;
}

.about-page li {
    margin-bottom: 8px;
}

.about-page code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 13px;
}

.about-back {
    margin-top: 36px;
    padding-top: 20px;
    border-top: 1px solid #e0e0e0;
}

.about-back a {
    color: #1a73e8;
    text-decoration: none;
    font-size: 14px;
}

.about-back a:hover {
    text-decoration: underline;
}
