/* Dashboard styles remain available for the empty page shell. */

.instr-lock-fields[hidden] {
    display: none;
}

/* Basis-.auth-error ist ohne .show unsichtbar; hier reicht gesetzter Text. */
#instructionError:not(:empty),
#instrLockError:not(:empty),
#instrForgotError:not(:empty),
#instrResetError:not(:empty) {
    display: block;
}

#instrForgotOverlay .auth-submit[hidden] {
    display: none;
}

.instr-lock-info {
    margin: 0;
    font-size: 14px;
    line-height: 1.45;
    text-align: center;
    color: var(--accent-solid);
}

.instr-lock-info:empty {
    display: none;
}

.instr-lock-forgot {
    align-self: center;
    margin-top: -6px;
    padding: 6px 10px;
    border: none;
    background: none;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    color: var(--profile-text-label);
    cursor: pointer;
}

.instr-lock-forgot:hover {
    color: var(--accent-solid);
    text-decoration: underline;
}

.instr-lock-forgot:disabled {
    opacity: 0.5;
    cursor: default;
    text-decoration: none;
}

/* ---- QR-Code-Fenster ---- */
.instr-qr-modal .auth-subtitle {
    margin-bottom: 22px;
}

.instr-qr-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    width: 100%;
    padding: 22px 20px 18px;
    box-sizing: border-box;
    border: 1.5px solid var(--profile-border);
    border-radius: 20px;
    background: var(--profile-surface);
}

/* QR immer schwarz auf weiß, auch im Dunkelmodus (sonst scannt er schlecht). */
.instr-qr-code {
    display: flex;
    padding: 12px;
    border-radius: 14px;
    background: #fff;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.08);
}

.instr-qr-code canvas {
    display: none;
}

.instr-qr-code img {
    display: block;
    width: 208px;
    height: 208px;
    image-rendering: pixelated;
}

.instr-qr-ref {
    margin-top: 10px;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--profile-text-muted);
}

.instr-qr-ref:empty {
    display: none;
}

.instr-qr-name {
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--profile-text);
    overflow-wrap: anywhere;
}

.instr-qr-hint {
    margin: 14px 0 0;
    font-size: 12.5px;
    line-height: 1.45;
    color: var(--profile-text-muted);
}

.instr-qr-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 100%;
    margin-top: 18px;
}

.instr-qr-download,
.instr-qr-print {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
}

.instr-qr-download {
    margin-top: 0;
}

.instr-qr-download svg,
.instr-qr-print svg {
    width: 18px;
    height: 18px;
}

.instr-qr-print {
    height: 48px;
    border: 1.5px solid var(--profile-border);
    border-radius: 14px;
    background: transparent;
    color: var(--profile-text);
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease;
}

.instr-qr-print:hover {
    background: var(--profile-surface);
    border-color: var(--profile-text-muted);
}

