#toolbar {

    display: flex;
    align-items: flex-start;
    flex-wrap: wrap;

    gap: 12px;

    margin-top: 18px;

    box-sizing: border-box;
    width: 100%;
    max-width: 100%;
}

.toolbar-group {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;

    min-width: 0;
    max-width: 100%;
    flex: 1 1 auto;
}

/* The open file's name gets a full-width row of its own under the button
   groups: sitting inline after the last button it pushed the zoom controls
   onto a second line, so the toolbar reflowed to a different height for
   every file opened. */
.toolbar-filename-row {

    display: flex;
    justify-content: center;

    flex: 1 0 100%;
    min-width: 0;
}

/* Nothing open yet — collapse the row rather than spend #toolbar's row-gap
   on an empty strip. */
.toolbar-filename-row:has(> .loaded-filename:empty) {
    display: none;
}

.loaded-filename {
    display: inline-block;

    /* min-width so the flex item may shrink past its (nowrap) min-content
       width — without it the ellipsis never kicks in and a long name widens
       the toolbar instead. */
    min-width: 0;
    max-width: 100%;

    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;

    padding: 6px 10px;
    border-radius: 6px;

    font-size: 0.9rem;
    color: var(--text);
    background: rgba(255, 255, 255, 0.05);

    text-align: center;
}

.loaded-filename:empty {
    display: none;
}

.nav {

    display: flex;
    align-items: center;
    flex-wrap: wrap;

    gap: 10px;

    margin-bottom: 20px;
}

.nav a {

    color: var(--text);
    text-decoration: none;

    padding: 10px 14px;

    border-radius: 8px;

    background: transparent;
}

.nav a.active,
.nav a:hover {

    background: var(--panel-light);

    /* stated explicitly: the selected tab sits on a panel fill, not on the
       accent, so its ink has to follow the skin */
    color: var(--text-strong);
}

.nav a.active {
    border-color: var(--accent);
}

.file-button {

    display: inline-flex;

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

    padding: 10px 18px;

    border-radius: 10px;

    /* --accent-strong, not --accent: identical in the light skin (#0066cc),
       but --accent is a pale blue in the dark skin on which even white ink
       only reached 3.7:1.  This pair measures 5.6:1 light / 5.1:1 dark. */
    background: var(--accent-strong);

    /* was inheriting --text, which is dark ink on the blue fill in the light
       skin — the label has to track the accent, not the page */
    color: var(--on-accent);

    cursor: pointer;

    user-select: none;

    transition: .15s;
}

.file-button:hover {
    transform: translateY(-1px);
}

button {

    border: none;

    background: var(--panel-light);

    color: var(--text);

    padding: 10px 18px;

    border-radius: 10px;

    cursor: pointer;

    /* An inset ring rather than a real border, so it costs no layout: the
       ring is transparent in dark (the fill alone separates the button from
       the dark page) and a real edge in light, where a --panel-light button
       on a white panel would otherwise read as plain text. */
    box-shadow: inset 0 0 0 1px var(--btn-border), var(--panel-shadow);

    transition: .15s;
}

button:hover {
    transform: translateY(-1px);
}

button:disabled {

    opacity: .45;
    cursor: not-allowed;
}

button:disabled:hover {
    transform: none;
}

.zoom-controls {

    margin-left: auto;
    flex: 0 0 auto;
}

#zoomValue {

    min-width: 48px;

    text-align: center;
    color: var(--text-dim);
}

/* Only the small captions that sit beside a control ("Quality", "Margin",
   "Preset", the checkbox labels).  .file-button is a <label> too, but it is a
   button: excluded here so it keeps the ink its own rule gives it — an ID
   selector would otherwise outrank .file-button and paint the accent-filled
   Open button dim grey. */
#toolbar label:not(.file-button) {

    color: var(--text-dim);
}

#toolbar select {

    min-height: 38px;
    padding: 8px 10px;

    border:
        1px solid var(--border);

    border-radius: 8px;

    background: var(--panel-light);
    color: var(--text);
}

.checkbox-inline {

    display: inline-flex;
    align-items: center;
    gap: 6px;

    cursor: pointer;
    user-select: none;
}

.checkbox-inline input[type="checkbox"] {

    width: 16px;
    height: 16px;
    margin: 0;
    cursor: pointer;
}
