* {
    box-sizing: border-box;
}

body {
    font-family: Arial, sans-serif;
    margin: 0;
    background: #f5f6f8;
    color: #222;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 18px;
    background: #0f172a;
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 10;
}

.brand {
    font-weight: 700;
    font-size: 18px;
    color: #fff;
    text-decoration: none;
    transition: opacity 0.2s;
}

.brand:hover {
    opacity: 0.8;
}

/* Show full brand text by default, hide short version */
.brand-full {
    display: inline;
}

.brand-short {
    display: none;
}

.nav-actions {
    display: flex;
    gap: 12px;
    align-items: center;
}

.home-icon {
    color: #fff;
    font-size: 18px;
    text-decoration: none;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 6px;
}

.home-icon:hover {
    opacity: 0.7;
}

.user-chip {
    background: #1e293b;
    padding: 6px 10px;
    border-radius: 999px;
    font-size: 14px;
}

.user-chip.muted {
    opacity: 0.8;
}

.header-with-back {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    width: 100%;
}

.back-icon {
    position: absolute;
    left: 0;
    color: #1f2937;
    font-size: 20px;
    text-decoration: none;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 8px;
    /* Increase touch target */
}

.back-icon:hover {
    opacity: 0.6;
}

/* Ensure rating buttons never wrap and shrink to fit */
.rating-actions {
    flex-wrap: nowrap !important;
    width: 100%;
    gap: 8px;
}

.rating-actions form {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
}

.rating-actions .btn {
    width: 100%;
    min-width: 30px;
    padding: 8px 2px;
}

.container {
    max-width: 1100px;
    margin: 20px auto;
    padding: 0 14px 40px;
}