/* Durchgehend dieselbe Schrift wie im Profil-Bereich (Buttons erben sie nicht automatisch) */
.instr-grid,
.instr-card,
.instr-card-title,
.instr-card-status,
.instr-card-metarow,
.instr-card-desc,
.instr-card-date,
.instr-menu-item,
.instr-card-ref,
.instr-safety,
.instr-empty,
.instr-empty-title,
.instr-empty-text,
.instruction-modal,
.instruction-modal select {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

/* Auswahlfeld im Anweisungs-Modal (gleicher Look wie .auth-field input) */
.instruction-modal select {
    height: 52px;
    padding: 0 44px 0 18px;
    box-sizing: border-box;
    border: 1.5px solid var(--profile-border);
    border-radius: 14px;
    background-color: var(--profile-input-bg);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%238a8a87' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    background-size: 18px 18px;
    font-family: inherit;
    font-size: 15px;
    color: var(--profile-text);
    outline: none;
    cursor: pointer;
    appearance: none;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.instruction-modal select:focus {
    border-color: var(--accent-solid);
    background-color: var(--profile-white);
    box-shadow: 0 0 0 4px var(--profile-focus-ring);
}

.instruction-modal {
    max-width: 520px;
    align-items: stretch;
    text-align: left;
}

/* ---- Sicherheitsstufe-Auswahl ---- */
.safety-picker {
    --lvl: var(--accent-solid);
    position: relative;
}

.safety-picker i,
.safety-picker b,
.safety-picker small {
    font-style: normal;
}

.safety-picker-btn {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    height: 52px;
    padding: 0 16px;
    box-sizing: border-box;
    border: 1.5px solid var(--profile-border);
    border-radius: 14px;
    background: var(--profile-input-bg);
    color: var(--profile-text);
    font-family: inherit;
    font-size: 15px;
    text-align: left;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
}

.safety-picker-btn:hover {
    border-color: var(--profile-hover-border);
}

.safety-picker-btn:focus-visible,
.safety-picker.open .safety-picker-btn {
    border-color: var(--accent-solid);
    background: var(--profile-white);
    box-shadow: 0 0 0 4px var(--profile-focus-ring);
    outline: none;
}

.safety-picker-btn.is-mittel,
.safety-opt.is-mittel { --lvl: #d97706; }
.safety-picker-btn.is-hoch,
.safety-opt.is-hoch { --lvl: #dc2626; }
.safety-picker-btn.is-gering,
.safety-opt.is-gering { --lvl: var(--accent-solid); }

.safety-picker-icon,
.safety-opt-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: color-mix(in srgb, var(--lvl) 14%, transparent);
    color: var(--lvl);
}

.safety-picker-icon svg,
.safety-opt-icon svg {
    width: 16px;
    height: 16px;
}

.safety-picker-value {
    flex: 1;
    font-weight: 600;
}

.safety-picker-chevron {
    display: inline-flex;
    color: var(--profile-text-muted);
    transition: transform 0.2s ease;
}

.safety-picker-chevron svg {
    width: 18px;
    height: 18px;
}

.safety-picker.open .safety-picker-chevron {
    transform: rotate(180deg);
}

.safety-picker-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    z-index: 30;
    display: none;
    flex-direction: column;
    gap: 2px;
    margin: 0;
    padding: 6px;
    list-style: none;
    border: 1px solid var(--profile-border);
    border-radius: 14px;
    background: var(--profile-white);
    box-shadow: 0 18px 44px rgba(16, 24, 40, 0.18), 0 2px 6px rgba(16, 24, 40, 0.06);
    transform-origin: top center;
}

.safety-picker.open .safety-picker-menu {
    display: flex;
    animation: instrSortIn 0.16s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.safety-opt {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    outline: none;
    transition: background 0.12s ease;
}

.safety-opt:hover,
.safety-opt:focus-visible {
    background: var(--profile-surface);
}

.safety-opt-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.safety-opt-text b {
    font-size: 14px;
    font-weight: 600;
    color: var(--profile-text);
}

.safety-opt-text small {
    font-size: 12.5px;
    color: var(--profile-text-muted);
}

.safety-opt-check {
    display: inline-flex;
    color: var(--lvl);
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.safety-opt-check svg {
    width: 17px;
    height: 17px;
}

.safety-opt.is-active {
    background: color-mix(in srgb, var(--lvl) 8%, transparent);
}

.safety-opt.is-active .safety-opt-check {
    opacity: 1;
    transform: none;
}

body.dark .safety-picker-btn.is-mittel,
body.dark .safety-opt.is-mittel { --lvl: #f59e0b; }
body.dark .safety-picker-btn.is-hoch,
body.dark .safety-opt.is-hoch { --lvl: #f87171; }

body.dark .safety-picker-menu {
    background: #2a2a2a;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 18px 44px rgba(0, 0, 0, 0.5);
}

body.dark .safety-opt:hover,
body.dark .safety-opt:focus-visible {
    background: rgba(255, 255, 255, 0.06);
}

body.dark .safety-opt.is-active {
    background: color-mix(in srgb, var(--lvl) 12%, transparent);
}

/* Kopfbereich zentriert, Formularfelder bleiben linksbündig */
.instruction-modal .auth-brand {
    align-self: center;
}

.instruction-modal .auth-title,
.instruction-modal .auth-subtitle {
    text-align: center;
}

/* ---- Anweisungs-Übersicht ---- */
.instr-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    flex-wrap: wrap;
    gap: 10px;
    /* page-content hat 32px Abstand oben – Filter näher an die Unter-Tabs ziehen */
    margin-top: -18px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.instr-sort {
    position: relative;
    z-index: 9; /* unter Topbar (10), damit das Profil-Menü darüber liegt */
}

.instr-sort-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 38px;
    padding: 0 10px 0 12px;
    border: 1px solid var(--profile-border);
    border-radius: 11px;
    background: var(--profile-white);
    color: var(--profile-text-muted);
    font-family: inherit;
    cursor: pointer;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.instr-sort-btn:hover {
    border-color: var(--profile-hover-border);
}

.instr-sort-btn:focus-visible,
.instr-sort.open .instr-sort-btn {
    border-color: var(--accent-solid);
    box-shadow: 0 0 0 3px rgba(21, 144, 121, 0.14);
    outline: none;
}

.instr-sort-btn > svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.instr-sort-label {
    font-size: 13px;
    font-weight: 500;
}

.instr-sort-value {
    font-size: 13px;
    font-weight: 600;
    color: var(--profile-text);
}

.instr-sort-chevron {
    display: inline-flex;
    margin-left: 2px;
    transition: transform 0.2s ease;
}

.instr-sort-chevron svg {
    width: 15px;
    height: 15px;
}

.instr-sort.open .instr-sort-chevron {
    transform: rotate(180deg);
}

.instr-sort-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    display: none;
    flex-direction: column;
    gap: 2px;
    width: 260px;
    margin: 0;
    padding: 6px;
    list-style: none;
    border: 1px solid var(--profile-border);
    border-radius: 14px;
    background: var(--profile-white);
    box-shadow: 0 16px 40px rgba(16, 24, 40, 0.16), 0 2px 6px rgba(16, 24, 40, 0.06);
    transform-origin: top left;
}

.instr-sort.open .instr-sort-menu {
    display: flex;
    animation: instrSortIn 0.16s cubic-bezier(0.16, 1, 0.3, 1) both;
}

@keyframes instrSortIn {
    from { opacity: 0; transform: translateY(-6px) scale(0.97); }
    to { opacity: 1; transform: none; }
}

.instr-sort-opt {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 9px 10px;
    border: none;
    border-radius: 10px;
    background: transparent;
    font-family: inherit;
    text-align: left;
    cursor: pointer;
    outline: none;
    transition: background 0.12s ease;
}

.instr-sort-opt:hover,
.instr-sort-opt:focus-visible {
    background: var(--profile-surface);
}

.instr-sort-opt-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 9px;
    background: var(--profile-surface);
    color: var(--profile-text-muted);
    transition: background 0.12s ease, color 0.12s ease;
}

.instr-sort-opt-icon svg {
    width: 16px;
    height: 16px;
}

.instr-sort-opt-text {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.instr-sort-opt-text b {
    font-size: 13.5px;
    font-weight: 600;
    color: var(--profile-text);
}

.instr-sort-opt-text small {
    font-size: 12px;
    color: var(--profile-text-muted);
}

.instr-sort-opt-check {
    display: inline-flex;
    color: var(--accent-solid);
    opacity: 0;
    transform: scale(0.6);
    transition: opacity 0.15s ease, transform 0.15s ease;
}

.instr-sort-opt-check svg {
    width: 16px;
    height: 16px;
}

.instr-sort-opt.is-active .instr-sort-opt-icon {
    background: rgba(21, 144, 121, 0.14);
    color: var(--accent-solid);
}

.instr-sort-opt.is-active .instr-sort-opt-check {
    opacity: 1;
    transform: none;
}

body.dark .instr-sort-btn {
    background: #242424;
}

.instr-pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 22px;
}

.instr-pager-info {
    font-size: 13px;
    color: var(--profile-text-muted);
}

.instr-pager-nav {
    display: flex;
    align-items: center;
    gap: 6px;
}

.instr-pager-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 40px;
    padding: 0 16px;
    border: 1px solid var(--profile-border);
    border-radius: 11px;
    background: var(--profile-white);
    color: var(--profile-text-muted);
    font: inherit;
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}

.instr-pager-btn svg {
    width: 16px;
    height: 16px;
}

.instr-pager-btn:hover {
    border-color: var(--profile-hover-border);
}

.instr-pager-btn.is-primary {
    border-color: var(--accent-solid);
    background: var(--accent-solid);
    color: #fff;
}

.instr-pager-btn.is-primary:hover {
    filter: brightness(1.08);
}

body.dark .instr-pager-btn:not(.is-primary) {
    background: #242424;
}

body.dark .instr-sort-menu {
    background: #2a2a2a;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

body.dark .instr-sort-opt:hover,
body.dark .instr-sort-opt:focus-visible {
    background: rgba(255, 255, 255, 0.06);
}

body.dark .instr-sort-opt-icon {
    background: rgba(255, 255, 255, 0.06);
}

body.dark .instr-sort-opt.is-active .instr-sort-opt-icon {
    background: rgba(21, 144, 121, 0.18);
}

.instr-toolbar + .instr-grid,
.instr-results {
    padding-top: 16px;
}

.instr-results .instr-grid {
    padding-top: 0;
}

/* Suche */
.instr-search {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 0 1 280px;
    min-width: 180px;
    height: 38px;
    padding: 0 12px;
    border: 1px solid var(--profile-border);
    border-radius: 11px;
    background: var(--profile-white);
    color: var(--profile-text-muted);
    cursor: text;
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.instr-search:focus-within {
    border-color: var(--accent-solid);
    box-shadow: 0 0 0 3px rgba(21, 144, 121, 0.14);
}

.instr-search svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
}

.instr-search input {
    flex: 1;
    min-width: 0;
    height: 100%;
    border: none;
    outline: none;
    background: transparent;
    color: var(--profile-text);
    font: inherit;
    font-size: 13.5px;
}

.instr-search input::placeholder {
    color: var(--profile-text-muted);
}

.instr-toolbar-end {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-left: auto;
}

/* Ansicht umschalten */
.instr-view {
    display: inline-flex;
    gap: 2px;
    padding: 3px;
    border: 1px solid var(--profile-border);
    border-radius: 11px;
    background: var(--profile-white);
}

.instr-view-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 30px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--profile-text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.instr-view-btn svg {
    width: 16px;
    height: 16px;
}

.instr-view-btn:hover {
    color: var(--profile-text);
}

.instr-view-btn.is-active {
    background: rgba(21, 144, 121, 0.12);
    color: var(--accent-solid);
}

body.dark .instr-search,
body.dark .instr-view {
    background: #242424;
}

/* Keine Treffer */
.instr-noresults {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    padding: 56px 20px;
    border: 1px dashed var(--profile-border);
    border-radius: 16px;
    color: var(--profile-text-muted);
    font-size: 13.5px;
    text-align: center;
}

.instr-noresults svg {
    width: 28px;
    height: 28px;
    margin-bottom: 4px;
}

.instr-noresults b {
    color: var(--profile-text);
    font-size: 15px;
}

/* Karten: Sicherheits-Streifen, Vorschaubild, Inhalt */
.instr-card,
.instr-row {
    --safety-color: var(--accent-solid);
    overflow: visible;
}

.instr-card.is-safety-mittel,
.instr-row.is-safety-mittel {
    --safety-color: #d97706;
}

.instr-card.is-safety-hoch,
.instr-row.is-safety-hoch {
    --safety-color: #dc2626;
}

.instr-card::before,
.instr-row::before {
    content: "";
    position: absolute;
    top: 14px;
    bottom: 14px;
    left: -1px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--safety-color);
}

.instr-card-icon.has-cover {
    overflow: hidden;
    background: var(--profile-surface);
}

.instr-card-icon.has-cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.instr-card-main .instr-card-ref {
    color: var(--profile-text-muted);
}

.instr-progress,
.instr-draft {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    font-weight: 600;
    white-space: nowrap;
}

.instr-progress {
    color: var(--profile-text);
}

.instr-progress svg {
    width: 14px;
    height: 14px;
    color: var(--profile-text-muted);
}

.instr-draft {
    padding: 3px 10px;
    border: 1px dashed var(--profile-border);
    border-radius: 999px;
    color: var(--profile-text-muted);
}

.instr-card-foot .instr-safety {
    padding: 3px 8px;
    font-size: 11.5px;
}

/* Listenansicht */
.instr-list {
    display: flex;
    flex-direction: column;
    border: 1px solid var(--profile-border);
    border-radius: 16px;
    background: var(--profile-white);
}

.instr-list-head,
.instr-row {
    display: grid;
    grid-template-columns: minmax(0, 2.4fr) minmax(0, 1.3fr) minmax(0, 0.9fr) minmax(0, 0.9fr) 36px;
    align-items: center;
    gap: 16px;
    padding: 0 14px 0 18px;
}

.instr-list-head {
    height: 40px;
    border-bottom: 1px solid var(--profile-border);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--profile-text-muted);
}

.instr-row {
    position: relative;
    min-height: 62px;
    cursor: pointer;
    transition: background 0.15s ease;
    z-index: 0;
}

.instr-row + .instr-row {
    border-top: 1px solid var(--profile-border);
}

.instr-row::before {
    top: 12px;
    bottom: 12px;
    left: 0;
}

.instr-row:hover {
    background: var(--profile-surface);
}

.instr-row:last-child {
    border-radius: 0 0 16px 16px;
}

.instr-row.menu-open {
    z-index: 5;
}

.instr-row-name {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.instr-row .instr-card-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
}

.instr-row .instr-card-icon svg {
    width: 18px;
    height: 18px;
}

.instr-row-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.instr-row .instr-card-title {
    font-size: 14.5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.instr-row .instr-card-ref {
    color: var(--profile-text-muted);
}

.instr-row .instr-card-date {
    margin-left: 0;
    font-size: 13px;
}

.instr-row.is-archived .instr-row-name {
    opacity: 0.6;
}

.instr-row .instr-card-menu {
    margin: 0;
}

body.dark .instr-list {
    background: #242424;
}

body.dark .instr-row:hover {
    background: #2a2a2a;
}

@media (max-width: 900px) {
    .instr-list-head,
    .instr-row {
        grid-template-columns: minmax(0, 1fr) auto 36px;
    }

    .instr-list-head span:nth-child(2),
    .instr-list-head span:nth-child(4),
    .instr-row-steps,
    .instr-row-date {
        display: none;
    }
}

@media (max-width: 820px) {
    .instr-toolbar .instr-sort {
        display: none;
    }

    .instr-search {
        flex: 1 1 auto;
    }

    .instr-toolbar-end {
        margin-left: 0;
    }

    .instr-sort-menu {
        left: auto;
        right: 0;
        transform-origin: top right;
    }
}

@media (max-width: 520px) {
    .instr-sort-label {
        display: none;
    }
}

.instr-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 18px;
    padding-top: 26px;
}

.instr-card {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px 16px 14px 18px;
    background: var(--profile-white);
    border: 1px solid var(--profile-border);
    border-radius: 16px;
    box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
    cursor: pointer;
    transition: border-color 0.25s ease, background-color 0.25s ease, box-shadow 0.25s ease;
    /* Stapelkontext immer vorhanden, damit das Öffnen des Menüs nur die Reihenfolge ändert */
    z-index: 0;
}

.instr-card:hover {
    border-color: var(--accent-solid);
    box-shadow: 0 0 0 3px rgba(21, 144, 121, 0.1), 0 8px 24px rgba(16, 24, 40, 0.06);
}

.instr-card.menu-open {
    z-index: 5;
}

/* Lesezeichen: wartet auf Freigabe */
.instr-flag {
    position: absolute;
    top: -1px;
    right: 54px;
    z-index: 1;
    filter: drop-shadow(0 4px 6px rgba(217, 119, 6, 0.35));
    pointer-events: auto;
}

.instr-flag i {
    display: flex;
    justify-content: center;
    box-sizing: border-box;
    width: 24px;
    height: 32px;
    padding-top: 6px;
    background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
    color: #ffffff;
    clip-path: polygon(0 0, 100% 0, 100% 100%, 50% 74%, 0 100%);
}

.instr-flag svg {
    width: 13px;
    height: 13px;
    stroke-width: 3;
}

.instr-card.is-pending .instr-card-main {
    padding-right: 30px;
}

/* Admin/Inhaber: freigabebereite Karten heben sich ab */
.instr-card.is-actionable {
    border-color: rgba(217, 119, 6, 0.45);
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.07) 0%, rgba(245, 158, 11, 0) 55%), var(--profile-white);
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.08), 0 6px 18px rgba(217, 119, 6, 0.08);
}

.instr-card.is-actionable:hover {
    border-color: #d97706;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.16), 0 8px 24px rgba(16, 24, 40, 0.06);
}

/* Listenansicht: kleines Lesezeichen am Vorschaubild */
.instr-row .instr-flag {
    top: 6px;
    right: auto;
    left: 44px;
}

.instr-row .instr-flag i {
    width: 18px;
    height: 24px;
    padding-top: 4px;
}

.instr-row .instr-flag svg {
    width: 10px;
    height: 10px;
}

.instr-row.is-actionable {
    background: rgba(245, 158, 11, 0.06);
}

.instr-card.is-archived .instr-card-icon,
.instr-card.is-archived .instr-card-title {
    opacity: 0.6;
}

.instr-card-head {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.instr-card-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    flex-shrink: 0;
    border-radius: 11px;
    background: rgba(21, 144, 121, 0.12);
    color: var(--accent-solid);
}

.instr-card-icon svg {
    width: 20px;
    height: 20px;
}

