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

:root {
    --primary-color: #4a90e2;
    --primary-hover: #357abd;
    --primary-active: #2868a8;
    --secondary-color: #5c6bc0;
    --text-primary: #1a1a1a;
    --text-secondary: #6b7280;
    --bg-primary: #fafafa;
    --bg-secondary: #ffffff;
    --border-color: #e5e7eb;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.08), 0 2px 4px -1px rgba(0, 0, 0, 0.04);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -2px rgba(0, 0, 0, 0.04);
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Inter', 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif;
    line-height: 1.6;
    color: var(--text-primary);
    background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%);
    min-height: 100vh;
}

header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 3rem 2rem;
    text-align: center;
    box-shadow: var(--shadow-md);
}

header h1 {
    margin-bottom: 0.5rem;
    font-size: 2.5rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

header p {
    opacity: 0.95;
    font-size: 1.1rem;
    font-weight: 400;
}

main {
    max-width: 1400px;
    margin: 2.5rem auto;
    padding: 0 2rem;
}

section {
    background: var(--bg-secondary);
    padding: 2rem;
    margin-bottom: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1px solid var(--border-color);
}

section h2 {
    margin-bottom: 1rem;
    color: var(--text-primary);
    font-size: 1.5rem;
    font-weight: 600;
}

/* Section Header with Collapse Button */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    cursor: pointer;
    user-select: none;
    padding: 0.75rem;
    margin: -0.75rem -0.75rem 1.5rem -0.75rem;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.section-header:hover {
    background-color: var(--bg-primary);
}

.section-header h2 {
    margin-bottom: 0;
}

.collapse-button {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--text-secondary);
    transition: all 0.3s ease;
    user-select: none;
    opacity: 0.7;
}

.collapse-button:hover {
    color: var(--primary-color);
    opacity: 1;
}

.collapse-button.collapsed {
    transform: rotate(-90deg);
}

/* Collapsible Content */
.collapsible-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    max-height: 2000px;
    opacity: 1;
}

.collapsible-content.collapsed {
    max-height: 0;
    opacity: 0;
}

/* Sequence Input Styles */
.sequence-input-group {
    margin-bottom: 1.5rem;
}

/* Align Button */
.align-button-container {
    margin-top: 1.5rem;
    text-align: center;
}

.align-button {
    padding: 0.75rem 2rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-md);
}

