/* Base
-------------------------------------------------- */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    color: #222;
    background: #fff;
}

textarea {
    width: 100%;
    min-height: 220px;
    padding: 12px;
    font-family: monospace;
    font-size: 0.9rem;
    line-height: 1.5;
    resize: vertical;
}

select,
button {
    padding: 8px 12px;
    margin-top: 10px;
}

button {
    cursor: pointer;
}

button:disabled {
    opacity: 0.6;
    cursor: wait;
}

pre {
    padding: 20px;
    overflow-x: auto;
    background: #f4f4f4;
}

.error {
    color: #a00;
}


/* Site header
-------------------------------------------------- */

.site-header {
    background: #fff;
    border-bottom: 1px solid #e5e5e5;
}

.site-header__inner {
    width: min(1160px, calc(100% - 48px));
    height: 92px;
    margin: 0 auto;

    display: flex;
    align-items: center;
    justify-content: space-between;
}


.site-brand {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: #171717;
    text-decoration: none;
    font-size: 1.65rem;
    font-weight: 700;
    line-height: 1;
}

.site-brand img {
    display: block;
    width: 54px;
    height: 54px;
}

.site-module {
    color: #2f7d48;
    font-size: 1.55rem;
    font-weight: 600;
}

/* Main content
-------------------------------------------------- */

.site-main {
    width: min(1160px, calc(100% - 48px));
    margin: 0 auto;
    padding: 48px 0 64px;
}

/* Sequence input
-------------------------------------------------- */

.sequence-input {
    margin-bottom: 28px;
}

.sequence-input__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.sequence-input__header label {
    font-weight: 600;
}

.sequence-input__clear {
    margin: 0;
    padding: 4px 0;
    color: #666;
    background: transparent;
    border: 0;
    font: inherit;
    font-size: 0.85rem;
}

.sequence-input__clear:hover {
    color: #222;
}

.sequence-drop-zone {
    position: relative;
    overflow: hidden;
    background: #fff;
    border: 1px solid #cfd8d2;
    transition:
        border-color 120ms ease,
        box-shadow 120ms ease,
        background-color 120ms ease;
}

.sequence-drop-zone:focus-within {
    border-color: #2f7d48;
    box-shadow: 0 0 0 3px rgba(47, 125, 72, 0.10);
}

.sequence-drop-zone.is-dragging {
    border-color: #2f7d48;
    background: #f5faf6;
    box-shadow: 0 0 0 3px rgba(47, 125, 72, 0.12);
}

.sequence-drop-zone textarea {
    display: block;
    width: 100%;
    min-height: 240px;
    margin: 0;
    padding: 22px 22px 18px;
    color: #222;
    background: transparent;
    border: 0;
    outline: 0;
    resize: vertical;
    font-family:
        ui-monospace,
        SFMono-Regular,
        Menlo,
        Monaco,
        Consolas,
        "Liberation Mono",
        monospace;
    font-size: 0.9rem;
    line-height: 1.55;
}

.sequence-drop-zone textarea::placeholder {
    color: #8a938d;
}

.sequence-input__footer {
    min-height: 48px;
    padding: 9px 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
    border-top: 1px solid #e4e9e5;
    background: #fafbfa;
}