.instr-card-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding-top: 1px;
}

.instr-card-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    letter-spacing: -0.01em;
    line-height: 1.3;
    color: var(--profile-text);
    overflow-wrap: anywhere;
}

.instr-card-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    font-size: 12.5px;
    color: var(--profile-text-muted);
}

.instr-card-ref {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.instr-card-dot {
    opacity: 0.6;
}

.instr-card-status {
    flex-shrink: 0;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.instr-safety {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.instr-safety svg {
    width: 13px;
    height: 13px;
}

.instr-safety.is-gering {
    background: rgba(21, 144, 121, 0.12);
    color: var(--accent-solid);
}

.instr-safety.is-mittel {
    background: rgba(217, 119, 6, 0.14);
    color: #b45309;
}

.instr-safety.is-hoch {
    background: rgba(220, 38, 38, 0.12);
    color: #c0392b;
}

.instr-card-metarow {
    display: flex;
    align-items: center;
    gap: 9px;
    font-size: 13.5px;
    color: #5c5c66;
}

.instr-card-metarow svg {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    color: #9a9aa5;
}

.instr-card-desc {
    margin: 0;
    font-size: 13.5px;
    line-height: 1.5;
    color: #6a6a74;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.instr-card-foot {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: auto;
    padding-top: 12px;
    border-top: 1px solid var(--profile-border);
    min-width: 0;
}

.instr-card-foot > * {
    flex-shrink: 0;
    white-space: nowrap;
}

.instr-card-date {
    margin-left: auto;
    font-size: 12px;
    color: var(--profile-text-muted);
}

/* Status-Pille (Archiviert / Papierkorb) darf umbrechen statt aus der Karte zu ragen */
.instr-card-foot .instr-card-status {
    flex-shrink: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ⋯-Menü */
.instr-card-menu {
    position: relative;
    flex-shrink: 0;
    margin: -6px -4px 0 0;
}

.instr-card-more {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: var(--profile-text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.instr-card-more svg {
    width: 18px;
    height: 18px;
    stroke-width: 2.4;
}

.instr-card-more:hover,
.instr-card-menu.open .instr-card-more {
    background: var(--profile-surface);
    color: var(--profile-text);
}

.instr-menu {
    position: absolute;
    top: calc(100% + 6px);
    right: 0;
    z-index: 10;
    display: none;
    flex-direction: column;
    min-width: 184px;
    padding: 6px;
    background: var(--profile-white);
    border: 1px solid var(--profile-border);
    border-radius: 12px;
    box-shadow: 0 12px 32px rgba(16, 24, 40, 0.16);
    /* Eigene, feste Compositing-Ebene: verhindert das Aufflackern, wenn die Animation endet */
    will-change: opacity, transform;
    backface-visibility: hidden;
}

.instr-card-menu.open .instr-menu {
    display: flex;
    animation: instrMenuIn 0.14s ease-out both;
}

@keyframes instrMenuIn {
    from { opacity: 0; transform: translate3d(0, -4px, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.instr-menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    height: 38px;
    padding: 0 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--profile-text);
    font-size: 14px;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 0.12s ease;
}

.instr-menu-item svg {
    width: 16px;
    height: 16px;
    flex-shrink: 0;
    color: var(--profile-text-muted);
}

.instr-menu-item:hover {
    background: var(--profile-surface);
}

.instr-menu-item.is-danger,
.instr-menu-item.is-danger svg {
    color: var(--profile-danger);
}

.instr-menu-item.is-danger:hover {
    background: var(--profile-danger-bg);
}

.instr-card-status.is-archived {
    background: var(--profile-surface);
    color: var(--profile-text-muted);
}

.instr-card-status.is-trashed {
    background: var(--profile-danger-bg);
    color: var(--profile-danger);
}

/* Entwürfe + Freigabe */
.instr-card-status.is-draft {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(59, 130, 246, 0.1);
    color: #2563eb;
}

.instr-card-status.is-draft svg {
    width: 12px;
    height: 12px;
    stroke-width: 2.4;
}

.instr-card-status.is-pending {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    background: rgba(217, 119, 6, 0.12);
    color: #b45309;
}

.instr-card-status.is-pending i,
.instr-draft-bar.is-pending .instr-draft-bar-ic i {
    position: relative;
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #d97706;
    flex-shrink: 0;
}

.instr-card-status.is-pending i::after,
.instr-draft-bar.is-pending .instr-draft-bar-ic i::after {
    content: "";
    position: absolute;
    inset: -3px;
    border-radius: 50%;
    background: rgba(217, 119, 6, 0.35);
    animation: instrPendingPulse 1.8s ease-out infinite;
}

@keyframes instrPendingPulse {
    0% { transform: scale(0.6); opacity: 0.9; }
    100% { transform: scale(1.9); opacity: 0; }
}

.instr-row-steps {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    min-width: 0;
}

.instr-menu-item.is-accent,
.instr-menu-item.is-accent svg {
    color: var(--accent-solid);
}

.instr-menu-item.is-accent:hover {
    background: rgba(21, 144, 121, 0.1);
}

/* Hinweisleiste im Tab "Entwürfe" */
.instr-draft-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 16px;
    padding: 13px 16px;
    border: 1px solid rgba(59, 130, 246, 0.18);
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.07), rgba(59, 130, 246, 0.02));
    color: var(--profile-text);
    font-size: 13.5px;
    line-height: 1.45;
}

.instr-draft-bar > span:last-child {
    flex: 1;
    min-width: 0;
}

.instr-draft-bar b {
    font-weight: 700;
}

.instr-draft-bar-ic {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    border-radius: 12px;
    background: rgba(59, 130, 246, 0.12);
    color: #2563eb;
}

.instr-draft-bar-ic svg {
    width: 19px;
    height: 19px;
}

.instr-draft-bar-ic i {
    position: absolute !important;
    top: -3px;
    right: -3px;
}

.instr-draft-bar.is-pending {
    border-color: rgba(217, 119, 6, 0.24);
    background: linear-gradient(135deg, rgba(217, 119, 6, 0.1), rgba(217, 119, 6, 0.03));
}

.instr-draft-bar.is-pending .instr-draft-bar-ic {
    background: rgba(217, 119, 6, 0.14);
    color: #b45309;
}

/* Zähler am Tab "Entwürfe" */
.page-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    border-radius: 999px;
    background: rgba(59, 130, 246, 0.12);
    color: #2563eb;
    font-size: 11.5px;
    font-style: normal;
    font-weight: 700;
    line-height: 1;
}

.page-tab-badge.is-pending {
    background: #d97706;
    color: #ffffff;
}

body.dark .instr-card-status.is-draft,
body.dark .page-tab-badge {
    background: rgba(96, 165, 250, 0.18);
    color: #93c5fd;
}

body.dark .page-tab-badge.is-pending {
    background: #d97706;
    color: #ffffff;
}

body.dark .instr-card-status.is-pending {
    color: #fbbf24;
}

body.dark .instr-draft-bar {
    border-color: rgba(96, 165, 250, 0.22);
    background: rgba(96, 165, 250, 0.08);
}

body.dark .instr-draft-bar-ic {
    color: #93c5fd;
}

body.dark .instr-draft-bar.is-pending {
    border-color: rgba(245, 158, 11, 0.3);
    background: rgba(245, 158, 11, 0.1);
}

body.dark .instr-draft-bar.is-pending .instr-draft-bar-ic {
    color: #fbbf24;
}

@media (max-width: 640px) {
    .instr-draft-bar {
        align-items: flex-start;
    }
}

/* Papierkorb: Hinweisleiste mit "leeren"-Button (zwei Klicks) */
.instr-trash-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 16px;
    padding: 12px 16px;
    border: 1px solid var(--profile-border);
    border-radius: 14px;
    background: var(--profile-surface);
    color: var(--profile-text-muted);
    font-size: 13.5px;
}

.instr-trash-bar > svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
    color: var(--profile-danger);
}

.instr-trash-bar > span {
    flex: 1;
    min-width: 0;
}

.instr-trash-empty {
    flex-shrink: 0;
    height: 34px;
    padding: 0 14px;
    border: 1px solid var(--profile-danger);
    border-radius: 999px;
    background: transparent;
    color: var(--profile-danger);
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.instr-trash-empty:hover,
.instr-trash-empty.is-confirm {
    background: var(--profile-danger);
    color: #ffffff;
}

.instr-trash-empty .is-ask,
.instr-trash-empty.is-confirm .is-idle {
    display: none;
}

.instr-trash-empty.is-confirm .is-ask {
    display: inline;
}

.instr-trash-empty:disabled {
    opacity: 0.6;
    cursor: default;
}

/* Papierkorb: gelöschte Versionen – eigener Abschnitt mit Karten im Anweisungs-Stil */
.instr-vtrash {
    margin-top: 34px;
}

.instr-results > .instr-vtrash:first-child,
.instr-trash-bar + .instr-vtrash {
    margin-top: 6px;
}

.instr-vtrash-head {
    display: flex;
    align-items: center;
    gap: 10px;
}

.instr-vtrash-head::after {
    content: "";
    flex: 1;
    height: 1px;
    margin-left: 6px;
    background: var(--profile-border);
}

.instr-vtrash-head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--profile-text);
}

.instr-vtrash-head-ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--profile-surface);
    color: var(--profile-text-muted);
}

.instr-vtrash-head-ic svg {
    width: 16px;
    height: 16px;
}

.instr-vtrash-count {
    padding: 1px 8px;
    border-radius: 999px;
    background: var(--profile-surface);
    color: var(--profile-text-muted);
    font-size: 12px;
    font-weight: 700;
}

.instr-vtrash .instr-grid {
    padding-top: 16px;
}

.instr-vcard {
    cursor: default;
}

.instr-vcard .instr-card-icon:not(.has-cover) {
    background: var(--profile-surface);
    color: var(--profile-text-muted);
}

/* Versions-Pille auf der Karte */
.instr-vbadge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    border: 1px solid var(--profile-border);
    border-radius: 999px;
    background: var(--profile-surface);
    color: var(--profile-text);
    font-size: 12px;
    font-weight: 600;
}

.instr-vbadge svg {
    width: 13px;
    height: 13px;
    color: var(--profile-text-muted);
}

body.dark .instr-vbadge {
    background: rgba(255, 255, 255, 0.06);
}

.instr-menu-item.is-confirm,
.instr-menu-item.is-confirm svg {
    background: var(--profile-danger);
    color: #ffffff;
}

.instr-menu-item .is-ask,
.instr-menu-item.is-confirm .is-idle {
    display: none;
}

.instr-menu-item.is-confirm .is-ask {
    display: inline;
}

@media (max-width: 640px) {
    .instr-trash-bar {
        flex-wrap: wrap;
    }

    .instr-trash-bar > span {
        flex-basis: calc(100% - 30px);
    }
}