.align-button:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.align-button:active {
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

.align-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* sgRNA Settings */
.sgrna-settings {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.sgrna-settings h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
    margin-bottom: 1rem;
    font-weight: 600;
}

.sgrna-params {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-top: 1rem;
}

.param-group {
    display: flex;
    flex-direction: column;
}

.param-group label {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.param-input {
    padding: 0.5rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s ease;
    background-color: var(--bg-primary);
}

.param-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.param-help {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
    font-style: italic;
}

/* Annotations Settings */
.annotations-settings {
    margin-top: 2rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.annotations-settings h3 {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 1rem;
}

.annotations-list {
    margin-bottom: 1rem;
}

.annotation-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-secondary);
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    margin-bottom: 0.5rem;
}

.annotation-item:last-child {
    margin-bottom: 0;
}

.annotation-badge {
    display: inline-block;
    padding: 0.25rem 0.5rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
}

.annotation-badge.seq1 {
    background: #8e44ad;
}

.annotation-badge.seq2 {
    background: #e67e22;
}

.annotation-range {
    font-family: 'Courier New', 'Monaco', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.annotation-content {
    flex: 1;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.annotation-delete {
    padding: 0.25rem 0.5rem;
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    font-size: 0.85rem;
    transition: all 0.2s ease;
}

.annotation-delete:hover {
    background: #e74c3c;
    border-color: #e74c3c;
    color: white;
}

.annotation-add {
    margin-top: 0.75rem;
}

.annotation-inputs {
    display: grid;
    grid-template-columns: 120px 80px 80px 1fr auto;
    gap: 0.5rem;
    align-items: center;
}

.annotation-select,
.annotation-input {
    padding: 0.5rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.9rem;
    background: var(--bg-primary);
    transition: all 0.2s ease;
}

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

.annotation-text-input {
    min-width: 200px;
}

.add-annotation-button {
    padding: 0.5rem 1rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.add-annotation-button:hover {
    background: #3a7bc8;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(74, 144, 226, 0.3);
}

.add-annotation-button:active {
    transform: translateY(0);
}

/* Annotation Markers in Visualization */
.annotation-marker {
    position: absolute;
    height: 10px;
    border-radius: 4px;
    z-index: 4;
    pointer-events: all;
    cursor: pointer;
    transition: all 0.2s ease;
    opacity: 0.8;
}

.annotation-marker.seq1 {
    background: #8e44ad;
    top: -15px;
}

.annotation-marker.seq2 {
    background: #e67e22;
    bottom: -15px;
}

.annotation-marker:hover {
    opacity: 1;
    height: 12px;
}

.annotation-label {
    position: absolute;
    background: rgba(0, 0, 0, 0.85);
    color: white;
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    white-space: nowrap;
    z-index: 100;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.annotation-marker:hover .annotation-label {
    opacity: 1;
}

.annotation-label.seq1 {
    top: -35px;
    left: 50%;
    transform: translateX(-50%);
}

.annotation-label.seq2 {
    bottom: -35px;
    left: 50%;
    transform: translateX(-50%);
}

.sequence-input-group label {
    display: block;
    margin-bottom: 0.5rem;
    margin-top: 0.75rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.sequence-input-group label:first-child {
    margin-top: 0;
}

.sequence-input-group .name-input {
    width: 100%;
    padding: 0.75rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s ease;
    background-color: var(--bg-primary);
}

.sequence-input-group .name-input:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

.sequence-input-group textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-family: 'Courier New', 'Monaco', monospace;
    font-size: 14px;
    resize: vertical;
    transition: all 0.2s ease;
    background-color: var(--bg-primary);
    line-height: 1.5;
}

.sequence-input-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background-color: var(--bg-secondary);
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.1);
}

/* Visualization Header */
.viz-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.viz-header h2 {
    margin-bottom: 0;
}

.reset-button {
    padding: 0.65rem 1.25rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.reset-button:hover {
    background: var(--primary-hover);
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.reset-button:active {
    background: var(--primary-active);
    transform: translateY(0);
    box-shadow: var(--shadow-sm);
}

/* Alignment Visualization Styles */
#alignment-container {
    min-height: 200px;
    font-family: 'Courier New', 'Monaco', monospace;
    overflow: hidden;
    padding: 1rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    cursor: grab;
    position: relative;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    background: var(--bg-primary);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.05);
}

#alignment-container:active {
    cursor: grabbing;
}

#alignment-content {
    transform-origin: top left;
    transition: transform 0.1s ease-out;
}

.alignment-row {
    display: flex;
    margin-bottom: 1px;
    align-items: center;
    position: relative;
}

.alignment-row:first-of-type {
    margin-top: 30px; /* Space for sgRNA rectangle above */
}

.alignment-row:nth-of-type(2) {
    margin-bottom: 30px; /* Space for sgRNA rectangle below */
}

.alignment-label {
    font-weight: 500;
    margin-right: 1rem;
    padding: 0;
    width: 150px;
    min-width: 150px;
    max-width: 150px;
    display: flex;
    align-items: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex-shrink: 0;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.base {
    display: inline-block;
    width: 30px;
    height: 30px;
    text-align: center;
    line-height: 30px;
    font-weight: 600;
    font-size: 20px;
}

/* CRISPResso-style base colors */
.base.A {
    background-color: #7FC97F;  /* Green for Adenine */
}

.base.T {
    background-color: #BEAED4;  /* Red for Thymine */
}

.base.C {
    background-color: #FDC086;  /* Blue for Cytosine */
}

.base.G {
    background-color: #FFFF99;  /* Orange for Guanine */
}

.base.gap {
    background-color: #666;  /* Gray for gaps */
    color: #1E1E1E;
}

/* Insertion indicator (red border) */
.base.insertion {
    box-shadow: 0 0 0 3px #FF0000;
    position: relative;
    z-index: 1;
}

/* Position ruler styles */
.position-ruler {
    display: flex;
    margin-bottom: 3px;
    align-items: flex-end;
    margin-top: 3px;
}

.position-label {
    font-size: 10px;
    color: var(--text-secondary);
    font-weight: 500;
}

.position-marker {
    width: 30px;
    height: 18px;
    text-align: center;
    font-size: 9px;
    color: var(--text-secondary);
    line-height: 18px;
    font-family: 'Courier New', 'Monaco', monospace;
    user-select: none;
}

.position-marker.tick {
    font-size: 11px;
    font-weight: 600;
    color: var(--primary-color);
}

.empty-message {
    text-align: center;
    color: var(--text-secondary);
    padding: 3rem;
    font-style: italic;
    font-size: 0.95rem;
}

/* Navigation Slider */
#navigation-slider {
    margin-top: 1.5rem;
    padding: 1rem;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-color);
}

#slider-track {
    position: relative;
    height: 8px;
    background: var(--border-color);
    border-radius: 999px;
    cursor: pointer;
    overflow: visible;
}

#slider-viewport {
    position: absolute;
    height: 30px;
    width: 6px;
    background: var(--primary-color);
    border-radius: 3px;
    cursor: grab;
    transform: translate(-50%, -11px);
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Left arrow */
#slider-viewport::before {
    content: '◄';
    position: absolute;
    left: -14px;
    color: var(--primary-color);
    font-size: 12px;
    font-weight: bold;
    transition: color 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

/* Right arrow */
#slider-viewport::after {
    content: '►';
    position: absolute;
    right: -14px;
    color: var(--primary-color);
    font-size: 12px;
    font-weight: bold;
    transition: color 0.2s ease, transform 0.2s ease;
    pointer-events: none;
}

#slider-viewport.animating {
    transition: background 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease, left 0.15s ease-out;
}