.panel {
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 16px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

.panel.tall {
    min-height: 140px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.panel h1,
.panel h2 {
    margin: 0 0 10px 0;
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    border: none;
    border-radius: 8px;
    padding: 10px 14px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
}

.btn.primary {
    background: #2563eb;
    color: #fff;
}

.btn.rate {
    background: #dbeafe;
    color: #1d4ed8;
    border: 1px solid #bfdbfe;
}

.btn.rate.selected {
    background: #2563eb;
    color: #fff;
    border: 1px solid #1d4ed8;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.25);
}

.btn.secondary {
    background: #e5e7eb;
    color: #1f2937;
}

.btn.ghost {
    background: transparent;
    color: inherit;
    border: 1px solid #cbd5e1;
}

.btn.large {
    min-width: 64px;
    padding: 12px 18px;
    font-size: 16px;
}

.btn.small {
    min-width: 44px;
    padding: 8px 10px;
    font-size: 14px;
}

.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
}

.stacked-form {
    display: grid;
    gap: 10px;
}

input[type="text"],
select {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th,
td {
    border-bottom: 1px solid #e5e7eb;
    padding: 10px;
    text-align: left;
}

th {
    background: #f8fafc;
    position: sticky;
    top: 0;
    z-index: 1;
}

.table-wrap {
    overflow-x: auto;
}

@keyframes skeleton-pulse {
    0% {
        background-color: #e2e8f0;
    }

    50% {
        background-color: #cbd5e1;
    }

    100% {
        background-color: #e2e8f0;
    }
}

.thumb {
    width: 80px;
    height: 80px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
    background-color: #e2e8f0;
    animation: skeleton-pulse 1.5s infinite ease-in-out;
}

.annotate-wrapper {
    display: flex;
    justify-content: flex-start;
    align-items: flex-start;
    background: #f8fafc;
    padding: 20px;
    border-radius: 10px;
    min-height: 320px;
}

.main-image {
    max-width: 100%;
    max-height: 70vh;
    border-radius: 8px;
    box-shadow: 0 6px 14px rgba(0, 0, 0, 0.1);
}

.actions-row {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
}

.top-actions {
    margin-bottom: 12px;
}

.annotate-layout {
    display: grid;
    grid-template-columns: minmax(340px, 2fr) minmax(260px, 1fr);
    gap: 18px;
    align-items: stretch;
}

.likert-card {
    background: #f8fafc;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 12px;
}

.likert-card h3 {
    margin-top: 0;
    margin-bottom: 8px;
}

.likert-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.likert-table th,
.likert-table td {
    border-bottom: 1px solid #e5e7eb;
    padding: 8px;
}

.likert-table th {
    background: #eef2ff;
}

.likert-table td:first-child {
    width: 60px;
    font-weight: 700;
    text-align: center;
}

.progress {
    width: 100%;
    height: 12px;
    background: #e5e7eb;
    border-radius: 999px;
    overflow: hidden;
}

.progress-text {
    margin: 8px 0 0 0;
    color: #374151;
}

.progress-multi {
    display: flex;
    width: 100%;
    height: 12px;
    border-radius: 999px;
    overflow: hidden;
    background: #e5e7eb;
}

.progress-segment {
    height: 100%;
}

.progress-segment.done {
    background: #22c55e;
}

.progress-segment.skipped {
    background: #f59e0b;
}

.progress-segment.open {
    background: #cbd5e1;
}

.notice {
    background: #ecfeff;
    color: #0f172a;
    border: 1px solid #67e8f9;
    border-radius: 8px;
    padding: 10px 12px;
    margin-bottom: 12px;
}

.centered {
    text-align: center;
}

.lightbox {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.lightbox.hidden {
    display: none;
}

.lightbox-content {
    background: #fff;
    padding: 16px;
    border-radius: 10px;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.lightbox img {
    max-width: 80vw;
    max-height: 80vh;
}

@media (min-width: 700px) {

    /* Make ALL views (except home and instructions) completely unscrollable - everything visible at a glance */
    body:not(.view-home):not(.view-instructions) {
        overflow: hidden;
        height: 100vh;
    }

    body:not(.view-home) .container {
        height: calc(100vh - 48px);
        /* Subtract topbar height */
        margin: 0 auto;
        padding: 10px 14px;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    /* Add bottom padding for annotation mode */
    body.view-annotate .container {
        padding-bottom: 20px;
    }

    /* All panels should shrink to fit content, except those with tables */
    body:not(.view-home) .panel {
        margin-bottom: 10px;
        padding: 12px;
        flex-shrink: 0;
    }

    body:not(.view-home) .panel:last-of-type {
        margin-bottom: 0;
    }

    /* Panels with tables should be scrollable and take remaining space */
    body:not(.view-home) .panel:has(.table-wrap) {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        min-height: 0;
    }

    body:not(.view-home) .panel:has(.table-wrap) h2,
    body:not(.view-home) .panel:has(.table-wrap) .panel-header {
        flex-shrink: 0;
        margin-bottom: 10px;
    }

    /* Make table wrapper scrollable */
    body:not(.view-home) .table-wrap {
        flex: 1;
        overflow: auto;
        min-height: 0;
        padding-bottom: 40px;
    }

    /* Sticky table headers */
    body:not(.view-home) .table-wrap table thead {
        position: sticky;
        top: 0;
        z-index: 2;
        background: #f8fafc;
    }


    /* Reduce spacing for compact layout */
    body:not(.view-home) .panel h1 {
        margin: 0 0 8px 0;
        font-size: 20px;
    }

    body:not(.view-home) .panel h2 {
        margin: 0 0 8px 0;
        font-size: 18px;
    }

    body:not(.view-home) .progress-multi {
        height: 10px;
    }

    body:not(.view-home) .progress-text {
        margin: 6px 0 0 0;
        font-size: 13px;
    }

    /* Home view specific */
    body.view-home .container {
        gap: 10px;
    }

    /* Overview view specific */
    body.view-overview .container {
        gap: 10px;
    }

    body.view-overview .panel.tall {
        min-height: 80px;
        flex-shrink: 0;
    }

    /* Rater view specific */
    body.view-rater .container {
        gap: 10px;
    }

    /* Annotate view specific */
    body.view-annotate .panel:last-of-type {
        flex: 1;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body.view-annotate .annotate-layout {
        flex: 1;
        display: grid;
        grid-template-columns: minmax(340px, 2fr) minmax(260px, 1fr);
        gap: 12px;
        align-items: stretch;
        overflow: hidden;
        min-height: 0;
    }

    body.view-annotate .annotate-wrapper {
        padding: 12px;
        min-height: 0;
        display: flex;
        align-items: center;
        justify-content: center;
        overflow: hidden;
    }

    body.view-annotate .main-image {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
    }

    body.view-annotate .likert-card {
        padding: 10px;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    body.view-annotate .likert-card h3 {
        margin: 0 0 6px 0;
        font-size: 16px;
    }

    body.view-annotate .likert-table {
        font-size: 13px;
    }

    body.view-annotate .likert-table th,
    body.view-annotate .likert-table td {
        padding: 6px;
    }

    body.view-annotate .actions-row {
        margin-bottom: 8px;
    }

    body.view-annotate .top-actions {
        margin-bottom: 8px;
    }

    body.view-annotate .current-item {
        margin: 0 0 8px 0;
        font-size: 14px;
    }

    body.view-annotate .centered:last-child {
        margin: 8px 0 0 0;
        font-size: 13px;
    }

    /* Center and constrain rating buttons on larger screens */
    body.view-annotate .rating-actions {
        max-width: 400px;
        margin-left: auto;
        margin-right: auto;
    }

    /* Restore scrolling for instructions view */
    body.view-instructions .container {
        height: auto;
        overflow: visible;
        display: block;
        padding-bottom: 40px;
    }

    body.view-instructions .panel {
        margin-bottom: 16px;
        flex-shrink: 1;
    }
}

@media (max-width: 699px) {

    /* Show short brand text on small screens */
    .brand-full {
        display: none;
    }

    .brand-short {
        display: inline;
    }

    /* Reduce header size on mobile for annotation view */
    .header-with-back h1 {
        font-size: 20px;
    }

    .panel-header {
        flex-direction: column;
        align-items: flex-start;
    }

    th,
    td {
        font-size: 14px;
    }

    .thumb {
        width: 60px;
        height: 60px;
    }

    .annotate-layout {
        grid-template-columns: 1fr;
    }
}

/* Right panel for annotation view (Comment + Likert) */
.right-panel {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 0;
}

.comment-box textarea {
    background: #fff;
    font-size: 14px;
    line-height: 1.4;
    transition: box-shadow 0.2s, border-color 0.2s;
}

.comment-box textarea:focus {
    outline: none;
    border-color: #2563eb !important;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Compact styles for Annotation Right Panel */
.right-panel {
    overflow-y: auto;
    gap: 8px;
}

body.view-annotate .likert-card {
    padding: 6px;
}

body.view-annotate .likert-table {
    font-size: 12.5px;
}

body.view-annotate .likert-table th,
body.view-annotate .likert-table td {
    padding: 4px;
}

/* Partners Footer */
.partners-footer {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #e5e7eb;
    text-align: center;
}

.partners-text {
    color: #6b7280;
    margin-bottom: 8px;
    font-size: 0.9em;
}

.partners-names {
    color: #374151;
    margin-bottom: 20px;
    font-weight: 500;
    font-size: 0.95em;
}

.partner-logos {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    flex-wrap: wrap;
}

.partner-logo {
    height: 60px;
    width: auto;
    object-fit: contain;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.partner-logo:hover {
    opacity: 1;
}