/* Nur-Lesen-Ansicht (Mitarbeiter / Papierkorb / aktive Anweisungen): Text auf weißem Grund */
.idm-text-box.is-readonly {
    background: var(--profile-white);
}

.idm-text-box.is-readonly:focus-within {
    border-color: var(--profile-border);
    box-shadow: none;
    background: var(--profile-white);
}

.idm-drop.is-readonly {
    border-style: solid;
    cursor: default;
}

/* Skeleton beim Laden */
.instr-card-skel {
    min-height: 130px;
    border: 1px solid var(--profile-border);
    background: linear-gradient(100deg, var(--profile-surface) 30%, var(--profile-hover-bg) 50%, var(--profile-surface) 70%);
    background-size: 200% 100%;
    animation: instrShimmer 1.3s ease-in-out infinite;
}

@keyframes instrShimmer {
    from { background-position: 200% 0; }
    to { background-position: -200% 0; }
}

/* Leerer Zustand */
.instr-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    gap: 12px;
    min-height: calc(100vh - 260px);
    padding: 20px;
}

.instr-empty-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 76px;
    height: 76px;
    border-radius: 22px;
    background: rgba(21, 144, 121, 0.12);
    color: var(--accent-solid);
    box-shadow: none;
}

.instr-empty-icon svg {
    width: 36px;
    height: 36px;
}

.instr-empty-title {
    margin: 8px 0 0;
    min-height: 28px;
    font-size: 21px;
    font-weight: 700;
    color: #1a1a1a;
}

.instr-empty-text {
    margin: 0;
    max-width: 380px;
    min-height: 45px;
    font-size: 14.5px;
    line-height: 1.55;
    color: #8a8a87;
}

/* Dark Mode – neutrale Grautöne passend zur Seite (#1e1e1e) */
body.dark .instr-card {
    background: #242424;
    box-shadow: none;
}

body.dark .instr-card:hover {
    background: #262626;
    border-color: var(--accent-solid);
    box-shadow: 0 0 0 3px rgba(21, 144, 121, 0.14), 0 8px 24px rgba(0, 0, 0, 0.3);
}

body.dark .instr-card.is-actionable,
body.dark .instr-card.is-actionable:hover {
    border-color: rgba(245, 158, 11, 0.55);
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.1) 0%, rgba(245, 158, 11, 0) 55%), #242424;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

body.dark .instr-card-icon {
    background: rgba(21, 144, 121, 0.16);
}

body.dark .instr-card-more:hover,
body.dark .instr-card-menu.open .instr-card-more,
body.dark .instr-menu-item:hover {
    background: rgba(255, 255, 255, 0.07);
}

body.dark .instr-menu {
    background: #2a2a2a;
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

body.dark .instr-menu-item.is-danger:hover {
    background: var(--profile-danger-bg);
}

body.dark .instr-safety.is-mittel {
    color: #f59e0b;
}

body.dark .instr-safety.is-hoch {
    color: #f87171;
}

body.dark .instr-empty-title {
    color: #f2f4fa;
}

body.dark .instr-card-metarow {
    color: #c3c6d2;
}

body.dark .instr-card-desc {
    color: #a8abb8;
}

body.dark .instr-card-status.is-archived {
    background: rgba(255, 255, 255, 0.08);
}

@media (max-width: 820px) {
    /* Platz für den schwebenden Aktionsbutton */
    .instr-grid,
    .instr-results {
        padding-bottom: 90px;
    }

    .instr-results .instr-grid {
        padding-bottom: 0;
    }

    .instr-empty {
        min-height: calc(100vh - 300px);
        padding-bottom: 90px;
    }
}

@media (max-width: 640px) {
    .instr-grid {
        grid-template-columns: 1fr;
    }
}

/* ================================================================== */
/*  Anweisungs-Fenster (Übersicht + Schritt-Editor)                    */
/* ================================================================== */
.idm-overlay {
    padding: 20px;
    box-sizing: border-box;
}

.idm {
    --idm-accent-soft: color-mix(in srgb, var(--accent-solid) 12%, transparent);
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 680px;
    max-height: min(880px, calc(100vh - 40px));
    overflow: hidden;
    background: var(--profile-white);
    color: var(--profile-text);
    border-radius: 24px;
    box-shadow: 0 30px 80px var(--profile-modal-shadow);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    animation: authPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.idm button,
.idm input,
.idm textarea {
    font-family: inherit;
}

.idm.is-editor {
    max-width: 820px;
    height: min(880px, calc(100vh - 40px));
}

.idm svg {
    flex-shrink: 0;
}

/* ---- Kopf ---- */
.idm-head {
    display: flex;
    align-items: flex-start;
    gap: 14px;
    padding: 22px 22px 18px;
    border-bottom: 1px solid var(--profile-border);
}

.idm-head-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 46px;
    height: 46px;
    border-radius: 14px;
    background: var(--accent-gradient);
    color: #ffffff;
    box-shadow: 0 6px 16px var(--accent-shadow);
}

.idm-head-icon svg {
    width: 22px;
    height: 22px;
}

.idm-head-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 3px;
}

.idm-head-main.is-center {
    align-items: center;
    text-align: center;
}

.idm-eyebrow {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.02em;
    color: var(--profile-text-muted);
}

.idm-title {
    margin: 0;
    font-size: 21px;
    font-weight: 700;
    letter-spacing: -0.02em;
    line-height: 1.2;
    color: var(--profile-text);
    overflow-wrap: anywhere;
}

.idm-title-sub {
    font-weight: 500;
    color: var(--profile-text-muted);
}

.idm-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 6px;
}

.idm-head-actions {
    display: flex;
    gap: 6px;
}

.idm-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: none;
    border-radius: 11px;
    background: var(--profile-surface);
    color: var(--profile-text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.idm-icon-btn:hover {
    background: var(--profile-border);
    color: var(--profile-text);
}

.idm-icon-btn svg {
    width: 18px;
    height: 18px;
}

.idm-head-editor {
    align-items: center;
}

.idm-done-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    height: 38px;
    padding: 0 14px;
    border: none;
    border-radius: 11px;
    background: var(--idm-accent-soft);
    color: var(--accent-solid);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s ease;
}

.idm-done-btn:hover {
    filter: brightness(0.96);
}

.idm-step-del {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    height: 38px;
    min-width: 38px;
    padding: 0 11px;
    border: none;
    border-radius: 11px;
    background: transparent;
    color: var(--profile-text-muted);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.idm-step-del svg {
    width: 17px;
    height: 17px;
}

.idm-step-del span {
    display: none;
}

.idm-step-del:hover {
    background: rgba(220, 38, 38, 0.08);
    color: #dc2626;
}

.idm-step-del.is-confirm {
    background: #dc2626;
    color: #ffffff;
}

.idm-step-del.is-confirm span {
    display: inline;
}

.idm-done-btn svg {
    width: 16px;
    height: 16px;
}

.idm-progress {
    height: 4px;
    background: var(--profile-surface);
}

.idm-progress span {
    display: block;
    height: 100%;
    background: var(--accent-gradient);
    border-radius: 0 4px 4px 0;
    transition: width 0.3s ease;
}

/* ---- Übersicht: Kopf ---- */
.idm-hero {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 22px 22px 20px;
    background: var(--profile-white);
    border-bottom: 1px solid var(--profile-border);
}

.idm-hero-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.idm-hero-actions {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: 8px;
}

.idm-hero-close {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    border-radius: 10px;
}

.idm-hero-qr {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
    height: 38px;
    padding: 0 14px 0 11px;
    border: none;
    border-radius: 11px;
    background: var(--accent-gradient);
    color: #fff;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    letter-spacing: normal;
    cursor: pointer;
    transition: filter 0.15s ease, transform 0.1s ease;
}

.idm-hero-qr svg {
    width: 18px;
    height: 18px;
}

.idm-hero-qr:hover {
    filter: brightness(1.08);
}

.idm-hero-qr:active {
    transform: scale(0.97);
}

/* Stift im Kopf (nur Icon): aktive Anweisung zum Bearbeiten in die Entwürfe holen */
.idm-hero-edit {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 38px;
    height: 38px;
    padding: 0;
    border: 1.5px solid var(--profile-border);
    border-radius: 11px;
    background: var(--profile-white);
    color: var(--profile-text);
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.idm-hero-edit svg {
    width: 18px;
    height: 18px;
}

.idm-hero-edit:hover {
    border-color: var(--accent-solid);
    color: var(--accent-solid);
    background: rgba(21, 144, 121, 0.06);
}

.idm-hero-edit:active {
    transform: scale(0.97);
}

@media (max-width: 640px) {
    .idm-hero-qr {
        width: 38px;
        padding: 0;
        justify-content: center;
    }

    .idm-hero-qr span {
        display: none;
    }
}

.idm-hero-ref {
    align-self: flex-start;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    color: var(--profile-text-muted);
}

.idm-hero-title {
    margin: 0;
    font-size: 24px;
    font-weight: 700;
    letter-spacing: -0.025em;
    line-height: 1.2;
    color: var(--profile-text);
    overflow-wrap: anywhere;
}

/* Versionen: kleine Pille neben dem Namen, Auswahl-Menü für ältere Stände */
.idm-hero {
    position: relative;
    z-index: 2;
}

.idm-hero-titlerow {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 10px;
    min-width: 0;
}

.idm-version-wrap {
    position: relative;
}

.idm-version {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    height: 24px;
    padding: 0 8px 0 10px;
    border: 1px solid var(--profile-border);
    border-radius: 999px;
    background: var(--profile-surface);
    color: var(--profile-text-muted);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.idm-version.is-static {
    padding: 0 10px;
    cursor: default;
}

.idm-version svg {
    width: 13px;
    height: 13px;
    transition: transform 0.15s ease;
}

button.idm-version:hover,
.idm-version-wrap.open .idm-version {
    border-color: var(--accent-solid);
    color: var(--accent-solid);
}

.idm-version-wrap.open .idm-version svg {
    transform: rotate(180deg);
}

.idm-version.is-old {
    border-color: rgba(217, 119, 6, 0.4);
    background: rgba(245, 158, 11, 0.12);
    color: #b45309;
}

.idm-version-menu {
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    z-index: 20;
    display: none;
    min-width: 230px;
    max-height: 320px;
    overflow-y: auto;
    padding: 6px;
    border: 1px solid var(--profile-border);
    border-radius: 12px;
    background: var(--profile-white);
    box-shadow: 0 14px 34px rgba(16, 24, 40, 0.18);
}

.idm-version-wrap.open .idm-version-menu {
    display: block;
}

.idm-version-list {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.idm-version-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    height: 38px;
    padding: 0 10px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--profile-text);
    font-family: inherit;
    font-size: 13.5px;
    text-align: left;
    cursor: pointer;
}

.idm-version-item b {
    font-weight: 600;
}

.idm-version-item:hover {
    background: var(--profile-surface);
}

.idm-version-item.is-active {
    background: rgba(21, 144, 121, 0.1);
    color: var(--accent-solid);
}

.idm-version-date {
    font-size: 12px;
    color: var(--profile-text-muted);
}

.idm-version-tag {
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(21, 144, 121, 0.14);
    color: var(--accent-solid);
    font-size: 11.5px;
    font-weight: 700;
}

.idm-version-empty {
    display: block;
    padding: 10px;
    font-size: 13px;
    color: var(--profile-text-muted);
}

.idm-version-row {
    display: flex;
    align-items: center;
    gap: 4px;
}

.idm-version-row .idm-version-item {
    flex: 1;
    min-width: 0;
}

/* Löschen alter Versionen: 1. Klick fragt nach, 2. Klick löscht */
.idm-version-del {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    flex-shrink: 0;
    min-width: 32px;
    height: 32px;
    padding: 0 8px;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--profile-text-muted);
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.idm-version-del svg {
    width: 15px;
    height: 15px;
}

.idm-version-del span {
    display: none;
}

.idm-version-del:hover {
    background: var(--profile-danger-bg);
    color: var(--profile-danger);
}

.idm-version-del.is-confirm {
    background: var(--profile-danger);
    color: #ffffff;
}

.idm-version-del.is-confirm span {
    display: inline;
}

/* Hinweisleiste beim Ansehen einer älteren Version */
.idm-version-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid rgba(217, 119, 6, 0.3);
    border-radius: 14px;
    background: rgba(245, 158, 11, 0.1);
}

.idm-version-bar-ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: rgba(217, 119, 6, 0.16);
    color: #b45309;
}