#slider-viewport:hover {
    background: var(--primary-hover);
    transform: translate(-50%, -11px) scale(1.1);
    box-shadow: var(--shadow-lg);
}

#slider-viewport:hover::before {
    color: var(--primary-hover);
    transform: translateX(-2px);
}

#slider-viewport:hover::after {
    color: var(--primary-hover);
    transform: translateX(2px);
}

#slider-viewport:active {
    cursor: grabbing;
    background: var(--primary-active);
    transform: translate(-50%, -11px) scale(1.05);
}

#slider-viewport:active::before {
    color: var(--primary-active);
}

#slider-viewport:active::after {
    color: var(--primary-active);
}

/* sgRNA Sidebar */
.sgrna-sidebar {
    background: var(--bg-secondary);
    padding: 1.5rem;
    margin-top: 2rem;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    border: 1.5px solid var(--border-color);
}

.sgrna-sidebar.hidden {
    display: none;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    cursor: pointer;
    padding: 0.5rem;
    margin: -0.5rem -0.5rem 1.5rem -0.5rem;
    border-radius: var(--radius-md);
    transition: all 0.2s ease;
}

.sidebar-header:hover {
    background-color: var(--bg-primary);
}

.sidebar-header h2 {
    margin-bottom: 0;
    font-size: 1.3rem;
}

.sidebar-content {
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
}

.sidebar-content.collapsed {
    max-height: 0;
    opacity: 0;
}

/* sgRNA Result Card */
.sgrna-result-card {
    background: var(--bg-primary);
    padding: 1rem;
    margin-bottom: 1rem;
    border-radius: var(--radius-md);
    border: 1.5px solid var(--border-color);
}

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

.sgrna-header {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    padding-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}

.sgrna-name {
    font-weight: 600;
    color: var(--text-primary);
    font-size: 0.9rem;
}

.sgrna-sequence {
    font-family: 'Courier New', 'Monaco', monospace;
    font-size: 0.85rem;
    color: var(--text-secondary);
    word-break: break-all;
    background: var(--bg-secondary);
    padding: 0.4rem 0.6rem;
    border-radius: var(--radius-sm);
}

.sgrna-match {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
}

.sgrna-match:last-child {
    margin-bottom: 0;
}

.match-label {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.4rem;
    font-size: 0.85rem;
}

.match-details {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    color: var(--text-secondary);
    font-size: 0.8rem;
    margin-bottom: 0.4rem;
}

.match-position {
    color: var(--text-secondary);
    font-family: 'Courier New', 'Monaco', monospace;
}

.match-strand {
    color: var(--text-secondary);
    font-family: 'Courier New', 'Monaco', monospace;
    font-weight: 600;
}

.match-info {
    color: var(--text-secondary);
    font-size: 0.75rem;
    margin-top: 0.25rem;
}

.match-warning {
    color: #e67e22;
    font-size: 0.75rem;
    margin-top: 0.25rem;
    font-style: italic;
}

.match-pass {
    color: #27ae60;
    font-weight: 600;
}

.match-fail {
    color: #e74c3c;
    font-weight: 600;
}

.match-icon {
    font-size: 1rem;
    margin-left: 0.25rem;
}

/* sgRNA Alignment Rectangles */
.sgrna-alignment-rectangle {
    position: absolute;
    height: 20px;
    background: rgba(128, 128, 128, 0.3);
    border: 2px solid rgba(128, 128, 128, 0.6);
    border-radius: 3px;
    z-index: 5;
    pointer-events: none;
    display: flex;
    align-items: center;
}

.sgrna-alignment-rectangle.seq1 {
    top: -25px;
}

.sgrna-alignment-rectangle.seq2 {
    bottom: -25px;
}

.sgrna-mismatch {
    position: absolute;
    width: 30px;
    height: 20px;
    background: rgba(231, 76, 60, 0.7);
    border: 1px solid rgba(231, 76, 60, 0.9);
    z-index: 6;
}

/* Cut Site Markers */
.cut-site-marker {
    position: absolute;
    width: 6px;
    background: #ff6b6b;
    opacity: 0.8;
    z-index: 10;
    pointer-events: none;
    top: 0;
    bottom: 0;
}

.cut-site-marker.sgrna-0 { background: #ff6b6b; }
.cut-site-marker.sgrna-1 { background: #4ecdc4; }
.cut-site-marker.sgrna-2 { background: #45b7d1; }
.cut-site-marker.sgrna-3 { background: #f7b731; }
.cut-site-marker.sgrna-4 { background: #5f27cd; }
.cut-site-marker.sgrna-5 { background: #00d2d3; }
.cut-site-marker.sgrna-6 { background: #ff9ff3; }
.cut-site-marker.sgrna-7 { background: #54a0ff; }

.cut-site-marker::before {
    content: '✂';
    position: absolute;
    top: -30px;
    left: -6px;
    font-size: 26px;
    color: inherit;
}

.cut-site-marker .cut-site-tooltip {
    position: absolute;
    top: -45px;
    left: 10px;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.cut-site-marker:hover .cut-site-tooltip {
    opacity: 1;
}
