:root {
    color-scheme: light dark;
    --bg: #f6f7f9;
    --surface: #ffffff;
    --text: #1d232b;
    --muted: #5d6773;
    --border: #d9dee4;
    --accent: #0f5ea8;
    --accent-text: #ffffff;
    --topbar: #0f3a63;
    --pass: #1f7a3d;
    --pass-bg: #e4f4e9;
    --fail: #b4232c;
    --fail-bg: #fbe7e8;
    --warn: #8a5a00;
    --warn-bg: #fdf1d6;
    --param-bg: #e8f0fb;
    --radius: 12px;
    --text-scale: 1;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg: #12161b;
        --surface: #1b2128;
        --text: #e7ebf0;
        --muted: #9aa5b1;
        --border: #2e3741;
        --accent: #5aa3e8;
        --accent-text: #0b1520;
        --topbar: #0b2440;
        --pass: #6fd08f;
        --pass-bg: #173323;
        --fail: #f08a90;
        --fail-bg: #3a1a1d;
        --warn: #f0c062;
        --warn-bg: #3a2e12;
        --param-bg: #1d3350;
    }
}

*, *::before, *::after {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    background: var(--bg);
    color: var(--text);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.45;
    -webkit-text-size-adjust: 100%;
}

a {
    color: var(--accent);
}

h1 {
    font-size: 1.4em;
    margin: 0.4em 0 0.6em;
    line-height: 1.25;
}

h1:focus {
    outline: none;
}

/* Layout */

.topbar {
    position: sticky;
    top: 0;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    padding-top: max(0.5rem, env(safe-area-inset-top));
    background: var(--topbar);
    color: #ffffff;
}

.topbar a, .topbar .link-button {
    color: #ffffff;
}

.topbar .link-button {
    padding: 0 0.25rem;
    white-space: nowrap;
}

/* On a narrow phone the controls keep one line each; the brand gives way first. */
.brand {
    min-width: 0;
    overflow: hidden;
    font-weight: 600;
    text-decoration: none;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.topbar-actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 0.25rem;
}

.content {
    max-width: 760px;
    margin: 0 auto;
    padding: 0.75rem 1rem 3rem;
    font-size: calc(1rem * var(--text-scale));
}

/* Aligned with the content column; takes no space until a new version is waiting. */
.prose p {
    max-width: 65ch;
}

.update-banner {
    max-width: 760px;
    margin: 0 auto;
    padding: 0 1rem;
    font-size: calc(1rem * var(--text-scale));
}

.update-banner .notice {
    margin: 0.75rem 0 0;
}

.update-banner .button {
    flex-shrink: 0;
}

/* Controls */

button {
    font: inherit;
}

.button, .icon-button, .segmented button {
    min-height: 44px;
    border-radius: 10px;
    border: 1px solid var(--border);
    cursor: pointer;
}

.button {
    padding: 0 1.1rem;
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
}

.icon-button {
    min-width: 44px;
    background: transparent;
    border-color: rgba(255, 255, 255, 0.35);
    color: #ffffff;
    font-weight: 600;
}

.icon-button:disabled {
    opacity: 0.4;
    cursor: default;
}

/* Drawn like the A− and A+ buttons: no system arrow, which would cost the width of the brand on a phone. */
.language-picker {
    min-width: 44px;
    min-height: 44px;
    padding: 0 0.5rem;
    appearance: none;
    text-align: center;
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.35);
    border-radius: 8px;
    background: transparent;
    color: #ffffff;
    font: inherit;
    font-weight: 600;
}

/* The open list is drawn by the system: keep it readable whatever the top bar colors. */
.language-picker option {
    background: var(--surface);
    color: var(--text);
}

.link-button {
    min-height: 44px;
    padding: 0 0.5rem;
    background: none;
    border: none;
    color: var(--accent);
    cursor: pointer;
    text-decoration: underline;
}

input[type=url], input[type=search] {
    width: 100%;
    min-height: 44px;
    padding: 0 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
}

.link-form {
    margin-bottom: 1.25rem;
}

.link-form label {
    display: block;
    margin-bottom: 0.35rem;
    color: var(--muted);
    font-size: 0.9em;
}

.row {
    display: flex;
    gap: 0.5rem;
}

.filter {
    margin-bottom: 0.75rem;
}

.toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

.segmented {
    display: inline-flex;
    flex-wrap: wrap;
    gap: 0.35rem;
}

.segmented button {
    padding: 0 0.9rem;
    background: var(--surface);
    color: var(--text);
}