.idm-version-bar-ic svg {
    width: 17px;
    height: 17px;
}

.idm-version-bar-text {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: baseline;
    gap: 8px;
    font-size: 14px;
    color: var(--profile-text);
}

.idm-version-bar-text span {
    font-size: 12.5px;
    color: var(--profile-text-muted);
}

.idm-version-bar-btn {
    flex-shrink: 0;
    height: 32px;
    padding: 0 12px;
    border: 1px solid var(--profile-border);
    border-radius: 9px;
    background: var(--profile-white);
    color: var(--profile-text);
    font-family: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, filter 0.15s ease;
}

.idm-version-bar-btn:hover {
    background: var(--profile-hover-bg);
    border-color: var(--profile-hover-border);
}

body.dark .idm-version.is-old,
body.dark .idm-version-bar-ic {
    color: #fbbf24;
}

body.dark .idm-version-menu {
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}

@media (max-width: 640px) {
    .idm-version-bar {
        flex-wrap: wrap;
    }

    .idm-version-bar-text {
        flex-basis: calc(100% - 46px);
    }
}

.idm-hero-meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin-top: 2px;
}

.idm-hero-date {
    font-size: 12.5px;
    color: var(--profile-text-muted);
}

/* ---- Inhalt ---- */
.idm-body {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    padding: 18px;
    background: var(--profile-surface);
}

/* Schlanke Scrollbar passend zum Seitenstil (gleiches Muster wie in den Einstellungen) */
.idm-body::-webkit-scrollbar,
.idm-text::-webkit-scrollbar,
.idm-rte::-webkit-scrollbar {
    width: 10px;
}

.idm-body::-webkit-scrollbar-track,
.idm-text::-webkit-scrollbar-track,
.idm-rte::-webkit-scrollbar-track {
    background: transparent;
    margin: 10px 0;
}

.idm-body::-webkit-scrollbar-button,
.idm-text::-webkit-scrollbar-button,
.idm-rte::-webkit-scrollbar-button {
    display: none;
}

.idm-body::-webkit-scrollbar-thumb,
.idm-text::-webkit-scrollbar-thumb,
.idm-rte::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.16);
    border-radius: 999px;
    border: 3px solid transparent;
    background-clip: padding-box;
}

.idm-body::-webkit-scrollbar-thumb:hover,
.idm-text::-webkit-scrollbar-thumb:hover,
.idm-rte::-webkit-scrollbar-thumb:hover {
    background: rgba(21, 144, 121, 0.55);
    background-clip: padding-box;
}

body.dark .idm-body::-webkit-scrollbar-thumb,
body.dark .idm-text::-webkit-scrollbar-thumb,
body.dark .idm-rte::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.14);
    background-clip: padding-box;
}

body.dark .idm-body::-webkit-scrollbar-thumb:hover,
body.dark .idm-text::-webkit-scrollbar-thumb:hover,
body.dark .idm-rte::-webkit-scrollbar-thumb:hover {
    background: rgba(21, 144, 121, 0.7);
    background-clip: padding-box;
}

/* Firefox kennt keine ::-webkit-scrollbar-Regeln */
@supports not selector(::-webkit-scrollbar) {
    .idm-body,
    .idm-text,
    .idm-rte {
        scrollbar-width: thin;
        scrollbar-color: rgba(0, 0, 0, 0.18) transparent;
    }

    body.dark .idm-body,
    body.dark .idm-text,
    body.dark .idm-rte {
        scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
    }
}

.idm-muted {
    margin: 0;
    padding: 14px;
    border: 1.5px dashed var(--profile-border);
    border-radius: 14px;
    font-size: 13.5px;
    line-height: 1.5;
    text-align: center;
    color: var(--profile-text-muted);
}

/* Jeder Abschnitt ist eine eigene Karte – klare optische Trennung für
   schnelles Erfassen auf dem Handy (z. B. durch Monteure auf der Baustelle). */
.idm-section {
    display: flex;
    flex-direction: column;
    gap: 14px;
    padding: 16px;
    border: 1px solid var(--profile-border);
    border-radius: 16px;
    background: var(--profile-white);
}

.idm-section-head {
    display: flex;
    align-items: center;
    gap: 12px;
}

.idm-section-title {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.idm-section-head h3 {
    margin: 0;
    font-size: 15px;
    font-weight: 700;
    letter-spacing: -0.01em;
    color: var(--profile-text);
}

.idm-section-sub {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.4;
    color: var(--profile-text-muted);
}

.idm-section-ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 12px;
    background: var(--idm-accent-soft);
    color: var(--accent-solid);
}

.idm-section-ic svg {
    width: 18px;
    height: 18px;
}

.idm-section-count {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 26px;
    height: 24px;
    margin-left: auto;
    padding: 0 8px;
    box-sizing: border-box;
    border-radius: 999px;
    background: var(--profile-surface);
    color: var(--profile-text-muted);
    font-size: 12px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.idm-hint {
    margin-left: auto;
    font-size: 12px;
    color: var(--profile-text-muted);
}

/* Werkzeug & Material */
.idm-tools {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.idm-tool {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 8px 9px 12px;
    border: 1px solid var(--profile-border);
    border-radius: 12px;
    background: var(--profile-input-bg);
}

.idm-tool-check {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border-radius: 50%;
    background: var(--idm-accent-soft);
    color: var(--accent-solid);
}

.idm-tool-check svg {
    width: 11px;
    height: 11px;
}

.idm-tool-name {
    flex: 1;
    min-width: 0;
    font-size: 14px;
    color: var(--profile-text);
    overflow-wrap: anywhere;
}

.idm-tool-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--profile-text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.idm-tool-remove svg {
    width: 14px;
    height: 14px;
}

.idm-tool-remove:hover {
    background: var(--profile-danger-bg);
    color: var(--profile-danger);
}

/* Eingabe + runder Plus-Button in einem gemeinsamen Feld */
.idm-add {
    display: flex;
    align-items: center;
    gap: 6px;
    height: 48px;
    padding: 0 5px 0 4px;
    box-sizing: border-box;
    border: 1.5px solid var(--profile-border);
    border-radius: 14px;
    background: var(--profile-input-bg);
    transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.idm-add:focus-within {
    border-color: var(--accent-solid);
    box-shadow: 0 0 0 4px var(--profile-focus-ring);
}

.idm-add input {
    flex: 1;
    min-width: 0;
    height: 100%;
    padding: 0 10px;
    box-sizing: border-box;
    border: none;
    background: transparent;
    color: var(--profile-text);
    font-size: 14px;
    outline: none;
}

.idm-add input::placeholder {
    color: var(--profile-placeholder);
}

.idm-add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    flex-shrink: 0;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: var(--accent-gradient);
    color: #ffffff;
    cursor: pointer;
    box-shadow: 0 4px 12px var(--accent-shadow);
    transition: filter 0.15s ease, transform 0.1s ease;
}

.idm-add-btn:hover {
    filter: brightness(1.08);
}

.idm-add-btn:active {
    transform: scale(0.95);
}

.idm-add-btn svg {
    width: 18px;
    height: 18px;
}

/* Schutzausrüstung – kompakte Chips statt großem Kachel-Raster:
   nur tatsächlich hinzugefügte Einträge werden als kleine Icon+Label-Badges
   angezeigt, damit die Übersicht nicht unnötig Platz verschwendet. */
.idm-ppe-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    list-style: none;
    margin: 0;
    padding: 0;
}

.idm-ppe-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 8px 6px 10px;
    border: 1.5px solid var(--profile-border);
    border-radius: 999px;
    background: var(--profile-input-bg);
}

.idm-ppe-chip-ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    color: var(--accent-solid);
}

.idm-ppe-chip-ic svg {
    width: 14px;
    height: 14px;
}

.idm-ppe-chip-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--profile-text);
    white-space: nowrap;
}

.idm-ppe-chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: var(--profile-text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.idm-ppe-chip-remove svg {
    width: 12px;
    height: 12px;
}

.idm-ppe-chip-remove:hover {
    background: var(--profile-surface);
    color: var(--profile-text);
}

/* Kurzer Hinweistext statt großer gestrichelter Box, wenn noch nichts
   hinterlegt ist – spart Platz im Vergleich zu .idm-muted. */
.idm-muted-inline {
    margin: 0;
    font-size: 13px;
    color: var(--profile-text-muted);
}

/* Unauffälliger Auslöser-Button, der erst beim Klick das Eingabefeld öffnet,
   statt immer ein volles Formular anzuzeigen. */
.idm-add-toggle {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    align-self: flex-start;
    height: 36px;
    padding: 0 12px;
    border: 1.5px dashed var(--profile-border);
    border-radius: 999px;
    background: transparent;
    color: var(--profile-text-muted);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease;
}

.idm-add-toggle:hover {
    border-color: var(--accent-solid);
    color: var(--accent-solid);
}

.idm-add-toggle svg {
    width: 14px;
    height: 14px;
}

/* Schritt-Liste */
.idm-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin: 0;
    padding: 0;
    list-style: none;
}

.idm-step-row {
    display: flex;
    align-items: center;
    gap: 14px;
    width: 100%;
    padding: 8px 12px 8px 8px;
    border: 1px solid var(--profile-border);
    border-radius: 16px;
    background: var(--profile-input-bg);
    color: var(--profile-text);
    text-align: left;
    cursor: pointer;
    transition: background 0.15s ease, border-color 0.15s ease, transform 0.15s ease, box-shadow 0.15s ease;
}