.sequence-input__file {
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sequence-input__file input[type="file"] {
    display: none;
}

.sequence-input__file-button {
    flex: 0 0 auto;
    margin: 0;
    padding: 5px 8px;
    color: #2f7d48;
    background: transparent;
    border: 0;
    font: inherit;
    font-size: 0.85rem;
    font-weight: 600;
}

.sequence-input__file-button:hover {
    text-decoration: underline;
}

.sequence-input__file-name {
    min-width: 0;
    overflow: hidden;
    color: #666;
    font-size: 0.82rem;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.sequence-input__length {
    flex: 0 0 auto;
    color: #666;
    font-family: monospace;
    font-size: 0.82rem;
}

.sequence-drop-zone__message {
    position: absolute;
    inset: 0;
    z-index: 5;

    display: flex;
    align-items: center;
    justify-content: center;

    color: #2f7d48;
    background: rgba(245, 250, 246, 0.96);

    font-size: 1.15rem;
    font-weight: 650;

    opacity: 0;
    pointer-events: none;

    transition: opacity 120ms ease;
}

.sequence-drop-zone.is-dragging
.sequence-drop-zone__message {
    opacity: 1;
}

/* Loading
-------------------------------------------------- */

.loading {
    display: none;
    align-items: center;
    gap: 10px;
    margin-top: 24px;
    font-weight: 600;
}

.loading.is-visible {
    display: flex;
}

.spinner {
    width: 18px;
    height: 18px;
    border: 3px solid #ddd;
    border-top-color: #333;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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


/* Analysis results
-------------------------------------------------- */

.analysis-result {
    margin-top: 32px;
}

.analysis-time {
    margin: 0 0 12px;
    font-weight: 600;
}

.analysis-result h2 {
    margin: 0 0 20px;
}


/* Summary
-------------------------------------------------- */

.analysis-summary {
    display: grid;
    grid-template-columns: auto 1fr auto;
    gap: 32px;
    margin-bottom: 28px;
    padding: 18px 20px;
    background: #f4f4f4;
    border: 1px solid #ddd;
}

.analysis-summary strong {
    display: inline-block;
    margin-bottom: 4px;
}


/* Results table
-------------------------------------------------- */

.results-table-wrapper {
    width: 100%;
    overflow-x: auto;
}

.results-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 24px;
}

.results-table th,
.results-table td {
    padding: 12px 14px;
    text-align: left;
    vertical-align: middle;
    border-bottom: 1px solid #ddd;
}

.results-table th {
    font-size: 0.9rem;
    font-weight: 600;
    background: #f4f4f4;
    white-space: nowrap;
}

.results-table tbody > tr:not(.result-detail-row):hover {
    background: #fafafa;
}

.results-table td:nth-child(1),
.results-table td:nth-child(5),
.results-table td:nth-child(6) {
    white-space: nowrap;
}

.results-table a {
    color: inherit;
}


/* Hit details
-------------------------------------------------- */

.result-detail-row > td {
    padding: 0;
    border-bottom: 0;
}

.result-detail {
    margin: 0 0 12px;
    border-bottom: 1px solid #ddd;
}

.result-detail summary {
    padding: 10px 14px;
    cursor: pointer;
    font-size: 0.9rem;
}

.result-detail summary:hover {
    background: #fafafa;
}

.result-detail-content {
    padding: 16px 20px 24px;
}

.result-detail-content h3 {
    margin: 28px 0 12px;
    font-size: 1rem;
}


/* Hit metrics
-------------------------------------------------- */

.hit-metrics {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 16px 24px;
    margin: 0;
}

.hit-metrics div {
    min-width: 0;
}

.hit-metrics dt {
    margin-bottom: 3px;
    font-size: 0.8rem;
    color: #666;
}

.hit-metrics dd {
    margin: 0;
    font-weight: 600;
}


/* Taxonomy
-------------------------------------------------- */

.taxonomy {
    display: grid;
    grid-template-columns: minmax(100px, auto) minmax(0, 1fr) minmax(100px, auto);
    gap: 10px 24px;
    margin: 0;
}

.taxonomy div {
    min-width: 0;
}

.taxonomy dt {
    margin-bottom: 2px;
    font-size: 0.8rem;
    color: #666;
}

.taxonomy dd {
    min-width: 0;
    margin: 0;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.taxonomy--silva {
    grid-template-columns: 1fr 1fr;
}

.taxonomy--silva div:nth-child(2) {
    grid-column: 1 / -1;
    grid-row: 2;
}

.taxonomy--silva div:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
}

.taxonomy--silva dd {
    min-width: 0;
    overflow-wrap: anywhere;
}


/* Sequence alignment
-------------------------------------------------- */

.alignment {
    margin: 0;
    padding: 16px;
    overflow-x: auto;
    font-family: monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre;
    background: #f4f4f4;
    border: 1px solid #ddd;
}


/* Raw JSON
-------------------------------------------------- */

.raw-json {
    margin-top: 28px;
    padding-top: 16px;
    border-top: 1px solid #ddd;
}

.raw-json summary {
    cursor: pointer;
    font-weight: 600;
}

.raw-json pre {
    margin-top: 14px;
}


/* Responsive
-------------------------------------------------- */

@media (max-width: 700px) {

    .site-header__inner {
        width: min(100% - 32px, 1160px);
        height: 76px;
    }

    .site-header__logo {
        width: 175px;
        height: 48px;
    }

    .site-header__module {
        font-size: 0.85rem;
    }

    .site-main {
        width: min(100% - 32px, 1160px);
        padding-top: 32px;
    }

    .analysis-summary {
        grid-template-columns: 1fr;
        gap: 14px;
    }

    .results-table th,
    .results-table td {
        padding: 10px;
    }

    .hit-metrics,
    .taxonomy {
        grid-template-columns: 1fr 1fr;
    }

        .sequence-input__footer {
        align-items: flex-start;
        flex-direction: column;
        gap: 6px;
    }

    .sequence-input__file {
        width: 100%;
    }

    .sequence-drop-zone textarea {
        min-height: 200px;
        padding: 18px;
    }
}

@media (max-width: 480px) {

    .hit-metrics,
    .taxonomy {
        grid-template-columns: 1fr;
    }
}