.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-2);
}

.header-brand {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    min-width: 0;
    flex-shrink: 0;
}

.brand-mark {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--color-primary), #7c3aed);
    flex-shrink: 0;
    position: relative;
}

.brand-mark::after {
    content: "";
    position: absolute;
    inset: 6px;
    border-radius: 5px;
    border: 2px solid rgba(255, 255, 255, 0.55);
}

.brand-name {
    font-weight: 700;
    font-size: var(--font-size-lg);
    letter-spacing: -0.02em;
    white-space: nowrap;
    flex-shrink: 0;
}

.btn-icon {
    width: var(--touch-min);
    height: var(--touch-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-md);
    color: var(--color-text);
    transition: background var(--transition-fast), color var(--transition-fast);
}

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

.btn-icon:hover:not(:disabled) {
    background: var(--color-surface-muted);
    color: var(--color-primary);
}

.btn-accent {
    height: var(--touch-min);
    padding: 0 var(--space-4);
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    border-radius: var(--radius-md);
    background: var(--color-primary);
    color: #fff;
    font-weight: 600;
    transition: background var(--transition-fast), transform var(--transition-fast);
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.btn-accent svg {
    width: 20px;
    height: 20px;
}

.btn-accent:hover {
    background: var(--color-primary-hover);
}

.btn-accent:active {
    transform: translateY(1px);
}

/* Bottom toolbar buttons */
.bottom-tool {
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    color: var(--color-text-muted);
    font-size: var(--font-size-xs);
    font-weight: 600;
    border-radius: var(--radius-md);
    transition: color var(--transition-fast), background var(--transition-fast);
    position: relative;
}

/* Arabic tool names are one or two words; keep them on one line and let the
   button size (not the label) decide how narrow the row gets. */
.bottom-tool > span {
    max-width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bottom-tool svg {
    width: 24px;
    height: 24px;
}

.bottom-tool:hover {
    color: var(--color-text);
}

.bottom-tool.active {
    color: var(--color-primary);
}

.bottom-tool.active::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 32px;
    height: 3px;
    border-radius: 0 0 3px 3px;
    background: var(--color-primary);
}

/* Mobile "selected element" quick actions */
.el-quickbar {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    position: absolute;
    top: var(--space-3);
    left: 50%;
    transform: translateX(-50%);
    /* above .sheet-backdrop (45) so the actions stay usable while the
       bottom sheet is open; the sheet itself (50) still paints on top */
    z-index: 46;
    max-width: calc(100% - var(--space-6));
}

.quick-btn {
    flex: 0 0 auto;
    width: var(--touch-min);
    height: var(--touch-min);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border-radius: var(--radius-md);
    border: 1px solid var(--color-border);
    background: var(--color-surface);
    color: var(--color-text);
    cursor: pointer;
    transition: background var(--transition-fast), color var(--transition-fast),
        border-color var(--transition-fast);
}

.quick-btn svg {
    width: 22px;
    height: 22px;
}

.quick-btn:hover {
    background: var(--color-surface-muted);
    color: var(--color-primary);
    border-color: var(--color-border-strong);
}

.quick-btn:active {
    transform: translateY(1px);
}

.quick-btn.danger:hover {
    color: var(--color-danger);
    background: rgba(220, 38, 38, 0.08);
}

/* Context menu */
.context-menu {
    display: none;
    position: fixed;
    z-index: 60;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    padding: var(--space-2);
    min-width: 180px;
}

.context-menu.open {
    display: block;
}

.context-menu button {
    display: flex;
    width: 100%;
    align-items: center;
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    color: var(--color-text);
    text-align: start;
    transition: background var(--transition-fast);
}

.context-menu button:hover {
    background: var(--color-primary-soft);
    color: var(--color-primary);
}

/* Toast */
.toast {
    position: fixed;
    bottom: calc(var(--bottom-bar-height) + var(--safe-bottom) + var(--space-4));
    left: 50%;
    transform: translateX(-50%) translateY(16px);
    background: var(--color-text);
    color: #fff;
    padding: var(--space-3) var(--space-5);
    border-radius: var(--radius-lg);
    font-size: var(--font-size-sm);
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-med), transform var(--transition-med);
    z-index: 70;
    max-width: calc(100% - var(--space-8));
    text-align: center;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast.error {
    background: var(--color-danger);
}

.toast.success {
    background: #16a34a;
}

/* Floating language switcher below the header. */
.lang-fab {
    position: absolute;
    top: calc(var(--header-height) + var(--space-2));
    inset-inline-end: var(--space-3);
    z-index: 35;
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    font-size: var(--font-size-xs);
    font-weight: 700;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.lang-fab svg {
    width: 16px;
    height: 16px;
}

/* Floating dark-mode switcher: opposite side from the language FAB. */
.theme-fab {
    position: absolute;
    top: calc(var(--header-height) + var(--space-2));
    inset-inline-start: var(--space-3);
    z-index: 35;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    color: var(--color-text-muted);
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 999px;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
}

.theme-fab svg {
    width: 18px;
    height: 18px;
}

/* Clear-all button: centered under the work area. */
.clear-all-fab {
    position: absolute;
    bottom: var(--space-3);
    left: 50%;
    transform: translateX(-50%);
    z-index: 25;
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    font-size: var(--font-size-sm);
    font-weight: 700;
    color: var(--color-danger);
    background: var(--color-surface);
    border: 1px solid var(--color-danger);
    border-radius: 999px;
    box-shadow: var(--shadow-md);
    cursor: pointer;
}

.clear-all-fab[hidden] {
    display: none;
}

.clear-all-fab svg {
    width: 18px;
    height: 18px;
}

/* Bottom sheet close button. */
.sheet-close {
    position: absolute;
    top: var(--space-2);
    inset-inline-end: var(--space-3);
    z-index: 2;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    color: var(--color-text-muted);
    background: var(--color-surface-muted);
    border: none;
    border-radius: 999px;
    cursor: pointer;
}

.sheet-close svg {
    width: 16px;
    height: 16px;
}