.idm-step-row:hover {
    background: var(--profile-hover-bg);
    border-color: var(--profile-hover-border);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.idm-step-row:active {
    transform: scale(0.99);
}

.idm-step-thumb {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    flex-shrink: 0;
    overflow: hidden;
    border-radius: 12px;
    background: var(--profile-surface);
    color: var(--profile-placeholder);
}

.idm-step-thumb svg {
    width: 22px;
    height: 22px;
}

.idm-step-thumb img,
.idm-step-thumb video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.idm-step-num {
    position: absolute;
    top: 4px;
    left: 4px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 5px;
    box-sizing: border-box;
    border-radius: 999px;
    background: var(--accent-gradient);
    color: #ffffff;
    font-size: 11px;
    font-weight: 800;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
}

.idm-step-body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.idm-step-label {
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--accent-solid);
}

.idm-step-text {
    font-size: 14px;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.idm-step-text em {
    font-style: normal;
    color: var(--profile-text-muted);
}

.idm-step-chev {
    display: inline-flex;
    color: var(--profile-text-muted);
}

.idm-step-chev svg {
    width: 18px;
    height: 18px;
}

/* ---- Fuß ---- */
.idm-foot {
    padding: 16px 22px calc(16px + env(safe-area-inset-bottom));
    border-top: 1px solid var(--profile-border);
    background: var(--profile-white);
}

.idm-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    height: 54px;
    border: none;
    border-radius: 16px;
    background: var(--accent-gradient);
    color: #ffffff;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    box-shadow: 0 10px 26px var(--accent-shadow);
    transition: filter 0.15s ease, transform 0.1s ease;
}

.idm-cta:hover {
    filter: brightness(1.07);
}

/* Übersicht: Fuß geht nahtlos in den Inhalt über */
.idm.is-overview .idm-foot {
    border-top: none;
    background: var(--profile-surface);
    box-shadow: 0 -12px 24px -12px rgba(0, 0, 0, 0.18);
}

.idm-cta:active {
    transform: scale(0.99);
}

.idm-cta svg {
    width: 19px;
    height: 19px;
}

/* Entwurf: zwei Aktionen nebeneinander (Schritte / Freigabe) */
.idm-foot-split {
    display: flex;
    gap: 10px;
}

.idm-foot-split .idm-cta {
    flex: 1 1 0;
    min-width: 0;
    padding: 0 14px;
}

.idm-foot-split .idm-cta span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Heller Modus: "Montage starten" im Entwurf leicht grün getönt, damit er nicht untergeht */
.idm-cta.is-ghost {
    background: rgba(21, 144, 121, 0.1);
    color: var(--accent-solid);
    border: 1.5px solid rgba(21, 144, 121, 0.55);
    box-shadow: none;
}

.idm-cta.is-ghost:hover {
    filter: none;
    background: rgba(21, 144, 121, 0.14);
    border-color: var(--accent-solid);
}

body.dark .idm-cta.is-ghost {
    background: var(--profile-white);
    color: var(--profile-text);
    border: 1px solid var(--profile-border);
}

body.dark .idm-cta.is-ghost:hover {
    background: var(--profile-hover-bg);
    border-color: var(--profile-hover-border);
}

.idm-cta:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    filter: none;
    box-shadow: none;
}

/* Mobil: beide Beschriftungen sichtbar, "Montage starten" bekommt etwas mehr Platz */
@media (max-width: 640px) {
    .idm-foot-split {
        gap: 8px;
    }

    .idm-foot-split .idm-cta {
        gap: 8px;
        padding: 0 12px;
        font-size: 15px;
    }

    .idm-foot-split .idm-cta.is-ghost {
        flex: 1.15 1 0;
    }

    .idm-foot-split .idm-cta svg {
        width: 17px;
        height: 17px;
        flex-shrink: 0;
    }
}

.idm-foot-nav {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.idm-nav-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 50px;
    padding: 0 20px;
    border: none;
    border-radius: 14px;
    font-size: 15px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s ease, background 0.15s ease, transform 0.1s ease;
}

.idm-nav-btn svg {
    width: 18px;
    height: 18px;
}

.idm-nav-btn:active {
    transform: scale(0.98);
}

.idm-nav-btn.is-back {
    background: var(--profile-surface);
    color: var(--profile-text);
}

.idm-nav-btn.is-back:hover {
    background: var(--profile-border);
}

.idm-nav-btn.is-next {
    min-width: 210px;
    background: var(--accent-gradient);
    color: #ffffff;
    box-shadow: 0 8px 22px var(--accent-shadow);
}

.idm-nav-btn.is-next:hover {
    filter: brightness(1.07);
}

/* ---- Editor: Medien ---- */
.idm-drop {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-height: 300px;
    box-sizing: border-box;
    padding: 40px 20px;
    border: 2px dashed var(--profile-border);
    border-radius: 18px;
    background: var(--profile-input-bg);
    text-align: center;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.idm-media.is-drag .idm-drop,
.idm-media.is-drag .idm-frame,
.idm-media.is-drag .idm-media-grid {
    border-color: var(--accent-solid);
    background: var(--idm-accent-soft);
}

.idm-media-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
    gap: 10px;
    padding: 2px;
    border: 2px dashed transparent;
    border-radius: 18px;
    transition: border-color 0.15s ease, background 0.15s ease;
}

.idm-drop-ic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 58px;
    height: 58px;
    margin-bottom: 4px;
    border-radius: 18px;
    background: var(--idm-accent-soft);
    color: var(--accent-solid);
}

.idm-drop-ic svg {
    width: 26px;
    height: 26px;
}

.idm-drop-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--profile-text);
}

.idm-drop .idm-muted {
    max-width: 340px;
}

.idm-drop-actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
}

.idm-media-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    height: 44px;
    padding: 0 18px;
    border: 1.5px solid var(--profile-border);
    border-radius: 12px;
    background: var(--profile-white);
    color: var(--profile-text);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, filter 0.15s ease;
}

.idm-media-btn:hover {
    border-color: var(--profile-hover-border);
}

.idm-media-btn svg {
    width: 18px;
    height: 18px;
}

.idm-media-btn.is-primary {
    border-color: transparent;
    background: var(--accent-gradient);
    color: #ffffff;
    box-shadow: 0 6px 16px var(--accent-shadow);
}

.idm-media-btn.is-primary:hover {
    filter: brightness(1.07);
}

.idm-frame {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 12px;
    border: 2px dashed var(--profile-border);
    border-radius: 18px;
    background: var(--profile-input-bg);
    transition: border-color 0.15s ease, background 0.15s ease;
}

.idm-shot {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 280px;
    overflow: hidden;
    border-radius: 14px;
    background: #000000;
}

.idm-shot img,
.idm-shot video {
    display: block;
    width: 100%;
    height: auto;
    max-height: 62vh;
    object-fit: contain;
}

.idm-shot.is-uploading img,
.idm-shot.is-uploading video {
    opacity: 0.45;
}

.idm-shot .idm-tile-remove {
    top: 10px;
    right: 10px;
    width: 34px;
    height: 34px;
}

.idm-frame-actions {
    display: flex;
    justify-content: center;
    gap: 10px;
}

/* Bildbereich: feste Höhe (per JS aus freiem Platz), Text darunter scrollt */
.idm.is-editor .idm-media {
    flex: 0 0 auto;
    display: flex;
    flex-direction: column;
    height: var(--idm-media-h, 360px);
}

.idm.is-editor .idm-drop,
.idm.is-editor .idm-frame {
    flex: 1;
}

.idm.is-editor .idm-shot {
    flex: 1;
    border-radius: 18px;
}

.idm.is-editor .idm-frame {
    padding: 0;
    border: none;
    background: transparent;
}

.idm.is-editor .idm-shot img,
.idm.is-editor .idm-shot video {
    position: absolute;
    inset: 0;
    height: 100%;
    max-height: none;
    object-fit: cover;
}

.idm.is-editor .idm-text {
    margin-top: 0;
}

/* Dark Mode: Editor-Fläche so dunkel wie Kopf- und Fußleiste */
body.dark .idm.is-editor .idm-body {
    background: var(--profile-white);
}

/* PC: Bild links, Text rechts, Bild unbeschnitten */
@media (min-width: 641px) {
    .idm.is-editor {
        max-width: 1120px;
    }

    .idm.is-editor .idm-body {
        display: grid;
        grid-template-columns: minmax(0, 2fr) minmax(0, 1fr);
        grid-template-rows: minmax(0, 1fr);
        gap: 20px;
        overflow: hidden;
    }

    .idm.is-editor .idm-media {
        height: auto;
        min-height: 0;
    }

    .idm.is-editor .idm-shot img,
    .idm.is-editor .idm-shot video {
        object-fit: contain;
    }

    .idm.is-editor .idm-text {
        min-height: 0;
        overflow: hidden;
    }

    .idm.is-editor .idm-text-box {
        flex: 1;
        min-height: 0;
    }

    .idm.is-editor .idm-text .idm-rte {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
    }
}

/* Zoom im Bild */
.idm-shot-bg {
    display: none;
}

.idm.is-editor .idm-shot img.idm-shot-bg {
    display: block;
    inset: -40px;
    width: calc(100% + 80px);
    height: calc(100% + 80px);
    object-fit: cover;
    filter: blur(32px) brightness(0.6) saturate(1.2);
    pointer-events: none;
}

.idm-zoom {
    position: absolute;
    inset: 0;
    overflow: hidden;
    touch-action: pan-y;
}

.idm-zoom img {
    transform-origin: center;
    transition: transform 0.2s ease;
    user-select: none;
}

.idm-zoom.is-zoomed {
    touch-action: none;
    cursor: grab;
}

.idm-zoom.is-gesture img {
    transition: none;
}

.idm-zoom.is-gesture {
    cursor: grabbing;
}

.idm-zoom-ctrl {
    position: absolute;
    right: 10px;
    bottom: 10px;
    display: flex;
    gap: 2px;
    padding: 3px;
    border-radius: 12px;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(6px);
}

.idm-zoom-ctrl button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 9px;
    background: transparent;
    color: #ffffff;
    cursor: pointer;
    transition: background 0.15s ease;
}

.idm-zoom-ctrl button:hover {
    background: rgba(255, 255, 255, 0.15);
}

.idm-zoom-ctrl svg {
    width: 16px;
    height: 16px;
}

/* Touch: Zoom per Fingergeste statt Buttons */
@media (max-width: 640px), (pointer: coarse) {
    .idm-zoom-ctrl {
        display: none;
    }
}

.idm-frame-actions .idm-media-btn {
    flex: 1;
    justify-content: center;
    max-width: 200px;
}

.idm-tile {
    position: relative;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 14px;
    background: var(--profile-surface);
}