.segmented button.selected {
    background: var(--accent);
    border-color: var(--accent);
    color: var(--accent-text);
    font-weight: 600;
}

/* Lists */

.breadcrumb {
    color: var(--muted);
    font-size: 0.9em;
}

.list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: grid;
    gap: 0.5rem;
}

.list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    min-height: 52px;
    padding: 0.6rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    color: var(--text);
    text-decoration: none;
}

.list-item.point {
    flex-direction: column;
    align-items: flex-start;
}

.point-title {
    font-weight: 500;
}

.point-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.4rem 0.75rem;
}

.muted {
    color: var(--muted);
}

.small {
    font-size: 0.85em;
}

.error {
    color: var(--fail);
}

.outcome {
    padding: 0.1rem 0.55rem;
    border-radius: 999px;
    font-size: 0.85em;
    font-weight: 600;
}

.outcome.passed { color: var(--pass); background: var(--pass-bg); }
.outcome.failed { color: var(--fail); background: var(--fail-bg); }
.outcome.blocked, .outcome.paused { color: var(--warn); background: var(--warn-bg); }
.outcome.na, .outcome.todo { color: var(--muted); background: var(--bg); border: 1px solid var(--border); }

/* Test case */

.iterations {
    margin: 0.75rem 0 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.values {
    display: grid;
    grid-template-columns: max-content 1fr;
    gap: 0.25rem 0.75rem;
    margin: 0.75rem 0 0;
}

.values dt {
    color: var(--muted);
}

.values dd {
    margin: 0;
    font-weight: 600;
    overflow-wrap: anywhere;
}

.values dd.missing {
    color: var(--warn);
    font-weight: normal;
}

.steps {
    list-style: none;
    margin: 0 0 1rem;
    padding: 0;
    display: grid;
    gap: 0.6rem;
}

.shared-header {
    display: flex;
    flex-wrap: wrap;
    align-items: baseline;
    gap: 0.5rem;
    margin-top: 0.4rem;
    padding: 0.4rem 0.25rem 0;
    font-weight: 600;
}

.step {
    display: flex;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}

.step.in-shared {
    margin-left: 0.75rem;
    border-left: 4px solid var(--accent);
}

.step-number {
    flex: none;
    width: 2em;
    height: 2em;
    display: grid;
    place-items: center;
    border-radius: 50%;
    background: var(--bg);
    border: 1px solid var(--border);
    font-weight: 600;
    font-size: 0.9em;
}

.step-body {
    min-width: 0;
    flex: 1;
}

.step-body p {
    margin: 0 0 0.4em;
}

.step-body img {
    max-width: 100%;
    height: auto;
    border-radius: 6px;
}

.step-expected {
    margin-top: 0.6rem;
    padding-top: 0.6rem;
    border-top: 1px dashed var(--border);
}

.step-expected .label {
    display: block;
    color: var(--muted);
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.param {
    padding: 0 0.3em;
    border-radius: 4px;
    background: var(--param-bg);
    font-weight: 600;
}

.param-missing {
    color: var(--warn);
    background: var(--warn-bg);
}

/* Suite list with run buttons */

.point-row {
    display: flex;
    gap: 0.5rem;
    align-items: stretch;
}

.point-row .list-item {
    flex: 1;
    min-width: 0;
}

.run-link {
    display: grid;
    place-items: center;
    min-width: 52px;
    border-radius: var(--radius);
    background: var(--accent);
    color: var(--accent-text);
    text-decoration: none;
    font-size: 1.1em;
}

a.button {
    display: inline-flex;
    align-items: center;
    text-decoration: none;
}

.button.secondary {
    background: var(--surface);
    border-color: var(--border);
    color: var(--text);
}

.button.pass, .big-button.pass { background: var(--pass); border-color: var(--pass); color: #ffffff; }
.button.fail, .big-button.fail { background: var(--fail); border-color: var(--fail); color: #ffffff; }

@media (prefers-color-scheme: dark) {
    .button.pass, .big-button.pass, .button.fail, .big-button.fail { color: #0b1520; }
}

/* Runner */

.runner {
    padding-bottom: 11rem;
}

.runner-title {
    margin-bottom: 0.3em;
}

.runner-status {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 0.25rem 1rem;
    color: var(--muted);
    font-size: 0.9em;
}

.sync.saved { color: var(--pass); }
.sync.saving { color: var(--muted); }
.sync.failed { color: var(--fail); font-weight: 600; }

.progress {
    height: 6px;
    margin: 0.4rem 0 0.8rem;
    border-radius: 999px;
    background: var(--border);
    overflow: hidden;
}

.progress div {
    height: 100%;
    background: var(--accent);
    transition: width 0.2s ease;
}

.notice {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: 10px;
    background: var(--param-bg);
}

.values.compact {
    margin: 0 0 0.75rem;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--surface);
}

.stage {
    touch-action: pan-y;
}

/* Text stays selectable (URLs, ids to copy); selection is only off while a card is dragged sideways. */
.stage.dragging {
    user-select: none;
    -webkit-user-select: none;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.preferences {
    margin: 1rem 0 0;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 10px;
}

.preferences legend {
    padding: 0 0.3rem;
    color: var(--muted);
    font-size: 0.9em;
}

.shared-label {
    margin: 0 0 0.35rem;
    color: var(--accent);
    font-weight: 600;
    font-size: 0.9em;
}

.step-card {
    position: relative;
    display: flex;
    gap: 0.9rem;
    min-height: 9rem;
    padding: 1.1rem 1.1rem 1.2rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
    font-size: 1.12em;
    overflow: hidden;
}

.step-card .step-number {
    width: 2.2em;
    height: 2.2em;
}

.swipe-hint {
    position: absolute;
    top: 0.75rem;
    padding: 0.2rem 0.7rem;
    border-radius: 8px;
    font-weight: 700;
    opacity: 0;
    pointer-events: none;
}

.swipe-hint.left { right: 0.75rem; }
.swipe-hint.right { left: 0.75rem; }

.stage[data-swipe=left] .swipe-hint.left,
.stage[data-swipe=right] .swipe-hint.right {
    opacity: var(--swipe-progress, 0);
}

/* The hint color follows its meaning, whichever side it is on. */
.swipe-hint.pass { background: var(--pass-bg); color: var(--pass); border: 2px solid var(--pass); }
.swipe-hint.fail { background: var(--fail-bg); color: var(--fail); border: 2px solid var(--fail); }

.hint {
    margin: 0.6rem 0 0;
    text-align: center;
}

.mini-steps {
    list-style: none;
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin: 1rem 0 0;
    padding: 0;
}

.mini {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: 0.8em;
    color: var(--muted);
}

.mini.passed { background: var(--pass-bg); color: var(--pass); border-color: var(--pass); }
.mini.failed { background: var(--fail-bg); color: var(--fail); border-color: var(--fail); }
.mini.current { outline: 2px solid var(--accent); outline-offset: 1px; color: var(--text); font-weight: 700; }

.summary {
    padding: 1.25rem;
    border: 1px solid var(--border);
    border-radius: 16px;
    background: var(--surface);
    text-align: center;
}

.summary-outcome {
    display: inline-block;
    font-size: 1.3em;
    padding: 0.3rem 1rem;
}

.countdown {
    font-weight: 600;
}

.summary-actions, .sheet-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.action-bar {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20;
    padding: 0.6rem 1rem;
    padding-bottom: max(0.6rem, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--bg) 92%, transparent);
    border-top: 1px solid var(--border);
    backdrop-filter: blur(8px);
}

.main-actions, .secondary-actions, .snackbar {
    max-width: 760px;
    margin: 0 auto;
}

.main-actions {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.big-button {
    min-height: 64px;
    border: none;
    border-radius: 14px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
}

.secondary-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 0.25rem;
}

.link-button:disabled {
    opacity: 0.4;
    cursor: default;
}

.snackbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
    padding: 0.2rem 0.4rem 0.2rem 0.9rem;
    border-radius: 10px;
    background: var(--text);
    color: var(--bg);
}

.snackbar .link-button {
    color: var(--bg);
    font-weight: 700;
}

.sheet-backdrop {
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(0, 0, 0, 0.45);
}

.sheet {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 31;
    max-width: 760px;
    margin: 0 auto;
    padding: 1.1rem 1rem;
    padding-bottom: max(1rem, env(safe-area-inset-bottom));
    border-radius: 18px 18px 0 0;
    background: var(--surface);
    font-size: calc(1rem * var(--text-scale));
}

.sheet h2 {
    margin: 0 0 0.6rem;
    font-size: 1.15em;
}

.sheet label {
    display: block;
    margin-bottom: 0.3rem;
    color: var(--muted);
    font-size: 0.9em;
}

.sheet textarea {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: 10px;
    background: var(--bg);
    color: var(--text);
    font: inherit;
}

.sheet-actions .button {
    flex: 1 1 100%;
}

.sheet .toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    color: var(--text);
}

/* Blazor template */

#blazor-error-ui {
    color-scheme: light only;
    background: lightyellow;
    color: #1d232b;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2);
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--border);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--accent);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Chargement");
}