.idm-tile img,
.idm-tile video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.idm-tile.is-uploading img,
.idm-tile.is-uploading video {
    opacity: 0.45;
}

.idm-tile-remove {
    position: absolute;
    top: 6px;
    right: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.55);
    color: #ffffff;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: background 0.15s ease;
}

.idm-tile-remove:hover {
    background: rgba(220, 38, 38, 0.9);
}

.idm-tile-remove svg {
    width: 14px;
    height: 14px;
}

.idm-tile-badge {
    position: absolute;
    left: 6px;
    bottom: 6px;
    display: inline-flex;
    padding: 4px 6px;
    border-radius: 7px;
    background: rgba(0, 0, 0, 0.55);
    color: #ffffff;
}

.idm-tile-badge svg {
    width: 14px;
    height: 14px;
}

.idm-tile-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 26px;
    height: 26px;
    margin: -13px 0 0 -13px;
    border: 3px solid rgba(255, 255, 255, 0.45);
    border-top-color: #ffffff;
    border-radius: 50%;
    animation: idmSpin 0.8s linear infinite;
}

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

.idm-tile-add {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    aspect-ratio: 4 / 3;
    border: 2px dashed var(--profile-border);
    border-radius: 14px;
    color: var(--profile-text-muted);
    font-size: 12.5px;
    font-weight: 600;
    cursor: pointer;
    transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.idm-tile-add svg {
    width: 22px;
    height: 22px;
}

.idm-tile-add:hover {
    border-color: var(--accent-solid);
    background: var(--idm-accent-soft);
    color: var(--accent-solid);
}

/* ---- Editor: Text + Diktat ---- */
.idm-text {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 10px;
}

.idm-text-box {
    position: relative;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    border: 1.5px solid var(--profile-border);
    border-radius: 14px;
    background: var(--profile-input-bg);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease;
}

.idm-text-box:focus-within {
    border-color: var(--accent-solid);
    background: var(--profile-white);
    box-shadow: 0 0 0 4px var(--profile-focus-ring);
}

.idm-text .idm-text-box .idm-rte {
    flex: 0 0 auto;
}

.idm-text-tools {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: flex-end;
    gap: 10px;
    padding: 4px 10px 10px 14px;
}

.idm-text-count {
    font-size: 11.5px;
    font-weight: 600;
    color: var(--profile-text-muted);
    font-variant-numeric: tabular-nums;
}

.idm-text-count.is-full {
    color: var(--profile-danger);
}

.idm-text-tools.is-recording .idm-text-count {
    display: none;
}

.idm-wave {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 12px;
    height: 34px;
    padding: 0 14px;
    box-sizing: border-box;
    border: 1px solid rgba(21, 144, 121, 0.22);
    border-radius: 999px;
    background: linear-gradient(90deg, rgba(21, 144, 121, 0.04), rgba(21, 144, 121, 0.14));
}

.idm-wave[hidden] {
    display: none;
}

.idm-wave-time {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
    font-size: 12px;
    font-weight: 700;
    color: var(--accent-solid);
    font-variant-numeric: tabular-nums;
}

.idm-wave-time::before {
    content: '';
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #dc2626;
    animation: idmRecBlink 1.2s ease-in-out infinite;
}

@keyframes idmRecBlink {
    50% { opacity: 0.25; }
}

.idm-wave-bars {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 2px;
    height: 22px;
    overflow: hidden;
    direction: rtl; /* neuester Balken rechts, bei Platzmangel werden die ältesten abgeschnitten */
    -webkit-mask-image: linear-gradient(90deg, transparent, #000 30%);
    mask-image: linear-gradient(90deg, transparent, #000 30%);
}

.idm-wave-bars i {
    display: block;
    flex: 0 1 3px;
    min-width: 2px;
    height: 12%;
    border-radius: 999px;
    background: linear-gradient(180deg, #2fc4a6, var(--accent-solid));
    transition: height 0.07s linear;
}

.idm-mic {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: var(--idm-accent-soft);
    color: var(--accent-solid);
    cursor: pointer;
    pointer-events: auto;
    transition: background 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.idm-mic svg {
    width: 17px;
    height: 17px;
}

.idm-mic:hover {
    background: var(--accent-solid);
    color: #ffffff;
}

.idm-mic:active {
    transform: scale(0.94);
}

.idm-mic.is-recording {
    border-color: transparent;
    background: #dc2626;
    color: #ffffff;
    animation: idmMicPulse 1.6s ease-in-out infinite;
}

@keyframes idmMicPulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(220, 38, 38, 0.45); }
    50% { box-shadow: 0 0 0 8px rgba(220, 38, 38, 0); }
}

.idm-mic.is-busy,
.idm-mic:disabled {
    cursor: progress;
    opacity: 0.6;
    background: var(--idm-accent-soft);
    color: var(--accent-solid);
}

.idm-rte {
    position: relative;
    min-height: 120px;
    padding: 14px 16px 6px;
    box-sizing: border-box;
    color: var(--profile-text);
    font-size: 15px;
    line-height: 1.6;
    outline: none;
    white-space: pre-wrap;
    overflow-wrap: anywhere;
    cursor: text;
}

.idm-rte.is-empty::before {
    content: attr(data-placeholder);
    position: absolute;
    top: 14px;
    left: 16px;
    right: 16px;
    color: var(--profile-placeholder);
    pointer-events: none;
}

.idm-rte strong,
.idm-rte b {
    font-weight: 700;
}

.idm-rte ul,
.idm-rte ol {
    margin: 4px 0;
    padding-left: 24px;
    white-space: normal;
}

.idm-rte li {
    margin: 2px 0;
    padding-left: 2px;
    white-space: pre-wrap;
}

.idm-rte li::marker {
    color: var(--accent-solid);
    font-weight: 700;
}

/* Nummerierung läuft über alle nummerierten Listen eines Schritts weiter (1., 2., 3. …) */
.idm-rte {
    counter-reset: idm-step;
}

.idm-rte ol {
    list-style: none;
}

.idm-rte ol > li {
    position: relative;
    counter-increment: idm-step;
}

.idm-rte ol > li::before {
    content: counter(idm-step) ".";
    position: absolute;
    right: 100%;
    margin-right: 6px;
    white-space: nowrap;
    color: var(--accent-solid);
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

/* Formatierungsleiste unten links im Feld */
.idm-rte-bar {
    display: flex;
    align-items: center;
    gap: 2px;
    margin-right: auto;
}

.idm-text-tools.is-recording .idm-rte-bar,
.idm-text-tools.has-status .idm-rte-bar {
    display: none;
}

.idm-rte-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: transparent;
    color: var(--profile-text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.idm-rte-btn svg {
    width: 16px;
    height: 16px;
}

.idm-rte-btn:hover {
    background: var(--idm-accent-soft);
    color: var(--profile-text);
}

.idm-rte-btn.is-active {
    background: var(--idm-accent-soft);
    color: var(--accent-solid);
}

.idm-rte-sep {
    width: 1px;
    height: 18px;
    margin: 0 5px;
    background: var(--profile-border);
}

@media (max-width: 380px) {
    .idm-rte-btn {
        width: 28px;
    }
}

.idm-mic-status {
    flex: 1;
    min-width: 0;
    display: flex;
    align-items: center;
    gap: 9px;
    height: 34px;
    margin: 0;
    padding: 0 14px;
    box-sizing: border-box;
    border: 1px solid rgba(220, 38, 38, 0.22);
    border-radius: 999px;
    background: rgba(220, 38, 38, 0.08);
    font-size: 12.5px;
    font-weight: 600;
    color: #dc2626;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.idm-text-tools.has-status .idm-text-count {
    display: none;
}

.idm-mic-status[hidden] {
    display: none;
}

.idm-mic-dot {
    flex-shrink: 0;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #dc2626;
    animation: idmMicPulse 1.6s ease-in-out infinite;
}

.idm-mic-status.is-busy {
    border-color: rgba(21, 144, 121, 0.22);
    background: linear-gradient(90deg, rgba(21, 144, 121, 0.04), rgba(21, 144, 121, 0.14));
    color: var(--accent-solid);
}

.idm-mic-status.is-busy .idm-mic-dot {
    width: 10px;
    height: 10px;
    box-sizing: border-box;
    border: 2px solid rgba(21, 144, 121, 0.25);
    border-top-color: var(--accent-solid);
    background: transparent;
    animation: idmMicSpin 0.8s linear infinite;
}

.idm-mic-status.is-error .idm-mic-dot {
    animation: none;
}

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

/* ---- Mobil: Vollbild unterhalb der App-Kopfleiste ---- */
@media (max-width: 640px) {
    .idm-overlay {
        top: 64px;
        z-index: 9; /* unter Topbar (10), damit Header + Profil-Menü sichtbar bleiben */
        padding: 0;
    }

    body.idm-open .page-action-btn {
        display: none;
    }

    .idm,
    .idm.is-editor {
        max-width: none;
        height: 100%;
        max-height: none;
        border-radius: 0;
        animation: none;
    }

    .idm-head {
        padding: 16px 16px 14px;
        gap: 12px;
    }

    .idm-head-icon {
        display: none;
    }

    .idm-title {
        font-size: 19px;
    }

    .idm-hero {
        padding: 18px 16px 16px;
    }

    .idm-hero-title {
        font-size: 21px;
    }

    .idm-body {
        padding: 14px;
        gap: 12px;
    }

    .idm-section {
        padding: 14px;
        border-radius: 16px;
    }

    .idm-hint {
        display: none;
    }

    .idm-media-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .idm-foot {
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
    }

    .idm-nav-btn {
        flex: 1;
        padding: 0 14px;
    }

    .idm-nav-btn.is-back {
        flex: 0 0 auto;
    }

    .idm-nav-btn.is-next {
        min-width: 0;
    }

    .idm-done-btn span {
        display: none;
    }

    .idm-done-btn {
        width: 38px;
        padding: 0;
        justify-content: center;
    }
}

/* Kamera-Fenster (Mobile) */
.idm-camwin {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    background: var(--profile-white);
    animation: authPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.idm-camwin-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--profile-border);
}

.idm-camwin-head h3 {
    margin: 0;
    font-size: 17px;
    font-weight: 700;
    color: var(--profile-text);
}

.idm-camwin-view {
    position: relative;
    flex: 1;
    min-height: 0;
    margin: 16px 16px 0;
    overflow: hidden;
    border-radius: 20px;
    background: #000000;
}

.idm-camwin-view video {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.idm-camwin-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.75);
    font-size: 14px;
}

.idm-camwin.is-live .idm-camwin-loading {
    display: none;
}

.idm-camwin-foot {
    display: flex;
    justify-content: center;
    padding: 18px 16px calc(18px + env(safe-area-inset-bottom));
}

.idm-shutter {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 74px;
    height: 74px;
    padding: 0;
    border: 4px solid var(--accent-solid);
    border-radius: 50%;
    background: transparent;
    cursor: pointer;
}

.idm-shutter:disabled {
    opacity: 0.4;
    cursor: default;
}

.idm-shutter span {
    width: 58px;
    height: 58px;
    border-radius: 50%;
    background: var(--accent-solid);
    transition: transform 0.1s ease;
}

.idm-shutter:not(:disabled):active span {
    transform: scale(0.88);
}

/* Bild markieren: Button im Foto */
.idm-shot-mark {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 34px;
    padding: 0 13px 0 11px;
    border: none;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.55);
    color: #ffffff;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(6px);
    transition: background 0.15s ease;
}

.idm-shot-mark:hover {
    background: var(--accent-solid);
}

.idm-shot-mark svg {
    width: 16px;
    height: 16px;
}

@media (max-width: 640px) {
    .idm-shot-mark span {
        display: none;
    }

    .idm-shot-mark {
        width: 34px;
        padding: 0;
        justify-content: center;
    }
}

.idm-shot-tools {
    position: absolute;
    top: 10px;
    left: 10px;
    z-index: 2;
    display: flex;
    gap: 6px;
}

.idm-shot-tools .idm-shot-mark {
    position: static;
    width: 34px;
    padding: 0;
    justify-content: center;
}

.idm-shot-tools .idm-shot-mark span {
    display: none;
}

/* Bild zuschneiden */
.idm-crop-wrap {
    position: relative;
    touch-action: none;
    user-select: none;
}

.idm-crop-canvas {
    display: block;
    width: 100%;
    height: 100%;
}

.idm-crop-box {
    position: absolute;
    cursor: move;
    border: 2px solid #ffffff;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.55);
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.35)),
        linear-gradient(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.35)),
        linear-gradient(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.35)),
        linear-gradient(rgba(255, 255, 255, 0.35), rgba(255, 255, 255, 0.35));
    background-size: 1px 100%, 1px 100%, 100% 1px, 100% 1px;
    background-position: 33.33% 0, 66.66% 0, 0 33.33%, 0 66.66%;
    background-repeat: no-repeat;
    opacity: 1;
}

.idm-crop:not(.is-dragging) .idm-crop-box {
    background-size: 0 0;
}

.idm-crop-box i {
    position: absolute;
    width: 28px;
    height: 28px;
}

.idm-crop-box i::after {
    content: "";
    position: absolute;
    width: 18px;
    height: 18px;
    border: 0 solid #ffffff;
}

.idm-crop-box i[data-h="nw"] { top: -14px; left: -14px; cursor: nwse-resize; }
.idm-crop-box i[data-h="ne"] { top: -14px; right: -14px; cursor: nesw-resize; }
.idm-crop-box i[data-h="sw"] { bottom: -14px; left: -14px; cursor: nesw-resize; }
.idm-crop-box i[data-h="se"] { bottom: -14px; right: -14px; cursor: nwse-resize; }

.idm-crop-box i[data-h="nw"]::after { top: 10px; left: 10px; border-top-width: 4px; border-left-width: 4px; }
.idm-crop-box i[data-h="ne"]::after { top: 10px; right: 10px; border-top-width: 4px; border-right-width: 4px; }
.idm-crop-box i[data-h="sw"]::after { bottom: 10px; left: 10px; border-bottom-width: 4px; border-left-width: 4px; }
.idm-crop-box i[data-h="se"]::after { bottom: 10px; right: 10px; border-bottom-width: 4px; border-right-width: 4px; }

.idm-crop-reset {
    position: absolute;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    height: 34px;
    padding: 0 16px;
    border: none;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    font: inherit;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    backdrop-filter: blur(6px);
}

.idm-crop-reset[hidden],
.idm-crop:not(.is-ready) .idm-crop-reset {
    display: none;
}

.idm-crop-reset:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Bild markieren: Fenster */
.idm-annot {
    position: absolute;
    inset: 0;
    z-index: 6;
    display: flex;
    flex-direction: column;
    background: var(--profile-white);
    animation: authPop 0.22s cubic-bezier(0.16, 1, 0.3, 1);
}

.idm-annot-head {
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    border-bottom: 1px solid var(--profile-border);
}

.idm-annot-head h3 {
    margin: 0;
    text-align: center;
    font-size: 16px;
    font-weight: 700;
    color: var(--profile-text);
}

.idm-annot-save {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    height: 38px;
    padding: 0 16px;
    border: none;
    border-radius: 11px;
    background: var(--accent-solid);
    color: #ffffff;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: filter 0.15s ease;
}

.idm-annot-save:hover:not(:disabled) {
    filter: brightness(1.08);
}

.idm-annot-save:disabled {
    opacity: 0.6;
    cursor: default;
}

.idm-annot-save svg {
    width: 16px;
    height: 16px;
}

.idm-annot-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin: 14px auto 0;
    padding: 5px;
    max-width: calc(100% - 32px);
    overflow-x: auto;
    border: 1px solid var(--profile-border);
    border-radius: 14px;
    background: var(--profile-surface);
    scrollbar-width: none;
}

.idm-annot-bar::-webkit-scrollbar {
    display: none;
}

.idm-annot-group {
    display: flex;
    align-items: center;
    gap: 2px;
    flex-shrink: 0;
}

.idm-annot-group.is-colors {
    gap: 6px;
    padding: 0 4px;
}

.idm-annot-sep {
    flex-shrink: 0;
    width: 1px;
    height: 22px;
    background: var(--profile-border);
}

.idm-annot-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 38px;
    height: 38px;
    padding: 0;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: var(--profile-text-muted);
    cursor: pointer;
    transition: background 0.15s ease, color 0.15s ease;
}

.idm-annot-btn:hover:not(:disabled) {
    background: var(--profile-white);
    color: var(--profile-text);
}

.idm-annot-btn[aria-pressed="true"] {
    background: var(--idm-accent-soft);
    color: var(--accent-solid);
}

.idm-annot-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.idm-annot-btn svg {
    width: 19px;
    height: 19px;
}

.idm-annot-swatch {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 2px solid rgba(0, 0, 0, 0.12);
    border-radius: 50%;
    background: var(--sw);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.idm-annot-swatch:hover {
    transform: scale(1.1);
}

.idm-annot-swatch[aria-pressed="true"] {
    box-shadow: 0 0 0 2px var(--profile-surface), 0 0 0 4px var(--sw);
}

body.dark .idm-annot-swatch {
    border-color: rgba(255, 255, 255, 0.15);
}

.idm-annot-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 14px 16px 16px;
    overflow: hidden;
    border-radius: 18px;
    background: #0b0b0d;
}

.idm-annot-canvas {
    display: block;
    touch-action: none;
    cursor: crosshair;
}

.idm-annot-loading {
    position: absolute;
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
}

.idm-annot.is-ready .idm-annot-loading {
    display: none;
}

.idm-annot-hint {
    position: absolute;
    left: 50%;
    bottom: 14px;
    transform: translateX(-50%);
    padding: 7px 13px;
    border-radius: 999px;
    background: rgba(0, 0, 0, 0.6);
    color: #ffffff;
    font-size: 12.5px;
    font-weight: 500;
    white-space: nowrap;
    pointer-events: none;
    backdrop-filter: blur(6px);
    transition: opacity 0.2s ease;
}

.idm-annot:not(.is-ready) .idm-annot-hint,
.idm-annot-hint.is-hidden {
    opacity: 0;
}

.idm-annot-input {
    position: absolute;
    transform: translateY(-50%);
    min-width: 160px;
    max-width: 60%;
    height: 34px;
    padding: 0 12px;
    border: 2px solid rgba(255, 255, 255, 0.85);
    border-radius: 10px;
    background: var(--ann);
    font: inherit;
    font-size: 14px;
    font-weight: 700;
    outline: none;
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
}

.idm-annot-input::placeholder {
    color: inherit;
    opacity: 0.65;
}

@media (max-width: 640px) {
    .idm-annot-head {
        padding: 10px 12px;
    }

    .idm-annot-save span {
        display: none;
    }

    .idm-annot-save {
        width: 40px;
        padding: 0;
        justify-content: center;
    }

    .idm-annot-bar {
        justify-content: flex-start;
        gap: 6px;
        margin-top: 10px;
    }

    .idm-annot-btn {
        width: 36px;
        height: 36px;
    }

    .idm-annot-stage {
        margin: 10px 10px 12px;
        border-radius: 14px;
    }
}

/* Mobile: Suche + Sortierung als kleine Icons neben den Unterseiten */
.instr-extra {
    display: flex;
    align-items: center;
    gap: 6px;
}

.instr-search-toggle {
    display: none;
}

@media (max-width: 820px) {
    .instr-search-toggle,
    .instr-extra .instr-sort-btn {
        position: relative;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        padding: 0;
        gap: 0;
        border: none;
        border-radius: 999px;
        background: rgba(26, 26, 26, 0.05);
        color: var(--profile-text);
        cursor: pointer;
        transition: background 0.15s ease, color 0.15s ease;
    }

    .instr-search-toggle svg,
    .instr-extra .instr-sort-btn > svg {
        width: 17px;
        height: 17px;
    }

    .instr-search-toggle[aria-expanded="true"],
    .instr-extra .instr-sort.open .instr-sort-btn {
        background: var(--accent-solid);
        color: #ffffff;
        box-shadow: none;
    }

    .instr-extra .instr-sort-label,
    .instr-extra .instr-sort-value,
    .instr-extra .instr-sort-chevron {
        display: none;
    }

    /* Punkt = Suche bzw. Sortierung weicht vom Standard ab */
    .instr-search-toggle.is-custom::after,
    .instr-extra .instr-sort.is-custom .instr-sort-btn::after {
        content: "";
        position: absolute;
        top: 5px;
        right: 5px;
        width: 7px;
        height: 7px;
        border-radius: 50%;
        background: var(--accent-solid);
        box-shadow: 0 0 0 2px var(--profile-white);
    }

    .instr-search-toggle[aria-expanded="true"]::after {
        display: none;
    }

    body.dark .instr-search-toggle,
    body.dark .instr-extra .instr-sort-btn {
        background: rgba(255, 255, 255, 0.07);
    }

    body.dark .instr-search-toggle[aria-expanded="true"],
    body.dark .instr-extra .instr-sort.open .instr-sort-btn {
        background: var(--accent-solid);
    }

    /* Inhalts-Toolbar nur bei geöffneter Suche, dann nur das Suchfeld */
    .instr-toolbar {
        display: none;
        margin-top: -8px;
    }

    .instr-toolbar.is-search-open {
        display: flex;
        animation: instrSortIn 0.16s cubic-bezier(0.16, 1, 0.3, 1) both;
    }

    .instr-toolbar-end {
        display: none;
    }

    .instr-search {
        flex: 1 1 100%;
        height: 42px;
    }

    .instr-toolbar:not(.is-search-open) + .instr-results {
        padding-top: 0;
    }
}
